Repository: rust
Issue: Macro expansion + E0308 'mismatched types' makes it hard to find what the types were
Labels: A-diagnostics,T-compiler,D-verbose

I tried this code:

```diff
diff --git a/compiler/rustc_middle/src/ty/query/plumbing.rs b/compiler/rustc_middle/src/ty/query/plumbing.rs
index f3fa3634026..ec990b414a0 100644
--- a/compiler/rustc_middle/src/ty/query/plumbing.rs
+++ b/compiler/rustc_middle/src/ty/query/plumbing.rs
@@ -486,7 +486,8 @@ macro_rules! define_queries_inner {
             $($(#[$attr])*
             #[inline(always)]
             pub fn $name(self, key: query_helper_param_ty!($($K)*))
-                -> <queries::$name<$tcx> as QueryConfig<TyCtxt<$tcx>>>::Stored
+                -> /*&'tcx*/ $V
+                //<queries::$name<$tcx> as QueryConfig<TyCtxt<$tcx>>>::Stored
             {
                 get_query::<queries::$name<'_>, _>(self.tcx, self.span, key.into_query_param())
             })*
```
applied to https://github.com/rust-lang/rust/commit/782013564efc06ef02614ba35a4e67dee4fcb8e7

The error message was (many hundreds of times, but that's not the compiler's fault):

```
error[E0308]: mismatched types
    --> compiler/rustc_middle/src/ty/query/plumbing.rs:452:17
     |
237  |  /   macro_rules! define_queries {
238  |  |       (<$tcx:tt> $($category:tt {
239  |  |           $($(#[$attr:meta])* [$($modifiers:tt)*] fn $name:ident: $node:ident($($K:tt)*) -> $V:ty,)*
240  |  |       },)*) => {
241  | /|           define_queries_inner! { <$tcx>
242  | ||               $($( $(#[$attr])* category<$category> [$($modifiers)*] fn $name: $node($($K)*) -> $V,)*)*
243  | ||           }
     | ||___________- in this macro invocation (#3)
244  |  |       }
245  |  |   }
     |  |___- in this expansion of `define_queries!` (#2)
...
252  | /    macro_rules! define_queries_inner {
253  | |        (<$tcx:tt>
254  | |         $($(#[$attr:meta])* category<$category:tt>
255  | |            [$($modifiers:tt)*] fn $name:ident: $node:ident($($K:tt)*) -> $V:ty,)*) => {
...    |
452  | |                    self.at(DUMMY_SP).$name(key.into_query_param())
     | |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     | |                    |
     | |                    expected `&ty::Generics`, found struct `ty::Generics`
     | |                    help: consider borrowing here: `&self.at(DUMMY_SP).$name(key.into_query_param())`
...    |
505  | |        }
506  | |    }
     | |____- in this expansion of `define_queries_inner!` (#3)
     | 
    ::: compiler/rustc_middle/src/ty/query/mod.rs:105:1
     |
105  |      rustc_query_append! { [define_queries!][<'tcx>] }
     |      ------------------------------------------------- in this macro invocation (#1)
     | 
    ::: compiler/rustc_middle/src/query/mod.rs:37:1
     |
37   |    / rustc_queries! {
38   |    |     Other {
39   |    |         query trigger_delay_span_bug(key: DefId) -> () {
40   |    |             desc { "trigger a delay span bug" }
...       |
1581 |    |     }
1582 |    | }
     |    | -
     |    | |
     |    |_in this expansion of `rustc_query_append!` (#1)
     |      in this macro invocation (#2)
```

Notice how
```
     | |                    expected `&ty::Generics`, found struct `ty::Generics`
     | |                    help: consider borrowing here: `&self.at(DUMMY_SP).$name(key.into_query_param())`
```
is buried deep inside the expanded macros. The compiler should print it at the beginning or end of the error so it's easier to find without hunting through 80 lines of errors.

### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version`:
```
rustc 1.47.0-beta.1 (0f91f5c28 2020-08-25)
```

cc @estebank