Skip to content

Commit 70612b7

Browse files
committed
reorganize tests a bit
1 parent e7f4399 commit 70612b7

17 files changed

+20
-9
lines changed

tests/ui/consts/monomorphization/dead-code-in-called-fn.rs renamed to tests/ui/consts/required-consts/dead-code-in-called-fn.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ impl<T> Fail<T> {
1313
fn called<T>() {
1414
// Any function that is called is guaranteed to have all consts that syntactically
1515
// appear in its body evaluated, even if they only appear in dead code.
16+
// This relies on mono-item collection checking `required_consts` in collected functions.
1617
if false {
1718
let _ = Fail::<T>::C;
1819
}

tests/ui/consts/monomorphization/dead-code-in-const-called-fn.no-opt.stderr renamed to tests/ui/consts/required-consts/dead-code-in-const-called-fn.no-opt.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | const C: () = panic!();
77
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
88

99
note: erroneous constant encountered
10-
--> $DIR/dead-code-in-const-called-fn.rs:16:9
10+
--> $DIR/dead-code-in-const-called-fn.rs:17:9
1111
|
1212
LL | Fail::<T>::C;
1313
| ^^^^^^^^^^^^

tests/ui/consts/monomorphization/dead-code-in-const-called-fn.opt.stderr renamed to tests/ui/consts/required-consts/dead-code-in-const-called-fn.opt.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | const C: () = panic!();
77
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
88

99
note: erroneous constant encountered
10-
--> $DIR/dead-code-in-const-called-fn.rs:16:9
10+
--> $DIR/dead-code-in-const-called-fn.rs:17:9
1111
|
1212
LL | Fail::<T>::C;
1313
| ^^^^^^^^^^^^

tests/ui/consts/monomorphization/dead-code-in-const-called-fn.rs renamed to tests/ui/consts/required-consts/dead-code-in-const-called-fn.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const fn no_codegen<T>() {
1313
if false {
1414
// This bad constant is only used in dead code in a no-codegen function... and yet we still
1515
// must make sure that the build fails.
16+
// This relies on const-eval evaluating all `required_consts` of `const fn`.
1617
Fail::<T>::C; //~ constant
1718
}
1819
}

tests/ui/consts/monomorphization/dead-code-in-dead-fn.rs renamed to tests/ui/consts/required-consts/dead-code-in-dead-fn.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ impl<T> Fail<T> {
1111

1212
// This function is not actually called, but it is mentioned in dead code in a function that is
1313
// called. Make sure we still find this error.
14+
// This relies on mono-item collection checking `required_consts` in functions that syntactically
15+
// are called in collected functions (even inside dead code).
1416
#[inline(never)]
1517
fn not_called<T>() {
16-
let _ = Fail::<T>::C;
18+
if false {
19+
let _ = Fail::<T>::C;
20+
}
1721
}
1822

1923
#[inline(never)]

tests/ui/consts/monomorphization/dead-code-in-dead-vtable.no-opt.stderr renamed to tests/ui/consts/required-consts/dead-code-in-dead-vtable.no-opt.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ LL | const C: () = panic!();
77
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
88

99
note: the above error was encountered while instantiating `fn <std::vec::Vec<i32> as MyTrait>::not_called`
10-
--> $DIR/dead-code-in-dead-vtable.rs:28:40
10+
--> $DIR/dead-code-in-dead-vtable.rs:30:40
1111
|
12-
LL | let gen_vtable: &dyn MyTrait = &v;
12+
LL | let gen_vtable: &dyn MyTrait = &v; // vtable "appears" here
1313
| ^^
1414

1515
error: aborting due to 1 previous error

tests/ui/consts/monomorphization/dead-code-in-dead-vtable.rs renamed to tests/ui/consts/required-consts/dead-code-in-dead-vtable.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,21 @@ trait MyTrait {
1515

1616
// This function is not actually called, but it is mentioned in a vtable in a function that is
1717
// called. Make sure we still find this error.
18+
// This relies on mono-item collection checking `required_consts` in functions that are referenced
19+
// in vtables that syntactically appear in collected functions (even inside dead code).
1820
impl<T> MyTrait for Vec<T> {
1921
fn not_called(&self) {
20-
let _ = Fail::<T>::C;
22+
if false {
23+
let _ = Fail::<T>::C;
24+
}
2125
}
2226
}
2327

2428
#[inline(never)]
2529
fn called<T>() {
2630
if false {
2731
let v: Vec<T> = Vec::new();
28-
let gen_vtable: &dyn MyTrait = &v;
32+
let gen_vtable: &dyn MyTrait = &v; // vtable "appears" here
2933
}
3034
}
3135

tests/ui/consts/monomorphization/dead-code-in-static.no-opt.stderr renamed to tests/ui/consts/required-consts/dead-code-in-static.no-opt.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | const C: () = panic!();
77
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
88

99
note: erroneous constant encountered
10-
--> $DIR/dead-code-in-static.rs:15:9
10+
--> $DIR/dead-code-in-static.rs:16:9
1111
|
1212
LL | Fail::<i32>::C;
1313
| ^^^^^^^^^^^^^^

tests/ui/consts/monomorphization/dead-code-in-static.opt.stderr renamed to tests/ui/consts/required-consts/dead-code-in-static.opt.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | const C: () = panic!();
77
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
88

99
note: erroneous constant encountered
10-
--> $DIR/dead-code-in-static.rs:15:9
10+
--> $DIR/dead-code-in-static.rs:16:9
1111
|
1212
LL | Fail::<i32>::C;
1313
| ^^^^^^^^^^^^^^

tests/ui/consts/monomorphization/dead-code-in-static.rs renamed to tests/ui/consts/required-consts/dead-code-in-static.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub static FOO: () = {
1212
if false {
1313
// This bad constant is only used in dead code in a static initializer... and yet we still
1414
// must make sure that the build fails.
15+
// This relies on const-eval evaluating all `required_consts` of the `static` MIR body.
1516
Fail::<i32>::C; //~ constant
1617
}
1718
};

0 commit comments

Comments
 (0)