mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-10 06:47:34 +00:00
Fix ICE when assigning references to a static mut with NLL
is_unsafe_place only filters out statics in the rhs, not the lhs. Since it's possible to reach that 'Place::Static', we handle statics the same way as we do locals. Fixes #47789
This commit is contained in:
parent
def3269a71
commit
bc8e11b975
@ -396,8 +396,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
|
||||
// Issue #46746: Two-phase borrows handles
|
||||
// stmts of form `Tmp = &mut Borrow` ...
|
||||
match lhs {
|
||||
Place::Local(..) => {} // okay
|
||||
Place::Static(..) => unreachable!(), // (filtered by is_unsafe_place)
|
||||
Place::Local(..) | Place::Static(..) => {} // okay
|
||||
Place::Projection(..) => {
|
||||
// ... can assign into projections,
|
||||
// e.g. `box (&mut _)`. Current
|
||||
|
20
src/test/run-pass/issue-47789.rs
Normal file
20
src/test/run-pass/issue-47789.rs
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
#![feature(nll)]
|
||||
|
||||
static mut x: &'static u32 = &0;
|
||||
|
||||
fn foo() {
|
||||
unsafe { x = &1; }
|
||||
}
|
||||
|
||||
fn main() { }
|
Loading…
Reference in New Issue
Block a user