mir-borrowck: Implement end-user output for field of downcast projection
This commit is contained in:
parent
0241ea45b2
commit
f35c4e3aa1
2 changed files with 22 additions and 5 deletions
|
@ -1125,11 +1125,6 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx>
|
|||
match proj.elem {
|
||||
ProjectionElem::Deref =>
|
||||
self.describe_field(&proj.base, field_index),
|
||||
ProjectionElem::Downcast(..) => {
|
||||
debug!("End-user description not implemented for field of projection {:?}",
|
||||
proj);
|
||||
format!("<downcast>{}", field_index)
|
||||
},
|
||||
ProjectionElem::Field(..) => {
|
||||
debug!("End-user description not implemented for field of projection {:?}",
|
||||
proj);
|
||||
|
@ -1145,6 +1140,8 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx>
|
|||
proj);
|
||||
format!("<constant_index>{}", field_index)
|
||||
},
|
||||
ProjectionElem::Downcast(def, variant_index) =>
|
||||
format!("{}", def.variants[variant_index].fields[field_index].name),
|
||||
ProjectionElem::Subslice { .. } => {
|
||||
debug!("End-user description not implemented for field of projection {:?}",
|
||||
proj);
|
||||
|
|
|
@ -233,4 +233,24 @@ fn main() {
|
|||
_ => panic!("other case"),
|
||||
}
|
||||
}
|
||||
// Downcasted field
|
||||
{
|
||||
enum E<X> { A(X), B { x: X } }
|
||||
|
||||
let mut e = E::A(3);
|
||||
let _e = &mut e;
|
||||
match e {
|
||||
E::A(ref ax) =>
|
||||
//[ast]~^ ERROR cannot borrow `e.0` as immutable because `e` is also borrowed as mutable
|
||||
//[mir]~^^ ERROR cannot borrow `e.0` as immutable because `e` is also borrowed as mutable (Ast)
|
||||
//[mir]~| ERROR cannot borrow `e.0` as immutable because it is also borrowed as mutable (Mir)
|
||||
//[mir]~| ERROR cannot use `e` because it was mutably borrowed (Mir)
|
||||
println!("e.ax: {:?}", ax),
|
||||
E::B { x: ref bx } =>
|
||||
//[ast]~^ ERROR cannot borrow `e.x` as immutable because `e` is also borrowed as mutable
|
||||
//[mir]~^^ ERROR cannot borrow `e.x` as immutable because `e` is also borrowed as mutable (Ast)
|
||||
//[mir]~| ERROR cannot borrow `e.x` as immutable because it is also borrowed as mutable (Mir)
|
||||
println!("e.bx: {:?}", bx),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue