Skip to content

Commit 05c30b0

Browse files
committed
Skip macros to avoid talking about bindings the user can't see
1 parent ea43eb3 commit 05c30b0

File tree

4 files changed

+4
-13
lines changed

4 files changed

+4
-13
lines changed

compiler/rustc_hir_typeck/src/demand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
260260
})) = map.find(parent) else { return false; };
261261

262262
let ty = self.node_ty(init.hir_id);
263-
if ty.is_closure() || init.span.overlaps(expr.span) {
263+
if ty.is_closure() || init.span.overlaps(expr.span) || pat.span.from_expansion() {
264264
return false;
265265
}
266266
let mut span_labels = vec![(

src/test/ui/span/coerce-suggestions.stderr

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ error[E0308]: mismatched types
6363
--> $DIR/coerce-suggestions.rs:21:9
6464
|
6565
LL | s = format!("foo");
66-
| ^^^^^^^^^^^^^^
67-
| |
68-
| expected `&mut String`, found struct `String`
69-
| here the type of `res` is inferred to be `String`
66+
| ^^^^^^^^^^^^^^ expected `&mut String`, found struct `String`
7067
|
7168
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
7269

src/test/ui/span/issue-33884.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/issue-33884.rs:6:22
33
|
44
LL | stream.write_fmt(format!("message received"))
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6-
| |
7-
| expected struct `Arguments`, found struct `String`
8-
| here the type of `res` is inferred to be `String`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Arguments`, found struct `String`
96
|
107
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
118

src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ error[E0308]: mismatched types
44
LL | / intrinsic_match! {
55
LL | | "abc"
66
LL | | };
7-
| | ^
8-
| | |
9-
| |_____expected `&str`, found struct `String`
10-
| here the type of `res` is inferred to be `String`
7+
| |_____^ expected `&str`, found struct `String`
118
|
129
= 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)
1310

0 commit comments

Comments
 (0)