-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LTA: Check where-clauses for well-formedness at the def site
- Loading branch information
Showing
6 changed files
with
99 additions
and
11 deletions.
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 at the definition site for well-formedness. | ||
#![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`. |
13 changes: 13 additions & 0 deletions
13
tests/ui/lazy-type-alias/def-site-predicates-wf.current.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,13 @@ | ||
error[E0277]: the size for values of type `str` cannot be known at compilation time | ||
--> $DIR/def-site-predicates-wf.rs:11:5 | ||
| | ||
LL | <Vec<str> as Discard>::Output:; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
23 changes: 23 additions & 0 deletions
23
tests/ui/lazy-type-alias/def-site-predicates-wf.next.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,23 @@ | ||
error[E0277]: the size for values of type `str` cannot be known at compilation time | ||
--> $DIR/def-site-predicates-wf.rs:11:5 | ||
| | ||
LL | <Vec<str> as Discard>::Output:; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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:16:36 | ||
| | ||
LL | <Vec<str> as Discard>::Output: 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`. |
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 @@ | ||
//! Ensure that we check the predicates at the definition site for well-formedness. | ||
#![feature(lazy_type_alias)] | ||
#![allow(incomplete_features)] | ||
|
||
//@ revisions: current next | ||
//@[next] compile-flags: -Znext-solver | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
|
||
type Alias0 = () | ||
where | ||
<Vec<str> as Discard>::Output:; //~ ERROR the size for values of type `str` cannot be known at compilation time | ||
|
||
// FIXME(#100041): This should error in the current solver, too. | ||
type Alias1 = () | ||
where | ||
<Vec<str> as Discard>::Output: Sized; //[next]~ ERROR the size for values of type `str` cannot be known at compilation time | ||
|
||
trait Discard { type Output; } | ||
impl<T> Discard for T { type Output = (); } | ||
|
||
fn main() {} |