-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a new lint that warns for pointers to stack memory #134218
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @compiler-errors. Use |
I am aware that this may warn on existing code. I wonder what is a good strategy here? Should it be an |
Is there a reason why this was implemented as a rust lint rather than a clippy suspicious lint or something? I guess let's find the fallout of this lint @bors try |
Add a new lint that warns for pointers to stack memory This adds a new lint with level `Warn` to check for code like: ```rust fn foo() -> *const i32 { let x = 42; &x } ``` and produce a warning like: ```text error: returning a pointer to stack memory associated with a local variable --> <source>:12:5 | LL| &x | ^^ ``` This fixes rust-lang#134215.
⌛ Trying commit 40eb5d7 with merge 6db1a6a7ebb2ad243051f3ff949f987dd70cde2b... |
This was completely my judgment, I am happy to change this if requested. My reasoning was that this is a pretty fundamental lint, since the code it lints should probably never exist? And looking at the list of rustc lints I thought it might be a good fit. |
This comment has been minimized.
This comment has been minimized.
This adds a new lint with level `Warn` to check for code like: ```rust fn foo() -> *const i32 { let x = 42; &x } ``` and produce a warning like: ```text error: returning a pointer to stack memory associated with a local variable --> <source>:12:5 | LL| &x | ^^ ```
40eb5d7
to
e162e89
Compare
Oops - I don't fully understand that error. The failure looks like in the .stderr file, but it still has unexpected errors that it doesn't match on... This even happens when passing |
This comment has been minimized.
This comment has been minimized.
@craterbot check |
🚨 Error: missing start toolchain 🆘 If you have any trouble with Crater please ping |
@craterbot run mode=check-only start=master#8e37e151835d96d6a7415e93e6876561485a3354 end=try#6db1a6a7ebb2ad243051f3ff949f987dd70cde2b |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
bless will generate a .stderr file for you, but it will not update the original .rs file. compiletest is complaining because it expects each warning to be annotated with |
This comment has been minimized.
This comment has been minimized.
3c39f0f
to
f56a313
Compare
The Miri subtree was changed cc @rust-lang/miri |
This comment has been minimized.
This comment has been minimized.
f56a313
to
80a2f21
Compare
This comment has been minimized.
This comment has been minimized.
80a2f21
to
4e7732c
Compare
This adds a new lint with level
Warn
to check for code like:and produce a warning like:
This fixes #134215.