rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.77k stars 12.76k forks source link

Refactor inner allocation logic of temp dangling pointer lint #133263

Open Urgau opened 2 days ago

Urgau commented 2 days ago

This PR refactors the inner allocation logic of the dangling_pointers_from_temporaries lint by removing the hardcoded list of types and instead taking advantage of the semantics of the as_ptr{,_mut} methods and derefs.

cc @GrigorenkoPV r? compiler

GrigorenkoPV commented 1 day ago

Okay, I've checked, [&u8; 10] gets linted, as it should.

The MaybeUninit<&u8> does not, even though I think it should. See above.

Anyways, with this change we can now remove the diagnostic item that was added for SyncUnsafeCell in #132732.

Also cc #132281 & #128985.

GrigorenkoPV commented 1 day ago

Anyways, with this change we can now remove the diagnostic item that was added for SyncUnsafeCell in #132732.

And Cell too, added in #128985. https://github.com/rust-lang/rust/pull/128985/files#diff-75a679ddd1aae61c8b60e45cea1fb213a086caee3600993c68af9f7a09785e9eR307 Well, unless someone else started using it since then.