about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2023-01-02 21:56:19 -0800
committerEsteban Küber <esteban@kuber.com.ar>2023-01-05 16:51:16 +0000
commit05c30b0ca5450b2beec0a6e4e034953e216f6bbe (patch)
tree58fbe335402a8e31265b56ef3e95266c90ff1b6a
parentea43eb3721e9a6567ff402db442fc5c1ad942009 (diff)
downloadrust-05c30b0ca5450b2beec0a6e4e034953e216f6bbe.tar.gz
rust-05c30b0ca5450b2beec0a6e4e034953e216f6bbe.zip
Skip macros to avoid talking about bindings the user can't see
-rw-r--r--compiler/rustc_hir_typeck/src/demand.rs2
-rw-r--r--src/test/ui/span/coerce-suggestions.stderr5
-rw-r--r--src/test/ui/span/issue-33884.stderr5
-rw-r--r--src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr5
4 files changed, 4 insertions, 13 deletions
diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs
index c9ee5c6cac8..5ba0d41ab9d 100644
--- a/compiler/rustc_hir_typeck/src/demand.rs
+++ b/compiler/rustc_hir_typeck/src/demand.rs
@@ -260,7 +260,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         })) = map.find(parent) else { return false; };
 
         let ty = self.node_ty(init.hir_id);
-        if ty.is_closure() || init.span.overlaps(expr.span) {
+        if ty.is_closure() || init.span.overlaps(expr.span) || pat.span.from_expansion() {
             return false;
         }
         let mut span_labels = vec![(
diff --git a/src/test/ui/span/coerce-suggestions.stderr b/src/test/ui/span/coerce-suggestions.stderr
index 75d460d7d8c..db784d5fe6c 100644
--- a/src/test/ui/span/coerce-suggestions.stderr
+++ b/src/test/ui/span/coerce-suggestions.stderr
@@ -63,10 +63,7 @@ error[E0308]: mismatched types
   --> $DIR/coerce-suggestions.rs:21:9
    |
 LL |     s = format!("foo");
-   |         ^^^^^^^^^^^^^^
-   |         |
-   |         expected `&mut String`, found struct `String`
-   |         here the type of `res` is inferred to be `String`
+   |         ^^^^^^^^^^^^^^ expected `&mut String`, found struct `String`
    |
    = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
 
diff --git a/src/test/ui/span/issue-33884.stderr b/src/test/ui/span/issue-33884.stderr
index 30e248f381c..aee15308517 100644
--- a/src/test/ui/span/issue-33884.stderr
+++ b/src/test/ui/span/issue-33884.stderr
@@ -2,10 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-33884.rs:6:22
    |
 LL |     stream.write_fmt(format!("message received"))
-   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |                      |
-   |                      expected struct `Arguments`, found struct `String`
-   |                      here the type of `res` is inferred to be `String`
+   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Arguments`, found struct `String`
    |
    = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
 
diff --git a/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr b/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr
index 2546f2515d7..5dc4e64446f 100644
--- a/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr
+++ b/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr
@@ -4,10 +4,7 @@ error[E0308]: mismatched types
 LL | /     intrinsic_match! {
 LL | |         "abc"
 LL | |     };
-   | |     ^
-   | |     |
-   | |_____expected `&str`, found struct `String`
-   |       here the type of `res` is inferred to be `String`
+   | |_____^ expected `&str`, found struct `String`
    |
    = note: this error originates in the macro `format` which comes from the expansion of the macro `intrinsic_match` (in Nightly builds, run with -Z macro-backtrace for more info)