]> git.lizzy.rs Git - rust.git/blob - tests/codegen/noalias-flag.rs
Rollup merge of #107731 - RalfJung:interpret-discriminant, r=cjgillot
[rust.git] / tests / codegen / noalias-flag.rs
1 // compile-flags: -O -Zmutable-noalias=no
2
3 #![crate_type = "lib"]
4
5 // `-Zmutable-noalias=no` should disable noalias on mut refs...
6
7 // CHECK-LABEL: @test_mut_ref(
8 // CHECK-NOT: noalias
9 // CHECK-SAME: %x
10 #[no_mangle]
11 pub fn test_mut_ref(x: &mut i32) -> &mut i32 {
12     x
13 }
14
15 // ...but not on shared refs
16
17 // CHECK-LABEL: @test_ref(
18 // CHECK-SAME: noalias
19 // CHECK-SAME: %x
20 #[no_mangle]
21 pub fn test_ref(x: &i32) -> &i32 {
22     x
23 }