1
Fork 0

experimentally label the spans for default binding modes

This commit is contained in:
dianne 2025-02-04 03:18:10 -08:00
parent 4331f55b72
commit 203d3109d8
8 changed files with 264 additions and 223 deletions

View file

@ -804,7 +804,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Determine the binding mode...
let bm = match user_bind_annot {
BindingMode(ByRef::No, Mutability::Mut) if let ByRef::Yes(def_br_mutbl) = def_br => {
BindingMode(ByRef::No, Mutability::Mut) if matches!(def_br, ByRef::Yes(_)) => {
// Only mention the experimental `mut_ref` feature if if we're in edition 2024 and
// using other experimental matching features compatible with it.
if pat.span.at_least_rust_2024()
@ -828,20 +828,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pat_info.top_info.hir_id,
pat,
ident.span,
def_br_mutbl,
);
BindingMode(ByRef::No, Mutability::Mut)
}
}
BindingMode(ByRef::No, mutbl) => BindingMode(def_br, mutbl),
BindingMode(ByRef::Yes(_), _) => {
if let ByRef::Yes(def_br_mutbl) = def_br {
if matches!(def_br, ByRef::Yes(_)) {
// `ref`/`ref mut` overrides the binding mode on edition <= 2021
self.add_rust_2024_migration_desugared_pat(
pat_info.top_info.hir_id,
pat,
ident.span,
def_br_mutbl,
);
}
user_bind_annot
@ -2380,7 +2378,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pat_info.top_info.hir_id,
pat,
inner.span,
inh_mut,
)
}
}
@ -2772,7 +2769,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pat_id: HirId,
subpat: &'tcx Pat<'tcx>,
cutoff_span: Span,
def_br_mutbl: Mutability,
) {
// Try to trim the span we're labeling to just the `&` or binding mode that's an issue.
// If the subpattern's span is is from an expansion, the emitted label will not be trimmed.
@ -2788,8 +2784,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut table = typeck_results.rust_2024_migration_desugared_pats_mut();
let info = table.entry(pat_id).or_default();
info.primary_spans.push(trimmed_span);
// 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 from_expansion = subpat.span.from_expansion();
@ -2807,15 +2801,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
"this reference pattern"
}
};
info.span_labels.push((trimmed_span, primary_label.to_owned()));
if !from_expansion {
// Add a secondary label covering the whole pattern noting the default binding mode
let def_br_desc = match def_br_mutbl {
Mutability::Not => "default binding mode is `ref`",
Mutability::Mut => "default binding mode is `ref mut`",
};
info.span_labels.push((subpat.span, def_br_desc.to_owned()));
}
info.primary_labels.push((trimmed_span, primary_label.to_owned()));
}
}

View file

