Skip to content

Commit f110640

Browse files
Add additional tests
Signed-off-by: FedericoBruzzone <[email protected]>
1 parent 4810e27 commit f110640

6 files changed

+71
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(trivial_bounds)]
2+
3+
fn return_str()
4+
where
5+
str: Sized,
6+
{
7+
[(); { let _a: Option<str> = None; 0 }];
8+
//~^ ERROR evaluation of constant value failed
9+
}
10+
11+
fn main() {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0080]: evaluation of constant value failed
2+
--> $DIR/uncomputable-due-to-trivial-bounds-ice-135138.rs:7:16
3+
|
4+
LL | [(); { let _a: Option<str> = None; 0 }];
5+
| ^^ the type `Option<str>` has an unknown layout
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0080`.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![feature(trivial_bounds)]
2+
3+
// The absence of `ERROR~` is because the span of the error is not reported
4+
// in the snippet, but in `core/src/mem/mod.rs`.
5+
6+
trait Project {
7+
type Assoc;
8+
}
9+
10+
fn foo() where (): Project {
11+
[(); size_of::<<() as Project>::Assoc>()];
12+
}
13+
14+
fn main() {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0080]: evaluation of constant value failed
2+
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
3+
|
4+
= note: the type `<() as Project>::Assoc` has an unknown layout
5+
|
6+
note: inside `std::mem::size_of::<<() as Project>::Assoc>`
7+
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
8+
note: inside `foo::{constant#0}`
9+
--> $DIR/unknown-when-no-type-parameter.rs:11:10
10+
|
11+
LL | [(); size_of::<<() as Project>::Assoc>()];
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13+
14+
error: aborting due to 1 previous error
15+
16+
For more information about this error, try `rustc --explain E0080`.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![feature(ptr_metadata)]
2+
#![feature(trivial_bounds)]
3+
4+
fn return_str()
5+
where
6+
str: std::ptr::Pointee<Metadata = str>,
7+
{
8+
[(); { let _a: Option<&str> = None; 0 }];
9+
//~^ ERROR evaluation of constant value failed
10+
}
11+
12+
fn main() {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0080]: evaluation of constant value failed
2+
--> $DIR/unknown-when-ptr-metadata-is-1zst.rs:8:16
3+
|
4+
LL | [(); { let _a: Option<&str> = None; 0 }];
5+
| ^^ the type `str` has an unknown layout
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)