about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs1
-rw-r--r--tests/ui/typeck/macro-shorthand-issue-140659.rs1
-rw-r--r--tests/ui/typeck/macro-shorthand-issue-140659.stderr4
3 files changed, 1 insertions, 5 deletions
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
index 91eb1989864..d3618a6ae69 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
@@ -2034,6 +2034,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(),
         };
diff --git a/tests/ui/typeck/macro-shorthand-issue-140659.rs b/tests/ui/typeck/macro-shorthand-issue-140659.rs
index dba06b43d39..d71a7ff1d3d 100644
--- a/tests/ui/typeck/macro-shorthand-issue-140659.rs
+++ b/tests/ui/typeck/macro-shorthand-issue-140659.rs
@@ -45,7 +45,6 @@ fn process<T: Reencode>(op: &Operator, reencoder: &mut T) -> Instruction {
         };
     }
 
-    // This should give the specific error message with the wrong help suggestion
     for_each_operator!(translate)
 }
 
diff --git a/tests/ui/typeck/macro-shorthand-issue-140659.stderr b/tests/ui/typeck/macro-shorthand-issue-140659.stderr
index 419db947571..12537754d80 100644
--- a/tests/ui/typeck/macro-shorthand-issue-140659.stderr
+++ b/tests/ui/typeck/macro-shorthand-issue-140659.stderr
@@ -10,10 +10,6 @@ LL |     for_each_operator!(translate)
    = note: expected type `u32`
               found enum `Result<u32, <T as Reencode>::Error>`
    = note: this error originates in the macro `translate` which comes from the expansion of the macro `for_each_operator` (in Nightly builds, run with -Z macro-backtrace for more info)
-help: consider using `Result::expect` to unwrap the `Result<u32, <T as Reencode>::Error>` value, panicking if the value is a `Result::Err`
-   |
-LL |         }: tag_index.expect("REASON")
-   |          ++++++++++++++++++++++++++++
 
 error: aborting due to 1 previous error