-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Rust: Make impl blocks only give rise to direct trait implementation #20723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -586,10 +586,10 @@ mod impl_overlap { | |
| println!("{:?}", w.m(x)); // $ target=S3<T>::m | ||
| println!("{:?}", S3::m(&w, x)); // $ target=S3<T>::m | ||
|
|
||
| S4.m(); // $ target=<S4_as_MyTrait1>::m $ SPURIOUS: target=MyTrait1::m | ||
| S4.m(); // $ target=<S4_as_MyTrait1>::m | ||
| S4::m(&S4); // $ target=<S4_as_MyTrait1>::m $ SPURIOUS: target=MyTrait1::m | ||
| S5(0i32).m(); // $ target=<S5<i32>_as_MyTrait1>::m $ SPURIOUS: target=MyTrait1::m | ||
| S5::m(&S5(0i32)); // $ target=<S5<i32>_as_MyTrait1>::m $ SPURIOUS: target=MyTrait1::m | ||
| S5(0i32).m(); // $ target=<S5<i32>_as_MyTrait1>::m | ||
| S5::m(&S5(0i32)); // $ target=<S5<i32>_as_MyTrait1>::m | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure why the second test did not get fixed, especially since it looks a lot like the fourth test. I'm guessing something more might be needed here, as the |
||
| S5(true).m(); // $ target=MyTrait1::m | ||
| S5::m(&S5(true)); // $ target=MyTrait1::m | ||
| } | ||
|
|
||
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.
Though this calls the version of
minimpl MyTrait1 for S4, if that did not overridemI believe Rust would in fact fall back to the implementation inMyTrait1. It's also possible that a function in a directImpl S4could be called here. I'm seeking reassurance that we will get the right call targets in expanded cases such as these: