diff options
| author | dianne <diannes.gm@gmail.com> | 2025-02-03 19:56:46 -0800 |
|---|---|---|
| committer | dianne <diannes.gm@gmail.com> | 2025-02-03 19:56:46 -0800 |
| commit | bbe40acb9a192ab2afec1f8adc45c3b72925caf2 (patch) | |
| tree | 28d68a4da5d36cdc7b5e82f636a77c0f044f8793 | |
| parent | bdc6c4d07b5ccb91df396e152deafc3a66b539ab (diff) | |
| download | rust-bbe40acb9a192ab2afec1f8adc45c3b72925caf2.tar.gz rust-bbe40acb9a192ab2afec1f8adc45c3b72925caf2.zip | |
use more specific wording for subpatterns from macro expansions
| -rw-r--r-- | compiler/rustc_hir_typeck/src/pat.rs | 5 | ||||
| -rw-r--r-- | tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index f5e7b1d9629..1970040ec86 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -2787,7 +2787,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Only provide a detailed label if the problematic subpattern isn't from an expansion. // In the case that it's from a macro, we'll add a more detailed note in the emitter. let desc = if subpat.span.from_expansion() { - "occurs within expansion" + // NB: This wording assumes the only expansions that can produce problematic reference + // patterns and bindings are macros. If a desugaring or AST pass is added that can do + // so, we may want to inspect the span's source callee or macro backtrace. + "occurs within macro expansion" } else { match def_br_mutbl { Mutability::Not => "default binding mode is `ref`", diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr index 8f675d2fb57..53558e6891e 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr @@ -206,7 +206,7 @@ error: binding modifiers may only be written when the default binding mode is `m --> $DIR/migration_lint.rs:137:15 | LL | (Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => { - | ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ occurs within expansion + | ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ occurs within macro expansion | | | default binding mode is `ref` | |
