Allow mutable derefs with feature gate

This commit is contained in:
Christian Poveda 2019-11-22 19:59:34 -05:00
parent de60f721c4
commit d92e9b7374
2 changed files with 8 additions and 2 deletions

View file

@ -216,7 +216,11 @@ impl NonConstOp for MutBorrow {
#[derive(Debug)]
pub struct MutDeref;
impl NonConstOp for MutDeref {}
impl NonConstOp for MutDeref {
fn feature_gate(tcx: TyCtxt<'_>) -> Option<bool> {
Some(tcx.features().const_mut_refs)
}
}
#[derive(Debug)]
pub struct Panic;

View file

@ -7,7 +7,9 @@ struct Foo {
}
const fn bar(foo: &mut Foo) -> usize {
foo.x + 1
let x = &mut foo.x;
*x = 1;
*x
}
fn main() {