Skip to content

Commit

Permalink
handle let ref binding
Browse files Browse the repository at this point in the history
  • Loading branch information
Medowhill committed May 24, 2024
1 parent ae5532c commit b2189a1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/tag_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use compile_util::{make_suggestion, span_to_snippet};
use etrace::{ok_or, some_or};
use must_analysis::Obj;
use rustc_abi::{FieldIdx, VariantIdx};
use rustc_ast::Mutability;
use rustc_ast::{BindingAnnotation, Mutability};
use rustc_hir::{
def::Res,
definitions::DefPathDataName,
intravisit::{self, Visitor as HVisitor},
Expr, ExprKind, ItemKind, Node, PatKind, QPath, StmtKind, UnOp, VariantData,
ByRef, Expr, ExprKind, ItemKind, Node, PatKind, QPath, StmtKind, UnOp, VariantData,
};
use rustc_index::{bit_set::BitSet, IndexVec};
use rustc_middle::{
Expand Down Expand Up @@ -1468,9 +1468,17 @@ fn get_expr_context<'tcx>(
}
_ => (ExprContext::Value, e),
},
Node::ExprField(_) | Node::Stmt(_) | Node::Local(_) | Node::Block(_) => {
(ExprContext::Value, expr)
Node::Local(rustc_hir::Local { pat, .. }) => {
let PatKind::Binding(BindingAnnotation(by_ref, _), _, _, _) = pat.kind else {
unreachable!()
};
if by_ref == ByRef::Yes {
(ExprContext::Address, expr)
} else {
(ExprContext::Value, expr)
}
}
Node::ExprField(_) | Node::Stmt(_) | Node::Block(_) => (ExprContext::Value, expr),
_ => unreachable!("{:?}", parent),
}
}
Expand Down

0 comments on commit b2189a1

Please sign in to comment.