about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2025-08-10 21:47:52 +0000
committerEsteban Küber <esteban@kuber.com.ar>2025-08-10 21:47:52 +0000
commite9609abda42e8d88cf1f07946362cd81516792da (patch)
treeb225c9f78a46116ae15a4b35a08c02128b90dab3 /compiler
parent18eeac04fc5c2a4c4a8020dbdf1c652077ad0e4e (diff)
downloadrust-e9609abda42e8d88cf1f07946362cd81516792da.tar.gz
rust-e9609abda42e8d88cf1f07946362cd81516792da.zip
Account for macros when trying to point at inference cause
Do not point at macro invocation which expands to an inference error. Avoid the following:

```
error[E0308]: mismatched types
  --> $DIR/does-not-have-iter-interpolated.rs:12:5
   |
LL |     quote!($($nonrep)*);
   |     ^^^^^^^^^^^^^^^^^^^
   |     |
   |     expected `HasIterator`, found `ThereIsNoIteratorInRepetition`
   |     expected due to this
   |     here the type of `has_iter` is inferred to be `ThereIsNoIteratorInRepetition`
```
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_hir_typeck/src/demand.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs
index e5684f8cbe6..fb6ebe066a8 100644
--- a/compiler/rustc_hir_typeck/src/demand.rs
+++ b/compiler/rustc_hir_typeck/src/demand.rs
@@ -698,7 +698,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
     ) {
         match (self.tcx.parent_hir_node(expr.hir_id), error) {
             (hir::Node::LetStmt(hir::LetStmt { ty: Some(ty), init: Some(init), .. }), _)
-                if init.hir_id == expr.hir_id =>
+                if init.hir_id == expr.hir_id && !ty.span.source_equal(init.span) =>
             {
                 // Point at `let` assignment type.
                 err.span_label(ty.span, "expected due to this");