Auto merge of #33620 - eddyb:oops-static-is-not-fn, r=dotdash
mir: always allow &mut [...] in static mut regardless of the array length.
This commit is contained in:
commit
e7420fbbae
@ -652,9 +652,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
|
||||
// In theory, any zero-sized value could be borrowed
|
||||
// mutably without consequences. However, only &mut []
|
||||
// is allowed right now, and only in functions.
|
||||
let allow = if let ty::TyArray(_, 0) = ty.sty {
|
||||
self.mode == Mode::Fn
|
||||
} else if self.mode == Mode::StaticMut {
|
||||
let allow = if self.mode == Mode::StaticMut {
|
||||
// Inside a `static mut`, &mut [...] is also allowed.
|
||||
match ty.sty {
|
||||
ty::TyArray(..) | ty::TySlice(_) => {
|
||||
@ -665,6 +663,8 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
|
||||
}
|
||||
_ => false
|
||||
}
|
||||
} else if let ty::TyArray(_, 0) = ty.sty {
|
||||
self.mode == Mode::Fn
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
|
||||
static mut TEST: &'static mut [isize] = &mut [1];
|
||||
static mut EMPTY: &'static mut [isize] = &mut [];
|
||||
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
|
Loading…
Reference in New Issue
Block a user