-
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
Handle infer vars in anon consts on stable #132971
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
21 changes: 21 additions & 0 deletions
21
tests/ui/const-generics/failing_goal_with_repeat_expr_anon_const.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,21 @@ | ||
// Regression test for #132955 checking that we handle anon consts with | ||
// inference variables in their generic arguments correctly. | ||
// | ||
// This arose via diagnostics where we would have some failing goal such | ||
// as `[u8; AnonConst<Self>]: PartialEq<Self::A>`, then as part of diagnostics | ||
// we would replace all generic parameters with inference vars which would yield | ||
// a self type of `[u8; AnonConst<?x>]` and then attempt to normalize `AnonConst<?x>`. | ||
|
||
pub trait T { | ||
type A; | ||
const P: Self::A; | ||
|
||
fn a() { | ||
[0u8; std::mem::size_of::<Self::A>()] == Self::P; | ||
//~^ ERROR: can't compare | ||
//~| ERROR: constant expression depends on a generic parameter | ||
//~| ERROR: constant expression depends on a generic parameter | ||
} | ||
} | ||
|
||
fn main() {} |
31 changes: 31 additions & 0 deletions
31
tests/ui/const-generics/failing_goal_with_repeat_expr_anon_const.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,31 @@ | ||
error: constant expression depends on a generic parameter | ||
--> $DIR/failing_goal_with_repeat_expr_anon_const.rs:14:15 | ||
| | ||
LL | [0u8; std::mem::size_of::<Self::A>()] == Self::P; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this may fail depending on what value the parameter takes | ||
|
||
error: constant expression depends on a generic parameter | ||
--> $DIR/failing_goal_with_repeat_expr_anon_const.rs:14:47 | ||
| | ||
LL | [0u8; std::mem::size_of::<Self::A>()] == Self::P; | ||
| ^^ | ||
| | ||
= note: this may fail depending on what value the parameter takes | ||
|
||
error[E0277]: can't compare `[u8; std::mem::size_of::<Self::A>()]` with `<Self as T>::A` | ||
--> $DIR/failing_goal_with_repeat_expr_anon_const.rs:14:47 | ||
| | ||
LL | [0u8; std::mem::size_of::<Self::A>()] == Self::P; | ||
| ^^ no implementation for `[u8; std::mem::size_of::<Self::A>()] == <Self as T>::A` | ||
| | ||
= help: the trait `PartialEq<<Self as T>::A>` is not implemented for `[u8; std::mem::size_of::<Self::A>()]` | ||
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement | ||
| | ||
LL | pub trait T where [u8; std::mem::size_of::<Self::A>()]: PartialEq<<Self as T>::A> { | ||
| +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this 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.
Unrelated change: just wanted a better ICE message here so that it's easier to tell that any ICEs from here are caused by
generic_const_exprs
not some problem with not calling normalize here (#132960). I can split this out if you want but it felt a little silly to make a separate PR just to change an ICE message when I already have to make a PR to make a follow up change to the previous PR.