Skip to content

Commit

Permalink
transformation: as_mut_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
Medowhill committed May 22, 2024
1 parent c0e9be3 commit 6a80b74
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/tag_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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(_) => {
Expand Down

0 comments on commit 6a80b74

Please sign in to comment.