]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/interpret/validity.rs
Rollup merge of #71508 - oli-obk:alloc_map_unlock, r=RalfJung
[rust.git] / src / librustc_mir / interpret / validity.rs
index 9f2e79bbee31ea71537372f21356aa9b6ff5a997..4f90f83b735d1e8c50adf02415ed26c17ecf6b0e 100644 (file)
@@ -321,11 +321,12 @@ fn check_wide_ptr_meta(
                 try_validation!(
                     self.ecx.read_drop_type_from_vtable(vtable),
                     self.path,
-                    err_ub!(InvalidDropFn(..)) |
                     err_ub!(DanglingIntPointer(..)) |
                     err_ub!(InvalidFunctionPointer(..)) |
                     err_unsup!(ReadBytesAsPointer) =>
-                        { "invalid drop function pointer in vtable" },
+                        { "invalid drop function pointer in vtable (not pointing to a function)" },
+                    err_ub!(InvalidDropFn(..)) =>
+                        { "invalid drop function pointer in vtable (function has incompatible signature)" },
                 );
                 try_validation!(
                     self.ecx.read_size_and_align_from_vtable(vtable),
@@ -365,7 +366,7 @@ fn check_safe_pointer(
         let place = try_validation!(
             self.ecx.ref_to_mplace(value),
             self.path,
-            err_ub!(InvalidUndefBytes(..)) => { "uninitialized {}", kind },
+            err_ub!(InvalidUninitBytes(..)) => { "uninitialized {}", kind },
         );
         if place.layout.is_unsized() {
             self.check_wide_ptr_meta(place.meta, place.layout)?;
@@ -400,7 +401,7 @@ fn check_safe_pointer(
             err_ub!(DanglingIntPointer(0, _)) =>
                 { "a NULL {}", kind },
             err_ub!(DanglingIntPointer(i, _)) =>
-                { "a dangling {} (address {} is unallocated)", kind, i },
+                { "a dangling {} (address 0x{:x} is unallocated)", kind, i },
             err_ub!(PointerOutOfBounds { .. }) =>
                 { "a dangling {} (going beyond the bounds of its allocation)", kind },
             err_unsup!(ReadBytesAsPointer) =>
@@ -415,7 +416,7 @@ fn check_safe_pointer(
             if let Some(ptr) = ptr {
                 // not a ZST
                 // Skip validation entirely for some external statics
-                let alloc_kind = self.ecx.tcx.alloc_map.lock().get(ptr.alloc_id);
+                let alloc_kind = self.ecx.tcx.get_global_alloc(ptr.alloc_id);
                 if let Some(GlobalAlloc::Static(did)) = alloc_kind {
                     // See const_eval::machine::MemoryExtra::can_access_statics for why
                     // this check is so important.
@@ -513,7 +514,7 @@ fn try_visit_primitive(
                 let place = try_validation!(
                     self.ecx.ref_to_mplace(self.ecx.read_immediate(value)?),
                     self.path,
-                    err_ub!(InvalidUndefBytes(..)) => { "uninitialized raw pointer" },
+                    err_ub!(InvalidUninitBytes(..)) => { "uninitialized raw pointer" },
                 );
                 if place.layout.is_unsized() {
                     self.check_wide_ptr_meta(place.meta, place.layout)?;
@@ -592,7 +593,7 @@ fn visit_scalar(
         let value = try_validation!(
             value.not_undef(),
             self.path,
-            err_ub!(InvalidUndefBytes(..)) => { "{}", value }
+            err_ub!(InvalidUninitBytes(..)) => { "{}", value }
                 expected { "something {}", wrapping_range_format(valid_range, max_hi) },
         );
         let bits = match value.to_bits_or_ptr(op.layout.size, self.ecx) {
@@ -802,7 +803,7 @@ fn visit_aggregate(
                         // For some errors we might be able to provide extra information.
                         // (This custom logic does not fit the `try_validation!` macro.)
                         match err.kind {
-                            err_ub!(InvalidUndefBytes(Some(ptr))) => {
+                            err_ub!(InvalidUninitBytes(Some(ptr))) => {
                                 // Some byte was uninitialized, determine which
                                 // element that byte belongs to so we can
                                 // provide an index.