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:
parent
48d3843be6
commit
3758e383a6
@ -214,23 +214,19 @@ 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 {
|
||||
// mutably without consequences.
|
||||
match ty.sty {
|
||||
// Inside a `static mut`, &mut [...] is also allowed.
|
||||
match ty.sty {
|
||||
ty::Array(..) | ty::Slice(_) => {}
|
||||
_ => 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;
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user