Skip to content

Commit 3758e38

Browse files
Remove reference to Mode::NonConstFn in qualifs
This should have no effect on behavior since the validator is never run in const contexts.
1 parent 48d3843 commit 3758e38

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

src/librustc_mir/transform/check_consts/qualifs.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -214,23 +214,19 @@ impl Qualif for HasMutInterior {
214214

215215
if let BorrowKind::Mut { .. } = kind {
216216
// In theory, any zero-sized value could be borrowed
217-
// mutably without consequences. However, only &mut []
218-
// is allowed right now, and only in functions.
219-
if cx.mode == Mode::StaticMut {
217+
// mutably without consequences.
218+
match ty.sty {
220219
// Inside a `static mut`, &mut [...] is also allowed.
221-
match ty.sty {
222-
ty::Array(..) | ty::Slice(_) => {}
223-
_ => return true,
224-
}
225-
} else if let ty::Array(_, len) = ty.sty {
226-
// FIXME(eddyb) the `cx.mode == Mode::NonConstFn` condition
227-
// seems unnecessary, given that this is merely a ZST.
228-
match len.try_eval_usize(cx.tcx, cx.param_env) {
229-
Some(0) if cx.mode == Mode::NonConstFn => {},
230-
_ => return true,
231-
}
232-
} else {
233-
return true;
220+
ty::Array(..) | ty::Slice(_) if cx.mode == Mode::StaticMut => {},
221+
222+
// FIXME(ecstaticmorse): uncomment the following match arm to stop marking
223+
// `&mut []` as `HasMutInterior`.
224+
/*
225+
ty::Array(_, len) if len.try_eval_usize(cx.tcx, cx.param_env) == Some(0)
226+
=> {},
227+
*/
228+
229+
_ => return true,
234230
}
235231
}
236232
}

0 commit comments

Comments
 (0)