From d5522de00a8a99902ff31c6c12650224aefa4041 Mon Sep 17 00:00:00 2001 From: Rua Date: Sat, 16 May 2026 23:15:15 +0200 Subject: [PATCH] refactor: Don't remove raw borrows in `remove_unnecessary_refs` --- c2rust-refactor/src/transform/canonicalize_refs.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/c2rust-refactor/src/transform/canonicalize_refs.rs b/c2rust-refactor/src/transform/canonicalize_refs.rs index c40656e98f..34ce8aa7be 100644 --- a/c2rust-refactor/src/transform/canonicalize_refs.rs +++ b/c2rust-refactor/src/transform/canonicalize_refs.rs @@ -1,5 +1,5 @@ use rustc_ast::ptr::P; -use rustc_ast::{Crate, Expr, ExprKind, Mutability, UnOp}; +use rustc_ast::{BorrowKind, Crate, Expr, ExprKind, Mutability, UnOp}; use rustc_middle::ty::adjustment::{Adjust, AutoBorrow, AutoBorrowMutability}; use rustc_type_ir::sty; @@ -85,7 +85,7 @@ impl Transform for RemoveUnnecessaryRefs { fn remove_ref(expr: &mut P) { match &expr.kind { - ExprKind::AddrOf(_, _, inner) => *expr = inner.clone(), + ExprKind::AddrOf(BorrowKind::Ref, _, inner) => *expr = inner.clone(), _ => {} } } @@ -106,7 +106,7 @@ fn remove_all_derefs(expr: &mut P, cx: &RefactorCtxt) { } fn remove_reborrow(expr: &mut P, cx: &RefactorCtxt) { - if let ExprKind::AddrOf(_, _, ref subexpr) = expr.kind { + if let ExprKind::AddrOf(BorrowKind::Ref, _, ref subexpr) = expr.kind { if let ExprKind::Unary(UnOp::Deref, ref subexpr) = subexpr.kind { if is_pointer(subexpr, cx) { // &* on a pointer produces a reference, so it's not a no-op