Skip to content

Commit a5aa408

Browse files
committed
New lint: dangling_pointers_from_temporaries
1 parent cde6279 commit a5aa408

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

alloc/tests/boxed.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use core::mem::MaybeUninit;
44
use core::ptr::NonNull;
55

66
#[test]
7+
#[cfg_attr(not(bootstrap), expect(dangling_pointers_from_temporaries))]
78
fn uninitialized_zero_size_box() {
89
assert_eq!(
910
&*Box::<()>::new_uninit() as *const _,

core/src/cell.rs

+1
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ pub use once::OnceCell;
304304
/// ```
305305
///
306306
/// See the [module-level documentation](self) for more.
307+
#[cfg_attr(not(test), rustc_diagnostic_item = "Cell")]
307308
#[stable(feature = "rust1", since = "1.0.0")]
308309
#[repr(transparent)]
309310
#[rustc_pub_transparent]

core/src/ffi/c_str.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,9 @@ impl CStr {
464464
/// behavior when `ptr` is used inside the `unsafe` block:
465465
///
466466
/// ```no_run
467-
/// # #![allow(unused_must_use)] #![allow(temporary_cstring_as_ptr)]
467+
/// # #![allow(unused_must_use)]
468+
/// # #![cfg_attr(bootstrap, expect(temporary_cstring_as_ptr))]
469+
/// # #![cfg_attr(not(bootstrap), expect(dangling_pointers_from_temporaries))]
468470
/// use std::ffi::CString;
469471
///
470472
/// // Do not do this:

0 commit comments

Comments
 (0)