From 6a80b74a812e7b9b22b6eee7cd5d280d22c3bf82 Mon Sep 17 00:00:00 2001 From: Jaemin Hong Date: Wed, 22 May 2024 16:41:53 +0000 Subject: [PATCH] transformation: as_mut_ptr --- src/tag_analysis.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/tag_analysis.rs b/src/tag_analysis.rs index 587bcf4..b8dc601 100644 --- a/src/tag_analysis.rs +++ b/src/tag_analysis.rs @@ -802,6 +802,9 @@ impl VariantTags { let mut all_tags = HashSet::new(); let mut field_tags = BTreeMap::new(); for (f, tags) in &self.tags { + if tags.is_empty() { + continue; + } for t in tags.keys() { if !all_tags.insert(*t) { return None; @@ -821,6 +824,9 @@ impl VariantTags { .copied() .filter(|t| !existing_tags.contains(t)) .collect(); + if v.is_empty() { + continue; + } for t in &v { if !new_tags.insert(*t) { return; @@ -1330,6 +1336,15 @@ fn get_expr_context<'tcx>( } ExprKind::AddrOf(_, _, _) => (ExprContext::Address, e), ExprKind::Field(_, _) | ExprKind::DropTemps(_) => get_expr_context(e, tcx), + ExprKind::MethodCall(method, receiver, _, _) => { + if expr.hir_id == receiver.hir_id + && method.ident.name.to_ident_string() == "as_mut_ptr" + { + (ExprContext::Address, expr) + } else { + (ExprContext::Value, expr) + } + } _ => (ExprContext::Value, e), }, Node::ExprField(_) | Node::Stmt(_) | Node::Local(_) | Node::Block(_) => {