Remove reference to Mode::NonConstFn in qualifs

This should have no effect on behavior since the validator is never run
in const contexts.
This commit is contained in:
Dylan MacKenzie 2019-09-17 16:25:37 -07:00
parent 48d3843be6
commit 3758e383a6

View file

@ -214,24 +214,20 @@ impl Qualif for HasMutInterior {
if let BorrowKind::Mut { .. } = kind {
// In theory, any zero-sized value could be borrowed
// mutably without consequences. However, only &mut []
// is allowed right now, and only in functions.
if cx.mode == Mode::StaticMut {
// Inside a `static mut`, &mut [...] is also allowed.
// mutably without consequences.
match ty.sty {
ty::Array(..) | ty::Slice(_) => {}
// Inside a `static mut`, &mut [...] is also allowed.
ty::Array(..) | ty::Slice(_) if cx.mode == Mode::StaticMut => {},
// FIXME(ecstaticmorse): uncomment the following match arm to stop marking
// `&mut []` as `HasMutInterior`.
/*
ty::Array(_, len) if len.try_eval_usize(cx.tcx, cx.param_env) == Some(0)
=> {},
*/
_ => return true,
}
} else if let ty::Array(_, len) = ty.sty {
// FIXME(eddyb) the `cx.mode == Mode::NonConstFn` condition
// seems unnecessary, given that this is merely a ZST.
match len.try_eval_usize(cx.tcx, cx.param_env) {
Some(0) if cx.mode == Mode::NonConstFn => {},
_ => return true,
}
} else {
return true;
}
}
}