]> git.lizzy.rs Git - rust.git/commitdiff
reword Miri validity errors: undefined -> uninitialized
authorRalf Jung <post@ralfj.de>
Wed, 15 Apr 2020 10:18:20 +0000 (12:18 +0200)
committerRalf Jung <post@ralfj.de>
Wed, 15 Apr 2020 11:38:07 +0000 (13:38 +0200)
src/librustc_mir/interpret/validity.rs
src/test/ui/consts/const-eval/ub-wide-ptr.stderr
src/test/ui/consts/const-eval/union-ice.stderr

index 701e394415bbdde8d27b3063282073587bd091b1..d60f6f38d07f2daa4a43e47eaa183cfe23bff9db 100644 (file)
@@ -322,7 +322,11 @@ fn check_safe_pointer(
         let value = self.ecx.read_immediate(value)?;
         // Handle wide pointers.
         // Check metadata early, for better diagnostics
-        let place = try_validation!(self.ecx.ref_to_mplace(value), "undefined pointer", self.path);
+        let place = try_validation!(
+            self.ecx.ref_to_mplace(value),
+            format_args!("uninitialized {}", kind),
+            self.path
+        );
         if place.layout.is_unsized() {
             self.check_wide_ptr_meta(place.meta, place.layout)?;
         }
@@ -334,7 +338,7 @@ fn check_safe_pointer(
                     format_args!("invalid {} metadata: {}", kind, msg),
                     self.path
                 ),
-                _ => bug!("Unexpected error during ptr size_and_align_of: {}", err),
+                _ => bug!("unexpected error during ptr size_and_align_of: {}", err),
             },
         };
         let (size, align) = size_and_align
@@ -477,10 +481,11 @@ fn try_visit_primitive(
             }
             ty::RawPtr(..) => {
                 // We are conservative with undef for integers, but try to
-                // actually enforce our current rules for raw pointers.
+                // actually enforce the strict rules for raw pointers (mostly because
+                // that lets us re-use `ref_to_mplace`).
                 let place = try_validation!(
                     self.ecx.ref_to_mplace(self.ecx.read_immediate(value)?),
-                    "undefined pointer",
+                    "uninitialized raw pointer",
                     self.path
                 );
                 if place.layout.is_unsized() {
@@ -776,14 +781,14 @@ fn visit_aggregate(
                         // For some errors we might be able to provide extra information
                         match err.kind {
                             err_ub!(InvalidUndefBytes(Some(ptr))) => {
-                                // Some byte was undefined, determine which
+                                // Some byte was uninitialized, determine which
                                 // element that byte belongs to so we can
                                 // provide an index.
                                 let i = usize::try_from(ptr.offset.bytes() / layout.size.bytes())
                                     .unwrap();
                                 self.path.push(PathElem::ArrayElem(i));
 
-                                throw_validation_failure!("undefined bytes", self.path)
+                                throw_validation_failure!("uninitialized value", self.path)
                             }
                             // Other errors shouldn't be possible
                             _ => return Err(err),
index 80e60dbb58a5d6adf5f74cc191158f2a3b218c36..f12753e5dcacc38b80a4e9db6480a995bf94f5dd 100644 (file)
@@ -62,7 +62,7 @@ LL | |
 LL | |     let uninit_len = MaybeUninit::<usize> { uninit: () };
 LL | |     mem::transmute((42, uninit_len))
 LL | | };
-   | |__^ type validation failed: encountered undefined pointer
+   | |__^ type validation failed: encountered uninitialized reference
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
 
@@ -130,7 +130,7 @@ LL | |
 LL | |     let uninit_len = MaybeUninit::<usize> { uninit: () };
 LL | |     mem::transmute((42, uninit_len))
 LL | | };
-   | |__^ type validation failed: encountered undefined pointer
+   | |__^ type validation failed: encountered uninitialized raw pointer
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
 
index 476f3651740ab7041722ad63a20d69a73186875e..946c375ced7013283467686b4e1cf9c79f09093d 100644 (file)
@@ -27,7 +27,7 @@ LL | |         unsafe { UNION.field3 },
 ...  |
 LL | |     a: 42,
 LL | | };
-   | |__^ type validation failed: encountered undefined bytes at .b[1]
+   | |__^ type validation failed: encountered uninitialized value at .b[1]
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.