mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
![]() remove this weird special case from promotion Promotion has a special case to ignore interior mutability under some specific circumstances. The purpose of this PR is to figure out what changes if we remove that. Since `Cell::new` and friends only get promoted inside `const`/`static` initializers these days, it actually is not easy to exploit this case: you need something like ```rust const TEST_INTERIOR_MUT: () = { // The "0." case is already ruled out by not permitting any interior mutability in `const`. let _val: &'static _ = &(Cell::new(1), 2).1; }; ``` I assume something like `&Some(&(Cell::new(1), 2).1)` would hit the nested case inside `validate_rvalue`... though I am not sure why that would not just trigger nested promotion, first promoting the inner reference and then the outer one? Fixes https://github.com/rust-lang/rust/issues/67534 (by simply rejecting that code^^) r? `@oli-obk` (but for now this is not meant to be merged!) Cc `@rust-lang/wg-const-eval` |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |