File tree 2 files changed +5
-3
lines changed
compiler/rustc_ty_utils/src
2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -273,9 +273,11 @@ fn adjust_for_rust_scalar<'tcx>(
273
273
| PointerKind :: UniqueBorrowed
274
274
| PointerKind :: UniqueBorrowedPinned => false ,
275
275
PointerKind :: UniqueOwned => noalias_for_box,
276
- PointerKind :: Frozen => !is_return ,
276
+ PointerKind :: Frozen => true ,
277
277
} ;
278
- if no_alias {
278
+ // We can never add `noalias` in return position; that LLVM attribute has some very surprising semantics
279
+ // (see <https://github.com/rust-lang/unsafe-code-guidelines/issues/385#issuecomment-1368055745>).
280
+ if no_alias && !is_return {
279
281
attrs. set ( ArgAttribute :: NoAlias ) ;
280
282
}
281
283
Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ pub fn raw_struct(_: *const S) {
145
145
146
146
// `Box` can get deallocated during execution of the function, so it should
147
147
// not get `dereferenceable`.
148
- // CHECK: noalias noundef nonnull align 4 {{i32\*|ptr}} @_box({{i32\*|ptr}} noalias noundef nonnull align 4 %x)
148
+ // CHECK: noundef nonnull align 4 {{i32\*|ptr}} @_box({{i32\*|ptr}} noalias noundef nonnull align 4 %x)
149
149
#[ no_mangle]
150
150
pub fn _box ( x : Box < i32 > ) -> Box < i32 > {
151
151
x
You can’t perform that action at this time.
0 commit comments