Account for field access when looking for inner-most path in expression
This commit is contained in:
parent
be2ec32b18
commit
c6111e8d23
@ -76,7 +76,8 @@ pub(crate) fn add_explanation_to_diagnostic(
|
||||
expr_finder.visit_expr(body.value);
|
||||
if let Some(mut expr) = expr_finder.result {
|
||||
while let hir::ExprKind::AddrOf(_, _, inner)
|
||||
| hir::ExprKind::Unary(hir::UnOp::Deref, inner) = &expr.kind
|
||||
| hir::ExprKind::Unary(hir::UnOp::Deref, inner)
|
||||
| hir::ExprKind::Field(inner, _) = &expr.kind
|
||||
{
|
||||
expr = inner;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
error[E0505]: cannot move out of `x` because it is borrowed
|
||||
--> $DIR/borrow-tuple-fields.rs:12:13
|
||||
|
|
||||
LL | let x: (Box<_>, _) = (Box::new(1), 2);
|
||||
| - binding `x` declared here
|
||||
LL | let r = &x.0;
|
||||
| ---- borrow of `x.0` occurs here
|
||||
LL | let y = x;
|
||||
@ -32,6 +34,8 @@ LL | a.use_ref();
|
||||
error[E0505]: cannot move out of `x` because it is borrowed
|
||||
--> $DIR/borrow-tuple-fields.rs:28:13
|
||||
|
|
||||
LL | let x = Foo(Box::new(1), 2);
|
||||
| - binding `x` declared here
|
||||
LL | let r = &x.0;
|
||||
| ---- borrow of `x.0` occurs here
|
||||
LL | let y = x;
|
||||
|
@ -41,6 +41,8 @@ LL | let p = &x.b;
|
||||
error[E0505]: cannot move out of `x.b` because it is borrowed
|
||||
--> $DIR/borrowck-field-sensitivity.rs:34:10
|
||||
|
|
||||
LL | let x = A { a: 1, b: Box::new(2) };
|
||||
| - binding `x` declared here
|
||||
LL | let p = &x.b;
|
||||
| ---- borrow of `x.b` occurs here
|
||||
LL | drop(x.b);
|
||||
@ -51,6 +53,8 @@ LL | drop(**p);
|
||||
error[E0505]: cannot move out of `x.b` because it is borrowed
|
||||
--> $DIR/borrowck-field-sensitivity.rs:41:14
|
||||
|
|
||||
LL | let x = A { a: 1, b: Box::new(2) };
|
||||
| - binding `x` declared here
|
||||
LL | let p = &x.b;
|
||||
| ---- borrow of `x.b` occurs here
|
||||
LL | let _y = A { a: 3, .. x };
|
||||
|
@ -1,6 +1,8 @@
|
||||
error[E0597]: `z.1` does not live long enough
|
||||
--> $DIR/borrowck-local-borrow-with-panic-outlives-fn.rs:3:15
|
||||
|
|
||||
LL | let mut z = (0, 0);
|
||||
| ----- binding `z` declared here
|
||||
LL | *x = Some(&mut z.1);
|
||||
| ----------^^^^^^^^-
|
||||
| | |
|
||||
|
Loading…
Reference in New Issue
Block a user