Skip to content

Commit 93405e1

Browse files
committed
add test involving opaque types
1 parent a7e6391 commit 93405e1

3 files changed

+74
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0080]: evaluation of `m::Fail::<i32>::C` failed
2+
--> $DIR/collect-in-dead-fn-behind-opaque-type.rs:10:23
3+
|
4+
LL | const C: () = panic!();
5+
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-fn-behind-opaque-type.rs:10:23
6+
|
7+
= 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)
8+
9+
note: erroneous constant encountered
10+
--> $DIR/collect-in-dead-fn-behind-opaque-type.rs:17:21
11+
|
12+
LL | let _ = Fail::<T>::C;
13+
| ^^^^^^^^^^^^
14+
15+
note: the above error was encountered while instantiating `fn m::not_called::<i32>`
16+
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
17+
18+
error: aborting due to 1 previous error
19+
20+
For more information about this error, try `rustc --explain E0080`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0080]: evaluation of `m::Fail::<i32>::C` failed
2+
--> $DIR/collect-in-dead-fn-behind-opaque-type.rs:10:23
3+
|
4+
LL | const C: () = panic!();
5+
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-fn-behind-opaque-type.rs:10:23
6+
|
7+
= 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)
8+
9+
note: erroneous constant encountered
10+
--> $DIR/collect-in-dead-fn-behind-opaque-type.rs:17:21
11+
|
12+
LL | let _ = Fail::<T>::C;
13+
| ^^^^^^^^^^^^
14+
15+
note: the above error was encountered while instantiating `fn m::not_called::<i32>`
16+
--> $DIR/collect-in-dead-fn-behind-opaque-type.rs:28:42
17+
|
18+
LL | let x: m::NotCalledFn = unsafe { std::mem::transmute(()) };
19+
| ^^^^^^^^^^^^^^^^^^^^^^^
20+
21+
error: aborting due to 1 previous error
22+
23+
For more information about this error, try `rustc --explain E0080`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//@revisions: noopt opt
2+
//@ build-fail
3+
//@[opt] compile-flags: -O
4+
//! This fails without optimizations, so it should also fail with optimizations.
5+
#![feature(type_alias_impl_trait)]
6+
7+
mod m {
8+
struct Fail<T>(T);
9+
impl<T> Fail<T> {
10+
const C: () = panic!(); //~ERROR evaluation of `m::Fail::<i32>::C` failed
11+
}
12+
13+
pub type NotCalledFn = impl Fn();
14+
15+
fn not_called<T>() {
16+
if false {
17+
let _ = Fail::<T>::C;
18+
}
19+
}
20+
21+
fn mk_not_called() -> NotCalledFn {
22+
not_called::<i32>
23+
}
24+
}
25+
26+
fn main() {
27+
if false {
28+
let x: m::NotCalledFn = unsafe { std::mem::transmute(()) };
29+
x();
30+
}
31+
}

0 commit comments

Comments
 (0)