Skip to content

Commit

Permalink
use more specific wording for subpatterns from macro expansions
Browse files Browse the repository at this point in the history
  • Loading branch information
dianne committed Feb 4, 2025
1 parent bdc6c4d commit bbe40ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion compiler/rustc_hir_typeck/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`
|
Expand Down

0 comments on commit bbe40ac

Please sign in to comment.