Skip to content

Commit a9465de

Browse files
committed
use more specific wording for subpatterns from macro expansions
(cherry picked from commit bbe40ac)
1 parent 1a18daa commit a9465de

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
@@ -2652,7 +2652,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26522652
// Only provide a detailed label if the problematic subpattern isn't from an expansion.
26532653
// In the case that it's from a macro, we'll add a more detailed note in the emitter.
26542654
let desc = if subpat.span.from_expansion() {
2655-
"occurs within expansion"
2655+
// NB: This wording assumes the only expansions that can produce problematic reference
2656+
// patterns and bindings are macros. If a desugaring or AST pass is added that can do
2657+
// so, we may want to inspect the span's source callee or macro backtrace.
2658+
"occurs within macro expansion"
26562659
} else {
26572660
match def_br_mutbl {
26582661
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)