-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Avoid ICE when Canonicalizer.infcx
is None
#119416
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 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
16 changes: 16 additions & 0 deletions
16
tests/ui/coherence/with-negative-coherence-issue-119381.rs
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,16 @@ | ||
#![feature(with_negative_coherence)] | ||
|
||
#[derive(Copy)] | ||
struct S<const N: [f32; N]>(); | ||
//~^ ERROR the type of const parameters must not depend on other generic parameters [E0770] | ||
//~^^ ERROR the type of const parameters must not depend on other generic parameters [E0770] | ||
//~^^^ ERROR `[f32; N]` is forbidden as the type of a const generic parameter | ||
//~^^^^ ERROR `[f32; N]` is forbidden as the type of a const generic parameter | ||
|
||
#[derive(Copy)] | ||
//~^ ERROR the trait bound `S<N>: Clone` is not satisfied [E0277] | ||
//~^^ the constant `N` is not of type `[f32; {const error}]` | ||
struct S<const N: usize>([f32; N]); | ||
//~^ ERROR the name `S` is defined multiple times [E0428] | ||
|
||
fn main() {} |
79 changes: 79 additions & 0 deletions
79
tests/ui/coherence/with-negative-coherence-issue-119381.stderr
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,79 @@ | ||
error[E0428]: the name `S` is defined multiple times | ||
--> $DIR/with-negative-coherence-issue-119381.rs:13:1 | ||
| | ||
LL | struct S<const N: [f32; N]>(); | ||
| ------------------------------ previous definition of the type `S` here | ||
... | ||
LL | struct S<const N: usize>([f32; N]); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `S` redefined here | ||
| | ||
= note: `S` must be defined only once in the type namespace of this module | ||
|
||
error[E0770]: the type of const parameters must not depend on other generic parameters | ||
--> $DIR/with-negative-coherence-issue-119381.rs:4:25 | ||
| | ||
LL | struct S<const N: [f32; N]>(); | ||
| ^ the type must not depend on the parameter `N` | ||
| | ||
= note: const parameters may not be used in the type of const parameters | ||
|
||
error[E0770]: the type of const parameters must not depend on other generic parameters | ||
--> $DIR/with-negative-coherence-issue-119381.rs:4:25 | ||
| | ||
LL | struct S<const N: [f32; N]>(); | ||
| ^ the type must not depend on the parameter `N` | ||
| | ||
= note: const parameters may not be used in the type of const parameters | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: `[f32; N]` is forbidden as the type of a const generic parameter | ||
--> $DIR/with-negative-coherence-issue-119381.rs:4:19 | ||
| | ||
LL | struct S<const N: [f32; N]>(); | ||
| ^^^^^^^^ | ||
| | ||
= note: the only supported types are integers, `bool` and `char` | ||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | ||
|
||
error: `[f32; N]` is forbidden as the type of a const generic parameter | ||
--> $DIR/with-negative-coherence-issue-119381.rs:4:19 | ||
| | ||
LL | struct S<const N: [f32; N]>(); | ||
| ^^^^^^^^ | ||
| | ||
= note: the only supported types are integers, `bool` and `char` | ||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error[E0277]: the trait bound `S<N>: Clone` is not satisfied | ||
--> $DIR/with-negative-coherence-issue-119381.rs:10:10 | ||
| | ||
LL | #[derive(Copy)] | ||
| ^^^^ the trait `Clone` is not implemented for `S<N>` | ||
| | ||
note: required by a bound in `Copy` | ||
--> $SRC_DIR/core/src/marker.rs:LL:COL | ||
= note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: consider annotating `S<N>` with `#[derive(Clone)]` | ||
| | ||
LL + #[derive(Clone)] | ||
LL | struct S<const N: [f32; N]>(); | ||
| | ||
|
||
error: the constant `N` is not of type `[f32; {const error}]` | ||
--> $DIR/with-negative-coherence-issue-119381.rs:10:10 | ||
| | ||
LL | #[derive(Copy)] | ||
| ^^^^ expected `[f32; {const error}]`, found `usize` | ||
| | ||
note: required by a bound in `S` | ||
--> $DIR/with-negative-coherence-issue-119381.rs:4:10 | ||
| | ||
LL | struct S<const N: [f32; N]>(); | ||
| ^^^^^^^^^^^^^^^^^ required by this bound in `S` | ||
= note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 7 previous errors | ||
|
||
Some errors have detailed explanations: E0277, E0428, E0770. | ||
For more information about an error, try `rustc --explain E0277`. |
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.
The title of this issue doesn't really explain why it's an ICE. Specifically, there's no explanation for why we're encountering an inference variable in the type of a constant inside of a param-env, which is why this ICE occurs.