diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index dd3adbf70a62f..f5cbbc7ca9198 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -1365,7 +1365,7 @@ pub fn build_global_var_di_node<'ll>(cx: &CodegenCx<'ll, '_>, def_id: DefId, glo is_local_to_unit, global, None, - global_align.bytes() as u32, + global_align.bits() as u32, ); } } diff --git a/compiler/rustc_const_eval/src/interpret/cast.rs b/compiler/rustc_const_eval/src/interpret/cast.rs index 73cc59ad1e674..fb484fba9fd06 100644 --- a/compiler/rustc_const_eval/src/interpret/cast.rs +++ b/compiler/rustc_const_eval/src/interpret/cast.rs @@ -221,7 +221,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let addr = addr.to_machine_usize(self)?; // Then turn address into pointer. - let ptr = M::ptr_from_addr_cast(&self, addr); + let ptr = M::ptr_from_addr_cast(&self, addr)?; Ok(Scalar::from_maybe_pointer(ptr, self).into()) } diff --git a/compiler/rustc_const_eval/src/interpret/machine.rs b/compiler/rustc_const_eval/src/interpret/machine.rs index 3572a9cc68174..5377535b9fa08 100644 --- a/compiler/rustc_const_eval/src/interpret/machine.rs +++ b/compiler/rustc_const_eval/src/interpret/machine.rs @@ -294,11 +294,10 @@ pub trait Machine<'mir, 'tcx>: Sized { fn ptr_from_addr_cast( ecx: &InterpCx<'mir, 'tcx, Self>, addr: u64, - ) -> Pointer<Option<Self::PointerTag>>; + ) -> InterpResult<'tcx, Pointer<Option<Self::PointerTag>>>; - // FIXME: Transmuting an integer to a pointer should just always return a `None` - // provenance, but that causes problems with function pointers in Miri. /// Hook for returning a pointer from a transmute-like operation on an addr. + /// This is only needed to support Miri's (unsound) "allow-ptr-int-transmute" flag. fn ptr_from_addr_transmute( ecx: &InterpCx<'mir, 'tcx, Self>, addr: u64, @@ -519,8 +518,10 @@ pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) { fn ptr_from_addr_cast( _ecx: &InterpCx<$mir, $tcx, Self>, addr: u64, - ) -> Pointer<Option<AllocId>> { - Pointer::new(None, Size::from_bytes(addr)) + ) -> InterpResult<$tcx, Pointer<Option<AllocId>>> { + // Allow these casts, but make the pointer not dereferenceable. + // (I.e., they behave like transmutation.) + Ok(Pointer::new(None, Size::from_bytes(addr))) } #[inline(always)] diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 5190cd4493661..cabaf321f80c3 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -547,23 +547,6 @@ pub enum PrintRequest { LinkArgs, } -#[derive(Copy, Clone)] -pub enum BorrowckMode { - Mir, - Migrate, -} - -impl BorrowckMode { - /// Returns whether we should run the MIR-based borrow check, but also fall back - /// on the AST borrow check if the MIR-based one errors. - pub fn migrate(self) -> bool { - match self { - BorrowckMode::Mir => false, - BorrowckMode::Migrate => true, - } - } -} - pub enum Input { /// Load source code from a file. File(PathBuf), diff --git a/library/alloc/tests/lib.rs b/library/alloc/tests/lib.rs index ffc7944ec7e1b..367cdcdcc061c 100644 --- a/library/alloc/tests/lib.rs +++ b/library/alloc/tests/lib.rs @@ -7,7 +7,6 @@ #![feature(const_convert)] #![feature(const_cow_is_borrowed)] #![feature(const_heap)] -#![feature(const_intrinsic_copy)] #![feature(const_mut_refs)] #![feature(const_nonnull_slice_from_raw_parts)] #![feature(const_ptr_write)] diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 0b76790c0097e..7c10ed65c4c4c 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2118,11 +2118,11 @@ pub(crate) fn is_nonoverlapping<T>(src: *const T, dst: *const T, count: usize) - /// [`Vec::append`]: ../../std/vec/struct.Vec.html#method.append #[doc(alias = "memcpy")] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] +#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[inline] pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) { extern "rust-intrinsic" { - #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] + #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] pub fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize); } @@ -2200,11 +2200,11 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us /// ``` #[doc(alias = "memmove")] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] +#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[inline] pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) { extern "rust-intrinsic" { - #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] + #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] fn copy<T>(src: *const T, dst: *mut T, count: usize); } diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index cfcc3ffb9c092..093c7d298734a 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -114,7 +114,6 @@ #![feature(const_convert)] #![feature(const_inherent_unchecked_arith)] #![feature(const_int_unchecked_arith)] -#![feature(const_intrinsic_copy)] #![feature(const_intrinsic_forget)] #![feature(const_likely)] #![feature(const_maybe_uninit_uninit_array)] diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 490d7594bb82f..74aa0d9c7bcb2 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -1199,7 +1199,7 @@ impl<T: ?Sized> *const T { /// See [`ptr::copy`] for safety concerns and examples. /// /// [`ptr::copy`]: crate::ptr::copy() - #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] + #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub const unsafe fn copy_to(self, dest: *mut T, count: usize) @@ -1218,7 +1218,7 @@ impl<T: ?Sized> *const T { /// See [`ptr::copy_nonoverlapping`] for safety concerns and examples. /// /// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping() - #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] + #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize) diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index a3b4e5886ef68..8fb0bfbe2e31b 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -1136,7 +1136,7 @@ pub const unsafe fn read<T>(src: *const T) -> T { // We are calling the intrinsics directly to avoid function calls in the generated code // as `intrinsics::copy_nonoverlapping` is a wrapper function. extern "rust-intrinsic" { - #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] + #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize); } @@ -1331,7 +1331,7 @@ pub const unsafe fn write<T>(dst: *mut T, src: T) { // We are calling the intrinsics directly to avoid function calls in the generated code // as `intrinsics::copy_nonoverlapping` is a wrapper function. extern "rust-intrinsic" { - #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] + #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize); } diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index 5846c855e8f64..b988090f4bc4c 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -1311,7 +1311,7 @@ impl<T: ?Sized> *mut T { /// See [`ptr::copy`] for safety concerns and examples. /// /// [`ptr::copy`]: crate::ptr::copy() - #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] + #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline(always)] pub const unsafe fn copy_to(self, dest: *mut T, count: usize) @@ -1330,7 +1330,7 @@ impl<T: ?Sized> *mut T { /// See [`ptr::copy_nonoverlapping`] for safety concerns and examples. /// /// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping() - #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] + #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline(always)] pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize) @@ -1349,7 +1349,7 @@ impl<T: ?Sized> *mut T { /// See [`ptr::copy`] for safety concerns and examples. /// /// [`ptr::copy`]: crate::ptr::copy() - #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] + #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline(always)] pub const unsafe fn copy_from(self, src: *const T, count: usize) @@ -1368,7 +1368,7 @@ impl<T: ?Sized> *mut T { /// See [`ptr::copy_nonoverlapping`] for safety concerns and examples. /// /// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping() - #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] + #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline(always)] pub const unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize) diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 9505ec31609f5..7e9d7d2710180 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -84,7 +84,6 @@ #![feature(const_option)] #![feature(const_option_ext)] #![feature(const_result)] -#![feature(const_intrinsic_copy)] #![feature(integer_atomics)] #![feature(int_roundings)] #![feature(slice_group_by)] diff --git a/src/test/codegen/debug-alignment.rs b/src/test/codegen/debug-alignment.rs new file mode 100644 index 0000000000000..f6c1062e0fc6c --- /dev/null +++ b/src/test/codegen/debug-alignment.rs @@ -0,0 +1,8 @@ +// Verifies that DWARF alignment is specified properly. +// +// compile-flags: -C debuginfo=2 +#![crate_type = "lib"] + +// CHECK: !DIGlobalVariable +// CHECK: align: 32 +pub static A: u32 = 1; diff --git a/src/test/ui/consts/copy-intrinsic.rs b/src/test/ui/consts/copy-intrinsic.rs index 5ab90324b8f86..249bbb5991cc9 100644 --- a/src/test/ui/consts/copy-intrinsic.rs +++ b/src/test/ui/consts/copy-intrinsic.rs @@ -2,14 +2,14 @@ // ignore-tidy-linelength #![feature(intrinsics, staged_api)] -#![feature(const_mut_refs, const_intrinsic_copy)] +#![feature(const_mut_refs)] use std::mem; extern "rust-intrinsic" { - #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] + #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize); - #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] + #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] fn copy<T>(src: *const T, dst: *mut T, count: usize); } diff --git a/src/test/ui/consts/intrinsic_without_const_stab.rs b/src/test/ui/consts/intrinsic_without_const_stab.rs index d5f694986fc89..40ec65d51beec 100644 --- a/src/test/ui/consts/intrinsic_without_const_stab.rs +++ b/src/test/ui/consts/intrinsic_without_const_stab.rs @@ -1,8 +1,8 @@ -#![feature(intrinsics, staged_api, const_intrinsic_copy)] +#![feature(intrinsics, staged_api)] #![stable(feature = "core", since = "1.6.0")] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] +#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[inline] pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) { // Const stability attributes are not inherited from parent items. diff --git a/src/test/ui/consts/intrinsic_without_const_stab_fail.rs b/src/test/ui/consts/intrinsic_without_const_stab_fail.rs index 8b37268b0b205..2b0745b3c110c 100644 --- a/src/test/ui/consts/intrinsic_without_const_stab_fail.rs +++ b/src/test/ui/consts/intrinsic_without_const_stab_fail.rs @@ -1,4 +1,4 @@ -#![feature(intrinsics, staged_api, const_intrinsic_copy)] +#![feature(intrinsics, staged_api)] #![stable(feature = "core", since = "1.6.0")] extern "rust-intrinsic" { @@ -6,7 +6,7 @@ extern "rust-intrinsic" { } #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] +#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[inline] pub const unsafe fn stuff<T>(src: *const T, dst: *mut T, count: usize) { unsafe { copy(src, dst, count) } //~ ERROR cannot call non-const fn