Closed
Description
I meet a compile error can be demonstrated by the following code, and think it's irrational:
trait Train {
fn knots(&self) -> usize;
}
impl Train for str {
fn knots(&self) -> usize {
self.chars().count()
}
}
fn train_length<T:Train>(text: &'static T) -> usize {
text.knots()
}
fn str_length(text: &'static str) -> usize {
text.knots()
}
fn main() {
println!("{:?}", str_length("asdfas")); // works
println!("{:?}", train_length("asdfas")); // compile error
}
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Trait systemCategory: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.