New lint: dangling_pointers_from_temporaries
· qinheping/verify-rust-std@a5aa408 (original) (raw)
3 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4,6 +4,7 @@ use core::mem::MaybeUninit; | ||
4 | 4 | use core::ptr::NonNull; |
5 | 5 | |
6 | 6 | #[test] |
7 | +#[cfg_attr(not(bootstrap), expect(dangling_pointers_from_temporaries))] | |
7 | 8 | fn uninitialized_zero_size_box() { |
8 | 9 | assert_eq!( |
9 | 10 | &*Box::<()>::new_uninit() as *const _, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -304,6 +304,7 @@ pub use once::OnceCell; | ||
304 | 304 | /// ``` |
305 | 305 | /// |
306 | 306 | /// See the [module-level documentation](self) for more. |
307 | +#[cfg_attr(not(test), rustc_diagnostic_item = "Cell")] | |
307 | 308 | #[stable(feature = "rust1", since = "1.0.0")] |
308 | 309 | #[repr(transparent)] |
309 | 310 | #[rustc_pub_transparent] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -464,7 +464,9 @@ impl CStr { | ||
464 | 464 | /// behavior when `ptr` is used inside the `unsafe` block: |
465 | 465 | /// |
466 | 466 | /// ```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))] | |
468 | 470 | /// use std::ffi::CString; |
469 | 471 | /// |
470 | 472 | /// // Do not do this: |