-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Don't ICE for kind mismatches during error rendering #123673
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,24 @@ | ||
//! This test used to ICE in typeck because of the type/const mismatch, | ||
//! even though wfcheck already errored. | ||
//! issue: rust-lang/rust#123457 | ||
|
||
pub struct KeyHolder<const K: u8> {} | ||
|
||
pub trait ContainsKey<const K: u8> {} | ||
|
||
pub trait SubsetExcept<P> {} | ||
|
||
impl<K> ContainsKey<K> for KeyHolder<K> {} | ||
//~^ ERROR: type provided when a constant was expected | ||
//~| ERROR: type provided when a constant was expected | ||
|
||
impl<P, T: ContainsKey<0>> SubsetExcept<P> for T {} | ||
|
||
pub fn remove_key<K, S: SubsetExcept<K>>() -> S { | ||
loop {} | ||
} | ||
|
||
fn main() { | ||
let map: KeyHolder<0> = remove_key::<_, _>(); | ||
//~^ ERROR: the trait bound `KeyHolder<0>: SubsetExcept<_>` is not satisfied | ||
} |
This file contains hidden or 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,39 @@ | ||
error[E0747]: type provided when a constant was expected | ||
--> $DIR/kind_mismatch.rs:11:38 | ||
| | ||
LL | impl<K> ContainsKey<K> for KeyHolder<K> {} | ||
| - ^ | ||
| | | ||
| help: consider changing this type parameter to a const parameter: `const K: u8` | ||
|
||
error[E0747]: type provided when a constant was expected | ||
--> $DIR/kind_mismatch.rs:11:21 | ||
| | ||
LL | impl<K> ContainsKey<K> for KeyHolder<K> {} | ||
| - ^ | ||
| | | ||
| help: consider changing this type parameter to a const parameter: `const K: u8` | ||
|
||
error[E0277]: the trait bound `KeyHolder<0>: SubsetExcept<_>` is not satisfied | ||
--> $DIR/kind_mismatch.rs:22:45 | ||
| | ||
LL | let map: KeyHolder<0> = remove_key::<_, _>(); | ||
| ^ the trait `ContainsKey<0>` is not implemented for `KeyHolder<0>`, which is required by `KeyHolder<0>: SubsetExcept<_>` | ||
| | ||
note: required for `KeyHolder<0>` to implement `SubsetExcept<_>` | ||
--> $DIR/kind_mismatch.rs:15:28 | ||
| | ||
LL | impl<P, T: ContainsKey<0>> SubsetExcept<P> for T {} | ||
| -------------- ^^^^^^^^^^^^^^^ ^ | ||
| | | ||
| unsatisfied trait bound introduced here | ||
note: required by a bound in `remove_key` | ||
--> $DIR/kind_mismatch.rs:17:25 | ||
| | ||
LL | pub fn remove_key<K, S: SubsetExcept<K>>() -> S { | ||
| ^^^^^^^^^^^^^^^ required by this bound in `remove_key` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0277, E0747. | ||
For more information about an error, try `rustc --explain E0277`. |
Oops, something went wrong.
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.
Please add an issue number for ICE test:
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.
As nice as it is to have the issue in the test itself (and helps with traceability in the future even when files move around), I find that 99% of the time I'm able to get to the ticket by finding the PR that introduced the file. It's good practice to add as much info as possible inline, but we should avoid holding up a PR when that's the only comment to address (some new contributors will just not have the bandwidth to address comments and might get put off by such a request, where accepting their PRs directly increases the likelihood of them coming back).
I'm wondering if we could try and automate this, make
.x,py tidy
check for test files that are introduced in the current branch that aren't inmaster
, check against github to see if there's an open PR for the current branch, and if that PR saysFixes #XXXXXX
. If so, complain about the lack of a link :)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.
Yeah, probably a good idea to make this somewhat automated