Open
Description
Code
trait Trait {}
mod m {
pub trait Trait {}
pub struct St;
impl Trait for St {}
}
fn func<T: Trait>(_: T) {}
fn main() {
func(m::St);
}
Current output
Compiling playground v0.0.1 (/playground)
error[E0277]: the trait bound `St: Trait` is not satisfied
--> src/main.rs:12:10
|
12 | func(m::St);
| ---- ^^^^^ the trait `Trait` is not implemented for `St`
| |
| required by a bound introduced by this call
|
help: this trait has no implementations, consider adding one
--> src/main.rs:1:1
|
1 | trait Trait {}
| ^^^^^^^^^^^
note: required by a bound in `func`
--> src/main.rs:9:12
|
9 | fn func<T: Trait>(_: T) {}
| ^^^^^ required by this bound in `func`
Desired output
Compiling playground v0.0.1 (/playground)
error[E0277]: the trait bound `St: Trait` is not satisfied
--> src/main.rs:12:10
|
12 | func(m::St);
| ---- ^^^^^ the trait `Trait` is not implemented for `St`
| |
| required by a bound introduced by this call
|
note: `St` implements similarly named `crate::m::Trait`, but not `crate::Trait`
help: this trait has no implementations, consider adding one
--> src/main.rs:1:1
|
1 | trait Trait {}
| ^^^^^^^^^^^
note: required by a bound in `func`
--> src/main.rs:9:12
|
9 | fn func<T: Trait>(_: T) {}
| ^^^^^ required by this bound in `func`
Rationale and extra context
This can easily happen if you accidentally have two different versions of the same crate in your dependency tree (see this URLO thread), or have two dependencies that use different trait for the same thing (eg. tokio::io::AsyncRead
and futures_io::AsyncRead
)
Other cases
Should also probably trigger if the implemented trait has a small enough edit distance between it and the desired trait, similar to the help messages for misspelled methods and types.
Rust Version
1.82.0
Anything else?
No response