]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #99307 - JohnTitor:issue-64401, r=compiler-errors
authorYuki Okushi <jtitor@2k36.org>
Sat, 16 Jul 2022 08:53:05 +0000 (17:53 +0900)
committerGitHub <noreply@github.com>
Sat, 16 Jul 2022 08:53:05 +0000 (17:53 +0900)
Add regression test for #64401

Closes #64401
r? `@compiler-errors`

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
23 files changed:
compiler/rustc_codegen_llvm/src/back/lto.rs
compiler/rustc_codegen_llvm/src/llvm/ffi.rs
compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
compiler/rustc_mir_dataflow/src/storage.rs
library/alloc/src/boxed.rs
library/alloc/src/ffi/c_str.rs
library/alloc/src/ffi/mod.rs
library/alloc/src/lib.rs
library/alloc/tests/lib.rs
library/core/src/ffi/c_str.rs
library/core/src/ffi/mod.rs
library/std/src/ffi/mod.rs
library/std/src/fs.rs
library/std/src/io/error.rs
library/std/src/io/error/repr_bitpacked.rs
library/std/src/io/error/repr_unpacked.rs
library/std/src/io/error/tests.rs
library/std/src/lib.rs
library/std/src/thread/mod.rs
src/test/debuginfo/basic-types-globals-lto.rs [new file with mode: 0644]
src/test/debuginfo/basic-types-globals.rs
src/test/ui/lint/unused/must-use-box-from-raw.rs [new file with mode: 0644]
src/test/ui/lint/unused/must-use-box-from-raw.stderr [new file with mode: 0644]

