Rollup merge of #147472 - AMS21:remove_llvm_rust_atomics, r=nikic
refactor: replace `LLVMRustAtomicLoad/Store` with LLVM built-in functions
This simplifies the code and reduces the burden of maintaining our own wrappers.
Work towards https://github.com/rust-lang/rust/issues/46437
diff --git a/compiler/rustc_attr_parsing/src/target_checking.rs b/compiler/rustc_attr_parsing/src/target_checking.rs
index c522536..d28f439 100644
--- a/compiler/rustc_attr_parsing/src/target_checking.rs
+++ b/compiler/rustc_attr_parsing/src/target_checking.rs
@@ -198,16 +198,20 @@ pub(crate) fn allowed_targets_applied(
filter_targets(&mut allowed_targets, IMPL_LIKE, "impl blocks", target, &mut added_fake_targets);
filter_targets(&mut allowed_targets, ADT_LIKE, "data types", target, &mut added_fake_targets);
+ let mut target_strings: Vec<_> = added_fake_targets
+ .iter()
+ .copied()
+ .chain(allowed_targets.iter().map(|t| t.plural_name()))
+ .map(|i| i.to_string())
+ .collect();
+
+ // ensure a consistent order
+ target_strings.sort();
+
// If there is now only 1 target left, show that as the only possible target
- (
- added_fake_targets
- .iter()
- .copied()
- .chain(allowed_targets.iter().map(|t| t.plural_name()))
- .map(|i| i.to_string())
- .collect(),
- allowed_targets.len() + added_fake_targets.len() == 1,
- )
+ let only_target = target_strings.len() == 1;
+
+ (target_strings, only_target)
}
fn filter_targets(
diff --git a/compiler/rustc_codegen_llvm/src/builder/autodiff.rs b/compiler/rustc_codegen_llvm/src/builder/autodiff.rs
index bf70a3f..4b433e2 100644
--- a/compiler/rustc_codegen_llvm/src/builder/autodiff.rs
+++ b/compiler/rustc_codegen_llvm/src/builder/autodiff.rs
@@ -12,7 +12,7 @@
use crate::builder::{Builder, PlaceRef, UNNAMED};
use crate::context::SimpleCx;
use crate::declare::declare_simple_fn;
-use crate::llvm::{self, Metadata, TRUE, Type, Value};
+use crate::llvm::{self, TRUE, Type, Value};
pub(crate) fn adjust_activity_to_abi<'tcx>(
tcx: TyCtxt<'tcx>,
@@ -143,9 +143,9 @@ fn match_args_from_caller_to_enzyme<'ll, 'tcx>(
cx: &SimpleCx<'ll>,
builder: &mut Builder<'_, 'll, 'tcx>,
width: u32,
- args: &mut Vec<&'ll llvm::Value>,
+ args: &mut Vec<&'ll Value>,
inputs: &[DiffActivity],
- outer_args: &[&'ll llvm::Value],
+ outer_args: &[&'ll Value],
) {
debug!("matching autodiff arguments");
// We now handle the issue that Rust level arguments not always match the llvm-ir level
@@ -157,32 +157,36 @@ fn match_args_from_caller_to_enzyme<'ll, 'tcx>(
let mut outer_pos: usize = 0;
let mut activity_pos = 0;
- let enzyme_const = cx.create_metadata(b"enzyme_const");
- let enzyme_out = cx.create_metadata(b"enzyme_out");
- let enzyme_dup = cx.create_metadata(b"enzyme_dup");
- let enzyme_dupv = cx.create_metadata(b"enzyme_dupv");
- let enzyme_dupnoneed = cx.create_metadata(b"enzyme_dupnoneed");
- let enzyme_dupnoneedv = cx.create_metadata(b"enzyme_dupnoneedv");
+ // We used to use llvm's metadata to instruct enzyme how to differentiate a function.
+ // In debug mode we would use incremental compilation which caused the metadata to be
+ // dropped. This is prevented by now using named globals, which are also understood
+ // by Enzyme.
+ let global_const = cx.declare_global("enzyme_const", cx.type_ptr());
+ let global_out = cx.declare_global("enzyme_out", cx.type_ptr());
+ let global_dup = cx.declare_global("enzyme_dup", cx.type_ptr());
+ let global_dupv = cx.declare_global("enzyme_dupv", cx.type_ptr());
+ let global_dupnoneed = cx.declare_global("enzyme_dupnoneed", cx.type_ptr());
+ let global_dupnoneedv = cx.declare_global("enzyme_dupnoneedv", cx.type_ptr());
while activity_pos < inputs.len() {
let diff_activity = inputs[activity_pos as usize];
// Duplicated arguments received a shadow argument, into which enzyme will write the
// gradient.
- let (activity, duplicated): (&Metadata, bool) = match diff_activity {
+ let (activity, duplicated): (&Value, bool) = match diff_activity {
DiffActivity::None => panic!("not a valid input activity"),
- DiffActivity::Const => (enzyme_const, false),
- DiffActivity::Active => (enzyme_out, false),
- DiffActivity::ActiveOnly => (enzyme_out, false),
- DiffActivity::Dual => (enzyme_dup, true),
- DiffActivity::Dualv => (enzyme_dupv, true),
- DiffActivity::DualOnly => (enzyme_dupnoneed, true),
- DiffActivity::DualvOnly => (enzyme_dupnoneedv, true),
- DiffActivity::Duplicated => (enzyme_dup, true),
- DiffActivity::DuplicatedOnly => (enzyme_dupnoneed, true),
- DiffActivity::FakeActivitySize(_) => (enzyme_const, false),
+ DiffActivity::Const => (global_const, false),
+ DiffActivity::Active => (global_out, false),
+ DiffActivity::ActiveOnly => (global_out, false),
+ DiffActivity::Dual => (global_dup, true),
+ DiffActivity::Dualv => (global_dupv, true),
+ DiffActivity::DualOnly => (global_dupnoneed, true),
+ DiffActivity::DualvOnly => (global_dupnoneedv, true),
+ DiffActivity::Duplicated => (global_dup, true),
+ DiffActivity::DuplicatedOnly => (global_dupnoneed, true),
+ DiffActivity::FakeActivitySize(_) => (global_const, false),
};
let outer_arg = outer_args[outer_pos];
- args.push(cx.get_metadata_value(activity));
+ args.push(activity);
if matches!(diff_activity, DiffActivity::Dualv) {
let next_outer_arg = outer_args[outer_pos + 1];
let elem_bytes_size: u64 = match inputs[activity_pos + 1] {
@@ -242,7 +246,7 @@ fn match_args_from_caller_to_enzyme<'ll, 'tcx>(
assert_eq!(cx.type_kind(next_outer_ty3), TypeKind::Integer);
args.push(next_outer_arg2);
}
- args.push(cx.get_metadata_value(enzyme_const));
+ args.push(global_const);
args.push(next_outer_arg);
outer_pos += 2 + 2 * iterations;
activity_pos += 2;
@@ -351,13 +355,13 @@ pub(crate) fn generate_enzyme_call<'ll, 'tcx>(
let mut args = Vec::with_capacity(num_args as usize + 1);
args.push(fn_to_diff);
- let enzyme_primal_ret = cx.create_metadata(b"enzyme_primal_return");
+ let global_primal_ret = cx.declare_global("enzyme_primal_return", cx.type_ptr());
if matches!(attrs.ret_activity, DiffActivity::Dual | DiffActivity::Active) {
- args.push(cx.get_metadata_value(enzyme_primal_ret));
+ args.push(global_primal_ret);
}
if attrs.width > 1 {
- let enzyme_width = cx.create_metadata(b"enzyme_width");
- args.push(cx.get_metadata_value(enzyme_width));
+ let global_width = cx.declare_global("enzyme_width", cx.type_ptr());
+ args.push(global_width);
args.push(cx.get_const_int(cx.type_i64(), attrs.width as u64));
}
diff --git a/compiler/rustc_const_eval/messages.ftl b/compiler/rustc_const_eval/messages.ftl
index 13a49e8..3a2b3f8 100644
--- a/compiler/rustc_const_eval/messages.ftl
+++ b/compiler/rustc_const_eval/messages.ftl
@@ -481,7 +481,10 @@
[true] maybe-null
*[false] null
} box
-const_eval_validation_null_fn_ptr = {$front_matter}: encountered a null function pointer
+const_eval_validation_null_fn_ptr = {$front_matter}: encountered a {$maybe ->
+ [true] maybe-null
+ *[false] null
+ } function pointer
const_eval_validation_null_ref = {$front_matter}: encountered a {$maybe ->
[true] maybe-null
*[false] null
diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs
index d352a63..a0958a2 100644
--- a/compiler/rustc_const_eval/src/errors.rs
+++ b/compiler/rustc_const_eval/src/errors.rs
@@ -666,7 +666,7 @@ fn diagnostic_message(&self) -> DiagMessage {
PartialPointer => const_eval_validation_partial_pointer,
MutableRefToImmutable => const_eval_validation_mutable_ref_to_immutable,
MutableRefInConst => const_eval_validation_mutable_ref_in_const,
- NullFnPtr => const_eval_validation_null_fn_ptr,
+ NullFnPtr { .. } => const_eval_validation_null_fn_ptr,
NeverVal => const_eval_validation_never_val,
NonnullPtrMaybeNull { .. } => const_eval_validation_nonnull_ptr_out_of_range,
PtrOutOfRange { .. } => const_eval_validation_ptr_out_of_range,
@@ -820,12 +820,11 @@ fn add_range_arg<G: EmissionGuarantee>(
err.arg("vtable_dyn_type", vtable_dyn_type.to_string());
err.arg("expected_dyn_type", expected_dyn_type.to_string());
}
- NullPtr { maybe, .. } => {
+ NullPtr { maybe, .. } | NullFnPtr { maybe } => {
err.arg("maybe", maybe);
}
MutableRefToImmutable
| MutableRefInConst
- | NullFnPtr
| NonnullPtrMaybeNull
| NeverVal
| UnsafeCellInImmutable
diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs
index 785978b..630e99a 100644
--- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs
+++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs
@@ -878,7 +878,7 @@ pub fn write_bytes_intrinsic(
.compute_size_in_bytes(layout.size, count)
.ok_or_else(|| err_ub_custom!(fluent::const_eval_size_overflow, name = name))?;
- let bytes = std::iter::repeat(byte).take(len.bytes_usize());
+ let bytes = std::iter::repeat_n(byte, len.bytes_usize());
self.write_bytes_ptr(dst, bytes)
}
diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs
index 5f088fe..c62a23e 100644
--- a/compiler/rustc_const_eval/src/interpret/validity.rs
+++ b/compiler/rustc_const_eval/src/interpret/validity.rs
@@ -757,14 +757,12 @@ fn try_visit_primitive(
);
// FIXME: Check if the signature matches
} else {
- // Otherwise (for standalone Miri), we have to still check it to be non-null.
+ // Otherwise (for standalone Miri and for `-Zextra-const-ub-checks`),
+ // we have to still check it to be non-null.
if self.ecx.scalar_may_be_null(scalar)? {
let maybe =
!M::Provenance::OFFSET_IS_ADDR && matches!(scalar, Scalar::Ptr(..));
- // This can't be a "maybe-null" pointer since the check for this being
- // a fn ptr at all already ensures that the pointer is inbounds.
- assert!(!maybe);
- throw_validation_failure!(self.path, NullFnPtr);
+ throw_validation_failure!(self.path, NullFnPtr { maybe });
}
}
if self.reset_provenance_and_padding {
diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs
index 46accb7..d14463e 100644
--- a/compiler/rustc_hir_typeck/src/pat.rs
+++ b/compiler/rustc_hir_typeck/src/pat.rs
@@ -3115,20 +3115,29 @@ fn add_rust_2024_migration_desugared_pat(
// binding mode. This keeps it from making those suggestions, as doing so could panic.
let info = table.entry(pat_id).or_insert_with(|| ty::Rust2024IncompatiblePatInfo {
primary_labels: Vec::new(),
- bad_modifiers: false,
+ bad_ref_modifiers: false,
+ bad_mut_modifiers: false,
bad_ref_pats: false,
suggest_eliding_modes: !self.tcx.features().ref_pat_eat_one_layer_2024()
&& !self.tcx.features().ref_pat_eat_one_layer_2024_structural(),
});
let pat_kind = if let PatKind::Binding(user_bind_annot, _, _, _) = subpat.kind {
- info.bad_modifiers = true;
// If the user-provided binding modifier doesn't match the default binding mode, we'll
// need to suggest reference patterns, which can affect other bindings.
// For simplicity, we opt to suggest making the pattern fully explicit.
info.suggest_eliding_modes &=
user_bind_annot == BindingMode(ByRef::Yes(def_br_mutbl), Mutability::Not);
- "binding modifier"
+ if user_bind_annot == BindingMode(ByRef::No, Mutability::Mut) {
+ info.bad_mut_modifiers = true;
+ "`mut` binding modifier"
+ } else {
+ info.bad_ref_modifiers = true;
+ match user_bind_annot.1 {
+ Mutability::Not => "explicit `ref` binding modifier",
+ Mutability::Mut => "explicit `ref mut` binding modifier",
+ }
+ }
} else {
info.bad_ref_pats = true;
// For simplicity, we don't try to suggest eliding reference patterns. Thus, we'll
@@ -3147,11 +3156,7 @@ fn add_rust_2024_migration_desugared_pat(
// so, we may want to inspect the span's source callee or macro backtrace.
"occurs within macro expansion".to_owned()
} else {
- let dbm_str = match def_br_mutbl {
- Mutability::Not => "ref",
- Mutability::Mut => "ref mut",
- };
- format!("{pat_kind} not allowed under `{dbm_str}` default binding mode")
+ format!("{pat_kind} not allowed when implicitly borrowing")
};
info.primary_labels.push((trimmed_span, primary_label));
}
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs
index 939f3d0..8b7b13a 100644
--- a/compiler/rustc_lint_defs/src/builtin.rs
+++ b/compiler/rustc_lint_defs/src/builtin.rs
@@ -1601,7 +1601,7 @@
"detects patterns whose meaning will change in Rust 2024",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024),
- reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>",
+ reference: "<https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>",
};
}
diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs
index 951aac5..976c209 100644
--- a/compiler/rustc_middle/src/mir/interpret/error.rs
+++ b/compiler/rustc_middle/src/mir/interpret/error.rs
@@ -497,7 +497,10 @@ pub enum ValidationErrorKind<'tcx> {
MutableRefToImmutable,
UnsafeCellInImmutable,
MutableRefInConst,
- NullFnPtr,
+ NullFnPtr {
+ /// Records whether this pointer is definitely null or just may be null.
+ maybe: bool,
+ },
NeverVal,
NonnullPtrMaybeNull,
PtrOutOfRange {
diff --git a/compiler/rustc_middle/src/ty/typeck_results.rs b/compiler/rustc_middle/src/ty/typeck_results.rs
index b276b99..d1fb700 100644
--- a/compiler/rustc_middle/src/ty/typeck_results.rs
+++ b/compiler/rustc_middle/src/ty/typeck_results.rs
@@ -858,8 +858,10 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
pub struct Rust2024IncompatiblePatInfo {
/// 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 `mut` binding modifiers occur under a non-`move` default binding mode.
+ pub bad_mut_modifiers: bool,
+ /// Whether any `ref`/`ref mut` binding modifiers occur under a non-`move` default binding mode.
+ pub bad_ref_modifiers: bool,
/// Whether any `&` or `&mut` patterns occur under a non-`move` default binding mode.
pub bad_ref_pats: bool,
/// If `true`, we can give a simpler suggestion solely by eliding explicit binding modifiers.
diff --git a/compiler/rustc_mir_build/messages.ftl b/compiler/rustc_mir_build/messages.ftl
index 83fbcb3..e84e42b 100644
--- a/compiler/rustc_mir_build/messages.ftl
+++ b/compiler/rustc_mir_build/messages.ftl
@@ -322,17 +322,6 @@
mir_build_privately_uninhabited = pattern `{$witness_1}` is currently uninhabited, but this variant contains private fields which may become inhabited in the future
-mir_build_rust_2024_incompatible_pat = {$bad_modifiers ->
- *[true] binding modifiers{$bad_ref_pats ->
- *[true] {" "}and reference patterns
- [false] {""}
- }
- [false] reference patterns
- } may only be written when the default binding mode is `move`{$is_hard_error ->
- *[true] {""}
- [false] {" "}in Rust 2024
- }
-
mir_build_static_in_pattern = statics cannot be referenced in patterns
.label = can't be used in patterns
mir_build_static_in_pattern_def = `static` defined here
diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs
index 58c3de4..e2aae5b 100644
--- a/compiler/rustc_mir_build/src/errors.rs
+++ b/compiler/rustc_mir_build/src/errors.rs
@@ -1,8 +1,7 @@
-use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::codes::*;
use rustc_errors::{
Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level,
- MultiSpan, Subdiagnostic, pluralize,
+ MultiSpan, Subdiagnostic,
};
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::{self, Ty};
@@ -1087,69 +1086,6 @@ pub(crate) enum MiscPatternSuggestion {
},
}
-#[derive(LintDiagnostic)]
-#[diag(mir_build_rust_2024_incompatible_pat)]
-pub(crate) struct Rust2024IncompatiblePat {
- #[subdiagnostic]
- pub(crate) sugg: Rust2024IncompatiblePatSugg,
- pub(crate) bad_modifiers: bool,
- pub(crate) bad_ref_pats: bool,
- pub(crate) is_hard_error: bool,
-}
-
-pub(crate) struct Rust2024IncompatiblePatSugg {
- /// If true, our suggestion is to elide explicit binding modifiers.
- /// If false, our suggestion is to make the pattern fully explicit.
- pub(crate) suggest_eliding_modes: bool,
- pub(crate) suggestion: Vec<(Span, String)>,
- pub(crate) ref_pattern_count: usize,
- pub(crate) binding_mode_count: usize,
- /// 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 {
- fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
- // Format and emit explanatory notes about default binding modes. Reversing the spans' order
- // means if we have nested spans, the innermost ones will be visited first.
- for (span, def_br_mutbl) in self.default_mode_labels.into_iter().rev() {
- // Don't point to a macro call site.
- if !span.from_expansion() {
- let note_msg = "matching on a reference type with a non-reference pattern changes the default binding mode";
- let label_msg =
- format!("this matches on type `{}_`", def_br_mutbl.ref_prefix_str());
- let mut label = MultiSpan::from(span);
- label.push_span_label(span, label_msg);
- diag.span_note(label, note_msg);
- }
- }
-
- // Format and emit the suggestion.
- let applicability =
- if self.suggestion.iter().all(|(span, _)| span.can_be_used_for_suggestions()) {
- Applicability::MachineApplicable
- } else {
- Applicability::MaybeIncorrect
- };
- let msg = if self.suggest_eliding_modes {
- let plural_modes = pluralize!(self.binding_mode_count);
- format!("remove the unnecessary binding modifier{plural_modes}")
- } else {
- let plural_derefs = pluralize!(self.ref_pattern_count);
- let and_modes = if self.binding_mode_count > 0 {
- format!(" and variable binding mode{}", pluralize!(self.binding_mode_count))
- } else {
- String::new()
- };
- format!("make the implied reference pattern{plural_derefs}{and_modes} explicit")
- };
- // FIXME(dianne): for peace of mind, don't risk emitting a 0-part suggestion (that panics!)
- if !self.suggestion.is_empty() {
- diag.multipart_suggestion_verbose(msg, self.suggestion, applicability);
- }
- }
-}
-
#[derive(Diagnostic)]
#[diag(mir_build_loop_match_invalid_update)]
pub(crate) struct LoopMatchInvalidUpdate {
diff --git a/compiler/rustc_mir_build/src/thir/pattern/migration.rs b/compiler/rustc_mir_build/src/thir/pattern/migration.rs
index 12c457f..8887308 100644
--- a/compiler/rustc_mir_build/src/thir/pattern/migration.rs
+++ b/compiler/rustc_mir_build/src/thir/pattern/migration.rs
@@ -1,15 +1,12 @@
//! Automatic migration of Rust 2021 patterns to a form valid in both Editions 2021 and 2024.
use rustc_data_structures::fx::FxIndexMap;
-use rustc_errors::MultiSpan;
+use rustc_errors::{Applicability, Diag, EmissionGuarantee, MultiSpan, pluralize};
use rustc_hir::{BindingMode, ByRef, HirId, Mutability};
use rustc_lint as lint;
use rustc_middle::ty::{self, Rust2024IncompatiblePatInfo, TyCtxt};
use rustc_span::{Ident, Span};
-use crate::errors::{Rust2024IncompatiblePat, Rust2024IncompatiblePatSugg};
-use crate::fluent_generated as fluent;
-
/// For patterns flagged for migration during HIR typeck, this handles constructing and emitting
/// a diagnostic suggestion.
pub(super) struct PatMigration<'a> {
@@ -49,39 +46,90 @@ pub(super) fn emit<'tcx>(self, tcx: TyCtxt<'tcx>, pat_id: HirId) {
for (span, label) in self.info.primary_labels.iter() {
spans.push_span_label(*span, label.clone());
}
- let sugg = Rust2024IncompatiblePatSugg {
- suggest_eliding_modes: self.info.suggest_eliding_modes,
- suggestion: self.suggestion,
- ref_pattern_count: self.ref_pattern_count,
- binding_mode_count: self.binding_mode_count,
- default_mode_labels: self.default_mode_labels,
- };
// 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());
+ let primary_message = self.primary_message(is_hard_error);
if is_hard_error {
- let mut err =
- tcx.dcx().struct_span_err(spans, fluent::mir_build_rust_2024_incompatible_pat);
- if let Some(info) = lint::builtin::RUST_2024_INCOMPATIBLE_PAT.future_incompatible {
- // provide the same reference link as the lint
- err.note(format!("for more information, see {}", info.reference));
- }
- err.arg("bad_modifiers", self.info.bad_modifiers);
- err.arg("bad_ref_pats", self.info.bad_ref_pats);
- err.arg("is_hard_error", true);
- err.subdiagnostic(sugg);
+ let mut err = tcx.dcx().struct_span_err(spans, primary_message);
+ err.note("for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>");
+ self.format_subdiagnostics(&mut err);
err.emit();
} else {
- tcx.emit_node_span_lint(
- lint::builtin::RUST_2024_INCOMPATIBLE_PAT,
- pat_id,
- spans,
- Rust2024IncompatiblePat {
- sugg,
- bad_modifiers: self.info.bad_modifiers,
- bad_ref_pats: self.info.bad_ref_pats,
- is_hard_error,
- },
- );
+ tcx.node_span_lint(lint::builtin::RUST_2024_INCOMPATIBLE_PAT, pat_id, spans, |diag| {
+ diag.primary_message(primary_message);
+ self.format_subdiagnostics(diag);
+ });
+ }
+ }
+
+ fn primary_message(&self, is_hard_error: bool) -> String {
+ let verb1 = match (self.info.bad_mut_modifiers, self.info.bad_ref_modifiers) {
+ (true, true) => "write explicit binding modifiers",
+ (true, false) => "mutably bind by value",
+ (false, true) => "explicitly borrow",
+ (false, false) => "explicitly dereference",
+ };
+ let or_verb2 = match (
+ self.info.bad_mut_modifiers,
+ self.info.bad_ref_modifiers,
+ self.info.bad_ref_pats,
+ ) {
+ // We only need two verb phrases if mentioning both modifiers and reference patterns.
+ (false, false, _) | (_, _, false) => "",
+ // If mentioning `mut`, we don't have an "explicitly" yet.
+ (true, _, true) => " or explicitly dereference",
+ // If mentioning `ref`/`ref mut` but not `mut`, we already have an "explicitly".
+ (false, true, true) => " or dereference",
+ };
+ let in_rust_2024 = if is_hard_error { "" } else { " in Rust 2024" };
+ format!("cannot {verb1}{or_verb2} within an implicitly-borrowing pattern{in_rust_2024}")
+ }
+
+ fn format_subdiagnostics(self, diag: &mut Diag<'_, impl EmissionGuarantee>) {
+ // Format and emit explanatory notes about default binding modes. Reversing the spans' order
+ // means if we have nested spans, the innermost ones will be visited first.
+ for (span, def_br_mutbl) in self.default_mode_labels.into_iter().rev() {
+ // Don't point to a macro call site.
+ if !span.from_expansion() {
+ let note_msg = "matching on a reference type with a non-reference pattern implicitly borrows the contents";
+ let label_msg = format!(
+ "this non-reference pattern matches on a reference type `{}_`",
+ def_br_mutbl.ref_prefix_str()
+ );
+ let mut label = MultiSpan::from(span);
+ label.push_span_label(span, label_msg);
+ diag.span_note(label, note_msg);
+ }
+ }
+
+ // Format and emit the suggestion.
+ let applicability =
+ if self.suggestion.iter().all(|(span, _)| span.can_be_used_for_suggestions()) {
+ Applicability::MachineApplicable
+ } else {
+ Applicability::MaybeIncorrect
+ };
+ let plural_modes = pluralize!(self.binding_mode_count);
+ let msg = if self.info.suggest_eliding_modes {
+ format!("remove the unnecessary binding modifier{plural_modes}")
+ } else {
+ let match_on_these_references = if self.ref_pattern_count == 1 {
+ "match on the reference with a reference pattern"
+ } else {
+ "match on these references with reference patterns"
+ };
+ let and_explain_modes = if self.binding_mode_count > 0 {
+ let a = if self.binding_mode_count == 1 { "a " } else { "" };
+ format!(" and borrow explicitly using {a}variable binding mode{plural_modes}")
+ } else {
+ " to avoid implicitly borrowing".to_owned()
+ };
+ format!("{match_on_these_references}{and_explain_modes}")
+ };
+ // FIXME(dianne): for peace of mind, don't risk emitting a 0-part suggestion (that panics!)
+ debug_assert!(!self.suggestion.is_empty());
+ if !self.suggestion.is_empty() {
+ diag.multipart_suggestion_verbose(msg, self.suggestion, applicability);
}
}
diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs
index 5e62dab..58bacb1 100644
--- a/compiler/rustc_query_system/src/dep_graph/graph.rs
+++ b/compiler/rustc_query_system/src/dep_graph/graph.rs
@@ -11,7 +11,7 @@
use rustc_data_structures::profiling::QueryInvocationId;
use rustc_data_structures::sharded::{self, ShardedHashMap};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
-use rustc_data_structures::sync::{AtomicU64, Lock, is_dyn_thread_safe};
+use rustc_data_structures::sync::{AtomicU64, Lock};
use rustc_data_structures::unord::UnordMap;
use rustc_errors::DiagInner;
use rustc_index::IndexVec;
@@ -68,18 +68,9 @@ pub struct MarkFrame<'a> {
#[derive(Debug)]
pub(super) enum DepNodeColor {
- Red,
Green(DepNodeIndex),
-}
-
-impl DepNodeColor {
- #[inline]
- fn is_green(self) -> bool {
- match self {
- DepNodeColor::Red => false,
- DepNodeColor::Green(_) => true,
- }
- }
+ Red,
+ Unknown,
}
pub(crate) struct DepGraphData<D: Deps> {
@@ -148,10 +139,9 @@ pub fn new(
);
assert_eq!(red_node_index, DepNodeIndex::FOREVER_RED_NODE);
if prev_graph_node_count > 0 {
- colors.insert(
- SerializedDepNodeIndex::from_u32(DepNodeIndex::FOREVER_RED_NODE.as_u32()),
- DepNodeColor::Red,
- );
+ colors.insert_red(SerializedDepNodeIndex::from_u32(
+ DepNodeIndex::FOREVER_RED_NODE.as_u32(),
+ ));
}
DepGraph {
@@ -625,7 +615,7 @@ fn assert_dep_node_not_yet_allocated_in_current_session<S: std::fmt::Display>(
) {
if let Some(prev_index) = self.previous.node_to_index_opt(dep_node) {
let current = self.colors.get(prev_index);
- assert!(current.is_none(), "{}", msg())
+ assert_matches!(current, DepNodeColor::Unknown, "{}", msg())
} else if let Some(nodes_in_current_session) = &self.current.nodes_in_current_session {
outline(|| {
let seen = nodes_in_current_session.lock().contains_key(dep_node);
@@ -634,12 +624,12 @@ fn assert_dep_node_not_yet_allocated_in_current_session<S: std::fmt::Display>(
}
}
- fn node_color(&self, dep_node: &DepNode) -> Option<DepNodeColor> {
+ fn node_color(&self, dep_node: &DepNode) -> DepNodeColor {
if let Some(prev_index) = self.previous.node_to_index_opt(dep_node) {
self.colors.get(prev_index)
} else {
// This is a node that did not exist in the previous compilation session.
- None
+ DepNodeColor::Unknown
}
}
@@ -647,7 +637,7 @@ fn node_color(&self, dep_node: &DepNode) -> Option<DepNodeColor> {
/// current compilation session. Used in various assertions
#[inline]
pub(crate) fn is_index_green(&self, prev_index: SerializedDepNodeIndex) -> bool {
- self.colors.get(prev_index).is_some_and(|c| c.is_green())
+ matches!(self.colors.get(prev_index), DepNodeColor::Green(_))
}
#[inline]
@@ -821,12 +811,12 @@ pub fn dep_node_debug_str(&self, dep_node: DepNode) -> Option<String> {
self.data.as_ref()?.dep_node_debug.borrow().get(&dep_node).cloned()
}
- fn node_color(&self, dep_node: &DepNode) -> Option<DepNodeColor> {
+ fn node_color(&self, dep_node: &DepNode) -> DepNodeColor {
if let Some(ref data) = self.data {
return data.node_color(dep_node);
}
- None
+ DepNodeColor::Unknown
}
pub fn try_mark_green<Qcx: QueryContext<Deps = D>>(
@@ -855,9 +845,9 @@ pub(crate) fn try_mark_green<Qcx: QueryContext<Deps = D>>(
let prev_index = self.previous.node_to_index_opt(dep_node)?;
match self.colors.get(prev_index) {
- Some(DepNodeColor::Green(dep_node_index)) => Some((prev_index, dep_node_index)),
- Some(DepNodeColor::Red) => None,
- None => {
+ DepNodeColor::Green(dep_node_index) => Some((prev_index, dep_node_index)),
+ DepNodeColor::Red => None,
+ DepNodeColor::Unknown => {
// This DepNode and the corresponding query invocation existed
// in the previous compilation session too, so we can try to
// mark it as green by recursively marking all of its
@@ -873,12 +863,12 @@ fn try_mark_parent_green<Qcx: QueryContext<Deps = D>>(
&self,
qcx: Qcx,
parent_dep_node_index: SerializedDepNodeIndex,
- frame: Option<&MarkFrame<'_>>,
+ frame: &MarkFrame<'_>,
) -> Option<()> {
let get_dep_dep_node = || self.previous.index_to_node(parent_dep_node_index);
match self.colors.get(parent_dep_node_index) {
- Some(DepNodeColor::Green(_)) => {
+ DepNodeColor::Green(_) => {
// This dependency has been marked as green before, we are
// still fine and can continue with checking the other
// dependencies.
@@ -889,7 +879,7 @@ fn try_mark_parent_green<Qcx: QueryContext<Deps = D>>(
debug!("dependency {:?} was immediately green", get_dep_dep_node());
return Some(());
}
- Some(DepNodeColor::Red) => {
+ DepNodeColor::Red => {
// We found a dependency the value of which has changed
// compared to the previous compilation session. We cannot
// mark the DepNode as green and also don't need to bother
@@ -897,7 +887,7 @@ fn try_mark_parent_green<Qcx: QueryContext<Deps = D>>(
debug!("dependency {:?} was immediately red", get_dep_dep_node());
return None;
}
- None => {}
+ DepNodeColor::Unknown => {}
}
let dep_dep_node = &get_dep_dep_node();
@@ -911,7 +901,7 @@ fn try_mark_parent_green<Qcx: QueryContext<Deps = D>>(
);
let node_index =
- self.try_mark_previous_green(qcx, parent_dep_node_index, dep_dep_node, frame);
+ self.try_mark_previous_green(qcx, parent_dep_node_index, dep_dep_node, Some(frame));
if node_index.is_some() {
debug!("managed to MARK dependency {dep_dep_node:?} as green");
@@ -928,15 +918,15 @@ fn try_mark_parent_green<Qcx: QueryContext<Deps = D>>(
}
match self.colors.get(parent_dep_node_index) {
- Some(DepNodeColor::Green(_)) => {
+ DepNodeColor::Green(_) => {
debug!("managed to FORCE dependency {dep_dep_node:?} to green");
return Some(());
}
- Some(DepNodeColor::Red) => {
+ DepNodeColor::Red => {
debug!("dependency {dep_dep_node:?} was red after forcing");
return None;
}
- None => {}
+ DepNodeColor::Unknown => {}
}
if let None = qcx.dep_context().sess().dcx().has_errors_or_delayed_bugs() {
@@ -976,7 +966,7 @@ fn try_mark_previous_green<Qcx: QueryContext<Deps = D>>(
let prev_deps = self.previous.edge_targets_from(prev_dep_node_index);
for dep_dep_node_index in prev_deps {
- self.try_mark_parent_green(qcx, dep_dep_node_index, Some(&frame))?;
+ self.try_mark_parent_green(qcx, dep_dep_node_index, &frame)?;
}
// If we got here without hitting a `return` that means that all
@@ -1001,13 +991,13 @@ impl<D: Deps> DepGraph<D> {
/// Returns true if the given node has been marked as red during the
/// current compilation session. Used in various assertions
pub fn is_red(&self, dep_node: &DepNode) -> bool {
- matches!(self.node_color(dep_node), Some(DepNodeColor::Red))
+ matches!(self.node_color(dep_node), DepNodeColor::Red)
}
/// Returns true if the given node has been marked as green during the
/// current compilation session. Used in various assertions
pub fn is_green(&self, dep_node: &DepNode) -> bool {
- self.node_color(dep_node).is_some_and(|c| c.is_green())
+ matches!(self.node_color(dep_node), DepNodeColor::Green(_))
}
pub fn assert_dep_node_not_yet_allocated_in_current_session<S: std::fmt::Display>(
@@ -1034,11 +1024,11 @@ pub fn exec_cache_promotions<Tcx: DepContext>(&self, tcx: Tcx) {
let data = self.data.as_ref().unwrap();
for prev_index in data.colors.values.indices() {
match data.colors.get(prev_index) {
- Some(DepNodeColor::Green(_)) => {
+ DepNodeColor::Green(_) => {
let dep_node = data.previous.index_to_node(prev_index);
tcx.try_load_from_on_disk_cache(dep_node);
}
- None | Some(DepNodeColor::Red) => {
+ DepNodeColor::Unknown | DepNodeColor::Red => {
// We can skip red nodes because a node can only be marked
// as red if the query result was recomputed and thus is
// already in memory.
@@ -1318,23 +1308,21 @@ fn default() -> Self {
}
}
}
+
// A data structure that stores Option<DepNodeColor> values as a contiguous
// array, using one u32 per entry.
pub(super) struct DepNodeColorMap {
values: IndexVec<SerializedDepNodeIndex, AtomicU32>,
- sync: bool,
}
-const COMPRESSED_NONE: u32 = u32::MAX;
+// All values below `COMPRESSED_RED` are green.
const COMPRESSED_RED: u32 = u32::MAX - 1;
+const COMPRESSED_UNKNOWN: u32 = u32::MAX;
impl DepNodeColorMap {
fn new(size: usize) -> DepNodeColorMap {
debug_assert!(COMPRESSED_RED > DepNodeIndex::MAX_AS_U32);
- DepNodeColorMap {
- values: (0..size).map(|_| AtomicU32::new(COMPRESSED_NONE)).collect(),
- sync: is_dyn_thread_safe(),
- }
+ DepNodeColorMap { values: (0..size).map(|_| AtomicU32::new(COMPRESSED_UNKNOWN)).collect() }
}
#[inline]
@@ -1353,58 +1341,48 @@ pub(super) fn try_mark_green(
index: DepNodeIndex,
) -> Result<(), DepNodeIndex> {
let value = &self.values[prev_index];
- if self.sync {
- match value.compare_exchange(
- COMPRESSED_NONE,
- index.as_u32(),
- Ordering::Relaxed,
- Ordering::Relaxed,
- ) {
- Ok(_) => Ok(()),
- Err(v) => Err(DepNodeIndex::from_u32(v)),
- }
+ match value.compare_exchange(
+ COMPRESSED_UNKNOWN,
+ index.as_u32(),
+ Ordering::Relaxed,
+ Ordering::Relaxed,
+ ) {
+ Ok(_) => Ok(()),
+ Err(v) => Err(DepNodeIndex::from_u32(v)),
+ }
+ }
+
+ #[inline]
+ pub(super) fn get(&self, index: SerializedDepNodeIndex) -> DepNodeColor {
+ let value = self.values[index].load(Ordering::Acquire);
+ // Green is by far the most common case. Check for that first so we can succeed with a
+ // single comparison.
+ if value < COMPRESSED_RED {
+ DepNodeColor::Green(DepNodeIndex::from_u32(value))
+ } else if value == COMPRESSED_RED {
+ DepNodeColor::Red
} else {
- let v = value.load(Ordering::Relaxed);
- if v == COMPRESSED_NONE {
- value.store(index.as_u32(), Ordering::Relaxed);
- Ok(())
- } else {
- Err(DepNodeIndex::from_u32(v))
- }
+ debug_assert_eq!(value, COMPRESSED_UNKNOWN);
+ DepNodeColor::Unknown
}
}
#[inline]
- pub(super) fn get(&self, index: SerializedDepNodeIndex) -> Option<DepNodeColor> {
- match self.values[index].load(Ordering::Acquire) {
- COMPRESSED_NONE => None,
- COMPRESSED_RED => Some(DepNodeColor::Red),
- value => Some(DepNodeColor::Green(DepNodeIndex::from_u32(value))),
- }
- }
-
- #[inline]
- pub(super) fn insert(&self, index: SerializedDepNodeIndex, color: DepNodeColor) {
- self.values[index].store(
- match color {
- DepNodeColor::Red => COMPRESSED_RED,
- DepNodeColor::Green(index) => index.as_u32(),
- },
- Ordering::Release,
- )
+ pub(super) fn insert_red(&self, index: SerializedDepNodeIndex) {
+ self.values[index].store(COMPRESSED_RED, Ordering::Release)
}
}
#[inline(never)]
#[cold]
-pub(crate) fn print_markframe_trace<D: Deps>(graph: &DepGraph<D>, frame: Option<&MarkFrame<'_>>) {
+pub(crate) fn print_markframe_trace<D: Deps>(graph: &DepGraph<D>, frame: &MarkFrame<'_>) {
let data = graph.data.as_ref().unwrap();
eprintln!("there was a panic while trying to force a dep node");
eprintln!("try_mark_green dep node stack:");
let mut i = 0;
- let mut current = frame;
+ let mut current = Some(frame);
while let Some(frame) = current {
let node = data.previous.index_to_node(frame.index);
eprintln!("#{i} {node:?}");
diff --git a/compiler/rustc_query_system/src/dep_graph/mod.rs b/compiler/rustc_query_system/src/dep_graph/mod.rs
index 512034a..d648415 100644
--- a/compiler/rustc_query_system/src/dep_graph/mod.rs
+++ b/compiler/rustc_query_system/src/dep_graph/mod.rs
@@ -63,7 +63,7 @@ fn try_force_from_dep_node(
self,
dep_node: DepNode,
prev_index: SerializedDepNodeIndex,
- frame: Option<&MarkFrame<'_>>,
+ frame: &MarkFrame<'_>,
) -> bool {
let cb = self.dep_kind_info(dep_node.kind);
if let Some(f) = cb.force_from_dep_node {
diff --git a/compiler/rustc_query_system/src/dep_graph/serialized.rs b/compiler/rustc_query_system/src/dep_graph/serialized.rs
index 79b99c5..43cac01 100644
--- a/compiler/rustc_query_system/src/dep_graph/serialized.rs
+++ b/compiler/rustc_query_system/src/dep_graph/serialized.rs
@@ -59,7 +59,7 @@
use rustc_session::Session;
use tracing::{debug, instrument};
-use super::graph::{CurrentDepGraph, DepNodeColor, DepNodeColorMap};
+use super::graph::{CurrentDepGraph, DepNodeColorMap};
use super::query::DepGraphQuery;
use super::{DepKind, DepNode, DepNodeIndex, Deps};
use crate::dep_graph::edges::EdgesVec;
@@ -906,7 +906,7 @@ pub(crate) fn send_and_color(
Err(dep_node_index) => return dep_node_index,
}
} else {
- colors.insert(prev_index, DepNodeColor::Red);
+ colors.insert_red(prev_index);
}
self.status.bump_index(&mut *local);
@@ -914,8 +914,9 @@ pub(crate) fn send_and_color(
index
}
- /// Encodes a node that was promoted from the previous graph. It reads the information directly from
- /// the previous dep graph and expects all edges to already have a new dep node index assigned.
+ /// Encodes a node that was promoted from the previous graph. It reads the information directly
+ /// from the previous dep graph and expects all edges to already have a new dep node index
+ /// assigned.
///
/// This will also ensure the dep node is marked green.
#[inline]
diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs
index 4415300..3931c3c 100644
--- a/compiler/rustc_resolve/src/ident.rs
+++ b/compiler/rustc_resolve/src/ident.rs
@@ -3,7 +3,7 @@
use rustc_ast::{self as ast, NodeId};
use rustc_errors::ErrorGuaranteed;
use rustc_hir::def::{DefKind, MacroKinds, Namespace, NonMacroAttrKind, PartialRes, PerNS};
-use rustc_middle::bug;
+use rustc_middle::{bug, span_bug};
use rustc_session::lint::builtin::PROC_MACRO_DERIVE_RESOLUTION_FALLBACK;
use rustc_session::parse::feature_err;
use rustc_span::hygiene::{ExpnId, ExpnKind, LocalExpnId, MacroKind, SyntaxContext};
@@ -677,14 +677,21 @@ struct Flags: u8 {
innermost_binding,
binding,
)
- || flags.contains(Flags::MACRO_RULES)
- && innermost_flags.contains(Flags::MODULE)
- && !this.disambiguate_macro_rules_vs_modularized(
- binding,
- innermost_binding,
- )
{
Some(AmbiguityKind::MacroRulesVsModularized)
+ } else if flags.contains(Flags::MACRO_RULES)
+ && innermost_flags.contains(Flags::MODULE)
+ {
+ // should be impossible because of visitation order in
+ // visit_scopes
+ //
+ // we visit all macro_rules scopes (e.g. textual scope macros)
+ // before we visit any modules (e.g. path-based scope macros)
+ span_bug!(
+ orig_ident.span,
+ "ambiguous scoped macro resolutions with path-based \
+ scope resolution as first candidate"
+ )
} else if innermost_binding.is_glob_import() {
Some(AmbiguityKind::GlobVsOuter)
} else if innermost_binding
diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs
index b44b1c9..d9c3f40 100644
--- a/compiler/rustc_resolve/src/lib.rs
+++ b/compiler/rustc_resolve/src/lib.rs
@@ -2226,16 +2226,14 @@ fn disambiguate_macro_rules_vs_modularized(
// Some non-controversial subset of ambiguities "modularized macro name" vs "macro_rules"
// is disambiguated to mitigate regressions from macro modularization.
// Scoping for `macro_rules` behaves like scoping for `let` at module level, in general.
- match (
- self.binding_parent_modules.get(¯o_rules),
- self.binding_parent_modules.get(&modularized),
- ) {
- (Some(macro_rules), Some(modularized)) => {
- macro_rules.nearest_parent_mod() == modularized.nearest_parent_mod()
- && modularized.is_ancestor_of(*macro_rules)
- }
- _ => false,
- }
+ //
+ // panic on index should be impossible, the only name_bindings passed in should be from
+ // `resolve_ident_in_scope_set` which will always refer to a local binding from an
+ // import or macro definition
+ let macro_rules = &self.binding_parent_modules[¯o_rules];
+ let modularized = &self.binding_parent_modules[&modularized];
+ macro_rules.nearest_parent_mod() == modularized.nearest_parent_mod()
+ && modularized.is_ancestor_of(*macro_rules)
}
fn extern_prelude_get_item<'r>(
diff --git a/library/proc_macro/src/bridge/arena.rs b/library/proc_macro/src/bridge/arena.rs
index bf5a5b5..5e0393e 100644
--- a/library/proc_macro/src/bridge/arena.rs
+++ b/library/proc_macro/src/bridge/arena.rs
@@ -7,7 +7,7 @@
use std::cell::{Cell, RefCell};
use std::mem::MaybeUninit;
use std::ops::Range;
-use std::{cmp, ptr, slice, str};
+use std::{cmp, ptr, slice};
// The arenas start with PAGE-sized chunks, and then each new chunk is twice as
// big as its predecessor, up until we reach HUGE_PAGE-sized chunks, whereupon
@@ -90,14 +90,13 @@ fn alloc_raw(&self, bytes: usize) -> &mut [MaybeUninit<u8>] {
return &mut [];
}
- loop {
- if let Some(a) = self.alloc_raw_without_grow(bytes) {
- break a;
- }
- // No free space left. Allocate a new chunk to satisfy the request.
- // On failure the grow will panic or abort.
- self.grow(bytes);
+ if let Some(a) = self.alloc_raw_without_grow(bytes) {
+ return a;
}
+ // No free space left. Allocate a new chunk to satisfy the request.
+ // On failure the grow will panic or abort.
+ self.grow(bytes);
+ self.alloc_raw_without_grow(bytes).unwrap()
}
#[allow(clippy::mut_from_ref)] // arena allocator
diff --git a/library/proc_macro/src/bridge/mod.rs b/library/proc_macro/src/bridge/mod.rs
index 1b09deb..582c43c 100644
--- a/library/proc_macro/src/bridge/mod.rs
+++ b/library/proc_macro/src/bridge/mod.rs
@@ -143,7 +143,7 @@ macro_rules! with_api_handle_types {
use buffer::Buffer;
pub use rpc::PanicMessage;
-use rpc::{Decode, DecodeMut, Encode, Reader, Writer};
+use rpc::{DecodeMut, Encode, Reader, Writer};
/// Configuration for establishing an active connection between a server and a
/// client. The server creates the bridge config (`run_server` in `server.rs`),
diff --git a/library/proc_macro/src/bridge/rpc.rs b/library/proc_macro/src/bridge/rpc.rs
index 85fd7d1..7f4f5fc 100644
--- a/library/proc_macro/src/bridge/rpc.rs
+++ b/library/proc_macro/src/bridge/rpc.rs
@@ -3,7 +3,6 @@
use std::any::Any;
use std::io::Write;
use std::num::NonZero;
-use std::str;
pub(super) type Writer = super::buffer::Buffer;
@@ -13,10 +12,6 @@ pub(super) trait Encode<S>: Sized {
pub(super) type Reader<'a> = &'a [u8];
-pub(super) trait Decode<'a, 's, S>: Sized {
- fn decode(r: &mut Reader<'a>, s: &'s S) -> Self;
-}
-
pub(super) trait DecodeMut<'a, 's, S>: Sized {
fn decode(r: &mut Reader<'a>, s: &'s mut S) -> Self;
}
@@ -31,7 +26,7 @@ fn encode(self, w: &mut Writer, _: &mut S) {
impl<S> DecodeMut<'_, '_, S> for $ty {
fn decode(r: &mut Reader<'_>, _: &mut S) -> Self {
- const N: usize = ::std::mem::size_of::<$ty>();
+ const N: usize = size_of::<$ty>();
let mut bytes = [0; N];
bytes.copy_from_slice(&r[..N]);
diff --git a/library/proc_macro/src/bridge/server.rs b/library/proc_macro/src/bridge/server.rs
index 0bb3069..2850e10 100644
--- a/library/proc_macro/src/bridge/server.rs
+++ b/library/proc_macro/src/bridge/server.rs
@@ -40,10 +40,10 @@ fn decode(r: &mut Reader<'_>, s: &mut HandleStore<MarkedTypes<S>>) -> Self {
}
}
- impl<'s, S: Types> Decode<'_, 's, HandleStore<MarkedTypes<S>>>
+ impl<'s, S: Types> DecodeMut<'_, 's, HandleStore<MarkedTypes<S>>>
for &'s Marked<S::$oty, client::$oty>
{
- fn decode(r: &mut Reader<'_>, s: &'s HandleStore<MarkedTypes<S>>) -> Self {
+ fn decode(r: &mut Reader<'_>, s: &'s mut HandleStore<MarkedTypes<S>>) -> Self {
&s.$oty[handle::Handle::decode(r, &mut ())]
}
}
diff --git a/library/proc_macro/src/bridge/symbol.rs b/library/proc_macro/src/bridge/symbol.rs
index 57ca7db..eb7d30f 100644
--- a/library/proc_macro/src/bridge/symbol.rs
+++ b/library/proc_macro/src/bridge/symbol.rs
@@ -11,7 +11,6 @@
use std::cell::RefCell;
use std::num::NonZero;
-use std::str;
use super::*;
diff --git a/src/bootstrap/src/core/build_steps/run.rs b/src/bootstrap/src/core/build_steps/run.rs
index 9f7248b..b9a4c1b 100644
--- a/src/bootstrap/src/core/build_steps/run.rs
+++ b/src/bootstrap/src/core/build_steps/run.rs
@@ -6,6 +6,7 @@
use std::path::PathBuf;
use build_helper::exit;
+use build_helper::git::get_git_untracked_files;
use clap_complete::{Generator, shells};
use crate::core::build_steps::dist::distdir;
@@ -208,6 +209,16 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
let dest = builder.src.join("license-metadata.json");
+ if !builder.config.dry_run() {
+ builder.require_and_update_all_submodules();
+ if let Ok(Some(untracked)) = get_git_untracked_files(None) {
+ eprintln!(
+ "Warning: {} untracked files may cause the license report to be incorrect.",
+ untracked.len()
+ );
+ }
+ }
+
let mut cmd = builder.tool_cmd(Tool::CollectLicenseMetadata);
cmd.env("REUSE_EXE", reuse);
cmd.env("DEST", &dest);
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs
index b8aaafc..0d4e245 100644
--- a/src/librustdoc/core.rs
+++ b/src/librustdoc/core.rs
@@ -407,6 +407,9 @@ pub(crate) fn run_global_ctxt(
crate::lint::MISSING_CRATE_LEVEL_DOCS,
DocContext::as_local_hir_id(tcx, krate.module.item_id).unwrap(),
|lint| {
+ if let Some(local_def_id) = krate.module.item_id.as_local_def_id() {
+ lint.span(tcx.def_span(local_def_id));
+ }
lint.primary_message("no documentation found for this crate's top-level module");
lint.help(help);
},
diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css
index 09d289d..7f47856 100644
--- a/src/librustdoc/html/static/css/rustdoc.css
+++ b/src/librustdoc/html/static/css/rustdoc.css
@@ -1987,12 +1987,10 @@
color: inherit;
}
#search-tabs button:not(.selected) {
- --search-tab-button-background: var(--search-tab-button-not-selected-background);
background-color: var(--search-tab-button-not-selected-background);
border-top-color: var(--search-tab-button-not-selected-border-top-color);
}
#search-tabs button:hover, #search-tabs button.selected {
- --search-tab-button-background: var(--search-tab-button-selected-background);
background-color: var(--search-tab-button-selected-background);
border-top-color: var(--search-tab-button-selected-border-top-color);
}
@@ -2008,66 +2006,27 @@
color: transparent;
}
-.search-form.loading {
- --search-tab-button-background: var(--button-background-color);
-}
-
-#search-tabs .count.loading::before,
-.search-form.loading::before
-{
- width: 16px;
- height: 16px;
- border-radius: 16px;
- background: radial-gradient(
- var(--search-tab-button-background) 0 50%,
- transparent 50% 100%
- ), conic-gradient(
- var(--code-highlight-kw-color) 0deg 30deg,
- var(--code-highlight-prelude-color) 30deg 60deg,
- var(--code-highlight-number-color) 90deg 120deg,
- var(--code-highlight-lifetime-color ) 120deg 150deg,
- var(--code-highlight-comment-color) 150deg 180deg,
- var(--code-highlight-self-color) 180deg 210deg,
- var(--code-highlight-attribute-color) 210deg 240deg,
- var(--code-highlight-literal-color) 210deg 240deg,
- var(--code-highlight-macro-color) 240deg 270deg,
- var(--code-highlight-question-mark-color) 270deg 300deg,
- var(--code-highlight-prelude-val-color) 300deg 330deg,
- var(--code-highlight-doc-comment-color) 330deg 360deg
- );
- content: "";
- position: absolute;
- left: 2px;
- top: 2px;
- animation: rotating 1.25s linear infinite;
-}
-#search-tabs .count.loading::after,
.search-form.loading::after
{
width: 18px;
height: 18px;
border-radius: 18px;
- background: conic-gradient(
- var(--search-tab-button-background) 0deg 180deg,
- transparent 270deg 360deg
- );
- content: "";
+ /* hourglass */
+ content: url('data:image/svg+xml,\
+ <svg width="16" height="16" viewBox="0 0 8 8" xmlns="http://www.w3.org/2000/svg">\
+ <g fill="none">\
+ <path d="m3.019 1.496v1.496l0.5878 1.018-0.5751 0.996v1.494" stroke="%233f3f3f"/>\
+ <path d="m5.003 1.496v1.496l-0.5878 1.018 0.5751 0.996v1.494" stroke="%233f3f3f"/>\
+ <path d="m2.006 1.5h3.978" stroke="%23000"/>\
+ <path d="m2.006 6.49h3.993" stroke="%23000"/>\
+ </g>\
+ <path d="m4.005 5.301-0.3987 0.6905h0.7977z" fill="%237f7f7f"/>\
+ <path d="m4.011 3.712-0.3987-0.6905h0.7977z" fill="%237f7f7f"/>\
+ </svg>');
position: absolute;
- left: 1px;
- top: 1px;
- animation: rotating 0.66s linear infinite;
-}
-
-.search-form.loading::before {
- left: auto;
- right: 9px;
- top: 8px;
-}
-
-.search-form.loading::after {
- left: auto;
right: 8px;
top: 8px;
+ filter: var(--settings-menu-filter);
}
#search .error code {
diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js
index 9a6d4c7..0929d35 100644
--- a/src/librustdoc/html/static/js/search.js
+++ b/src/librustdoc/html/static/js/search.js
@@ -1,5 +1,5 @@
// ignore-tidy-filelength
-/* global addClass, getNakedUrl, getVar, nonnull, getSettingValue */
+/* global addClass, getNakedUrl, getVar, getSettingValue, hasClass, nonnull */
/* global onEachLazy, removeClass, searchState, browserSupportsHistoryApi */
"use strict";
@@ -4804,6 +4804,15 @@
if (nb === iter) {
addClass(elem, "selected");
foundCurrentTab = true;
+ onEachLazy(document.querySelectorAll(
+ ".search-form",
+ ), form => {
+ if (hasClass(elem.firstElementChild, "loading")) {
+ addClass(form, "loading");
+ } else {
+ removeClass(form, "loading");
+ }
+ });
} else {
removeClass(elem, "selected");
}
@@ -5019,7 +5028,9 @@
await Promise.all(descList);
// need to make sure the element is shown before
// running this callback
- yieldToBrowser().then(() => finishedCallback(count, output));
+ yieldToBrowser().then(() => {
+ finishedCallback(count, output);
+ });
}
});
};
@@ -5156,6 +5167,7 @@
count < 100 ? `\u{2007}(${count})\u{2007}` : `\u{2007}(${count})`;
tabCount.innerHTML = fmtNbElems;
tabCount.className = "count";
+ printTab(window.searchState.currentTab);
}, isTypeSearch),
];
}
@@ -5215,9 +5227,12 @@
resultsElem.id = "results";
search.innerHTML = "";
- for (const [tab, output] of tabs) {
+ for (const [tabNb, [tab, output]] of tabs.entries()) {
tabsElem.appendChild(tab);
+ const isCurrentTab = window.searchState.currentTab === tabNb;
const placeholder = document.createElement("div");
+ placeholder.className = isCurrentTab ? "search-results active" : "search-results";
+ placeholder.innerHTML = "Loading...";
output.then(output => {
if (placeholder.parentElement) {
placeholder.parentElement.replaceChild(output, placeholder);
@@ -5474,11 +5489,6 @@
const database = await Stringdex.loadDatabase(hooks);
if (typeof window !== "undefined") {
docSearch = new DocSearch(ROOT_PATH, database);
- onEachLazy(document.querySelectorAll(
- ".search-form.loading",
- ), form => {
- removeClass(form, "loading");
- });
registerSearchEvents();
// If there's a search term in the URL, execute the search now.
if (window.searchState.getQueryStringParams().search !== undefined) {
diff --git a/tests/rustdoc-gui/search-throbber.goml b/tests/rustdoc-gui/search-throbber.goml
new file mode 100644
index 0000000..9d41f93
--- /dev/null
+++ b/tests/rustdoc-gui/search-throbber.goml
@@ -0,0 +1,23 @@
+// We are intentionally triggering errors for race-free throbber test
+fail-on-request-error: false
+fail-on-js-error: false
+
+// First, make sure the throbber goes away when done
+go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search="
+wait-for: ".search-input"
+wait-for-false: ".search-form.loading"
+write-into: (".search-input", "test")
+press-key: 'Enter'
+wait-for-false: ".search-form.loading"
+
+// Make sure the throbber shows up if we prevent the search from
+// ever finishing (this tactic is needed to make sure we don't get stuck
+// with any race conditions).
+go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search="
+block-network-request: "*/desc/*.js"
+reload:
+wait-for: ".search-input"
+wait-for-false: ".search-form.loading"
+write-into: (".search-input", "test")
+press-key: 'Enter'
+wait-for: ".search-form.loading"
diff --git a/tests/rustdoc-ui/lints/check.rs b/tests/rustdoc-ui/lints/check.rs
index 0943f9f..9a4cc96 100644
--- a/tests/rustdoc-ui/lints/check.rs
+++ b/tests/rustdoc-ui/lints/check.rs
@@ -2,7 +2,7 @@
//@ compile-flags: -Z unstable-options --check
//@ normalize-stderr: "nightly|beta|1\.[0-9][0-9]\.[0-9]" -> "$$CHANNEL"
-#![feature(rustdoc_missing_doc_code_examples)]
+#![feature(rustdoc_missing_doc_code_examples)] //~ WARN no documentation found for this crate's top-level module
//~^ WARN
#![warn(missing_docs)]
@@ -12,5 +12,3 @@
pub fn foo() {}
//~^ WARN
//~^^ WARN
-
-//~? WARN no documentation found for this crate's top-level module
diff --git a/tests/rustdoc-ui/lints/check.stderr b/tests/rustdoc-ui/lints/check.stderr
index dcdf25d..52c8c17 100644
--- a/tests/rustdoc-ui/lints/check.stderr
+++ b/tests/rustdoc-ui/lints/check.stderr
@@ -22,6 +22,15 @@
| ^^^^^^^^^^^^
warning: no documentation found for this crate's top-level module
+ --> $DIR/check.rs:5:1
+ |
+LL | / #![feature(rustdoc_missing_doc_code_examples)]
+LL | |
+LL | |
+LL | | #![warn(missing_docs)]
+... |
+LL | | pub fn foo() {}
+ | |_______________^
|
= help: The following guide may be of use:
https://doc.rust-lang.org/$CHANNEL/rustdoc/how-to-write-documentation.html
diff --git a/tests/rustdoc-ui/lints/no-crate-level-doc-lint.rs b/tests/rustdoc-ui/lints/no-crate-level-doc-lint.rs
index 5e7dc37..0402fa5 100644
--- a/tests/rustdoc-ui/lints/no-crate-level-doc-lint.rs
+++ b/tests/rustdoc-ui/lints/no-crate-level-doc-lint.rs
@@ -1,7 +1,5 @@
//@ normalize-stderr: "nightly|beta|1\.[0-9][0-9]\.[0-9]" -> "$$CHANNEL"
-#![deny(rustdoc::missing_crate_level_docs)]
+#![deny(rustdoc::missing_crate_level_docs)] //~ ERROR no documentation found for this crate's top-level module
//^~ NOTE defined here
pub fn foo() {}
-
-//~? ERROR no documentation found for this crate's top-level module
diff --git a/tests/rustdoc-ui/lints/no-crate-level-doc-lint.stderr b/tests/rustdoc-ui/lints/no-crate-level-doc-lint.stderr
index 721d366..8d2b9b4 100644
--- a/tests/rustdoc-ui/lints/no-crate-level-doc-lint.stderr
+++ b/tests/rustdoc-ui/lints/no-crate-level-doc-lint.stderr
@@ -1,4 +1,10 @@
error: no documentation found for this crate's top-level module
+ --> $DIR/no-crate-level-doc-lint.rs:2:1
+ |
+LL | / #![deny(rustdoc::missing_crate_level_docs)]
+... |
+LL | | pub fn foo() {}
+ | |_______________^
|
= help: The following guide may be of use:
https://doc.rust-lang.org/$CHANNEL/rustdoc/how-to-write-documentation.html
diff --git a/tests/ui/asm/naked-invalid-attr.stderr b/tests/ui/asm/naked-invalid-attr.stderr
index 33bbfc8..923d2de 100644
--- a/tests/ui/asm/naked-invalid-attr.stderr
+++ b/tests/ui/asm/naked-invalid-attr.stderr
@@ -18,7 +18,7 @@
LL | #[unsafe(naked)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[naked]` can be applied to methods and functions
+ = help: `#[naked]` can be applied to functions and methods
error: `#[naked]` attribute cannot be used on structs
--> $DIR/naked-invalid-attr.rs:13:1
@@ -50,7 +50,7 @@
LL | #[unsafe(naked)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[naked]` can be applied to methods and functions
+ = help: `#[naked]` can be applied to functions and methods
error[E0736]: attribute incompatible with `#[unsafe(naked)]`
--> $DIR/naked-invalid-attr.rs:56:3
diff --git a/tests/ui/attributes/attr-on-mac-call.stderr b/tests/ui/attributes/attr-on-mac-call.stderr
index 02c0ec8..1aeec46 100644
--- a/tests/ui/attributes/attr-on-mac-call.stderr
+++ b/tests/ui/attributes/attr-on-mac-call.stderr
@@ -55,7 +55,7 @@
| ^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, foreign statics, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, and crates
+ = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, unions, and use statements
warning: `#[inline]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:24:5
@@ -136,7 +136,7 @@
| ^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, foreign statics, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, and crates
+ = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, unions, and use statements
warning: `#[automatically_derived]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:51:5
@@ -154,7 +154,7 @@
| ^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[macro_use]` can be applied to modules, extern crates, and crates
+ = help: `#[macro_use]` can be applied to crates, extern crates, and modules
warning: `#[must_use]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:57:5
@@ -163,7 +163,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
warning: `#[no_implicit_prelude]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:60:5
@@ -172,7 +172,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[no_implicit_prelude]` can be applied to modules and crates
+ = help: `#[no_implicit_prelude]` can be applied to crates and modules
warning: `#[path]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:63:5
diff --git a/tests/ui/attributes/linkage.stderr b/tests/ui/attributes/linkage.stderr
index d2aee38..167cdb0 100644
--- a/tests/ui/attributes/linkage.stderr
+++ b/tests/ui/attributes/linkage.stderr
@@ -4,7 +4,7 @@
LL | #[linkage = "weak"]
| ^^^^^^^^^^^^^^^^^^^
|
- = help: `#[linkage]` can be applied to functions, statics, and foreign statics
+ = help: `#[linkage]` can be applied to foreign statics, functions, and statics
error: `#[linkage]` attribute cannot be used on modules
--> $DIR/linkage.rs:9:1
@@ -12,7 +12,7 @@
LL | #[linkage = "weak"]
| ^^^^^^^^^^^^^^^^^^^
|
- = help: `#[linkage]` can be applied to functions, statics, and foreign statics
+ = help: `#[linkage]` can be applied to foreign statics, functions, and statics
error: `#[linkage]` attribute cannot be used on structs
--> $DIR/linkage.rs:12:1
@@ -20,7 +20,7 @@
LL | #[linkage = "weak"]
| ^^^^^^^^^^^^^^^^^^^
|
- = help: `#[linkage]` can be applied to functions, statics, and foreign statics
+ = help: `#[linkage]` can be applied to foreign statics, functions, and statics
error: `#[linkage]` attribute cannot be used on inherent impl blocks
--> $DIR/linkage.rs:15:1
@@ -28,7 +28,7 @@
LL | #[linkage = "weak"]
| ^^^^^^^^^^^^^^^^^^^
|
- = help: `#[linkage]` can be applied to functions, statics, and foreign statics
+ = help: `#[linkage]` can be applied to foreign statics, functions, and statics
error: `#[linkage]` attribute cannot be used on expressions
--> $DIR/linkage.rs:23:5
@@ -36,7 +36,7 @@
LL | #[linkage = "weak"]
| ^^^^^^^^^^^^^^^^^^^
|
- = help: `#[linkage]` can be applied to functions, statics, and foreign statics
+ = help: `#[linkage]` can be applied to foreign statics, functions, and statics
error: `#[linkage]` attribute cannot be used on closures
--> $DIR/linkage.rs:39:13
@@ -44,7 +44,7 @@
LL | let _ = #[linkage = "weak"]
| ^^^^^^^^^^^^^^^^^^^
|
- = help: `#[linkage]` can be applied to methods, functions, statics, foreign statics, and foreign functions
+ = help: `#[linkage]` can be applied to foreign functions, foreign statics, functions, methods, and statics
error: aborting due to 6 previous errors
diff --git a/tests/ui/attributes/malformed-static-align.stderr b/tests/ui/attributes/malformed-static-align.stderr
index 35f654d..e618ca8 100644
--- a/tests/ui/attributes/malformed-static-align.stderr
+++ b/tests/ui/attributes/malformed-static-align.stderr
@@ -25,7 +25,7 @@
LL | #[rustc_align_static(16)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
- = help: `#[rustc_align_static]` can be applied to statics and foreign statics
+ = help: `#[rustc_align_static]` can be applied to foreign statics and statics
error: `#[repr(align(...))]` is not supported on statics
--> $DIR/malformed-static-align.rs:13:8
diff --git a/tests/ui/autodiff/autodiff_illegal.rs b/tests/ui/autodiff/autodiff_illegal.rs
index a53b6d5..6bb384c 100644
--- a/tests/ui/autodiff/autodiff_illegal.rs
+++ b/tests/ui/autodiff/autodiff_illegal.rs
@@ -110,15 +110,6 @@ fn f14(x: f32) -> Foo {
type MyFloat = f32;
-// We would like to support type alias to f32/f64 in argument type in the future,
-// but that requires us to implement our checks at a later stage
-// like THIR which has type information available.
-#[autodiff_reverse(df15, Active, Active)]
-fn f15(x: MyFloat) -> f32 {
- //~^^ ERROR failed to resolve: use of undeclared type `MyFloat` [E0433]
- unimplemented!()
-}
-
// We would like to support type alias to f32/f64 in return type in the future
#[autodiff_reverse(df16, Active, Active)]
fn f16(x: f32) -> MyFloat {
@@ -136,13 +127,6 @@ fn f17(x: f64) -> F64Trans {
unimplemented!()
}
-// We would like to support `#[repr(transparent)]` f32/f64 wrapper in argument type in the future
-#[autodiff_reverse(df18, Active, Active)]
-fn f18(x: F64Trans) -> f64 {
- //~^^ ERROR failed to resolve: use of undeclared type `F64Trans` [E0433]
- unimplemented!()
-}
-
// Invalid return activity
#[autodiff_forward(df19, Dual, Active)]
fn f19(x: f32) -> f32 {
@@ -163,11 +147,4 @@ fn f21(x: f32) -> f32 {
unimplemented!()
}
-struct DoesNotImplDefault;
-#[autodiff_forward(df22, Dual)]
-pub fn f22() -> DoesNotImplDefault {
- //~^^ ERROR the function or associated item `default` exists for tuple `(DoesNotImplDefault, DoesNotImplDefault)`, but its trait bounds were not satisfied
- unimplemented!()
-}
-
fn main() {}
diff --git a/tests/ui/autodiff/autodiff_illegal.stderr b/tests/ui/autodiff/autodiff_illegal.stderr
index ad6f10a..848ae11 100644
--- a/tests/ui/autodiff/autodiff_illegal.stderr
+++ b/tests/ui/autodiff/autodiff_illegal.stderr
@@ -107,53 +107,24 @@
| ^^^^^^^
error: invalid return activity Active in Forward Mode
- --> $DIR/autodiff_illegal.rs:147:1
+ --> $DIR/autodiff_illegal.rs:131:1
|
LL | #[autodiff_forward(df19, Dual, Active)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: invalid return activity Dual in Reverse Mode
- --> $DIR/autodiff_illegal.rs:153:1
+ --> $DIR/autodiff_illegal.rs:137:1
|
LL | #[autodiff_reverse(df20, Active, Dual)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: invalid return activity Duplicated in Reverse Mode
- --> $DIR/autodiff_illegal.rs:160:1
+ --> $DIR/autodiff_illegal.rs:144:1
|
LL | #[autodiff_reverse(df21, Active, Duplicated)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error[E0433]: failed to resolve: use of undeclared type `MyFloat`
- --> $DIR/autodiff_illegal.rs:116:1
- |
-LL | #[autodiff_reverse(df15, Active, Active)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared type `MyFloat`
+error: aborting due to 18 previous errors
-error[E0433]: failed to resolve: use of undeclared type `F64Trans`
- --> $DIR/autodiff_illegal.rs:140:1
- |
-LL | #[autodiff_reverse(df18, Active, Active)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared type `F64Trans`
-
-error[E0599]: the function or associated item `default` exists for tuple `(DoesNotImplDefault, DoesNotImplDefault)`, but its trait bounds were not satisfied
- --> $DIR/autodiff_illegal.rs:167:1
- |
-LL | struct DoesNotImplDefault;
- | ------------------------- doesn't satisfy `DoesNotImplDefault: Default`
-LL | #[autodiff_forward(df22, Dual)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item cannot be called on `(DoesNotImplDefault, DoesNotImplDefault)` due to unsatisfied trait bounds
- |
- = note: the following trait bounds were not satisfied:
- `DoesNotImplDefault: Default`
- which is required by `(DoesNotImplDefault, DoesNotImplDefault): Default`
-help: consider annotating `DoesNotImplDefault` with `#[derive(Default)]`
- |
-LL + #[derive(Default)]
-LL | struct DoesNotImplDefault;
- |
-
-error: aborting due to 21 previous errors
-
-Some errors have detailed explanations: E0428, E0433, E0599, E0658.
+Some errors have detailed explanations: E0428, E0658.
For more information about an error, try `rustc --explain E0428`.
diff --git a/tests/ui/autodiff/incremental.rs b/tests/ui/autodiff/incremental.rs
new file mode 100644
index 0000000..a79059de
--- /dev/null
+++ b/tests/ui/autodiff/incremental.rs
@@ -0,0 +1,41 @@
+//@ revisions: DEBUG RELEASE
+//@[RELEASE] compile-flags: -Zautodiff=Enable,NoTT -C opt-level=3 -Clto=fat
+//@[DEBUG] compile-flags: -Zautodiff=Enable,NoTT -C opt-level=0 -Clto=fat -C debuginfo=2
+//@ needs-enzyme
+//@ incremental
+//@ no-prefer-dynamic
+//@ build-pass
+#![crate_type = "bin"]
+#![feature(autodiff)]
+
+// We used to use llvm's metadata to instruct enzyme how to differentiate a function.
+// In debug mode we would use incremental compilation which caused the metadata to be
+// dropped. We now use globals instead and add this test to verify that incremental
+// keeps working. Also testing debug mode while at it.
+
+use std::autodiff::autodiff_reverse;
+
+#[autodiff_reverse(bar, Duplicated, Duplicated)]
+pub fn foo(r: &[f64; 10], res: &mut f64) {
+ let mut output = [0.0; 10];
+ output[0] = r[0];
+ output[1] = r[1] * r[2];
+ output[2] = r[4] * r[5];
+ output[3] = r[2] * r[6];
+ output[4] = r[1] * r[7];
+ output[5] = r[2] * r[8];
+ output[6] = r[1] * r[9];
+ output[7] = r[5] * r[6];
+ output[8] = r[5] * r[7];
+ output[9] = r[4] * r[8];
+ *res = output.iter().sum();
+}
+fn main() {
+ let inputs = Box::new([3.1; 10]);
+ let mut d_inputs = Box::new([0.0; 10]);
+ let mut res = Box::new(0.0);
+ let mut d_res = Box::new(1.0);
+
+ bar(&inputs, &mut d_inputs, &mut res, &mut d_res);
+ dbg!(&d_inputs);
+}
diff --git a/tests/ui/consts/extra-const-ub/detect-extra-ub.rs b/tests/ui/consts/extra-const-ub/detect-extra-ub.rs
index e17bac6..60086ac 100644
--- a/tests/ui/consts/extra-const-ub/detect-extra-ub.rs
+++ b/tests/ui/consts/extra-const-ub/detect-extra-ub.rs
@@ -52,6 +52,16 @@ enum UninhDiscriminant {
//[with_flag]~^ ERROR: invalid value
};
+// A function pointer offset to be maybe-null.
+const MAYBE_NULL_FN_PTR: () = unsafe {
+ let _x: fn() = transmute({
+ //[with_flag]~^ ERROR: invalid value
+ fn fun() {}
+ let ptr = fun as fn();
+ (ptr as *const u8).wrapping_add(10)
+ });
+};
+
const UNINHABITED_VARIANT: () = unsafe {
let data = [1u8];
// Not using transmute, we want to hit the ImmTy code path.
diff --git a/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr b/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr
index 6af7286..96c1666 100644
--- a/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr
+++ b/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr
@@ -37,14 +37,26 @@
LL | let _x: &u32 = transmute(&[0u8; 4]);
| ^^^^^^^^^^^^^^^^^^^^ evaluation of `UNALIGNED_PTR` failed here
+error[E0080]: constructing invalid value: encountered a maybe-null function pointer
+ --> $DIR/detect-extra-ub.rs:57:20
+ |
+LL | let _x: fn() = transmute({
+ | ____________________^
+LL | |
+LL | | fn fun() {}
+LL | | let ptr = fun as fn();
+LL | | (ptr as *const u8).wrapping_add(10)
+LL | | });
+ | |______^ evaluation of `MAYBE_NULL_FN_PTR` failed here
+
error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
- --> $DIR/detect-extra-ub.rs:58:13
+ --> $DIR/detect-extra-ub.rs:68:13
|
LL | let v = *addr_of!(data).cast::<UninhDiscriminant>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINHABITED_VARIANT` failed here
error[E0080]: constructing invalid value at [0]: encountered a partial pointer or a mix of pointers
- --> $DIR/detect-extra-ub.rs:77:16
+ --> $DIR/detect-extra-ub.rs:87:16
|
LL | let _val = *(&mem as *const Align as *const [*const u8; 2]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `PARTIAL_POINTER` failed here
@@ -53,11 +65,11 @@
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object
- --> $DIR/detect-extra-ub.rs:91:16
+ --> $DIR/detect-extra-ub.rs:101:16
|
LL | let _val = &*slice;
| ^^^^^^^ evaluation of `OVERSIZED_REF` failed here
-error: aborting due to 8 previous errors
+error: aborting due to 9 previous errors
For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/coverage-attr/allowed-positions.stderr b/tests/ui/coverage-attr/allowed-positions.stderr
index 1690d08..09d6bac 100644
--- a/tests/ui/coverage-attr/allowed-positions.stderr
+++ b/tests/ui/coverage-attr/allowed-positions.stderr
@@ -14,7 +14,7 @@
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error: `#[coverage]` attribute cannot be used on traits
--> $DIR/allowed-positions.rs:17:1
@@ -22,7 +22,7 @@
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error: `#[coverage]` attribute cannot be used on associated consts
--> $DIR/allowed-positions.rs:19:5
@@ -30,7 +30,7 @@
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error: `#[coverage]` attribute cannot be used on associated types
--> $DIR/allowed-positions.rs:22:5
@@ -38,7 +38,7 @@
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error: `#[coverage]` attribute cannot be used on required trait methods
--> $DIR/allowed-positions.rs:25:5
@@ -46,7 +46,7 @@
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to impl blocks, functions, closures, provided trait methods, trait methods in impl blocks, inherent methods, modules, and crates
+ = help: `#[coverage]` can be applied to closures, crates, functions, impl blocks, inherent methods, modules, provided trait methods, and trait methods in impl blocks
error: `#[coverage]` attribute cannot be used on required trait methods
--> $DIR/allowed-positions.rs:31:5
@@ -54,7 +54,7 @@
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to impl blocks, functions, closures, provided trait methods, trait methods in impl blocks, inherent methods, modules, and crates
+ = help: `#[coverage]` can be applied to closures, crates, functions, impl blocks, inherent methods, modules, provided trait methods, and trait methods in impl blocks
error: `#[coverage]` attribute cannot be used on associated types
--> $DIR/allowed-positions.rs:39:5
@@ -62,7 +62,7 @@
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error: `#[coverage]` attribute cannot be used on associated types
--> $DIR/allowed-positions.rs:56:5
@@ -70,7 +70,7 @@
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error: `#[coverage]` attribute cannot be used on structs
--> $DIR/allowed-positions.rs:61:1
@@ -78,7 +78,7 @@
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error: `#[coverage]` attribute cannot be used on struct fields
--> $DIR/allowed-positions.rs:63:5
@@ -86,7 +86,7 @@
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error: `#[coverage]` attribute cannot be used on foreign statics
--> $DIR/allowed-positions.rs:76:5
@@ -94,7 +94,7 @@
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error: `#[coverage]` attribute cannot be used on foreign types
--> $DIR/allowed-positions.rs:79:5
@@ -102,7 +102,7 @@
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error: `#[coverage]` attribute cannot be used on foreign functions
--> $DIR/allowed-positions.rs:82:5
@@ -110,7 +110,7 @@
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to methods, impl blocks, functions, closures, modules, and crates
+ = help: `#[coverage]` can be applied to closures, crates, functions, impl blocks, methods, and modules
error: `#[coverage]` attribute cannot be used on statements
--> $DIR/allowed-positions.rs:88:5
@@ -118,7 +118,7 @@
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error: `#[coverage]` attribute cannot be used on statements
--> $DIR/allowed-positions.rs:94:5
@@ -126,7 +126,7 @@
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error: `#[coverage]` attribute cannot be used on match arms
--> $DIR/allowed-positions.rs:110:9
@@ -134,7 +134,7 @@
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error: `#[coverage]` attribute cannot be used on expressions
--> $DIR/allowed-positions.rs:114:5
@@ -142,7 +142,7 @@
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error: aborting due to 18 previous errors
diff --git a/tests/ui/coverage-attr/name-value.stderr b/tests/ui/coverage-attr/name-value.stderr
index 77abaa4..06e59e5 100644
--- a/tests/ui/coverage-attr/name-value.stderr
+++ b/tests/ui/coverage-attr/name-value.stderr
@@ -49,7 +49,7 @@
LL | #[coverage = "off"]
| ^^^^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error[E0539]: malformed `coverage` attribute input
--> $DIR/name-value.rs:26:1
@@ -87,7 +87,7 @@
LL | #[coverage = "off"]
| ^^^^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error[E0539]: malformed `coverage` attribute input
--> $DIR/name-value.rs:35:1
@@ -110,7 +110,7 @@
LL | #[coverage = "off"]
| ^^^^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error[E0539]: malformed `coverage` attribute input
--> $DIR/name-value.rs:39:5
@@ -133,7 +133,7 @@
LL | #[coverage = "off"]
| ^^^^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error[E0539]: malformed `coverage` attribute input
--> $DIR/name-value.rs:44:5
@@ -156,7 +156,7 @@
LL | #[coverage = "off"]
| ^^^^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error[E0539]: malformed `coverage` attribute input
--> $DIR/name-value.rs:50:1
@@ -194,7 +194,7 @@
LL | #[coverage = "off"]
| ^^^^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error[E0539]: malformed `coverage` attribute input
--> $DIR/name-value.rs:58:5
@@ -217,7 +217,7 @@
LL | #[coverage = "off"]
| ^^^^^^^^^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error[E0539]: malformed `coverage` attribute input
--> $DIR/name-value.rs:64:1
diff --git a/tests/ui/coverage-attr/word-only.stderr b/tests/ui/coverage-attr/word-only.stderr
index 5fcffac..0547869 100644
--- a/tests/ui/coverage-attr/word-only.stderr
+++ b/tests/ui/coverage-attr/word-only.stderr
@@ -43,7 +43,7 @@
LL | #[coverage]
| ^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error[E0539]: malformed `coverage` attribute input
--> $DIR/word-only.rs:26:1
@@ -77,7 +77,7 @@
LL | #[coverage]
| ^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error[E0539]: malformed `coverage` attribute input
--> $DIR/word-only.rs:35:1
@@ -98,7 +98,7 @@
LL | #[coverage]
| ^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error[E0539]: malformed `coverage` attribute input
--> $DIR/word-only.rs:39:5
@@ -119,7 +119,7 @@
LL | #[coverage]
| ^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error[E0539]: malformed `coverage` attribute input
--> $DIR/word-only.rs:44:5
@@ -140,7 +140,7 @@
LL | #[coverage]
| ^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error[E0539]: malformed `coverage` attribute input
--> $DIR/word-only.rs:50:1
@@ -174,7 +174,7 @@
LL | #[coverage]
| ^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error[E0539]: malformed `coverage` attribute input
--> $DIR/word-only.rs:58:5
@@ -195,7 +195,7 @@
LL | #[coverage]
| ^^^^^^^^^^^
|
- = help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
+ = help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules
error[E0539]: malformed `coverage` attribute input
--> $DIR/word-only.rs:64:1
diff --git a/tests/ui/deprecation/deprecation-sanity.stderr b/tests/ui/deprecation/deprecation-sanity.stderr
index ea021b7..48d08b1 100644
--- a/tests/ui/deprecation/deprecation-sanity.stderr
+++ b/tests/ui/deprecation/deprecation-sanity.stderr
@@ -177,7 +177,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, foreign statics, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, and crates
+ = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, unions, and use statements
= note: `#[deny(useless_deprecated)]` on by default
error: aborting due to 10 previous errors
diff --git a/tests/ui/extern/extern-no-mangle.stderr b/tests/ui/extern/extern-no-mangle.stderr
index 69c4fbb..61146e0 100644
--- a/tests/ui/extern/extern-no-mangle.stderr
+++ b/tests/ui/extern/extern-no-mangle.stderr
@@ -19,7 +19,7 @@
| ^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[no_mangle]` can be applied to methods, functions, and statics
+ = help: `#[no_mangle]` can be applied to functions, methods, and statics
warning: `#[no_mangle]` attribute cannot be used on statements
--> $DIR/extern-no-mangle.rs:24:5
diff --git a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr
index 42141b8..d68affa 100644
--- a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr
+++ b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr
@@ -13,7 +13,7 @@
LL | #[allow_internal_unstable(something)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
- = help: `#[allow_internal_unstable]` can be applied to macro defs and functions
+ = help: `#[allow_internal_unstable]` can be applied to functions and macro defs
error: aborting due to 2 previous errors
diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr
index 4f4edee..13152ca 100644
--- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr
+++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr
@@ -134,7 +134,7 @@
LL | #[export_name = "2200"] fn foo();
| ^^^^^^^^^^^^^^^^^^^^^^^
|
- = help: `#[export_name]` can be applied to statics, functions, inherent methods, provided trait methods, and trait methods in impl blocks
+ = help: `#[export_name]` can be applied to functions, inherent methods, provided trait methods, statics, and trait methods in impl blocks
error: attribute should be applied to an `extern crate` item
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:55:1
diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr
index 30b6d1c..29044f1 100644
--- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr
+++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr
@@ -644,7 +644,7 @@
| ^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[macro_use]` can be applied to modules, extern crates, and crates
+ = help: `#[macro_use]` can be applied to crates, extern crates, and modules
warning: `#[macro_use]` attribute cannot be used on structs
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:197:5
@@ -653,7 +653,7 @@
| ^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[macro_use]` can be applied to modules, extern crates, and crates
+ = help: `#[macro_use]` can be applied to crates, extern crates, and modules
warning: `#[macro_use]` attribute cannot be used on type aliases
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:203:5
@@ -662,7 +662,7 @@
| ^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[macro_use]` can be applied to modules, extern crates, and crates
+ = help: `#[macro_use]` can be applied to crates, extern crates, and modules
warning: `#[macro_use]` attribute cannot be used on inherent impl blocks
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:209:5
@@ -671,7 +671,7 @@
| ^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[macro_use]` can be applied to modules, extern crates, and crates
+ = help: `#[macro_use]` can be applied to crates, extern crates, and modules
warning: `#[macro_export]` attribute cannot be used on modules
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:216:1
@@ -878,7 +878,7 @@
| ^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[no_mangle]` can be applied to functions, statics, inherent methods, and trait methods in impl blocks
+ = help: `#[no_mangle]` can be applied to functions, inherent methods, statics, and trait methods in impl blocks
warning: `#[no_mangle]` attribute cannot be used on provided trait methods
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:398:9
@@ -887,7 +887,7 @@
| ^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[no_mangle]` can be applied to functions, statics, inherent methods, and trait methods in impl blocks
+ = help: `#[no_mangle]` can be applied to functions, inherent methods, statics, and trait methods in impl blocks
warning: `#[should_panic]` attribute cannot be used on modules
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:406:1
@@ -986,7 +986,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[no_implicit_prelude]` can be applied to modules and crates
+ = help: `#[no_implicit_prelude]` can be applied to crates and modules
warning: `#[no_implicit_prelude]` attribute cannot be used on structs
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:482:5
@@ -995,7 +995,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[no_implicit_prelude]` can be applied to modules and crates
+ = help: `#[no_implicit_prelude]` can be applied to crates and modules
warning: `#[no_implicit_prelude]` attribute cannot be used on type aliases
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:488:5
@@ -1004,7 +1004,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[no_implicit_prelude]` can be applied to modules and crates
+ = help: `#[no_implicit_prelude]` can be applied to crates and modules
warning: `#[no_implicit_prelude]` attribute cannot be used on inherent impl blocks
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:494:5
@@ -1013,7 +1013,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[no_implicit_prelude]` can be applied to modules and crates
+ = help: `#[no_implicit_prelude]` can be applied to crates and modules
warning: `#[macro_escape]` attribute cannot be used on functions
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:533:5
@@ -1022,7 +1022,7 @@
| ^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[macro_escape]` can be applied to modules, extern crates, and crates
+ = help: `#[macro_escape]` can be applied to crates, extern crates, and modules
warning: `#[macro_escape]` attribute cannot be used on structs
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:539:5
@@ -1031,7 +1031,7 @@
| ^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[macro_escape]` can be applied to modules, extern crates, and crates
+ = help: `#[macro_escape]` can be applied to crates, extern crates, and modules
warning: `#[macro_escape]` attribute cannot be used on type aliases
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:545:5
@@ -1040,7 +1040,7 @@
| ^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[macro_escape]` can be applied to modules, extern crates, and crates
+ = help: `#[macro_escape]` can be applied to crates, extern crates, and modules
warning: `#[macro_escape]` attribute cannot be used on inherent impl blocks
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:551:5
@@ -1049,7 +1049,7 @@
| ^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[macro_escape]` can be applied to modules, extern crates, and crates
+ = help: `#[macro_escape]` can be applied to crates, extern crates, and modules
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]`
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:558:1
@@ -1290,7 +1290,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
warning: `#[must_use]` attribute cannot be used on modules
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:795:17
@@ -1299,7 +1299,7 @@
| ^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
warning: `#[must_use]` attribute cannot be used on type aliases
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:804:5
@@ -1308,7 +1308,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
warning: `#[must_use]` attribute cannot be used on inherent impl blocks
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:809:5
@@ -1317,7 +1317,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]`
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:841:1
@@ -1590,7 +1590,7 @@
| ^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
warning: 174 warnings emitted
diff --git a/tests/ui/invalid/invalid-debugger-visualizer-target.stderr b/tests/ui/invalid/invalid-debugger-visualizer-target.stderr
index 629af94..c721e3d 100644
--- a/tests/ui/invalid/invalid-debugger-visualizer-target.stderr
+++ b/tests/ui/invalid/invalid-debugger-visualizer-target.stderr
@@ -4,7 +4,7 @@
LL | #[debugger_visualizer(natvis_file = "./foo.natvis.xml")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
- = help: `#[debugger_visualizer]` can be applied to modules and crates
+ = help: `#[debugger_visualizer]` can be applied to crates and modules
error: aborting due to 1 previous error
diff --git a/tests/ui/issues/issue-32782.stderr b/tests/ui/issues/issue-32782.stderr
index 96cd048..2a1183a 100644
--- a/tests/ui/issues/issue-32782.stderr
+++ b/tests/ui/issues/issue-32782.stderr
@@ -20,7 +20,7 @@
LL | foo!();
| ------ in this macro invocation
|
- = help: `#[allow_internal_unstable]` can be applied to macro defs and functions
+ = help: `#[allow_internal_unstable]` can be applied to functions and macro defs
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
diff --git a/tests/ui/lint/unused/unused-attr-macro-rules.stderr b/tests/ui/lint/unused/unused-attr-macro-rules.stderr
index 0c68250..e251ec6 100644
--- a/tests/ui/lint/unused/unused-attr-macro-rules.stderr
+++ b/tests/ui/lint/unused/unused-attr-macro-rules.stderr
@@ -5,7 +5,7 @@
| ^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[macro_use]` can be applied to modules, extern crates, and crates
+ = help: `#[macro_use]` can be applied to crates, extern crates, and modules
note: the lint level is defined here
--> $DIR/unused-attr-macro-rules.rs:1:9
|
diff --git a/tests/ui/lint/unused/unused_attributes-must_use.stderr b/tests/ui/lint/unused/unused_attributes-must_use.stderr
index 001ec52..9b9a6a9 100644
--- a/tests/ui/lint/unused/unused_attributes-must_use.stderr
+++ b/tests/ui/lint/unused/unused_attributes-must_use.stderr
@@ -5,7 +5,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
note: the lint level is defined here
--> $DIR/unused_attributes-must_use.rs:4:9
|
@@ -19,7 +19,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on modules
--> $DIR/unused_attributes-must_use.rs:11:1
@@ -28,7 +28,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on use statements
--> $DIR/unused_attributes-must_use.rs:15:1
@@ -37,7 +37,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on constants
--> $DIR/unused_attributes-must_use.rs:19:1
@@ -46,7 +46,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on statics
--> $DIR/unused_attributes-must_use.rs:22:1
@@ -55,7 +55,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on inherent impl blocks
--> $DIR/unused_attributes-must_use.rs:40:1
@@ -64,7 +64,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on foreign modules
--> $DIR/unused_attributes-must_use.rs:55:1
@@ -73,7 +73,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on foreign statics
--> $DIR/unused_attributes-must_use.rs:59:5
@@ -82,7 +82,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on type aliases
--> $DIR/unused_attributes-must_use.rs:73:1
@@ -91,7 +91,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on function params
--> $DIR/unused_attributes-must_use.rs:77:8
@@ -100,7 +100,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on associated consts
--> $DIR/unused_attributes-must_use.rs:82:5
@@ -109,7 +109,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on associated types
--> $DIR/unused_attributes-must_use.rs:85:5
@@ -118,7 +118,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on trait impl blocks
--> $DIR/unused_attributes-must_use.rs:95:1
@@ -127,7 +127,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on trait methods in impl blocks
--> $DIR/unused_attributes-must_use.rs:100:5
@@ -136,7 +136,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to data types, functions, unions, required trait methods, provided trait methods, inherent methods, foreign functions, and traits
+ = help: `#[must_use]` can be applied to data types, foreign functions, functions, inherent methods, provided trait methods, required trait methods, traits, and unions
error: `#[must_use]` attribute cannot be used on trait aliases
--> $DIR/unused_attributes-must_use.rs:107:1
@@ -145,7 +145,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on macro defs
--> $DIR/unused_attributes-must_use.rs:111:1
@@ -154,7 +154,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on statements
--> $DIR/unused_attributes-must_use.rs:120:5
@@ -163,7 +163,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on closures
--> $DIR/unused_attributes-must_use.rs:125:13
@@ -172,7 +172,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to methods, data types, functions, unions, foreign functions, and traits
+ = help: `#[must_use]` can be applied to data types, foreign functions, functions, methods, traits, and unions
error: `#[must_use]` attribute cannot be used on match arms
--> $DIR/unused_attributes-must_use.rs:148:9
@@ -181,7 +181,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on struct fields
--> $DIR/unused_attributes-must_use.rs:157:28
@@ -190,7 +190,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: `#[must_use]` attribute cannot be used on pattern fields
--> $DIR/unused_attributes-must_use.rs:159:24
@@ -199,7 +199,7 @@
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[must_use]` can be applied to functions, data types, unions, and traits
+ = help: `#[must_use]` can be applied to data types, functions, traits, and unions
error: unused `X` that must be used
--> $DIR/unused_attributes-must_use.rs:130:5
diff --git a/tests/ui/lint/warn-unused-inline-on-fn-prototypes.stderr b/tests/ui/lint/warn-unused-inline-on-fn-prototypes.stderr
index fcce1db..bdeaabb 100644
--- a/tests/ui/lint/warn-unused-inline-on-fn-prototypes.stderr
+++ b/tests/ui/lint/warn-unused-inline-on-fn-prototypes.stderr
@@ -5,7 +5,7 @@
| ^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[inline]` can be applied to functions, inherent methods, provided trait methods, trait methods in impl blocks, and closures
+ = help: `#[inline]` can be applied to closures, functions, inherent methods, provided trait methods, and trait methods in impl blocks
note: the lint level is defined here
--> $DIR/warn-unused-inline-on-fn-prototypes.rs:1:9
|
@@ -19,7 +19,7 @@
| ^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = help: `#[inline]` can be applied to methods, functions, and closures
+ = help: `#[inline]` can be applied to closures, functions, and methods
error: aborting due to 2 previous errors
diff --git a/tests/ui/macros/issue-68060.stderr b/tests/ui/macros/issue-68060.stderr
index 4699594..54a6baa 100644
--- a/tests/ui/macros/issue-68060.stderr
+++ b/tests/ui/macros/issue-68060.stderr
@@ -4,7 +4,7 @@
LL | #[target_feature(enable = "")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
- = help: `#[target_feature]` can be applied to methods and functions
+ = help: `#[target_feature]` can be applied to functions and methods
error[E0658]: `#[track_caller]` on closures is currently unstable
--> $DIR/issue-68060.rs:6:13
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2021.stderr
index 7e3caaf..fc1ca18 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2021.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2021.stderr
@@ -59,20 +59,20 @@
| |
| help: replace this `&` with `&mut`: `&mut`
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/mixed-editions.rs:30:10
|
LL | let [bind_ref!(y)] = &[0];
| ^^^^^^^^^^^^ occurs within macro expansion
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/mixed-editions.rs:30:9
|
LL | let [bind_ref!(y)] = &[0];
- | ^^^^^^^^^^^^^^ this matches on type `&_`
+ | ^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
= note: this error originates in the macro `bind_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
-help: make the implied reference pattern explicit
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &[bind_ref!(y)] = &[0];
| +
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2024.stderr
index 466993a..9377d53 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2024.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2024.stderr
@@ -58,14 +58,14 @@
| |
| help: replace this `&` with `&mut`: `&mut`
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/mixed-editions.rs:26:21
|
LL | let match_ctor!(ref x) = &[0];
- | ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = 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
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+help: match on the reference with a reference pattern to avoid implicitly borrowing
--> $DIR/auxiliary/mixed-editions-macros.rs:11:9
|
LL | &[$p]
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.rs
index 0a22b55..3580ed3 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.rs
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.rs
@@ -24,11 +24,11 @@ fn assert_type_eq<T, U: Eq<T>>(_: T, _: U) {}
/// only when the binding is from edition 2024.
fn ref_binding_tests() {
let match_ctor!(ref x) = &[0];
- //[classic2024,structural2024]~^ ERROR: binding modifiers may only be written when the default binding mode is `move`
+ //[classic2024,structural2024]~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern
#[cfg(any(classic2021, structural2021))] assert_type_eq(x, &0u32);
let [bind_ref!(y)] = &[0];
- //[classic2021,structural2021]~^ ERROR: binding modifiers may only be written when the default binding mode is `move`
+ //[classic2021,structural2021]~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern
#[cfg(any(classic2024, structural2024))] assert_type_eq(y, &0u32);
}
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.structural2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.structural2021.stderr
index 4075dc9..69ddb07 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.structural2021.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.structural2021.stderr
@@ -37,20 +37,20 @@
| |
| help: replace this `&` with `&mut`: `&mut`
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/mixed-editions.rs:30:10
|
LL | let [bind_ref!(y)] = &[0];
| ^^^^^^^^^^^^ occurs within macro expansion
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/mixed-editions.rs:30:9
|
LL | let [bind_ref!(y)] = &[0];
- | ^^^^^^^^^^^^^^ this matches on type `&_`
+ | ^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
= note: this error originates in the macro `bind_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
-help: make the implied reference pattern explicit
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &[bind_ref!(y)] = &[0];
| +
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.structural2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.structural2024.stderr
index 819a542..bc1fee3 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.structural2024.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.structural2024.stderr
@@ -36,14 +36,14 @@
| |
| help: replace this `&` with `&mut`: `&mut`
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/mixed-editions.rs:26:21
|
LL | let match_ctor!(ref x) = &[0];
- | ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = 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
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+help: match on the reference with a reference pattern to avoid implicitly borrowing
--> $DIR/auxiliary/mixed-editions-macros.rs:11:9
|
LL | &[$p]
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr
index 04e53e0..956cd21 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr
@@ -11,19 +11,19 @@
LL + let [&ref x] = &[&mut 0];
|
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/ref-binding-on-inh-ref-errors.rs:73:10
|
LL | let [ref mut x] = &[0];
- | ^^^^^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^^^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/ref-binding-on-inh-ref-errors.rs:73:9
|
LL | let [ref mut x] = &[0];
- | ^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &[ref mut x] = &[0];
| +
@@ -34,53 +34,53 @@
LL | let [ref mut x] = &[0];
| ^^^^^^^^^ cannot borrow as mutable
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/ref-binding-on-inh-ref-errors.rs:81:10
|
LL | let [ref x] = &[0];
- | ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/ref-binding-on-inh-ref-errors.rs:81:9
|
LL | let [ref x] = &[0];
- | ^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern explicit
+ | ^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &[ref x] = &[0];
| +
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/ref-binding-on-inh-ref-errors.rs:85:10
|
LL | let [ref x] = &mut [0];
- | ^^^ binding modifier not allowed under `ref mut` default binding mode
+ | ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/ref-binding-on-inh-ref-errors.rs:85:9
|
LL | let [ref x] = &mut [0];
- | ^^^^^^^ this matches on type `&mut _`
-help: make the implied reference pattern explicit
+ | ^^^^^^^ this non-reference pattern matches on a reference type `&mut _`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &mut [ref x] = &mut [0];
| ++++
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/ref-binding-on-inh-ref-errors.rs:89:10
|
LL | let [ref mut x] = &mut [0];
- | ^^^^^^^ binding modifier not allowed under `ref mut` default binding mode
+ | ^^^^^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/ref-binding-on-inh-ref-errors.rs:89:9
|
LL | let [ref mut x] = &mut [0];
- | ^^^^^^^^^^^ this matches on type `&mut _`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^^^^ this non-reference pattern matches on a reference type `&mut _`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &mut [ref mut x] = &mut [0];
| ++++
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.rs
index c9e3f75..628cb60 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.rs
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.rs
@@ -17,22 +17,22 @@
/// The eat-outer variant eats the inherited reference, so binding with `ref` isn't a problem.
fn errors_from_eating_the_real_reference() {
let [&ref x] = &[&0];
- //[structural2024]~^ ERROR: binding modifiers may only be written when the default binding mode is `move`
+ //[structural2024]~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern
#[cfg(any(stable2021, classic2021, structural2021))] let _: &u32 = x;
#[cfg(classic2024)] let _: &&u32 = x;
let [&ref x] = &mut [&0];
- //[structural2024]~^ ERROR: binding modifiers may only be written when the default binding mode is `move`
+ //[structural2024]~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern
#[cfg(any(stable2021, classic2021, structural2021))] let _: &u32 = x;
#[cfg(classic2024)] let _: &&u32 = x;
let [&mut ref x] = &mut [&mut 0];
- //[structural2024]~^ ERROR: binding modifiers may only be written when the default binding mode is `move`
+ //[structural2024]~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern
#[cfg(any(stable2021, classic2021, structural2021))] let _: &u32 = x;
#[cfg(classic2024)] let _: &&mut u32 = x;
let [&mut ref mut x] = &mut [&mut 0];
- //[structural2024]~^ ERROR: binding modifiers may only be written when the default binding mode is `move`
+ //[structural2024]~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern
#[cfg(any(stable2021, classic2021, structural2021))] let _: &mut u32 = x;
#[cfg(classic2024)] let _: &mut &mut u32 = x;
}
@@ -43,14 +43,14 @@ fn errors_from_eating_the_real_reference_caught_in_hir_typeck_on_stable() {
let [&ref x] = &[&mut 0];
//[stable2021]~^ ERROR: mismatched types
//[stable2021]~| NOTE types differ in mutability
- //[structural2024]~^^^ ERROR: binding modifiers may only be written when the default binding mode is `move`
+ //[structural2024]~^^^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern
#[cfg(any(classic2021, structural2021))] let _: &u32 = x;
#[cfg(classic2024)] let _: &&mut u32 = x;
let [&ref x] = &mut [&mut 0];
//[stable2021]~^ ERROR: mismatched types
//[stable2021]~| NOTE types differ in mutability
- //[structural2024]~^^^ ERROR: binding modifiers may only be written when the default binding mode is `move`
+ //[structural2024]~^^^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern
#[cfg(any(classic2021, structural2021))] let _: &u32 = x;
#[cfg(classic2024)] let _: &&mut u32 = x;
}
@@ -60,7 +60,7 @@ fn errors_dependent_on_eating_order_caught_in_hir_typeck_when_eating_outer() {
let [&mut ref x] = &[&mut 0];
//[classic2024]~^ ERROR: mismatched types
//[classic2024]~| NOTE cannot match inherited `&` with `&mut` pattern
- //[structural2024]~^^^ ERROR: binding modifiers may only be written when the default binding mode is `move`
+ //[structural2024]~^^^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern
#[cfg(any(stable2021, classic2021, structural2021))] let _: &u32 = x;
}
@@ -72,21 +72,21 @@ fn errors_dependent_on_eating_order_caught_in_hir_typeck_when_eating_outer() {
fn borrowck_errors_in_old_editions() {
let [ref mut x] = &[0];
//~^ ERROR: cannot borrow data in a `&` reference as mutable
- //[classic2024,structural2024]~| ERROR: binding modifiers may only be written when the default binding mode is `move`
+ //[classic2024,structural2024]~| ERROR: cannot explicitly borrow within an implicitly-borrowing pattern
}
/// The remaining tests are purely for testing `ref` bindings in the presence of an inherited
/// reference. These should always fail on edition 2024 and succeed on edition 2021.
pub fn main() {
let [ref x] = &[0];
- //[classic2024,structural2024]~^ ERROR: binding modifiers may only be written when the default binding mode is `move`
+ //[classic2024,structural2024]~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern
#[cfg(any(stable2021, classic2021, structural2021))] let _: &u32 = x;
let [ref x] = &mut [0];
- //[classic2024,structural2024]~^ ERROR: binding modifiers may only be written when the default binding mode is `move`
+ //[classic2024,structural2024]~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern
#[cfg(any(stable2021, classic2021, structural2021))] let _: &u32 = x;
let [ref mut x] = &mut [0];
- //[classic2024,structural2024]~^ ERROR: binding modifiers may only be written when the default binding mode is `move`
+ //[classic2024,structural2024]~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern
#[cfg(any(stable2021, classic2021, structural2021))] let _: &mut u32 = x;
}
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr
index def6deb..9753e3e 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr
@@ -1,135 +1,135 @@
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/ref-binding-on-inh-ref-errors.rs:19:11
|
LL | let [&ref x] = &[&0];
- | ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/ref-binding-on-inh-ref-errors.rs:19:9
|
LL | let [&ref x] = &[&0];
- | ^^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &[&ref x] = &[&0];
| +
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/ref-binding-on-inh-ref-errors.rs:24:11
|
LL | let [&ref x] = &mut [&0];
- | ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/ref-binding-on-inh-ref-errors.rs:24:9
|
LL | let [&ref x] = &mut [&0];
- | ^^^^^^^^ this matches on type `&mut _`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^ this non-reference pattern matches on a reference type `&mut _`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &mut [&ref x] = &mut [&0];
| ++++
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/ref-binding-on-inh-ref-errors.rs:29:15
|
LL | let [&mut ref x] = &mut [&mut 0];
- | ^^^ binding modifier not allowed under `ref mut` default binding mode
+ | ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/ref-binding-on-inh-ref-errors.rs:29:9
|
LL | let [&mut ref x] = &mut [&mut 0];
- | ^^^^^^^^^^^^ this matches on type `&mut _`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&mut _`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &mut [&mut ref x] = &mut [&mut 0];
| ++++
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/ref-binding-on-inh-ref-errors.rs:34:15
|
LL | let [&mut ref mut x] = &mut [&mut 0];
- | ^^^^^^^ binding modifier not allowed under `ref mut` default binding mode
+ | ^^^^^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/ref-binding-on-inh-ref-errors.rs:34:9
|
LL | let [&mut ref mut x] = &mut [&mut 0];
- | ^^^^^^^^^^^^^^^^ this matches on type `&mut _`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&mut _`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &mut [&mut ref mut x] = &mut [&mut 0];
| ++++
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/ref-binding-on-inh-ref-errors.rs:43:11
|
LL | let [&ref x] = &[&mut 0];
- | ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/ref-binding-on-inh-ref-errors.rs:43:9
|
LL | let [&ref x] = &[&mut 0];
- | ^^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &[&ref x] = &[&mut 0];
| +
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/ref-binding-on-inh-ref-errors.rs:50:11
|
LL | let [&ref x] = &mut [&mut 0];
- | ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/ref-binding-on-inh-ref-errors.rs:50:9
|
LL | let [&ref x] = &mut [&mut 0];
- | ^^^^^^^^ this matches on type `&mut _`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^ this non-reference pattern matches on a reference type `&mut _`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &mut [&ref x] = &mut [&mut 0];
| ++++
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/ref-binding-on-inh-ref-errors.rs:60:15
|
LL | let [&mut ref x] = &[&mut 0];
- | ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/ref-binding-on-inh-ref-errors.rs:60:9
|
LL | let [&mut ref x] = &[&mut 0];
- | ^^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &[&mut ref x] = &[&mut 0];
| +
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/ref-binding-on-inh-ref-errors.rs:73:10
|
LL | let [ref mut x] = &[0];
- | ^^^^^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^^^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/ref-binding-on-inh-ref-errors.rs:73:9
|
LL | let [ref mut x] = &[0];
- | ^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &[ref mut x] = &[0];
| +
@@ -140,53 +140,53 @@
LL | let [ref mut x] = &[0];
| ^^^^^^^^^ cannot borrow as mutable
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/ref-binding-on-inh-ref-errors.rs:81:10
|
LL | let [ref x] = &[0];
- | ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/ref-binding-on-inh-ref-errors.rs:81:9
|
LL | let [ref x] = &[0];
- | ^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern explicit
+ | ^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &[ref x] = &[0];
| +
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/ref-binding-on-inh-ref-errors.rs:85:10
|
LL | let [ref x] = &mut [0];
- | ^^^ binding modifier not allowed under `ref mut` default binding mode
+ | ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/ref-binding-on-inh-ref-errors.rs:85:9
|
LL | let [ref x] = &mut [0];
- | ^^^^^^^ this matches on type `&mut _`
-help: make the implied reference pattern explicit
+ | ^^^^^^^ this non-reference pattern matches on a reference type `&mut _`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &mut [ref x] = &mut [0];
| ++++
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/ref-binding-on-inh-ref-errors.rs:89:10
|
LL | let [ref mut x] = &mut [0];
- | ^^^^^^^ binding modifier not allowed under `ref mut` default binding mode
+ | ^^^^^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/ref-binding-on-inh-ref-errors.rs:89:9
|
LL | let [ref mut x] = &mut [0];
- | ^^^^^^^^^^^ this matches on type `&mut _`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^^^^ this non-reference pattern matches on a reference type `&mut _`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &mut [ref mut x] = &mut [0];
| ++++
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.fixed b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.fixed
index bb4ecc0..2df39fd 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.fixed
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.fixed
@@ -23,22 +23,22 @@
assert_type_eq(x, &mut 0u8);
let &Foo(mut x) = &Foo(0);
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let &mut Foo(mut x) = &mut Foo(0);
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let Foo(x) = &Foo(0);
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &0u8);
let &mut Foo(ref x) = &mut Foo(0);
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &0u8);
@@ -55,22 +55,22 @@
assert_type_eq(x, &0u8);
let &Foo(&x) = &Foo(&0);
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let &Foo(&mut x) = &Foo(&mut 0);
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let &mut Foo(&x) = &mut Foo(&0);
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let &mut Foo(&mut x) = &mut Foo(&mut 0);
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
@@ -79,25 +79,25 @@
}
if let &&&&&Some(&x) = &&&&&Some(&0u8) {
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}
if let &&&&&Some(&mut x) = &&&&&Some(&mut 0u8) {
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}
if let &&&&&mut Some(&x) = &&&&&mut Some(&0u8) {
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}
if let &mut Some(&mut Some(&mut Some(ref mut x))) = &mut Some(&mut Some(&mut Some(0u8))) {
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &mut 0u8);
}
@@ -109,20 +109,20 @@
}
let &Struct { ref a, mut b, ref c } = &Struct { a: 0, b: 0, c: 0 };
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(b, 0u32);
let &Struct { a: &a, ref b, ref c } = &Struct { a: &0, b: &0, c: &0 };
- //~^ ERROR: binding modifiers and reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly borrow or dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, 0u32);
assert_type_eq(b, &&0u32);
assert_type_eq(c, &&0u32);
if let &Struct { a: &Some(a), b: &Some(&b), c: &Some(ref c) } =
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
&(Struct { a: &Some(&0), b: &Some(&0), c: &Some(&0) })
{
@@ -135,7 +135,7 @@
// The two patterns are the same syntactically, but because they're defined in different
// editions they don't mean the same thing.
&(Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => {
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move`
+ //~^ ERROR: cannot mutably bind by value within an implicitly-borrowing pattern
assert_type_eq(x, 0u32);
assert_type_eq(y, 0u32);
}
@@ -143,26 +143,26 @@
}
let &mut [&mut &[ref a]] = &mut [&mut &[0]];
- //~^ ERROR: binding modifiers and reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly borrow or dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
let &[&(_)] = &[&0];
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
// NB: Most of the following tests are for possible future improvements to migration suggestions
// Test removing multiple binding modifiers.
let Struct { a, b, c } = &Struct { a: 0, b: 0, c: 0 };
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(c, &0u32);
// Test that we don't change bindings' modes when removing binding modifiers.
let &mut Struct { ref a, ref mut b, ref mut c } = &mut Struct { a: 0, b: 0, c: 0 };
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(b, &mut 0u32);
@@ -170,7 +170,7 @@
// Test removing multiple reference patterns of various mutabilities, plus a binding modifier.
let &mut &Struct { a: &[ref a], b: &mut [&[ref b]], ref c } = &mut &Struct { a: &[0], b: &mut [&[0]], c: 0 };
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(b, &0u32);
@@ -178,13 +178,13 @@
// Test that we don't change bindings' types when removing reference patterns.
let &Foo(&ref a) = &Foo(&0);
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
// Test that we don't change bindings' modes when adding reference paterns (caught early).
let &(&a, ref b, &[ref c], &mut [&mut (ref d, &[ref e])]) = &(&0, 0, &[0], &mut [&mut (0, &[0])]);
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, 0u32);
assert_type_eq(b, &0u32);
@@ -194,7 +194,7 @@
// Test that we don't change bindings' modes when adding reference patterns (caught late).
let &(ref a, &mut [ref b], &[mut c]) = &(0, &mut [0], &[0]);
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(b, &0u32);
@@ -202,7 +202,7 @@
// Test featuring both additions and removals.
let &(&a, &mut (ref b, &[ref c])) = &(&0, &mut (0, &[0]));
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, 0u32);
assert_type_eq(b, &0u32);
@@ -210,21 +210,21 @@
// Test that bindings' subpatterns' modes are updated properly.
let &[mut a @ ref b] = &[0];
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, 0u32);
assert_type_eq(b, &0u32);
// Test that bindings' subpatterns' modes are checked properly.
let &[ref a @ mut b] = &[0];
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(b, 0u32);
// Test that we respect bindings' subpatterns' types when rewriting `&ref x` to `x`.
let [&Foo(&ref a @ ref b), &Foo(&ref c @ d)] = [&Foo(&0); 2];
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(b, &0u32);
@@ -233,7 +233,7 @@
// Test that we respect bindings' subpatterns' modes when rewriting `&ref x` to `x`.
let [&Foo(&ref a @ [ref b]), &Foo(&ref c @ [d])] = [&Foo(&[0]); 2];
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &[0u32]);
assert_type_eq(b, &0u32);
@@ -242,12 +242,32 @@
// Test that we use the correct message and suggestion style when pointing inside expansions.
let &[migration_lint_macros::bind_ref!(a)] = &[0];
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move`
+ //~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern
assert_type_eq(a, &0u32);
// Test that we use the correct span when labeling a `&` whose subpattern is from an expansion.
let &[&migration_lint_macros::bind_ref!(a)] = &[&0];
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
+
+ // Test the primary diagnostic message for mixes of `mut`/`ref`/`&`.
+ let &(mut a, ref b) = &(0, 0);
+ //~^ ERROR: cannot write explicit binding modifiers within an implicitly-borrowing pattern in Rust 2024
+ //~| WARN: this changes meaning in Rust 2024
+ assert_type_eq(a, 0u32);
+ assert_type_eq(b, &0u32);
+
+ let &(mut a, &b) = &(0, &0);
+ //~^ ERROR: cannot mutably bind by value or explicitly dereference within an implicitly-borrowing pattern in Rust 2024
+ //~| WARN: this changes meaning in Rust 2024
+ assert_type_eq(a, 0u32);
+ assert_type_eq(b, 0u32);
+
+ let &(mut a, ref b, &c) = &(0, 0, &0);
+ //~^ ERROR: cannot write explicit binding modifiers or explicitly dereference within an implicitly-borrowing pattern in Rust 2024
+ //~| WARN: this changes meaning in Rust 2024
+ assert_type_eq(a, 0u32);
+ assert_type_eq(b, &0u32);
+ assert_type_eq(c, 0u32);
}
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.rs
index 2837c8d..0d727ad 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.rs
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.rs
@@ -23,22 +23,22 @@ fn main() {
assert_type_eq(x, &mut 0u8);
let Foo(mut x) = &Foo(0);
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let Foo(mut x) = &mut Foo(0);
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let Foo(ref x) = &Foo(0);
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &0u8);
let Foo(ref x) = &mut Foo(0);
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &0u8);
@@ -55,22 +55,22 @@ fn main() {
assert_type_eq(x, &0u8);
let Foo(&x) = &Foo(&0);
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let Foo(&mut x) = &Foo(&mut 0);
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let Foo(&x) = &mut Foo(&0);
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let Foo(&mut x) = &mut Foo(&mut 0);
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
@@ -79,25 +79,25 @@ fn main() {
}
if let Some(&x) = &&&&&Some(&0u8) {
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}
if let Some(&mut x) = &&&&&Some(&mut 0u8) {
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}
if let Some(&x) = &&&&&mut Some(&0u8) {
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}
if let Some(&mut Some(Some(x))) = &mut Some(&mut Some(&mut Some(0u8))) {
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &mut 0u8);
}
@@ -109,20 +109,20 @@ struct Struct<A, B, C> {
}
let Struct { a, mut b, c } = &Struct { a: 0, b: 0, c: 0 };
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(b, 0u32);
let Struct { a: &a, b, ref c } = &Struct { a: &0, b: &0, c: &0 };
- //~^ ERROR: binding modifiers and reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly borrow or dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, 0u32);
assert_type_eq(b, &&0u32);
assert_type_eq(c, &&0u32);
if let Struct { a: &Some(a), b: Some(&b), c: Some(c) } =
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
&(Struct { a: &Some(&0), b: &Some(&0), c: &Some(&0) })
{
@@ -135,7 +135,7 @@ struct Struct<A, B, C> {
// The two patterns are the same syntactically, but because they're defined in different
// editions they don't mean the same thing.
(Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => {
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move`
+ //~^ ERROR: cannot mutably bind by value within an implicitly-borrowing pattern
assert_type_eq(x, 0u32);
assert_type_eq(y, 0u32);
}
@@ -143,26 +143,26 @@ struct Struct<A, B, C> {
}
let [&mut [ref a]] = &mut [&mut &[0]];
- //~^ ERROR: binding modifiers and reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly borrow or dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
let [&(_)] = &[&0];
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
// NB: Most of the following tests are for possible future improvements to migration suggestions
// Test removing multiple binding modifiers.
let Struct { ref a, ref b, c } = &Struct { a: 0, b: 0, c: 0 };
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(c, &0u32);
// Test that we don't change bindings' modes when removing binding modifiers.
let Struct { ref a, ref mut b, c } = &mut Struct { a: 0, b: 0, c: 0 };
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(b, &mut 0u32);
@@ -170,7 +170,7 @@ struct Struct<A, B, C> {
// Test removing multiple reference patterns of various mutabilities, plus a binding modifier.
let Struct { a: &[ref a], b: &mut [[b]], c } = &mut &Struct { a: &[0], b: &mut [&[0]], c: 0 };
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(b, &0u32);
@@ -178,13 +178,13 @@ struct Struct<A, B, C> {
// Test that we don't change bindings' types when removing reference patterns.
let Foo(&ref a) = &Foo(&0);
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
// Test that we don't change bindings' modes when adding reference paterns (caught early).
let (&a, b, [c], [(d, [e])]) = &(&0, 0, &[0], &mut [&mut (0, &[0])]);
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, 0u32);
assert_type_eq(b, &0u32);
@@ -194,7 +194,7 @@ struct Struct<A, B, C> {
// Test that we don't change bindings' modes when adding reference patterns (caught late).
let (a, [b], [mut c]) = &(0, &mut [0], &[0]);
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(b, &0u32);
@@ -202,7 +202,7 @@ struct Struct<A, B, C> {
// Test featuring both additions and removals.
let (&a, (b, &[ref c])) = &(&0, &mut (0, &[0]));
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, 0u32);
assert_type_eq(b, &0u32);
@@ -210,21 +210,21 @@ struct Struct<A, B, C> {
// Test that bindings' subpatterns' modes are updated properly.
let [mut a @ b] = &[0];
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, 0u32);
assert_type_eq(b, &0u32);
// Test that bindings' subpatterns' modes are checked properly.
let [a @ mut b] = &[0];
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(b, 0u32);
// Test that we respect bindings' subpatterns' types when rewriting `&ref x` to `x`.
let [Foo(&ref a @ ref b), Foo(&ref c @ d)] = [&Foo(&0); 2];
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(b, &0u32);
@@ -233,7 +233,7 @@ struct Struct<A, B, C> {
// Test that we respect bindings' subpatterns' modes when rewriting `&ref x` to `x`.
let [Foo(&ref a @ [ref b]), Foo(&ref c @ [d])] = [&Foo(&[0]); 2];
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &[0u32]);
assert_type_eq(b, &0u32);
@@ -242,12 +242,32 @@ struct Struct<A, B, C> {
// Test that we use the correct message and suggestion style when pointing inside expansions.
let [migration_lint_macros::bind_ref!(a)] = &[0];
- //~^ ERROR: binding modifiers may only be written when the default binding mode is `move`
+ //~^ ERROR: cannot explicitly borrow within an implicitly-borrowing pattern
assert_type_eq(a, &0u32);
// Test that we use the correct span when labeling a `&` whose subpattern is from an expansion.
let [&migration_lint_macros::bind_ref!(a)] = &[&0];
- //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+ //~^ ERROR: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
+
+ // Test the primary diagnostic message for mixes of `mut`/`ref`/`&`.
+ let (mut a, ref b) = &(0, 0);
+ //~^ ERROR: cannot write explicit binding modifiers within an implicitly-borrowing pattern in Rust 2024
+ //~| WARN: this changes meaning in Rust 2024
+ assert_type_eq(a, 0u32);
+ assert_type_eq(b, &0u32);
+
+ let (mut a, &b) = &(0, &0);
+ //~^ ERROR: cannot mutably bind by value or explicitly dereference within an implicitly-borrowing pattern in Rust 2024
+ //~| WARN: this changes meaning in Rust 2024
+ assert_type_eq(a, 0u32);
+ assert_type_eq(b, 0u32);
+
+ let (mut a, ref b, &c) = &(0, 0, &0);
+ //~^ ERROR: cannot write explicit binding modifiers or explicitly dereference within an implicitly-borrowing pattern in Rust 2024
+ //~| WARN: this changes meaning in Rust 2024
+ assert_type_eq(a, 0u32);
+ assert_type_eq(b, &0u32);
+ assert_type_eq(c, 0u32);
}
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 6efda4f..01fcfdc 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
@@ -1,602 +1,663 @@
-error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+error: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:25:13
|
LL | let Foo(mut x) = &Foo(0);
- | ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ `mut` binding modifier not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:25:9
|
LL | let Foo(mut x) = &Foo(0);
- | ^^^^^^^^^^ this matches on type `&_`
+ | ^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
note: the lint level is defined here
--> $DIR/migration_lint.rs:7:9
|
LL | #![deny(rust_2024_incompatible_pat)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: make the implied reference pattern explicit
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &Foo(mut x) = &Foo(0);
| +
-error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+error: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:30:13
|
LL | let Foo(mut x) = &mut Foo(0);
- | ^^^ binding modifier not allowed under `ref mut` default binding mode
+ | ^^^ `mut` binding modifier not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:30:9
|
LL | let Foo(mut x) = &mut Foo(0);
- | ^^^^^^^^^^ this matches on type `&mut _`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^^^ this non-reference pattern matches on a reference type `&mut _`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &mut Foo(mut x) = &mut Foo(0);
| ++++
-error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly borrow within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:35:13
|
LL | let Foo(ref x) = &Foo(0);
- | ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:35:9
|
LL | let Foo(ref x) = &Foo(0);
- | ^^^^^^^^^^ this matches on type `&_`
+ | ^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
help: remove the unnecessary binding modifier
|
LL - let Foo(ref x) = &Foo(0);
LL + let Foo(x) = &Foo(0);
|
-error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly borrow within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:40:13
|
LL | let Foo(ref x) = &mut Foo(0);
- | ^^^ binding modifier not allowed under `ref mut` default binding mode
+ | ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:40:9
|
LL | let Foo(ref x) = &mut Foo(0);
- | ^^^^^^^^^^ this matches on type `&mut _`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^^^ this non-reference pattern matches on a reference type `&mut _`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &mut Foo(ref x) = &mut Foo(0);
| ++++
-error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:57:13
|
LL | let Foo(&x) = &Foo(&0);
- | ^ reference pattern not allowed under `ref` default binding mode
+ | ^ reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:57:9
|
LL | let Foo(&x) = &Foo(&0);
- | ^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern explicit
+ | ^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &Foo(&x) = &Foo(&0);
| +
-error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:62:13
|
LL | let Foo(&mut x) = &Foo(&mut 0);
- | ^^^^ reference pattern not allowed under `ref` default binding mode
+ | ^^^^ reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:62:9
|
LL | let Foo(&mut x) = &Foo(&mut 0);
- | ^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &Foo(&mut x) = &Foo(&mut 0);
| +
-error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:67:13
|
LL | let Foo(&x) = &mut Foo(&0);
- | ^ reference pattern not allowed under `ref mut` default binding mode
+ | ^ reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:67:9
|
LL | let Foo(&x) = &mut Foo(&0);
- | ^^^^^^^ this matches on type `&mut _`
-help: make the implied reference pattern explicit
+ | ^^^^^^^ this non-reference pattern matches on a reference type `&mut _`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &mut Foo(&x) = &mut Foo(&0);
| ++++
-error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:72:13
|
LL | let Foo(&mut x) = &mut Foo(&mut 0);
- | ^^^^ reference pattern not allowed under `ref mut` default binding mode
+ | ^^^^ reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:72:9
|
LL | let Foo(&mut x) = &mut Foo(&mut 0);
- | ^^^^^^^^^^^ this matches on type `&mut _`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^^^^ this non-reference pattern matches on a reference type `&mut _`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &mut Foo(&mut x) = &mut Foo(&mut 0);
| ++++
-error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:81:17
|
LL | if let Some(&x) = &&&&&Some(&0u8) {
- | ^ reference pattern not allowed under `ref` default binding mode
+ | ^ reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:81:12
|
LL | if let Some(&x) = &&&&&Some(&0u8) {
- | ^^^^^^^^ this matches on type `&_`
-help: make the implied reference patterns explicit
+ | ^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on these references with reference patterns to avoid implicitly borrowing
|
LL | if let &&&&&Some(&x) = &&&&&Some(&0u8) {
| +++++
-error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:87:17
|
LL | if let Some(&mut x) = &&&&&Some(&mut 0u8) {
- | ^^^^ reference pattern not allowed under `ref` default binding mode
+ | ^^^^ reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:87:12
|
LL | if let Some(&mut x) = &&&&&Some(&mut 0u8) {
- | ^^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference patterns explicit
+ | ^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on these references with reference patterns to avoid implicitly borrowing
|
LL | if let &&&&&Some(&mut x) = &&&&&Some(&mut 0u8) {
| +++++
-error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:93:17
|
LL | if let Some(&x) = &&&&&mut Some(&0u8) {
- | ^ reference pattern not allowed under `ref` default binding mode
+ | ^ reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:93:12
|
LL | if let Some(&x) = &&&&&mut Some(&0u8) {
- | ^^^^^^^^ this matches on type `&_`
-help: make the implied reference patterns explicit
+ | ^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on these references with reference patterns to avoid implicitly borrowing
|
LL | if let &&&&&mut Some(&x) = &&&&&mut Some(&0u8) {
| ++++++++
-error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:99:17
|
LL | if let Some(&mut Some(Some(x))) = &mut Some(&mut Some(&mut Some(0u8))) {
- | ^^^^ reference pattern not allowed under `ref mut` default binding mode
+ | ^^^^ reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:99:12
|
LL | if let Some(&mut Some(Some(x))) = &mut Some(&mut Some(&mut Some(0u8))) {
- | ^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&mut _`
-help: make the implied reference patterns and variable binding mode explicit
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&mut _`
+help: match on these references with reference patterns and borrow explicitly using a variable binding mode
|
LL | if let &mut Some(&mut Some(&mut Some(ref mut x))) = &mut Some(&mut Some(&mut Some(0u8))) {
| ++++ ++++ +++++++
-error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+error: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:111:21
|
LL | let Struct { a, mut b, c } = &Struct { a: 0, b: 0, c: 0 };
- | ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ `mut` binding modifier not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:111:9
|
LL | let Struct { a, mut b, c } = &Struct { a: 0, b: 0, c: 0 };
- | ^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern and variable binding modes explicit
+ | ^^^^^^^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern and borrow explicitly using variable binding modes
|
LL | let &Struct { ref a, mut b, ref c } = &Struct { a: 0, b: 0, c: 0 };
| + +++ +++
-error: binding modifiers and reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly borrow or dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:117:21
|
LL | let Struct { a: &a, b, ref c } = &Struct { a: &0, b: &0, c: &0 };
- | ^ ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^ ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
| |
- | reference pattern not allowed under `ref` default binding mode
+ | reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:117:9
|
LL | let Struct { a: &a, b, ref c } = &Struct { a: &0, b: &0, c: &0 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern and variable binding mode explicit
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern and borrow explicitly using a variable binding mode
|
LL | let &Struct { a: &a, ref b, ref c } = &Struct { a: &0, b: &0, c: &0 };
| + +++
-error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:124:24
|
LL | if let Struct { a: &Some(a), b: Some(&b), c: Some(c) } =
- | ^ ^ reference pattern not allowed under `ref` default binding mode
+ | ^ ^ reference pattern not allowed when implicitly borrowing
| |
- | reference pattern not allowed under `ref` default binding mode
+ | reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:124:12
|
LL | if let Struct { a: &Some(a), b: Some(&b), c: Some(c) } =
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference patterns and variable binding mode explicit
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on these references with reference patterns and borrow explicitly using a variable binding mode
|
LL | if let &Struct { a: &Some(a), b: &Some(&b), c: &Some(ref c) } =
| + + + +++
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot mutably bind by value within an implicitly-borrowing pattern
--> $DIR/migration_lint.rs:137:15
|
LL | (Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => {
| ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ occurs within macro expansion
| |
- | binding modifier not allowed under `ref` default binding mode
+ | `mut` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:137:9
|
LL | (Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
= note: this error originates in the macro `migration_lint_macros::mixed_edition_pat` (in Nightly builds, run with -Z macro-backtrace for more info)
-help: make the implied reference pattern explicit
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | &(Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => {
| +
-error: binding modifiers and reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly borrow or dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:145:10
|
LL | let [&mut [ref a]] = &mut [&mut &[0]];
- | ^^^^ ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^^ ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
| |
- | reference pattern not allowed under `ref mut` default binding mode
+ | reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:145:15
|
LL | let [&mut [ref a]] = &mut [&mut &[0]];
- | ^^^^^^^ this matches on type `&_`
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ | ^^^^^^^ this non-reference pattern matches on a reference type `&_`
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:145:9
|
LL | let [&mut [ref a]] = &mut [&mut &[0]];
- | ^^^^^^^^^^^^^^ this matches on type `&mut _`
-help: make the implied reference patterns explicit
+ | ^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&mut _`
+help: match on these references with reference patterns to avoid implicitly borrowing
|
LL | let &mut [&mut &[ref a]] = &mut [&mut &[0]];
| ++++ +
-error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:150:10
|
LL | let [&(_)] = &[&0];
- | ^ reference pattern not allowed under `ref` default binding mode
+ | ^ reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:150:9
|
LL | let [&(_)] = &[&0];
- | ^^^^^^ this matches on type `&_`
-help: make the implied reference pattern explicit
+ | ^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &[&(_)] = &[&0];
| +
-error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly borrow within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:157:18
|
LL | let Struct { ref a, ref b, c } = &Struct { a: 0, b: 0, c: 0 };
- | ^^^ ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
| |
- | binding modifier not allowed under `ref` default binding mode
+ | explicit `ref` binding modifier not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:157:9
|
LL | let Struct { ref a, ref b, c } = &Struct { a: 0, b: 0, c: 0 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
help: remove the unnecessary binding modifiers
|
LL - let Struct { ref a, ref b, c } = &Struct { a: 0, b: 0, c: 0 };
LL + let Struct { a, b, c } = &Struct { a: 0, b: 0, c: 0 };
|
-error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly borrow within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:164:18
|
LL | let Struct { ref a, ref mut b, c } = &mut Struct { a: 0, b: 0, c: 0 };
- | ^^^ ^^^^^^^ binding modifier not allowed under `ref mut` default binding mode
+ | ^^^ ^^^^^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
| |
- | binding modifier not allowed under `ref mut` default binding mode
+ | explicit `ref` binding modifier not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:164:9
|
LL | let Struct { ref a, ref mut b, c } = &mut Struct { a: 0, b: 0, c: 0 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&mut _`
-help: make the implied reference pattern and variable binding mode explicit
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&mut _`
+help: match on the reference with a reference pattern and borrow explicitly using a variable binding mode
|
LL | let &mut Struct { ref a, ref mut b, ref mut c } = &mut Struct { a: 0, b: 0, c: 0 };
| ++++ +++++++
-error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:172:21
|
LL | let Struct { a: &[ref a], b: &mut [[b]], c } = &mut &Struct { a: &[0], b: &mut [&[0]], c: 0 };
- | ^ ^^^^ reference pattern not allowed under `ref` default binding mode
+ | ^ ^^^^ reference pattern not allowed when implicitly borrowing
| |
- | reference pattern not allowed under `ref` default binding mode
+ | reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:172:9
|
LL | let Struct { a: &[ref a], b: &mut [[b]], c } = &mut &Struct { a: &[0], b: &mut [&[0]], c: 0 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference patterns and variable binding modes explicit
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on these references with reference patterns and borrow explicitly using variable binding modes
|
LL | let &mut &Struct { a: &[ref a], b: &mut [&[ref b]], ref c } = &mut &Struct { a: &[0], b: &mut [&[0]], c: 0 };
| ++++++ + +++ +++
-error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:180:13
|
LL | let Foo(&ref a) = &Foo(&0);
- | ^ reference pattern not allowed under `ref` default binding mode
+ | ^ reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:180:9
|
LL | let Foo(&ref a) = &Foo(&0);
- | ^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &Foo(&ref a) = &Foo(&0);
| +
-error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:186:10
|
LL | let (&a, b, [c], [(d, [e])]) = &(&0, 0, &[0], &mut [&mut (0, &[0])]);
- | ^ reference pattern not allowed under `ref` default binding mode
+ | ^ reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:186:9
|
LL | let (&a, b, [c], [(d, [e])]) = &(&0, 0, &[0], &mut [&mut (0, &[0])]);
- | ^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference patterns and variable binding modes explicit
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on these references with reference patterns and borrow explicitly using variable binding modes
|
LL | let &(&a, ref b, &[ref c], &mut [&mut (ref d, &[ref e])]) = &(&0, 0, &[0], &mut [&mut (0, &[0])]);
| + +++ + +++ ++++ ++++ +++ + +++
-error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+error: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:196:19
|
LL | let (a, [b], [mut c]) = &(0, &mut [0], &[0]);
- | ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ `mut` binding modifier not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:196:9
|
LL | let (a, [b], [mut c]) = &(0, &mut [0], &[0]);
- | ^^^^^^^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference patterns and variable binding modes explicit
+ | ^^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on these references with reference patterns and borrow explicitly using variable binding modes
|
LL | let &(ref a, &mut [ref b], &[mut c]) = &(0, &mut [0], &[0]);
| + +++ ++++ +++ +
-error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:204:10
|
LL | let (&a, (b, &[ref c])) = &(&0, &mut (0, &[0]));
- | ^ ^ reference pattern not allowed under `ref` default binding mode
+ | ^ ^ reference pattern not allowed when implicitly borrowing
| |
- | reference pattern not allowed under `ref` default binding mode
+ | reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:204:9
|
LL | let (&a, (b, &[ref c])) = &(&0, &mut (0, &[0]));
- | ^^^^^^^^^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference patterns and variable binding mode explicit
+ | ^^^^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on these references with reference patterns and borrow explicitly using a variable binding mode
|
LL | let &(&a, &mut (ref b, &[ref c])) = &(&0, &mut (0, &[0]));
| + ++++ +++
-error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+error: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:212:10
|
LL | let [mut a @ b] = &[0];
- | ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ `mut` binding modifier not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:212:9
|
LL | let [mut a @ b] = &[0];
- | ^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern and variable binding mode explicit
+ | ^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern and borrow explicitly using a variable binding mode
|
LL | let &[mut a @ ref b] = &[0];
| + +++
-error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024
+error: cannot mutably bind by value within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:219:14
|
LL | let [a @ mut b] = &[0];
- | ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ `mut` binding modifier not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:219:9
|
LL | let [a @ mut b] = &[0];
- | ^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern and variable binding mode explicit
+ | ^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern and borrow explicitly using a variable binding mode
|
LL | let &[ref a @ mut b] = &[0];
| + +++
-error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:226:14
|
LL | let [Foo(&ref a @ ref b), Foo(&ref c @ d)] = [&Foo(&0); 2];
- | ^ ^ reference pattern not allowed under `ref` default binding mode
+ | ^ ^ reference pattern not allowed when implicitly borrowing
| |
- | reference pattern not allowed under `ref` default binding mode
+ | reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:226:31
|
LL | let [Foo(&ref a @ ref b), Foo(&ref c @ d)] = [&Foo(&0); 2];
- | ^^^^^^^^^^^^^^^ this matches on type `&_`
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ | ^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:226:10
|
LL | let [Foo(&ref a @ ref b), Foo(&ref c @ d)] = [&Foo(&0); 2];
- | ^^^^^^^^^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference patterns explicit
+ | ^^^^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on these references with reference patterns to avoid implicitly borrowing
|
LL | let [&Foo(&ref a @ ref b), &Foo(&ref c @ d)] = [&Foo(&0); 2];
| + +
-error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:235:14
|
LL | let [Foo(&ref a @ [ref b]), Foo(&ref c @ [d])] = [&Foo(&[0]); 2];
- | ^ ^ reference pattern not allowed under `ref` default binding mode
+ | ^ ^ reference pattern not allowed when implicitly borrowing
| |
- | reference pattern not allowed under `ref` default binding mode
+ | reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:235:33
|
LL | let [Foo(&ref a @ [ref b]), Foo(&ref c @ [d])] = [&Foo(&[0]); 2];
- | ^^^^^^^^^^^^^^^^^ this matches on type `&_`
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ | ^^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:235:10
|
LL | let [Foo(&ref a @ [ref b]), Foo(&ref c @ [d])] = [&Foo(&[0]); 2];
- | ^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference patterns explicit
+ | ^^^^^^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on these references with reference patterns to avoid implicitly borrowing
|
LL | let [&Foo(&ref a @ [ref b]), &Foo(&ref c @ [d])] = [&Foo(&[0]); 2];
| + +
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/migration_lint.rs:244:10
|
LL | let [migration_lint_macros::bind_ref!(a)] = &[0];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ occurs within macro expansion
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:244:9
|
LL | let [migration_lint_macros::bind_ref!(a)] = &[0];
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
= note: this error originates in the macro `migration_lint_macros::bind_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
-help: make the implied reference pattern explicit
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &[migration_lint_macros::bind_ref!(a)] = &[0];
| +
-error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
+error: cannot explicitly dereference within an implicitly-borrowing pattern in Rust 2024
--> $DIR/migration_lint.rs:249:10
|
LL | let [&migration_lint_macros::bind_ref!(a)] = &[&0];
- | ^ reference pattern not allowed under `ref` default binding mode
+ | ^ reference pattern not allowed when implicitly borrowing
|
= warning: this changes meaning in Rust 2024
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/migration_lint.rs:249:9
|
LL | let [&migration_lint_macros::bind_ref!(a)] = &[&0];
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | let &[&migration_lint_macros::bind_ref!(a)] = &[&0];
| +
-error: aborting due to 31 previous errors
+error: cannot write explicit binding modifiers within an implicitly-borrowing pattern in Rust 2024
+ --> $DIR/migration_lint.rs:255:10
+ |
+LL | let (mut a, ref b) = &(0, 0);
+ | ^^^ ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
+ | |
+ | `mut` binding modifier not allowed when implicitly borrowing
+ |
+ = warning: this changes meaning in Rust 2024
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
+ --> $DIR/migration_lint.rs:255:9
+ |
+LL | let (mut a, ref b) = &(0, 0);
+ | ^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
+ |
+LL | let &(mut a, ref b) = &(0, 0);
+ | +
+
+error: cannot mutably bind by value or explicitly dereference within an implicitly-borrowing pattern in Rust 2024
+ --> $DIR/migration_lint.rs:261:10
+ |
+LL | let (mut a, &b) = &(0, &0);
+ | ^^^ ^ reference pattern not allowed when implicitly borrowing
+ | |
+ | `mut` binding modifier not allowed when implicitly borrowing
+ |
+ = warning: this changes meaning in Rust 2024
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
+ --> $DIR/migration_lint.rs:261:9
+ |
+LL | let (mut a, &b) = &(0, &0);
+ | ^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
+ |
+LL | let &(mut a, &b) = &(0, &0);
+ | +
+
+error: cannot write explicit binding modifiers or explicitly dereference within an implicitly-borrowing pattern in Rust 2024
+ --> $DIR/migration_lint.rs:267:10
+ |
+LL | let (mut a, ref b, &c) = &(0, 0, &0);
+ | ^^^ ^^^ ^ reference pattern not allowed when implicitly borrowing
+ | | |
+ | | explicit `ref` binding modifier not allowed when implicitly borrowing
+ | `mut` binding modifier not allowed when implicitly borrowing
+ |
+ = warning: this changes meaning in Rust 2024
+ = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
+ --> $DIR/migration_lint.rs:267:9
+ |
+LL | let (mut a, ref b, &c) = &(0, 0, &0);
+ | ^^^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
+ |
+LL | let &(mut a, ref b, &c) = &(0, 0, &0);
+ | +
+
+error: aborting due to 34 previous errors
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.rs
index 4dc04d9..d56b835 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.rs
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.rs
@@ -21,17 +21,17 @@ fn foo($($tt)*) {}
}
test_pat_on_type![(&x,): &(T,)]; //~ ERROR mismatched types
-test_pat_on_type![(&x,): &(&T,)]; //~ ERROR reference patterns may only be written when the default binding mode is `move`
+test_pat_on_type![(&x,): &(&T,)]; //~ ERROR cannot explicitly dereference within an implicitly-borrowing pattern
test_pat_on_type![(&x,): &(&mut T,)]; //~ ERROR mismatched types
test_pat_on_type![(&mut x,): &(&T,)]; //~ ERROR mismatched types
-test_pat_on_type![(&mut x,): &(&mut T,)]; //~ ERROR reference patterns may only be written when the default binding mode is `move`
+test_pat_on_type![(&mut x,): &(&mut T,)]; //~ ERROR cannot explicitly dereference within an implicitly-borrowing pattern
test_pat_on_type![(&x,): &&mut &(T,)]; //~ ERROR mismatched types
test_pat_on_type![Foo { f: (&x,) }: Foo]; //~ ERROR mismatched types
test_pat_on_type![Foo { f: (&x,) }: &mut Foo]; //~ ERROR mismatched types
-test_pat_on_type![Foo { f: &(x,) }: &Foo]; //~ ERROR reference patterns may only be written when the default binding mode is `move`
-test_pat_on_type![(mut x,): &(T,)]; //~ ERROR binding modifiers may only be written when the default binding mode is `move`
-test_pat_on_type![(ref x,): &(T,)]; //~ ERROR binding modifiers may only be written when the default binding mode is `move`
-test_pat_on_type![(ref mut x,): &mut (T,)]; //~ ERROR binding modifiers may only be written when the default binding mode is `move`
+test_pat_on_type![Foo { f: &(x,) }: &Foo]; //~ ERROR cannot explicitly dereference within an implicitly-borrowing pattern
+test_pat_on_type![(mut x,): &(T,)]; //~ ERROR cannot mutably bind by value within an implicitly-borrowing pattern
+test_pat_on_type![(ref x,): &(T,)]; //~ ERROR cannot explicitly borrow within an implicitly-borrowing pattern
+test_pat_on_type![(ref mut x,): &mut (T,)]; //~ ERROR cannot explicitly borrow within an implicitly-borrowing pattern
fn get<X>() -> X {
unimplemented!()
@@ -40,6 +40,6 @@ fn get<X>() -> X {
// Make sure this works even when the underlying type is inferred. This test passes on rust stable.
fn infer<X: Copy>() -> X {
match &get() {
- (&x,) => x, //~ ERROR reference patterns may only be written when the default binding mode is `move`
+ (&x,) => x, //~ ERROR cannot explicitly dereference within an implicitly-borrowing pattern
}
}
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr
index 0c6b2ff..23f1557 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr
@@ -99,123 +99,123 @@
LL + test_pat_on_type![Foo { f: (x,) }: &mut Foo];
|
-error: reference patterns may only be written when the default binding mode is `move`
+error: cannot explicitly dereference within an implicitly-borrowing pattern
--> $DIR/min_match_ergonomics_fail.rs:24:20
|
LL | test_pat_on_type![(&x,): &(&T,)];
- | ^ reference pattern not allowed under `ref` default binding mode
+ | ^ reference pattern not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/min_match_ergonomics_fail.rs:24:19
|
LL | test_pat_on_type![(&x,): &(&T,)];
- | ^^^^^ this matches on type `&_`
-help: make the implied reference pattern explicit
+ | ^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | test_pat_on_type![&(&x,): &(&T,)];
| +
-error: reference patterns may only be written when the default binding mode is `move`
+error: cannot explicitly dereference within an implicitly-borrowing pattern
--> $DIR/min_match_ergonomics_fail.rs:27:20
|
LL | test_pat_on_type![(&mut x,): &(&mut T,)];
- | ^^^^ reference pattern not allowed under `ref` default binding mode
+ | ^^^^ reference pattern not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/min_match_ergonomics_fail.rs:27:19
|
LL | test_pat_on_type![(&mut x,): &(&mut T,)];
- | ^^^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | test_pat_on_type![&(&mut x,): &(&mut T,)];
| +
-error: reference patterns may only be written when the default binding mode is `move`
+error: cannot explicitly dereference within an implicitly-borrowing pattern
--> $DIR/min_match_ergonomics_fail.rs:31:28
|
LL | test_pat_on_type![Foo { f: &(x,) }: &Foo];
- | ^ reference pattern not allowed under `ref` default binding mode
+ | ^ reference pattern not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/min_match_ergonomics_fail.rs:31:19
|
LL | test_pat_on_type![Foo { f: &(x,) }: &Foo];
- | ^^^^^^^^^^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | test_pat_on_type![&Foo { f: &(x,) }: &Foo];
| +
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot mutably bind by value within an implicitly-borrowing pattern
--> $DIR/min_match_ergonomics_fail.rs:32:20
|
LL | test_pat_on_type![(mut x,): &(T,)];
- | ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ `mut` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/min_match_ergonomics_fail.rs:32:19
|
LL | test_pat_on_type![(mut x,): &(T,)];
- | ^^^^^^^^ this matches on type `&_`
-help: make the implied reference pattern explicit
+ | ^^^^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | test_pat_on_type![&(mut x,): &(T,)];
| +
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/min_match_ergonomics_fail.rs:33:20
|
LL | test_pat_on_type![(ref x,): &(T,)];
- | ^^^ binding modifier not allowed under `ref` default binding mode
+ | ^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/min_match_ergonomics_fail.rs:33:19
|
LL | test_pat_on_type![(ref x,): &(T,)];
- | ^^^^^^^^ this matches on type `&_`
+ | ^^^^^^^^ this non-reference pattern matches on a reference type `&_`
help: remove the unnecessary binding modifier
|
LL - test_pat_on_type![(ref x,): &(T,)];
LL + test_pat_on_type![(x,): &(T,)];
|
-error: binding modifiers may only be written when the default binding mode is `move`
+error: cannot explicitly borrow within an implicitly-borrowing pattern
--> $DIR/min_match_ergonomics_fail.rs:34:20
|
LL | test_pat_on_type![(ref mut x,): &mut (T,)];
- | ^^^^^^^ binding modifier not allowed under `ref mut` default binding mode
+ | ^^^^^^^ explicit `ref` binding modifier not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/min_match_ergonomics_fail.rs:34:19
|
LL | test_pat_on_type![(ref mut x,): &mut (T,)];
- | ^^^^^^^^^^^^ this matches on type `&mut _`
+ | ^^^^^^^^^^^^ this non-reference pattern matches on a reference type `&mut _`
help: remove the unnecessary binding modifier
|
LL - test_pat_on_type![(ref mut x,): &mut (T,)];
LL + test_pat_on_type![(x,): &mut (T,)];
|
-error: reference patterns may only be written when the default binding mode is `move`
+error: cannot explicitly dereference within an implicitly-borrowing pattern
--> $DIR/min_match_ergonomics_fail.rs:43:10
|
LL | (&x,) => x,
- | ^ reference pattern not allowed under `ref` default binding mode
+ | ^ reference pattern not allowed when implicitly borrowing
|
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
-note: matching on a reference type with a non-reference pattern changes the default binding mode
+ = note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
+note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> $DIR/min_match_ergonomics_fail.rs:43:9
|
LL | (&x,) => x,
- | ^^^^^ this matches on type `&_`
-help: make the implied reference pattern explicit
+ | ^^^^^ this non-reference pattern matches on a reference type `&_`
+help: match on the reference with a reference pattern to avoid implicitly borrowing
|
LL | &(&x,) => x,
| +
diff --git a/tests/ui/target-feature/invalid-attribute.stderr b/tests/ui/target-feature/invalid-attribute.stderr
index d85bccc..eaa26aa 100644
--- a/tests/ui/target-feature/invalid-attribute.stderr
+++ b/tests/ui/target-feature/invalid-attribute.stderr
@@ -143,7 +143,7 @@
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
- = help: `#[target_feature]` can be applied to methods and functions
+ = help: `#[target_feature]` can be applied to functions and methods
error[E0658]: cannot use `#[inline(always)]` with `#[target_feature]`
--> $DIR/invalid-attribute.rs:62:1
diff --git a/tests/ui/where-clauses/unsupported_attribute.stderr b/tests/ui/where-clauses/unsupported_attribute.stderr
index 42a8a13..9ebc14c 100644
--- a/tests/ui/where-clauses/unsupported_attribute.stderr
+++ b/tests/ui/where-clauses/unsupported_attribute.stderr
@@ -48,7 +48,7 @@
LL | #[macro_use] T: Trait,
| ^^^^^^^^^^^^
|
- = help: `#[macro_use]` can be applied to modules, extern crates, and crates
+ = help: `#[macro_use]` can be applied to crates, extern crates, and modules
error: `#[macro_use]` attribute cannot be used on where predicates
--> $DIR/unsupported_attribute.rs:21:5
@@ -56,7 +56,7 @@
LL | #[macro_use] 'a: 'static,
| ^^^^^^^^^^^^
|
- = help: `#[macro_use]` can be applied to modules, extern crates, and crates
+ = help: `#[macro_use]` can be applied to crates, extern crates, and modules
error: `#[deprecated]` attribute cannot be used on where predicates
--> $DIR/unsupported_attribute.rs:24:5
@@ -64,7 +64,7 @@
LL | #[deprecated] T: Trait,
| ^^^^^^^^^^^^^
|
- = help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, foreign statics, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, and crates
+ = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, unions, and use statements
error: `#[deprecated]` attribute cannot be used on where predicates
--> $DIR/unsupported_attribute.rs:25:5
@@ -72,7 +72,7 @@
LL | #[deprecated] 'a: 'static,
| ^^^^^^^^^^^^^
|
- = help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, foreign statics, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, and crates
+ = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, unions, and use statements
error: `#[automatically_derived]` attribute cannot be used on where predicates
--> $DIR/unsupported_attribute.rs:26:5