diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs index 632bb5b34284d..80990bcc08089 100644 --- a/src/librustc_mir/dataflow/impls/borrows.rs +++ b/src/librustc_mir/dataflow/impls/borrows.rs @@ -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 diff --git a/src/test/run-pass/issue-47789.rs b/src/test/run-pass/issue-47789.rs new file mode 100644 index 0000000000000..3148939992caf --- /dev/null +++ b/src/test/run-pass/issue-47789.rs @@ -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 or the MIT license +// , 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() { }