We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 72417d8 commit 2f9d338Copy full SHA for 2f9d338
src/librustc_mir/transform/check_consts/ops.rs
@@ -205,6 +205,12 @@ impl NonConstOp for CellBorrow {
205
#[derive(Debug)]
206
pub struct MutBorrow;
207
impl NonConstOp for MutBorrow {
208
+ fn is_allowed_in_item(&self, ccx: &ConstCx<'_, '_>) -> bool {
209
+ // Forbid everywhere except in const fn
210
+ ccx.const_kind() == hir::ConstContext::ConstFn
211
+ && ccx.tcx.features().enabled(Self::feature_gate().unwrap())
212
+ }
213
+
214
fn feature_gate() -> Option<Symbol> {
215
Some(sym::const_mut_refs)
216
}
0 commit comments