about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-05-17 10:33:12 +0200
committerGitHub <noreply@github.com>2025-05-17 10:33:12 +0200
commit14f3ef997f5650913f2f735c36f54da4d0f5f94a (patch)
treeaf94a1ba60a8e458aa7fd60ed778029ab9be0cad /compiler
parent59ad0cbd04597067cfb15aed6df2f7e20eeeab77 (diff)
parent1c17324c7d82812b3e23902cd118b8ce77e9592c (diff)
downloadrust-14f3ef997f5650913f2f735c36f54da4d0f5f94a.tar.gz
rust-14f3ef997f5650913f2f735c36f54da4d0f5f94a.zip
Rollup merge of #141070 - xizheyin:issue-140659, r=chenyukang
Do not emit help when shorthand from macro when suggest `?` or `expect`

Fixes #140659

I didn't fully minimize the original bug, but I found a similar test case, and they have perhaps the same root cause. For the bug mentioned in #140659 , I also tested it locally and passed it.

Jieyou has worked on this part before, maybe r? `@jieyouxu`
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
index 251801f479e..1079262b5af 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
@@ -2043,6 +2043,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         };
 
         let sugg = match self.tcx.hir_maybe_get_struct_pattern_shorthand_field(expr) {
+            Some(_) if expr.span.from_expansion() => return false,
             Some(ident) => format!(": {ident}{sugg}"),
             None => sugg.to_string(),
         };