From b73cdf1b29d25d3c6d0cc4f8a7744b08930e86ee Mon Sep 17 00:00:00 2001 From: Ezra Shaw Date: Wed, 18 Jan 2023 13:14:56 +1300 Subject: special case removing `&` suggestion --- compiler/rustc_hir/src/hir.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'compiler/rustc_hir/src') diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 60f5b79de10..5e59475a7bd 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -1787,6 +1787,14 @@ impl Expr<'_> { expr } + pub fn peel_borrows(&self) -> &Self { + let mut expr = self; + while let ExprKind::AddrOf(.., inner) = &expr.kind { + expr = inner; + } + expr + } + pub fn can_have_side_effects(&self) -> bool { match self.peel_drop_temps().kind { ExprKind::Path(_) | ExprKind::Lit(_) => false, -- cgit 1.4.1-3-g733a5