Skip to content

Commit 1647af0

Browse files
committed
instantly_dangling_pointer: fix the treatment of [] indexing
1 parent 448e0fb commit 1647af0

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

compiler/rustc_lint/src/dangling.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,10 @@ fn is_temporary_rvalue(expr: &Expr<'_>) -> bool {
9898
ExprKind::Path(_) => false,
9999

100100
// Calls return rvalues.
101-
ExprKind::Call(_, _)
102-
| ExprKind::MethodCall(_, _, _, _)
103-
| ExprKind::Index(_, _, _)
104-
| ExprKind::Binary(_, _, _) => true,
101+
ExprKind::Call(_, _) | ExprKind::MethodCall(_, _, _, _) | ExprKind::Binary(_, _, _) => true,
105102

106-
// This is likely a dereference.
107-
ExprKind::Unary(_, _) => false,
103+
// Produces lvalue.
104+
ExprKind::Unary(_, _) | ExprKind::Index(_, _, _) => false,
108105

109106
// Inner blocks are rvalues.
110107
ExprKind::If(_, _, _)

0 commit comments

Comments
 (0)