index 38402e0431379ffb3f5f83c7951591788e504c4c..be539499b5610cce4841e965ea2fed99fed9ba76 100644 (file)
@@ -325,20 +325,6 @@ fn fat_lto(
         drop(linker);
         save_temp_bitcode(cgcx, &module, "lto.input");
 
-        // Fat LTO also suffers from the invalid DWARF issue similar to Thin LTO.
-        // Here we rewrite all `DICompileUnit` pointers if there is only one `DICompileUnit`.
-        // This only works around the problem when codegen-units = 1.
-        // Refer to the comments in the `optimize_thin_module` function for more details.
-        let mut cu1 = ptr::null_mut();
-        let mut cu2 = ptr::null_mut();
-        unsafe { llvm::LLVMRustLTOGetDICompileUnit(llmod, &mut cu1, &mut cu2) };
-        if !cu2.is_null() {
-            let _timer =
-                cgcx.prof.generic_activity_with_arg("LLVM_fat_lto_patch_debuginfo", &*module.name);
-            unsafe { llvm::LLVMRustLTOPatchDICompileUnit(llmod, cu1) };
-            save_temp_bitcode(cgcx, &module, "fat-lto-after-patch");
-        }
-
         // Internalize everything below threshold to help strip out more modules and such.
         unsafe {
             let ptr = symbols_below_threshold.as_ptr();
@@ -769,7 +755,7 @@ pub unsafe fn optimize_thin_module(
         // an error.
         let mut cu1 = ptr::null_mut();
         let mut cu2 = ptr::null_mut();
-        llvm::LLVMRustLTOGetDICompileUnit(llmod, &mut cu1, &mut cu2);
+        llvm::LLVMRustThinLTOGetDICompileUnit(llmod, &mut cu1, &mut cu2);
         if !cu2.is_null() {
             let msg = "multiple source DICompileUnits found";
             return Err(write::llvm_err(&diag_handler, msg));
@@ -858,7 +844,7 @@ pub unsafe fn optimize_thin_module(
             let _timer = cgcx
                 .prof
                 .generic_activity_with_arg("LLVM_thin_lto_patch_debuginfo", thin_module.name());
-            llvm::LLVMRustLTOPatchDICompileUnit(llmod, cu1);
+            llvm::LLVMRustThinLTOPatchDICompileUnit(llmod, cu1);
             save_temp_bitcode(cgcx, &module, "thin-lto-after-patch");
         }
 
index 5ebc2d6139fc863b219646859d44fbb38868554a..0ad65e5d99bb48eeae12f61fb0c1a36e0ddd4fea 100644 (file)
@@ -2508,8 +2508,12 @@ pub fn LLVMRustGetBitcodeSliceFromObjectData(
         len: usize,
         out_len: &mut usize,
     ) -> *const u8;
-    pub fn LLVMRustLTOGetDICompileUnit(M: &Module, CU1: &mut *mut c_void, CU2: &mut *mut c_void);
-    pub fn LLVMRustLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
+    pub fn LLVMRustThinLTOGetDICompileUnit(
+        M: &Module,
+        CU1: &mut *mut c_void,
+        CU2: &mut *mut c_void,
+    );
+    pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
 
     pub fn LLVMRustLinkerNew(M: &Module) -> &mut Linker<'_>;
     pub fn LLVMRustLinkerAdd(
index 0f4973ebf7129bd55571a117fd2a1addc216d079..be8fbf7677bcfae16a6a8a0fa9316e9499c08e15 100644 (file)
@@ -1715,7 +1715,7 @@ LLVMRustGetBitcodeSliceFromObjectData(const char *data,
 // Rewrite all `DICompileUnit` pointers to the `DICompileUnit` specified. See
 // the comment in `back/lto.rs` for why this exists.
 extern "C" void
-LLVMRustLTOGetDICompileUnit(LLVMModuleRef Mod,
+LLVMRustThinLTOGetDICompileUnit(LLVMModuleRef Mod,
                                 DICompileUnit **A,
                                 DICompileUnit **B) {
   Module *M = unwrap(Mod);
@@ -1733,7 +1733,7 @@ LLVMRustLTOGetDICompileUnit(LLVMModuleRef Mod,
 // Rewrite all `DICompileUnit` pointers to the `DICompileUnit` specified. See
 // the comment in `back/lto.rs` for why this exists.
 extern "C" void
-LLVMRustLTOPatchDICompileUnit(LLVMModuleRef Mod, DICompileUnit *Unit) {
+LLVMRustThinLTOPatchDICompileUnit(LLVMModuleRef Mod, DICompileUnit *Unit) {
   Module *M = unwrap(Mod);
 
   // If the original source module didn't have a `DICompileUnit` then try to
index 566c9d2d5054e6d1bf4333d3aead9fdae586b552..c909648ea017ebbb49b4f06ccf5cb0c9fe286bfe 100644 (file)
@@ -4,9 +4,6 @@
 /// The set of locals in a MIR body that do not have `StorageLive`/`StorageDead` annotations.
 ///
 /// These locals have fixed storage for the duration of the body.
-//
-// FIXME: Currently, we need to traverse the entire MIR to compute this. We should instead store it
-// as a field in the `LocalDecl` for each `Local`.
 pub fn always_storage_live_locals(body: &mir::Body<'_>) -> BitSet<Local> {
     let mut always_live_locals = BitSet::new_filled(body.local_decls.len());
 
index d83bab7bbbdadd2d41bf9ef0e9bd8557dbb809ce..c1ceeb0deb837100e2b77cccfc7312a7889c5f00 100644 (file)
@@ -949,6 +949,7 @@ impl<T: ?Sized> Box<T> {
     /// [`Layout`]: crate::Layout
     #[stable(feature = "box_raw", since = "1.4.0")]
     #[inline]
+    #[must_use = "call `drop(from_raw(ptr))` if you intend to drop the `Box`"]
     pub unsafe fn from_raw(raw: *mut T) -> Self {
         unsafe { Self::from_raw_in(raw, Global) }
     }
index cde4219be84c22a0d0e7e5788699acb3a2bab977..ae61b1f1e8ed5f43496f959fb52108231dff61dd 100644 (file)
 /// and other memory errors.
 #[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone)]
 #[cfg_attr(not(test), rustc_diagnostic_item = "cstring_type")]
-#[unstable(feature = "alloc_c_string", issue = "94079")]
+#[stable(feature = "alloc_c_string", since = "1.64.0")]
 pub struct CString {
     // Invariant 1: the slice ends with a zero byte and has a length of at least one.
     // Invariant 2: the slice contains only one zero byte.
@@ -132,7 +132,7 @@ pub struct CString {
 /// let _: NulError = CString::new(b"f\0oo".to_vec()).unwrap_err();
 /// ```
 #[derive(Clone, PartialEq, Eq, Debug)]
-#[unstable(feature = "alloc_c_string", issue = "94079")]
+#[stable(feature = "alloc_c_string", since = "1.64.0")]
 pub struct NulError(usize, Vec<u8>);
 
 #[derive(Clone, PartialEq, Eq, Debug)]
@@ -157,7 +157,7 @@ enum FromBytesWithNulErrorKind {
 /// let _: FromVecWithNulError = CString::from_vec_with_nul(b"f\0oo".to_vec()).unwrap_err();
 /// ```
 #[derive(Clone, PartialEq, Eq, Debug)]
-#[unstable(feature = "alloc_c_string", issue = "94079")]
+#[stable(feature = "alloc_c_string", since = "1.64.0")]
 pub struct FromVecWithNulError {
     error_kind: FromBytesWithNulErrorKind,
     bytes: Vec<u8>,
@@ -223,7 +223,7 @@ pub fn into_bytes(self) -> Vec<u8> {
 /// This `struct` is created by [`CString::into_string()`]. See
 /// its documentation for more.
 #[derive(Clone, PartialEq, Eq, Debug)]
-#[unstable(feature = "alloc_c_string", issue = "94079")]
+#[stable(feature = "alloc_c_string", since = "1.64.0")]
 pub struct IntoStringError {
     inner: CString,
     error: Utf8Error,
index fec2bec566a8b6033c8a931e14c2d21fefdb658c..e8530fbc1f08f506bc1852b1a9537d3f980e74b3 100644 (file)
 //! [`String`]: crate::string::String
 //! [`CStr`]: core::ffi::CStr
 
-#![unstable(feature = "alloc_ffi", issue = "94079")]
+#![stable(feature = "alloc_ffi", since = "1.64.0")]
 
-#[unstable(feature = "alloc_c_string", issue = "94079")]
+#[stable(feature = "alloc_c_string", since = "1.64.0")]
 pub use self::c_str::FromVecWithNulError;
-#[unstable(feature = "alloc_c_string", issue = "94079")]
+#[stable(feature = "alloc_c_string", since = "1.64.0")]
 pub use self::c_str::{CString, IntoStringError, NulError};
 
 mod c_str;
index 541de5c902970a21e89198c8956c55bfee057520..315469387e5ae86a6499b90931382794df4f3d04 100644 (file)
@@ -86,7 +86,6 @@
 #![allow(explicit_outlives_requirements)]
 //
 // Library features:
-#![cfg_attr(not(no_global_oom_handling), feature(alloc_c_string))]
 #![feature(alloc_layout_extra)]
 #![feature(allocator_api)]
 #![feature(array_chunks)]
 #![feature(const_maybe_uninit_write)]
 #![feature(const_maybe_uninit_as_mut_ptr)]
 #![feature(const_refs_to_cell)]
-#![feature(core_c_str)]
 #![feature(core_intrinsics)]
 #![feature(const_eval_select)]
 #![feature(const_pin)]
index bf5d0c941e934f2db7dc0d53b7757b4364737ca1..c29e7b9c81efb0d985887809ccadaec3ff0d4092 100644 (file)
@@ -11,7 +11,6 @@
 #![feature(const_nonnull_slice_from_raw_parts)]
 #![feature(const_ptr_write)]
 #![feature(const_try)]
-#![feature(core_c_str)]
 #![feature(core_intrinsics)]
 #![feature(drain_filter)]
 #![feature(exact_size_is_empty)]
index 10bf95abd39594ae3a1d1652f35e90a105ae547a..ee9baf811e29c099c70d18323978f655a98e65a6 100644 (file)
@@ -76,7 +76,7 @@
 /// [str]: prim@str "str"
 #[derive(Hash)]
 #[cfg_attr(not(test), rustc_diagnostic_item = "CStr")]
-#[unstable(feature = "core_c_str", issue = "94079")]
+#[stable(feature = "core_c_str", since = "1.64.0")]
 #[rustc_has_incoherent_inherent_impls]
 // FIXME:
 // `fn from` in `impl From<&CStr> for Box<CStr>` current implementation relies
@@ -108,7 +108,7 @@ pub struct CStr {
 /// let _: FromBytesWithNulError = CStr::from_bytes_with_nul(b"f\0oo").unwrap_err();
 /// ```
 #[derive(Clone, PartialEq, Eq, Debug)]
-#[unstable(feature = "core_c_str", issue = "94079")]
+#[stable(feature = "core_c_str", since = "1.64.0")]
 pub struct FromBytesWithNulError {
     kind: FromBytesWithNulErrorKind,
 }
index 3b711c6b72d6d11acc540364cfc250ab2d02f146..ec1eaa99f0b8e756cb4c7c713180a6368dfac458 100644 (file)
@@ -14,7 +14,7 @@
 use crate::num::*;
 use crate::ops::{Deref, DerefMut};
 
-#[unstable(feature = "core_c_str", issue = "94079")]
+#[stable(feature = "core_c_str", since = "1.64.0")]
 pub use self::c_str::{CStr, FromBytesUntilNulError, FromBytesWithNulError};
 
 mod c_str;
index 484f42dafc3df4731d8541046a2e87db78ced972..d987bf69b25768919536407fde46130fec1005d4 100644 (file)
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-/// See [alloc::ffi::FromVecWithNulError].
-#[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")]
-pub type FromVecWithNulError = alloc::ffi::FromVecWithNulError;
-/// See [alloc::ffi::CString].
-#[stable(feature = "rust1", since = "1.0.0")]
-pub type CString = alloc::ffi::CString;
-/// See [alloc::ffi::IntoStringError].
-#[stable(feature = "rust1", since = "1.0.0")]
-pub type IntoStringError = alloc::ffi::IntoStringError;
-/// See [alloc::ffi::NulError].
-#[stable(feature = "rust1", since = "1.0.0")]
-pub type NulError = alloc::ffi::NulError;
-/// See [core::ffi::CStr].
-#[stable(feature = "rust1", since = "1.0.0")]
-pub type CStr = core::ffi::CStr;
-/// See [core::ffi::FromBytesWithNulError].
-#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
-pub type FromBytesWithNulError = core::ffi::FromBytesWithNulError;
+#[stable(feature = "alloc_c_string", since = "1.64.0")]
+pub use alloc::ffi::{CString, FromVecWithNulError, IntoStringError, NulError};
+#[stable(feature = "core_c_str", since = "1.64.0")]
+pub use core::ffi::{CStr, FromBytesWithNulError};
 
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use self::os_str::{OsStr, OsString};
index f46997b807ab230653d361ab92de59d16cc7ddef..d799776548a65b9d3e069c687d8ab143857d7a7c 100644 (file)
@@ -295,6 +295,9 @@ fn inner(path: &Path) -> io::Result<String> {
 /// This function will create a file if it does not exist,
 /// and will entirely replace its contents if it does.
 ///
+/// Depending on the platform, this function may fail if the
+/// full directory path does not exist.
+///
 /// This is a convenience function for using [`File::create`] and [`write_all`]
 /// with fewer imports.
 ///
@@ -349,6 +352,9 @@ pub fn open<P: AsRef<Path>>(path: P) -> io::Result<File> {
     /// This function will create a file if it does not exist,
     /// and will truncate it if it does.
     ///
+    /// Depending on the platform, this function may fail if the
+    /// full directory path does not exist.
+    ///
     /// See the [`OpenOptions::open`] function for more details.
     ///
     /// # Examples
index 4a50e647c640ef5bc813abbbe67f73a8b7b2af82..ff7fdcae16f535450124a904da0ecc2d36fc15f4 100644 (file)
@@ -795,6 +795,68 @@ pub fn into_inner(self) -> Option<Box<dyn error::Error + Send + Sync>> {
         }
     }
 
+    /// Attempt to downgrade the inner error to `E` if any.
+    ///
+    /// If this [`Error`] was constructed via [`new`] then this function will
+    /// attempt to perform downgrade on it, otherwise it will return [`Err`].
+    ///
+    /// If downgrade succeeds, it will return [`Ok`], otherwise it will also
+    /// return [`Err`].
+    ///
+    /// [`new`]: Error::new
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// #![feature(io_error_downcast)]
+    ///
+    /// use std::fmt;
+    /// use std::io;
+    /// use std::error::Error;
+    ///
+    /// #[derive(Debug)]
+    /// enum E {
+    ///     Io(io::Error),
+    ///     SomeOtherVariant,
+    /// }
+    ///
+    /// impl fmt::Display for E {
+    ///    // ...
+    /// #    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+    /// #        todo!()
+    /// #    }
+    /// }
+    /// impl Error for E {}
+    ///
+    /// impl From<io::Error> for E {
+    ///     fn from(err: io::Error) -> E {
+    ///         err.downcast::<E>()
+    ///             .map(|b| *b)
+    ///             .unwrap_or_else(E::Io)
+    ///     }
+    /// }
+    /// ```
+    #[unstable(feature = "io_error_downcast", issue = "99262")]
+    pub fn downcast<E>(self) -> result::Result<Box<E>, Self>
+    where
+        E: error::Error + Send + Sync + 'static,
+    {
+        match self.repr.into_data() {
+            ErrorData::Custom(b) if b.error.is::<E>() => {
+                let res = (*b).error.downcast::<E>();
+
+                // downcast is a really trivial and is marked as inline, so
+                // it's likely be inlined here.
+                //
+                // And the compiler should be able to eliminate the branch
+                // that produces `Err` here since b.error.is::<E>()
+                // returns true.
+                Ok(res.unwrap())
+            }
+            repr_data => Err(Self { repr: Repr::new(repr_data) }),
+        }
+    }
+
     /// Returns the corresponding [`ErrorKind`] for this error.
     ///
     /// # Examples
index e80068b46abb9f360f34957c5b3f1ea01c0ca641..292bf4826fd237a3d9dafe63b3d9ae1b5deac1d5 100644 (file)
@@ -132,6 +132,15 @@ unsafe impl Send for Repr {}
 unsafe impl Sync for Repr {}
 
 impl Repr {
+    pub(super) fn new(dat: ErrorData<Box<Custom>>) -> Self {
+        match dat {
+            ErrorData::Os(code) => Self::new_os(code),
+            ErrorData::Simple(kind) => Self::new_simple(kind),
+            ErrorData::SimpleMessage(simple_message) => Self::new_simple_message(simple_message),
+            ErrorData::Custom(b) => Self::new_custom(b),
+        }
+    }
+
     pub(super) fn new_custom(b: Box<Custom>) -> Self {
         let p = Box::into_raw(b).cast::<u8>();
         // Should only be possible if an allocator handed out a pointer with
index 3729c039c42d70553482fe6a74511d60017547c1..d6ad55b99f5c0aef5abe2d413084b1e2a84d0033 100644 (file)
 pub(super) struct Repr(Inner);
 
 impl Repr {
+    #[inline]
+    pub(super) fn new(dat: ErrorData<Box<Custom>>) -> Self {
+        Self(dat)
+    }
     pub(super) fn new_custom(b: Box<Custom>) -> Self {
         Self(Inner::Custom(b))
     }
index 8d7877bcad35d078108a042e2a8a102a76b334cd..c897a5e8701c45ebad019aa86eb679e7660b71a5 100644 (file)
@@ -1,4 +1,4 @@
-use super::{const_io_error, Custom, Error, ErrorData, ErrorKind, Repr};
+use super::{const_io_error, Custom, Error, ErrorData, ErrorKind, Repr, SimpleMessage};
 use crate::assert_matches::assert_matches;
 use crate::error;
 use crate::fmt;
@@ -141,3 +141,54 @@ fn test_custom_error_packing() {
         }) if error.downcast_ref::<Bojji>().as_deref() == Some(&Bojji(true)),
     );
 }
+
+#[derive(Debug)]
+struct E;
+
+impl fmt::Display for E {
+    fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        Ok(())
+    }
+}
+
+impl error::Error for E {}
+
+#[test]
+fn test_std_io_error_downcast() {
+    // Case 1: custom error, downcast succeeds
+    let io_error = Error::new(ErrorKind::Other, Bojji(true));
+    let e: Box<Bojji> = io_error.downcast().unwrap();
+    assert!(e.0);
+
+    // Case 2: custom error, downcast fails
+    let io_error = Error::new(ErrorKind::Other, Bojji(true));
+    let io_error = io_error.downcast::<E>().unwrap_err();
+
+    //   ensures that the custom error is intact
+    assert_eq!(ErrorKind::Other, io_error.kind());
+    let e: Box<Bojji> = io_error.downcast().unwrap();
+    assert!(e.0);
+
+    // Case 3: os error
+    let errno = 20;
+    let io_error = Error::from_raw_os_error(errno);
+    let io_error = io_error.downcast::<E>().unwrap_err();
+
+    assert_eq!(errno, io_error.raw_os_error().unwrap());
+
+    // Case 4: simple
+    let kind = ErrorKind::OutOfMemory;
+    let io_error: Error = kind.into();
+    let io_error = io_error.downcast::<E>().unwrap_err();
+
+    assert_eq!(kind, io_error.kind());
+
+    // Case 5: simple message
+    const SIMPLE_MESSAGE: SimpleMessage =
+        SimpleMessage { kind: ErrorKind::Other, message: "simple message error test" };
+    let io_error = Error::from_static_message(&SIMPLE_MESSAGE);
+    let io_error = io_error.downcast::<E>().unwrap_err();
+
+    assert_eq!(SIMPLE_MESSAGE.kind, io_error.kind());
+    assert_eq!(SIMPLE_MESSAGE.message, &*format!("{io_error}"));
+}
index 8fbc5e27d02b8f2334e049c256b56d3bb11f46e9..ab50845e2b208f17e6a34f541ec183a473bf5990 100644 (file)
 #![feature(atomic_mut_ptr)]
 #![feature(char_error_internals)]
 #![feature(char_internals)]
-#![feature(core_c_str)]
 #![feature(core_intrinsics)]
 #![feature(cstr_from_bytes_until_nul)]
 #![feature(cstr_internals)]
 //
 // Library features (alloc):
 #![feature(alloc_layout_extra)]
-#![feature(alloc_c_string)]
-#![feature(alloc_ffi)]
 #![feature(allocator_api)]
 #![feature(get_mut_unchecked)]
 #![feature(map_try_insert)]
index c70ac8c9806d6a3e4c4682caa21fb6efb62dd959..d28c7b58b20ba95ed83dacd5e4a3bf5fbdb3af74 100644 (file)
@@ -1114,7 +1114,7 @@ impl Thread {
     // Used only internally to construct a thread object without spawning
     // Panics if the name contains nuls.
     pub(crate) fn new(name: Option<CString>) -> Thread {
-        // We have to use `unsafe` here to constuct the `Parker` in-place,
+        // We have to use `unsafe` here to construct the `Parker` in-place,
         // which is required for the UNIX implementation.
         //
         // SAFETY: We pin the Arc immediately after creation, so its address never
diff --git a/src/test/debuginfo/basic-types-globals-lto.rs b/src/test/debuginfo/basic-types-globals-lto.rs
new file mode 100644 (file)
index 0000000..555d51c
--- /dev/null
@@ -0,0 +1,81 @@
+// Caveat - gdb doesn't know about UTF-32 character encoding and will print a
+// rust char as only its numerical value.
+
+// min-lldb-version: 310
+// min-gdb-version: 8.0
+
+// no-prefer-dynamic
+// compile-flags:-g -C lto
+// gdb-command:run
+// gdbg-command:print 'basic_types_globals::B'
+// gdbr-command:print B
+// gdb-check:$1 = false
+// gdbg-command:print 'basic_types_globals::I'
+// gdbr-command:print I
+// gdb-check:$2 = -1
+// gdbg-command:print 'basic_types_globals::C'
+// gdbr-command:print C
+// gdbg-check:$3 = 97
+// gdbr-check:$3 = 97
+// gdbg-command:print/d 'basic_types_globals::I8'
+// gdbr-command:print I8
+// gdb-check:$4 = 68
+// gdbg-command:print 'basic_types_globals::I16'
+// gdbr-command:print I16
+// gdb-check:$5 = -16
+// gdbg-command:print 'basic_types_globals::I32'
+// gdbr-command:print I32
+// gdb-check:$6 = -32
+// gdbg-command:print 'basic_types_globals::I64'
+// gdbr-command:print I64
+// gdb-check:$7 = -64
+// gdbg-command:print 'basic_types_globals::U'
+// gdbr-command:print U
+// gdb-check:$8 = 1
+// gdbg-command:print/d 'basic_types_globals::U8'
+// gdbr-command:print U8
+// gdb-check:$9 = 100
+// gdbg-command:print 'basic_types_globals::U16'
+// gdbr-command:print U16
+// gdb-check:$10 = 16
+// gdbg-command:print 'basic_types_globals::U32'
+// gdbr-command:print U32
+// gdb-check:$11 = 32
+// gdbg-command:print 'basic_types_globals::U64'
+// gdbr-command:print U64
+// gdb-check:$12 = 64
+// gdbg-command:print 'basic_types_globals::F32'
+// gdbr-command:print F32
+// gdb-check:$13 = 2.5
+// gdbg-command:print 'basic_types_globals::F64'
+// gdbr-command:print F64
+// gdb-check:$14 = 3.5
+// gdb-command:continue
+
+#![allow(unused_variables)]
+#![feature(omit_gdb_pretty_printer_section)]
+#![omit_gdb_pretty_printer_section]
+
+// N.B. These are `mut` only so they don't constant fold away.
+static mut B: bool = false;
+static mut I: isize = -1;
+static mut C: char = 'a';
+static mut I8: i8 = 68;
+static mut I16: i16 = -16;
+static mut I32: i32 = -32;
+static mut I64: i64 = -64;
+static mut U: usize = 1;
+static mut U8: u8 = 100;
+static mut U16: u16 = 16;
+static mut U32: u32 = 32;
+static mut U64: u64 = 64;
+static mut F32: f32 = 2.5;
+static mut F64: f64 = 3.5;
+
+fn main() {
+    _zzz(); // #break
+
+    let a = unsafe { (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64) };
+}
+
+fn _zzz() {()}
index 389b2cf015cac3a6c6636eb1eda5a0ea2245f365..a6d8c15bcdcf0f96ba61e5ab2ad72e987283fd7c 100644 (file)
@@ -1,11 +1,8 @@
-// Caveats - gdb prints any 8-bit value (meaning rust I8 and u8 values)
-// as its numerical value along with its associated ASCII char, there
-// doesn't seem to be any way around this. Also, gdb doesn't know
-// about UTF-32 character encoding and will print a rust char as only
-// its numerical value.
+// Caveat - gdb doesn't know about UTF-32 character encoding and will print a
+// rust char as only its numerical value.
 
 // min-lldb-version: 310
-// ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155
+// min-gdb-version: 8.0
 
 // compile-flags:-g
 // gdb-command:run
@@ -18,7 +15,7 @@
 // gdbg-command:print 'basic_types_globals::C'
 // gdbr-command:print C
 // gdbg-check:$3 = 97
-// gdbr-check:$3 = 97 'a'
+// gdbr-check:$3 = 97
 // gdbg-command:print/d 'basic_types_globals::I8'
 // gdbr-command:print I8
 // gdb-check:$4 = 68
diff --git a/src/test/ui/lint/unused/must-use-box-from-raw.rs b/src/test/ui/lint/unused/must-use-box-from-raw.rs
new file mode 100644 (file)
index 0000000..9ea7726
--- /dev/null
@@ -0,0 +1,11 @@
+// #99269
+
+// check-pass
+
+#![warn(unused_must_use)]
+
+unsafe fn free<T>(ptr: *mut T) {
+    Box::from_raw(ptr); //~ WARNING unused return value
+}
+
+fn main() {}
diff --git a/src/test/ui/lint/unused/must-use-box-from-raw.stderr b/src/test/ui/lint/unused/must-use-box-from-raw.stderr
new file mode 100644 (file)
index 0000000..7769f09
--- /dev/null
@@ -0,0 +1,15 @@
+warning: unused return value of `Box::<T>::from_raw` that must be used
+  --> $DIR/must-use-box-from-raw.rs:8:5
+   |
+LL |     Box::from_raw(ptr);
+   |     ^^^^^^^^^^^^^^^^^^^
+   |
+note: the lint level is defined here
+  --> $DIR/must-use-box-from-raw.rs:5:9
+   |
+LL | #![warn(unused_must_use)]
+   |         ^^^^^^^^^^^^^^^
+   = note: call `drop(from_raw(ptr))` if you intend to drop the `Box`
+
+warning: 1 warning emitted
+