-
Notifications
You must be signed in to change notification settings - Fork 13.3k
LTA: Actually check where-clauses for well-formedness at the def site #136432
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
+78
−11
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//! Ensure that we check generic parameter defaults for well-formedness at the definition site. | ||
#![feature(lazy_type_alias)] | ||
#![allow(incomplete_features)] | ||
|
||
type Alias<T = Vec<str>, const N: usize = {0 - 1}> = T; | ||
//~^ ERROR evaluation of constant value failed | ||
//~| ERROR the size for values of type `str` cannot be known at compilation time | ||
|
||
fn main() {} |
20 changes: 20 additions & 0 deletions
20
tests/ui/lazy-type-alias/def-site-param-defaults-wf.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,20 @@ | ||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/def-site-param-defaults-wf.rs:5:44 | ||
| | ||
LL | type Alias<T = Vec<str>, const N: usize = {0 - 1}> = T; | ||
| ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow | ||
|
||
error[E0277]: the size for values of type `str` cannot be known at compilation time | ||
--> $DIR/def-site-param-defaults-wf.rs:5:16 | ||
| | ||
LL | type Alias<T = Vec<str>, const N: usize = {0 - 1}> = T; | ||
| ^^^^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `str` | ||
note: required by an implicit `Sized` bound in `Vec` | ||
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0080, E0277. | ||
For more information about an error, try `rustc --explain E0080`. |
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,13 @@ | ||
//! Ensure that we check the predicates at the definition site for well-formedness. | ||
#![feature(lazy_type_alias)] | ||
#![allow(incomplete_features)] | ||
|
||
type Alias0 = () | ||
where | ||
Vec<str>:; //~ ERROR the size for values of type `str` cannot be known at compilation time | ||
|
||
type Alias1 = () | ||
where | ||
Vec<str>: Sized; //~ ERROR the size for values of type `str` cannot be known at compilation time | ||
|
||
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,23 @@ | ||
error[E0277]: the size for values of type `str` cannot be known at compilation time | ||
--> $DIR/def-site-predicates-wf.rs:7:5 | ||
| | ||
LL | Vec<str>:; | ||
| ^^^^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `str` | ||
note: required by an implicit `Sized` bound in `Vec` | ||
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | ||
|
||
error[E0277]: the size for values of type `str` cannot be known at compilation time | ||
--> $DIR/def-site-predicates-wf.rs:11:15 | ||
| | ||
LL | Vec<str>: Sized; | ||
| ^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `str` | ||
note: required by an implicit `Sized` bound in `Vec` | ||
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this 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.
I've basically just added
check_where_clause
and inlinedcheck_item_type
. I could've made it work without inlining but that wouldn't've been super nice (it's already quite branch-y and that would've made it worse)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.
Nah,
check_item_type
is jank and didn't really make sense since it's otherwise only used for consts/statics.