mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-02 10:18:25 +00:00

`&Freeze` parameters are not only `readonly` within the function, but any captures of the pointer can also only be used for reads. This can now be encoded using the `captures(address, read_provenance)` attribute.
19 lines
323 B
Rust
19 lines
323 B
Rust
//@ compile-flags: -C opt-level=3 -Z mir-opt-level=0
|
|
//@ min-llvm-version: 21
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
unsafe extern "C" {
|
|
safe fn do_something(p: &i32);
|
|
}
|
|
|
|
#[unsafe(no_mangle)]
|
|
pub fn test() -> i32 {
|
|
// CHECK-LABEL: @test(
|
|
// CHECK: ret i32 0
|
|
let i = 0;
|
|
do_something(&i);
|
|
do_something(&i);
|
|
i
|
|
}
|