Add new lint to detect dangling pointer return from closure#15154
Add new lint to detect dangling pointer return from closure#15154PitiBouchon wants to merge 1 commit intorust-lang:masterfrom
Conversation
|
The lint is working using two checks for a closure :
if those two check are valid, the closure is potentially create a dangling pointer and should attract attention |
|
This seems very similar to |
What I want to detect is things like : let v_opt = Some(vec![0]);
let v_ptr = v_opt.map(|v| v.as_ptr());where it is easy to forget a I didn't checked rustc lints (only clippy), however the Also, I don't know how to detect temporaries 🤷 |
I think that's rust-lang/rust#139249 |
|
☔ The latest upstream changes (possibly 368b235) made this pull request unmergeable. Please resolve the merge conflicts. |
as_ptr_in_mapis not good.stderrfile)cargo testpasses locallycargo dev update_lintscargo dev fmtThe goal of this MR is to add a lint to detect dangling pointer from closure that can easily get undetected people think the closure should have took a reference instead of a value (see examples)
changelog: [
as_ptr_in_map]: add a new lint to detect dangling pointer returned from closure