-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
do not ICE on bound variables, return TooGeneric
instead
#76581
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// compile-flags: -Zsave-analysis | ||
|
||
#![feature(const_generics)] | ||
#![allow(incomplete_features)] | ||
struct Arr<const N: usize> | ||
where Assert::<{N < usize::max_value() / 2}>: IsTrue, //~ ERROR constant expression | ||
{ | ||
} | ||
|
||
enum Assert<const CHECK: bool> {} | ||
|
||
trait IsTrue {} | ||
|
||
impl IsTrue for Assert<true> {} | ||
|
||
fn main() { | ||
let x: Arr<{usize::max_value()}> = Arr {}; | ||
//~^ ERROR mismatched types | ||
//~| ERROR mismatched types | ||
} |
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,29 @@ | ||
error: constant expression depends on a generic parameter | ||
--> $DIR/issue-73260.rs:6:47 | ||
| | ||
LL | where Assert::<{N < usize::max_value() / 2}>: IsTrue, | ||
| ^^^^^^ | ||
| | ||
= note: this may fail depending on what value the parameter takes | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-73260.rs:17:12 | ||
| | ||
LL | let x: Arr<{usize::max_value()}> = Arr {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `false`, found `true` | ||
| | ||
= note: expected type `false` | ||
found type `true` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-73260.rs:17:40 | ||
| | ||
LL | let x: Arr<{usize::max_value()}> = Arr {}; | ||
| ^^^ expected `false`, found `true` | ||
| | ||
= note: expected type `false` | ||
found type `true` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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,27 @@ | ||
#![feature(const_generics)] | ||
#![allow(incomplete_features)] | ||
|
||
trait If<const COND: bool> {} | ||
impl If<true> for () {} | ||
|
||
trait IsZero<const N: u8> { | ||
type Answer; | ||
} | ||
|
||
struct True; | ||
struct False; | ||
|
||
impl<const N: u8> IsZero<N> for () | ||
where (): If<{N == 0}> { //~ERROR constant expression | ||
type Answer = True; | ||
} | ||
|
||
trait Foobar<const N: u8> {} | ||
|
||
impl<const N: u8> Foobar<N> for () | ||
where (): IsZero<N, Answer = True> {} | ||
|
||
impl<const N: u8> Foobar<N> for () | ||
where (): IsZero<N, Answer = False> {} | ||
|
||
fn main() {} |
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,10 @@ | ||
error: constant expression depends on a generic parameter | ||
--> $DIR/issue-74634.rs:15:11 | ||
| | ||
LL | where (): If<{N == 0}> { | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: this may fail depending on what value the parameter takes | ||
|
||
error: aborting due to previous error | ||
|
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,18 @@ | ||
#![feature(const_generics, const_evaluatable_checked)] | ||
#![allow(incomplete_features)] | ||
|
||
struct Bool<const B: bool>; | ||
|
||
trait True {} | ||
|
||
impl True for Bool<true> {} | ||
|
||
fn test<T, const P: usize>() where Bool<{core::mem::size_of::<T>() > 4}>: True { | ||
todo!() | ||
} | ||
|
||
fn main() { | ||
test::<2>(); | ||
//~^ ERROR wrong number of type | ||
//~| ERROR constant expression depends | ||
} |
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,20 @@ | ||
error[E0107]: wrong number of type arguments: expected 1, found 0 | ||
--> $DIR/issue-76595.rs:15:5 | ||
| | ||
LL | test::<2>(); | ||
| ^^^^^^^^^ expected 1 type argument | ||
|
||
error: constant expression depends on a generic parameter | ||
--> $DIR/issue-76595.rs:15:5 | ||
| | ||
LL | fn test<T, const P: usize>() where Bool<{core::mem::size_of::<T>() > 4}>: True { | ||
| ---- required by this bound in `test` | ||
... | ||
LL | test::<2>(); | ||
| ^^^^^^^^^ | ||
| | ||
= note: this may fail depending on what value the parameter takes | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0107`. |
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.
I think this is something I suggested in the past so it's probably fine.