-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #90819 - JakobDegen:issue-90804, r=petrochenkov
Fixes incorrect handling of TraitRefs when emitting suggestions. Closes #90804 , although there were more issues here that were hidden by the thing that caused this ICE. Underlying problem was that substitutions were being thrown out, which not only leads to an ICE but also incorrect diagnostics. On top of that, in some cases the self types from the root obligations were being mixed in with those from derived obligations. This makes a couple diagnostics arguable worse ("`B<C>` does not implement `Copy`" instead of "`C` does not implement `Copy`") but the worse diagnostics are at least still correct and that downside is in my opinion clearly outweighed by the benefits of fixing the ICE and unambiguously wrong diagnostics.
- Loading branch information
Showing
5 changed files
with
55 additions
and
50 deletions.
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
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
11 changes: 11 additions & 0 deletions
11
src/test/ui/typeck/issue-90804-incorrect-reference-suggestion.rs
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,11 @@ | ||
// Do not suggest referencing the parameter to `check` | ||
|
||
trait Marker<T> {} | ||
|
||
impl<T> Marker<i32> for T {} | ||
|
||
pub fn check<T: Marker<u32>>(_: T) {} | ||
|
||
pub fn main() { | ||
check::<()>(()); //~ ERROR [E0277] | ||
} |
17 changes: 17 additions & 0 deletions
17
src/test/ui/typeck/issue-90804-incorrect-reference-suggestion.stderr
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,17 @@ | ||
error[E0277]: the trait bound `(): Marker<u32>` is not satisfied | ||
--> $DIR/issue-90804-incorrect-reference-suggestion.rs:10:17 | ||
| | ||
LL | check::<()>(()); | ||
| ----------- ^^ the trait `Marker<u32>` is not implemented for `()` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
note: required by a bound in `check` | ||
--> $DIR/issue-90804-incorrect-reference-suggestion.rs:7:17 | ||
| | ||
LL | pub fn check<T: Marker<u32>>(_: T) {} | ||
| ^^^^^^^^^^^ required by this bound in `check` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |