Properly assign to aggregate fields
This commit is contained in:
parent
37fcd5cad5
commit
301ce8b2aa
3 changed files with 26 additions and 1 deletions
|
@ -267,7 +267,12 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
debug!("store to var {:?}", index);
|
debug!("store to var {:?}", index);
|
||||||
self.local_qualif[index] = Some(self.qualif);
|
match &mut self.local_qualif[index] {
|
||||||
|
// update
|
||||||
|
Some(ref mut qualif) => *qualif = *qualif | self.qualif,
|
||||||
|
// or insert
|
||||||
|
qualif @ None => *qualif = Some(self.qualif),
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
src/test/ui/consts/partial_qualif.rs
Normal file
11
src/test/ui/consts/partial_qualif.rs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#![feature(const_let)]
|
||||||
|
|
||||||
|
use std::cell::Cell;
|
||||||
|
|
||||||
|
const FOO: &(Cell<usize>, bool) = {
|
||||||
|
let mut a = (Cell::new(0), false);
|
||||||
|
a.1 = true; // resets `qualif(a)` to `qualif(true)`
|
||||||
|
&{a} //~ ERROR cannot borrow a constant which may contain interior mutability
|
||||||
|
};
|
||||||
|
|
||||||
|
fn main() {}
|
9
src/test/ui/consts/partial_qualif.stderr
Normal file
9
src/test/ui/consts/partial_qualif.stderr
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
|
||||||
|
--> $DIR/partial_qualif.rs:8:5
|
||||||
|
|
|
||||||
|
LL | &{a} //~ ERROR cannot borrow a constant which may contain interior mutability
|
||||||
|
| ^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0492`.
|
Loading…
Add table
Add a link
Reference in a new issue