Skip to content
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

Permit mutable references in all const contexts #78578

Merged
merged 7 commits into from
Jan 25, 2021
Prev Previous commit
Next Next commit
Fix a comment that only made sense in the context of a dataflow based…
… mutability check
  • Loading branch information
oli-obk committed Jan 23, 2021
commit 3cd0b46baca1848b577f2172935a139663697643
5 changes: 2 additions & 3 deletions src/test/ui/consts/const-mut-refs/mut_ref_in_final.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ const A: *const i32 = &4;
// as that would be an enormous footgun in oli-obk's opinion.
const B: *mut i32 = &mut 4; //~ ERROR mutable references are not allowed

// Could be ok, but the same analysis that prevents the mutable one above will also bail out here
// Using a block with some complex content, because just `&45` would get promoted,
// which is not what we want to test here.
// Ok, because no references to mutable data exist here, since the `{}` moves
// its value and then takes a reference to that.
const C: *const i32 = &{
let mut x = 42;
x += 3;
Expand Down