-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Allow unsafe through inline const #105147
Conversation
r? @nagisa (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
This comment has been minimized.
This comment has been minimized.
Why is that any harder than having EDIT: Either way that is separate from inline consts, so I opened a new issue at #105204. |
The difficulty arises precisely from the fact that they are separate MIR bodies. For closures (and after this PR, inline consts), their use is visible in the MIR of the containing body -- closures appear as a So the issue for anon consts cannot easily be resolved with MIR unsafeck. It should be solvable, though, once we move to THIR unsafeck. |
r? @oli-obk I can’t even begin to guess whether we actually want to do this… |
This is handled similar to closures
The closure handling code is changed slightly to avoid allocation when THIR building failed.
MIR unsafety checking requires this to be valid
All bodies are unsafe checked anyway. Current MIR unsafeck also just returns for closures.
14a90a8
to
d6dc912
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit d6dc912 with merge 26e606eb2c7253f83a3db16651f9ed5443c7d61d... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (26e606eb2c7253f83a3db16651f9ed5443c7d61d): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. |
These regressions are just noise, the exact same regression is happening on unrelated other PRs. @bors r+ rollup |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#105147 (Allow unsafe through inline const) - rust-lang#105438 (Move some codegen-y methods from `rustc_hir_analysis::collect` -> `rustc_codegen_ssa`) - rust-lang#105464 (Support #[track_caller] on async closures) - rust-lang#105476 (Change pattern borrowing suggestions to be verbose and remove invalid suggestion) - rust-lang#105500 (Make some diagnostics not depend on the source of what they reference being available) - rust-lang#105628 (Small doc fixes) - rust-lang#105659 (Don't require owned data in `MaybeStorageLive`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Handle similar to closures.
Address #104087 (comment)
Note that this PR does not fix the issue for
unsafe { [0; function_requiring_unsafe()] }
. This is fundamentally unfixable for MIR unsafeck IMO.This PR also does not fix unsafety checking for inline const in pattern position. It actually breaks it, allowing unsafe functions to be used in inline const in pattern position without unsafe blocks. Inline const in pattern position is not visible in MIR so ignored by MIR unsafety checking (currently it is also not checked by borrow checker, which is the reason why it's considered an incomplete feature).
@rustbot label: +T-lang +F-inline_const