make sure we don't inline these generic fn as that could monomorphize them

This commit is contained in:
Ralf Jung 2024-03-21 09:03:49 +01:00
parent 0cb1065d7e
commit 8c01b85dba
9 changed files with 12 additions and 6 deletions

View File

@ -7,7 +7,7 @@ LL | const C: () = panic!();
= 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)
note: erroneous constant encountered
--> $DIR/collect-in-dead-fn-behind-assoc-type.rs:15:17
--> $DIR/collect-in-dead-fn-behind-assoc-type.rs:16:17
|
LL | let _ = Fail::<T>::C;
| ^^^^^^^^^^^^

View File

@ -7,7 +7,7 @@ LL | const C: () = panic!();
= 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)
note: erroneous constant encountered
--> $DIR/collect-in-dead-fn-behind-assoc-type.rs:15:17
--> $DIR/collect-in-dead-fn-behind-assoc-type.rs:16:17
|
LL | let _ = Fail::<T>::C;
| ^^^^^^^^^^^^

View File

@ -10,12 +10,14 @@ impl<T> Fail<T> {
const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed
}
#[inline(never)]
fn not_called<T>() {
if false {
let _ = Fail::<T>::C;
}
}
#[inline(never)]
fn callit_not(f: impl Fn()) {
if false {
f();
@ -33,6 +35,7 @@ impl Hideaway for () {
const C: Self::T = not_called::<i32>;
}
#[inline(never)]
fn reveal<T: Hideaway>() {
if false {
callit_not(T::C);

View File

@ -7,7 +7,7 @@ LL | const C: () = panic!();
= 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)
note: erroneous constant encountered
--> $DIR/collect-in-dead-fn-behind-generic.rs:14:17
--> $DIR/collect-in-dead-fn-behind-generic.rs:15:17
|
LL | let _ = Fail::<T>::C;
| ^^^^^^^^^^^^

View File

@ -7,7 +7,7 @@ LL | const C: () = panic!();
= 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)
note: erroneous constant encountered
--> $DIR/collect-in-dead-fn-behind-generic.rs:14:17
--> $DIR/collect-in-dead-fn-behind-generic.rs:15:17
|
LL | let _ = Fail::<T>::C;
| ^^^^^^^^^^^^

View File

@ -9,12 +9,14 @@ impl<T> Fail<T> {
const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed
}
#[inline(never)]
fn not_called<T>() {
if false {
let _ = Fail::<T>::C;
}
}
#[inline(never)]
fn callit_not(f: impl Fn()) {
if false {
f();

View File

@ -7,7 +7,7 @@ LL | const C: () = panic!();
= 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)
note: erroneous constant encountered
--> $DIR/collect-in-dead-fn-behind-opaque-type.rs:18:21
--> $DIR/collect-in-dead-fn-behind-opaque-type.rs:19:21
|
LL | let _ = Fail::<T>::C;
| ^^^^^^^^^^^^

View File

@ -7,7 +7,7 @@ LL | const C: () = panic!();
= 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)
note: erroneous constant encountered
--> $DIR/collect-in-dead-fn-behind-opaque-type.rs:18:21
--> $DIR/collect-in-dead-fn-behind-opaque-type.rs:19:21
|
LL | let _ = Fail::<T>::C;
| ^^^^^^^^^^^^

View File

@ -13,6 +13,7 @@ mod m {
pub type NotCalledFn = impl Fn();
#[inline(never)]
fn not_called<T>() {
if false {
let _ = Fail::<T>::C;