Skip to content

Commit bbe40ac

Browse files
committed
use more specific wording for subpatterns from macro expansions
1 parent bdc6c4d commit bbe40ac

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

compiler/rustc_hir_typeck/src/pat.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2787,7 +2787,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
27872787
// Only provide a detailed label if the problematic subpattern isn't from an expansion.
27882788
// In the case that it's from a macro, we'll add a more detailed note in the emitter.
27892789
let desc = if subpat.span.from_expansion() {
2790-
"occurs within expansion"
2790+
// NB: This wording assumes the only expansions that can produce problematic reference
2791+
// patterns and bindings are macros. If a desugaring or AST pass is added that can do
2792+
// so, we may want to inspect the span's source callee or macro backtrace.
2793+
"occurs within macro expansion"
27912794
} else {
27922795
match def_br_mutbl {
27932796
Mutability::Not => "default binding mode is `ref`",

tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ error: binding modifiers may only be written when the default binding mode is `m
206206
--> $DIR/migration_lint.rs:137:15
207207
|
208208
LL | (Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => {
209-
| ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ occurs within expansion
209+
| ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ occurs within macro expansion
210210
| |
211211
| default binding mode is `ref`
212212
|

0 commit comments

Comments
 (0)