Skip to content

Commit e9609ab

Browse files
committed
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` ```
1 parent 18eeac0 commit e9609ab

File tree

5 files changed

+3
-11
lines changed

5 files changed

+3
-11
lines changed

compiler/rustc_hir_typeck/src/demand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
698698
) {
699699
match (self.tcx.parent_hir_node(expr.hir_id), error) {
700700
(hir::Node::LetStmt(hir::LetStmt { ty: Some(ty), init: Some(init), .. }), _)
701-
if init.hir_id == expr.hir_id =>
701+
if init.hir_id == expr.hir_id && !ty.span.source_equal(init.span) =>
702702
{
703703
// Point at `let` assignment type.
704704
err.span_label(ty.span, "expected due to this");

tests/ui/proc-macro/quote/does-not-have-iter-interpolated-dup.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ LL | quote!($($nonrep $nonrep)*);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
| |
77
| expected `HasIterator`, found `ThereIsNoIteratorInRepetition`
8-
| expected due to this
98
| here the type of `has_iter` is inferred to be `ThereIsNoIteratorInRepetition`
109

1110
error: aborting due to 1 previous error

tests/ui/proc-macro/quote/does-not-have-iter-interpolated.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ LL | quote!($($nonrep)*);
55
| ^^^^^^^^^^^^^^^^^^^
66
| |
77
| expected `HasIterator`, found `ThereIsNoIteratorInRepetition`
8-
| expected due to this
98
| here the type of `has_iter` is inferred to be `ThereIsNoIteratorInRepetition`
109

1110
error: aborting due to 1 previous error

tests/ui/proc-macro/quote/does-not-have-iter-separated.stderr

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/does-not-have-iter-separated.rs:8:5
33
|
44
LL | quote!($(a b),*);
5-
| ^^^^^^^^^^^^^^^^
6-
| |
7-
| expected `HasIterator`, found `ThereIsNoIteratorInRepetition`
8-
| expected due to this
5+
| ^^^^^^^^^^^^^^^^ expected `HasIterator`, found `ThereIsNoIteratorInRepetition`
96

107
error: aborting due to 1 previous error
118

tests/ui/proc-macro/quote/does-not-have-iter.stderr

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/does-not-have-iter.rs:8:5
33
|
44
LL | quote!($(a b)*);
5-
| ^^^^^^^^^^^^^^^
6-
| |
7-
| expected `HasIterator`, found `ThereIsNoIteratorInRepetition`
8-
| expected due to this
5+
| ^^^^^^^^^^^^^^^ expected `HasIterator`, found `ThereIsNoIteratorInRepetition`
96

107
error: aborting due to 1 previous error
118

0 commit comments

Comments
 (0)