-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Don't report numeric inference ambiguity when we have previous errors #95751
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
trait Fallback { | ||
fn foo(&self) {} | ||
} | ||
|
||
impl Fallback for i32 {} | ||
|
||
impl Fallback for u64 {} | ||
|
||
impl Fallback for usize {} | ||
|
||
fn main() { | ||
missing(); | ||
//~^ ERROR cannot find function `missing` in this scope | ||
0.foo(); | ||
// But then we shouldn't report an inference ambiguity here... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0425]: cannot find function `missing` in this scope | ||
--> $DIR/no-fallback-multiple-impls.rs:12:5 | ||
| | ||
LL | missing(); | ||
| ^^^^^^^ not found in this scope | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0425`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,35 +79,7 @@ LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); } | |
= note: required because of the requirements on the impl of `CoerceUnsized<Box<dyn bar>>` for `Box<{integer}>` | ||
= note: required by cast to type `Box<dyn bar>` | ||
|
||
error[E0283]: type annotations needed | ||
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. hehe, wonderful to see this issue getting better too |
||
--> $DIR/test-2.rs:9:8 | ||
| | ||
LL | 10.dup::<i32>(); | ||
| ^^^ cannot infer type for type `{integer}` | ||
| | ||
note: multiple `impl`s satisfying `{integer}: bar` found | ||
--> $DIR/test-2.rs:5:1 | ||
| | ||
LL | impl bar for i32 { fn dup(&self) -> i32 { *self } fn blah<X>(&self) {} } | ||
| ^^^^^^^^^^^^^^^^ | ||
LL | impl bar for u32 { fn dup(&self) -> u32 { *self } fn blah<X>(&self) {} } | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error[E0283]: type annotations needed | ||
--> $DIR/test-2.rs:11:8 | ||
| | ||
LL | 10.blah::<i32, i32>(); | ||
| ^^^^ cannot infer type for type `{integer}` | ||
| | ||
note: multiple `impl`s satisfying `{integer}: bar` found | ||
--> $DIR/test-2.rs:5:1 | ||
| | ||
LL | impl bar for i32 { fn dup(&self) -> i32 { *self } fn blah<X>(&self) {} } | ||
| ^^^^^^^^^^^^^^^^ | ||
LL | impl bar for u32 { fn dup(&self) -> u32 { *self } fn blah<X>(&self) {} } | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 7 previous errors | ||
error: aborting due to 5 previous errors | ||
|
||
Some errors have detailed explanations: E0038, E0107, E0283. | ||
Some errors have detailed explanations: E0038, E0107. | ||
For more information about an error, try `rustc --explain E0038`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could this check just be simplified to "if the self type is a numeric infer"?
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.
So we need to check for int/float variables not just in self, but in the trait's substs as well, so we don't report the things that implement
ConcreteType: Trait<{integer}>
.Also removing the core/alloc/std crate name check leads to some regressions in errors reported with simd stuff and when we're unable to infer const variables due to other errors :/