Allow mutable derefs with feature gate
This commit is contained in:
parent
de60f721c4
commit
d92e9b7374
2 changed files with 8 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue