Closed
Description
pub trait Example {
fn query<Q>(self, q: Q);
}
impl Example for i32 {
fn query<Q>(self, _: Q) {
unimplemented!()
}
}
mod nested {
use super::Example;
fn example() {
1.query::<dyn ToString>("")
}
}
error: the `query` method cannot be invoked on a trait object
--> src/lib.rs:14:11
|
14 | 1.query::<dyn ToString>("")
| ^^^^^
|
= note: another candidate was found in the following trait, perhaps add a `use` for it:
`use crate::Example;`
Issues with this diagnostic:
- The
query
method is not being invoked on a trait object; it's invoked on the concrete value1
. - The note suggests importing the same trait that is already being reported about.
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 that should be reworked.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.