Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/librustc_mir/transform/qualify_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_) => {
Expand All @@ -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
};
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/check-static-mut-slices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


static mut TEST: &'static mut [isize] = &mut [1];
static mut EMPTY: &'static mut [isize] = &mut [];

pub fn main() {
unsafe {
Expand Down