about summary refs log tree commit diff
path: root/library
diff options
context:
space:
mode:
authorPavel Grigorenko <GrigorenkoPV@ya.ru>2024-10-16 22:19:56 +0300
committerPavel Grigorenko <GrigorenkoPV@ya.ru>2024-10-28 14:16:05 +0300
commitc69894eaec2a29f9db023cbfff63e48266de4ee5 (patch)
tree503a18333c8b8f4a1d968c28154f4c3942df67db /library
parent81d6652e741f091f4ee0b7a660120d204e0417b8 (diff)
downloadrust-c69894eaec2a29f9db023cbfff63e48266de4ee5.tar.gz
rust-c69894eaec2a29f9db023cbfff63e48266de4ee5.zip
New lint: `dangling_pointers_from_temporaries`
Diffstat (limited to 'library')
-rw-r--r--library/alloc/tests/boxed.rs1
-rw-r--r--library/core/src/cell.rs1
-rw-r--r--library/core/src/ffi/c_str.rs4
3 files changed, 5 insertions, 1 deletions
diff --git a/library/alloc/tests/boxed.rs b/library/alloc/tests/boxed.rs
index bfc31a626fa..544f60da587 100644
--- a/library/alloc/tests/boxed.rs
+++ b/library/alloc/tests/boxed.rs
@@ -4,6 +4,7 @@ use core::mem::MaybeUninit;
 use core::ptr::NonNull;
 
 #[test]
+#[cfg_attr(not(bootstrap), expect(dangling_pointers_from_temporaries))]
 fn uninitialized_zero_size_box() {
     assert_eq!(
         &*Box::<()>::new_uninit() as *const _,
diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs
index 0b106244793..7e6c042274d 100644
--- a/library/core/src/cell.rs
+++ b/library/core/src/cell.rs
@@ -304,6 +304,7 @@ pub use once::OnceCell;
 /// ```
 ///
 /// See the [module-level documentation](self) for more.
+#[cfg_attr(not(test), rustc_diagnostic_item = "Cell")]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[repr(transparent)]
 #[rustc_pub_transparent]
diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs
index 0f4386190ee..93dd351b029 100644
--- a/library/core/src/ffi/c_str.rs
+++ b/library/core/src/ffi/c_str.rs
@@ -464,7 +464,9 @@ impl CStr {
     /// behavior when `ptr` is used inside the `unsafe` block:
     ///
     /// ```no_run
-    /// # #![allow(unused_must_use)] #![allow(temporary_cstring_as_ptr)]
+    /// # #![allow(unused_must_use)]
+    /// # #![cfg_attr(bootstrap, expect(temporary_cstring_as_ptr))]
+    /// # #![cfg_attr(not(bootstrap), expect(dangling_pointers_from_temporaries))]
     /// use std::ffi::CString;
     ///
     /// // Do not do this: