Skip to content

Commit 419e60e

Browse files
committed
Auto merge of #52673 - oli-obk:mutable_promoted, r=nagisa,cramertj,estebank
Try to fix an ICE might fix #52671
2 parents 45b48b9 + 01d4cd5 commit 419e60e

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/librustc_mir/borrow_check/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1864,8 +1864,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
18641864
}),
18651865
}
18661866
}
1867-
// promoteds may never be mutated
1868-
Place::Promoted(_) => bug!("encountered mutable promoted"),
1867+
// The rules for promotion are made by `qualify_consts`, there wouldn't even be a
1868+
// `Place::Promoted` if the promotion weren't 100% legal. So we just forward this
1869+
Place::Promoted(_) => Ok(RootPlace {
1870+
place,
1871+
is_local_mutation_allowed,
1872+
}),
18691873
Place::Static(ref static_) => {
18701874
if self.tcx.is_static(static_.def_id) != Some(hir::Mutability::MutMutable) {
18711875
Err(place)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-pass
12+
13+
#![feature(nll)]
14+
15+
pub fn main() {
16+
let y: &'static mut [u8; 0] = &mut [];
17+
}

0 commit comments

Comments
 (0)