Remove attributes and test comments accidentally left behind, add in span_mirbugs
This commit is contained in:
parent
fe32df9adb
commit
47c6db09ee
2 changed files with 20 additions and 11 deletions
|
|
@ -1056,28 +1056,39 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn check_rvalue(&mut self, mir: &Mir<'tcx>, rv: &Rvalue<'tcx>, location: Location) {
|
||||
let tcx = self.tcx();
|
||||
match rv {
|
||||
Rvalue::Aggregate(ref ak, ref ops) => {
|
||||
Rvalue::Aggregate(ak, ops) => {
|
||||
match **ak {
|
||||
// tuple rvalue field type is always the type of the op. Nothing to check here.
|
||||
AggregateKind::Tuple => { },
|
||||
_ => {
|
||||
for (i, op) in ops.iter().enumerate() {
|
||||
let field_ty = if let Ok(field_ty) = self.aggregate_field_ty(ak, i, location) {
|
||||
field_ty
|
||||
} else {
|
||||
// TODO(nashenas88) log span_mirbug terr??
|
||||
continue;
|
||||
let field_ty = match self.aggregate_field_ty(ak, i, location) {
|
||||
Ok(field_ty) => field_ty,
|
||||
Err(FieldAccessError::OutOfRange { field_count }) => {
|
||||
span_mirbug!(
|
||||
self,
|
||||
rv,
|
||||
"accessed field #{} but variant only has {}",
|
||||
i,
|
||||
field_count);
|
||||
continue;
|
||||
},
|
||||
};
|
||||
let op_ty = match op {
|
||||
Operand::Consume(lv) => lv.ty(mir, tcx).to_ty(tcx),
|
||||
Operand::Constant(c) => c.ty,
|
||||
};
|
||||
if let Err(_terr) = self.sub_types(op_ty, field_ty, location.at_successor_within_block()) {
|
||||
// TODO(nashenas88) log span_mirbug terr??
|
||||
if let Err(terr) = self.sub_types(op_ty, field_ty, location.at_successor_within_block()) {
|
||||
span_mirbug!(
|
||||
self,
|
||||
rv,
|
||||
"{:?} is not a subtype of {:?}: {:?}",
|
||||
op_ty,
|
||||
field_ty,
|
||||
terr);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ struct Wrap<'a> { w: &'a mut u32 }
|
|||
fn foo() {
|
||||
let mut x = 22;
|
||||
let wrapper = Wrap { w: &mut x };
|
||||
//~^ ERROR cannot assign to `x` because it is borrowed (Mir) [E0506]
|
||||
//~^^ ERROR cannot use `x` because it was mutably borrowed (Mir) [E0503]
|
||||
x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506]
|
||||
//[mir]~^ ERROR cannot assign to `x` because it is borrowed (Ast) [E0506]
|
||||
//[mir]~^^ ERROR cannot assign to `x` because it is borrowed (Mir) [E0506]
|
||||
Loading…
Add table
Add a link
Reference in a new issue