forbid mutable references in all constants except const fns
This commit is contained in:
parent
72417d84fb
commit
2f9d33830c
1 changed files with 6 additions and 0 deletions
|
@ -205,6 +205,12 @@ impl NonConstOp for CellBorrow {
|
|||
#[derive(Debug)]
|
||||
pub struct MutBorrow;
|
||||
impl NonConstOp for MutBorrow {
|
||||
fn is_allowed_in_item(&self, ccx: &ConstCx<'_, '_>) -> bool {
|
||||
// Forbid everywhere except in const fn
|
||||
ccx.const_kind() == hir::ConstContext::ConstFn
|
||||
&& ccx.tcx.features().enabled(Self::feature_gate().unwrap())
|
||||
}
|
||||
|
||||
fn feature_gate() -> Option<Symbol> {
|
||||
Some(sym::const_mut_refs)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue