diff --git a/tests/codegen/noalias-freeze.rs b/tests/codegen/noalias-freeze.rs new file mode 100644 index 0000000000000..f0bcad4a0d821 --- /dev/null +++ b/tests/codegen/noalias-freeze.rs @@ -0,0 +1,21 @@ +//@ compile-flags: -Copt-level=1 + +// References returned by a Frozen pointer type +// could be marked as "noalias", which caused miscompilation errors. +// This test runs the most minimal possible code that can reproduce this bug, +// and checks that noalias does not appear. +// See https://github.com/rust-lang/rust/issues/46239 + +#![crate_type = "lib"] + +fn project(x: &(T,)) -> &T { &x.0 } + +fn dummy() {} + +// CHECK-LABEL: @foo( +// CHECK-NOT: noalias +#[no_mangle] +pub fn foo() { + let f = (dummy as fn(),); + (*project(&f))(); +} \ No newline at end of file diff --git a/tests/run-make/no-mark-noalias/main.rs b/tests/run-make/no-mark-noalias/main.rs deleted file mode 100644 index b7df5cf4d8128..0000000000000 --- a/tests/run-make/no-mark-noalias/main.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn project(x: &(T,)) -> &T { &x.0 } - -fn dummy() {} - -fn main() { - let f = (dummy as fn(),); - (*project(&f))(); -} diff --git a/tests/run-make/no-mark-noalias/rmake.rs b/tests/run-make/no-mark-noalias/rmake.rs deleted file mode 100644 index d47cc998961b6..0000000000000 --- a/tests/run-make/no-mark-noalias/rmake.rs +++ /dev/null @@ -1,14 +0,0 @@ -// In the rustc_trans crate, references returned by a Frozen pointer type -// could mark them as "noalias", which caused miscompilation errors. -// This test runs the most minimal possible code that can reproduce this bug, -// and checks that compilation remains successful. -// See https://github.com/rust-lang/rust/issues/46239 - -//@ ignore-cross-compile - -use run_make_support::{run, rustc}; - -fn main() { - rustc().input("main.rs").opt_level("1").run(); - run("main"); -}