-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Use structured suggestion for disambiguating method calls #67127
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
8083dde
to
d1dc69e
Compare
d1dc69e
to
8c4f1d5
Compare
| --^^^-- | ||
| | | | ||
| | multiple `foo` found | ||
| help: disambiguate the method call for candidate #2: `T::foo(&x)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there only one disambiguation suggestion here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code for this is
trait T {
fn foo(&self);
}
impl<'a> dyn T + 'a {
fn foo(&self) {}
}
impl T for i32 {
fn foo(&self) {}
}
fn main() {
let x: &dyn T = &0i32;
x.foo(); //~ ERROR multiple applicable items in scope [E0034]
}
I'm not sure what the appropriate syntax would be to call (&dyn T)::foo
. Also note that we were already not suggesting it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also note that we were already not suggesting it.
I did notice this. I think we ought to open a new issue — if the user can't specify (&dyn T)::foo
, we should at least explain this in the diagnostic. But this PR looks good as it is.
@bors r+ |
📌 Commit 8c4f1d5 has been approved by |
🌲 The tree is currently closed for pull requests below priority 100, this pull request will be tested once the tree is reopened |
…=varkor Use structured suggestion for disambiguating method calls Fix rust-lang#65635.
…=varkor Use structured suggestion for disambiguating method calls Fix rust-lang#65635.
…=varkor Use structured suggestion for disambiguating method calls Fix rust-lang#65635.
…=varkor Use structured suggestion for disambiguating method calls Fix rust-lang#65635.
Rollup of 7 pull requests Successful merges: - rust-lang#66670 (Normalize ident) - rust-lang#66755 (Remove a const-if-hack in RawVec) - rust-lang#67127 (Use structured suggestion for disambiguating method calls) - rust-lang#67281 (add string.insert benchmarks) - rust-lang#67328 (Remove now-redundant range check on u128 -> f32 casts) - rust-lang#67392 (Fix unresolved type span inside async object) - rust-lang#67421 (Fix internal documentation typo) Failed merges: r? @ghost
Rollup of 7 pull requests Successful merges: - rust-lang#66670 (Normalize ident) - rust-lang#66755 (Remove a const-if-hack in RawVec) - rust-lang#67127 (Use structured suggestion for disambiguating method calls) - rust-lang#67281 (add string.insert benchmarks) - rust-lang#67328 (Remove now-redundant range check on u128 -> f32 casts) - rust-lang#67392 (Fix unresolved type span inside async object) - rust-lang#67421 (Fix internal documentation typo) Failed merges: r? @ghost
Rollup of 7 pull requests Successful merges: - rust-lang#66670 (Normalize ident) - rust-lang#66755 (Remove a const-if-hack in RawVec) - rust-lang#67127 (Use structured suggestion for disambiguating method calls) - rust-lang#67281 (add string.insert benchmarks) - rust-lang#67328 (Remove now-redundant range check on u128 -> f32 casts) - rust-lang#67392 (Fix unresolved type span inside async object) - rust-lang#67421 (Fix internal documentation typo) Failed merges: r? @ghost
…=varkor Use structured suggestion for disambiguating method calls Fix rust-lang#65635.
…=varkor Use structured suggestion for disambiguating method calls Fix rust-lang#65635.
Rollup of 7 pull requests Successful merges: - #66755 (Remove a const-if-hack in RawVec) - #67127 (Use structured suggestion for disambiguating method calls) - #67219 (Fix up Command Debug output when arg0 is specified.) - #67285 (Indicate origin of where type parameter for uninferred types ) - #67328 (Remove now-redundant range check on u128 -> f32 casts) - #67367 (Move command line option definitions into a dedicated file) - #67442 (Remove `SOCK_CLOEXEC` dummy variable on platforms that don't use it.) Failed merges: r? @ghost
Fix #65635.