-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 tests (and a bit of cleanup) for interior mut handling in promotion and const-checking #121893
Conversation
r=me with comment nit |
//~^ERROR: mutable pointer in final value of constant | ||
|
||
// In contrast, this one works since it is being promoted. | ||
const NONE: &'static Option<Cell<i32>> = &None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe show off the promotion somewhere other than the trailing expression?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I didn't even realize that's possible -- I will add
// Making it clear that this is promotion, not "outer scope".
const NONE_EXPLICIT_PROMOTED: &'static Option<Cell<i32>> = {
let x = &None;
x
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly, the behavior of this example changed between stable and nightly. On nightly it just says "can't drop String
in const", on stable it additionally says "temporary value dropped while borrowed". I hope that's just suppressing two errors from the same location and not secretly actually doing promotion...
4697d4e
to
0a33a62
Compare
0a33a62
to
fb802f2
Compare
@bors r=oli-obk |
… r=oli-obk Add tests (and a bit of cleanup) for interior mut handling in promotion and const-checking Basically these are the parts of rust-lang#121786 that can be salvaged. r? `@oli-obk`
…kingjubilee Rollup of 15 pull requests Successful merges: - rust-lang#116791 (Allow codegen backends to opt-out of parallel codegen) - rust-lang#116793 (Allow targets to override default codegen backend) - rust-lang#117458 (LLVM Bitcode Linker: A self contained linker for nvptx and other targets) - rust-lang#119385 (Fix type resolution of associated const equality bounds (take 2)) - rust-lang#121438 (std support for wasm32 panic=unwind) - rust-lang#121893 (Add tests (and a bit of cleanup) for interior mut handling in promotion and const-checking) - rust-lang#122080 (Clarity improvements to `DropTree`) - rust-lang#122152 (Improve diagnostics for parenthesized type arguments) - rust-lang#122166 (Remove the unused `field_remapping` field from `TypeLowering`) - rust-lang#122249 (interpret: do not call machine read hooks during validation) - rust-lang#122299 (Store backtrace for `must_produce_diag`) - rust-lang#122318 (Revision-related tweaks for next-solver tests) - rust-lang#122320 (Use ptradd for vtable indexing) - rust-lang#122328 (unix_sigpipe: Replace `inherit` with `sig_dfl` in syntax tests) - rust-lang#122330 (bootstrap readme: fix, improve, update) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#121893 - RalfJung:const-interior-mut-tests, r=oli-obk Add tests (and a bit of cleanup) for interior mut handling in promotion and const-checking Basically these are the parts of rust-lang#121786 that can be salvaged. r? ``@oli-obk``
Basically these are the parts of #121786 that can be salvaged.
r? @oli-obk