Skip to content

Commit bc2c2b5

Browse files
Rollup merge of #157733 - hanna-kruppe:fixme-nocapture, r=mati865
Remove old FIXMEs about nocapture attribute As discussed in the long-closed issue referenced by the FIXMEs (#25759), it would be unsound to add nocapture to all reference arguments. The canonical example is taking &T and returning *const T, i.e., `std::ptr::from_ref`. Some of the removed test cases suggest that named vs elided vs static lifetime on the reference would make a difference for capturing, which is incompatible with all modern takes on Rust opsem. Hypothetically, we could add some kind of escape analysis on MIR to determine which arguments can be marked as nocapture. But LLVM can do that too (often better), so why should we? Plus, if we started doing such analysis, the test that had the FIXMEs would not be a good place to exercise it, as all the function bodies are trivial. Part of #44366
2 parents 5e01de4 + 460f825 commit bc2c2b5

1 file changed

Lines changed: 0 additions & 17 deletions

File tree

tests/codegen-llvm/function-arguments.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ pub fn option_nonzero_int(x: Option<NonZero<u64>>) -> Option<NonZero<u64>> {
8181
}
8282

8383
// CHECK: @readonly_borrow(ptr noalias nofree noundef readonly align 4{{( captures\(address, read_provenance\))?}} dereferenceable(4) %_1)
84-
// FIXME #25759 This should also have `nocapture`
8584
#[no_mangle]
8685
pub fn readonly_borrow(_: &i32) {}
8786

@@ -91,16 +90,6 @@ pub fn readonly_borrow_ret() -> &'static i32 {
9190
loop {}
9291
}
9392

94-
// CHECK: @static_borrow(ptr noalias nofree noundef readonly align 4{{( captures\(address, read_provenance\))?}} dereferenceable(4) %_1)
95-
// static borrow may be captured
96-
#[no_mangle]
97-
pub fn static_borrow(_: &'static i32) {}
98-
99-
// CHECK: @named_borrow(ptr noalias nofree noundef readonly align 4{{( captures\(address, read_provenance\))?}} dereferenceable(4) %_1)
100-
// borrow with named lifetime may be captured
101-
#[no_mangle]
102-
pub fn named_borrow<'r>(_: &'r i32) {}
103-
10493
// CHECK: @unsafe_borrow(ptr noundef nonnull align 2 %_1)
10594
// unsafe interior means this isn't actually readonly and there may be aliases ...
10695
#[no_mangle]
@@ -112,7 +101,6 @@ pub fn unsafe_borrow(_: &UnsafeInner) {}
112101
pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) {}
113102

114103
// CHECK: @mutable_borrow(ptr noalias nofree noundef align 4 dereferenceable(4) %_1)
115-
// FIXME #25759 This should also have `nocapture`
116104
#[no_mangle]
117105
pub fn mutable_borrow(_: &mut i32) {}
118106

@@ -139,7 +127,6 @@ pub fn notunpin_borrow(_: &NotUnpin) {}
139127
pub fn indirect_struct(_: S) {}
140128

141129
// CHECK: @borrowed_struct(ptr noalias nofree noundef readonly align 4{{( captures\(address, read_provenance\))?}} dereferenceable(32) %_1)
142-
// FIXME #25759 This should also have `nocapture`
143130
#[no_mangle]
144131
pub fn borrowed_struct(_: &S) {}
145132

@@ -196,14 +183,12 @@ pub fn helper(_: usize) {}
196183
// CHECK: @slice(
197184
// CHECK-SAME: ptr noalias nofree noundef nonnull readonly{{( captures\(address, read_provenance\))?}} %_1.0,
198185
// CHECK-SAME: [[USIZE]] noundef range({{i32 0, -2147483648|i64 0, -9223372036854775808}}) %_1.1)
199-
// FIXME #25759 This should also have `nocapture`
200186
#[no_mangle]
201187
pub fn slice(_: &[u8]) {}
202188

203189
// CHECK: @mutable_slice(
204190
// CHECK-SAME: ptr noalias nofree noundef nonnull %_1.0,
205191
// CHECK-SAME: [[USIZE]] noundef range({{i32 0, -2147483648|i64 0, -9223372036854775808}}) %_1.1)
206-
// FIXME #25759 This should also have `nocapture`
207192
#[no_mangle]
208193
pub fn mutable_slice(_: &mut [u8]) {}
209194

@@ -221,12 +206,10 @@ pub fn raw_slice(_: *const [u8]) {}
221206
// CHECK: @str(
222207
// CHECK-SAME: ptr noalias nofree noundef nonnull readonly{{( captures\(address, read_provenance\))?}} %_1.0,
223208
// CHECK-SAME: [[USIZE]] noundef range({{i32 0, -2147483648|i64 0, -9223372036854775808}}) %_1.1)
224-
// FIXME #25759 This should also have `nocapture`
225209
#[no_mangle]
226210
pub fn str(_: &[u8]) {}
227211

228212
// CHECK: @trait_borrow(ptr noundef nonnull %_1.0, {{.+}} noalias nofree noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1)
229-
// FIXME #25759 This should also have `nocapture`
230213
#[no_mangle]
231214
pub fn trait_borrow(_: &dyn Drop) {}
232215

0 commit comments

Comments
 (0)