File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
compiler/rustc_ty_utils/src Expand file tree Collapse file tree 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>(
273273 | PointerKind :: UniqueBorrowed
274274 | PointerKind :: UniqueBorrowedPinned => false ,
275275 PointerKind :: UniqueOwned => noalias_for_box,
276- PointerKind :: Frozen => !is_return ,
276+ PointerKind :: Frozen => true ,
277277 } ;
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 {
279281 attrs. set ( ArgAttribute :: NoAlias ) ;
280282 }
281283
Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ pub fn raw_struct(_: *const S) {
145145
146146// `Box` can get deallocated during execution of the function, so it should
147147// 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)
149149#[ no_mangle]
150150pub fn _box ( x : Box < i32 > ) -> Box < i32 > {
151151 x
You can’t perform that action at this time.
0 commit comments