@ -816,10 +816,8 @@ impl<'tcx> std::fmt::Display for UserTypeKind<'tcx> {
/// emitted during THIR construction.
#[derive(TyEncodable, TyDecodable, Debug, HashStable, Default)]
pub struct Rust2024IncompatiblePatInfo {
/// Spans for `&`s, `&mut`s, and binding modifiers incompatible with Rust 2024.
pub primary_spans: Vec<Span>,
/// Labels for the primary spans and their patterns, to provide additional context.
pub span_labels: Vec<(Span, String)>,
/// Labeled spans for `&`s, `&mut`s, and binding modifiers incompatible with Rust 2024.
pub primary_labels: Vec<(Span, String)>,
/// Whether any binding modifiers occur under a non-`move` default binding mode.
pub bad_modifiers: bool,
/// Whether any `&` or `&mut` patterns occur under a non-`move` default binding mode.

View file

@ -1,3 +1,4 @@
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::codes::*;
use rustc_errors::{
Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level,
@ -1109,6 +1110,11 @@ pub(crate) struct Rust2024IncompatiblePatSugg {
pub(crate) suggestion: Vec<(Span, String)>,
pub(crate) ref_pattern_count: usize,
pub(crate) binding_mode_count: usize,
/// Internal state: the ref-mutability of the default binding mode at the subpattern being
/// lowered, with the span where it was introduced. `None` for a by-value default mode.
pub(crate) default_mode_span: Option<(Span, ty::Mutability)>,
/// Labels for where incompatibility-causing by-ref default binding modes were introduced.
pub(crate) default_mode_labels: FxIndexMap<Span, ty::Mutability>,
}
impl Subdiagnostic for Rust2024IncompatiblePatSugg {

View file

@ -53,16 +53,29 @@ pub(super) fn pat_from_hir<'a, 'tcx>(
suggestion: Vec::new(),
ref_pattern_count: 0,
binding_mode_count: 0,
default_mode_span: None,
default_mode_labels: Default::default(),
})),
};
let result = pcx.lower_pattern(pat);
debug!("pat_from_hir({:?}) = {:?}", pat, result);
if let Some(info) = migration_info {
let sugg = pcx.rust_2024_migration_suggestion.expect("suggestion should be present");
let mut spans = MultiSpan::from_spans(info.primary_spans.clone());
for (span, label) in &info.span_labels {
let mut spans =
MultiSpan::from_spans(info.primary_labels.iter().map(|(span, _)| *span).collect());
for (span, label) in &info.primary_labels {
spans.push_span_label(*span, label.clone());
}
for (span, label_mutbl) in &sugg.default_mode_labels {
// Don't point to a macro call site.
if !span.from_expansion() {
let label = match label_mutbl {
Mutability::Not => "default binding mode is `ref`",
Mutability::Mut => "default binding mode is `ref mut`",
};
spans.push_span_label(*span, label.to_owned())
}
}
// If a relevant span is from at least edition 2024, this is a hard error.
let is_hard_error = spans.primary_spans().iter().any(|span| span.at_least_rust_2024());
if is_hard_error {
@ -96,6 +109,40 @@ pub(super) fn pat_from_hir<'a, 'tcx>(
impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
fn lower_pattern(&mut self, pat: &'tcx hir::Pat<'tcx>) -> Box<Pat<'tcx>> {
let adjustments: &[Ty<'tcx>] =
self.typeck_results.pat_adjustments().get(pat.hir_id).map_or(&[], |v| &**v);
let mut opt_old_mode_span = None;
if let Some(s) = &mut self.rust_2024_migration_suggestion
&& !adjustments.is_empty()
{
let mut min_mutbl = Mutability::Mut;
let suggestion_str: String = adjustments
.iter()
.map(|ref_ty| {
let &ty::Ref(_, _, mutbl) = ref_ty.kind() else {
span_bug!(pat.span, "pattern implicitly dereferences a non-ref type");
};
match mutbl {
Mutability::Not => {
min_mutbl = Mutability::Not;
"&"
}
Mutability::Mut => "&mut ",
}
})
.collect();
s.suggestion.push((pat.span.shrink_to_lo(), suggestion_str));
s.ref_pattern_count += adjustments.len();
// Remember if this changed the default binding mode, in case we want to label it.
if s.default_mode_span.is_none_or(|(_, old_mutbl)| min_mutbl < old_mutbl) {
opt_old_mode_span = Some(s.default_mode_span);
s.default_mode_span = Some((pat.span, min_mutbl));
}
};
// When implicit dereferences have been inserted in this pattern, the unadjusted lowered
// pattern has the type that results *after* dereferencing. For example, in this code:
//
@ -124,8 +171,6 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
_ => self.lower_pattern_unadjusted(pat),
};
let adjustments: &[Ty<'tcx>] =
self.typeck_results.pat_adjustments().get(pat.hir_id).map_or(&[], |v| &**v);
let adjusted_pat = adjustments.iter().rev().fold(unadjusted_pat, |thir_pat, ref_ty| {
debug!("{:?}: wrapping pattern with type {:?}", thir_pat, ref_ty);
Box::new(Pat {
@ -136,24 +181,10 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
});
if let Some(s) = &mut self.rust_2024_migration_suggestion
&& !adjustments.is_empty()
&& let Some(old_mode_span) = opt_old_mode_span
{
let suggestion_str: String = adjustments
.iter()
.map(|ref_ty| {
let &ty::Ref(_, _, mutbl) = ref_ty.kind() else {
span_bug!(pat.span, "pattern implicitly dereferences a non-ref type");
};
match mutbl {
ty::Mutability::Not => "&",
ty::Mutability::Mut => "&mut ",
s.default_mode_span = old_mode_span;
}
})
.collect();
s.suggestion.push((pat.span.shrink_to_lo(), suggestion_str));
s.ref_pattern_count += adjustments.len();
};
adjusted_pat
}
@ -343,7 +374,22 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
let mutability = if mutable { hir::Mutability::Mut } else { hir::Mutability::Not };
PatKind::DerefPattern { subpattern: self.lower_pattern(subpattern), mutability }
}
hir::PatKind::Ref(subpattern, _) | hir::PatKind::Box(subpattern) => {
hir::PatKind::Ref(subpattern, _) => {
// Track the default binding mode for the Rust 2024 migration suggestion.
let old_mode_span = self.rust_2024_migration_suggestion.as_mut().and_then(|s| {
if let Some((default_mode_span, default_ref_mutbl)) = s.default_mode_span {
// If this eats a by-ref default binding mode, label the binding mode.
s.default_mode_labels.insert(default_mode_span, default_ref_mutbl);
}
s.default_mode_span.take()
});
let subpattern = self.lower_pattern(subpattern);
if let Some(s) = &mut self.rust_2024_migration_suggestion {
s.default_mode_span = old_mode_span;
}
PatKind::Deref { subpattern }
}
hir::PatKind::Box(subpattern) => {
PatKind::Deref { subpattern: self.lower_pattern(subpattern) }
}
@ -370,8 +416,14 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
.get(pat.hir_id)
.expect("missing binding mode");
if let Some(s) = &mut self.rust_2024_migration_suggestion
&& explicit_ba.0 == ByRef::No
if let Some(s) = &mut self.rust_2024_migration_suggestion {
if explicit_ba != hir::BindingMode::NONE
&& let Some((default_mode_span, default_ref_mutbl)) = s.default_mode_span
{
// If this overrides a by-ref default binding mode, label the binding mode.
s.default_mode_labels.insert(default_mode_span, default_ref_mutbl);
}
if explicit_ba.0 == ByRef::No
&& let ByRef::Yes(mutbl) = mode.0
{
let sugg_str = match mutbl {
@ -384,6 +436,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
));
s.binding_mode_count += 1;
}
}
// A ref x pattern is the same node used for x, and as such it has
// x's type, which is &T, where we want T (the type being matched).

View file

@ -14,9 +14,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/ref-binding-on-inh-ref-errors.rs:67:10
|
LL | let [ref mut x] = &[0];
| ^^^^^^^--
| |
| this binding modifier
| -^^^^^^^---
| ||
| |this binding modifier
| default binding mode is `ref`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -35,9 +35,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/ref-binding-on-inh-ref-errors.rs:75:10
|
LL | let [ref x] = &[0];
| ^^^--
| |
| this binding modifier
| -^^^---
| ||
| |this binding modifier
| default binding mode is `ref`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -50,9 +50,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/ref-binding-on-inh-ref-errors.rs:79:10
|
LL | let [ref x] = &mut [0];
| ^^^--
| |
| this binding modifier
| -^^^---
| ||
| |this binding modifier
| default binding mode is `ref mut`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -65,9 +65,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/ref-binding-on-inh-ref-errors.rs:83:10
|
LL | let [ref mut x] = &mut [0];
| ^^^^^^^--
| |
| this binding modifier
| -^^^^^^^---
| ||
| |this binding modifier
| default binding mode is `ref mut`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>

View file

@ -2,9 +2,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/ref-binding-on-inh-ref-errors.rs:15:11
|
LL | let [&ref x] = &[&0];
| ^^^--
| |
| this binding modifier
| --^^^---
| | |
| | this binding modifier
| default binding mode is `ref`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -17,10 +17,10 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/ref-binding-on-inh-ref-errors.rs:20:11
|
LL | let [&ref x] = &mut [&0];
| ^^^--
| |
| this binding modifier
| default binding mode is `ref`
| --^^^---
| | |
| | this binding modifier
| default binding mode is `ref mut`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
help: make the implied reference pattern explicit
@ -32,9 +32,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/ref-binding-on-inh-ref-errors.rs:25:15
|
LL | let [&mut ref x] = &mut [&mut 0];
| ^^^--
| |
| this binding modifier
| ------^^^---
| | |
| | this binding modifier
| default binding mode is `ref mut`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -47,9 +47,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/ref-binding-on-inh-ref-errors.rs:30:15
|
LL | let [&mut ref mut x] = &mut [&mut 0];
| ^^^^^^^--
| |
| this binding modifier
| ------^^^^^^^---
| | |
| | this binding modifier
| default binding mode is `ref mut`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -62,9 +62,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/ref-binding-on-inh-ref-errors.rs:39:11
|
LL | let [&ref x] = &[&mut 0];
| ^^^--
| |
| this binding modifier
| --^^^---
| | |
| | this binding modifier
| default binding mode is `ref`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -77,10 +77,10 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/ref-binding-on-inh-ref-errors.rs:45:11
|
LL | let [&ref x] = &mut [&mut 0];
| ^^^--
| |
| this binding modifier
| default binding mode is `ref`
| --^^^---
| | |
| | this binding modifier
| default binding mode is `ref mut`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
help: make the implied reference pattern explicit
@ -92,9 +92,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/ref-binding-on-inh-ref-errors.rs:54:15
|
LL | let [&mut ref x] = &[&mut 0];
| ^^^--
| |
| this binding modifier
| ------^^^---
| | |
| | this binding modifier
| default binding mode is `ref`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -107,9 +107,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/ref-binding-on-inh-ref-errors.rs:67:10
|
LL | let [ref mut x] = &[0];
| ^^^^^^^--
| |
| this binding modifier
| -^^^^^^^---
| ||
| |this binding modifier
| default binding mode is `ref`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -128,9 +128,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/ref-binding-on-inh-ref-errors.rs:75:10
|
LL | let [ref x] = &[0];
| ^^^--
| |
| this binding modifier
| -^^^---
| ||
| |this binding modifier
| default binding mode is `ref`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -143,9 +143,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/ref-binding-on-inh-ref-errors.rs:79:10
|
LL | let [ref x] = &mut [0];
| ^^^--
| |
| this binding modifier
| -^^^---
| ||
| |this binding modifier
| default binding mode is `ref mut`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -158,9 +158,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/ref-binding-on-inh-ref-errors.rs:83:10
|
LL | let [ref mut x] = &mut [0];
| ^^^^^^^--
| |
| this binding modifier
| -^^^^^^^---
| ||
| |this binding modifier
| default binding mode is `ref mut`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>

View file

@ -2,9 +2,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/migration_lint.rs:25:13
|
LL | let Foo(mut x) = &Foo(0);
| ^^^--
| |
| this binding modifier
| ----^^^---
| | |
| | this binding modifier
| default binding mode is `ref`
|
= warning: this changes meaning in Rust 2024
@ -23,9 +23,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/migration_lint.rs:30:13
|
LL | let Foo(mut x) = &mut Foo(0);
| ^^^--
| |
| this binding modifier
| ----^^^---
| | |
| | this binding modifier
| default binding mode is `ref mut`
|
= warning: this changes meaning in Rust 2024
@ -39,9 +39,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/migration_lint.rs:35:13
|
LL | let Foo(ref x) = &Foo(0);
| ^^^--
| |
| this binding modifier
| ----^^^---
| | |
| | this binding modifier
| default binding mode is `ref`
|
= warning: this changes meaning in Rust 2024
@ -55,9 +55,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/migration_lint.rs:40:13
|
LL | let Foo(ref x) = &mut Foo(0);
| ^^^--
| |
| this binding modifier
| ----^^^---
| | |
| | this binding modifier
| default binding mode is `ref mut`
|
= warning: this changes meaning in Rust 2024
@ -71,9 +71,9 @@ error: reference patterns may only be written when the default binding mode is `
--> $DIR/migration_lint.rs:57:13
|
LL | let Foo(&x) = &Foo(&0);
| ^-
| |
| this reference pattern
| ----^--
| | |
| | this reference pattern
| default binding mode is `ref`
|
= warning: this changes meaning in Rust 2024
@ -87,9 +87,9 @@ error: reference patterns may only be written when the default binding mode is `
--> $DIR/migration_lint.rs:62:13
|
LL | let Foo(&mut x) = &Foo(&mut 0);
| ^^^^--
| |
| this reference pattern
| ----^^^^---
| | |
| | this reference pattern
| default binding mode is `ref`
|
= warning: this changes meaning in Rust 2024
@ -103,9 +103,9 @@ error: reference patterns may only be written when the default binding mode is `
--> $DIR/migration_lint.rs:67:13
|
LL | let Foo(&x) = &mut Foo(&0);
| ^-
| |
| this reference pattern
| ----^--
| | |
| | this reference pattern
| default binding mode is `ref mut`
|
= warning: this changes meaning in Rust 2024
@ -119,9 +119,9 @@ error: reference patterns may only be written when the default binding mode is `
--> $DIR/migration_lint.rs:72:13
|
LL | let Foo(&mut x) = &mut Foo(&mut 0);
| ^^^^--
| |
| this reference pattern
| ----^^^^---
| | |
| | this reference pattern
| default binding mode is `ref mut`
|
= warning: this changes meaning in Rust 2024
@ -135,9 +135,9 @@ error: reference patterns may only be written when the default binding mode is `
--> $DIR/migration_lint.rs:81:17
|
LL | if let Some(&x) = &&&&&Some(&0u8) {
| ^-
| |
| this reference pattern
| -----^--
| | |
| | this reference pattern
| default binding mode is `ref`
|
= warning: this changes meaning in Rust 2024
@ -151,9 +151,9 @@ error: reference patterns may only be written when the default binding mode is `
--> $DIR/migration_lint.rs:87:17
|
LL | if let Some(&mut x) = &&&&&Some(&mut 0u8) {
| ^^^^--
| |
| this reference pattern
| -----^^^^---
| | |
| | this reference pattern
| default binding mode is `ref`
|
= warning: this changes meaning in Rust 2024
@ -167,9 +167,9 @@ error: reference patterns may only be written when the default binding mode is `
--> $DIR/migration_lint.rs:93:17
|
LL | if let Some(&x) = &&&&&mut Some(&0u8) {
| ^-
| |
| this reference pattern
| -----^--
| | |
| | this reference pattern
| default binding mode is `ref`
|
= warning: this changes meaning in Rust 2024
@ -183,9 +183,9 @@ error: reference patterns may only be written when the default binding mode is `
--> $DIR/migration_lint.rs:99:17
|
LL | if let Some(&mut Some(Some(x))) = &mut Some(&mut Some(&mut Some(0u8))) {
| ^^^^--------------
| |
| this reference pattern
| -----^^^^---------------
| | |
| | this reference pattern
| default binding mode is `ref mut`
|
= warning: this changes meaning in Rust 2024
@ -199,9 +199,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/migration_lint.rs:111:21
|
LL | let Struct { a, mut b, c } = &Struct { a: 0, b: 0, c: 0 };
| ^^^--
| |
| this binding modifier
| ------------^^^-------
| | |
| | this binding modifier
| default binding mode is `ref`
|
= warning: this changes meaning in Rust 2024
@ -215,11 +215,10 @@ error: binding modifiers and reference patterns may only be written when the def
--> $DIR/migration_lint.rs:117:21
|
LL | let Struct { a: &a, b, ref c } = &Struct { a: &0, b: &0, c: &0 };
| ^- ^^^--
| | |
| | this binding modifier
| | default binding mode is `ref`
| this reference pattern
| ------------^------^^^----
| | | |
| | | this binding modifier
| | this reference pattern
| default binding mode is `ref`
|
= warning: this changes meaning in Rust 2024
@ -233,11 +232,10 @@ error: reference patterns may only be written when the default binding mode is `
--> $DIR/migration_lint.rs:124:24
|
LL | if let Struct { a: &Some(a), b: Some(&b), c: Some(c) } =
| ^------- ^-
| | |
| ------------^-----------------^----------------
| | | |
| | | this reference pattern
| | this reference pattern
| | default binding mode is `ref`
| this reference pattern
| default binding mode is `ref`
|
= warning: this changes meaning in Rust 2024
@ -251,9 +249,10 @@ 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 macro expansion
| |
| this binding modifier
| ------^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
| | | |
| | | occurs within macro expansion
| | this binding modifier
| default binding mode is `ref`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -267,11 +266,11 @@ error: binding modifiers and reference patterns may only be written when the def
--> $DIR/migration_lint.rs:145:10
|
LL | let [&mut [ref a]] = &mut [&mut &[0]];
| ^^^^--^^^---
| | |
| | this binding modifier
| | default binding mode is `ref`
| this reference pattern
| -^^^^--^^^----
| || ||
| || |this binding modifier
| || default binding mode is `ref`
| |this reference pattern
| default binding mode is `ref mut`
|
= warning: this changes meaning in Rust 2024
@ -285,9 +284,9 @@ error: reference patterns may only be written when the default binding mode is `
--> $DIR/migration_lint.rs:150:10
|
LL | let [&(_)] = &[&0];
| ^^--
| |
| this reference pattern
| -^^---
| ||
| |this reference pattern
| default binding mode is `ref`
|
= warning: this changes meaning in Rust 2024

View file

@ -103,9 +103,9 @@ error: reference patterns may only be written when the default binding mode is `
--> $DIR/min_match_ergonomics_fail.rs:24:20
|
LL | test_pat_on_type![(&x,): &(&T,)];
| ^-
| |
| this reference pattern
| -^---
| ||
| |this reference pattern
| default binding mode is `ref`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -118,9 +118,9 @@ error: reference patterns may only be written when the default binding mode is `
--> $DIR/min_match_ergonomics_fail.rs:27:20
|
LL | test_pat_on_type![(&mut x,): &(&mut T,)];
| ^^^^--
| |
| this reference pattern
| -^^^^----
| ||
| |this reference pattern
| default binding mode is `ref`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -133,9 +133,9 @@ error: reference patterns may only be written when the default binding mode is `
--> $DIR/min_match_ergonomics_fail.rs:31:28
|
LL | test_pat_on_type![Foo { f: &(x,) }: &Foo];
| ^----
| |
| this reference pattern
| ---------^------
| | |
| | this reference pattern
| default binding mode is `ref`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -148,9 +148,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/min_match_ergonomics_fail.rs:32:20
|
LL | test_pat_on_type![(mut x,): &(T,)];
| ^^^--
| |
| this binding modifier
| -^^^----
| ||
| |this binding modifier
| default binding mode is `ref`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -163,9 +163,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/min_match_ergonomics_fail.rs:33:20
|
LL | test_pat_on_type![(ref x,): &(T,)];
| ^^^--
| |
| this binding modifier
| -^^^----
| ||
| |this binding modifier
| default binding mode is `ref`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -178,9 +178,9 @@ error: binding modifiers may only be written when the default binding mode is `m
--> $DIR/min_match_ergonomics_fail.rs:34:20
|
LL | test_pat_on_type![(ref mut x,): &mut (T,)];
| ^^^^^^^--
| |
| this binding modifier
| -^^^^^^^----
| ||
| |this binding modifier
| default binding mode is `ref mut`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
@ -193,9 +193,9 @@ error: reference patterns may only be written when the default binding mode is `
--> $DIR/min_match_ergonomics_fail.rs:43:10
|
LL | (&x,) => x,
| ^-
| |
| this reference pattern
| -^---
| ||
| |this reference pattern
| default binding mode is `ref`
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>