diff options
161 files changed, 3687 insertions, 1560 deletions
diff --git a/Cargo.lock b/Cargo.lock index fd8d461c545..4d7b62e9c55 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -345,7 +345,6 @@ dependencies = [ "libgit2-sys", "log", "memchr", - "num_cpus", "opener", "openssl", "os_info", @@ -1503,9 +1502,9 @@ dependencies = [ [[package]] name = "git2" -version = "0.13.23" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a8057932925d3a9d9e4434ea016570d37420ddb1ceed45a174d577f24ed6700" +checksum = "6e7d3b96ec1fcaa8431cf04a4f1ef5caafe58d5cf7bcc31f09c1626adddb0ffe" dependencies = [ "bitflags", "libc", @@ -1518,9 +1517,9 @@ dependencies = [ [[package]] name = "git2-curl" -version = "0.14.1" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "883539cb0ea94bab3f8371a98cd8e937bbe9ee7c044499184aa4c17deb643a50" +checksum = "1ee51709364c341fbb6fe2a385a290fb9196753bdde2fc45447d27cd31b11b13" dependencies = [ "curl", "git2", @@ -1975,9 +1974,9 @@ dependencies = [ [[package]] name = "libgit2-sys" -version = "0.12.24+1.3.0" +version = "0.13.1+1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddbd6021eef06fb289a8f54b3c2acfdd85ff2a585dfbb24b8576325373d2152c" +checksum = "43e598aa7a4faedf1ea1b4608f582b06f0f40211eec551b7ef36019ae3f62def" dependencies = [ "cc", "libc", diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 2a74e1ce8b1..1cbca58ca25 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -1,5 +1,5 @@ use either::Either; -use rustc_const_eval::util::{CallDesugaringKind, CallKind}; +use rustc_const_eval::util::CallKind; use rustc_data_structures::fx::FxHashSet; use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed}; use rustc_hir as hir; @@ -17,7 +17,7 @@ use rustc_middle::ty::{ }; use rustc_mir_dataflow::move_paths::{InitKind, MoveOutIndex, MovePathIndex}; use rustc_span::symbol::sym; -use rustc_span::{BytePos, MultiSpan, Span, DUMMY_SP}; +use rustc_span::{BytePos, MultiSpan, Span}; use rustc_trait_selection::infer::InferCtxtExt; use rustc_trait_selection::traits::TraitEngineExt as _; @@ -195,144 +195,19 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { is_loop_move = true; } - if let UseSpans::FnSelfUse { var_span, fn_call_span, fn_span, kind } = move_spans { - let place_name = self - .describe_place(moved_place.as_ref()) - .map(|n| format!("`{}`", n)) - .unwrap_or_else(|| "value".to_owned()); - match kind { - CallKind::FnCall { fn_trait_id, .. } - if Some(fn_trait_id) == self.infcx.tcx.lang_items().fn_once_trait() => - { - err.span_label( - fn_call_span, - &format!( - "{} {}moved due to this call{}", - place_name, partially_str, loop_message - ), - ); - err.span_note( - var_span, - "this value implements `FnOnce`, which causes it to be moved when called", - ); - } - CallKind::Operator { self_arg, .. } => { - let self_arg = self_arg.unwrap(); - err.span_label( - fn_call_span, - &format!( - "{} {}moved due to usage in operator{}", - place_name, partially_str, loop_message - ), - ); - if self.fn_self_span_reported.insert(fn_span) { - err.span_note( - // Check whether the source is accessible - if self - .infcx - .tcx - .sess - .source_map() - .span_to_snippet(self_arg.span) - .is_ok() - { - self_arg.span - } else { - fn_call_span - }, - "calling this operator moves the left-hand side", - ); - } - } - CallKind::Normal { self_arg, desugaring, is_option_or_result } => { - let self_arg = self_arg.unwrap(); - if let Some((CallDesugaringKind::ForLoopIntoIter, _)) = desugaring { - err.span_label( - fn_call_span, - &format!( - "{} {}moved due to this implicit call to `.into_iter()`{}", - place_name, partially_str, loop_message - ), - ); - let sess = self.infcx.tcx.sess; - let ty = used_place.ty(self.body, self.infcx.tcx).ty; - // If we have a `&mut` ref, we need to reborrow. - if let ty::Ref(_, _, hir::Mutability::Mut) = ty.kind() { - // If we are in a loop this will be suggested later. - if !is_loop_move { - err.span_suggestion_verbose( - move_span.shrink_to_lo(), - &format!( - "consider creating a fresh reborrow of {} here", - self.describe_place(moved_place.as_ref()) - .map(|n| format!("`{}`", n)) - .unwrap_or_else( - || "the mutable reference".to_string() - ), - ), - "&mut *".to_string(), - Applicability::MachineApplicable, - ); - } - } else if let Ok(snippet) = - sess.source_map().span_to_snippet(move_span) - { - err.span_suggestion( - move_span, - "consider borrowing to avoid moving into the for loop", - format!("&{}", snippet), - Applicability::MaybeIncorrect, - ); - } - } else { - err.span_label( - fn_call_span, - &format!( - "{} {}moved due to this method call{}", - place_name, partially_str, loop_message - ), - ); - } - if is_option_or_result && maybe_reinitialized_locations.is_empty() { - err.span_suggestion_verbose( - fn_call_span.shrink_to_lo(), - "consider calling `.as_ref()` to borrow the type's contents", - "as_ref().".to_string(), - Applicability::MachineApplicable, - ); - } - // Avoid pointing to the same function in multiple different - // error messages. - if span != DUMMY_SP && self.fn_self_span_reported.insert(self_arg.span) - { - err.span_note( - self_arg.span, - &format!("this function takes ownership of the receiver `self`, which moves {}", place_name) - ); - } - } - // Other desugarings takes &self, which cannot cause a move - _ => unreachable!(), - } - } else { - err.span_label( - move_span, - format!("value {}moved{} here{}", partially_str, move_msg, loop_message), - ); - // If the move error occurs due to a loop, don't show - // another message for the same span - if loop_message.is_empty() { - move_spans.var_span_label( - &mut err, - format!( - "variable {}moved due to use{}", - partially_str, - move_spans.describe() - ), - "moved", - ); - } - } + self.explain_captures( + &mut err, + span, + move_span, + move_spans, + *moved_place, + Some(used_place), + partially_str, + loop_message, + move_msg, + is_loop_move, + maybe_reinitialized_locations.is_empty(), + ); if let (UseSpans::PatUse(span), []) = (move_spans, &maybe_reinitialized_locations[..]) diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 754856043b3..164ebfed0f7 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -1,11 +1,12 @@ //! Borrow checker diagnostics. -use rustc_const_eval::util::call_kind; -use rustc_errors::Diagnostic; +use rustc_const_eval::util::{call_kind, CallDesugaringKind}; +use rustc_errors::{Applicability, Diagnostic}; use rustc_hir as hir; use rustc_hir::def::Namespace; use rustc_hir::def_id::DefId; use rustc_hir::GeneratorKind; +use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::mir::{ AggregateKind, Constant, FakeReadCause, Field, Local, LocalInfo, LocalKind, Location, Operand, Place, PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind, @@ -13,8 +14,9 @@ use rustc_middle::mir::{ use rustc_middle::ty::print::Print; use rustc_middle::ty::{self, DefIdTree, Instance, Ty, TyCtxt}; use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult}; -use rustc_span::{symbol::sym, Span}; +use rustc_span::{symbol::sym, Span, DUMMY_SP}; use rustc_target::abi::VariantIdx; +use rustc_trait_selection::traits::type_known_to_meet_bound_modulo_regions; use super::borrow_set::BorrowData; use super::MirBorrowckCtxt; @@ -482,9 +484,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { BorrowedContentSource::DerefSharedRef } } -} -impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// Return the name of the provided `Ty` (that must be a reference) with a synthesized lifetime /// name where required. pub(super) fn get_name_for_ty(&self, ty: Ty<'tcx>, counter: usize) -> String { @@ -995,4 +995,173 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let span = self.body.source_info(borrow.reserve_location).span; self.borrow_spans(span, borrow.reserve_location) } + + fn explain_captures( + &mut self, + err: &mut Diagnostic, + span: Span, + move_span: Span, + move_spans: UseSpans<'tcx>, + moved_place: Place<'tcx>, + used_place: Option<PlaceRef<'tcx>>, + partially_str: &str, + loop_message: &str, + move_msg: &str, + is_loop_move: bool, + maybe_reinitialized_locations_is_empty: bool, + ) { + if let UseSpans::FnSelfUse { var_span, fn_call_span, fn_span, kind } = move_spans { + let place_name = self + .describe_place(moved_place.as_ref()) + .map(|n| format!("`{}`", n)) + .unwrap_or_else(|| "value".to_owned()); + match kind { + CallKind::FnCall { fn_trait_id, .. } + if Some(fn_trait_id) == self.infcx.tcx.lang_items().fn_once_trait() => + { + err.span_label( + fn_call_span, + &format!( + "{} {}moved due to this call{}", + place_name, partially_str, loop_message + ), + ); + err.span_note( + var_span, + "this value implements `FnOnce`, which causes it to be moved when called", + ); + } + CallKind::Operator { self_arg, .. } => { + let self_arg = self_arg.unwrap(); + err.span_label( + fn_call_span, + &format!( + "{} {}moved due to usage in operator{}", + place_name, partially_str, loop_message + ), + ); + if self.fn_self_span_reported.insert(fn_span) { + err.span_note( + // Check whether the source is accessible + if self + .infcx + .tcx + .sess + .source_map() + .span_to_snippet(self_arg.span) + .is_ok() + { + self_arg.span + } else { + fn_call_span + }, + "calling this operator moves the left-hand side", + ); + } + } + CallKind::Normal { self_arg, desugaring, is_option_or_result } => { + let self_arg = self_arg.unwrap(); + if let Some((CallDesugaringKind::ForLoopIntoIter, _)) = desugaring { + let ty = moved_place.ty(self.body, self.infcx.tcx).ty; + let suggest = match self.infcx.tcx.get_diagnostic_item(sym::IntoIterator) { + Some(def_id) => self.infcx.tcx.infer_ctxt().enter(|infcx| { + type_known_to_meet_bound_modulo_regions( + &infcx, + self.param_env, + infcx.tcx.mk_imm_ref( + infcx.tcx.lifetimes.re_erased, + infcx.tcx.erase_regions(ty), + ), + def_id, + DUMMY_SP, + ) + }), + _ => false, + }; + if suggest { + err.span_suggestion_verbose( + move_span.shrink_to_lo(), + &format!( + "consider iterating over a slice of the `{}`'s content to \ + avoid moving into the `for` loop", + ty, + ), + "&".to_string(), + Applicability::MaybeIncorrect, + ); + } + + err.span_label( + fn_call_span, + &format!( + "{} {}moved due to this implicit call to `.into_iter()`{}", + place_name, partially_str, loop_message + ), + ); + // If we have a `&mut` ref, we need to reborrow. + if let Some(ty::Ref(_, _, hir::Mutability::Mut)) = used_place + .map(|used_place| used_place.ty(self.body, self.infcx.tcx).ty.kind()) + { + // If we are in a loop this will be suggested later. + if !is_loop_move { + err.span_suggestion_verbose( + move_span.shrink_to_lo(), + &format!( + "consider creating a fresh reborrow of {} here", + self.describe_place(moved_place.as_ref()) + .map(|n| format!("`{}`", n)) + .unwrap_or_else(|| "the mutable reference".to_string()), + ), + "&mut *".to_string(), + Applicability::MachineApplicable, + ); + } + } + } else { + err.span_label( + fn_call_span, + &format!( + "{} {}moved due to this method call{}", + place_name, partially_str, loop_message + ), + ); + } + if is_option_or_result && maybe_reinitialized_locations_is_empty { + err.span_suggestion_verbose( + fn_call_span.shrink_to_lo(), + "consider calling `.as_ref()` to borrow the type's contents", + "as_ref().".to_string(), + Applicability::MachineApplicable, + ); + } + // Avoid pointing to the same function in multiple different + // error messages. + if span != DUMMY_SP && self.fn_self_span_reported.insert(self_arg.span) { + err.span_note( + self_arg.span, + &format!("this function takes ownership of the receiver `self`, which moves {}", place_name) + ); + } + } + // Other desugarings takes &self, which cannot cause a move + _ => {} + } + } else { + if move_span != span || !loop_message.is_empty() { + err.span_label( + move_span, + format!("value {}moved{} here{}", partially_str, move_msg, loop_message), + ); + } + // If the move error occurs due to a loop, don't show + // another message for the same span + if loop_message.is_empty() { + move_spans.var_span_label( + err, + format!("variable {}moved due to use{}", partially_str, move_spans.describe()), + "moved", + ); + } + } + } } diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index 19091569b4d..f76ec031aa9 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -1,15 +1,12 @@ -use rustc_const_eval::util::CallDesugaringKind; use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed}; -use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::mir::*; use rustc_middle::ty; use rustc_mir_dataflow::move_paths::{ IllegalMoveOrigin, IllegalMoveOriginKind, LookupResult, MoveError, MovePathIndex, }; -use rustc_span::{sym, Span, DUMMY_SP}; -use rustc_trait_selection::traits::type_known_to_meet_bound_modulo_regions; +use rustc_span::{sym, Span}; -use crate::diagnostics::{CallKind, UseSpans}; +use crate::diagnostics::UseSpans; use crate::prefixes::PrefixSet; use crate::MirBorrowckCtxt; @@ -409,34 +406,10 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { ".as_ref()".to_string(), Applicability::MaybeIncorrect, ); - } else if let Some(UseSpans::FnSelfUse { - kind: - CallKind::Normal { desugaring: Some((CallDesugaringKind::ForLoopIntoIter, _)), .. }, - .. - }) = use_spans - { - let suggest = match self.infcx.tcx.get_diagnostic_item(sym::IntoIterator) { - Some(def_id) => self.infcx.tcx.infer_ctxt().enter(|infcx| { - type_known_to_meet_bound_modulo_regions( - &infcx, - self.param_env, - infcx - .tcx - .mk_imm_ref(infcx.tcx.lifetimes.re_erased, infcx.tcx.erase_regions(ty)), - def_id, - DUMMY_SP, - ) - }), - _ => false, - }; - if suggest { - err.span_suggestion_verbose( - span.shrink_to_lo(), - &format!("consider iterating over a slice of the `{}`'s content", ty), - "&".to_string(), - Applicability::MaybeIncorrect, - ); - } + } else if let Some(use_spans) = use_spans { + self.explain_captures( + &mut err, span, span, use_spans, move_place, None, "", "", "", false, true, + ); } err } @@ -491,11 +464,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { self.note_type_does_not_implement_copy(err, &place_desc, place_ty, Some(span), ""); use_spans.args_span_label(err, format!("move out of {} occurs here", place_desc)); - use_spans.var_span_label( - err, - format!("move occurs due to use{}", use_spans.describe()), - "moved", - ); } } } diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index a59d91ea789..39ebd57b4b2 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -7,6 +7,7 @@ use crate::SuggestionStyle; use crate::ToolMetadata; use rustc_lint_defs::Applicability; use rustc_serialize::json::Json; +use rustc_span::edition::LATEST_STABLE_EDITION; use rustc_span::{MultiSpan, Span, DUMMY_SP}; use std::fmt; use std::hash::{Hash, Hasher}; @@ -342,6 +343,18 @@ impl Diagnostic { self } + /// Help the user upgrade to the latest edition. + /// This is factored out to make sure it does the right thing with `Cargo.toml`. + pub fn help_use_latest_edition(&mut self) -> &mut Self { + if std::env::var_os("CARGO").is_some() { + self.help(&format!("set `edition = \"{}\"` in `Cargo.toml`", LATEST_STABLE_EDITION)); + } else { + self.help(&format!("pass `--edition {}` to `rustc`", LATEST_STABLE_EDITION)); + } + self.note("for more on editions, read https://doc.rust-lang.org/edition-guide"); + self + } + /// Disallow attaching suggestions this diagnostic. /// Any suggestions attached e.g. with the `span_suggestion_*` methods /// (before and after the call to `disable_suggestions`) will be ignored. diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs index 5dc71f16200..98b8b2a569e 100644 --- a/compiler/rustc_errors/src/diagnostic_builder.rs +++ b/compiler/rustc_errors/src/diagnostic_builder.rs @@ -409,6 +409,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { sp: impl Into<MultiSpan>, msg: &str, ) -> &mut Self); + forward!(pub fn help_use_latest_edition(&mut self,) -> &mut Self); forward!(pub fn set_is_lint(&mut self,) -> &mut Self); forward!(pub fn disable_suggestions(&mut self,) -> &mut Self); diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 4b9cf784495..bb51f880099 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -606,17 +606,17 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ rustc_attr!( rustc_layout_scalar_valid_range_start, Normal, template!(List: "value"), ErrorFollowing, "the `#[rustc_layout_scalar_valid_range_start]` attribute is just used to enable \ - niche optimizations in libcore and will never be stable", + niche optimizations in libcore and libstd and will never be stable", ), rustc_attr!( rustc_layout_scalar_valid_range_end, Normal, template!(List: "value"), ErrorFollowing, "the `#[rustc_layout_scalar_valid_range_end]` attribute is just used to enable \ - niche optimizations in libcore and will never be stable", + niche optimizations in libcore and libstd and will never be stable", ), rustc_attr!( rustc_nonnull_optimization_guaranteed, Normal, template!(Word), WarnFollowing, "the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to enable \ - niche optimizations in libcore and will never be stable", + niche optimizations in libcore and libstd and will never be stable", ), // ========================================================================== diff --git a/compiler/rustc_infer/src/infer/glb.rs b/compiler/rustc_infer/src/infer/glb.rs index 381097344ec..e98f33ea86e 100644 --- a/compiler/rustc_infer/src/infer/glb.rs +++ b/compiler/rustc_infer/src/infer/glb.rs @@ -1,3 +1,5 @@ +//! Greatest lower bound. See [`lattice`]. + use super::combine::CombineFields; use super::lattice::{self, LatticeDir}; use super::InferCtxt; diff --git a/compiler/rustc_infer/src/infer/lattice.rs b/compiler/rustc_infer/src/infer/lattice.rs index c47d4769637..32affd6a14e 100644 --- a/compiler/rustc_infer/src/infer/lattice.rs +++ b/compiler/rustc_infer/src/infer/lattice.rs @@ -1,23 +1,21 @@ -//! # Lattice Variables +//! # Lattice variables //! -//! This file contains generic code for operating on inference variables -//! that are characterized by an upper- and lower-bound. The logic and -//! reasoning is explained in detail in the large comment in `infer.rs`. +//! Generic code for operating on [lattices] of inference variables +//! that are characterized by an upper- and lower-bound. //! -//! The code in here is defined quite generically so that it can be +//! The code is defined quite generically so that it can be //! applied both to type variables, which represent types being inferred, //! and fn variables, which represent function types being inferred. -//! It may eventually be applied to their types as well, who knows. +//! (It may eventually be applied to their types as well.) //! In some cases, the functions are also generic with respect to the //! operation on the lattice (GLB vs LUB). //! -//! Although all the functions are generic, we generally write the -//! comments in a way that is specific to type variables and the LUB -//! operation. It's just easier that way. +//! ## Note //! -//! In general all of the functions are defined parametrically -//! over a `LatticeValue`, which is a value defined with respect to -//! a lattice. +//! Although all the functions are generic, for simplicity, comments in the source code +//! generally refer to type variables and the LUB operation. +//! +//! [lattices]: https://en.wikipedia.org/wiki/Lattice_(order) use super::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use super::InferCtxt; @@ -27,6 +25,11 @@ use rustc_middle::ty::relate::{RelateResult, TypeRelation}; use rustc_middle::ty::TyVar; use rustc_middle::ty::{self, Ty}; +/// Trait for returning data about a lattice, and for abstracting +/// over the "direction" of the lattice operation (LUB/GLB). +/// +/// GLB moves "down" the lattice (to smaller values); LUB moves +/// "up" the lattice (to bigger values). pub trait LatticeDir<'f, 'tcx>: TypeRelation<'tcx> { fn infcx(&self) -> &'f InferCtxt<'f, 'tcx>; @@ -41,6 +44,7 @@ pub trait LatticeDir<'f, 'tcx>: TypeRelation<'tcx> { fn relate_bound(&mut self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()>; } +/// Relates two types using a given lattice. pub fn super_lattice_tys<'a, 'tcx: 'a, L>( this: &mut L, a: Ty<'tcx>, diff --git a/compiler/rustc_infer/src/infer/lub.rs b/compiler/rustc_infer/src/infer/lub.rs index 57cbe2c54f7..bc85a4ac609 100644 --- a/compiler/rustc_infer/src/infer/lub.rs +++ b/compiler/rustc_infer/src/infer/lub.rs @@ -1,3 +1,5 @@ +//! Least upper bound. See [`lattice`]. + use super::combine::CombineFields; use super::lattice::{self, LatticeDir}; use super::InferCtxt; diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index f46f74fa45f..bbfbf61f486 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -258,7 +258,7 @@ impl<'s> LintLevelsBuilder<'s> { }; if metas.is_empty() { - // FIXME (#55112): issue unused-attributes lint for `#[level()]` + // This emits the unused_attributes lint for `#[level()]` continue; } @@ -271,8 +271,6 @@ impl<'s> LintLevelsBuilder<'s> { ast::MetaItemKind::Word => {} // actual lint names handled later ast::MetaItemKind::NameValue(ref name_value) => { if item.path == sym::reason { - // FIXME (#55112): issue unused-attributes lint if we thereby - // don't have any lint names (`#[level(reason = "foo")]`) if let ast::LitKind::Str(rationale, _) = name_value.kind { if !self.sess.features_untracked().lint_reasons { feature_err( diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 0d5e1e7f551..d4dac640cc7 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -795,7 +795,9 @@ crate fn repr_nullable_ptr<'tcx>( let field_ty_abi = &cx.layout_of(field_ty).unwrap().abi; if let Abi::Scalar(field_ty_scalar) = field_ty_abi { match (field_ty_scalar.valid_range.start, field_ty_scalar.valid_range.end) { - (0, _) => unreachable!("Non-null optimisation extended to a non-zero value."), + (0, x) if x == field_ty_scalar.value.size(&cx.tcx).unsigned_int_max() - 1 => { + return Some(get_nullable_type(cx, field_ty).unwrap()); + } (1, _) => { return Some(get_nullable_type(cx, field_ty).unwrap()); } diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index deef8037259..632164b897a 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -2537,7 +2537,7 @@ pub enum ConstantKind<'tcx> { impl<'tcx> Constant<'tcx> { pub fn check_static_ptr(&self, tcx: TyCtxt<'_>) -> Option<DefId> { - match self.literal.const_for_ty()?.val().try_to_scalar() { + match self.literal.try_to_scalar() { Some(Scalar::Ptr(ptr, _size)) => match tcx.global_alloc(ptr.provenance) { GlobalAlloc::Static(def_id) => { assert!(!tcx.is_thread_local_static(def_id)); diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index dab1da78d4c..50d9c8e98b9 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -18,9 +18,8 @@ use rustc_middle::mir::interpret::{ use rustc_middle::mir::visit::Visitor; use rustc_middle::mir::MirSource; use rustc_middle::mir::*; -use rustc_middle::ty::{self, TyCtxt, TypeFoldable, TypeVisitor}; +use rustc_middle::ty::{self, TyCtxt}; use rustc_target::abi::Size; -use std::ops::ControlFlow; const INDENT: &str = " "; /// Alignment for lining up comments following MIR statements @@ -672,16 +671,27 @@ pub fn write_allocations<'tcx>( } } struct CollectAllocIds(BTreeSet<AllocId>); - impl<'tcx> TypeVisitor<'tcx> for CollectAllocIds { - fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> { + + impl<'tcx> Visitor<'tcx> for CollectAllocIds { + fn visit_const(&mut self, c: ty::Const<'tcx>, _loc: Location) { if let ty::ConstKind::Value(val) = c.val() { self.0.extend(alloc_ids_from_const(val)); } - c.super_visit_with(self) + } + + fn visit_constant(&mut self, c: &Constant<'tcx>, loc: Location) { + match c.literal { + ConstantKind::Ty(c) => self.visit_const(c, loc), + ConstantKind::Val(val, _) => { + self.0.extend(alloc_ids_from_const(val)); + } + } } } + let mut visitor = CollectAllocIds(Default::default()); - body.visit_with(&mut visitor); + visitor.visit_body(body); + // `seen` contains all seen allocations, including the ones we have *not* printed yet. // The protocol is to first `insert` into `seen`, and only if that returns `true` // then push to `todo`. diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index 40dce281c82..04bc0c8b521 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -17,6 +17,7 @@ use rustc_index::newtype_index; use rustc_index::vec::IndexVec; use rustc_middle::infer::canonical::Canonical; use rustc_middle::middle::region; +use rustc_middle::mir::interpret::AllocId; use rustc_middle::mir::{ BinOp, BorrowKind, FakeReadCause, Field, Mutability, UnOp, UserTypeProjection, }; @@ -419,7 +420,8 @@ pub enum ExprKind<'tcx> { /// This is only distinguished from `Literal` so that we can register some /// info for diagnostics. StaticRef { - literal: Const<'tcx>, + alloc_id: AllocId, + ty: Ty<'tcx>, def_id: DefId, }, /// Inline assembly, i.e. `asm!()`. diff --git a/compiler/rustc_middle/src/thir/visit.rs b/compiler/rustc_middle/src/thir/visit.rs index 95489ac3ab2..1c472f38184 100644 --- a/compiler/rustc_middle/src/thir/visit.rs +++ b/compiler/rustc_middle/src/thir/visit.rs @@ -123,7 +123,7 @@ pub fn walk_expr<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, expr: &Exp } Closure { closure_id: _, substs: _, upvars: _, movability: _, fake_reads: _ } => {} Literal { literal, user_ty: _, const_id: _ } => visitor.visit_const(literal), - StaticRef { literal, def_id: _ } => visitor.visit_const(literal), + StaticRef { alloc_id: _, ty: _, def_id: _ } => {} InlineAsm { ref operands, template: _, options: _, line_spans: _ } => { for op in &**operands { use InlineAsmOperand::*; diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index a1e906140e0..8b0e7794f92 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -977,7 +977,6 @@ impl<'tcx> TraitRef<'tcx> { substs: SubstsRef<'tcx>, ) -> ty::TraitRef<'tcx> { let defs = tcx.generics_of(trait_id); - ty::TraitRef { def_id: trait_id, substs: tcx.intern_substs(&substs[..defs.params.len()]) } } } diff --git a/compiler/rustc_mir_build/src/build/expr/as_constant.rs b/compiler/rustc_mir_build/src/build/expr/as_constant.rs index 79ac09d523d..0c0b0f2bd05 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_constant.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_constant.rs @@ -1,6 +1,7 @@ //! See docs in build/expr/mod.rs use crate::build::Builder; +use rustc_middle::mir::interpret::{ConstValue, Scalar}; use rustc_middle::mir::*; use rustc_middle::thir::*; use rustc_middle::ty::CanonicalUserTypeAnnotation; @@ -26,8 +27,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { assert_eq!(literal.ty(), ty); Constant { span, user_ty, literal: literal.into() } } - ExprKind::StaticRef { literal, .. } => { - Constant { span, user_ty: None, literal: literal.into() } + ExprKind::StaticRef { alloc_id, ty, .. } => { + let const_val = + ConstValue::Scalar(Scalar::from_pointer(alloc_id.into(), &this.tcx)); + let literal = ConstantKind::Val(const_val, ty); + + Constant { span, user_ty: None, literal } } ExprKind::ConstBlock { value } => { Constant { span: span, user_ty: None, literal: value.into() } diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index 651edc827c3..5a7e1d88dd0 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -8,7 +8,6 @@ use rustc_middle::hir::place::Place as HirPlace; use rustc_middle::hir::place::PlaceBase as HirPlaceBase; use rustc_middle::hir::place::ProjectionKind as HirProjectionKind; use rustc_middle::middle::region; -use rustc_middle::mir::interpret::Scalar; use rustc_middle::mir::{BinOp, BorrowKind, Field, UnOp}; use rustc_middle::thir::*; use rustc_middle::ty::adjustment::{ @@ -941,15 +940,8 @@ impl<'tcx> Cx<'tcx> { let kind = if self.tcx.is_thread_local_static(id) { ExprKind::ThreadLocalRef(id) } else { - let ptr = self.tcx.create_static_alloc(id); - ExprKind::StaticRef { - literal: ty::Const::from_scalar( - self.tcx, - Scalar::from_pointer(ptr.into(), &self.tcx), - ty, - ), - def_id: id, - } + let alloc_id = self.tcx.create_static_alloc(id); + ExprKind::StaticRef { alloc_id, ty, def_id: id } }; ExprKind::Deref { arg: self.thir.exprs.push(Expr { ty, temp_lifetime, span: expr.span, kind }), diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index 27a6b5beb62..b80d2e52ee7 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -20,7 +20,7 @@ use rustc_session::lint::builtin::{ }; use rustc_session::Session; use rustc_span::source_map::Spanned; -use rustc_span::{DesugaringKind, ExpnKind, Span}; +use rustc_span::{DesugaringKind, ExpnKind, MultiSpan, Span}; crate fn check_match(tcx: TyCtxt<'_>, def_id: DefId) { let body_id = match def_id.as_local() { @@ -64,7 +64,9 @@ impl<'tcx> Visitor<'tcx> for MatchVisitor<'_, '_, 'tcx> { fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) { intravisit::walk_expr(self, ex); match &ex.kind { - hir::ExprKind::Match(scrut, arms, source) => self.check_match(scrut, arms, *source), + hir::ExprKind::Match(scrut, arms, source) => { + self.check_match(scrut, arms, *source, ex.span) + } hir::ExprKind::Let(hir::Let { pat, init, span, .. }) => { self.check_let(pat, init, *span) } @@ -163,6 +165,7 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> { scrut: &hir::Expr<'_>, hir_arms: &'tcx [hir::Arm<'tcx>], source: hir::MatchSource, + expr_span: Span, ) { let mut cx = self.new_cx(scrut.hir_id); @@ -208,7 +211,6 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> { } // Check if the match is exhaustive. - let is_empty_match = arms.is_empty(); let witnesses = report.non_exhaustiveness_witnesses; if !witnesses.is_empty() { if source == hir::MatchSource::ForLoopDesugar && hir_arms.len() == 2 { @@ -216,7 +218,7 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> { let pat = hir_arms[1].pat.for_loop_some().unwrap(); self.check_irrefutable(pat, "`for` loop binding", None); } else { - non_exhaustive_match(&cx, scrut_ty, scrut.span, witnesses, is_empty_match); + non_exhaustive_match(&cx, scrut_ty, scrut.span, witnesses, hir_arms, expr_span); } } } @@ -334,7 +336,7 @@ fn check_for_bindings_named_same_as_variants( let ty_path = cx.tcx.def_path_str(edef.did); let mut err = lint.build(&format!( "pattern binding `{}` is named the same as one \ - of the variants of the type `{}`", + of the variants of the type `{}`", ident, ty_path )); err.code(error_code!(E0170)); @@ -494,8 +496,10 @@ fn non_exhaustive_match<'p, 'tcx>( scrut_ty: Ty<'tcx>, sp: Span, witnesses: Vec<DeconstructedPat<'p, 'tcx>>, - is_empty_match: bool, + arms: &[hir::Arm<'tcx>], + expr_span: Span, ) { + let is_empty_match = arms.is_empty(); let non_empty_enum = match scrut_ty.kind() { ty::Adt(def, _) => def.is_enum() && !def.variants.is_empty(), _ => false, @@ -503,12 +507,15 @@ fn non_exhaustive_match<'p, 'tcx>( // In the case of an empty match, replace the '`_` not covered' diagnostic with something more // informative. let mut err; + let pattern; + let mut patterns_len = 0; if is_empty_match && !non_empty_enum { err = create_e0004( cx.tcx.sess, sp, format!("non-exhaustive patterns: type `{}` is non-empty", scrut_ty), ); + pattern = "_".to_string(); } else { let joined_patterns = joined_uncovered_patterns(cx, &witnesses); err = create_e0004( @@ -517,6 +524,16 @@ fn non_exhaustive_match<'p, 'tcx>( format!("non-exhaustive patterns: {} not covered", joined_patterns), ); err.span_label(sp, pattern_not_covered_label(&witnesses, &joined_patterns)); + patterns_len = witnesses.len(); + pattern = if witnesses.len() < 4 { + witnesses + .iter() + .map(|witness| witness.to_pat(cx).to_string()) + .collect::<Vec<String>>() + .join(" | ") + } else { + "_".to_string() + }; }; let is_variant_list_non_exhaustive = match scrut_ty.kind() { @@ -525,10 +542,6 @@ fn non_exhaustive_match<'p, 'tcx>( }; adt_defined_here(cx, &mut err, scrut_ty, &witnesses); - err.help( - "ensure that all possible cases are being handled, \ - possibly by adding wildcards or more match arms", - ); err.note(&format!( "the matched value is of type `{}`{}", scrut_ty, @@ -540,14 +553,14 @@ fn non_exhaustive_match<'p, 'tcx>( && matches!(witnesses[0].ctor(), Constructor::NonExhaustive) { err.note(&format!( - "`{}` does not have a fixed maximum value, \ - so a wildcard `_` is necessary to match exhaustively", + "`{}` does not have a fixed maximum value, so a wildcard `_` is necessary to match \ + exhaustively", scrut_ty, )); if cx.tcx.sess.is_nightly_build() { err.help(&format!( - "add `#![feature(precise_pointer_size_matching)]` \ - to the crate attributes to enable precise `{}` matching", + "add `#![feature(precise_pointer_size_matching)]` to the crate attributes to \ + enable precise `{}` matching", scrut_ty, )); } @@ -557,6 +570,84 @@ fn non_exhaustive_match<'p, 'tcx>( err.note("references are always considered inhabited"); } } + + let mut suggestion = None; + let sm = cx.tcx.sess.source_map(); + match arms { + [] if sp.ctxt() == expr_span.ctxt() => { + // Get the span for the empty match body `{}`. + let (indentation, more) = if let Some(snippet) = sm.indentation_before(sp) { + (format!("\n{}", snippet), " ") + } else { + (" ".to_string(), "") + }; + suggestion = Some(( + sp.shrink_to_hi().with_hi(expr_span.hi()), + format!( + " {{{indentation}{more}{pattern} => todo!(),{indentation}}}", + indentation = indentation, + more = more, + pattern = pattern, + ), + )); + } + [only] => { + let pre_indentation = if let (Some(snippet), true) = ( + sm.indentation_before(only.span), + sm.is_multiline(sp.shrink_to_hi().with_hi(only.span.lo())), + ) { + format!("\n{}", snippet) + } else { + " ".to_string() + }; + let comma = if matches!(only.body.kind, hir::ExprKind::Block(..)) { "" } else { "," }; + suggestion = Some(( + only.span.shrink_to_hi(), + format!("{}{}{} => todo!()", comma, pre_indentation, pattern), + )); + } + [.., prev, last] if prev.span.ctxt() == last.span.ctxt() => { + if let Ok(snippet) = sm.span_to_snippet(prev.span.between(last.span)) { + let comma = + if matches!(last.body.kind, hir::ExprKind::Block(..)) { "" } else { "," }; + suggestion = Some(( + last.span.shrink_to_hi(), + format!( + "{}{}{} => todo!()", + comma, + snippet.strip_prefix(",").unwrap_or(&snippet), + pattern + ), + )); + } + } + _ => {} + } + + let msg = format!( + "ensure that all possible cases are being handled by adding a match arm with a wildcard \ + pattern{}{}", + if patterns_len > 1 && patterns_len < 4 && suggestion.is_some() { + ", a match arm with multiple or-patterns" + } else { + // we are either not suggesting anything, or suggesting `_` + "" + }, + match patterns_len { + // non-exhaustive enum case + 0 if suggestion.is_some() => " as shown", + 0 => "", + 1 if suggestion.is_some() => " or an explicit pattern as shown", + 1 => " or an explicit pattern", + _ if suggestion.is_some() => " as shown, or multiple match arms", + _ => " or multiple match arms", + }, + ); + if let Some((span, sugg)) = suggestion { + err.span_suggestion_verbose(span, &msg, sugg, Applicability::HasPlaceholders); + } else { + err.help(&msg); + } err.emit(); } @@ -597,15 +688,27 @@ fn adt_defined_here<'p, 'tcx>( ) { let ty = ty.peel_refs(); if let ty::Adt(def, _) = ty.kind() { - if let Some(sp) = cx.tcx.hir().span_if_local(def.did) { - err.span_label(sp, format!("`{}` defined here", ty)); - } - - if witnesses.len() < 4 { + let mut spans = vec![]; + if witnesses.len() < 5 { for sp in maybe_point_at_variant(cx, def, witnesses.iter()) { - err.span_label(sp, "not covered"); + spans.push(sp); } } + let def_span = cx + .tcx + .hir() + .get_if_local(def.did) + .and_then(|node| node.ident()) + .map(|ident| ident.span) + .unwrap_or_else(|| cx.tcx.def_span(def.did)); + let mut span: MultiSpan = + if spans.is_empty() { def_span.into() } else { spans.clone().into() }; + + span.push_span_label(def_span, String::new()); + for pat in spans { + span.push_span_label(pat, "not covered".to_string()); + } + err.span_note(span, &format!("`{}` defined here", ty)); } } diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index df865d77b9b..b993d48c995 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -20,7 +20,6 @@ use rustc_ast_pretty::pprust; use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, PResult}; use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP; use rustc_session::lint::BuiltinLintDiagnostics; -use rustc_span::edition::LATEST_STABLE_EDITION; use rustc_span::source_map::{self, Span, Spanned}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{BytePos, Pos}; @@ -2712,8 +2711,7 @@ impl<'a> Parser<'a> { let mut async_block_err = |e: &mut Diagnostic, span: Span| { recover_async = true; e.span_label(span, "`async` blocks are only allowed in Rust 2018 or later"); - e.help(&format!("set `edition = \"{}\"` in `Cargo.toml`", LATEST_STABLE_EDITION)); - e.note("for more on editions, read https://doc.rust-lang.org/edition-guide"); + e.help_use_latest_edition(); }; while self.token != token::CloseDelim(close_delim) { diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 5db1e4e0523..06460c7b1b3 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -14,7 +14,7 @@ use rustc_ast::{FnHeader, ForeignItem, Path, PathSegment, Visibility, Visibility use rustc_ast::{MacArgs, MacCall, MacDelimiter}; use rustc_ast_pretty::pprust; use rustc_errors::{struct_span_err, Applicability, PResult, StashKey}; -use rustc_span::edition::{Edition, LATEST_STABLE_EDITION}; +use rustc_span::edition::Edition; use rustc_span::lev_distance::lev_distance; use rustc_span::source_map::{self, Span}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; @@ -2102,8 +2102,7 @@ impl<'a> Parser<'a> { let diag = self.diagnostic(); struct_span_err!(diag, span, E0670, "`async fn` is not permitted in Rust 2015") .span_label(span, "to use `async fn`, switch to Rust 2018 or later") - .help(&format!("set `edition = \"{}\"` in `Cargo.toml`", LATEST_STABLE_EDITION)) - .note("for more on editions, read https://doc.rust-lang.org/edition-guide") + .help_use_latest_edition() .emit(); } } diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index d94ad7ba71a..01b12eec628 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -4,7 +4,7 @@ //! conflicts between multiple such attributes attached to the same //! item. -use rustc_ast::{ast, AttrStyle, Attribute, Lit, LitKind, NestedMetaItem}; +use rustc_ast::{ast, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{pluralize, struct_span_err, Applicability}; use rustc_feature::{AttributeDuplicates, AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP}; @@ -178,34 +178,7 @@ impl CheckAttrVisitor<'_> { check_duplicates(self.tcx, attr, hir_id, *duplicates, &mut seen); } - // Warn on useless empty attributes. - if matches!( - attr.name_or_empty(), - sym::macro_use - | sym::allow - | sym::warn - | sym::deny - | sym::forbid - | sym::feature - | sym::repr - | sym::target_feature - ) && attr.meta_item_list().map_or(false, |list| list.is_empty()) - { - self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| { - lint.build("unused attribute") - .span_suggestion( - attr.span, - "remove this attribute", - String::new(), - Applicability::MachineApplicable, - ) - .note(&format!( - "attribute `{}` with an empty list has no effect", - attr.name_or_empty() - )) - .emit(); - }); - } + self.check_unused_attribute(hir_id, attr) } if !is_valid { @@ -1372,7 +1345,7 @@ impl CheckAttrVisitor<'_> { target: Target, item: Option<ItemLike<'_>>, ) -> bool { - let is_function = matches!(target, Target::Fn | Target::Method(..)); + let is_function = matches!(target, Target::Fn); if !is_function { self.tcx .sess @@ -1969,6 +1942,55 @@ impl CheckAttrVisitor<'_> { }); } } + + fn check_unused_attribute(&self, hir_id: HirId, attr: &Attribute) { + // Warn on useless empty attributes. + let note = if matches!( + attr.name_or_empty(), + sym::macro_use + | sym::allow + | sym::expect + | sym::warn + | sym::deny + | sym::forbid + | sym::feature + | sym::repr + | sym::target_feature + ) && attr.meta_item_list().map_or(false, |list| list.is_empty()) + { + format!( + "attribute `{}` with an empty list has no effect", + attr.name_or_empty() + ) + } else if matches!( + attr.name_or_empty(), + sym::allow | sym::warn | sym::deny | sym::forbid | sym::expect + ) && let Some(meta) = attr.meta_item_list() + && meta.len() == 1 + && let Some(item) = meta[0].meta_item() + && let MetaItemKind::NameValue(_) = &item.kind + && item.path == sym::reason + { + format!( + "attribute `{}` without any lints has no effect", + attr.name_or_empty() + ) + } else { + return; + }; + + self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| { + lint.build("unused attribute") + .span_suggestion( + attr.span, + "remove this attribute", + String::new(), + Applicability::MachineApplicable, + ) + .note(¬e) + .emit(); + }); + } } impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> { diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs index a277f74f7a4..6dfbdace8e2 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs @@ -4,7 +4,7 @@ use super::{ use crate::infer::InferCtxt; use rustc_hir as hir; use rustc_hir::def_id::DefId; -use rustc_middle::ty::subst::Subst; +use rustc_middle::ty::subst::{Subst, SubstsRef}; use rustc_middle::ty::{self, GenericParamDefKind}; use rustc_span::symbol::sym; use std::iter; @@ -17,7 +17,7 @@ crate trait InferCtxtExt<'tcx> { &self, trait_ref: ty::PolyTraitRef<'tcx>, obligation: &PredicateObligation<'tcx>, - ) -> Option<DefId>; + ) -> Option<(DefId, SubstsRef<'tcx>)>; /*private*/ fn describe_enclosure(&self, hir_id: hir::HirId) -> Option<&'static str>; @@ -34,7 +34,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { &self, trait_ref: ty::PolyTraitRef<'tcx>, obligation: &PredicateObligation<'tcx>, - ) -> Option<DefId> { + ) -> Option<(DefId, SubstsRef<'tcx>)> { let tcx = self.tcx; let param_env = obligation.param_env; let trait_ref = tcx.erase_late_bound_regions(trait_ref); @@ -50,7 +50,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { let impl_self_ty = impl_trait_ref.self_ty(); if let Ok(..) = self.can_eq(param_env, trait_self_ty, impl_self_ty) { - self_match_impls.push(def_id); + self_match_impls.push((def_id, impl_substs)); if iter::zip( trait_ref.substs.types().skip(1), @@ -58,12 +58,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { ) .all(|(u, v)| self.fuzzy_match_tys(u, v, false).is_some()) { - fuzzy_match_impls.push(def_id); + fuzzy_match_impls.push((def_id, impl_substs)); } } }); - let impl_def_id = if self_match_impls.len() == 1 { + let impl_def_id_and_substs = if self_match_impls.len() == 1 { self_match_impls[0] } else if fuzzy_match_impls.len() == 1 { fuzzy_match_impls[0] @@ -71,7 +71,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { return None; }; - tcx.has_attr(impl_def_id, sym::rustc_on_unimplemented).then_some(impl_def_id) + tcx.has_attr(impl_def_id_and_substs.0, sym::rustc_on_unimplemented) + .then_some(impl_def_id_and_substs) } /// Used to set on_unimplemented's `ItemContext` @@ -120,8 +121,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { trait_ref: ty::PolyTraitRef<'tcx>, obligation: &PredicateObligation<'tcx>, ) -> OnUnimplementedNote { - let def_id = - self.impl_similar_to(trait_ref, obligation).unwrap_or_else(|| trait_ref.def_id()); + let (def_id, substs) = self + .impl_similar_to(trait_ref, obligation) + .unwrap_or_else(|| (trait_ref.def_id(), trait_ref.skip_binder().substs)); let trait_ref = trait_ref.skip_binder(); let mut flags = vec![( @@ -176,7 +178,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { for param in generics.params.iter() { let value = match param.kind { GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { - trait_ref.substs[param.index as usize].to_string() + substs[param.index as usize].to_string() } GenericParamDefKind::Lifetime => continue, }; @@ -184,7 +186,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { flags.push((name, Some(value))); if let GenericParamDefKind::Type { .. } = param.kind { - let param_ty = trait_ref.substs[param.index as usize].expect_ty(); + let param_ty = substs[param.index as usize].expect_ty(); if let Some(def) = param_ty.ty_adt_def() { // We also want to be able to select the parameter's // original signature with no type arguments resolved @@ -229,9 +231,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { } }); - if let Ok(Some(command)) = - OnUnimplementedDirective::of_item(self.tcx, trait_ref.def_id, def_id) - { + if let Ok(Some(command)) = OnUnimplementedDirective::of_item(self.tcx, def_id) { command.evaluate(self.tcx, trait_ref, &flags) } else { OnUnimplementedNote::default() diff --git a/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs index 9752ff45323..2f697c1fa27 100644 --- a/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs @@ -54,7 +54,7 @@ fn parse_error( impl<'tcx> OnUnimplementedDirective { fn parse( tcx: TyCtxt<'tcx>, - trait_def_id: DefId, + item_def_id: DefId, items: &[NestedMetaItem], span: Span, is_root: bool, @@ -63,7 +63,7 @@ impl<'tcx> OnUnimplementedDirective { let mut item_iter = items.iter(); let parse_value = |value_str| { - OnUnimplementedFormatString::try_parse(tcx, trait_def_id, value_str, span).map(Some) + OnUnimplementedFormatString::try_parse(tcx, item_def_id, value_str, span).map(Some) }; let condition = if is_root { @@ -135,7 +135,7 @@ impl<'tcx> OnUnimplementedDirective { { if let Some(items) = item.meta_item_list() { if let Ok(subcommand) = - Self::parse(tcx, trait_def_id, &items, item.span(), false) + Self::parse(tcx, item_def_id, &items, item.span(), false) { subcommands.push(subcommand); } else { @@ -178,19 +178,15 @@ impl<'tcx> OnUnimplementedDirective { } } - pub fn of_item( - tcx: TyCtxt<'tcx>, - trait_def_id: DefId, - impl_def_id: DefId, - ) -> Result<Option<Self>, ErrorGuaranteed> { - let attrs = tcx.get_attrs(impl_def_id); + pub fn of_item(tcx: TyCtxt<'tcx>, item_def_id: DefId) -> Result<Option<Self>, ErrorGuaranteed> { + let attrs = tcx.get_attrs(item_def_id); let Some(attr) = tcx.sess.find_by_name(&attrs, sym::rustc_on_unimplemented) else { return Ok(None); }; let result = if let Some(items) = attr.meta_item_list() { - Self::parse(tcx, trait_def_id, &items, attr.span, true).map(Some) + Self::parse(tcx, item_def_id, &items, attr.span, true).map(Some) } else if let Some(value) = attr.value_str() { Ok(Some(OnUnimplementedDirective { condition: None, @@ -198,7 +194,7 @@ impl<'tcx> OnUnimplementedDirective { subcommands: vec![], label: Some(OnUnimplementedFormatString::try_parse( tcx, - trait_def_id, + item_def_id, value, attr.span, )?), @@ -209,7 +205,7 @@ impl<'tcx> OnUnimplementedDirective { } else { return Err(ErrorGuaranteed); }; - debug!("of_item({:?}/{:?}) = {:?}", trait_def_id, impl_def_id, result); + debug!("of_item({:?}) = {:?}", item_def_id, result); result } @@ -280,23 +276,29 @@ impl<'tcx> OnUnimplementedDirective { impl<'tcx> OnUnimplementedFormatString { fn try_parse( tcx: TyCtxt<'tcx>, - trait_def_id: DefId, + item_def_id: DefId, from: Symbol, err_sp: Span, ) -> Result<Self, ErrorGuaranteed> { let result = OnUnimplementedFormatString(from); - result.verify(tcx, trait_def_id, err_sp)?; + result.verify(tcx, item_def_id, err_sp)?; Ok(result) } fn verify( &self, tcx: TyCtxt<'tcx>, - trait_def_id: DefId, + item_def_id: DefId, span: Span, ) -> Result<(), ErrorGuaranteed> { - let name = tcx.item_name(trait_def_id); - let generics = tcx.generics_of(trait_def_id); + let trait_def_id = if tcx.is_trait(item_def_id) { + item_def_id + } else { + tcx.trait_id_of_impl(item_def_id) + .expect("expected `on_unimplemented` to correspond to a trait") + }; + let trait_name = tcx.item_name(trait_def_id); + let generics = tcx.generics_of(item_def_id); let s = self.0.as_str(); let parser = Parser::new(s, None, None, false, ParseMode::Format); let mut result = Ok(()); @@ -307,7 +309,7 @@ impl<'tcx> OnUnimplementedFormatString { // `{Self}` is allowed Position::ArgumentNamed(s, _) if s == kw::SelfUpper => (), // `{ThisTraitsName}` is allowed - Position::ArgumentNamed(s, _) if s == name => (), + Position::ArgumentNamed(s, _) if s == trait_name => (), // `{from_method}` is allowed Position::ArgumentNamed(s, _) if s == sym::from_method => (), // `{from_desugaring}` is allowed @@ -329,9 +331,13 @@ impl<'tcx> OnUnimplementedFormatString { tcx.sess, span, E0230, - "there is no parameter `{}` on trait `{}`", + "there is no parameter `{}` on {}", s, - name + if trait_def_id == item_def_id { + format!("trait `{}`", trait_name) + } else { + "impl".to_string() + } ) .emit(); result = Err(ErrorGuaranteed); diff --git a/compiler/rustc_typeck/src/check/check.rs b/compiler/rustc_typeck/src/check/check.rs index 765b752691f..7c3594175b8 100644 --- a/compiler/rustc_typeck/src/check/check.rs +++ b/compiler/rustc_typeck/src/check/check.rs @@ -742,12 +742,11 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) { impl_trait_ref, &impl_.items, ); - let trait_def_id = impl_trait_ref.def_id; - check_on_unimplemented(tcx, trait_def_id, it); + check_on_unimplemented(tcx, it); } } hir::ItemKind::Trait(_, _, _, _, ref items) => { - check_on_unimplemented(tcx, it.def_id.to_def_id(), it); + check_on_unimplemented(tcx, it); for item in items.iter() { let item = tcx.hir().trait_item(item.id); @@ -857,9 +856,9 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) { } } -pub(super) fn check_on_unimplemented(tcx: TyCtxt<'_>, trait_def_id: DefId, item: &hir::Item<'_>) { +pub(super) fn check_on_unimplemented(tcx: TyCtxt<'_>, item: &hir::Item<'_>) { // an error would be reported if this fails. - let _ = traits::OnUnimplementedDirective::of_item(tcx, trait_def_id, item.def_id.to_def_id()); + let _ = traits::OnUnimplementedDirective::of_item(tcx, item.def_id.to_def_id()); } pub(super) fn check_specialization_validity<'tcx>( diff --git a/compiler/rustc_typeck/src/check/expr.rs b/compiler/rustc_typeck/src/check/expr.rs index 8e245beaa3d..7e7104f62fd 100644 --- a/compiler/rustc_typeck/src/check/expr.rs +++ b/compiler/rustc_typeck/src/check/expr.rs @@ -43,7 +43,6 @@ use rustc_middle::ty::error::TypeError::{FieldMisMatch, Sorts}; use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::{self, AdtKind, Ty, TypeFoldable}; use rustc_session::parse::feature_err; -use rustc_span::edition::LATEST_STABLE_EDITION; use rustc_span::hygiene::DesugaringKind; use rustc_span::lev_distance::find_best_match_for_name; use rustc_span::source_map::Span; @@ -2010,8 +2009,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // We know by construction that `<expr>.await` is either on Rust 2015 // or results in `ExprKind::Await`. Suggest switching the edition to 2018. err.note("to `.await` a `Future`, switch to Rust 2018 or later"); - err.help(&format!("set `edition = \"{}\"` in `Cargo.toml`", LATEST_STABLE_EDITION)); - err.note("for more on editions, read https://doc.rust-lang.org/edition-guide"); + err.help_use_latest_edition(); } err.emit(); diff --git a/library/alloc/src/collections/btree/map/entry.rs b/library/alloc/src/collections/btree/map/entry.rs index 5cef007a46f..66608d09082 100644 --- a/library/alloc/src/collections/btree/map/entry.rs +++ b/library/alloc/src/collections/btree/map/entry.rs @@ -3,7 +3,7 @@ use core::marker::PhantomData; use core::mem; use super::super::borrow::DormantMutRef; -use super::super::node::{marker, Handle, InsertResult::*, NodeRef}; +use super::super::node::{marker, Handle, NodeRef}; use super::BTreeMap; use Entry::*; @@ -313,13 +313,13 @@ impl<'a, K: Ord, V> VacantEntry<'a, K, V> { #[stable(feature = "rust1", since = "1.0.0")] pub fn insert(self, value: V) -> &'a mut V { let out_ptr = match self.handle.insert_recursing(self.key, value) { - (Fit(_), val_ptr) => { + (None, val_ptr) => { // SAFETY: We have consumed self.handle and the handle returned. let map = unsafe { self.dormant_map.awaken() }; map.length += 1; val_ptr } - (Split(ins), val_ptr) => { + (Some(ins), val_ptr) => { drop(ins.left); // SAFETY: We have consumed self.handle and the reference returned. let map = unsafe { self.dormant_map.awaken() }; diff --git a/library/alloc/src/collections/btree/node.rs b/library/alloc/src/collections/btree/node.rs index dfce98f97bd..44f5bc850b8 100644 --- a/library/alloc/src/collections/btree/node.rs +++ b/library/alloc/src/collections/btree/node.rs @@ -861,11 +861,10 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, mark /// this edge. This method splits the node if there isn't enough room. /// /// The returned pointer points to the inserted value. - fn insert(mut self, key: K, val: V) -> (InsertResult<'a, K, V, marker::Leaf>, *mut V) { + fn insert(mut self, key: K, val: V) -> (Option<SplitResult<'a, K, V, marker::Leaf>>, *mut V) { if self.node.len() < CAPACITY { let val_ptr = self.insert_fit(key, val); - let kv = unsafe { Handle::new_kv(self.node, self.idx) }; - (InsertResult::Fit(kv), val_ptr) + (None, val_ptr) } else { let (middle_kv_idx, insertion) = splitpoint(self.idx); let middle = unsafe { Handle::new_kv(self.node, middle_kv_idx) }; @@ -879,7 +878,7 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, mark }, }; let val_ptr = insertion_edge.insert_fit(key, val); - (InsertResult::Split(result), val_ptr) + (Some(result), val_ptr) } } } @@ -923,13 +922,12 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>, key: K, val: V, edge: Root<K, V>, - ) -> InsertResult<'a, K, V, marker::Internal> { + ) -> Option<SplitResult<'a, K, V, marker::Internal>> { assert!(edge.height == self.node.height - 1); if self.node.len() < CAPACITY { self.insert_fit(key, val, edge); - let kv = unsafe { Handle::new_kv(self.node, self.idx) }; - InsertResult::Fit(kv) + None } else { let (middle_kv_idx, insertion) = splitpoint(self.idx); let middle = unsafe { Handle::new_kv(self.node, middle_kv_idx) }; @@ -943,7 +941,7 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>, }, }; insertion_edge.insert_fit(key, val, edge); - InsertResult::Split(result) + Some(result) } } } @@ -953,32 +951,26 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, mark /// this edge. This method splits the node if there isn't enough room, and tries to /// insert the split off portion into the parent node recursively, until the root is reached. /// - /// If the returned result is a `Fit`, its handle's node can be this edge's node or an ancestor. - /// If the returned result is a `Split`, the `left` field will be the root node. - /// The returned pointer points to the inserted value. + /// If the returned result is some `SplitResult`, the `left` field will be the root node. + /// The returned pointer points to the inserted value, which in the case of `SplitResult` + /// is in the `left` or `right` tree. pub fn insert_recursing( self, key: K, value: V, - ) -> (InsertResult<'a, K, V, marker::LeafOrInternal>, *mut V) { + ) -> (Option<SplitResult<'a, K, V, marker::LeafOrInternal>>, *mut V) { let (mut split, val_ptr) = match self.insert(key, value) { - (InsertResult::Fit(handle), ptr) => { - return (InsertResult::Fit(handle.forget_node_type()), ptr); - } - (InsertResult::Split(split), val_ptr) => (split.forget_node_type(), val_ptr), + (None, val_ptr) => return (None, val_ptr), + (Some(split), val_ptr) => (split.forget_node_type(), val_ptr), }; loop { split = match split.left.ascend() { Ok(parent) => match parent.insert(split.kv.0, split.kv.1, split.right) { - InsertResult::Fit(handle) => { - return (InsertResult::Fit(handle.forget_node_type()), val_ptr); - } - InsertResult::Split(split) => split.forget_node_type(), + None => return (None, val_ptr), + Some(split) => split.forget_node_type(), }, - Err(root) => { - return (InsertResult::Split(SplitResult { left: root, ..split }), val_ptr); - } + Err(root) => return (Some(SplitResult { left: root, ..split }), val_ptr), }; } } @@ -1529,14 +1521,6 @@ impl<BorrowType, K, V> Handle<NodeRef<BorrowType, K, V, marker::Leaf>, marker::K } } -impl<BorrowType, K, V> Handle<NodeRef<BorrowType, K, V, marker::Internal>, marker::KV> { - pub fn forget_node_type( - self, - ) -> Handle<NodeRef<BorrowType, K, V, marker::LeafOrInternal>, marker::KV> { - unsafe { Handle::new_kv(self.node.forget_type(), self.idx) } - } -} - impl<BorrowType, K, V, Type> Handle<NodeRef<BorrowType, K, V, marker::LeafOrInternal>, Type> { /// Checks whether the underlying node is an `Internal` node or a `Leaf` node. pub fn force( @@ -1621,7 +1605,7 @@ pub enum ForceResult<Leaf, Internal> { pub struct SplitResult<'a, K, V, NodeType> { // Altered node in existing tree with elements and edges that belong to the left of `kv`. pub left: NodeRef<marker::Mut<'a>, K, V, NodeType>, - // Some key and value split off, to be inserted elsewhere. + // Some key and value that existed before and were split off, to be inserted elsewhere. pub kv: (K, V), // Owned, unattached, new node with elements and edges that belong to the right of `kv`. pub right: NodeRef<marker::Owned, K, V, NodeType>, @@ -1639,11 +1623,6 @@ impl<'a, K, V> SplitResult<'a, K, V, marker::Internal> { } } -pub enum InsertResult<'a, K, V, NodeType> { - Fit(Handle<NodeRef<marker::Mut<'a>, K, V, NodeType>, marker::KV>), - Split(SplitResult<'a, K, V, NodeType>), -} - pub mod marker { use core::marker::PhantomData; diff --git a/library/core/src/hint.rs b/library/core/src/hint.rs index 330c43d2948..58ea109c735 100644 --- a/library/core/src/hint.rs +++ b/library/core/src/hint.rs @@ -173,3 +173,126 @@ pub fn spin_loop() { pub const fn black_box<T>(dummy: T) -> T { crate::intrinsics::black_box(dummy) } + +/// An identity function that causes an `unused_must_use` warning to be +/// triggered if the given value is not used (returned, stored in a variable, +/// etc) by the caller. +/// +/// This is primarily intended for use in macro-generated code, in which a +/// [`#[must_use]` attribute][must_use] either on a type or a function would not +/// be convenient. +/// +/// [must_use]: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute +/// +/// # Example +/// +/// ``` +/// #![feature(hint_must_use)] +/// +/// use core::fmt; +/// +/// pub struct Error(/* ... */); +/// +/// #[macro_export] +/// macro_rules! make_error { +/// ($($args:expr),*) => { +/// core::hint::must_use({ +/// let error = $crate::make_error(core::format_args!($($args),*)); +/// error +/// }) +/// }; +/// } +/// +/// // Implementation detail of make_error! macro. +/// #[doc(hidden)] +/// pub fn make_error(args: fmt::Arguments<'_>) -> Error { +/// Error(/* ... */) +/// } +/// +/// fn demo() -> Option<Error> { +/// if true { +/// // Oops, meant to write `return Some(make_error!("..."));` +/// Some(make_error!("...")); +/// } +/// None +/// } +/// # +/// # // Make rustdoc not wrap the whole snippet in fn main, so that $crate::make_error works +/// # fn main() {} +/// ``` +/// +/// In the above example, we'd like an `unused_must_use` lint to apply to the +/// value created by `make_error!`. However, neither `#[must_use]` on a struct +/// nor `#[must_use]` on a function is appropriate here, so the macro expands +/// using `core::hint::must_use` instead. +/// +/// - We wouldn't want `#[must_use]` on the `struct Error` because that would +/// make the following unproblematic code trigger a warning: +/// +/// ``` +/// # struct Error; +/// # +/// fn f(arg: &str) -> Result<(), Error> +/// # { Ok(()) } +/// +/// #[test] +/// fn t() { +/// // Assert that `f` returns error if passed an empty string. +/// // A value of type `Error` is unused here but that's not a problem. +/// f("").unwrap_err(); +/// } +/// ``` +/// +/// - Using `#[must_use]` on `fn make_error` can't help because the return value +/// *is* used, as the right-hand side of a `let` statement. The `let` +/// statement looks useless but is in fact necessary for ensuring that +/// temporaries within the `format_args` expansion are not kept alive past the +/// creation of the `Error`, as keeping them alive past that point can cause +/// autotrait issues in async code: +/// +/// ``` +/// # #![feature(hint_must_use)] +/// # +/// # struct Error; +/// # +/// # macro_rules! make_error { +/// # ($($args:expr),*) => { +/// # core::hint::must_use({ +/// # // If `let` isn't used, then `f()` produces a non-Send future. +/// # let error = make_error(core::format_args!($($args),*)); +/// # error +/// # }) +/// # }; +/// # } +/// # +/// # fn make_error(args: core::fmt::Arguments<'_>) -> Error { +/// # Error +/// # } +/// # +/// async fn f() { +/// // Using `let` inside the make_error expansion causes temporaries like +/// // `unsync()` to drop at the semicolon of that `let` statement, which +/// // is prior to the await point. They would otherwise stay around until +/// // the semicolon on *this* statement, which is after the await point, +/// // and the enclosing Future would not implement Send. +/// log(make_error!("look: {:p}", unsync())).await; +/// } +/// +/// async fn log(error: Error) {/* ... */} +/// +/// // Returns something without a Sync impl. +/// fn unsync() -> *const () { +/// 0 as *const () +/// } +/// # +/// # fn test() { +/// # fn assert_send(_: impl Send) {} +/// # assert_send(f()); +/// # } +/// ``` +#[unstable(feature = "hint_must_use", issue = "94745")] +#[rustc_const_unstable(feature = "hint_must_use", issue = "94745")] +#[must_use] // <-- :) +pub const fn must_use<T>(value: T) -> T { + value +} diff --git a/library/core/src/result.rs b/library/core/src/result.rs index 801e3a0b3a4..1827860a390 100644 --- a/library/core/src/result.rs +++ b/library/core/src/result.rs @@ -632,10 +632,16 @@ impl<T, E> Result<T, E> { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn ok(self) -> Option<T> { + #[rustc_const_unstable(feature = "const_result_drop", issue = "92384")] + pub const fn ok(self) -> Option<T> + where + E: ~const Drop, + { match self { Ok(x) => Some(x), - Err(_) => None, + // FIXME: ~const Drop doesn't quite work right yet + #[allow(unused_variables)] + Err(x) => None, } } @@ -657,9 +663,15 @@ impl<T, E> Result<T, E> { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn err(self) -> Option<E> { + #[rustc_const_unstable(feature = "const_result_drop", issue = "92384")] + pub const fn err(self) -> Option<E> + where + T: ~const Drop, + { match self { - Ok(_) => None, + // FIXME: ~const Drop doesn't quite work right yet + #[allow(unused_variables)] + Ok(x) => None, Err(x) => Some(x), } } @@ -1266,10 +1278,18 @@ impl<T, E> Result<T, E> { /// assert_eq!(x.and(y), Ok("different result type")); /// ``` #[inline] + #[rustc_const_unstable(feature = "const_result_drop", issue = "92384")] #[stable(feature = "rust1", since = "1.0.0")] - pub fn and<U>(self, res: Result<U, E>) -> Result<U, E> { + pub const fn and<U>(self, res: Result<U, E>) -> Result<U, E> + where + T: ~const Drop, + U: ~const Drop, + E: ~const Drop, + { match self { - Ok(_) => res, + // FIXME: ~const Drop doesn't quite work right yet + #[allow(unused_variables)] + Ok(x) => res, Err(e) => Err(e), } } @@ -1343,11 +1363,19 @@ impl<T, E> Result<T, E> { /// assert_eq!(x.or(y), Ok(2)); /// ``` #[inline] + #[rustc_const_unstable(feature = "const_result_drop", issue = "92384")] #[stable(feature = "rust1", since = "1.0.0")] - pub fn or<F>(self, res: Result<T, F>) -> Result<T, F> { + pub const fn or<F>(self, res: Result<T, F>) -> Result<T, F> + where + T: ~const Drop, + E: ~const Drop, + F: ~const Drop, + { match self { Ok(v) => Ok(v), - Err(_) => res, + // FIXME: ~const Drop doesn't quite work right yet + #[allow(unused_variables)] + Err(e) => res, } } @@ -1399,11 +1427,18 @@ impl<T, E> Result<T, E> { /// assert_eq!(x.unwrap_or(default), default); /// ``` #[inline] + #[rustc_const_unstable(feature = "const_result_drop", issue = "92384")] #[stable(feature = "rust1", since = "1.0.0")] - pub fn unwrap_or(self, default: T) -> T { + pub const fn unwrap_or(self, default: T) -> T + where + T: ~const Drop, + E: ~const Drop, + { match self { Ok(t) => t, - Err(_) => default, + // FIXME: ~const Drop doesn't quite work right yet + #[allow(unused_variables)] + Err(e) => default, } } diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 2b8bbe19244..2da04ab2cea 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -352,7 +352,7 @@ impl AtomicBool { /// let a = &*AtomicBool::from_mut_slice(&mut some_bools); /// std::thread::scope(|s| { /// for i in 0..a.len() { - /// s.spawn(move |_| a[i].store(true, Ordering::Relaxed)); + /// s.spawn(move || a[i].store(true, Ordering::Relaxed)); /// } /// }); /// assert_eq!(some_bools, [true; 10]); @@ -984,7 +984,7 @@ impl<T> AtomicPtr<T> { /// let a = &*AtomicPtr::from_mut_slice(&mut some_ptrs); /// std::thread::scope(|s| { /// for i in 0..a.len() { - /// s.spawn(move |_| { + /// s.spawn(move || { /// let name = Box::new(format!("thread{i}")); /// a[i].store(Box::into_raw(name), Ordering::Relaxed); /// }); @@ -1533,7 +1533,7 @@ macro_rules! atomic_int { #[doc = concat!("let a = &*", stringify!($atomic_type), "::from_mut_slice(&mut some_ints);")] /// std::thread::scope(|s| { /// for i in 0..a.len() { - /// s.spawn(move |_| a[i].store(i as _, Ordering::Relaxed)); + /// s.spawn(move || a[i].store(i as _, Ordering::Relaxed)); /// } /// }); /// for (i, n) in some_ints.into_iter().enumerate() { diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 5b02e711aab..c35389d44f9 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -231,6 +231,7 @@ #![feature(assert_matches)] #![feature(associated_type_bounds)] #![feature(async_iterator)] +#![feature(atomic_mut_ptr)] #![feature(bench_black_box)] #![feature(box_syntax)] #![feature(c_unwind)] diff --git a/library/std/src/net/tcp/tests.rs b/library/std/src/net/tcp/tests.rs index c2061c13512..959fe6943f6 100644 --- a/library/std/src/net/tcp/tests.rs +++ b/library/std/src/net/tcp/tests.rs @@ -508,7 +508,6 @@ fn close_readwrite_smoke() { } #[test] -#[cfg(unix)] // test doesn't work on Windows, see #31657 fn close_read_wakes_up() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index 03684608f75..a3e6b081936 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -228,23 +228,54 @@ struct Dir(*mut libc::DIR); unsafe impl Send for Dir {} unsafe impl Sync for Dir {} +#[cfg(any( + target_os = "android", + target_os = "linux", + target_os = "solaris", + target_os = "illumos", + target_os = "fuchsia", + target_os = "redox" +))] pub struct DirEntry { - entry: dirent64, dir: Arc<InnerReadDir>, + entry: dirent64_min, // We need to store an owned copy of the entry name on platforms that use // readdir() (not readdir_r()), because a) struct dirent may use a flexible // array to store the name, b) it lives only until the next readdir() call. - #[cfg(any( - target_os = "android", - target_os = "linux", - target_os = "solaris", - target_os = "illumos", - target_os = "fuchsia", - target_os = "redox" - ))] name: CString, } +// Define a minimal subset of fields we need from `dirent64`, especially since +// we're not using the immediate `d_name` on these targets. Keeping this as an +// `entry` field in `DirEntry` helps reduce the `cfg` boilerplate elsewhere. +#[cfg(any( + target_os = "android", + target_os = "linux", + target_os = "solaris", + target_os = "illumos", + target_os = "fuchsia", + target_os = "redox" +))] +struct dirent64_min { + d_ino: u64, + #[cfg(not(any(target_os = "solaris", target_os = "illumos")))] + d_type: u8, +} + +#[cfg(not(any( + target_os = "android", + target_os = "linux", + target_os = "solaris", + target_os = "illumos", + target_os = "fuchsia", + target_os = "redox" +)))] +pub struct DirEntry { + dir: Arc<InnerReadDir>, + // The full entry includes a fixed-length `d_name`. + entry: dirent64, +} + #[derive(Clone, Debug)] pub struct OpenOptions { // generic @@ -501,8 +532,14 @@ impl Iterator for ReadDir { let entry_name = entry_bytes.add(name_offset); ptr::copy_nonoverlapping(entry_bytes, copy_bytes, name_offset); + let entry = dirent64_min { + d_ino: copy.d_ino as u64, + #[cfg(not(any(target_os = "solaris", target_os = "illumos")))] + d_type: copy.d_type as u8, + }; + let ret = DirEntry { - entry: copy, + entry, // d_name is guaranteed to be null-terminated. name: CStr::from_ptr(entry_name as *const _).to_owned(), dir: Arc::clone(&self.inner), @@ -1604,17 +1641,15 @@ mod remove_dir_impl { } } - fn remove_dir_all_recursive(parent_fd: Option<RawFd>, p: &Path) -> io::Result<()> { - let pcstr = cstr(p)?; - + fn remove_dir_all_recursive(parent_fd: Option<RawFd>, path: &CStr) -> io::Result<()> { // try opening as directory - let fd = match openat_nofollow_dironly(parent_fd, &pcstr) { + let fd = match openat_nofollow_dironly(parent_fd, &path) { Err(err) if err.raw_os_error() == Some(libc::ENOTDIR) => { // not a directory - don't traverse further return match parent_fd { // unlink... Some(parent_fd) => { - cvt(unsafe { unlinkat(parent_fd, pcstr.as_ptr(), 0) }).map(drop) + cvt(unsafe { unlinkat(parent_fd, path.as_ptr(), 0) }).map(drop) } // ...unless this was supposed to be the deletion root directory None => Err(err), @@ -1627,26 +1662,27 @@ mod remove_dir_impl { let (dir, fd) = fdreaddir(fd)?; for child in dir { let child = child?; + let child_name = child.name_cstr(); match is_dir(&child) { Some(true) => { - remove_dir_all_recursive(Some(fd), Path::new(&child.file_name()))?; + remove_dir_all_recursive(Some(fd), child_name)?; } Some(false) => { - cvt(unsafe { unlinkat(fd, child.name_cstr().as_ptr(), 0) })?; + cvt(unsafe { unlinkat(fd, child_name.as_ptr(), 0) })?; } None => { // POSIX specifies that calling unlink()/unlinkat(..., 0) on a directory can succeed // if the process has the appropriate privileges. This however can causing orphaned // directories requiring an fsck e.g. on Solaris and Illumos. So we try recursing // into it first instead of trying to unlink() it. - remove_dir_all_recursive(Some(fd), Path::new(&child.file_name()))?; + remove_dir_all_recursive(Some(fd), child_name)?; } } } // unlink the directory after removing its contents cvt(unsafe { - unlinkat(parent_fd.unwrap_or(libc::AT_FDCWD), pcstr.as_ptr(), libc::AT_REMOVEDIR) + unlinkat(parent_fd.unwrap_or(libc::AT_FDCWD), path.as_ptr(), libc::AT_REMOVEDIR) })?; Ok(()) } @@ -1659,7 +1695,7 @@ mod remove_dir_impl { if attr.file_type().is_symlink() { crate::fs::remove_file(p) } else { - remove_dir_all_recursive(None, p) + remove_dir_all_recursive(None, &cstr(p)?) } } diff --git a/library/std/src/sys/unix/rwlock.rs b/library/std/src/sys/unix/rwlock.rs index b1faf12c226..1318c5b8e3a 100644 --- a/library/std/src/sys/unix/rwlock.rs +++ b/library/std/src/sys/unix/rwlock.rs @@ -48,9 +48,9 @@ impl RWLock { } panic!("rwlock read lock would result in deadlock"); } else { - // According to POSIX, for a properly initialized rwlock this can only - // return EAGAIN or EDEADLK or 0. We rely on that. - debug_assert_eq!(r, 0); + // POSIX does not make guarantees about all the errors that may be returned. + // See issue #94705 for more details. + assert_eq!(r, 0, "unexpected error during rwlock read lock: {:?}", r); self.num_readers.fetch_add(1, Ordering::Relaxed); } } diff --git a/library/std/src/sys/windows/mod.rs b/library/std/src/sys/windows/mod.rs index dc288176346..6097e628768 100644 --- a/library/std/src/sys/windows/mod.rs +++ b/library/std/src/sys/windows/mod.rs @@ -224,8 +224,14 @@ where } as usize; if k == n && c::GetLastError() == c::ERROR_INSUFFICIENT_BUFFER { n *= 2; - } else if k >= n { + } else if k > n { n = k; + } else if k == n { + // It is impossible to reach this point. + // On success, k is the returned string length excluding the null. + // On failure, k is the required buffer length including the null. + // Therefore k never equals n. + unreachable!(); } else { return Ok(f2(&buf[..k])); } diff --git a/library/std/src/thread/scoped.rs b/library/std/src/thread/scoped.rs index ea9623be63b..4af58f1a380 100644 --- a/library/std/src/thread/scoped.rs +++ b/library/std/src/thread/scoped.rs @@ -9,23 +9,24 @@ use crate::sync::Arc; /// A scope to spawn scoped threads in. /// /// See [`scope`] for details. -pub struct Scope<'env> { +pub struct Scope<'scope, 'env: 'scope> { data: ScopeData, - /// Invariance over 'env, to make sure 'env cannot shrink, + /// Invariance over 'scope, to make sure 'scope cannot shrink, /// which is necessary for soundness. /// /// Without invariance, this would compile fine but be unsound: /// - /// ```compile_fail + /// ```compile_fail,E0373 /// #![feature(scoped_threads)] /// /// std::thread::scope(|s| { - /// s.spawn(|s| { + /// s.spawn(|| { /// let a = String::from("abcd"); - /// s.spawn(|_| println!("{:?}", a)); // might run after `a` is dropped + /// s.spawn(|| println!("{:?}", a)); // might run after `a` is dropped /// }); /// }); /// ``` + scope: PhantomData<&'scope mut &'scope ()>, env: PhantomData<&'env mut &'env ()>, } @@ -88,12 +89,12 @@ impl ScopeData { /// let mut x = 0; /// /// thread::scope(|s| { -/// s.spawn(|_| { +/// s.spawn(|| { /// println!("hello from the first scoped thread"); /// // We can borrow `a` here. /// dbg!(&a); /// }); -/// s.spawn(|_| { +/// s.spawn(|| { /// println!("hello from the second scoped thread"); /// // We can even mutably borrow `x` here, /// // because no other threads are using it. @@ -109,7 +110,7 @@ impl ScopeData { #[track_caller] pub fn scope<'env, F, T>(f: F) -> T where - F: FnOnce(&Scope<'env>) -> T, + F: for<'scope> FnOnce(&'scope Scope<'scope, 'env>) -> T, { let scope = Scope { data: ScopeData { @@ -118,6 +119,7 @@ where a_thread_panicked: AtomicBool::new(false), }, env: PhantomData, + scope: PhantomData, }; // Run `f`, but catch panics so we can make sure to wait for all the threads to join. @@ -138,7 +140,7 @@ where } } -impl<'env> Scope<'env> { +impl<'scope, 'env> Scope<'scope, 'env> { /// Spawns a new thread within a scope, returning a [`ScopedJoinHandle`] for it. /// /// Unlike non-scoped threads, threads spawned with this function may @@ -163,10 +165,10 @@ impl<'env> Scope<'env> { /// to recover from such errors. /// /// [`join`]: ScopedJoinHandle::join - pub fn spawn<'scope, F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T> + pub fn spawn<F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T> where - F: FnOnce(&Scope<'env>) -> T + Send + 'env, - T: Send + 'env, + F: FnOnce() -> T + Send + 'scope, + T: Send + 'scope, { Builder::new().spawn_scoped(self, f).expect("failed to spawn thread") } @@ -196,7 +198,7 @@ impl Builder { /// thread::scope(|s| { /// thread::Builder::new() /// .name("first".to_string()) - /// .spawn_scoped(s, |_| + /// .spawn_scoped(s, || /// { /// println!("hello from the {:?} scoped thread", thread::current().name()); /// // We can borrow `a` here. @@ -205,7 +207,7 @@ impl Builder { /// .unwrap(); /// thread::Builder::new() /// .name("second".to_string()) - /// .spawn_scoped(s, |_| + /// .spawn_scoped(s, || /// { /// println!("hello from the {:?} scoped thread", thread::current().name()); /// // We can even mutably borrow `x` here, @@ -222,14 +224,14 @@ impl Builder { /// ``` pub fn spawn_scoped<'scope, 'env, F, T>( self, - scope: &'scope Scope<'env>, + scope: &'scope Scope<'scope, 'env>, f: F, ) -> io::Result<ScopedJoinHandle<'scope, T>> where - F: FnOnce(&Scope<'env>) -> T + Send + 'env, - T: Send + 'env, + F: FnOnce() -> T + Send + 'scope, + T: Send + 'scope, { - Ok(ScopedJoinHandle(unsafe { self.spawn_unchecked_(|| f(scope), Some(&scope.data)) }?)) + Ok(ScopedJoinHandle(unsafe { self.spawn_unchecked_(f, Some(&scope.data)) }?)) } } @@ -244,7 +246,7 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> { /// use std::thread; /// /// thread::scope(|s| { - /// let t = s.spawn(|_| { + /// let t = s.spawn(|| { /// println!("hello"); /// }); /// println!("thread id: {:?}", t.thread().id()); @@ -277,7 +279,7 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> { /// use std::thread; /// /// thread::scope(|s| { - /// let t = s.spawn(|_| { + /// let t = s.spawn(|| { /// panic!("oh no"); /// }); /// assert!(t.join().is_err()); @@ -302,7 +304,7 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> { } } -impl<'env> fmt::Debug for Scope<'env> { +impl fmt::Debug for Scope<'_, '_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Scope") .field("num_running_threads", &self.data.num_running_threads.load(Ordering::Relaxed)) diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index fe9d6a727ed..4c32547f059 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -3,6 +3,7 @@ name = "bootstrap" version = "0.0.0" edition = "2021" build = "build.rs" +default-run = "bootstrap" [lib] path = "lib.rs" diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 6c1128b393f..1777dae594f 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -1267,7 +1267,7 @@ def bootstrap(help_triggered): build.check_vendored_status() build_dir = build.get_toml('build-dir', 'build') or 'build' - build.build_dir = os.path.abspath(build_dir.replace("$ROOT", build.rust_root)) + build.build_dir = os.path.abspath(build_dir) with open(os.path.join(build.rust_root, "src", "stage0.json")) as f: data = json.load(f) @@ -1302,10 +1302,7 @@ def bootstrap(help_triggered): env = os.environ.copy() env["BOOTSTRAP_PARENT_ID"] = str(os.getpid()) env["BOOTSTRAP_PYTHON"] = sys.executable - env["BUILD_DIR"] = build.build_dir env["RUSTC_BOOTSTRAP"] = '1' - if toml_path: - env["BOOTSTRAP_CONFIG"] = toml_path if build.rustc_commit is not None: env["BOOTSTRAP_DOWNLOAD_RUSTC"] = '1' run(args, env=env, verbose=build.verbose, is_bootstrap=True) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index fc55c8626d9..1903f0baef1 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -883,7 +883,7 @@ impl<'a> Builder<'a> { } pub fn rustdoc_cmd(&self, compiler: Compiler) -> Command { - let mut cmd = Command::new(&self.out.join("bootstrap/debug/rustdoc")); + let mut cmd = Command::new(&self.bootstrap_out.join("rustdoc")); cmd.env("RUSTC_STAGE", compiler.stage.to_string()) .env("RUSTC_SYSROOT", self.sysroot(compiler)) // Note that this is *not* the sysroot_libdir because rustdoc must be linked @@ -1249,7 +1249,7 @@ impl<'a> Builder<'a> { .env("RUSTC_STAGE", stage.to_string()) .env("RUSTC_SYSROOT", &sysroot) .env("RUSTC_LIBDIR", &libdir) - .env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc")) + .env("RUSTDOC", self.bootstrap_out.join("rustdoc")) .env( "RUSTDOC_REAL", if cmd == "doc" || cmd == "rustdoc" || (cmd == "test" && want_rustdoc) { @@ -1263,7 +1263,7 @@ impl<'a> Builder<'a> { // Clippy support is a hack and uses the default `cargo-clippy` in path. // Don't override RUSTC so that the `cargo-clippy` in path will be run. if cmd != "clippy" { - cargo.env("RUSTC", self.out.join("bootstrap/debug/rustc")); + cargo.env("RUSTC", self.bootstrap_out.join("rustc")); } // Dealing with rpath here is a little special, so let's go into some diff --git a/src/bootstrap/builder/tests.rs b/src/bootstrap/builder/tests.rs index bc710344969..b76bb569852 100644 --- a/src/bootstrap/builder/tests.rs +++ b/src/bootstrap/builder/tests.rs @@ -8,10 +8,10 @@ fn configure(cmd: &str, host: &[&str], target: &[&str]) -> Config { config.save_toolstates = None; config.dry_run = true; config.ninja_in_file = false; - // try to avoid spurious failures in dist where we create/delete each others file config.out = PathBuf::from(env::var_os("BOOTSTRAP_OUTPUT_DIRECTORY").unwrap()); config.initial_rustc = PathBuf::from(env::var_os("RUSTC").unwrap()); config.initial_cargo = PathBuf::from(env::var_os("BOOTSTRAP_INITIAL_CARGO").unwrap()); + // try to avoid spurious failures in dist where we create/delete each others file let dir = config .out .join("tmp-rustbuild-tests") diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index b17b94f2893..73a855ae4d7 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -6,7 +6,6 @@ use std::cmp; use std::collections::{HashMap, HashSet}; use std::env; -use std::ffi::OsString; use std::fmt; use std::fs; use std::path::{Path, PathBuf}; @@ -392,7 +391,6 @@ derive_merge! { build: Option<String>, host: Option<Vec<String>>, target: Option<Vec<String>>, - // This is ignored, the rust code always gets the build directory from the `BUILD_DIR` env variable build_dir: Option<String>, cargo: Option<String>, rustc: Option<String>, @@ -588,18 +586,6 @@ derive_merge! { } impl Config { - fn path_from_python(var_key: &str) -> PathBuf { - match env::var_os(var_key) { - Some(var_val) => Self::normalize_python_path(var_val), - _ => panic!("expected '{}' to be set", var_key), - } - } - - /// Normalizes paths from Python slightly. We don't trust paths from Python (#49785). - fn normalize_python_path(path: OsString) -> PathBuf { - Path::new(&path).components().collect() - } - pub fn default_opts() -> Config { let mut config = Config::default(); config.llvm_optimize = true; @@ -625,7 +611,7 @@ impl Config { let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); // Undo `src/bootstrap` config.src = manifest_dir.parent().unwrap().parent().unwrap().to_owned(); - config.out = Config::path_from_python("BUILD_DIR"); + config.out = PathBuf::from("build"); config.initial_cargo = PathBuf::from(env!("CARGO")); config.initial_rustc = PathBuf::from(env!("RUSTC")); @@ -655,12 +641,6 @@ impl Config { config.llvm_profile_use = flags.llvm_profile_use; config.llvm_profile_generate = flags.llvm_profile_generate; - if config.dry_run { - let dir = config.out.join("tmp-dry-run"); - t!(fs::create_dir_all(&dir)); - config.out = dir; - } - #[cfg(test)] let get_toml = |_| TomlConfig::default(); #[cfg(not(test))] @@ -677,7 +657,15 @@ impl Config { } }; - let mut toml = flags.config.as_deref().map(get_toml).unwrap_or_else(TomlConfig::default); + // check --config first, then `$RUST_BOOTSTRAP_CONFIG` first, then `config.toml` + let toml_path = flags + .config + .clone() + .or_else(|| env::var_os("RUST_BOOTSTRAP_CONFIG").map(PathBuf::from)) + .unwrap_or_else(|| PathBuf::from("config.toml")); + let mut toml = + if toml_path.exists() { get_toml(&toml_path) } else { TomlConfig::default() }; + if let Some(include) = &toml.profile { let mut include_path = config.src.clone(); include_path.push("src"); @@ -689,12 +677,25 @@ impl Config { } config.changelog_seen = toml.changelog_seen; - if let Some(cfg) = flags.config { - config.config = cfg; - } + config.config = toml_path; let build = toml.build.unwrap_or_default(); + set(&mut config.initial_rustc, build.rustc.map(PathBuf::from)); + set(&mut config.out, build.build_dir.map(PathBuf::from)); + // NOTE: Bootstrap spawns various commands with different working directories. + // To avoid writing to random places on the file system, `config.out` needs to be an absolute path. + if !config.out.is_absolute() { + // `canonicalize` requires the path to already exist. Use our vendored copy of `absolute` instead. + config.out = crate::util::absolute(&config.out); + } + + if config.dry_run { + let dir = config.out.join("tmp-dry-run"); + t!(fs::create_dir_all(&dir)); + config.out = dir; + } + config.hosts = if let Some(arg_host) = flags.host { arg_host } else if let Some(file_host) = build.host { diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index e34b40a93ff..1a4e6a96888 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -3,7 +3,6 @@ //! This module implements the command-line parsing of the build system which //! has various flags to configure how it's run. -use std::env; use std::path::PathBuf; use std::process; @@ -541,7 +540,6 @@ Arguments: // Get any optional paths which occur after the subcommand let mut paths = matches.free[1..].iter().map(|p| p.into()).collect::<Vec<PathBuf>>(); - let cfg_file = env::var_os("BOOTSTRAP_CONFIG").map(PathBuf::from); let verbose = matches.opt_present("verbose"); // User passed in -h/--help? @@ -671,7 +669,7 @@ Arguments: } else { None }, - config: cfg_file, + config: matches.opt_str("config").map(PathBuf::from), jobs: matches.opt_str("jobs").map(|j| j.parse().expect("`jobs` should be a number")), cmd, incremental: matches.opt_present("incremental"), diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index ccc8516a89a..2ae63858ff6 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -261,6 +261,7 @@ pub struct Build { // Properties derived from the above configuration src: PathBuf, out: PathBuf, + bootstrap_out: PathBuf, rust_info: channel::GitInfo, cargo_info: channel::GitInfo, rls_info: channel::GitInfo, @@ -435,6 +436,20 @@ impl Build { .expect("failed to read src/version"); let version = version.trim(); + let bootstrap_out = if std::env::var("BOOTSTRAP_PYTHON").is_ok() { + out.join("bootstrap").join("debug") + } else { + let workspace_target_dir = std::env::var("CARGO_TARGET_DIR") + .map(PathBuf::from) + .unwrap_or_else(|_| src.join("target")); + let bootstrap_out = workspace_target_dir.join("debug"); + if !bootstrap_out.join("rustc").exists() { + // this restriction can be lifted whenever https://github.com/rust-lang/rfcs/pull/3028 is implemented + panic!("run `cargo build --bins` before `cargo run`") + } + bootstrap_out + }; + let mut build = Build { initial_rustc: config.initial_rustc.clone(), initial_cargo: config.initial_cargo.clone(), @@ -453,6 +468,7 @@ impl Build { version: version.to_string(), src, out, + bootstrap_out, rust_info, cargo_info, @@ -629,7 +645,7 @@ impl Build { } if let Subcommand::Setup { profile } = &self.config.cmd { - return setup::setup(&self.config.src, *profile); + return setup::setup(&self.config, *profile); } { diff --git a/src/bootstrap/setup.rs b/src/bootstrap/setup.rs index 9a9ef0b7695..e1235829b3a 100644 --- a/src/bootstrap/setup.rs +++ b/src/bootstrap/setup.rs @@ -1,5 +1,5 @@ -use crate::TargetSelection; use crate::{t, VERSION}; +use crate::{Config, TargetSelection}; use std::env::consts::EXE_SUFFIX; use std::fmt::Write as _; use std::fs::File; @@ -81,24 +81,22 @@ impl fmt::Display for Profile { } } -pub fn setup(src_path: &Path, profile: Profile) { - let cfg_file = env::var_os("BOOTSTRAP_CONFIG").map(PathBuf::from); +pub fn setup(config: &Config, profile: Profile) { + let path = &config.config; - if cfg_file.as_ref().map_or(false, |f| f.exists()) { - let file = cfg_file.unwrap(); + if path.exists() { println!( "error: you asked `x.py` to setup a new config file, but one already exists at `{}`", - file.display() + path.display() ); - println!("help: try adding `profile = \"{}\"` at the top of {}", profile, file.display()); + println!("help: try adding `profile = \"{}\"` at the top of {}", profile, path.display()); println!( "note: this will use the configuration in {}", - profile.include_path(src_path).display() + profile.include_path(&config.src).display() ); std::process::exit(1); } - let path = cfg_file.unwrap_or_else(|| "config.toml".into()); let settings = format!( "# Includes one of the default files in src/bootstrap/defaults\n\ profile = \"{}\"\n\ @@ -107,7 +105,7 @@ pub fn setup(src_path: &Path, profile: Profile) { ); t!(fs::write(path, settings)); - let include_path = profile.include_path(src_path); + let include_path = profile.include_path(&config.src); println!("`x.py` will now use the configuration at {}", include_path.display()); let build = TargetSelection::from_user(&env!("BUILD_TRIPLE")); @@ -138,7 +136,7 @@ pub fn setup(src_path: &Path, profile: Profile) { println!(); - t!(install_git_hook_maybe(src_path)); + t!(install_git_hook_maybe(&config.src)); println!(); diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index e4fcb287f12..58b73ebed50 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -730,7 +730,7 @@ impl Step for RustdocTheme { } fn run(self, builder: &Builder<'_>) { - let rustdoc = builder.out.join("bootstrap/debug/rustdoc"); + let rustdoc = builder.bootstrap_out.join("rustdoc"); let mut cmd = builder.tool_cmd(Tool::RustdocTheme); cmd.arg(rustdoc.to_str().unwrap()) .arg(builder.src.join("src/librustdoc/html/static/css/themes").to_str().unwrap()) @@ -2346,6 +2346,8 @@ impl Step for Bootstrap { .current_dir(builder.src.join("src/bootstrap")) .env("RUSTFLAGS", "-Cdebuginfo=2") .env("CARGO_TARGET_DIR", builder.out.join("bootstrap")) + // HACK: bootstrap's tests want to know the output directory, but there's no way to set + // it except through config.toml. Set it through an env variable instead. .env("BOOTSTRAP_OUTPUT_DIRECTORY", &builder.config.out) .env("BOOTSTRAP_INITIAL_CARGO", &builder.config.initial_cargo) .env("RUSTC_BOOTSTRAP", "1") diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index 8e770d4d57f..30d9665dd0f 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -440,3 +440,112 @@ fn fail(s: &str) -> ! { println!("\n\n{}\n\n", s); std::process::exit(1); } + +/// Copied from `std::path::absolute` until it stabilizes. +/// +/// FIXME: this shouldn't exist. +pub(crate) fn absolute(path: &Path) -> PathBuf { + if path.as_os_str().is_empty() { + panic!("can't make empty path absolute"); + } + #[cfg(unix)] + { + t!(absolute_unix(path), format!("could not make path absolute: {}", path.display())) + } + #[cfg(windows)] + { + t!(absolute_windows(path), format!("could not make path absolute: {}", path.display())) + } + #[cfg(not(any(unix, windows)))] + { + println!("warning: bootstrap is not supported on non-unix platforms"); + t!(std::fs::canonicalize(t!(std::env::current_dir()))).join(path) + } +} + +#[cfg(unix)] +/// Make a POSIX path absolute without changing its semantics. +fn absolute_unix(path: &Path) -> io::Result<PathBuf> { + // This is mostly a wrapper around collecting `Path::components`, with + // exceptions made where this conflicts with the POSIX specification. + // See 4.13 Pathname Resolution, IEEE Std 1003.1-2017 + // https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13 + + use std::os::unix::prelude::OsStrExt; + let mut components = path.components(); + let path_os = path.as_os_str().as_bytes(); + + let mut normalized = if path.is_absolute() { + // "If a pathname begins with two successive <slash> characters, the + // first component following the leading <slash> characters may be + // interpreted in an implementation-defined manner, although more than + // two leading <slash> characters shall be treated as a single <slash> + // character." + if path_os.starts_with(b"//") && !path_os.starts_with(b"///") { + components.next(); + PathBuf::from("//") + } else { + PathBuf::new() + } + } else { + env::current_dir()? + }; + normalized.extend(components); + + // "Interfaces using pathname resolution may specify additional constraints + // when a pathname that does not name an existing directory contains at + // least one non- <slash> character and contains one or more trailing + // <slash> characters". + // A trailing <slash> is also meaningful if "a symbolic link is + // encountered during pathname resolution". + + if path_os.ends_with(b"/") { + normalized.push(""); + } + + Ok(normalized) +} + +#[cfg(windows)] +fn absolute_windows(path: &std::path::Path) -> std::io::Result<std::path::PathBuf> { + use std::ffi::OsString; + use std::io::Error; + use std::os::windows::ffi::{OsStrExt, OsStringExt}; + use std::ptr::null_mut; + #[link(name = "kernel32")] + extern "system" { + fn GetFullPathNameW( + lpFileName: *const u16, + nBufferLength: u32, + lpBuffer: *mut u16, + lpFilePart: *mut *const u16, + ) -> u32; + } + + unsafe { + // encode the path as UTF-16 + let path: Vec<u16> = path.as_os_str().encode_wide().chain([0]).collect(); + let mut buffer = Vec::new(); + // Loop until either success or failure. + loop { + // Try to get the absolute path + let len = GetFullPathNameW( + path.as_ptr(), + buffer.len().try_into().unwrap(), + buffer.as_mut_ptr(), + null_mut(), + ); + match len as usize { + // Failure + 0 => return Err(Error::last_os_error()), + // Buffer is too small, resize. + len if len > buffer.len() => buffer.resize(len, 0), + // Success! + len => { + buffer.truncate(len); + return Ok(OsString::from_wide(&buffer).into()); + } + } + } + } +} diff --git a/src/test/rustdoc-gui/mobile.goml b/src/test/rustdoc-gui/mobile.goml index e70abcb83cf..13b9b563d94 100644 --- a/src/test/rustdoc-gui/mobile.goml +++ b/src/test/rustdoc-gui/mobile.goml @@ -3,6 +3,7 @@ goto: file://|DOC_PATH|/staged_api/struct.Foo.html size: (400, 600) font-size: 18 +wait-for: 100 // wait a bit for the resize and the font-size change to be fully taken into account. // The out-of-band info (source, stable version, collapse) should be below the // h1 when the screen gets narrow enough. @@ -18,10 +19,12 @@ assert-property: (".mobile-topbar h2.location", {"offsetHeight": 36}) assert-css: (".content .out-of-band .since::before", { "content": "\"Since \"" }) size: (1000, 1000) +wait-for: 100 // wait a bit for the resize to be fully taken into account. assert-css-false: (".content .out-of-band .since::before", { "content": "\"Since \"" }) // On the settings page, the theme buttons should not line-wrap. Instead, they should // all be placed as a group on a line below the setting name "Theme." goto: file://|DOC_PATH|/settings.html size: (400, 600) -compare-elements-position-near-false: ("#preferred-light-theme .setting-name", "#preferred-light-theme .choice", {"y": 16}) +// Ignored for now https://github.com/rust-lang/rust/issues/93784. +// compare-elements-position-near-false: ("#preferred-light-theme .setting-name", "#preferred-light-theme .choice", {"y": 16}) diff --git a/src/test/ui/async-await/edition-deny-async-fns-2015.stderr b/src/test/ui/async-await/edition-deny-async-fns-2015.stderr index 8fb570d6756..35f9c581c7b 100644 --- a/src/test/ui/async-await/edition-deny-async-fns-2015.stderr +++ b/src/test/ui/async-await/edition-deny-async-fns-2015.stderr @@ -4,7 +4,7 @@ error[E0670]: `async fn` is not permitted in Rust 2015 LL | async fn foo() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later | - = help: set `edition = "2021"` in `Cargo.toml` + = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 @@ -13,7 +13,7 @@ error[E0670]: `async fn` is not permitted in Rust 2015 LL | fn baz() { async fn foo() {} } | ^^^^^ to use `async fn`, switch to Rust 2018 or later | - = help: set `edition = "2021"` in `Cargo.toml` + = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 @@ -22,7 +22,7 @@ error[E0670]: `async fn` is not permitted in Rust 2015 LL | async fn async_baz() { | ^^^^^ to use `async fn`, switch to Rust 2018 or later | - = help: set `edition = "2021"` in `Cargo.toml` + = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 @@ -31,7 +31,7 @@ error[E0670]: `async fn` is not permitted in Rust 2015 LL | async fn bar() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later | - = help: set `edition = "2021"` in `Cargo.toml` + = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 @@ -40,7 +40,7 @@ error[E0670]: `async fn` is not permitted in Rust 2015 LL | async fn foo() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later | - = help: set `edition = "2021"` in `Cargo.toml` + = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 @@ -49,7 +49,7 @@ error[E0670]: `async fn` is not permitted in Rust 2015 LL | async fn foo() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later | - = help: set `edition = "2021"` in `Cargo.toml` + = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 @@ -58,7 +58,7 @@ error[E0670]: `async fn` is not permitted in Rust 2015 LL | async fn bar() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later | - = help: set `edition = "2021"` in `Cargo.toml` + = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 @@ -67,7 +67,7 @@ error[E0670]: `async fn` is not permitted in Rust 2015 LL | async fn foo() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later | - = help: set `edition = "2021"` in `Cargo.toml` + = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 @@ -76,7 +76,7 @@ error[E0670]: `async fn` is not permitted in Rust 2015 LL | async fn bar() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later | - = help: set `edition = "2021"` in `Cargo.toml` + = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0706]: functions in traits cannot be declared `async` diff --git a/src/test/ui/async-await/suggest-switching-edition-on-await-cargo.rs b/src/test/ui/async-await/suggest-switching-edition-on-await-cargo.rs new file mode 100644 index 00000000000..4919e0a051d --- /dev/null +++ b/src/test/ui/async-await/suggest-switching-edition-on-await-cargo.rs @@ -0,0 +1,47 @@ +// rustc-env:CARGO=/usr/bin/cargo + +use std::pin::Pin; +use std::future::Future; + +fn main() {} + +fn await_on_struct_missing() { + struct S; + let x = S; + x.await; + //~^ ERROR no field `await` on type + //~| NOTE unknown field + //~| NOTE to `.await` a `Future`, switch to Rust 2018 + //~| HELP set `edition = "2021"` in `Cargo.toml` + //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide +} + +fn await_on_struct_similar() { + struct S { + awai: u8, + } + let x = S { awai: 42 }; + x.await; + //~^ ERROR no field `await` on type + //~| HELP a field with a similar name exists + //~| NOTE to `.await` a `Future`, switch to Rust 2018 + //~| HELP set `edition = "2021"` in `Cargo.toml` + //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide +} + +fn await_on_63533(x: Pin<&mut dyn Future<Output = ()>>) { + x.await; + //~^ ERROR no field `await` on type + //~| NOTE unknown field + //~| NOTE to `.await` a `Future`, switch to Rust 2018 + //~| HELP set `edition = "2021"` in `Cargo.toml` + //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide +} + +fn await_on_apit(x: impl Future<Output = ()>) { + x.await; + //~^ ERROR no field `await` on type + //~| NOTE to `.await` a `Future`, switch to Rust 2018 + //~| HELP set `edition = "2021"` in `Cargo.toml` + //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide +} diff --git a/src/test/ui/async-await/suggest-switching-edition-on-await-cargo.stderr b/src/test/ui/async-await/suggest-switching-edition-on-await-cargo.stderr new file mode 100644 index 00000000000..409eb179e83 --- /dev/null +++ b/src/test/ui/async-await/suggest-switching-edition-on-await-cargo.stderr @@ -0,0 +1,43 @@ +error[E0609]: no field `await` on type `await_on_struct_missing::S` + --> $DIR/suggest-switching-edition-on-await-cargo.rs:11:7 + | +LL | x.await; + | ^^^^^ unknown field + | + = note: to `.await` a `Future`, switch to Rust 2018 or later + = help: set `edition = "2021"` in `Cargo.toml` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0609]: no field `await` on type `await_on_struct_similar::S` + --> $DIR/suggest-switching-edition-on-await-cargo.rs:24:7 + | +LL | x.await; + | ^^^^^ help: a field with a similar name exists: `awai` + | + = note: to `.await` a `Future`, switch to Rust 2018 or later + = help: set `edition = "2021"` in `Cargo.toml` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0609]: no field `await` on type `Pin<&mut dyn Future<Output = ()>>` + --> $DIR/suggest-switching-edition-on-await-cargo.rs:33:7 + | +LL | x.await; + | ^^^^^ unknown field + | + = note: to `.await` a `Future`, switch to Rust 2018 or later + = help: set `edition = "2021"` in `Cargo.toml` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0609]: no field `await` on type `impl Future<Output = ()>` + --> $DIR/suggest-switching-edition-on-await-cargo.rs:42:7 + | +LL | x.await; + | ^^^^^ + | + = note: to `.await` a `Future`, switch to Rust 2018 or later + = help: set `edition = "2021"` in `Cargo.toml` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0609`. diff --git a/src/test/ui/async-await/suggest-switching-edition-on-await.rs b/src/test/ui/async-await/suggest-switching-edition-on-await.rs index f2e0fb19c63..9852e8fc918 100644 --- a/src/test/ui/async-await/suggest-switching-edition-on-await.rs +++ b/src/test/ui/async-await/suggest-switching-edition-on-await.rs @@ -10,7 +10,7 @@ fn await_on_struct_missing() { //~^ ERROR no field `await` on type //~| NOTE unknown field //~| NOTE to `.await` a `Future`, switch to Rust 2018 - //~| HELP set `edition = "2021"` in `Cargo.toml` + //~| HELP pass `--edition 2021` to `rustc` //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide } @@ -23,7 +23,7 @@ fn await_on_struct_similar() { //~^ ERROR no field `await` on type //~| HELP a field with a similar name exists //~| NOTE to `.await` a `Future`, switch to Rust 2018 - //~| HELP set `edition = "2021"` in `Cargo.toml` + //~| HELP pass `--edition 2021` to `rustc` //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide } @@ -32,7 +32,7 @@ fn await_on_63533(x: Pin<&mut dyn Future<Output = ()>>) { //~^ ERROR no field `await` on type //~| NOTE unknown field //~| NOTE to `.await` a `Future`, switch to Rust 2018 - //~| HELP set `edition = "2021"` in `Cargo.toml` + //~| HELP pass `--edition 2021` to `rustc` //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide } @@ -40,6 +40,6 @@ fn await_on_apit(x: impl Future<Output = ()>) { x.await; //~^ ERROR no field `await` on type //~| NOTE to `.await` a `Future`, switch to Rust 2018 - //~| HELP set `edition = "2021"` in `Cargo.toml` + //~| HELP pass `--edition 2021` to `rustc` //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide } diff --git a/src/test/ui/async-await/suggest-switching-edition-on-await.stderr b/src/test/ui/async-await/suggest-switching-edition-on-await.stderr index b38c897fc74..ef3334381b7 100644 --- a/src/test/ui/async-await/suggest-switching-edition-on-await.stderr +++ b/src/test/ui/async-await/suggest-switching-edition-on-await.stderr @@ -5,7 +5,7 @@ LL | x.await; | ^^^^^ unknown field | = note: to `.await` a `Future`, switch to Rust 2018 or later - = help: set `edition = "2021"` in `Cargo.toml` + = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0609]: no field `await` on type `await_on_struct_similar::S` @@ -15,7 +15,7 @@ LL | x.await; | ^^^^^ help: a field with a similar name exists: `awai` | = note: to `.await` a `Future`, switch to Rust 2018 or later - = help: set `edition = "2021"` in `Cargo.toml` + = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0609]: no field `await` on type `Pin<&mut dyn Future<Output = ()>>` @@ -25,7 +25,7 @@ LL | x.await; | ^^^^^ unknown field | = note: to `.await` a `Future`, switch to Rust 2018 or later - = help: set `edition = "2021"` in `Cargo.toml` + = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0609]: no field `await` on type `impl Future<Output = ()>` @@ -35,7 +35,7 @@ LL | x.await; | ^^^^^ | = note: to `.await` a `Future`, switch to Rust 2018 or later - = help: set `edition = "2021"` in `Cargo.toml` + = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error: aborting due to 4 previous errors diff --git a/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.edition.stderr b/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.edition.stderr index e2c80732414..d88185af778 100644 --- a/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.edition.stderr +++ b/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.edition.stderr @@ -2,10 +2,8 @@ error[E0507]: cannot move out of `foo` in pattern guard --> $DIR/borrowck-feature-nll-overrides-migrate.rs:22:18 | LL | (|| { let bar = foo; bar.take() })(); - | ^^ --- - | | | - | | move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait - | | move occurs due to use in closure + | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait + | | | move out of `foo` occurs here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard diff --git a/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.zflag.stderr b/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.zflag.stderr index e2c80732414..d88185af778 100644 --- a/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.zflag.stderr +++ b/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.zflag.stderr @@ -2,10 +2,8 @@ error[E0507]: cannot move out of `foo` in pattern guard --> $DIR/borrowck-feature-nll-overrides-migrate.rs:22:18 | LL | (|| { let bar = foo; bar.take() })(); - | ^^ --- - | | | - | | move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait - | | move occurs due to use in closure + | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait + | | | move out of `foo` occurs here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard diff --git a/src/test/ui/borrowck/borrowck-move-by-capture.stderr b/src/test/ui/borrowck/borrowck-move-by-capture.stderr index 257ec3fbb7f..f81b34a641b 100644 --- a/src/test/ui/borrowck/borrowck-move-by-capture.stderr +++ b/src/test/ui/borrowck/borrowck-move-by-capture.stderr @@ -8,8 +8,8 @@ LL | let _g = to_fn_mut(|| { LL | | let _h = to_fn_once(move || -> isize { *bar }); | | ^^^^^^^^^^^^^^^^ ---- | | | | + | | | variable moved due to use in closure | | | move occurs because `bar` has type `Box<isize>`, which does not implement the `Copy` trait - | | | move occurs due to use in closure | | move out of `bar` occurs here LL | | }); | |_____- captured by this `FnMut` closure diff --git a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.stderr b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.stderr index 79745065070..800f30b34e5 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.stderr @@ -2,7 +2,16 @@ error[E0507]: cannot move out of an `Rc` --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:4:14 | LL | let _x = Rc::new(vec![1, 2]).into_iter(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ move occurs because value has type `Vec<i32>`, which does not implement the `Copy` trait + | ^^^^^^^^^^^^^^^^^^^^----------- + | | | + | | value moved due to this method call + | move occurs because value has type `Vec<i32>`, which does not implement the `Copy` trait + | +note: this function takes ownership of the receiver `self`, which moves value + --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + | +LL | fn into_iter(self) -> Self::IntoIter; + | ^^^^ error: aborting due to previous error diff --git a/src/test/ui/borrowck/issue-27282-mutation-in-guard.stderr b/src/test/ui/borrowck/issue-27282-mutation-in-guard.stderr index 540f7f8a484..c4ce7e62fda 100644 --- a/src/test/ui/borrowck/issue-27282-mutation-in-guard.stderr +++ b/src/test/ui/borrowck/issue-27282-mutation-in-guard.stderr @@ -2,10 +2,8 @@ error[E0507]: cannot move out of `foo` in pattern guard --> $DIR/issue-27282-mutation-in-guard.rs:6:18 | LL | (|| { let bar = foo; bar.take() })(); - | ^^ --- - | | | - | | move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait - | | move occurs due to use in closure + | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait + | | | move out of `foo` occurs here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard diff --git a/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr b/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr index 1663ce81d6c..3ea72262003 100644 --- a/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr +++ b/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr @@ -6,10 +6,18 @@ LL | let y = vec![format!("World")]; LL | call(|| { | __________- LL | | y.into_iter(); - | | ^ move occurs because `y` has type `Vec<String>`, which does not implement the `Copy` trait + | | ^ ----------- `y` moved due to this method call + | | | + | | move occurs because `y` has type `Vec<String>`, which does not implement the `Copy` trait LL | | LL | | }); | |_____- captured by this `Fn` closure + | +note: this function takes ownership of the receiver `self`, which moves `y` + --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + | +LL | fn into_iter(self) -> Self::IntoIter; + | ^^^^ error: aborting due to previous error diff --git a/src/test/ui/closures/2229_closure_analysis/match/issue-88331.stderr b/src/test/ui/closures/2229_closure_analysis/match/issue-88331.stderr index f02d23464f1..7e22defa98d 100644 --- a/src/test/ui/closures/2229_closure_analysis/match/issue-88331.stderr +++ b/src/test/ui/closures/2229_closure_analysis/match/issue-88331.stderr @@ -1,26 +1,38 @@ error[E0004]: non-exhaustive patterns: `Opcode(0_u8)` and `Opcode(2_u8..=u8::MAX)` not covered --> $DIR/issue-88331.rs:11:20 | -LL | pub struct Opcode(pub u8); - | -------------------------- `Opcode` defined here -... LL | move |i| match msg_type { | ^^^^^^^^ patterns `Opcode(0_u8)` and `Opcode(2_u8..=u8::MAX)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `Opcode` defined here + --> $DIR/issue-88331.rs:4:12 + | +LL | pub struct Opcode(pub u8); + | ^^^^^^ = note: the matched value is of type `Opcode` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ Opcode::OP1 => unimplemented!(), +LL ~ Opcode(0_u8) | Opcode(2_u8..=u8::MAX) => todo!(), + | error[E0004]: non-exhaustive patterns: `Opcode2(Opcode(0_u8))` and `Opcode2(Opcode(2_u8..=u8::MAX))` not covered --> $DIR/issue-88331.rs:27:20 | -LL | pub struct Opcode2(Opcode); - | --------------------------- `Opcode2` defined here -... LL | move |i| match msg_type { | ^^^^^^^^ patterns `Opcode2(Opcode(0_u8))` and `Opcode2(Opcode(2_u8..=u8::MAX))` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `Opcode2` defined here + --> $DIR/issue-88331.rs:18:12 + | +LL | pub struct Opcode2(Opcode); + | ^^^^^^^ = note: the matched value is of type `Opcode2` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ Opcode2::OP2=> unimplemented!(), +LL ~ Opcode2(Opcode(0_u8)) | Opcode2(Opcode(2_u8..=u8::MAX)) => todo!(), + | error: aborting due to 2 previous errors diff --git a/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr b/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr index 91ffe1a47f4..32d36274ff6 100644 --- a/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr +++ b/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr @@ -1,17 +1,19 @@ error[E0004]: non-exhaustive patterns: `B` not covered --> $DIR/non-exhaustive-match.rs:26:25 | -LL | enum L1 { A, B } - | ---------------- - | | | - | | not covered - | `L1` defined here -... LL | let _b = || { match l1 { L1::A => () } }; | ^^ pattern `B` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `L1` defined here + --> $DIR/non-exhaustive-match.rs:12:14 + | +LL | enum L1 { A, B } + | -- ^ not covered = note: the matched value is of type `L1` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL | let _b = || { match l1 { L1::A => (), B => todo!() } }; + | ++++++++++++++ error[E0004]: non-exhaustive patterns: type `E1` is non-empty --> $DIR/non-exhaustive-match.rs:37:25 @@ -19,8 +21,18 @@ error[E0004]: non-exhaustive patterns: type `E1` is non-empty LL | let _d = || { match e1 {} }; | ^^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `E1` defined here + --> $DIR/auxiliary/match_non_exhaustive_lib.rs:2:1 + | +LL | pub enum E1 {} + | ^^^^^^^^^^^^^^ = note: the matched value is of type `E1`, which is marked as non-exhaustive +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ let _d = || { match e1 { +LL + _ => todo!(), +LL ~ } }; + | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/non-exhaustive-match.rs:39:25 @@ -28,8 +40,16 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | let _e = || { match e2 { E2::A => (), E2::B => () } }; | ^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `E2` defined here + --> $DIR/auxiliary/match_non_exhaustive_lib.rs:5:1 + | +LL | pub enum E2 { A, B } + | ^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `E2`, which is marked as non-exhaustive +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL | let _e = || { match e2 { E2::A => (), E2::B => (), _ => todo!() } }; + | ++++++++++++++ error[E0505]: cannot move out of `e3` because it is borrowed --> $DIR/non-exhaustive-match.rs:46:22 diff --git a/src/test/ui/closures/2229_closure_analysis/match/pattern-matching-should-fail.stderr b/src/test/ui/closures/2229_closure_analysis/match/pattern-matching-should-fail.stderr index 45641ea3de3..e55fb7ce4bb 100644 --- a/src/test/ui/closures/2229_closure_analysis/match/pattern-matching-should-fail.stderr +++ b/src/test/ui/closures/2229_closure_analysis/match/pattern-matching-should-fail.stderr @@ -4,8 +4,13 @@ error[E0004]: non-exhaustive patterns: type `u8` is non-empty LL | let c1 = || match x { }; | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ let c1 = || match x { +LL + _ => todo!(), +LL ~ }; + | error[E0381]: use of possibly-uninitialized variable: `x` --> $DIR/pattern-matching-should-fail.rs:8:23 diff --git a/src/test/ui/consts/issue-94675.rs b/src/test/ui/consts/issue-94675.rs new file mode 100644 index 00000000000..0604aab3bcd --- /dev/null +++ b/src/test/ui/consts/issue-94675.rs @@ -0,0 +1,16 @@ +#![feature(const_trait_impl, const_mut_refs)] + +struct Foo<'a> { + bar: &'a mut Vec<usize>, +} + +impl<'a> Foo<'a> { + const fn spam(&mut self, baz: &mut Vec<u32>) { + self.bar[0] = baz.len(); + //~^ ERROR cannot call non-const fn `Vec::<u32>::len` in constant functions + //~| ERROR the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied + //~| ERROR cannot call non-const operator in constant functions + } +} + +fn main() {} diff --git a/src/test/ui/consts/issue-94675.stderr b/src/test/ui/consts/issue-94675.stderr new file mode 100644 index 00000000000..6665e42835b --- /dev/null +++ b/src/test/ui/consts/issue-94675.stderr @@ -0,0 +1,38 @@ +error[E0015]: cannot call non-const fn `Vec::<u32>::len` in constant functions + --> $DIR/issue-94675.rs:9:27 + | +LL | self.bar[0] = baz.len(); + | ^^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error[E0277]: the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied + --> $DIR/issue-94675.rs:9:9 + | +LL | self.bar[0] = baz.len(); + | ^^^^^^^^^^^ vector indices are of type `usize` or ranges of `usize` + | + = help: the trait `~const IndexMut<usize>` is not implemented for `Vec<usize>` +note: the trait `IndexMut<usize>` is implemented for `Vec<usize>`, but that implementation is not `const` + --> $DIR/issue-94675.rs:9:9 + | +LL | self.bar[0] = baz.len(); + | ^^^^^^^^^^^ + +error[E0015]: cannot call non-const operator in constant functions + --> $DIR/issue-94675.rs:9:9 + | +LL | self.bar[0] = baz.len(); + | ^^^^^^^^^^^ + | +note: impl defined here, but it is not `const` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + | +LL | impl<T, I: SliceIndex<[T]>, A: Allocator> IndexMut<I> for Vec<T, A> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0015, E0277. +For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/editions/async-block-2015.rs b/src/test/ui/editions/async-block-2015.rs index 24112c9855a..3daf4930c5b 100644 --- a/src/test/ui/editions/async-block-2015.rs +++ b/src/test/ui/editions/async-block-2015.rs @@ -1,7 +1,7 @@ async fn foo() { //~^ ERROR `async fn` is not permitted in Rust 2015 //~| NOTE to use `async fn`, switch to Rust 2018 or later -//~| HELP set `edition = "2021"` in `Cargo.toml` +//~| HELP pass `--edition 2021` to `rustc` //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide let x = async {}; @@ -11,7 +11,7 @@ async fn foo() { let x = 42; //~^ ERROR expected identifier, found keyword `let` //~| NOTE expected identifier, found keyword - //~| HELP set `edition = "2021"` in `Cargo.toml` + //~| HELP pass `--edition 2021` to `rustc` //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide 42 }; @@ -19,7 +19,7 @@ async fn foo() { 42 //~^ ERROR expected identifier, found `42` //~| NOTE expected identifier - //~| HELP set `edition = "2021"` in `Cargo.toml` + //~| HELP pass `--edition 2021` to `rustc` //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide }; y.await; diff --git a/src/test/ui/editions/async-block-2015.stderr b/src/test/ui/editions/async-block-2015.stderr index da8412ddcb3..b792b8c1e0d 100644 --- a/src/test/ui/editions/async-block-2015.stderr +++ b/src/test/ui/editions/async-block-2015.stderr @@ -4,7 +4,7 @@ error[E0670]: `async fn` is not permitted in Rust 2015 LL | async fn foo() { | ^^^^^ to use `async fn`, switch to Rust 2018 or later | - = help: set `edition = "2021"` in `Cargo.toml` + = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error: expected identifier, found keyword `let` @@ -15,7 +15,7 @@ LL | let y = async { LL | let x = 42; | ^^^ expected identifier, found keyword | - = help: set `edition = "2021"` in `Cargo.toml` + = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error: expected identifier, found `42` @@ -26,7 +26,7 @@ LL | let z = async { LL | 42 | ^^ expected identifier | - = help: set `edition = "2021"` in `Cargo.toml` + = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0422]: cannot find struct, variant or union type `async` in this scope diff --git a/src/test/ui/empty/empty-attributes.rs b/src/test/ui/empty/empty-attributes.rs index 7e9b05587b0..d319227b217 100644 --- a/src/test/ui/empty/empty-attributes.rs +++ b/src/test/ui/empty/empty-attributes.rs @@ -1,5 +1,8 @@ +#![feature(lint_reasons)] + #![deny(unused_attributes)] #![allow()] //~ ERROR unused attribute +#![expect()] //~ ERROR unused attribute #![warn()] //~ ERROR unused attribute #![deny()] //~ ERROR unused attribute #![forbid()] //~ ERROR unused attribute diff --git a/src/test/ui/empty/empty-attributes.stderr b/src/test/ui/empty/empty-attributes.stderr index e0798e4f0c6..8653eaf5ccd 100644 --- a/src/test/ui/empty/empty-attributes.stderr +++ b/src/test/ui/empty/empty-attributes.stderr @@ -1,18 +1,18 @@ error: unused attribute - --> $DIR/empty-attributes.rs:8:1 + --> $DIR/empty-attributes.rs:11:1 | LL | #[repr()] | ^^^^^^^^^ help: remove this attribute | note: the lint level is defined here - --> $DIR/empty-attributes.rs:1:9 + --> $DIR/empty-attributes.rs:3:9 | LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ = note: attribute `repr` with an empty list has no effect error: unused attribute - --> $DIR/empty-attributes.rs:11:1 + --> $DIR/empty-attributes.rs:14:1 | LL | #[target_feature()] | ^^^^^^^^^^^^^^^^^^^ help: remove this attribute @@ -20,7 +20,7 @@ LL | #[target_feature()] = note: attribute `target_feature` with an empty list has no effect error: unused attribute - --> $DIR/empty-attributes.rs:2:1 + --> $DIR/empty-attributes.rs:4:1 | LL | #![allow()] | ^^^^^^^^^^^ help: remove this attribute @@ -28,7 +28,15 @@ LL | #![allow()] = note: attribute `allow` with an empty list has no effect error: unused attribute - --> $DIR/empty-attributes.rs:3:1 + --> $DIR/empty-attributes.rs:5:1 + | +LL | #![expect()] + | ^^^^^^^^^^^^ help: remove this attribute + | + = note: attribute `expect` with an empty list has no effect + +error: unused attribute + --> $DIR/empty-attributes.rs:6:1 | LL | #![warn()] | ^^^^^^^^^^ help: remove this attribute @@ -36,7 +44,7 @@ LL | #![warn()] = note: attribute `warn` with an empty list has no effect error: unused attribute - --> $DIR/empty-attributes.rs:4:1 + --> $DIR/empty-attributes.rs:7:1 | LL | #![deny()] | ^^^^^^^^^^ help: remove this attribute @@ -44,7 +52,7 @@ LL | #![deny()] = note: attribute `deny` with an empty list has no effect error: unused attribute - --> $DIR/empty-attributes.rs:5:1 + --> $DIR/empty-attributes.rs:8:1 | LL | #![forbid()] | ^^^^^^^^^^^^ help: remove this attribute @@ -52,12 +60,12 @@ LL | #![forbid()] = note: attribute `forbid` with an empty list has no effect error: unused attribute - --> $DIR/empty-attributes.rs:6:1 + --> $DIR/empty-attributes.rs:9:1 | LL | #![feature()] | ^^^^^^^^^^^^^ help: remove this attribute | = note: attribute `feature` with an empty list has no effect -error: aborting due to 7 previous errors +error: aborting due to 8 previous errors diff --git a/src/test/ui/empty/empty-never-array.stderr b/src/test/ui/empty/empty-never-array.stderr index 64d640c0e9d..8dd0f377533 100644 --- a/src/test/ui/empty/empty-never-array.stderr +++ b/src/test/ui/empty/empty-never-array.stderr @@ -1,19 +1,18 @@ error[E0005]: refutable pattern in local binding: `T(_, _)` not covered --> $DIR/empty-never-array.rs:10:9 | -LL | / enum Helper<T, U> { -LL | | T(T, [!; 0]), - | | - not covered -LL | | #[allow(dead_code)] -LL | | U(U), -LL | | } - | |_- `Helper<T, U>` defined here -... -LL | let Helper::U(u) = Helper::T(t, []); - | ^^^^^^^^^^^^ pattern `T(_, _)` not covered +LL | let Helper::U(u) = Helper::T(t, []); + | ^^^^^^^^^^^^ pattern `T(_, _)` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html +note: `Helper<T, U>` defined here + --> $DIR/empty-never-array.rs:4:5 + | +LL | enum Helper<T, U> { + | ------ +LL | T(T, [!; 0]), + | ^ not covered = note: the matched value is of type `Helper<T, U>` help: you might want to use `if let` to ignore the variant that isn't matched | diff --git a/src/test/ui/error-codes/E0004-2.stderr b/src/test/ui/error-codes/E0004-2.stderr index fd0215e72ee..d4519af5408 100644 --- a/src/test/ui/error-codes/E0004-2.stderr +++ b/src/test/ui/error-codes/E0004-2.stderr @@ -4,16 +4,27 @@ error[E0004]: non-exhaustive patterns: `None` and `Some(_)` not covered LL | match x { } | ^ patterns `None` and `Some(_)` not covered | - ::: $SRC_DIR/core/src/option.rs:LL:COL +note: `Option<i32>` defined here + --> $SRC_DIR/core/src/option.rs:LL:COL | -LL | None, - | ---- not covered -... -LL | Some(#[stable(feature = "rust1", since = "1.0.0")] T), - | ---- not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | / pub enum Option<T> { +LL | | /// No value. +LL | | #[lang = "None"] +LL | | #[stable(feature = "rust1", since = "1.0.0")] +LL | | None, + | | ^^^^ not covered +... | +LL | | Some(#[stable(feature = "rust1", since = "1.0.0")] T), + | | ^^^^ not covered +LL | | } + | |_- = note: the matched value is of type `Option<i32>` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ match x { +LL + None | Some(_) => todo!(), +LL ~ } + | error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0004.stderr b/src/test/ui/error-codes/E0004.stderr index 5bf375a6484..8ba151d9e65 100644 --- a/src/test/ui/error-codes/E0004.stderr +++ b/src/test/ui/error-codes/E0004.stderr @@ -1,18 +1,22 @@ error[E0004]: non-exhaustive patterns: `HastaLaVistaBaby` not covered --> $DIR/E0004.rs:9:11 | -LL | / enum Terminator { -LL | | HastaLaVistaBaby, - | | ---------------- not covered -LL | | TalkToMyHand, -LL | | } - | |_- `Terminator` defined here -... -LL | match x { - | ^ pattern `HastaLaVistaBaby` not covered +LL | match x { + | ^ pattern `HastaLaVistaBaby` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `Terminator` defined here + --> $DIR/E0004.rs:2:5 + | +LL | enum Terminator { + | ---------- +LL | HastaLaVistaBaby, + | ^^^^^^^^^^^^^^^^ not covered = note: the matched value is of type `Terminator` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ Terminator::TalkToMyHand => {} +LL + HastaLaVistaBaby => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0005.stderr b/src/test/ui/error-codes/E0005.stderr index b95dcbd8935..208c625a53e 100644 --- a/src/test/ui/error-codes/E0005.stderr +++ b/src/test/ui/error-codes/E0005.stderr @@ -4,13 +4,21 @@ error[E0005]: refutable pattern in local binding: `None` not covered LL | let Some(y) = x; | ^^^^^^^ pattern `None` not covered | - ::: $SRC_DIR/core/src/option.rs:LL:COL - | -LL | None, - | ---- not covered - | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html +note: `Option<i32>` defined here + --> $SRC_DIR/core/src/option.rs:LL:COL + | +LL | / pub enum Option<T> { +LL | | /// No value. +LL | | #[lang = "None"] +LL | | #[stable(feature = "rust1", since = "1.0.0")] +LL | | None, + | | ^^^^ not covered +... | +LL | | Some(#[stable(feature = "rust1", since = "1.0.0")] T), +LL | | } + | |_- = note: the matched value is of type `Option<i32>` help: you might want to use `if let` to ignore the variant that isn't matched | diff --git a/src/test/ui/error-codes/E0297.stderr b/src/test/ui/error-codes/E0297.stderr index 957e79a9f39..95d95003c61 100644 --- a/src/test/ui/error-codes/E0297.stderr +++ b/src/test/ui/error-codes/E0297.stderr @@ -4,11 +4,19 @@ error[E0005]: refutable pattern in `for` loop binding: `None` not covered LL | for Some(x) in xs {} | ^^^^^^^ pattern `None` not covered | - ::: $SRC_DIR/core/src/option.rs:LL:COL - | -LL | None, - | ---- not covered +note: `Option<i32>` defined here + --> $SRC_DIR/core/src/option.rs:LL:COL | +LL | / pub enum Option<T> { +LL | | /// No value. +LL | | #[lang = "None"] +LL | | #[stable(feature = "rust1", since = "1.0.0")] +LL | | None, + | | ^^^^ not covered +... | +LL | | Some(#[stable(feature = "rust1", since = "1.0.0")] T), +LL | | } + | |_- = note: the matched value is of type `Option<i32>` error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0507.stderr b/src/test/ui/error-codes/E0507.stderr index 3837e206169..ce8d1ef0349 100644 --- a/src/test/ui/error-codes/E0507.stderr +++ b/src/test/ui/error-codes/E0507.stderr @@ -2,7 +2,16 @@ error[E0507]: cannot move out of dereference of `Ref<'_, TheDarkKnight>` --> $DIR/E0507.rs:12:5 | LL | x.borrow().nothing_is_true(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ move occurs because value has type `TheDarkKnight`, which does not implement the `Copy` trait + | ^^^^^^^^^^^----------------- + | | | + | | value moved due to this method call + | move occurs because value has type `TheDarkKnight`, which does not implement the `Copy` trait + | +note: this function takes ownership of the receiver `self`, which moves value + --> $DIR/E0507.rs:6:24 + | +LL | fn nothing_is_true(self) {} + | ^^^^ error: aborting due to previous error diff --git a/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.stderr b/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.stderr index c5ffa55ebec..c2ffda6bb72 100644 --- a/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.stderr +++ b/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.stderr @@ -4,13 +4,20 @@ error[E0005]: refutable pattern in local binding: `Err(_)` not covered LL | let Ok(_x) = foo(); | ^^^^^^ pattern `Err(_)` not covered | - ::: $SRC_DIR/core/src/result.rs:LL:COL - | -LL | Err(#[stable(feature = "rust1", since = "1.0.0")] E), - | --- not covered - | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html +note: `Result<u32, !>` defined here + --> $SRC_DIR/core/src/result.rs:LL:COL + | +LL | / pub enum Result<T, E> { +LL | | /// Contains the success value +LL | | #[lang = "Ok"] +LL | | #[stable(feature = "rust1", since = "1.0.0")] +... | +LL | | Err(#[stable(feature = "rust1", since = "1.0.0")] E), + | | ^^^ not covered +LL | | } + | |_- = note: the matched value is of type `Result<u32, !>` help: you might want to use `if let` to ignore the variant that isn't matched | diff --git a/src/test/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr b/src/test/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr index 9895646fc2b..b5510683328 100644 --- a/src/test/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr +++ b/src/test/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr @@ -4,10 +4,14 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | match 0usize { | ^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `usize` = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ 0..=usize::MAX => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/feature-gate-precise_pointer_size_matching.rs:10:11 @@ -15,10 +19,14 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | match 0isize { | ^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `isize` = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ isize::MIN..=isize::MAX => {} +LL + _ => todo!() + | error: aborting due to 2 previous errors diff --git a/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.rs b/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.rs index 04f816ea501..667bc9f8ddf 100644 --- a/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.rs +++ b/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.rs @@ -2,6 +2,6 @@ #[rustc_variance] //~ ERROR the `#[rustc_variance]` attribute is just used for rustc unit tests and will never be stable #[rustc_error] //~ ERROR the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable -#[rustc_nonnull_optimization_guaranteed] //~ ERROR the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to enable niche optimizations in libcore and will never be stable +#[rustc_nonnull_optimization_guaranteed] //~ ERROR the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to enable niche optimizations in libcore and libstd and will never be stable fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.stderr b/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.stderr index 822368a5946..45a095903d2 100644 --- a/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.stderr +++ b/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.stderr @@ -14,7 +14,7 @@ LL | #[rustc_error] | = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable -error[E0658]: the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to enable niche optimizations in libcore and will never be stable +error[E0658]: the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to enable niche optimizations in libcore and libstd and will never be stable --> $DIR/feature-gate-rustc-attrs-1.rs:5:1 | LL | #[rustc_nonnull_optimization_guaranteed] diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.stderr b/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.stderr index 14dbca60b78..c2c77290c43 100644 --- a/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.stderr +++ b/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.stderr @@ -4,8 +4,12 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | m!(0f32, f32::NEG_INFINITY..); | ^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `f32` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ _ => todo!() } + | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:17:8 @@ -13,8 +17,12 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | m!(0f32, ..f32::INFINITY); | ^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `f32` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ _ => todo!() } + | error[E0004]: non-exhaustive patterns: `'\u{10ffff}'` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:26:8 @@ -22,8 +30,12 @@ error[E0004]: non-exhaustive patterns: `'\u{10ffff}'` not covered LL | m!('a', ..core::char::MAX); | ^^^ pattern `'\u{10ffff}'` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `char` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ '\u{10ffff}' => todo!() } + | error[E0004]: non-exhaustive patterns: `'\u{10fffe}'..='\u{10ffff}'` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:27:8 @@ -31,8 +43,12 @@ error[E0004]: non-exhaustive patterns: `'\u{10fffe}'..='\u{10ffff}'` not covered LL | m!('a', ..ALMOST_MAX); | ^^^ pattern `'\u{10fffe}'..='\u{10ffff}'` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `char` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ '\u{10fffe}'..='\u{10ffff}' => todo!() } + | error[E0004]: non-exhaustive patterns: `'\u{0}'` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:28:8 @@ -40,8 +56,12 @@ error[E0004]: non-exhaustive patterns: `'\u{0}'` not covered LL | m!('a', ALMOST_MIN..); | ^^^ pattern `'\u{0}'` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `char` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ '\u{0}' => todo!() } + | error[E0004]: non-exhaustive patterns: `'\u{10ffff}'` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:29:8 @@ -49,8 +69,12 @@ error[E0004]: non-exhaustive patterns: `'\u{10ffff}'` not covered LL | m!('a', ..=ALMOST_MAX); | ^^^ pattern `'\u{10ffff}'` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `char` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ '\u{10ffff}' => todo!() } + | error[E0004]: non-exhaustive patterns: `'b'` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:30:8 @@ -58,8 +82,12 @@ error[E0004]: non-exhaustive patterns: `'b'` not covered LL | m!('a', ..=VAL | VAL_2..); | ^^^ pattern `'b'` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `char` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 'b' => todo!() } + | error[E0004]: non-exhaustive patterns: `'b'` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:31:8 @@ -67,8 +95,12 @@ error[E0004]: non-exhaustive patterns: `'b'` not covered LL | m!('a', ..VAL_1 | VAL_2..); | ^^^ pattern `'b'` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `char` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 'b' => todo!() } + | error[E0004]: non-exhaustive patterns: `u8::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:41:12 @@ -76,8 +108,12 @@ error[E0004]: non-exhaustive patterns: `u8::MAX` not covered LL | m!(0, ..u8::MAX); | ^ pattern `u8::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ u8::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `254_u8..=u8::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:42:12 @@ -85,8 +121,12 @@ error[E0004]: non-exhaustive patterns: `254_u8..=u8::MAX` not covered LL | m!(0, ..ALMOST_MAX); | ^ pattern `254_u8..=u8::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 254_u8..=u8::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `0_u8` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:43:12 @@ -94,8 +134,12 @@ error[E0004]: non-exhaustive patterns: `0_u8` not covered LL | m!(0, ALMOST_MIN..); | ^ pattern `0_u8` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 0_u8 => todo!() } + | error[E0004]: non-exhaustive patterns: `u8::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:44:12 @@ -103,8 +147,12 @@ error[E0004]: non-exhaustive patterns: `u8::MAX` not covered LL | m!(0, ..=ALMOST_MAX); | ^ pattern `u8::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ u8::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `43_u8` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:45:12 @@ -112,8 +160,12 @@ error[E0004]: non-exhaustive patterns: `43_u8` not covered LL | m!(0, ..=VAL | VAL_2..); | ^ pattern `43_u8` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_u8 => todo!() } + | error[E0004]: non-exhaustive patterns: `43_u8` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:46:12 @@ -121,8 +173,12 @@ error[E0004]: non-exhaustive patterns: `43_u8` not covered LL | m!(0, ..VAL_1 | VAL_2..); | ^ pattern `43_u8` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_u8 => todo!() } + | error[E0004]: non-exhaustive patterns: `u16::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:54:12 @@ -130,8 +186,12 @@ error[E0004]: non-exhaustive patterns: `u16::MAX` not covered LL | m!(0, ..u16::MAX); | ^ pattern `u16::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u16` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ u16::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `65534_u16..=u16::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:55:12 @@ -139,8 +199,12 @@ error[E0004]: non-exhaustive patterns: `65534_u16..=u16::MAX` not covered LL | m!(0, ..ALMOST_MAX); | ^ pattern `65534_u16..=u16::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u16` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 65534_u16..=u16::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `0_u16` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:56:12 @@ -148,8 +212,12 @@ error[E0004]: non-exhaustive patterns: `0_u16` not covered LL | m!(0, ALMOST_MIN..); | ^ pattern `0_u16` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u16` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 0_u16 => todo!() } + | error[E0004]: non-exhaustive patterns: `u16::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:57:12 @@ -157,8 +225,12 @@ error[E0004]: non-exhaustive patterns: `u16::MAX` not covered LL | m!(0, ..=ALMOST_MAX); | ^ pattern `u16::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u16` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ u16::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `43_u16` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:58:12 @@ -166,8 +238,12 @@ error[E0004]: non-exhaustive patterns: `43_u16` not covered LL | m!(0, ..=VAL | VAL_2..); | ^ pattern `43_u16` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u16` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_u16 => todo!() } + | error[E0004]: non-exhaustive patterns: `43_u16` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:59:12 @@ -175,8 +251,12 @@ error[E0004]: non-exhaustive patterns: `43_u16` not covered LL | m!(0, ..VAL_1 | VAL_2..); | ^ pattern `43_u16` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u16` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_u16 => todo!() } + | error[E0004]: non-exhaustive patterns: `u32::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:67:12 @@ -184,8 +264,12 @@ error[E0004]: non-exhaustive patterns: `u32::MAX` not covered LL | m!(0, ..u32::MAX); | ^ pattern `u32::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u32` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ u32::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `4294967294_u32..=u32::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:68:12 @@ -193,8 +277,12 @@ error[E0004]: non-exhaustive patterns: `4294967294_u32..=u32::MAX` not covered LL | m!(0, ..ALMOST_MAX); | ^ pattern `4294967294_u32..=u32::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u32` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 4294967294_u32..=u32::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `0_u32` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:69:12 @@ -202,8 +290,12 @@ error[E0004]: non-exhaustive patterns: `0_u32` not covered LL | m!(0, ALMOST_MIN..); | ^ pattern `0_u32` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u32` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 0_u32 => todo!() } + | error[E0004]: non-exhaustive patterns: `u32::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:70:12 @@ -211,8 +303,12 @@ error[E0004]: non-exhaustive patterns: `u32::MAX` not covered LL | m!(0, ..=ALMOST_MAX); | ^ pattern `u32::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u32` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ u32::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `43_u32` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:71:12 @@ -220,8 +316,12 @@ error[E0004]: non-exhaustive patterns: `43_u32` not covered LL | m!(0, ..=VAL | VAL_2..); | ^ pattern `43_u32` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u32` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_u32 => todo!() } + | error[E0004]: non-exhaustive patterns: `43_u32` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:72:12 @@ -229,8 +329,12 @@ error[E0004]: non-exhaustive patterns: `43_u32` not covered LL | m!(0, ..VAL_1 | VAL_2..); | ^ pattern `43_u32` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u32` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_u32 => todo!() } + | error[E0004]: non-exhaustive patterns: `u64::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:80:12 @@ -238,8 +342,12 @@ error[E0004]: non-exhaustive patterns: `u64::MAX` not covered LL | m!(0, ..u64::MAX); | ^ pattern `u64::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u64` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ u64::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `18446744073709551614_u64..=u64::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:81:12 @@ -247,8 +355,12 @@ error[E0004]: non-exhaustive patterns: `18446744073709551614_u64..=u64::MAX` not LL | m!(0, ..ALMOST_MAX); | ^ pattern `18446744073709551614_u64..=u64::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u64` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 18446744073709551614_u64..=u64::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `0_u64` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:82:12 @@ -256,8 +368,12 @@ error[E0004]: non-exhaustive patterns: `0_u64` not covered LL | m!(0, ALMOST_MIN..); | ^ pattern `0_u64` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u64` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 0_u64 => todo!() } + | error[E0004]: non-exhaustive patterns: `u64::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:83:12 @@ -265,8 +381,12 @@ error[E0004]: non-exhaustive patterns: `u64::MAX` not covered LL | m!(0, ..=ALMOST_MAX); | ^ pattern `u64::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u64` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ u64::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `43_u64` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:84:12 @@ -274,8 +394,12 @@ error[E0004]: non-exhaustive patterns: `43_u64` not covered LL | m!(0, ..=VAL | VAL_2..); | ^ pattern `43_u64` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u64` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_u64 => todo!() } + | error[E0004]: non-exhaustive patterns: `43_u64` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:85:12 @@ -283,8 +407,12 @@ error[E0004]: non-exhaustive patterns: `43_u64` not covered LL | m!(0, ..VAL_1 | VAL_2..); | ^ pattern `43_u64` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u64` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_u64 => todo!() } + | error[E0004]: non-exhaustive patterns: `u128::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:93:12 @@ -292,8 +420,12 @@ error[E0004]: non-exhaustive patterns: `u128::MAX` not covered LL | m!(0, ..u128::MAX); | ^ pattern `u128::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u128` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ u128::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `340282366920938463463374607431768211454_u128..=u128::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:94:12 @@ -301,8 +433,12 @@ error[E0004]: non-exhaustive patterns: `340282366920938463463374607431768211454_ LL | m!(0, ..ALMOST_MAX); | ^ pattern `340282366920938463463374607431768211454_u128..=u128::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u128` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 340282366920938463463374607431768211454_u128..=u128::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `0_u128` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:95:12 @@ -310,8 +446,12 @@ error[E0004]: non-exhaustive patterns: `0_u128` not covered LL | m!(0, ALMOST_MIN..); | ^ pattern `0_u128` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u128` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 0_u128 => todo!() } + | error[E0004]: non-exhaustive patterns: `u128::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:96:12 @@ -319,8 +459,12 @@ error[E0004]: non-exhaustive patterns: `u128::MAX` not covered LL | m!(0, ..=ALMOST_MAX); | ^ pattern `u128::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u128` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ u128::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `43_u128` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:97:12 @@ -328,8 +472,12 @@ error[E0004]: non-exhaustive patterns: `43_u128` not covered LL | m!(0, ..=VAL | VAL_2..); | ^ pattern `43_u128` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u128` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_u128 => todo!() } + | error[E0004]: non-exhaustive patterns: `43_u128` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:98:12 @@ -337,8 +485,12 @@ error[E0004]: non-exhaustive patterns: `43_u128` not covered LL | m!(0, ..VAL_1 | VAL_2..); | ^ pattern `43_u128` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u128` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_u128 => todo!() } + | error[E0004]: non-exhaustive patterns: `i8::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:109:12 @@ -346,8 +498,12 @@ error[E0004]: non-exhaustive patterns: `i8::MAX` not covered LL | m!(0, ..i8::MAX); | ^ pattern `i8::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i8::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `126_i8..=i8::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:110:12 @@ -355,8 +511,12 @@ error[E0004]: non-exhaustive patterns: `126_i8..=i8::MAX` not covered LL | m!(0, ..ALMOST_MAX); | ^ pattern `126_i8..=i8::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 126_i8..=i8::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `i8::MIN` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:111:12 @@ -364,8 +524,12 @@ error[E0004]: non-exhaustive patterns: `i8::MIN` not covered LL | m!(0, ALMOST_MIN..); | ^ pattern `i8::MIN` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i8::MIN => todo!() } + | error[E0004]: non-exhaustive patterns: `i8::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:112:12 @@ -373,8 +537,12 @@ error[E0004]: non-exhaustive patterns: `i8::MAX` not covered LL | m!(0, ..=ALMOST_MAX); | ^ pattern `i8::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i8::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `43_i8` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:113:12 @@ -382,8 +550,12 @@ error[E0004]: non-exhaustive patterns: `43_i8` not covered LL | m!(0, ..=VAL | VAL_2..); | ^ pattern `43_i8` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_i8 => todo!() } + | error[E0004]: non-exhaustive patterns: `43_i8` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:114:12 @@ -391,8 +563,12 @@ error[E0004]: non-exhaustive patterns: `43_i8` not covered LL | m!(0, ..VAL_1 | VAL_2..); | ^ pattern `43_i8` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_i8 => todo!() } + | error[E0004]: non-exhaustive patterns: `i16::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:122:12 @@ -400,8 +576,12 @@ error[E0004]: non-exhaustive patterns: `i16::MAX` not covered LL | m!(0, ..i16::MAX); | ^ pattern `i16::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i16` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i16::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `32766_i16..=i16::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:123:12 @@ -409,8 +589,12 @@ error[E0004]: non-exhaustive patterns: `32766_i16..=i16::MAX` not covered LL | m!(0, ..ALMOST_MAX); | ^ pattern `32766_i16..=i16::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i16` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 32766_i16..=i16::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `i16::MIN` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:124:12 @@ -418,8 +602,12 @@ error[E0004]: non-exhaustive patterns: `i16::MIN` not covered LL | m!(0, ALMOST_MIN..); | ^ pattern `i16::MIN` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i16` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i16::MIN => todo!() } + | error[E0004]: non-exhaustive patterns: `i16::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:125:12 @@ -427,8 +615,12 @@ error[E0004]: non-exhaustive patterns: `i16::MAX` not covered LL | m!(0, ..=ALMOST_MAX); | ^ pattern `i16::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i16` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i16::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `43_i16` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:126:12 @@ -436,8 +628,12 @@ error[E0004]: non-exhaustive patterns: `43_i16` not covered LL | m!(0, ..=VAL | VAL_2..); | ^ pattern `43_i16` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i16` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_i16 => todo!() } + | error[E0004]: non-exhaustive patterns: `43_i16` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:127:12 @@ -445,8 +641,12 @@ error[E0004]: non-exhaustive patterns: `43_i16` not covered LL | m!(0, ..VAL_1 | VAL_2..); | ^ pattern `43_i16` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i16` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_i16 => todo!() } + | error[E0004]: non-exhaustive patterns: `i32::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:135:12 @@ -454,8 +654,12 @@ error[E0004]: non-exhaustive patterns: `i32::MAX` not covered LL | m!(0, ..i32::MAX); | ^ pattern `i32::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i32` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i32::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `2147483646_i32..=i32::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:136:12 @@ -463,8 +667,12 @@ error[E0004]: non-exhaustive patterns: `2147483646_i32..=i32::MAX` not covered LL | m!(0, ..ALMOST_MAX); | ^ pattern `2147483646_i32..=i32::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i32` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 2147483646_i32..=i32::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `i32::MIN` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:137:12 @@ -472,8 +680,12 @@ error[E0004]: non-exhaustive patterns: `i32::MIN` not covered LL | m!(0, ALMOST_MIN..); | ^ pattern `i32::MIN` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i32` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i32::MIN => todo!() } + | error[E0004]: non-exhaustive patterns: `i32::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:138:12 @@ -481,8 +693,12 @@ error[E0004]: non-exhaustive patterns: `i32::MAX` not covered LL | m!(0, ..=ALMOST_MAX); | ^ pattern `i32::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i32` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i32::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `43_i32` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:139:12 @@ -490,8 +706,12 @@ error[E0004]: non-exhaustive patterns: `43_i32` not covered LL | m!(0, ..=VAL | VAL_2..); | ^ pattern `43_i32` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i32` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_i32 => todo!() } + | error[E0004]: non-exhaustive patterns: `43_i32` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:140:12 @@ -499,8 +719,12 @@ error[E0004]: non-exhaustive patterns: `43_i32` not covered LL | m!(0, ..VAL_1 | VAL_2..); | ^ pattern `43_i32` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i32` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_i32 => todo!() } + | error[E0004]: non-exhaustive patterns: `i64::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:148:12 @@ -508,8 +732,12 @@ error[E0004]: non-exhaustive patterns: `i64::MAX` not covered LL | m!(0, ..i64::MAX); | ^ pattern `i64::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i64` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i64::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `9223372036854775806_i64..=i64::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:149:12 @@ -517,8 +745,12 @@ error[E0004]: non-exhaustive patterns: `9223372036854775806_i64..=i64::MAX` not LL | m!(0, ..ALMOST_MAX); | ^ pattern `9223372036854775806_i64..=i64::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i64` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 9223372036854775806_i64..=i64::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `i64::MIN` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:150:12 @@ -526,8 +758,12 @@ error[E0004]: non-exhaustive patterns: `i64::MIN` not covered LL | m!(0, ALMOST_MIN..); | ^ pattern `i64::MIN` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i64` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i64::MIN => todo!() } + | error[E0004]: non-exhaustive patterns: `i64::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:151:12 @@ -535,8 +771,12 @@ error[E0004]: non-exhaustive patterns: `i64::MAX` not covered LL | m!(0, ..=ALMOST_MAX); | ^ pattern `i64::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i64` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i64::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `43_i64` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:152:12 @@ -544,8 +784,12 @@ error[E0004]: non-exhaustive patterns: `43_i64` not covered LL | m!(0, ..=VAL | VAL_2..); | ^ pattern `43_i64` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i64` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_i64 => todo!() } + | error[E0004]: non-exhaustive patterns: `43_i64` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:153:12 @@ -553,8 +797,12 @@ error[E0004]: non-exhaustive patterns: `43_i64` not covered LL | m!(0, ..VAL_1 | VAL_2..); | ^ pattern `43_i64` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i64` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_i64 => todo!() } + | error[E0004]: non-exhaustive patterns: `i128::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:161:12 @@ -562,8 +810,12 @@ error[E0004]: non-exhaustive patterns: `i128::MAX` not covered LL | m!(0, ..i128::MAX); | ^ pattern `i128::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i128` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i128::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `170141183460469231731687303715884105726_i128..=i128::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:162:12 @@ -571,8 +823,12 @@ error[E0004]: non-exhaustive patterns: `170141183460469231731687303715884105726_ LL | m!(0, ..ALMOST_MAX); | ^ pattern `170141183460469231731687303715884105726_i128..=i128::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i128` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 170141183460469231731687303715884105726_i128..=i128::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `i128::MIN` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:163:12 @@ -580,8 +836,12 @@ error[E0004]: non-exhaustive patterns: `i128::MIN` not covered LL | m!(0, ALMOST_MIN..); | ^ pattern `i128::MIN` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i128` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i128::MIN => todo!() } + | error[E0004]: non-exhaustive patterns: `i128::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:164:12 @@ -589,8 +849,12 @@ error[E0004]: non-exhaustive patterns: `i128::MAX` not covered LL | m!(0, ..=ALMOST_MAX); | ^ pattern `i128::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i128` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i128::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `43_i128` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:165:12 @@ -598,8 +862,12 @@ error[E0004]: non-exhaustive patterns: `43_i128` not covered LL | m!(0, ..=VAL | VAL_2..); | ^ pattern `43_i128` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i128` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_i128 => todo!() } + | error[E0004]: non-exhaustive patterns: `43_i128` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:166:12 @@ -607,8 +875,12 @@ error[E0004]: non-exhaustive patterns: `43_i128` not covered LL | m!(0, ..VAL_1 | VAL_2..); | ^ pattern `43_i128` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i128` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 43_i128 => todo!() } + | error: aborting due to 68 previous errors diff --git a/src/test/ui/impl-trait/issues/issue-79099.stderr b/src/test/ui/impl-trait/issues/issue-79099.stderr index 4c9ec2a83ff..362c67dafd2 100644 --- a/src/test/ui/impl-trait/issues/issue-79099.stderr +++ b/src/test/ui/impl-trait/issues/issue-79099.stderr @@ -6,7 +6,7 @@ LL | let f: impl core::future::Future<Output = u8> = async { 1 }; | | | `async` blocks are only allowed in Rust 2018 or later | - = help: set `edition = "2021"` in `Cargo.toml` + = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding diff --git a/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs b/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs index 3d8478f06db..6eabd9b1015 100644 --- a/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs +++ b/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs @@ -29,6 +29,11 @@ extern { #[rustc_legacy_const_generics(0)] //~ ERROR #[rustc_legacy_const_generics] functions must only have fn foo8<X>() {} +impl S { + #[rustc_legacy_const_generics(0)] //~ ERROR attribute should be applied to a function + fn foo9<const X: usize>() {} +} + #[rustc_legacy_const_generics] //~ ERROR malformed `rustc_legacy_const_generics` attribute fn bar1() {} diff --git a/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr b/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr index 1f55a8e72d2..bfe7bb2e10d 100644 --- a/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr +++ b/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr @@ -7,13 +7,13 @@ LL | #[rustc_legacy_const_generics(0usize)] = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: malformed `rustc_legacy_const_generics` attribute input - --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:32:1 + --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:37:1 | LL | #[rustc_legacy_const_generics] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_legacy_const_generics(N)]` error: malformed `rustc_legacy_const_generics` attribute input - --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:35:1 + --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:40:1 | LL | #[rustc_legacy_const_generics = 1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_legacy_const_generics(N)]` @@ -67,6 +67,14 @@ LL | fn foo8<X>() {} | - non-const generic parameter error: attribute should be applied to a function + --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:33:5 + | +LL | #[rustc_legacy_const_generics(0)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo9<const X: usize>() {} + | ---------------------------- not a function + +error: attribute should be applied to a function --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:25:5 | LL | #[rustc_legacy_const_generics(1)] @@ -82,6 +90,6 @@ LL | fn foo7<const X: usize>(); | = help: replace the const parameters with concrete consts -error: aborting due to 12 previous errors +error: aborting due to 13 previous errors For more information about this error, try `rustc --explain E0044`. diff --git a/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.stderr b/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.stderr index 7895cefb4cb..a0d32616f83 100644 --- a/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.stderr +++ b/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.stderr @@ -2,10 +2,8 @@ error[E0507]: cannot move out of `foo` in pattern guard --> $DIR/issue-27282-move-ref-mut-into-guard.rs:9:19 | LL | if { (|| { let bar = foo; bar.take() })(); false } => {}, - | ^^ --- - | | | - | | move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait - | | move occurs due to use in closure + | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait + | | | move out of `foo` occurs here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard diff --git a/src/test/ui/issues/issue-61108.stderr b/src/test/ui/issues/issue-61108.stderr index 6f345f56d1a..e5b671d7b7a 100644 --- a/src/test/ui/issues/issue-61108.stderr +++ b/src/test/ui/issues/issue-61108.stderr @@ -4,10 +4,7 @@ error[E0382]: borrow of moved value: `bad_letters` LL | let mut bad_letters = vec!['e', 't', 'o', 'i']; | --------------- move occurs because `bad_letters` has type `Vec<char>`, which does not implement the `Copy` trait LL | for l in bad_letters { - | ----------- - | | - | `bad_letters` moved due to this implicit call to `.into_iter()` - | help: consider borrowing to avoid moving into the for loop: `&bad_letters` + | ----------- `bad_letters` moved due to this implicit call to `.into_iter()` ... LL | bad_letters.push('s'); | ^^^^^^^^^^^^^^^^^^^^^ value borrowed here after move @@ -17,6 +14,10 @@ note: this function takes ownership of the receiver `self`, which moves `bad_let | LL | fn into_iter(self) -> Self::IntoIter; | ^^^^ +help: consider iterating over a slice of the `Vec<char>`'s content to avoid moving into the `for` loop + | +LL | for l in &bad_letters { + | + error: aborting due to previous error diff --git a/src/test/ui/issues/issue-64559.stderr b/src/test/ui/issues/issue-64559.stderr index e0da3fd5195..ef178bbd155 100644 --- a/src/test/ui/issues/issue-64559.stderr +++ b/src/test/ui/issues/issue-64559.stderr @@ -4,10 +4,7 @@ error[E0382]: use of moved value: `orig` LL | let orig = vec![true]; | ---- move occurs because `orig` has type `Vec<bool>`, which does not implement the `Copy` trait LL | for _val in orig {} - | ---- - | | - | `orig` moved due to this implicit call to `.into_iter()` - | help: consider borrowing to avoid moving into the for loop: `&orig` + | ---- `orig` moved due to this implicit call to `.into_iter()` LL | let _closure = || orig; | ^^ ---- use occurs due to use in closure | | @@ -18,6 +15,10 @@ note: this function takes ownership of the receiver `self`, which moves `orig` | LL | fn into_iter(self) -> Self::IntoIter; | ^^^^ +help: consider iterating over a slice of the `Vec<bool>`'s content to avoid moving into the `for` loop + | +LL | for _val in &orig {} + | + error: aborting due to previous error diff --git a/src/test/ui/issues/issue-87707.rs b/src/test/ui/issues/issue-87707.rs index d2e9343f86c..26e9e2c8f91 100644 --- a/src/test/ui/issues/issue-87707.rs +++ b/src/test/ui/issues/issue-87707.rs @@ -1,6 +1,7 @@ // test for #87707 // edition:2018 // run-fail +// exec-env:RUST_BACKTRACE=0 // check-run-results use std::sync::Once; diff --git a/src/test/ui/issues/issue-87707.run.stderr b/src/test/ui/issues/issue-87707.run.stderr index 8f82ccc0c2a..e6c9ea0eb53 100644 --- a/src/test/ui/issues/issue-87707.run.stderr +++ b/src/test/ui/issues/issue-87707.run.stderr @@ -1,3 +1,3 @@ -thread 'main' panicked at 'Here Once instance is poisoned.', $DIR/issue-87707.rs:12:24 +thread 'main' panicked at 'Here Once instance is poisoned.', $DIR/issue-87707.rs:13:24 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' panicked at 'Once instance has previously been poisoned', $DIR/issue-87707.rs:14:7 +thread 'main' panicked at 'Once instance has previously been poisoned', $DIR/issue-87707.rs:15:7 diff --git a/src/test/ui/lint/rfc-2383-lint-reason/lint-attribute-only-with-reason.rs b/src/test/ui/lint/rfc-2383-lint-reason/lint-attribute-only-with-reason.rs new file mode 100644 index 00000000000..bafdea96e08 --- /dev/null +++ b/src/test/ui/lint/rfc-2383-lint-reason/lint-attribute-only-with-reason.rs @@ -0,0 +1,14 @@ +#![feature(lint_reasons)] + +#![deny(unused_attributes)] + +#[allow(reason = "I want to allow something")]//~ ERROR unused attribute +#[expect(reason = "I don't know what I'm waiting for")]//~ ERROR unused attribute +#[warn(reason = "This should be warn by default")]//~ ERROR unused attribute +#[deny(reason = "All listed lints are denied")]//~ ERROR unused attribute +#[forbid(reason = "Just some reason")]//~ ERROR unused attribute + +#[allow(clippy::box_collection, reason = "This is still valid")] +#[warn(dead_code, reason = "This is also reasonable")] + +fn main() {} diff --git a/src/test/ui/lint/rfc-2383-lint-reason/lint-attribute-only-with-reason.stderr b/src/test/ui/lint/rfc-2383-lint-reason/lint-attribute-only-with-reason.stderr new file mode 100644 index 00000000000..3bf8137dc6e --- /dev/null +++ b/src/test/ui/lint/rfc-2383-lint-reason/lint-attribute-only-with-reason.stderr @@ -0,0 +1,47 @@ +error: unused attribute + --> $DIR/lint-attribute-only-with-reason.rs:5:1 + | +LL | #[allow(reason = "I want to allow something")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: the lint level is defined here + --> $DIR/lint-attribute-only-with-reason.rs:3:9 + | +LL | #![deny(unused_attributes)] + | ^^^^^^^^^^^^^^^^^ + = note: attribute `allow` without any lints has no effect + +error: unused attribute + --> $DIR/lint-attribute-only-with-reason.rs:6:1 + | +LL | #[expect(reason = "I don't know what I'm waiting for")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | + = note: attribute `expect` without any lints has no effect + +error: unused attribute + --> $DIR/lint-attribute-only-with-reason.rs:7:1 + | +LL | #[warn(reason = "This should be warn by default")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | + = note: attribute `warn` without any lints has no effect + +error: unused attribute + --> $DIR/lint-attribute-only-with-reason.rs:8:1 + | +LL | #[deny(reason = "All listed lints are denied")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | + = note: attribute `deny` without any lints has no effect + +error: unused attribute + --> $DIR/lint-attribute-only-with-reason.rs:9:1 + | +LL | #[forbid(reason = "Just some reason")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | + = note: attribute `forbid` without any lints has no effect + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/loops/issue-82916.stderr b/src/test/ui/loops/issue-82916.stderr index ad42cce71f6..57d76016c45 100644 --- a/src/test/ui/loops/issue-82916.stderr +++ b/src/test/ui/loops/issue-82916.stderr @@ -4,10 +4,7 @@ error[E0382]: use of moved value: `x` LL | fn foo(x: Vec<S>) { | - move occurs because `x` has type `Vec<S>`, which does not implement the `Copy` trait LL | for y in x { - | - - | | - | `x` moved due to this implicit call to `.into_iter()` - | help: consider borrowing to avoid moving into the for loop: `&x` + | - `x` moved due to this implicit call to `.into_iter()` ... LL | let z = x; | ^ value used here after move @@ -17,6 +14,10 @@ note: this function takes ownership of the receiver `self`, which moves `x` | LL | fn into_iter(self) -> Self::IntoIter; | ^^^^ +help: consider iterating over a slice of the `Vec<S>`'s content to avoid moving into the `for` loop + | +LL | for y in &x { + | + error: aborting due to previous error diff --git a/src/test/ui/match/match_non_exhaustive.stderr b/src/test/ui/match/match_non_exhaustive.stderr index 5debfe1c566..6206dc85ea0 100644 --- a/src/test/ui/match/match_non_exhaustive.stderr +++ b/src/test/ui/match/match_non_exhaustive.stderr @@ -1,17 +1,19 @@ error[E0004]: non-exhaustive patterns: `B` not covered --> $DIR/match_non_exhaustive.rs:23:11 | -LL | enum L { A, B } - | --------------- - | | | - | | not covered - | `L` defined here -... LL | match l { L::A => () }; | ^ pattern `B` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `L` defined here + --> $DIR/match_non_exhaustive.rs:10:13 + | +LL | enum L { A, B } + | - ^ not covered = note: the matched value is of type `L` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL | match l { L::A => (), B => todo!() }; + | ++++++++++++++ error[E0004]: non-exhaustive patterns: type `E1` is non-empty --> $DIR/match_non_exhaustive.rs:28:11 @@ -19,8 +21,18 @@ error[E0004]: non-exhaustive patterns: type `E1` is non-empty LL | match e1 {}; | ^^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `E1` defined here + --> $DIR/auxiliary/match_non_exhaustive_lib.rs:2:1 + | +LL | pub enum E1 {} + | ^^^^^^^^^^^^^^ = note: the matched value is of type `E1`, which is marked as non-exhaustive +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match e1 { +LL + _ => todo!(), +LL ~ }; + | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/match_non_exhaustive.rs:30:11 @@ -28,8 +40,16 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | match e2 { E2::A => (), E2::B => () }; | ^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `E2` defined here + --> $DIR/auxiliary/match_non_exhaustive_lib.rs:5:1 + | +LL | pub enum E2 { A, B } + | ^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `E2`, which is marked as non-exhaustive +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL | match e2 { E2::A => (), E2::B => (), _ => todo!() }; + | ++++++++++++++ error: aborting due to 3 previous errors diff --git a/src/test/ui/moves/issue-46099-move-in-macro.stderr b/src/test/ui/moves/issue-46099-move-in-macro.stderr index db4c3979e3a..baa87e3e9fd 100644 --- a/src/test/ui/moves/issue-46099-move-in-macro.stderr +++ b/src/test/ui/moves/issue-46099-move-in-macro.stderr @@ -4,10 +4,7 @@ error[E0382]: use of moved value: `b` LL | let b = Box::new(true); | - move occurs because `b` has type `Box<bool>`, which does not implement the `Copy` trait LL | test!({b}); - | ^ - | | - | value moved here - | value used here after move + | ^ value used here after move error: aborting due to previous error diff --git a/src/test/ui/moves/move-fn-self-receiver.stderr b/src/test/ui/moves/move-fn-self-receiver.stderr index 57be5fb4d8a..3a686121a92 100644 --- a/src/test/ui/moves/move-fn-self-receiver.stderr +++ b/src/test/ui/moves/move-fn-self-receiver.stderr @@ -119,12 +119,14 @@ error[E0382]: use of moved value: `implicit_into_iter` LL | let implicit_into_iter = vec![true]; | ------------------ move occurs because `implicit_into_iter` has type `Vec<bool>`, which does not implement the `Copy` trait LL | for _val in implicit_into_iter {} - | ------------------ - | | - | `implicit_into_iter` moved due to this implicit call to `.into_iter()` - | help: consider borrowing to avoid moving into the for loop: `&implicit_into_iter` + | ------------------ `implicit_into_iter` moved due to this implicit call to `.into_iter()` LL | implicit_into_iter; | ^^^^^^^^^^^^^^^^^^ value used here after move + | +help: consider iterating over a slice of the `Vec<bool>`'s content to avoid moving into the `for` loop + | +LL | for _val in &implicit_into_iter {} + | + error[E0382]: use of moved value: `explicit_into_iter` --> $DIR/move-fn-self-receiver.rs:67:5 diff --git a/src/test/ui/moves/move-in-guard-2.stderr b/src/test/ui/moves/move-in-guard-2.stderr index ea350926b15..8d636c11b78 100644 --- a/src/test/ui/moves/move-in-guard-2.stderr +++ b/src/test/ui/moves/move-in-guard-2.stderr @@ -5,10 +5,7 @@ LL | let x: Box<_> = Box::new(1); | - move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait ... LL | (_, 2) if take(x) => (), - | ^ - | | - | value moved here - | value used here after move + | ^ value used here after move error: aborting due to previous error diff --git a/src/test/ui/nll/match-guards-always-borrow.stderr b/src/test/ui/nll/match-guards-always-borrow.stderr index df6d65056ac..c0fb5f65382 100644 --- a/src/test/ui/nll/match-guards-always-borrow.stderr +++ b/src/test/ui/nll/match-guards-always-borrow.stderr @@ -2,10 +2,8 @@ error[E0507]: cannot move out of `foo` in pattern guard --> $DIR/match-guards-always-borrow.rs:8:14 | LL | (|| { let bar = foo; bar.take() })(); - | ^^ --- - | | | - | | move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait - | | move occurs due to use in closure + | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait + | | | move out of `foo` occurs here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard diff --git a/src/test/ui/on-unimplemented/impl-substs.rs b/src/test/ui/on-unimplemented/impl-substs.rs new file mode 100644 index 00000000000..fe9c50ec3d4 --- /dev/null +++ b/src/test/ui/on-unimplemented/impl-substs.rs @@ -0,0 +1,15 @@ +#![feature(rustc_attrs)] + +trait Foo<A> { + fn foo(self); +} + +#[rustc_on_unimplemented = "an impl did not match: {A} {B} {C}"] +impl<A, B, C> Foo<A> for (A, B, C) { + fn foo(self) {} +} + +fn main() { + Foo::<usize>::foo((1i32, 1i32, 1i32)); + //~^ ERROR the trait bound `(i32, i32, i32): Foo<usize>` is not satisfied +} diff --git a/src/test/ui/on-unimplemented/impl-substs.stderr b/src/test/ui/on-unimplemented/impl-substs.stderr new file mode 100644 index 00000000000..db66ab0bfae --- /dev/null +++ b/src/test/ui/on-unimplemented/impl-substs.stderr @@ -0,0 +1,13 @@ +error[E0277]: the trait bound `(i32, i32, i32): Foo<usize>` is not satisfied + --> $DIR/impl-substs.rs:13:23 + | +LL | Foo::<usize>::foo((1i32, 1i32, 1i32)); + | ----------------- ^^^^^^^^^^^^^^^^^^ an impl did not match: usize _ _ + | | + | required by a bound introduced by this call + | + = help: the trait `Foo<usize>` is not implemented for `(i32, i32, i32)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.stderr b/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.stderr index 44f334eee93..9aa808e6bc9 100644 --- a/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.stderr +++ b/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.stderr @@ -4,8 +4,12 @@ error[E0004]: non-exhaustive patterns: `(2_u8..=u8::MAX, _)` not covered LL | match (0u8, 0u8) { | ^^^^^^^^^^ pattern `(2_u8..=u8::MAX, _)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(u8, u8)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ (0 | 1, 2 | 3) => {} +LL + (2_u8..=u8::MAX, _) => todo!() + | error[E0004]: non-exhaustive patterns: `((4_u8..=u8::MAX))` not covered --> $DIR/exhaustiveness-non-exhaustive.rs:9:11 @@ -13,8 +17,12 @@ error[E0004]: non-exhaustive patterns: `((4_u8..=u8::MAX))` not covered LL | match ((0u8,),) { | ^^^^^^^^^ pattern `((4_u8..=u8::MAX))` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `((u8,),)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ ((0 | 1,) | (2 | 3,),) => {} +LL + ((4_u8..=u8::MAX)) => todo!() + | error[E0004]: non-exhaustive patterns: `(Some(2_u8..=u8::MAX))` not covered --> $DIR/exhaustiveness-non-exhaustive.rs:13:11 @@ -22,8 +30,12 @@ error[E0004]: non-exhaustive patterns: `(Some(2_u8..=u8::MAX))` not covered LL | match (Some(0u8),) { | ^^^^^^^^^^^^ pattern `(Some(2_u8..=u8::MAX))` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(Option<u8>,)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ (None | Some(0 | 1),) => {} +LL + (Some(2_u8..=u8::MAX)) => todo!() + | error: aborting due to 3 previous errors diff --git a/src/test/ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.stderr b/src/test/ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.stderr index 8e6964e3062..37a35700b36 100644 --- a/src/test/ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.stderr +++ b/src/test/ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.stderr @@ -18,8 +18,12 @@ error[E0004]: non-exhaustive patterns: `i32::MIN..=-1_i32` and `3_i32..=i32::MAX LL | match 0 { | ^ patterns `i32::MIN..=-1_i32` and `3_i32..=i32::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i32` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ 0 | (1 | 2) => {} +LL + i32::MIN..=-1_i32 | 3_i32..=i32::MAX => todo!() + | error: aborting due to 2 previous errors diff --git a/src/test/ui/pattern/usefulness/always-inhabited-union-ref.stderr b/src/test/ui/pattern/usefulness/always-inhabited-union-ref.stderr index 2ca774a48b6..cd5c283f9fd 100644 --- a/src/test/ui/pattern/usefulness/always-inhabited-union-ref.stderr +++ b/src/test/ui/pattern/usefulness/always-inhabited-union-ref.stderr @@ -4,23 +4,33 @@ error[E0004]: non-exhaustive patterns: type `&!` is non-empty LL | match uninhab_ref() { | ^^^^^^^^^^^^^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&!` = note: references are always considered inhabited +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match uninhab_ref() { +LL + _ => todo!(), +LL + } + | error[E0004]: non-exhaustive patterns: type `Foo` is non-empty --> $DIR/always-inhabited-union-ref.rs:27:11 | -LL | / pub union Foo { -LL | | foo: !, -LL | | } - | |_- `Foo` defined here -... -LL | match uninhab_union() { - | ^^^^^^^^^^^^^^^ +LL | match uninhab_union() { + | ^^^^^^^^^^^^^^^ + | +note: `Foo` defined here + --> $DIR/always-inhabited-union-ref.rs:10:11 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | pub union Foo { + | ^^^ = note: the matched value is of type `Foo` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match uninhab_union() { +LL + _ => todo!(), +LL + } + | error: aborting due to 2 previous errors diff --git a/src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr b/src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr index 6c9539822b3..7d0b71a497e 100644 --- a/src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr +++ b/src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr @@ -4,8 +4,22 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | match Foo::A { | ^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `Foo` defined here + --> $DIR/auxiliary/hidden.rs:1:1 + | +LL | / pub enum Foo { +LL | | A, +LL | | B, +LL | | #[doc(hidden)] +LL | | C, +LL | | } + | |_^ = note: the matched value is of type `Foo` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ Foo::B => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `B` not covered --> $DIR/doc-hidden-non-exhaustive.rs:14:11 @@ -13,13 +27,23 @@ error[E0004]: non-exhaustive patterns: `B` not covered LL | match Foo::A { | ^^^^^^ pattern `B` not covered | - ::: $DIR/auxiliary/hidden.rs:3:5 +note: `Foo` defined here + --> $DIR/auxiliary/hidden.rs:3:5 | -LL | B, - | - not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | / pub enum Foo { +LL | | A, +LL | | B, + | | ^ not covered +LL | | #[doc(hidden)] +LL | | C, +LL | | } + | |_- = note: the matched value is of type `Foo` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ Foo::C => {} +LL + B => todo!() + | error[E0004]: non-exhaustive patterns: `B` and `_` not covered --> $DIR/doc-hidden-non-exhaustive.rs:20:11 @@ -27,13 +51,23 @@ error[E0004]: non-exhaustive patterns: `B` and `_` not covered LL | match Foo::A { | ^^^^^^ patterns `B` and `_` not covered | - ::: $DIR/auxiliary/hidden.rs:3:5 +note: `Foo` defined here + --> $DIR/auxiliary/hidden.rs:3:5 | -LL | B, - | - not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | / pub enum Foo { +LL | | A, +LL | | B, + | | ^ not covered +LL | | #[doc(hidden)] +LL | | C, +LL | | } + | |_- = note: the matched value is of type `Foo` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ Foo::A => {} +LL + B | _ => todo!() + | error[E0004]: non-exhaustive patterns: `Some(B)` and `Some(_)` not covered --> $DIR/doc-hidden-non-exhaustive.rs:25:11 @@ -41,13 +75,24 @@ error[E0004]: non-exhaustive patterns: `Some(B)` and `Some(_)` not covered LL | match None { | ^^^^ patterns `Some(B)` and `Some(_)` not covered | - ::: $SRC_DIR/core/src/option.rs:LL:COL +note: `Option<Foo>` defined here + --> $SRC_DIR/core/src/option.rs:LL:COL | -LL | Some(#[stable(feature = "rust1", since = "1.0.0")] T), - | ---- not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | / pub enum Option<T> { +LL | | /// No value. +LL | | #[lang = "None"] +LL | | #[stable(feature = "rust1", since = "1.0.0")] +... | +LL | | Some(#[stable(feature = "rust1", since = "1.0.0")] T), + | | ^^^^ not covered +LL | | } + | |_- = note: the matched value is of type `Option<Foo>` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ Some(Foo::A) => {} +LL + Some(B) | Some(_) => todo!() + | error: aborting due to 4 previous errors diff --git a/src/test/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr b/src/test/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr index b99386e7402..d31ee0dbd14 100644 --- a/src/test/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr +++ b/src/test/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr @@ -46,107 +46,112 @@ error[E0004]: non-exhaustive patterns: type `u8` is non-empty LL | match_no_arms!(0u8); | ^^^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` + = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: type `NonEmptyStruct1` is non-empty --> $DIR/empty-match.rs:79:20 | -LL | struct NonEmptyStruct1; - | ----------------------- `NonEmptyStruct1` defined here -... LL | match_no_arms!(NonEmptyStruct1); | ^^^^^^^^^^^^^^^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `NonEmptyStruct1` defined here + --> $DIR/empty-match.rs:14:8 + | +LL | struct NonEmptyStruct1; + | ^^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyStruct1` + = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: type `NonEmptyStruct2` is non-empty --> $DIR/empty-match.rs:80:20 | -LL | struct NonEmptyStruct2(bool); - | ----------------------------- `NonEmptyStruct2` defined here -... LL | match_no_arms!(NonEmptyStruct2(true)); | ^^^^^^^^^^^^^^^^^^^^^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `NonEmptyStruct2` defined here + --> $DIR/empty-match.rs:15:8 + | +LL | struct NonEmptyStruct2(bool); + | ^^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyStruct2` + = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty --> $DIR/empty-match.rs:81:20 | -LL | / union NonEmptyUnion1 { -LL | | foo: (), -LL | | } - | |_- `NonEmptyUnion1` defined here -... -LL | match_no_arms!((NonEmptyUnion1 { foo: () })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | match_no_arms!((NonEmptyUnion1 { foo: () })); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: `NonEmptyUnion1` defined here + --> $DIR/empty-match.rs:16:7 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | union NonEmptyUnion1 { + | ^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyUnion1` + = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty --> $DIR/empty-match.rs:82:20 | -LL | / union NonEmptyUnion2 { -LL | | foo: (), -LL | | bar: (), -LL | | } - | |_- `NonEmptyUnion2` defined here -... -LL | match_no_arms!((NonEmptyUnion2 { foo: () })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | match_no_arms!((NonEmptyUnion2 { foo: () })); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: `NonEmptyUnion2` defined here + --> $DIR/empty-match.rs:19:7 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | union NonEmptyUnion2 { + | ^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyUnion2` + = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: `Foo(_)` not covered --> $DIR/empty-match.rs:83:20 | -LL | / enum NonEmptyEnum1 { -LL | | Foo(bool), - | | --- not covered -LL | | } - | |_- `NonEmptyEnum1` defined here -... -LL | match_no_arms!(NonEmptyEnum1::Foo(true)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo(_)` not covered +LL | match_no_arms!(NonEmptyEnum1::Foo(true)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo(_)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `NonEmptyEnum1` defined here + --> $DIR/empty-match.rs:24:5 + | +LL | enum NonEmptyEnum1 { + | ------------- +LL | Foo(bool), + | ^^^ not covered = note: the matched value is of type `NonEmptyEnum1` + = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern error[E0004]: non-exhaustive patterns: `Foo(_)` and `Bar` not covered --> $DIR/empty-match.rs:84:20 | -LL | / enum NonEmptyEnum2 { -LL | | Foo(bool), - | | --- not covered -LL | | Bar, - | | --- not covered -LL | | } - | |_- `NonEmptyEnum2` defined here -... -LL | match_no_arms!(NonEmptyEnum2::Foo(true)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo(_)` and `Bar` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | match_no_arms!(NonEmptyEnum2::Foo(true)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo(_)` and `Bar` not covered + | +note: `NonEmptyEnum2` defined here + --> $DIR/empty-match.rs:27:5 + | +LL | enum NonEmptyEnum2 { + | ------------- +LL | Foo(bool), + | ^^^ not covered +LL | Bar, + | ^^^ not covered = note: the matched value is of type `NonEmptyEnum2` + = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms error[E0004]: non-exhaustive patterns: `V1`, `V2`, `V3` and 2 more not covered --> $DIR/empty-match.rs:85:20 | -LL | / enum NonEmptyEnum5 { -LL | | V1, V2, V3, V4, V5, -LL | | } - | |_- `NonEmptyEnum5` defined here -... -LL | match_no_arms!(NonEmptyEnum5::V1); - | ^^^^^^^^^^^^^^^^^ patterns `V1`, `V2`, `V3` and 2 more not covered +LL | match_no_arms!(NonEmptyEnum5::V1); + | ^^^^^^^^^^^^^^^^^ patterns `V1`, `V2`, `V3` and 2 more not covered + | +note: `NonEmptyEnum5` defined here + --> $DIR/empty-match.rs:30:6 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | enum NonEmptyEnum5 { + | ^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyEnum5` + = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/empty-match.rs:87:24 @@ -154,107 +159,144 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | match_guarded_arm!(0u8); | ^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ _ if false => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `NonEmptyStruct1` not covered --> $DIR/empty-match.rs:88:24 | -LL | struct NonEmptyStruct1; - | ----------------------- `NonEmptyStruct1` defined here -... LL | match_guarded_arm!(NonEmptyStruct1); | ^^^^^^^^^^^^^^^ pattern `NonEmptyStruct1` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `NonEmptyStruct1` defined here + --> $DIR/empty-match.rs:14:8 + | +LL | struct NonEmptyStruct1; + | ^^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyStruct1` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ _ if false => {} +LL + NonEmptyStruct1 => todo!() + | error[E0004]: non-exhaustive patterns: `NonEmptyStruct2(_)` not covered --> $DIR/empty-match.rs:89:24 | -LL | struct NonEmptyStruct2(bool); - | ----------------------------- `NonEmptyStruct2` defined here -... LL | match_guarded_arm!(NonEmptyStruct2(true)); | ^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct2(_)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `NonEmptyStruct2` defined here + --> $DIR/empty-match.rs:15:8 + | +LL | struct NonEmptyStruct2(bool); + | ^^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyStruct2` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ _ if false => {} +LL + NonEmptyStruct2(_) => todo!() + | error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered --> $DIR/empty-match.rs:90:24 | -LL | / union NonEmptyUnion1 { -LL | | foo: (), -LL | | } - | |_- `NonEmptyUnion1` defined here -... -LL | match_guarded_arm!((NonEmptyUnion1 { foo: () })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered +LL | match_guarded_arm!((NonEmptyUnion1 { foo: () })); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered + | +note: `NonEmptyUnion1` defined here + --> $DIR/empty-match.rs:16:7 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | union NonEmptyUnion1 { + | ^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyUnion1` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ _ if false => {} +LL + NonEmptyUnion1 { .. } => todo!() + | error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered --> $DIR/empty-match.rs:91:24 | -LL | / union NonEmptyUnion2 { -LL | | foo: (), -LL | | bar: (), -LL | | } - | |_- `NonEmptyUnion2` defined here -... -LL | match_guarded_arm!((NonEmptyUnion2 { foo: () })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered +LL | match_guarded_arm!((NonEmptyUnion2 { foo: () })); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered + | +note: `NonEmptyUnion2` defined here + --> $DIR/empty-match.rs:19:7 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | union NonEmptyUnion2 { + | ^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyUnion2` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ _ if false => {} +LL + NonEmptyUnion2 { .. } => todo!() + | error[E0004]: non-exhaustive patterns: `Foo(_)` not covered --> $DIR/empty-match.rs:92:24 | -LL | / enum NonEmptyEnum1 { -LL | | Foo(bool), - | | --- not covered -LL | | } - | |_- `NonEmptyEnum1` defined here -... -LL | match_guarded_arm!(NonEmptyEnum1::Foo(true)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo(_)` not covered +LL | match_guarded_arm!(NonEmptyEnum1::Foo(true)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo(_)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `NonEmptyEnum1` defined here + --> $DIR/empty-match.rs:24:5 + | +LL | enum NonEmptyEnum1 { + | ------------- +LL | Foo(bool), + | ^^^ not covered = note: the matched value is of type `NonEmptyEnum1` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ _ if false => {} +LL + Foo(_) => todo!() + | error[E0004]: non-exhaustive patterns: `Foo(_)` and `Bar` not covered --> $DIR/empty-match.rs:93:24 | -LL | / enum NonEmptyEnum2 { -LL | | Foo(bool), - | | --- not covered -LL | | Bar, - | | --- not covered -LL | | } - | |_- `NonEmptyEnum2` defined here -... -LL | match_guarded_arm!(NonEmptyEnum2::Foo(true)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo(_)` and `Bar` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | match_guarded_arm!(NonEmptyEnum2::Foo(true)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo(_)` and `Bar` not covered + | +note: `NonEmptyEnum2` defined here + --> $DIR/empty-match.rs:27:5 + | +LL | enum NonEmptyEnum2 { + | ------------- +LL | Foo(bool), + | ^^^ not covered +LL | Bar, + | ^^^ not covered = note: the matched value is of type `NonEmptyEnum2` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ _ if false => {} +LL + Foo(_) | Bar => todo!() + | error[E0004]: non-exhaustive patterns: `V1`, `V2`, `V3` and 2 more not covered --> $DIR/empty-match.rs:94:24 | -LL | / enum NonEmptyEnum5 { -LL | | V1, V2, V3, V4, V5, -LL | | } - | |_- `NonEmptyEnum5` defined here -... -LL | match_guarded_arm!(NonEmptyEnum5::V1); - | ^^^^^^^^^^^^^^^^^ patterns `V1`, `V2`, `V3` and 2 more not covered +LL | match_guarded_arm!(NonEmptyEnum5::V1); + | ^^^^^^^^^^^^^^^^^ patterns `V1`, `V2`, `V3` and 2 more not covered + | +note: `NonEmptyEnum5` defined here + --> $DIR/empty-match.rs:30:6 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | enum NonEmptyEnum5 { + | ^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyEnum5` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms + | +LL ~ _ if false => {} +LL + _ => todo!() + | error: aborting due to 22 previous errors diff --git a/src/test/ui/pattern/usefulness/empty-match.normal.stderr b/src/test/ui/pattern/usefulness/empty-match.normal.stderr index b99386e7402..d31ee0dbd14 100644 --- a/src/test/ui/pattern/usefulness/empty-match.normal.stderr +++ b/src/test/ui/pattern/usefulness/empty-match.normal.stderr @@ -46,107 +46,112 @@ error[E0004]: non-exhaustive patterns: type `u8` is non-empty LL | match_no_arms!(0u8); | ^^^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` + = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: type `NonEmptyStruct1` is non-empty --> $DIR/empty-match.rs:79:20 | -LL | struct NonEmptyStruct1; - | ----------------------- `NonEmptyStruct1` defined here -... LL | match_no_arms!(NonEmptyStruct1); | ^^^^^^^^^^^^^^^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `NonEmptyStruct1` defined here + --> $DIR/empty-match.rs:14:8 + | +LL | struct NonEmptyStruct1; + | ^^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyStruct1` + = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: type `NonEmptyStruct2` is non-empty --> $DIR/empty-match.rs:80:20 | -LL | struct NonEmptyStruct2(bool); - | ----------------------------- `NonEmptyStruct2` defined here -... LL | match_no_arms!(NonEmptyStruct2(true)); | ^^^^^^^^^^^^^^^^^^^^^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `NonEmptyStruct2` defined here + --> $DIR/empty-match.rs:15:8 + | +LL | struct NonEmptyStruct2(bool); + | ^^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyStruct2` + = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty --> $DIR/empty-match.rs:81:20 | -LL | / union NonEmptyUnion1 { -LL | | foo: (), -LL | | } - | |_- `NonEmptyUnion1` defined here -... -LL | match_no_arms!((NonEmptyUnion1 { foo: () })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | match_no_arms!((NonEmptyUnion1 { foo: () })); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: `NonEmptyUnion1` defined here + --> $DIR/empty-match.rs:16:7 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | union NonEmptyUnion1 { + | ^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyUnion1` + = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty --> $DIR/empty-match.rs:82:20 | -LL | / union NonEmptyUnion2 { -LL | | foo: (), -LL | | bar: (), -LL | | } - | |_- `NonEmptyUnion2` defined here -... -LL | match_no_arms!((NonEmptyUnion2 { foo: () })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | match_no_arms!((NonEmptyUnion2 { foo: () })); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: `NonEmptyUnion2` defined here + --> $DIR/empty-match.rs:19:7 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | union NonEmptyUnion2 { + | ^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyUnion2` + = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: `Foo(_)` not covered --> $DIR/empty-match.rs:83:20 | -LL | / enum NonEmptyEnum1 { -LL | | Foo(bool), - | | --- not covered -LL | | } - | |_- `NonEmptyEnum1` defined here -... -LL | match_no_arms!(NonEmptyEnum1::Foo(true)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo(_)` not covered +LL | match_no_arms!(NonEmptyEnum1::Foo(true)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo(_)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `NonEmptyEnum1` defined here + --> $DIR/empty-match.rs:24:5 + | +LL | enum NonEmptyEnum1 { + | ------------- +LL | Foo(bool), + | ^^^ not covered = note: the matched value is of type `NonEmptyEnum1` + = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern error[E0004]: non-exhaustive patterns: `Foo(_)` and `Bar` not covered --> $DIR/empty-match.rs:84:20 | -LL | / enum NonEmptyEnum2 { -LL | | Foo(bool), - | | --- not covered -LL | | Bar, - | | --- not covered -LL | | } - | |_- `NonEmptyEnum2` defined here -... -LL | match_no_arms!(NonEmptyEnum2::Foo(true)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo(_)` and `Bar` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | match_no_arms!(NonEmptyEnum2::Foo(true)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo(_)` and `Bar` not covered + | +note: `NonEmptyEnum2` defined here + --> $DIR/empty-match.rs:27:5 + | +LL | enum NonEmptyEnum2 { + | ------------- +LL | Foo(bool), + | ^^^ not covered +LL | Bar, + | ^^^ not covered = note: the matched value is of type `NonEmptyEnum2` + = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms error[E0004]: non-exhaustive patterns: `V1`, `V2`, `V3` and 2 more not covered --> $DIR/empty-match.rs:85:20 | -LL | / enum NonEmptyEnum5 { -LL | | V1, V2, V3, V4, V5, -LL | | } - | |_- `NonEmptyEnum5` defined here -... -LL | match_no_arms!(NonEmptyEnum5::V1); - | ^^^^^^^^^^^^^^^^^ patterns `V1`, `V2`, `V3` and 2 more not covered +LL | match_no_arms!(NonEmptyEnum5::V1); + | ^^^^^^^^^^^^^^^^^ patterns `V1`, `V2`, `V3` and 2 more not covered + | +note: `NonEmptyEnum5` defined here + --> $DIR/empty-match.rs:30:6 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | enum NonEmptyEnum5 { + | ^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyEnum5` + = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/empty-match.rs:87:24 @@ -154,107 +159,144 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | match_guarded_arm!(0u8); | ^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ _ if false => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `NonEmptyStruct1` not covered --> $DIR/empty-match.rs:88:24 | -LL | struct NonEmptyStruct1; - | ----------------------- `NonEmptyStruct1` defined here -... LL | match_guarded_arm!(NonEmptyStruct1); | ^^^^^^^^^^^^^^^ pattern `NonEmptyStruct1` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `NonEmptyStruct1` defined here + --> $DIR/empty-match.rs:14:8 + | +LL | struct NonEmptyStruct1; + | ^^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyStruct1` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ _ if false => {} +LL + NonEmptyStruct1 => todo!() + | error[E0004]: non-exhaustive patterns: `NonEmptyStruct2(_)` not covered --> $DIR/empty-match.rs:89:24 | -LL | struct NonEmptyStruct2(bool); - | ----------------------------- `NonEmptyStruct2` defined here -... LL | match_guarded_arm!(NonEmptyStruct2(true)); | ^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct2(_)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `NonEmptyStruct2` defined here + --> $DIR/empty-match.rs:15:8 + | +LL | struct NonEmptyStruct2(bool); + | ^^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyStruct2` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ _ if false => {} +LL + NonEmptyStruct2(_) => todo!() + | error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered --> $DIR/empty-match.rs:90:24 | -LL | / union NonEmptyUnion1 { -LL | | foo: (), -LL | | } - | |_- `NonEmptyUnion1` defined here -... -LL | match_guarded_arm!((NonEmptyUnion1 { foo: () })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered +LL | match_guarded_arm!((NonEmptyUnion1 { foo: () })); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered + | +note: `NonEmptyUnion1` defined here + --> $DIR/empty-match.rs:16:7 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | union NonEmptyUnion1 { + | ^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyUnion1` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ _ if false => {} +LL + NonEmptyUnion1 { .. } => todo!() + | error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered --> $DIR/empty-match.rs:91:24 | -LL | / union NonEmptyUnion2 { -LL | | foo: (), -LL | | bar: (), -LL | | } - | |_- `NonEmptyUnion2` defined here -... -LL | match_guarded_arm!((NonEmptyUnion2 { foo: () })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered +LL | match_guarded_arm!((NonEmptyUnion2 { foo: () })); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered + | +note: `NonEmptyUnion2` defined here + --> $DIR/empty-match.rs:19:7 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | union NonEmptyUnion2 { + | ^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyUnion2` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ _ if false => {} +LL + NonEmptyUnion2 { .. } => todo!() + | error[E0004]: non-exhaustive patterns: `Foo(_)` not covered --> $DIR/empty-match.rs:92:24 | -LL | / enum NonEmptyEnum1 { -LL | | Foo(bool), - | | --- not covered -LL | | } - | |_- `NonEmptyEnum1` defined here -... -LL | match_guarded_arm!(NonEmptyEnum1::Foo(true)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo(_)` not covered +LL | match_guarded_arm!(NonEmptyEnum1::Foo(true)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo(_)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `NonEmptyEnum1` defined here + --> $DIR/empty-match.rs:24:5 + | +LL | enum NonEmptyEnum1 { + | ------------- +LL | Foo(bool), + | ^^^ not covered = note: the matched value is of type `NonEmptyEnum1` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ _ if false => {} +LL + Foo(_) => todo!() + | error[E0004]: non-exhaustive patterns: `Foo(_)` and `Bar` not covered --> $DIR/empty-match.rs:93:24 | -LL | / enum NonEmptyEnum2 { -LL | | Foo(bool), - | | --- not covered -LL | | Bar, - | | --- not covered -LL | | } - | |_- `NonEmptyEnum2` defined here -... -LL | match_guarded_arm!(NonEmptyEnum2::Foo(true)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo(_)` and `Bar` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | match_guarded_arm!(NonEmptyEnum2::Foo(true)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo(_)` and `Bar` not covered + | +note: `NonEmptyEnum2` defined here + --> $DIR/empty-match.rs:27:5 + | +LL | enum NonEmptyEnum2 { + | ------------- +LL | Foo(bool), + | ^^^ not covered +LL | Bar, + | ^^^ not covered = note: the matched value is of type `NonEmptyEnum2` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ _ if false => {} +LL + Foo(_) | Bar => todo!() + | error[E0004]: non-exhaustive patterns: `V1`, `V2`, `V3` and 2 more not covered --> $DIR/empty-match.rs:94:24 | -LL | / enum NonEmptyEnum5 { -LL | | V1, V2, V3, V4, V5, -LL | | } - | |_- `NonEmptyEnum5` defined here -... -LL | match_guarded_arm!(NonEmptyEnum5::V1); - | ^^^^^^^^^^^^^^^^^ patterns `V1`, `V2`, `V3` and 2 more not covered +LL | match_guarded_arm!(NonEmptyEnum5::V1); + | ^^^^^^^^^^^^^^^^^ patterns `V1`, `V2`, `V3` and 2 more not covered + | +note: `NonEmptyEnum5` defined here + --> $DIR/empty-match.rs:30:6 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | enum NonEmptyEnum5 { + | ^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyEnum5` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms + | +LL ~ _ if false => {} +LL + _ => todo!() + | error: aborting due to 22 previous errors diff --git a/src/test/ui/pattern/usefulness/floats.stderr b/src/test/ui/pattern/usefulness/floats.stderr index 464bfbdb2c3..c926e50b358 100644 --- a/src/test/ui/pattern/usefulness/floats.stderr +++ b/src/test/ui/pattern/usefulness/floats.stderr @@ -4,8 +4,12 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | match 0.0 { | ^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `f64` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ 0.0..=1.0 => {} +LL + _ => todo!() + | error: unreachable pattern --> $DIR/floats.rs:16:7 diff --git a/src/test/ui/pattern/usefulness/guards.stderr b/src/test/ui/pattern/usefulness/guards.stderr index 61f7facb330..0c1563c160c 100644 --- a/src/test/ui/pattern/usefulness/guards.stderr +++ b/src/test/ui/pattern/usefulness/guards.stderr @@ -4,8 +4,12 @@ error[E0004]: non-exhaustive patterns: `128_u8..=u8::MAX` not covered LL | match 0u8 { | ^^^ pattern `128_u8..=u8::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ 128 ..= 255 if true => {} +LL + 128_u8..=u8::MAX => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr b/src/test/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr index 2e0023348e4..fec54e89d63 100644 --- a/src/test/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr +++ b/src/test/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr @@ -4,8 +4,12 @@ error[E0004]: non-exhaustive patterns: `u8::MAX` not covered LL | m!(0u8, 0..255); | ^^^ pattern `u8::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ u8::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `u8::MAX` not covered --> $DIR/exhaustiveness.rs:48:8 @@ -13,8 +17,12 @@ error[E0004]: non-exhaustive patterns: `u8::MAX` not covered LL | m!(0u8, 0..=254); | ^^^ pattern `u8::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ u8::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `0_u8` not covered --> $DIR/exhaustiveness.rs:49:8 @@ -22,8 +30,12 @@ error[E0004]: non-exhaustive patterns: `0_u8` not covered LL | m!(0u8, 1..=255); | ^^^ pattern `0_u8` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 0_u8 => todo!() } + | error[E0004]: non-exhaustive patterns: `42_u8` not covered --> $DIR/exhaustiveness.rs:50:8 @@ -31,8 +43,12 @@ error[E0004]: non-exhaustive patterns: `42_u8` not covered LL | m!(0u8, 0..42 | 43..=255); | ^^^ pattern `42_u8` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 42_u8 => todo!() } + | error[E0004]: non-exhaustive patterns: `i8::MAX` not covered --> $DIR/exhaustiveness.rs:51:8 @@ -40,8 +56,12 @@ error[E0004]: non-exhaustive patterns: `i8::MAX` not covered LL | m!(0i8, -128..127); | ^^^ pattern `i8::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i8::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `i8::MAX` not covered --> $DIR/exhaustiveness.rs:52:8 @@ -49,8 +69,12 @@ error[E0004]: non-exhaustive patterns: `i8::MAX` not covered LL | m!(0i8, -128..=126); | ^^^ pattern `i8::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i8::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `i8::MIN` not covered --> $DIR/exhaustiveness.rs:53:8 @@ -58,8 +82,12 @@ error[E0004]: non-exhaustive patterns: `i8::MIN` not covered LL | m!(0i8, -127..=127); | ^^^ pattern `i8::MIN` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ i8::MIN => todo!() } + | error[E0004]: non-exhaustive patterns: `0_i8` not covered --> $DIR/exhaustiveness.rs:54:11 @@ -67,8 +95,12 @@ error[E0004]: non-exhaustive patterns: `0_i8` not covered LL | match 0i8 { | ^^^ pattern `0_i8` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ 1 ..= i8::MAX => {} +LL + 0_i8 => todo!() + | error[E0004]: non-exhaustive patterns: `u128::MAX` not covered --> $DIR/exhaustiveness.rs:59:8 @@ -76,8 +108,12 @@ error[E0004]: non-exhaustive patterns: `u128::MAX` not covered LL | m!(0u128, 0..=ALMOST_MAX); | ^^^^^ pattern `u128::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u128` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ u128::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `5_u128..=u128::MAX` not covered --> $DIR/exhaustiveness.rs:60:8 @@ -85,8 +121,12 @@ error[E0004]: non-exhaustive patterns: `5_u128..=u128::MAX` not covered LL | m!(0u128, 0..=4); | ^^^^^ pattern `5_u128..=u128::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u128` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 5_u128..=u128::MAX => todo!() } + | error[E0004]: non-exhaustive patterns: `0_u128` not covered --> $DIR/exhaustiveness.rs:61:8 @@ -94,8 +134,12 @@ error[E0004]: non-exhaustive patterns: `0_u128` not covered LL | m!(0u128, 1..=u128::MAX); | ^^^^^ pattern `0_u128` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `u128` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ 0_u128 => todo!() } + | error[E0004]: non-exhaustive patterns: `(126_u8..=127_u8, false)` not covered --> $DIR/exhaustiveness.rs:69:11 @@ -103,8 +147,12 @@ error[E0004]: non-exhaustive patterns: `(126_u8..=127_u8, false)` not covered LL | match (0u8, true) { | ^^^^^^^^^^^ pattern `(126_u8..=127_u8, false)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(u8, bool)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ (0 ..= 255, true) => {} +LL + (126_u8..=127_u8, false) => todo!() + | error: aborting due to 12 previous errors diff --git a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr index 25632934583..9f277fa1e18 100644 --- a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr +++ b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr @@ -4,8 +4,13 @@ error[E0004]: non-exhaustive patterns: type `usize` is non-empty LL | match 7usize {} | ^^^^^^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `usize` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match 7usize { +LL + _ => todo!(), +LL + } + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr index e8ac9f3cfe1..fa4146a7ad8 100644 --- a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr +++ b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr @@ -4,10 +4,14 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | match 0usize { | ^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `usize` = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ 0 ..= usize::MAX => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/pointer-sized-int.rs:17:11 @@ -15,10 +19,14 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | match 0isize { | ^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `isize` = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ isize::MIN ..= isize::MAX => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/pointer-sized-int.rs:22:8 @@ -26,10 +34,14 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | m!(0usize, 0..=usize::MAX); | ^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `usize` = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ _ => todo!() } + | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/pointer-sized-int.rs:24:8 @@ -37,10 +49,14 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | m!(0usize, 0..5 | 5..=usize::MAX); | ^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `usize` = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ _ => todo!() } + | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/pointer-sized-int.rs:26:8 @@ -48,10 +64,14 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | m!(0usize, 0..usize::MAX | usize::MAX); | ^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `usize` = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ _ => todo!() } + | error[E0004]: non-exhaustive patterns: `(_, _)` not covered --> $DIR/pointer-sized-int.rs:28:8 @@ -59,8 +79,12 @@ error[E0004]: non-exhaustive patterns: `(_, _)` not covered LL | m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false)); | ^^^^^^^^^^^^^^ pattern `(_, _)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(usize, bool)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ (_, _) => todo!() } + | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/pointer-sized-int.rs:31:8 @@ -68,10 +92,14 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | m!(0isize, isize::MIN..=isize::MAX); | ^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `isize` = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ _ => todo!() } + | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/pointer-sized-int.rs:33:8 @@ -79,10 +107,14 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | m!(0isize, isize::MIN..5 | 5..=isize::MAX); | ^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `isize` = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ _ => todo!() } + | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/pointer-sized-int.rs:35:8 @@ -90,10 +122,14 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | m!(0isize, isize::MIN..isize::MAX | isize::MAX); | ^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `isize` = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ _ => todo!() } + | error[E0004]: non-exhaustive patterns: `(_, _)` not covered --> $DIR/pointer-sized-int.rs:37:8 @@ -101,8 +137,12 @@ error[E0004]: non-exhaustive patterns: `(_, _)` not covered LL | m!((0isize, true), (isize::MIN..5, true) | ^^^^^^^^^^^^^^ pattern `(_, _)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(isize, bool)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match $s { $($t)+ => {} +LL ~ (_, _) => todo!() } + | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/pointer-sized-int.rs:41:11 @@ -110,10 +150,14 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | match 0isize { | ^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `isize` = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ 1 ..= isize::MAX => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: type `usize` is non-empty --> $DIR/pointer-sized-int.rs:48:11 @@ -121,8 +165,13 @@ error[E0004]: non-exhaustive patterns: type `usize` is non-empty LL | match 7usize {} | ^^^^^^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `usize` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match 7usize { +LL + _ => todo!(), +LL + } + | error: aborting due to 12 previous errors diff --git a/src/test/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr b/src/test/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr index 37e73a68f22..30492c98206 100644 --- a/src/test/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr +++ b/src/test/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr @@ -4,10 +4,14 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | match 0usize { | ^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `usize` = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ 0..=usize::MAX => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/precise_pointer_matching-message.rs:11:11 @@ -15,10 +19,14 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | match 0isize { | ^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `isize` = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ isize::MIN..=isize::MAX => {} +LL + _ => todo!() + | error: aborting due to 2 previous errors diff --git a/src/test/ui/pattern/usefulness/issue-15129.stderr b/src/test/ui/pattern/usefulness/issue-15129.stderr index 79a77240937..af60f3ff50b 100644 --- a/src/test/ui/pattern/usefulness/issue-15129.stderr +++ b/src/test/ui/pattern/usefulness/issue-15129.stderr @@ -4,8 +4,12 @@ error[E0004]: non-exhaustive patterns: `(T1(()), V2(_))` and `(T2(()), V1(_))` n LL | match (T::T1(()), V::V2(true)) { | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `(T1(()), V2(_))` and `(T2(()), V1(_))` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(T, V)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ (T::T2(()), V::V2(b)) => (), +LL ~ (T1(()), V2(_)) | (T2(()), V1(_)) => todo!(), + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/issue-2111.stderr b/src/test/ui/pattern/usefulness/issue-2111.stderr index 60d9b8514b7..01890b73cbd 100644 --- a/src/test/ui/pattern/usefulness/issue-2111.stderr +++ b/src/test/ui/pattern/usefulness/issue-2111.stderr @@ -4,8 +4,12 @@ error[E0004]: non-exhaustive patterns: `(None, None)` and `(Some(_), Some(_))` n LL | match (a, b) { | ^^^^^^ patterns `(None, None)` and `(Some(_), Some(_))` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(Option<usize>, Option<usize>)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ (Some(_), None) | (None, Some(_)) => {} +LL + (None, None) | (Some(_), Some(_)) => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/issue-30240.stderr b/src/test/ui/pattern/usefulness/issue-30240.stderr index a2c58d6e051..759fdeafe4e 100644 --- a/src/test/ui/pattern/usefulness/issue-30240.stderr +++ b/src/test/ui/pattern/usefulness/issue-30240.stderr @@ -4,8 +4,12 @@ error[E0004]: non-exhaustive patterns: `&_` not covered LL | match "world" { | ^^^^^^^ pattern `&_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&str` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ "hello" => {} +LL + &_ => todo!() + | error[E0004]: non-exhaustive patterns: `&_` not covered --> $DIR/issue-30240.rs:6:11 @@ -13,8 +17,12 @@ error[E0004]: non-exhaustive patterns: `&_` not covered LL | match "world" { | ^^^^^^^ pattern `&_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&str` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ "hello" => {} +LL + &_ => todo!() + | error: aborting due to 2 previous errors diff --git a/src/test/ui/pattern/usefulness/issue-3096-1.stderr b/src/test/ui/pattern/usefulness/issue-3096-1.stderr index 97c34755189..d8884394f8e 100644 --- a/src/test/ui/pattern/usefulness/issue-3096-1.stderr +++ b/src/test/ui/pattern/usefulness/issue-3096-1.stderr @@ -4,8 +4,13 @@ error[E0004]: non-exhaustive patterns: type `()` is non-empty LL | match () { } | ^^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `()` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match () { +LL + _ => todo!(), +LL ~ } + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/issue-3096-2.stderr b/src/test/ui/pattern/usefulness/issue-3096-2.stderr index 472d1a91e6a..2df8911badc 100644 --- a/src/test/ui/pattern/usefulness/issue-3096-2.stderr +++ b/src/test/ui/pattern/usefulness/issue-3096-2.stderr @@ -4,8 +4,13 @@ error[E0004]: non-exhaustive patterns: type `*const Bottom` is non-empty LL | match x { } | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `*const Bottom` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/issue-31561.stderr b/src/test/ui/pattern/usefulness/issue-31561.stderr index 2f562b23692..dffcfc01607 100644 --- a/src/test/ui/pattern/usefulness/issue-31561.stderr +++ b/src/test/ui/pattern/usefulness/issue-31561.stderr @@ -1,20 +1,21 @@ error[E0005]: refutable pattern in local binding: `Bar` and `Baz` not covered --> $DIR/issue-31561.rs:8:9 | -LL | / enum Thing { -LL | | Foo(u8), -LL | | Bar, - | | --- not covered -LL | | Baz - | | --- not covered -LL | | } - | |_- `Thing` defined here -... -LL | let Thing::Foo(y) = Thing::Foo(1); - | ^^^^^^^^^^^^^ patterns `Bar` and `Baz` not covered +LL | let Thing::Foo(y) = Thing::Foo(1); + | ^^^^^^^^^^^^^ patterns `Bar` and `Baz` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html +note: `Thing` defined here + --> $DIR/issue-31561.rs:3:5 + | +LL | enum Thing { + | ----- +LL | Foo(u8), +LL | Bar, + | ^^^ not covered +LL | Baz + | ^^^ not covered = note: the matched value is of type `Thing` help: you might want to use `if let` to ignore the variant that isn't matched | diff --git a/src/test/ui/pattern/usefulness/issue-35609.stderr b/src/test/ui/pattern/usefulness/issue-35609.stderr index 0598c8d6f38..717bb53c327 100644 --- a/src/test/ui/pattern/usefulness/issue-35609.stderr +++ b/src/test/ui/pattern/usefulness/issue-35609.stderr @@ -4,8 +4,12 @@ error[E0004]: non-exhaustive patterns: `(B, _)`, `(C, _)`, `(D, _)` and 2 more n LL | match (A, ()) { | ^^^^^^^ patterns `(B, _)`, `(C, _)`, `(D, _)` and 2 more not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(Enum, ())` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms + | +LL ~ (A, _) => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `(_, B)`, `(_, C)`, `(_, D)` and 2 more not covered --> $DIR/issue-35609.rs:14:11 @@ -13,8 +17,12 @@ error[E0004]: non-exhaustive patterns: `(_, B)`, `(_, C)`, `(_, D)` and 2 more n LL | match (A, A) { | ^^^^^^ patterns `(_, B)`, `(_, C)`, `(_, D)` and 2 more not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(Enum, Enum)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms + | +LL ~ (_, A) => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `((B, _), _)`, `((C, _), _)`, `((D, _), _)` and 2 more not covered --> $DIR/issue-35609.rs:18:11 @@ -22,8 +30,12 @@ error[E0004]: non-exhaustive patterns: `((B, _), _)`, `((C, _), _)`, `((D, _), _ LL | match ((A, ()), ()) { | ^^^^^^^^^^^^^ patterns `((B, _), _)`, `((C, _), _)`, `((D, _), _)` and 2 more not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `((Enum, ()), ())` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms + | +LL ~ ((A, ()), _) => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `((B, _), _)`, `((C, _), _)`, `((D, _), _)` and 2 more not covered --> $DIR/issue-35609.rs:22:11 @@ -31,8 +43,12 @@ error[E0004]: non-exhaustive patterns: `((B, _), _)`, `((C, _), _)`, `((D, _), _ LL | match ((A, ()), A) { | ^^^^^^^^^^^^ patterns `((B, _), _)`, `((C, _), _)`, `((D, _), _)` and 2 more not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `((Enum, ()), Enum)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms + | +LL ~ ((A, ()), _) => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `((B, _), _)`, `((C, _), _)`, `((D, _), _)` and 2 more not covered --> $DIR/issue-35609.rs:26:11 @@ -40,32 +56,48 @@ error[E0004]: non-exhaustive patterns: `((B, _), _)`, `((C, _), _)`, `((D, _), _ LL | match ((A, ()), ()) { | ^^^^^^^^^^^^^ patterns `((B, _), _)`, `((C, _), _)`, `((D, _), _)` and 2 more not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `((Enum, ()), ())` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms + | +LL ~ ((A, _), _) => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `S(B, _)`, `S(C, _)`, `S(D, _)` and 2 more not covered --> $DIR/issue-35609.rs:31:11 | -LL | struct S(Enum, ()); - | ------------------- `S` defined here -... LL | match S(A, ()) { | ^^^^^^^^ patterns `S(B, _)`, `S(C, _)`, `S(D, _)` and 2 more not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `S` defined here + --> $DIR/issue-35609.rs:6:8 + | +LL | struct S(Enum, ()); + | ^ = note: the matched value is of type `S` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms + | +LL ~ S(A, _) => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `Sd { x: B, .. }`, `Sd { x: C, .. }`, `Sd { x: D, .. }` and 2 more not covered --> $DIR/issue-35609.rs:35:11 | -LL | struct Sd { x: Enum, y: () } - | ---------------------------- `Sd` defined here -... LL | match (Sd { x: A, y: () }) { | ^^^^^^^^^^^^^^^^^^^^ patterns `Sd { x: B, .. }`, `Sd { x: C, .. }`, `Sd { x: D, .. }` and 2 more not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `Sd` defined here + --> $DIR/issue-35609.rs:7:8 + | +LL | struct Sd { x: Enum, y: () } + | ^^ = note: the matched value is of type `Sd` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms + | +LL ~ Sd { x: A, y: _ } => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `Some(B)`, `Some(C)`, `Some(D)` and 2 more not covered --> $DIR/issue-35609.rs:39:11 @@ -73,8 +105,23 @@ error[E0004]: non-exhaustive patterns: `Some(B)`, `Some(C)`, `Some(D)` and 2 mor LL | match Some(A) { | ^^^^^^^ patterns `Some(B)`, `Some(C)`, `Some(D)` and 2 more not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `Option<Enum>` defined here + --> $SRC_DIR/core/src/option.rs:LL:COL + | +LL | / pub enum Option<T> { +LL | | /// No value. +LL | | #[lang = "None"] +LL | | #[stable(feature = "rust1", since = "1.0.0")] +... | +LL | | Some(#[stable(feature = "rust1", since = "1.0.0")] T), +LL | | } + | |_^ = note: the matched value is of type `Option<Enum>` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms + | +LL ~ None => (), +LL + _ => todo!() + | error: aborting due to 8 previous errors diff --git a/src/test/ui/pattern/usefulness/issue-3601.stderr b/src/test/ui/pattern/usefulness/issue-3601.stderr index 48ed1491508..4e0adcc1ba2 100644 --- a/src/test/ui/pattern/usefulness/issue-3601.stderr +++ b/src/test/ui/pattern/usefulness/issue-3601.stderr @@ -4,8 +4,20 @@ error[E0004]: non-exhaustive patterns: `box _` not covered LL | box NodeKind::Element(ed) => match ed.kind { | ^^^^^^^ pattern `box _` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `Box<ElementKind>` defined here + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL + | +LL | / pub struct Box< +LL | | T: ?Sized, +LL | | #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, +LL | | >(Unique<T>, A); + | |________________^ = note: the matched value is of type `Box<ElementKind>` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ box ElementKind::HTMLImageElement(ref d) if d.image.is_some() => { true } +LL + box _ => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/issue-39362.stderr b/src/test/ui/pattern/usefulness/issue-39362.stderr index 8c162e55619..ca37af6fb80 100644 --- a/src/test/ui/pattern/usefulness/issue-39362.stderr +++ b/src/test/ui/pattern/usefulness/issue-39362.stderr @@ -1,16 +1,22 @@ error[E0004]: non-exhaustive patterns: `Bar { bar: C, .. }`, `Bar { bar: D, .. }`, `Bar { bar: E, .. }` and 1 more not covered --> $DIR/issue-39362.rs:10:11 | -LL | / enum Foo { -LL | | Bar { bar: Bar, id: usize } -LL | | } - | |_- `Foo` defined here -... -LL | match f { - | ^ patterns `Bar { bar: C, .. }`, `Bar { bar: D, .. }`, `Bar { bar: E, .. }` and 1 more not covered +LL | match f { + | ^ patterns `Bar { bar: C, .. }`, `Bar { bar: D, .. }`, `Bar { bar: E, .. }` and 1 more not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `Foo` defined here + --> $DIR/issue-39362.rs:2:5 + | +LL | enum Foo { + | --- +LL | Bar { bar: Bar, id: usize } + | ^^^ not covered = note: the matched value is of type `Foo` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms + | +LL ~ Foo::Bar { bar: Bar::B, .. } => (), +LL ~ _ => todo!(), + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/issue-40221.stderr b/src/test/ui/pattern/usefulness/issue-40221.stderr index 98efe805a0b..c477e435335 100644 --- a/src/test/ui/pattern/usefulness/issue-40221.stderr +++ b/src/test/ui/pattern/usefulness/issue-40221.stderr @@ -1,17 +1,22 @@ error[E0004]: non-exhaustive patterns: `C(QA)` not covered --> $DIR/issue-40221.rs:11:11 | -LL | / enum P { -LL | | C(PC), - | | - not covered -LL | | } - | |_- `P` defined here -... -LL | match proto { - | ^^^^^ pattern `C(QA)` not covered +LL | match proto { + | ^^^^^ pattern `C(QA)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `P` defined here + --> $DIR/issue-40221.rs:2:5 + | +LL | enum P { + | - +LL | C(PC), + | ^ not covered = note: the matched value is of type `P` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ P::C(PC::Q) => (), +LL ~ C(QA) => todo!(), + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/issue-4321.stderr b/src/test/ui/pattern/usefulness/issue-4321.stderr index 1e8852556b1..29327317410 100644 --- a/src/test/ui/pattern/usefulness/issue-4321.stderr +++ b/src/test/ui/pattern/usefulness/issue-4321.stderr @@ -4,8 +4,12 @@ error[E0004]: non-exhaustive patterns: `(true, false)` not covered LL | println!("foo {:}", match tup { | ^^^ pattern `(true, false)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(bool, bool)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ (true, true) => "baz", +LL + (true, false) => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/issue-50900.stderr b/src/test/ui/pattern/usefulness/issue-50900.stderr index d378b6e8efe..2bdbecabbbe 100644 --- a/src/test/ui/pattern/usefulness/issue-50900.stderr +++ b/src/test/ui/pattern/usefulness/issue-50900.stderr @@ -1,14 +1,20 @@ error[E0004]: non-exhaustive patterns: `Tag(Exif, _)` not covered --> $DIR/issue-50900.rs:15:11 | -LL | pub struct Tag(pub Context, pub u16); - | ------------------------------------- `Tag` defined here -... LL | match Tag::ExifIFDPointer { | ^^^^^^^^^^^^^^^^^^^ pattern `Tag(Exif, _)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `Tag` defined here + --> $DIR/issue-50900.rs:2:12 + | +LL | pub struct Tag(pub Context, pub u16); + | ^^^ = note: the matched value is of type `Tag` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ Tag::ExifIFDPointer => {} +LL + Tag(Exif, _) => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/issue-56379.stderr b/src/test/ui/pattern/usefulness/issue-56379.stderr index 6a231b868c8..f6261001c5e 100644 --- a/src/test/ui/pattern/usefulness/issue-56379.stderr +++ b/src/test/ui/pattern/usefulness/issue-56379.stderr @@ -1,21 +1,26 @@ error[E0004]: non-exhaustive patterns: `A(false)`, `B(false)` and `C(false)` not covered --> $DIR/issue-56379.rs:8:11 | -LL | / enum Foo { -LL | | A(bool), - | | - not covered -LL | | B(bool), - | | - not covered -LL | | C(bool), - | | - not covered -LL | | } - | |_- `Foo` defined here -... -LL | match Foo::A(true) { - | ^^^^^^^^^^^^ patterns `A(false)`, `B(false)` and `C(false)` not covered +LL | match Foo::A(true) { + | ^^^^^^^^^^^^ patterns `A(false)`, `B(false)` and `C(false)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `Foo` defined here + --> $DIR/issue-56379.rs:2:5 + | +LL | enum Foo { + | --- +LL | A(bool), + | ^ not covered +LL | B(bool), + | ^ not covered +LL | C(bool), + | ^ not covered = note: the matched value is of type `Foo` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ Foo::C(true) => {} +LL + A(false) | B(false) | C(false) => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/issue-72377.stderr b/src/test/ui/pattern/usefulness/issue-72377.stderr index b4a68333967..20f002dd3db 100644 --- a/src/test/ui/pattern/usefulness/issue-72377.stderr +++ b/src/test/ui/pattern/usefulness/issue-72377.stderr @@ -4,8 +4,12 @@ error[E0004]: non-exhaustive patterns: `(A, Some(A))`, `(A, Some(B))`, `(B, Some LL | match (x, y) { | ^^^^^^ patterns `(A, Some(A))`, `(A, Some(B))`, `(B, Some(B))` and 2 more not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(X, Option<X>)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms + | +LL ~ (X::A, Some(X::C)) | (X::C, Some(X::A)) => false, +LL ~ _ => todo!(), + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.rs b/src/test/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.rs index 6c5a331b4b5..cbfcf0eafd4 100644 --- a/src/test/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.rs +++ b/src/test/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.rs @@ -1,5 +1,6 @@ enum A {} //~^ NOTE `A` defined here + //~| NOTE fn f(a: &A) { match a {} diff --git a/src/test/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.stderr b/src/test/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.stderr index e992632a91f..bf05d616d6e 100644 --- a/src/test/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.stderr +++ b/src/test/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.stderr @@ -1,15 +1,22 @@ error[E0004]: non-exhaustive patterns: type `&A` is non-empty - --> $DIR/issue-78123-non-exhaustive-reference.rs:5:11 + --> $DIR/issue-78123-non-exhaustive-reference.rs:6:11 | -LL | enum A {} - | --------- `A` defined here -... LL | match a {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `A` defined here + --> $DIR/issue-78123-non-exhaustive-reference.rs:1:6 + | +LL | enum A {} + | ^ = note: the matched value is of type `&A` = note: references are always considered inhabited +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match a { +LL + _ => todo!(), +LL + } + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/match-arm-statics-2.stderr b/src/test/ui/pattern/usefulness/match-arm-statics-2.stderr index 4a987cb6c03..3326e6b85a4 100644 --- a/src/test/ui/pattern/usefulness/match-arm-statics-2.stderr +++ b/src/test/ui/pattern/usefulness/match-arm-statics-2.stderr @@ -4,8 +4,12 @@ error[E0004]: non-exhaustive patterns: `(true, false)` not covered LL | match (true, false) { | ^^^^^^^^^^^^^ pattern `(true, false)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(bool, bool)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ (false, true) => (), +LL + (true, false) => todo!() + | error[E0004]: non-exhaustive patterns: `Some(Some(West))` not covered --> $DIR/match-arm-statics-2.rs:29:11 @@ -13,31 +17,45 @@ error[E0004]: non-exhaustive patterns: `Some(Some(West))` not covered LL | match Some(Some(North)) { | ^^^^^^^^^^^^^^^^^ pattern `Some(Some(West))` not covered | - ::: $SRC_DIR/core/src/option.rs:LL:COL +note: `Option<Option<Direction>>` defined here + --> $SRC_DIR/core/src/option.rs:LL:COL + | +LL | / pub enum Option<T> { +LL | | /// No value. +LL | | #[lang = "None"] +LL | | #[stable(feature = "rust1", since = "1.0.0")] +... | +LL | | Some(#[stable(feature = "rust1", since = "1.0.0")] T), + | | ^^^^ + | | | + | | not covered + | | not covered +LL | | } + | |_- + = note: the matched value is of type `Option<Option<Direction>>` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL | Some(#[stable(feature = "rust1", since = "1.0.0")] T), - | ---- - | | - | not covered - | not covered +LL ~ None => (), +LL + Some(Some(West)) => todo!() | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `Option<Option<Direction>>` error[E0004]: non-exhaustive patterns: `Foo { bar: Some(North), baz: NewBool(true) }` not covered --> $DIR/match-arm-statics-2.rs:48:11 | -LL | / struct Foo { -LL | | bar: Option<Direction>, -LL | | baz: NewBool -LL | | } - | |_- `Foo` defined here -... -LL | match (Foo { bar: Some(North), baz: NewBool(true) }) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo { bar: Some(North), baz: NewBool(true) }` not covered +LL | match (Foo { bar: Some(North), baz: NewBool(true) }) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo { bar: Some(North), baz: NewBool(true) }` not covered + | +note: `Foo` defined here + --> $DIR/match-arm-statics-2.rs:40:8 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | struct Foo { + | ^^^ = note: the matched value is of type `Foo` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ Foo { bar: Some(EAST), .. } => (), +LL + Foo { bar: Some(North), baz: NewBool(true) } => todo!() + | error: aborting due to 3 previous errors diff --git a/src/test/ui/pattern/usefulness/match-byte-array-patterns-2.stderr b/src/test/ui/pattern/usefulness/match-byte-array-patterns-2.stderr index ffc8433403f..a90f32f7aeb 100644 --- a/src/test/ui/pattern/usefulness/match-byte-array-patterns-2.stderr +++ b/src/test/ui/pattern/usefulness/match-byte-array-patterns-2.stderr @@ -4,8 +4,12 @@ error[E0004]: non-exhaustive patterns: `&[0_u8..=64_u8, _, _, _]` and `&[66_u8.. LL | match buf { | ^^^ patterns `&[0_u8..=64_u8, _, _, _]` and `&[66_u8..=u8::MAX, _, _, _]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[u8; 4]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ b"AAAA" => {} +LL + &[0_u8..=64_u8, _, _, _] | &[66_u8..=u8::MAX, _, _, _] => todo!() + | error[E0004]: non-exhaustive patterns: `&[]`, `&[_]`, `&[_, _]` and 2 more not covered --> $DIR/match-byte-array-patterns-2.rs:10:11 @@ -13,8 +17,12 @@ error[E0004]: non-exhaustive patterns: `&[]`, `&[_]`, `&[_, _]` and 2 more not c LL | match buf { | ^^^ patterns `&[]`, `&[_]`, `&[_, _]` and 2 more not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[u8]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms + | +LL ~ b"AAAA" => {} +LL + _ => todo!() + | error: aborting due to 2 previous errors diff --git a/src/test/ui/pattern/usefulness/match-non-exhaustive.stderr b/src/test/ui/pattern/usefulness/match-non-exhaustive.stderr index a35d61e4b71..08dde523a15 100644 --- a/src/test/ui/pattern/usefulness/match-non-exhaustive.stderr +++ b/src/test/ui/pattern/usefulness/match-non-exhaustive.stderr @@ -4,8 +4,11 @@ error[E0004]: non-exhaustive patterns: `i32::MIN..=0_i32` and `2_i32..=i32::MAX` LL | match 0 { 1 => () } | ^ patterns `i32::MIN..=0_i32` and `2_i32..=i32::MAX` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i32` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL | match 0 { 1 => (), i32::MIN..=0_i32 | 2_i32..=i32::MAX => todo!() } + | ++++++++++++++++++++++++++++++++++++++++++++++++ error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/match-non-exhaustive.rs:3:11 @@ -13,8 +16,11 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | match 0 { 0 if false => () } | ^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `i32` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL | match 0 { 0 if false => (), _ => todo!() } + | ++++++++++++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/pattern/usefulness/match-privately-empty.stderr b/src/test/ui/pattern/usefulness/match-privately-empty.stderr index 4efb41978a2..88178d64291 100644 --- a/src/test/ui/pattern/usefulness/match-privately-empty.stderr +++ b/src/test/ui/pattern/usefulness/match-privately-empty.stderr @@ -4,13 +4,24 @@ error[E0004]: non-exhaustive patterns: `Some(Private { misc: true, .. })` not co LL | match private::DATA { | ^^^^^^^^^^^^^ pattern `Some(Private { misc: true, .. })` not covered | - ::: $SRC_DIR/core/src/option.rs:LL:COL +note: `Option<Private>` defined here + --> $SRC_DIR/core/src/option.rs:LL:COL | -LL | Some(#[stable(feature = "rust1", since = "1.0.0")] T), - | ---- not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | / pub enum Option<T> { +LL | | /// No value. +LL | | #[lang = "None"] +LL | | #[stable(feature = "rust1", since = "1.0.0")] +... | +LL | | Some(#[stable(feature = "rust1", since = "1.0.0")] T), + | | ^^^^ not covered +LL | | } + | |_- = note: the matched value is of type `Option<Private>` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ }) => {} +LL + Some(Private { misc: true, .. }) => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/match-slice-patterns.stderr b/src/test/ui/pattern/usefulness/match-slice-patterns.stderr index 88f27be0412..961dd590119 100644 --- a/src/test/ui/pattern/usefulness/match-slice-patterns.stderr +++ b/src/test/ui/pattern/usefulness/match-slice-patterns.stderr @@ -4,8 +4,12 @@ error[E0004]: non-exhaustive patterns: `&[_, Some(_), .., None, _]` not covered LL | match list { | ^^^^ pattern `&[_, Some(_), .., None, _]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[Option<()>]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ &[.., Some(_), _] => {} +LL ~ &[_, Some(_), .., None, _] => todo!(), + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/non-exhaustive-defined-here.rs b/src/test/ui/pattern/usefulness/non-exhaustive-defined-here.rs index 6f009acbdfe..2e15bc2d2a5 100644 --- a/src/test/ui/pattern/usefulness/non-exhaustive-defined-here.rs +++ b/src/test/ui/pattern/usefulness/non-exhaustive-defined-here.rs @@ -4,20 +4,26 @@ #[derive(Clone)] enum E { -//~^ `E` defined here -//~| `E` defined here -//~| `E` defined here -//~| `E` defined here -//~| `E` defined here -//~| `E` defined here + //~^ NOTE + //~| NOTE + //~| NOTE + //~| NOTE + //~| NOTE + //~| NOTE A, B, - //~^ not covered - //~| not covered - //~| not covered - //~| not covered - //~| not covered - //~| not covered + //~^ NOTE `E` defined here + //~| NOTE `E` defined here + //~| NOTE `E` defined here + //~| NOTE `E` defined here + //~| NOTE `E` defined here + //~| NOTE `E` defined here + //~| NOTE not covered + //~| NOTE not covered + //~| NOTE not covered + //~| NOTE not covered + //~| NOTE not covered + //~| NOTE not covered C //~^ not covered //~| not covered @@ -30,43 +36,70 @@ enum E { fn by_val(e: E) { let e1 = e.clone(); match e1 { //~ ERROR non-exhaustive patterns: `B` and `C` not covered + //~^ NOTE patterns `B` and `C` not covered + //~| NOTE the matched value is of type `E` E::A => {} } let E::A = e; //~ ERROR refutable pattern in local binding: `B` and `C` not covered + //~^ NOTE patterns `B` and `C` not covered + //~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with + //~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + //~| NOTE the matched value is of type `E` } fn by_ref_once(e: &E) { match e { //~ ERROR non-exhaustive patterns: `&B` and `&C` not covered + //~^ NOTE patterns `&B` and `&C` not covered + //~| NOTE the matched value is of type `&E` E::A => {} } let E::A = e; //~ ERROR refutable pattern in local binding: `&B` and `&C` not covered + //~^ NOTE patterns `&B` and `&C` not covered + //~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with + //~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + //~| NOTE the matched value is of type `&E` } fn by_ref_thrice(e: & &mut &E) { match e { //~ ERROR non-exhaustive patterns: `&&mut &B` and `&&mut &C` not covered + //~^ NOTE patterns `&&mut &B` and `&&mut &C` not covered + //~| NOTE the matched value is of type `&&mut &E` E::A => {} } let E::A = e; //~^ ERROR refutable pattern in local binding: `&&mut &B` and `&&mut &C` not covered + //~| NOTE patterns `&&mut &B` and `&&mut &C` not covered + //~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with + //~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + //~| NOTE the matched value is of type `&&mut &E` } enum Opt { -//~^ `Opt` defined here -//~| `Opt` defined here + //~^ NOTE + //~| NOTE Some(u8), None, - //~^ not covered + //~^ NOTE `Opt` defined here + //~| NOTE `Opt` defined here + //~| NOTE not covered + //~| NOTE not covered } fn ref_pat(e: Opt) { match e {//~ ERROR non-exhaustive patterns: `None` not covered + //~^ NOTE pattern `None` not covered + //~| NOTE the matched value is of type `Opt` Opt::Some(ref _x) => {} } let Opt::Some(ref _x) = e; //~ ERROR refutable pattern in local binding: `None` not covered + //~^ NOTE the matched value is of type `Opt` + //~| NOTE pattern `None` not covered + //~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with + //~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html } fn main() {} diff --git a/src/test/ui/pattern/usefulness/non-exhaustive-defined-here.stderr b/src/test/ui/pattern/usefulness/non-exhaustive-defined-here.stderr index 02eff28015d..8f5adccea80 100644 --- a/src/test/ui/pattern/usefulness/non-exhaustive-defined-here.stderr +++ b/src/test/ui/pattern/usefulness/non-exhaustive-defined-here.stderr @@ -1,50 +1,46 @@ error[E0004]: non-exhaustive patterns: `B` and `C` not covered - --> $DIR/non-exhaustive-defined-here.rs:32:11 - | -LL | / enum E { -LL | | -LL | | -LL | | -... | -LL | | B, - | | - not covered -... | -LL | | C - | | - not covered -... | -LL | | -LL | | } - | |_- `E` defined here -... -LL | match e1 { - | ^^ patterns `B` and `C` not covered + --> $DIR/non-exhaustive-defined-here.rs:38:11 + | +LL | match e1 { + | ^^ patterns `B` and `C` not covered + | +note: `E` defined here + --> $DIR/non-exhaustive-defined-here.rs:14:5 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | enum E { + | - +... +LL | B, + | ^ not covered +... +LL | C + | ^ not covered = note: the matched value is of type `E` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ E::A => {} +LL + B | C => todo!() + | error[E0005]: refutable pattern in local binding: `B` and `C` not covered - --> $DIR/non-exhaustive-defined-here.rs:36:9 - | -LL | / enum E { -LL | | -LL | | -LL | | -... | -LL | | B, - | | - not covered -... | -LL | | C - | | - not covered -... | -LL | | -LL | | } - | |_- `E` defined here -... -LL | let E::A = e; - | ^^^^ patterns `B` and `C` not covered + --> $DIR/non-exhaustive-defined-here.rs:44:9 + | +LL | let E::A = e; + | ^^^^ patterns `B` and `C` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html +note: `E` defined here + --> $DIR/non-exhaustive-defined-here.rs:14:5 + | +LL | enum E { + | - +... +LL | B, + | ^ not covered +... +LL | C + | ^ not covered = note: the matched value is of type `E` help: you might want to use `if let` to ignore the variant that isn't matched | @@ -52,52 +48,48 @@ LL | if let E::A = e { /* */ } | ~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0004]: non-exhaustive patterns: `&B` and `&C` not covered - --> $DIR/non-exhaustive-defined-here.rs:40:11 - | -LL | / enum E { -LL | | -LL | | -LL | | -... | -LL | | B, - | | - not covered -... | -LL | | C - | | - not covered -... | -LL | | -LL | | } - | |_- `E` defined here -... -LL | match e { - | ^ patterns `&B` and `&C` not covered + --> $DIR/non-exhaustive-defined-here.rs:52:11 + | +LL | match e { + | ^ patterns `&B` and `&C` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `E` defined here + --> $DIR/non-exhaustive-defined-here.rs:14:5 + | +LL | enum E { + | - +... +LL | B, + | ^ not covered +... +LL | C + | ^ not covered = note: the matched value is of type `&E` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ E::A => {} +LL + &B | &C => todo!() + | error[E0005]: refutable pattern in local binding: `&B` and `&C` not covered - --> $DIR/non-exhaustive-defined-here.rs:44:9 + --> $DIR/non-exhaustive-defined-here.rs:58:9 | -LL | / enum E { -LL | | -LL | | -LL | | -... | -LL | | B, - | | - not covered -... | -LL | | C - | | - not covered -... | -LL | | -LL | | } - | |_- `E` defined here -... -LL | let E::A = e; - | ^^^^ patterns `&B` and `&C` not covered +LL | let E::A = e; + | ^^^^ patterns `&B` and `&C` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html +note: `E` defined here + --> $DIR/non-exhaustive-defined-here.rs:14:5 + | +LL | enum E { + | - +... +LL | B, + | ^ not covered +... +LL | C + | ^ not covered = note: the matched value is of type `&E` help: you might want to use `if let` to ignore the variant that isn't matched | @@ -105,52 +97,48 @@ LL | if let E::A = e { /* */ } | ~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0004]: non-exhaustive patterns: `&&mut &B` and `&&mut &C` not covered - --> $DIR/non-exhaustive-defined-here.rs:48:11 - | -LL | / enum E { -LL | | -LL | | -LL | | -... | -LL | | B, - | | - not covered -... | -LL | | C - | | - not covered -... | -LL | | -LL | | } - | |_- `E` defined here -... -LL | match e { - | ^ patterns `&&mut &B` and `&&mut &C` not covered + --> $DIR/non-exhaustive-defined-here.rs:66:11 + | +LL | match e { + | ^ patterns `&&mut &B` and `&&mut &C` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `E` defined here + --> $DIR/non-exhaustive-defined-here.rs:14:5 + | +LL | enum E { + | - +... +LL | B, + | ^ not covered +... +LL | C + | ^ not covered = note: the matched value is of type `&&mut &E` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ E::A => {} +LL + &&mut &B | &&mut &C => todo!() + | error[E0005]: refutable pattern in local binding: `&&mut &B` and `&&mut &C` not covered - --> $DIR/non-exhaustive-defined-here.rs:52:9 - | -LL | / enum E { -LL | | -LL | | -LL | | -... | -LL | | B, - | | - not covered -... | -LL | | C - | | - not covered -... | -LL | | -LL | | } - | |_- `E` defined here -... -LL | let E::A = e; - | ^^^^ patterns `&&mut &B` and `&&mut &C` not covered + --> $DIR/non-exhaustive-defined-here.rs:72:9 + | +LL | let E::A = e; + | ^^^^ patterns `&&mut &B` and `&&mut &C` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html +note: `E` defined here + --> $DIR/non-exhaustive-defined-here.rs:14:5 + | +LL | enum E { + | - +... +LL | B, + | ^ not covered +... +LL | C + | ^ not covered = note: the matched value is of type `&&mut &E` help: you might want to use `if let` to ignore the variant that isn't matched | @@ -158,42 +146,42 @@ LL | if let E::A = e { /* */ } | error[E0004]: non-exhaustive patterns: `None` not covered - --> $DIR/non-exhaustive-defined-here.rs:65:11 - | -LL | / enum Opt { -LL | | -LL | | -LL | | Some(u8), -LL | | None, - | | ---- not covered -LL | | -LL | | } - | |_- `Opt` defined here -... -LL | match e { - | ^ pattern `None` not covered + --> $DIR/non-exhaustive-defined-here.rs:92:11 + | +LL | match e { + | ^ pattern `None` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `Opt` defined here + --> $DIR/non-exhaustive-defined-here.rs:84:5 + | +LL | enum Opt { + | --- +... +LL | None, + | ^^^^ not covered = note: the matched value is of type `Opt` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ Opt::Some(ref _x) => {} +LL + None => todo!() + | error[E0005]: refutable pattern in local binding: `None` not covered - --> $DIR/non-exhaustive-defined-here.rs:69:9 - | -LL | / enum Opt { -LL | | -LL | | -LL | | Some(u8), -LL | | None, - | | ---- not covered -LL | | -LL | | } - | |_- `Opt` defined here -... -LL | let Opt::Some(ref _x) = e; - | ^^^^^^^^^^^^^^^^^ pattern `None` not covered + --> $DIR/non-exhaustive-defined-here.rs:98:9 + | +LL | let Opt::Some(ref _x) = e; + | ^^^^^^^^^^^^^^^^^ pattern `None` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html +note: `Opt` defined here + --> $DIR/non-exhaustive-defined-here.rs:84:5 + | +LL | enum Opt { + | --- +... +LL | None, + | ^^^^ not covered = note: the matched value is of type `Opt` help: you might want to use `if let` to ignore the variant that isn't matched | diff --git a/src/test/ui/pattern/usefulness/non-exhaustive-match-nested.stderr b/src/test/ui/pattern/usefulness/non-exhaustive-match-nested.stderr index 928e9068266..cbbd544f943 100644 --- a/src/test/ui/pattern/usefulness/non-exhaustive-match-nested.stderr +++ b/src/test/ui/pattern/usefulness/non-exhaustive-match-nested.stderr @@ -4,23 +4,30 @@ error[E0004]: non-exhaustive patterns: `(Some(&[]), Err(_))` not covered LL | match (l1, l2) { | ^^^^^^^^ pattern `(Some(&[]), Err(_))` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(Option<&[T]>, Result<&[T], ()>)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ (None, Ok(&[_, _, ..])) => "None, Ok(at least two elements)", +LL + (Some(&[]), Err(_)) => todo!() + | error[E0004]: non-exhaustive patterns: `A(C)` not covered --> $DIR/non-exhaustive-match-nested.rs:15:11 | -LL | enum T { A(U), B } - | ------------------ - | | | - | | not covered - | `T` defined here -... LL | match x { | ^ pattern `A(C)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `T` defined here + --> $DIR/non-exhaustive-match-nested.rs:1:10 + | +LL | enum T { A(U), B } + | - ^ not covered = note: the matched value is of type `T` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ T::B => { panic!("goodbye"); } +LL + A(C) => todo!() + | error: aborting due to 2 previous errors diff --git a/src/test/ui/pattern/usefulness/non-exhaustive-match.stderr b/src/test/ui/pattern/usefulness/non-exhaustive-match.stderr index 1ca0a33bf37..e7fa6a7814f 100644 --- a/src/test/ui/pattern/usefulness/non-exhaustive-match.stderr +++ b/src/test/ui/pattern/usefulness/non-exhaustive-match.stderr @@ -1,17 +1,19 @@ error[E0004]: non-exhaustive patterns: `A` not covered --> $DIR/non-exhaustive-match.rs:7:11 | -LL | enum T { A, B } - | --------------- - | | | - | | not covered - | `T` defined here -... LL | match x { T::B => { } } | ^ pattern `A` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `T` defined here + --> $DIR/non-exhaustive-match.rs:3:10 + | +LL | enum T { A, B } + | - ^ not covered = note: the matched value is of type `T` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL | match x { T::B => { } A => todo!() } + | ++++++++++++ error[E0004]: non-exhaustive patterns: `false` not covered --> $DIR/non-exhaustive-match.rs:8:11 @@ -19,8 +21,12 @@ error[E0004]: non-exhaustive patterns: `false` not covered LL | match true { | ^^^^ pattern `false` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `bool` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ true => {} +LL + false => todo!() + | error[E0004]: non-exhaustive patterns: `Some(_)` not covered --> $DIR/non-exhaustive-match.rs:11:11 @@ -28,13 +34,24 @@ error[E0004]: non-exhaustive patterns: `Some(_)` not covered LL | match Some(10) { | ^^^^^^^^ pattern `Some(_)` not covered | - ::: $SRC_DIR/core/src/option.rs:LL:COL +note: `Option<i32>` defined here + --> $SRC_DIR/core/src/option.rs:LL:COL + | +LL | / pub enum Option<T> { +LL | | /// No value. +LL | | #[lang = "None"] +LL | | #[stable(feature = "rust1", since = "1.0.0")] +... | +LL | | Some(#[stable(feature = "rust1", since = "1.0.0")] T), + | | ^^^^ not covered +LL | | } + | |_- + = note: the matched value is of type `Option<i32>` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL | Some(#[stable(feature = "rust1", since = "1.0.0")] T), - | ---- not covered +LL ~ None => {} +LL + Some(_) => todo!() | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `Option<i32>` error[E0004]: non-exhaustive patterns: `(_, _, i32::MIN..=3_i32)` and `(_, _, 5_i32..=i32::MAX)` not covered --> $DIR/non-exhaustive-match.rs:14:11 @@ -42,8 +59,12 @@ error[E0004]: non-exhaustive patterns: `(_, _, i32::MIN..=3_i32)` and `(_, _, 5_ LL | match (2, 3, 4) { | ^^^^^^^^^ patterns `(_, _, i32::MIN..=3_i32)` and `(_, _, 5_i32..=i32::MAX)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(i32, i32, i32)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ (_, _, 4) => {} +LL + (_, _, i32::MIN..=3_i32) | (_, _, 5_i32..=i32::MAX) => todo!() + | error[E0004]: non-exhaustive patterns: `(A, A)` and `(B, B)` not covered --> $DIR/non-exhaustive-match.rs:18:11 @@ -51,23 +72,30 @@ error[E0004]: non-exhaustive patterns: `(A, A)` and `(B, B)` not covered LL | match (T::A, T::A) { | ^^^^^^^^^^^^ patterns `(A, A)` and `(B, B)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(T, T)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ (T::B, T::A) => {} +LL + (A, A) | (B, B) => todo!() + | error[E0004]: non-exhaustive patterns: `B` not covered --> $DIR/non-exhaustive-match.rs:22:11 | -LL | enum T { A, B } - | --------------- - | | | - | | not covered - | `T` defined here -... LL | match T::A { | ^^^^ pattern `B` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `T` defined here + --> $DIR/non-exhaustive-match.rs:3:13 + | +LL | enum T { A, B } + | - ^ not covered = note: the matched value is of type `T` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ T::A => {} +LL + B => todo!() + | error[E0004]: non-exhaustive patterns: `[]` not covered --> $DIR/non-exhaustive-match.rs:33:11 @@ -75,8 +103,12 @@ error[E0004]: non-exhaustive patterns: `[]` not covered LL | match *vec { | ^^^^ pattern `[]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `[Option<isize>]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [None] => {} +LL + [] => todo!() + | error[E0004]: non-exhaustive patterns: `[_, _, _, _, ..]` not covered --> $DIR/non-exhaustive-match.rs:46:11 @@ -84,8 +116,12 @@ error[E0004]: non-exhaustive patterns: `[_, _, _, _, ..]` not covered LL | match *vec { | ^^^^ pattern `[_, _, _, _, ..]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `[f32]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [] => (), +LL + [_, _, _, _, ..] => todo!() + | error: aborting due to 8 previous errors diff --git a/src/test/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr b/src/test/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr index c9ed12aae5f..b0cfd631fb0 100644 --- a/src/test/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr +++ b/src/test/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr @@ -1,83 +1,102 @@ error[E0004]: non-exhaustive patterns: `Foo { first: false, second: Some([_, _, _, _]) }` not covered --> $DIR/non-exhaustive-pattern-witness.rs:7:11 | -LL | / struct Foo { -LL | | first: bool, -LL | | second: Option<[usize; 4]> -LL | | } - | |_- `Foo` defined here -... -LL | match (Foo { first: true, second: None }) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo { first: false, second: Some([_, _, _, _]) }` not covered +LL | match (Foo { first: true, second: None }) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo { first: false, second: Some([_, _, _, _]) }` not covered + | +note: `Foo` defined here + --> $DIR/non-exhaustive-pattern-witness.rs:1:8 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | struct Foo { + | ^^^ = note: the matched value is of type `Foo` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ Foo { first: false, second: Some([1, 2, 3, 4]) } => (), +LL + Foo { first: false, second: Some([_, _, _, _]) } => todo!() + | error[E0004]: non-exhaustive patterns: `Red` not covered --> $DIR/non-exhaustive-pattern-witness.rs:23:11 | -LL | / enum Color { -LL | | Red, - | | --- not covered -LL | | Green, -LL | | CustomRGBA { a: bool, r: u8, g: u8, b: u8 } -LL | | } - | |_- `Color` defined here -... -LL | match Color::Red { - | ^^^^^^^^^^ pattern `Red` not covered +LL | match Color::Red { + | ^^^^^^^^^^ pattern `Red` not covered + | +note: `Color` defined here + --> $DIR/non-exhaustive-pattern-witness.rs:17:5 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | enum Color { + | ----- +LL | Red, + | ^^^ not covered = note: the matched value is of type `Color` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ Color::Green => (), +LL + Red => todo!() + | error[E0004]: non-exhaustive patterns: `East`, `South` and `West` not covered --> $DIR/non-exhaustive-pattern-witness.rs:35:11 | -LL | / enum Direction { -LL | | North, East, South, West - | | ---- ----- ---- not covered - | | | | - | | | not covered - | | not covered -LL | | } - | |_- `Direction` defined here -... -LL | match Direction::North { - | ^^^^^^^^^^^^^^^^ patterns `East`, `South` and `West` not covered +LL | match Direction::North { + | ^^^^^^^^^^^^^^^^ patterns `East`, `South` and `West` not covered + | +note: `Direction` defined here + --> $DIR/non-exhaustive-pattern-witness.rs:31:12 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | enum Direction { + | --------- +LL | North, East, South, West + | ^^^^ ^^^^^ ^^^^ not covered + | | | + | | not covered + | not covered = note: the matched value is of type `Direction` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ Direction::North => (), +LL + East | South | West => todo!() + | error[E0004]: non-exhaustive patterns: `Second`, `Third`, `Fourth` and 8 more not covered --> $DIR/non-exhaustive-pattern-witness.rs:46:11 | -LL | / enum ExcessiveEnum { -LL | | First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth, Eleventh, Twelfth -LL | | } - | |_- `ExcessiveEnum` defined here -... -LL | match ExcessiveEnum::First { - | ^^^^^^^^^^^^^^^^^^^^ patterns `Second`, `Third`, `Fourth` and 8 more not covered +LL | match ExcessiveEnum::First { + | ^^^^^^^^^^^^^^^^^^^^ patterns `Second`, `Third`, `Fourth` and 8 more not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `ExcessiveEnum` defined here + --> $DIR/non-exhaustive-pattern-witness.rs:41:6 + | +LL | enum ExcessiveEnum { + | ^^^^^^^^^^^^^ = note: the matched value is of type `ExcessiveEnum` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms + | +LL ~ ExcessiveEnum::First => (), +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `CustomRGBA { a: true, .. }` not covered --> $DIR/non-exhaustive-pattern-witness.rs:54:11 | -LL | / enum Color { -LL | | Red, -LL | | Green, -LL | | CustomRGBA { a: bool, r: u8, g: u8, b: u8 } - | | ---------- not covered -LL | | } - | |_- `Color` defined here -... -LL | match Color::Red { - | ^^^^^^^^^^ pattern `CustomRGBA { a: true, .. }` not covered +LL | match Color::Red { + | ^^^^^^^^^^ pattern `CustomRGBA { a: true, .. }` not covered + | +note: `Color` defined here + --> $DIR/non-exhaustive-pattern-witness.rs:19:5 | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | enum Color { + | ----- +... +LL | CustomRGBA { a: bool, r: u8, g: u8, b: u8 } + | ^^^^^^^^^^ not covered = note: the matched value is of type `Color` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ Color::CustomRGBA { a: false, r: _, g: _, b: _ } => (), +LL + CustomRGBA { a: true, .. } => todo!() + | error[E0004]: non-exhaustive patterns: `[Second(true), Second(false)]` not covered --> $DIR/non-exhaustive-pattern-witness.rs:70:11 @@ -85,8 +104,12 @@ error[E0004]: non-exhaustive patterns: `[Second(true), Second(false)]` not cover LL | match *x { | ^^ pattern `[Second(true), Second(false)]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `[Enum]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [_, _, ref tail @ .., _] => (), +LL + [Second(true), Second(false)] => todo!() + | error[E0004]: non-exhaustive patterns: `((), false)` not covered --> $DIR/non-exhaustive-pattern-witness.rs:83:11 @@ -94,8 +117,12 @@ error[E0004]: non-exhaustive patterns: `((), false)` not covered LL | match ((), false) { | ^^^^^^^^^^^ pattern `((), false)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `((), bool)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ ((), true) => (), +LL + ((), false) => todo!() + | error: aborting due to 7 previous errors diff --git a/src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr b/src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr index e34770fb912..5d1e170ae6c 100644 --- a/src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr +++ b/src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr @@ -4,8 +4,12 @@ error[E0004]: non-exhaustive patterns: `&[false, _]` not covered LL | match s2 { | ^^ pattern `&[false, _]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool; 2]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [true, .., true] => {} +LL + &[false, _] => todo!() + | error[E0004]: non-exhaustive patterns: `&[false, ..]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:12:11 @@ -13,8 +17,12 @@ error[E0004]: non-exhaustive patterns: `&[false, ..]` not covered LL | match s3 { | ^^ pattern `&[false, ..]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool; 3]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [true, .., true] => {} +LL + &[false, ..] => todo!() + | error[E0004]: non-exhaustive patterns: `&[false, ..]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:16:11 @@ -22,8 +30,12 @@ error[E0004]: non-exhaustive patterns: `&[false, ..]` not covered LL | match s10 { | ^^^ pattern `&[false, ..]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool; 10]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [true, .., true] => {} +LL + &[false, ..] => todo!() + | error[E0004]: non-exhaustive patterns: `&[false, true]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:25:11 @@ -31,8 +43,12 @@ error[E0004]: non-exhaustive patterns: `&[false, true]` not covered LL | match s2 { | ^^ pattern `&[false, true]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool; 2]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [.., false] => {} +LL + &[false, true] => todo!() + | error[E0004]: non-exhaustive patterns: `&[false, .., true]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:30:11 @@ -40,8 +56,12 @@ error[E0004]: non-exhaustive patterns: `&[false, .., true]` not covered LL | match s3 { | ^^ pattern `&[false, .., true]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool; 3]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [.., false] => {} +LL + &[false, .., true] => todo!() + | error[E0004]: non-exhaustive patterns: `&[false, .., true]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:35:11 @@ -49,8 +69,12 @@ error[E0004]: non-exhaustive patterns: `&[false, .., true]` not covered LL | match s { | ^ pattern `&[false, .., true]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [.., false] => {} +LL + &[false, .., true] => todo!() + | error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:42:11 @@ -58,8 +82,12 @@ error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered LL | match s { | ^ pattern `&[_, ..]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [] => {} +LL + &[_, ..] => todo!() + | error[E0004]: non-exhaustive patterns: `&[_, _, ..]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:46:11 @@ -67,8 +95,12 @@ error[E0004]: non-exhaustive patterns: `&[_, _, ..]` not covered LL | match s { | ^ pattern `&[_, _, ..]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [_] => {} +LL + &[_, _, ..] => todo!() + | error[E0004]: non-exhaustive patterns: `&[false, ..]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:51:11 @@ -76,8 +108,12 @@ error[E0004]: non-exhaustive patterns: `&[false, ..]` not covered LL | match s { | ^ pattern `&[false, ..]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [true, ..] => {} +LL + &[false, ..] => todo!() + | error[E0004]: non-exhaustive patterns: `&[false, _, ..]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:56:11 @@ -85,8 +121,12 @@ error[E0004]: non-exhaustive patterns: `&[false, _, ..]` not covered LL | match s { | ^ pattern `&[false, _, ..]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [true, ..] => {} +LL + &[false, _, ..] => todo!() + | error[E0004]: non-exhaustive patterns: `&[_, .., false]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:62:11 @@ -94,8 +134,12 @@ error[E0004]: non-exhaustive patterns: `&[_, .., false]` not covered LL | match s { | ^ pattern `&[_, .., false]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [.., true] => {} +LL + &[_, .., false] => todo!() + | error[E0004]: non-exhaustive patterns: `&[_, _, .., true]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:69:11 @@ -103,8 +147,12 @@ error[E0004]: non-exhaustive patterns: `&[_, _, .., true]` not covered LL | match s { | ^ pattern `&[_, _, .., true]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [.., false] => {} +LL + &[_, _, .., true] => todo!() + | error[E0004]: non-exhaustive patterns: `&[true, _, .., _]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:76:11 @@ -112,8 +160,12 @@ error[E0004]: non-exhaustive patterns: `&[true, _, .., _]` not covered LL | match s { | ^ pattern `&[true, _, .., _]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [false, .., false] => {} +LL + &[true, _, .., _] => todo!() + | error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:85:11 @@ -121,8 +173,12 @@ error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered LL | match s { | ^ patterns `&[]` and `&[_, _, ..]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ &[true] => {} +LL + &[] | &[_, _, ..] => todo!() + | error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:89:11 @@ -130,8 +186,12 @@ error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered LL | match s { | ^ patterns `&[]` and `&[_, _, ..]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ CONST => {} +LL + &[] | &[_, _, ..] => todo!() + | error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:93:11 @@ -139,8 +199,12 @@ error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered LL | match s { | ^ patterns `&[]` and `&[_, _, ..]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ &[false] => {} +LL + &[] | &[_, _, ..] => todo!() + | error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:98:11 @@ -148,8 +212,12 @@ error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered LL | match s { | ^ patterns `&[]` and `&[_, _, ..]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ CONST => {} +LL + &[] | &[_, _, ..] => todo!() + | error[E0004]: non-exhaustive patterns: `&[_, _, ..]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:103:11 @@ -157,8 +225,12 @@ error[E0004]: non-exhaustive patterns: `&[_, _, ..]` not covered LL | match s { | ^ pattern `&[_, _, ..]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ CONST => {} +LL + &[_, _, ..] => todo!() + | error[E0004]: non-exhaustive patterns: `&[false]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:108:11 @@ -166,8 +238,12 @@ error[E0004]: non-exhaustive patterns: `&[false]` not covered LL | match s { | ^ pattern `&[false]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ &[_, _, ..] => {} +LL + &[false] => todo!() + | error[E0004]: non-exhaustive patterns: `&[false]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:121:11 @@ -175,8 +251,12 @@ error[E0004]: non-exhaustive patterns: `&[false]` not covered LL | match s1 { | ^^ pattern `&[false]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[bool; 1]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ CONST1 => {} +LL + &[false] => todo!() + | error: aborting due to 20 previous errors diff --git a/src/test/ui/pattern/usefulness/stable-gated-patterns.stderr b/src/test/ui/pattern/usefulness/stable-gated-patterns.stderr index 9b42565ac73..696ef9d8de9 100644 --- a/src/test/ui/pattern/usefulness/stable-gated-patterns.stderr +++ b/src/test/ui/pattern/usefulness/stable-gated-patterns.stderr @@ -4,13 +4,25 @@ error[E0004]: non-exhaustive patterns: `Stable2` and `_` not covered LL | match Foo::Stable { | ^^^^^^^^^^^ patterns `Stable2` and `_` not covered | - ::: $DIR/auxiliary/unstable.rs:9:5 +note: `Foo` defined here + --> $DIR/auxiliary/unstable.rs:9:5 | -LL | Stable2, - | ------- not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | / pub enum Foo { +LL | | #[stable(feature = "stable_test_feature", since = "1.0.0")] +LL | | Stable, +LL | | #[stable(feature = "stable_test_feature", since = "1.0.0")] +LL | | Stable2, + | | ^^^^^^^ not covered +LL | | #[unstable(feature = "unstable_test_feature", issue = "none")] +LL | | Unstable, +LL | | } + | |_- = note: the matched value is of type `Foo` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ Foo::Stable => {} +LL + Stable2 | _ => todo!() + | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/stable-gated-patterns.rs:13:11 @@ -18,8 +30,23 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | match Foo::Stable { | ^^^^^^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `Foo` defined here + --> $DIR/auxiliary/unstable.rs:5:1 + | +LL | / pub enum Foo { +LL | | #[stable(feature = "stable_test_feature", since = "1.0.0")] +LL | | Stable, +LL | | #[stable(feature = "stable_test_feature", since = "1.0.0")] +... | +LL | | Unstable, +LL | | } + | |_^ = note: the matched value is of type `Foo` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ Foo::Stable2 => {} +LL + _ => todo!() + | error: aborting due to 2 previous errors diff --git a/src/test/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr b/src/test/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr index 23ff6c626f7..6127fad3f7d 100644 --- a/src/test/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr +++ b/src/test/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr @@ -1,18 +1,22 @@ error[E0004]: non-exhaustive patterns: `B { x: Some(_) }` not covered --> $DIR/struct-like-enum-nonexhaustive.rs:8:11 | -LL | / enum A { -LL | | B { x: Option<isize> }, - | | - not covered -LL | | C -LL | | } - | |_- `A` defined here -... -LL | match x { - | ^ pattern `B { x: Some(_) }` not covered +LL | match x { + | ^ pattern `B { x: Some(_) }` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `A` defined here + --> $DIR/struct-like-enum-nonexhaustive.rs:2:5 + | +LL | enum A { + | - +LL | B { x: Option<isize> }, + | ^ not covered = note: the matched value is of type `A` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ A::B { x: None } => {} +LL + B { x: Some(_) } => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr b/src/test/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr index ca8f67f3c8d..fc0430d06fa 100644 --- a/src/test/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr +++ b/src/test/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr @@ -1,14 +1,20 @@ error[E0004]: non-exhaustive patterns: `Foo(_, _)` not covered --> $DIR/tuple-struct-nonexhaustive.rs:5:11 | -LL | struct Foo(isize, isize); - | ------------------------- `Foo` defined here -... LL | match x { | ^ pattern `Foo(_, _)` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `Foo` defined here + --> $DIR/tuple-struct-nonexhaustive.rs:1:8 + | +LL | struct Foo(isize, isize); + | ^^^ = note: the matched value is of type `Foo` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ Foo(2, b) => println!("{}", b) +LL + Foo(_, _) => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/type_polymorphic_byte_str_literals.stderr b/src/test/ui/pattern/usefulness/type_polymorphic_byte_str_literals.stderr index 6ce53a4f21e..acae605dae3 100644 --- a/src/test/ui/pattern/usefulness/type_polymorphic_byte_str_literals.stderr +++ b/src/test/ui/pattern/usefulness/type_polymorphic_byte_str_literals.stderr @@ -4,8 +4,12 @@ error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered LL | match data { | ^^^^ pattern `&[_, ..]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[u8]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ b"" => 1, +LL ~ &[_, ..] => todo!(), + | error[E0004]: non-exhaustive patterns: `&[]`, `&[_]`, `&[_, _]` and 1 more not covered --> $DIR/type_polymorphic_byte_str_literals.rs:23:11 @@ -13,8 +17,12 @@ error[E0004]: non-exhaustive patterns: `&[]`, `&[_]`, `&[_, _]` and 1 more not c LL | match data { | ^^^^ patterns `&[]`, `&[_]`, `&[_, _]` and 1 more not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[u8]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms + | +LL ~ [_, _, _] => 1, +LL ~ _ => todo!(), + | error: aborting due to 2 previous errors diff --git a/src/test/ui/pattern/usefulness/unstable-gated-patterns.stderr b/src/test/ui/pattern/usefulness/unstable-gated-patterns.stderr index f9c0196b765..8487c9725da 100644 --- a/src/test/ui/pattern/usefulness/unstable-gated-patterns.stderr +++ b/src/test/ui/pattern/usefulness/unstable-gated-patterns.stderr @@ -4,13 +4,24 @@ error[E0004]: non-exhaustive patterns: `Unstable` not covered LL | match Foo::Stable { | ^^^^^^^^^^^ pattern `Unstable` not covered | - ::: $DIR/auxiliary/unstable.rs:11:5 +note: `Foo` defined here + --> $DIR/auxiliary/unstable.rs:11:5 | -LL | Unstable, - | -------- not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | / pub enum Foo { +LL | | #[stable(feature = "stable_test_feature", since = "1.0.0")] +LL | | Stable, +LL | | #[stable(feature = "stable_test_feature", since = "1.0.0")] +... | +LL | | Unstable, + | | ^^^^^^^^ not covered +LL | | } + | |_- = note: the matched value is of type `Foo` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ Foo::Stable2 => {} +LL + Unstable => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/recursion/recursive-types-are-not-uninhabited.stderr b/src/test/ui/recursion/recursive-types-are-not-uninhabited.stderr index f904a0ecd11..ded3cf3ad1d 100644 --- a/src/test/ui/recursion/recursive-types-are-not-uninhabited.stderr +++ b/src/test/ui/recursion/recursive-types-are-not-uninhabited.stderr @@ -4,13 +4,20 @@ error[E0005]: refutable pattern in local binding: `Err(_)` not covered LL | let Ok(x) = res; | ^^^^^ pattern `Err(_)` not covered | - ::: $SRC_DIR/core/src/result.rs:LL:COL - | -LL | Err(#[stable(feature = "rust1", since = "1.0.0")] E), - | --- not covered - | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html +note: `Result<u32, &R>` defined here + --> $SRC_DIR/core/src/result.rs:LL:COL + | +LL | / pub enum Result<T, E> { +LL | | /// Contains the success value +LL | | #[lang = "Ok"] +LL | | #[stable(feature = "rust1", since = "1.0.0")] +... | +LL | | Err(#[stable(feature = "rust1", since = "1.0.0")] E), + | | ^^^ not covered +LL | | } + | |_- = note: the matched value is of type `Result<u32, &R>` help: you might want to use `if let` to ignore the variant that isn't matched | diff --git a/src/test/ui/rfc-2005-default-binding-mode/slice.stderr b/src/test/ui/rfc-2005-default-binding-mode/slice.stderr index 18d8f5481c9..60c1f5420f6 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/slice.stderr +++ b/src/test/ui/rfc-2005-default-binding-mode/slice.stderr @@ -4,8 +4,12 @@ error[E0004]: non-exhaustive patterns: `&[]` not covered LL | match sl { | ^^ pattern `&[]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[u8]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [first, remainder @ ..] => {} +LL ~ &[] => todo!(), + | error: aborting due to previous error diff --git a/src/test/ui/rfc-2008-non-exhaustive/enum.stderr b/src/test/ui/rfc-2008-non-exhaustive/enum.stderr index cd9ded81e6a..5ef078c2005 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/enum.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/enum.stderr @@ -4,8 +4,18 @@ error[E0004]: non-exhaustive patterns: type `EmptyNonExhaustiveEnum` is non-empt LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `EmptyNonExhaustiveEnum` defined here + --> $DIR/auxiliary/enums.rs:18:1 + | +LL | pub enum EmptyNonExhaustiveEnum {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `EmptyNonExhaustiveEnum`, which is marked as non-exhaustive +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/enum.rs:16:11 @@ -13,8 +23,21 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | match enum_unit { | ^^^^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `NonExhaustiveEnum` defined here + --> $DIR/auxiliary/enums.rs:4:1 + | +LL | / pub enum NonExhaustiveEnum { +LL | | Unit, +LL | | Tuple(u32), +LL | | Struct { field: u32 }, +LL | | } + | |_^ = note: the matched value is of type `NonExhaustiveEnum`, which is marked as non-exhaustive +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ NonExhaustiveEnum::Struct { .. } => "third", +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/enum.rs:23:11 @@ -22,8 +45,22 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | match enum_unit {}; | ^^^^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `NonExhaustiveEnum` defined here + --> $DIR/auxiliary/enums.rs:4:1 + | +LL | / pub enum NonExhaustiveEnum { +LL | | Unit, +LL | | Tuple(u32), +LL | | Struct { field: u32 }, +LL | | } + | |_^ = note: the matched value is of type `NonExhaustiveEnum`, which is marked as non-exhaustive +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match enum_unit { +LL + _ => todo!(), +LL ~ }; + | error: aborting due to 3 previous errors diff --git a/src/test/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr b/src/test/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr index 966f3a2e414..1f20904483f 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr @@ -13,46 +13,56 @@ LL | #![deny(unreachable_patterns)] error[E0004]: non-exhaustive patterns: `Unit`, `Tuple(_)` and `Struct { .. }` not covered --> $DIR/enum_same_crate_empty_match.rs:33:11 | -LL | / pub enum NonExhaustiveEnum { -LL | | Unit, - | | ---- not covered -LL | | -LL | | Tuple(u32), - | | ----- not covered -LL | | -LL | | Struct { field: u32 } - | | ------ not covered -LL | | -LL | | } - | |_- `NonExhaustiveEnum` defined here -... -LL | match NonExhaustiveEnum::Unit {} - | ^^^^^^^^^^^^^^^^^^^^^^^ patterns `Unit`, `Tuple(_)` and `Struct { .. }` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | match NonExhaustiveEnum::Unit {} + | ^^^^^^^^^^^^^^^^^^^^^^^ patterns `Unit`, `Tuple(_)` and `Struct { .. }` not covered + | +note: `NonExhaustiveEnum` defined here + --> $DIR/enum_same_crate_empty_match.rs:5:5 + | +LL | pub enum NonExhaustiveEnum { + | ----------------- +LL | Unit, + | ^^^^ not covered +LL | +LL | Tuple(u32), + | ^^^^^ not covered +LL | +LL | Struct { field: u32 } + | ^^^^^^ not covered = note: the matched value is of type `NonExhaustiveEnum` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ match NonExhaustiveEnum::Unit { +LL + Unit | Tuple(_) | Struct { .. } => todo!(), +LL + } + | error[E0004]: non-exhaustive patterns: `Unit`, `Tuple(_)` and `Struct { .. }` not covered --> $DIR/enum_same_crate_empty_match.rs:35:11 | -LL | / pub enum NormalEnum { -LL | | Unit, - | | ---- not covered -LL | | -LL | | Tuple(u32), - | | ----- not covered -LL | | -LL | | Struct { field: u32 } - | | ------ not covered -LL | | -LL | | } - | |_- `NormalEnum` defined here -... -LL | match NormalEnum::Unit {} - | ^^^^^^^^^^^^^^^^ patterns `Unit`, `Tuple(_)` and `Struct { .. }` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | match NormalEnum::Unit {} + | ^^^^^^^^^^^^^^^^ patterns `Unit`, `Tuple(_)` and `Struct { .. }` not covered + | +note: `NormalEnum` defined here + --> $DIR/enum_same_crate_empty_match.rs:14:5 + | +LL | pub enum NormalEnum { + | ---------- +LL | Unit, + | ^^^^ not covered +LL | +LL | Tuple(u32), + | ^^^^^ not covered +LL | +LL | Struct { field: u32 } + | ^^^^^^ not covered = note: the matched value is of type `NormalEnum` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ match NormalEnum::Unit { +LL + Unit | Tuple(_) | Struct { .. } => todo!(), +LL + } + | error: aborting due to 3 previous errors diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr index c461302a366..2dc4eabb863 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr @@ -4,8 +4,18 @@ error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedEnum` is non-emp LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `IndirectUninhabitedEnum` defined here + --> $DIR/auxiliary/uninhabited.rs:26:1 + | +LL | pub struct IndirectUninhabitedEnum(UninhabitedEnum); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `IndirectUninhabitedEnum` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedStruct` is non-empty --> $DIR/indirect_match.rs:23:11 @@ -13,8 +23,18 @@ error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedStruct` is non-e LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `IndirectUninhabitedStruct` defined here + --> $DIR/auxiliary/uninhabited.rs:28:1 + | +LL | pub struct IndirectUninhabitedStruct(UninhabitedStruct); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `IndirectUninhabitedStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedTupleStruct` is non-empty --> $DIR/indirect_match.rs:27:11 @@ -22,8 +42,18 @@ error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedTupleStruct` is LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `IndirectUninhabitedTupleStruct` defined here + --> $DIR/auxiliary/uninhabited.rs:30:1 + | +LL | pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `IndirectUninhabitedTupleStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedVariants` is non-empty --> $DIR/indirect_match.rs:33:11 @@ -31,8 +61,18 @@ error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedVariants` is non LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `IndirectUninhabitedVariants` defined here + --> $DIR/auxiliary/uninhabited.rs:32:1 + | +LL | pub struct IndirectUninhabitedVariants(UninhabitedVariants); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `IndirectUninhabitedVariants` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error: aborting due to 4 previous errors diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.stderr index 42bf67c0a45..c1219054140 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.stderr @@ -1,50 +1,78 @@ error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedEnum` is non-empty --> $DIR/indirect_match_same_crate.rs:34:11 | -LL | pub struct IndirectUninhabitedEnum(UninhabitedEnum); - | ---------------------------------------------------- `IndirectUninhabitedEnum` defined here -... LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `IndirectUninhabitedEnum` defined here + --> $DIR/indirect_match_same_crate.rs:20:12 + | +LL | pub struct IndirectUninhabitedEnum(UninhabitedEnum); + | ^^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `IndirectUninhabitedEnum` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedStruct` is non-empty --> $DIR/indirect_match_same_crate.rs:38:11 | -LL | pub struct IndirectUninhabitedStruct(UninhabitedStruct); - | -------------------------------------------------------- `IndirectUninhabitedStruct` defined here -... LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `IndirectUninhabitedStruct` defined here + --> $DIR/indirect_match_same_crate.rs:22:12 + | +LL | pub struct IndirectUninhabitedStruct(UninhabitedStruct); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `IndirectUninhabitedStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedTupleStruct` is non-empty --> $DIR/indirect_match_same_crate.rs:42:11 | -LL | pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); - | ------------------------------------------------------------------ `IndirectUninhabitedTupleStruct` defined here -... LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `IndirectUninhabitedTupleStruct` defined here + --> $DIR/indirect_match_same_crate.rs:24:12 + | +LL | pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `IndirectUninhabitedTupleStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedVariants` is non-empty --> $DIR/indirect_match_same_crate.rs:48:11 | -LL | pub struct IndirectUninhabitedVariants(UninhabitedVariants); - | ------------------------------------------------------------ `IndirectUninhabitedVariants` defined here -... LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `IndirectUninhabitedVariants` defined here + --> $DIR/indirect_match_same_crate.rs:26:12 + | +LL | pub struct IndirectUninhabitedVariants(UninhabitedVariants); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `IndirectUninhabitedVariants` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error: aborting due to 4 previous errors diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr index c397158c024..f0cb13de3f7 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr @@ -4,8 +4,18 @@ error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedEnum` is non-emp LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `IndirectUninhabitedEnum` defined here + --> $DIR/auxiliary/uninhabited.rs:26:1 + | +LL | pub struct IndirectUninhabitedEnum(UninhabitedEnum); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `IndirectUninhabitedEnum` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedStruct` is non-empty --> $DIR/indirect_match_with_exhaustive_patterns.rs:27:11 @@ -13,8 +23,18 @@ error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedStruct` is non-e LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `IndirectUninhabitedStruct` defined here + --> $DIR/auxiliary/uninhabited.rs:28:1 + | +LL | pub struct IndirectUninhabitedStruct(UninhabitedStruct); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `IndirectUninhabitedStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedTupleStruct` is non-empty --> $DIR/indirect_match_with_exhaustive_patterns.rs:31:11 @@ -22,8 +42,18 @@ error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedTupleStruct` is LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `IndirectUninhabitedTupleStruct` defined here + --> $DIR/auxiliary/uninhabited.rs:30:1 + | +LL | pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `IndirectUninhabitedTupleStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedVariants` is non-empty --> $DIR/indirect_match_with_exhaustive_patterns.rs:37:11 @@ -31,8 +61,18 @@ error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedVariants` is non LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `IndirectUninhabitedVariants` defined here + --> $DIR/auxiliary/uninhabited.rs:32:1 + | +LL | pub struct IndirectUninhabitedVariants(UninhabitedVariants); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `IndirectUninhabitedVariants` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error: aborting due to 4 previous errors diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match.stderr index d21a94a0d64..49febd9241d 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match.stderr @@ -4,8 +4,19 @@ error[E0004]: non-exhaustive patterns: type `UninhabitedEnum` is non-empty LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `UninhabitedEnum` defined here + --> $DIR/auxiliary/uninhabited.rs:5:1 + | +LL | / pub enum UninhabitedEnum { +LL | | } + | |_^ = note: the matched value is of type `UninhabitedEnum`, which is marked as non-exhaustive +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: type `UninhabitedStruct` is non-empty --> $DIR/match.rs:23:11 @@ -13,8 +24,20 @@ error[E0004]: non-exhaustive patterns: type `UninhabitedStruct` is non-empty LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `UninhabitedStruct` defined here + --> $DIR/auxiliary/uninhabited.rs:9:1 + | +LL | / pub struct UninhabitedStruct { +LL | | _priv: !, +LL | | } + | |_^ = note: the matched value is of type `UninhabitedStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: type `UninhabitedTupleStruct` is non-empty --> $DIR/match.rs:27:11 @@ -22,8 +45,18 @@ error[E0004]: non-exhaustive patterns: type `UninhabitedTupleStruct` is non-empt LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `UninhabitedTupleStruct` defined here + --> $DIR/auxiliary/uninhabited.rs:14:1 + | +LL | pub struct UninhabitedTupleStruct(!); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `UninhabitedTupleStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: `Tuple(_)` and `Struct { .. }` not covered --> $DIR/match.rs:31:11 @@ -31,15 +64,23 @@ error[E0004]: non-exhaustive patterns: `Tuple(_)` and `Struct { .. }` not covere LL | match x {} | ^ patterns `Tuple(_)` and `Struct { .. }` not covered | - ::: $DIR/auxiliary/uninhabited.rs:17:23 +note: `UninhabitedVariants` defined here + --> $DIR/auxiliary/uninhabited.rs:17:23 | -LL | #[non_exhaustive] Tuple(!), - | ----- not covered -LL | #[non_exhaustive] Struct { x: ! } - | ------ not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | / pub enum UninhabitedVariants { +LL | | #[non_exhaustive] Tuple(!), + | | ^^^^^ not covered +LL | | #[non_exhaustive] Struct { x: ! } + | | ^^^^^^ not covered +LL | | } + | |_- = note: the matched value is of type `UninhabitedVariants` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ match x { +LL + Tuple(_) | Struct { .. } => todo!(), +LL ~ } + | error: aborting due to 4 previous errors diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr index e4d0c7022f3..c89c70ae6cc 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr @@ -1,45 +1,63 @@ error[E0004]: non-exhaustive patterns: type `UninhabitedStruct` is non-empty --> $DIR/match_same_crate.rs:30:11 | -LL | / pub struct UninhabitedStruct { -LL | | _priv: !, -LL | | } - | |_- `UninhabitedStruct` defined here -... -LL | match x {} - | ^ - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | match x {} + | ^ + | +note: `UninhabitedStruct` defined here + --> $DIR/match_same_crate.rs:8:12 + | +LL | pub struct UninhabitedStruct { + | ^^^^^^^^^^^^^^^^^ = note: the matched value is of type `UninhabitedStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: type `UninhabitedTupleStruct` is non-empty --> $DIR/match_same_crate.rs:34:11 | -LL | pub struct UninhabitedTupleStruct(!); - | ------------------------------------- `UninhabitedTupleStruct` defined here -... LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `UninhabitedTupleStruct` defined here + --> $DIR/match_same_crate.rs:13:12 + | +LL | pub struct UninhabitedTupleStruct(!); + | ^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `UninhabitedTupleStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: `Tuple(_)` and `Struct { .. }` not covered --> $DIR/match_same_crate.rs:38:11 | -LL | / pub enum UninhabitedVariants { -LL | | #[non_exhaustive] Tuple(!), - | | ----- not covered -LL | | #[non_exhaustive] Struct { x: ! } - | | ------ not covered -LL | | } - | |_- `UninhabitedVariants` defined here -... -LL | match x {} - | ^ patterns `Tuple(_)` and `Struct { .. }` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | match x {} + | ^ patterns `Tuple(_)` and `Struct { .. }` not covered + | +note: `UninhabitedVariants` defined here + --> $DIR/match_same_crate.rs:16:23 + | +LL | pub enum UninhabitedVariants { + | ------------------- +LL | #[non_exhaustive] Tuple(!), + | ^^^^^ not covered +LL | #[non_exhaustive] Struct { x: ! } + | ^^^^^^ not covered = note: the matched value is of type `UninhabitedVariants` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ match x { +LL + Tuple(_) | Struct { .. } => todo!(), +LL ~ } + | error: aborting due to 3 previous errors diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr index cc3dc6c29b9..e18c2678d32 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr @@ -4,8 +4,19 @@ error[E0004]: non-exhaustive patterns: type `UninhabitedEnum` is non-empty LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `UninhabitedEnum` defined here + --> $DIR/auxiliary/uninhabited.rs:5:1 + | +LL | / pub enum UninhabitedEnum { +LL | | } + | |_^ = note: the matched value is of type `UninhabitedEnum`, which is marked as non-exhaustive +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: type `UninhabitedStruct` is non-empty --> $DIR/match_with_exhaustive_patterns.rs:26:11 @@ -13,8 +24,20 @@ error[E0004]: non-exhaustive patterns: type `UninhabitedStruct` is non-empty LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `UninhabitedStruct` defined here + --> $DIR/auxiliary/uninhabited.rs:9:1 + | +LL | / pub struct UninhabitedStruct { +LL | | _priv: !, +LL | | } + | |_^ = note: the matched value is of type `UninhabitedStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: type `UninhabitedTupleStruct` is non-empty --> $DIR/match_with_exhaustive_patterns.rs:30:11 @@ -22,8 +45,18 @@ error[E0004]: non-exhaustive patterns: type `UninhabitedTupleStruct` is non-empt LL | match x {} | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `UninhabitedTupleStruct` defined here + --> $DIR/auxiliary/uninhabited.rs:14:1 + | +LL | pub struct UninhabitedTupleStruct(!); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `UninhabitedTupleStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | error[E0004]: non-exhaustive patterns: `Tuple(_)` and `Struct { .. }` not covered --> $DIR/match_with_exhaustive_patterns.rs:34:11 @@ -31,15 +64,23 @@ error[E0004]: non-exhaustive patterns: `Tuple(_)` and `Struct { .. }` not covere LL | match x {} | ^ patterns `Tuple(_)` and `Struct { .. }` not covered | - ::: $DIR/auxiliary/uninhabited.rs:17:23 +note: `UninhabitedVariants` defined here + --> $DIR/auxiliary/uninhabited.rs:17:23 | -LL | #[non_exhaustive] Tuple(!), - | ----- not covered -LL | #[non_exhaustive] Struct { x: ! } - | ------ not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | / pub enum UninhabitedVariants { +LL | | #[non_exhaustive] Tuple(!), + | | ^^^^^ not covered +LL | | #[non_exhaustive] Struct { x: ! } + | | ^^^^^^ not covered +LL | | } + | |_- = note: the matched value is of type `UninhabitedVariants` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ match x { +LL + Tuple(_) | Struct { .. } => todo!(), +LL ~ } + | error: aborting due to 4 previous errors diff --git a/src/test/ui/suggestions/borrow-for-loop-head.stderr b/src/test/ui/suggestions/borrow-for-loop-head.stderr index 28c319b6597..1059e3d1525 100644 --- a/src/test/ui/suggestions/borrow-for-loop-head.stderr +++ b/src/test/ui/suggestions/borrow-for-loop-head.stderr @@ -13,16 +13,17 @@ LL | let a = vec![1, 2, 3]; | - move occurs because `a` has type `Vec<i32>`, which does not implement the `Copy` trait LL | for i in &a { LL | for j in a { - | ^ - | | - | `a` moved due to this implicit call to `.into_iter()`, in previous iteration of loop - | help: consider borrowing to avoid moving into the for loop: `&a` + | ^ `a` moved due to this implicit call to `.into_iter()`, in previous iteration of loop | note: this function takes ownership of the receiver `self`, which moves `a` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL | LL | fn into_iter(self) -> Self::IntoIter; | ^^^^ +help: consider iterating over a slice of the `Vec<i32>`'s content to avoid moving into the `for` loop + | +LL | for j in &a { + | + error: aborting due to 2 previous errors diff --git a/src/test/ui/suggestions/for-i-in-vec.stderr b/src/test/ui/suggestions/for-i-in-vec.stderr index c39363f762b..88be9e30a76 100644 --- a/src/test/ui/suggestions/for-i-in-vec.stderr +++ b/src/test/ui/suggestions/for-i-in-vec.stderr @@ -2,9 +2,17 @@ error[E0507]: cannot move out of `self.v` which is behind a shared reference --> $DIR/for-i-in-vec.rs:11:18 | LL | for _ in self.v { - | ^^^^^^ move occurs because `self.v` has type `Vec<u32>`, which does not implement the `Copy` trait + | ^^^^^^ + | | + | `self.v` moved due to this implicit call to `.into_iter()` + | move occurs because `self.v` has type `Vec<u32>`, which does not implement the `Copy` trait | -help: consider iterating over a slice of the `Vec<u32>`'s content +note: this function takes ownership of the receiver `self`, which moves `self.v` + --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + | +LL | fn into_iter(self) -> Self::IntoIter; + | ^^^^ +help: consider iterating over a slice of the `Vec<u32>`'s content to avoid moving into the `for` loop | LL | for _ in &self.v { | + @@ -13,9 +21,12 @@ error[E0507]: cannot move out of `self.h` which is behind a shared reference --> $DIR/for-i-in-vec.rs:13:18 | LL | for _ in self.h { - | ^^^^^^ move occurs because `self.h` has type `HashMap<i32, i32>`, which does not implement the `Copy` trait + | ^^^^^^ + | | + | `self.h` moved due to this implicit call to `.into_iter()` + | move occurs because `self.h` has type `HashMap<i32, i32>`, which does not implement the `Copy` trait | -help: consider iterating over a slice of the `HashMap<i32, i32>`'s content +help: consider iterating over a slice of the `HashMap<i32, i32>`'s content to avoid moving into the `for` loop | LL | for _ in &self.h { | + @@ -24,9 +35,17 @@ error[E0507]: cannot move out of a shared reference --> $DIR/for-i-in-vec.rs:21:19 | LL | for loader in *LOADERS { - | ^^^^^^^^ move occurs because value has type `Vec<&u8>`, which does not implement the `Copy` trait + | ^^^^^^^^ + | | + | value moved due to this implicit call to `.into_iter()` + | move occurs because value has type `Vec<&u8>`, which does not implement the `Copy` trait + | +note: this function takes ownership of the receiver `self`, which moves value + --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL | -help: consider iterating over a slice of the `Vec<&u8>`'s content +LL | fn into_iter(self) -> Self::IntoIter; + | ^^^^ +help: consider iterating over a slice of the `Vec<&u8>`'s content to avoid moving into the `for` loop | LL | for loader in &*LOADERS { | + diff --git a/src/test/ui/suggestions/option-content-move2.stderr b/src/test/ui/suggestions/option-content-move2.stderr index a0ce7d05b4d..16cbbaba512 100644 --- a/src/test/ui/suggestions/option-content-move2.stderr +++ b/src/test/ui/suggestions/option-content-move2.stderr @@ -12,8 +12,8 @@ LL | | LL | | var = Some(NotCopyable); | | --- | | | + | | variable moved due to use in closure | | move occurs because `var` has type `Option<NotCopyable>`, which does not implement the `Copy` trait - | | move occurs due to use in closure LL | | } LL | | }); | |_____- captured by this `FnMut` closure diff --git a/src/test/ui/uninhabited/uninhabited-irrefutable.stderr b/src/test/ui/uninhabited/uninhabited-irrefutable.stderr index 3cb99556748..ad19c34a40a 100644 --- a/src/test/ui/uninhabited/uninhabited-irrefutable.stderr +++ b/src/test/ui/uninhabited/uninhabited-irrefutable.stderr @@ -1,20 +1,18 @@ error[E0005]: refutable pattern in local binding: `A(_)` not covered --> $DIR/uninhabited-irrefutable.rs:27:9 | -LL | / enum Foo { -LL | | A(foo::SecretlyEmpty), - | | - not covered -LL | | B(foo::NotSoSecretlyEmpty), -LL | | C(NotSoSecretlyEmpty), -LL | | D(u32), -LL | | } - | |_- `Foo` defined here -... -LL | let Foo::D(_y) = x; - | ^^^^^^^^^^ pattern `A(_)` not covered +LL | let Foo::D(_y) = x; + | ^^^^^^^^^^ pattern `A(_)` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html +note: `Foo` defined here + --> $DIR/uninhabited-irrefutable.rs:19:5 + | +LL | enum Foo { + | --- +LL | A(foo::SecretlyEmpty), + | ^ not covered = note: the matched value is of type `Foo` help: you might want to use `if let` to ignore the variant that isn't matched | diff --git a/src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr b/src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr index b92ceb479bd..d90075d82f4 100644 --- a/src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr +++ b/src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr @@ -4,26 +4,44 @@ error[E0004]: non-exhaustive patterns: `Err(_)` not covered LL | let _ = match x { | ^ pattern `Err(_)` not covered | - ::: $SRC_DIR/core/src/result.rs:LL:COL +note: `Result<u32, &Void>` defined here + --> $SRC_DIR/core/src/result.rs:LL:COL + | +LL | / pub enum Result<T, E> { +LL | | /// Contains the success value +LL | | #[lang = "Ok"] +LL | | #[stable(feature = "rust1", since = "1.0.0")] +... | +LL | | Err(#[stable(feature = "rust1", since = "1.0.0")] E), + | | ^^^ not covered +LL | | } + | |_- + = note: the matched value is of type `Result<u32, &Void>` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL | Err(#[stable(feature = "rust1", since = "1.0.0")] E), - | --- not covered +LL ~ Ok(n) => n, +LL ~ Err(_) => todo!(), | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `Result<u32, &Void>` error[E0004]: non-exhaustive patterns: type `&Void` is non-empty --> $DIR/uninhabited-matches-feature-gated.rs:15:19 | -LL | enum Void {} - | ------------ `Void` defined here -... LL | let _ = match x {}; | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `Void` defined here + --> $DIR/uninhabited-matches-feature-gated.rs:2:6 + | +LL | enum Void {} + | ^^^^ = note: the matched value is of type `&Void` = note: references are always considered inhabited +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ let _ = match x { +LL + _ => todo!(), +LL ~ }; + | error[E0004]: non-exhaustive patterns: type `(Void,)` is non-empty --> $DIR/uninhabited-matches-feature-gated.rs:18:19 @@ -31,8 +49,13 @@ error[E0004]: non-exhaustive patterns: type `(Void,)` is non-empty LL | let _ = match x {}; | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(Void,)` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ let _ = match x { +LL + _ => todo!(), +LL ~ }; + | error[E0004]: non-exhaustive patterns: type `[Void; 1]` is non-empty --> $DIR/uninhabited-matches-feature-gated.rs:21:19 @@ -40,8 +63,13 @@ error[E0004]: non-exhaustive patterns: type `[Void; 1]` is non-empty LL | let _ = match x {}; | ^ | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `[Void; 1]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ let _ = match x { +LL + _ => todo!(), +LL ~ }; + | error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered --> $DIR/uninhabited-matches-feature-gated.rs:24:19 @@ -49,8 +77,12 @@ error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered LL | let _ = match x { | ^ pattern `&[_, ..]` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `&[Void]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ &[] => (), +LL ~ &[_, ..] => todo!(), + | error[E0004]: non-exhaustive patterns: `Err(_)` not covered --> $DIR/uninhabited-matches-feature-gated.rs:32:19 @@ -58,13 +90,24 @@ error[E0004]: non-exhaustive patterns: `Err(_)` not covered LL | let _ = match x { | ^ pattern `Err(_)` not covered | - ::: $SRC_DIR/core/src/result.rs:LL:COL +note: `Result<u32, Void>` defined here + --> $SRC_DIR/core/src/result.rs:LL:COL + | +LL | / pub enum Result<T, E> { +LL | | /// Contains the success value +LL | | #[lang = "Ok"] +LL | | #[stable(feature = "rust1", since = "1.0.0")] +... | +LL | | Err(#[stable(feature = "rust1", since = "1.0.0")] E), + | | ^^^ not covered +LL | | } + | |_- + = note: the matched value is of type `Result<u32, Void>` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL | Err(#[stable(feature = "rust1", since = "1.0.0")] E), - | --- not covered +LL ~ Ok(x) => x, +LL ~ Err(_) => todo!(), | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `Result<u32, Void>` error[E0005]: refutable pattern in local binding: `Err(_)` not covered --> $DIR/uninhabited-matches-feature-gated.rs:37:9 @@ -72,13 +115,20 @@ error[E0005]: refutable pattern in local binding: `Err(_)` not covered LL | let Ok(x) = x; | ^^^^^ pattern `Err(_)` not covered | - ::: $SRC_DIR/core/src/result.rs:LL:COL - | -LL | Err(#[stable(feature = "rust1", since = "1.0.0")] E), - | --- not covered - | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html +note: `Result<u32, Void>` defined here + --> $SRC_DIR/core/src/result.rs:LL:COL + | +LL | / pub enum Result<T, E> { +LL | | /// Contains the success value +LL | | #[lang = "Ok"] +LL | | #[stable(feature = "rust1", since = "1.0.0")] +... | +LL | | Err(#[stable(feature = "rust1", since = "1.0.0")] E), + | | ^^^ not covered +LL | | } + | |_- = note: the matched value is of type `Result<u32, Void>` help: you might want to use `if let` to ignore the variant that isn't matched | diff --git a/src/tools/cargo b/src/tools/cargo -Subproject 3d6970d50e30e797b8e26b2b9b1bdf92dc381f3 +Subproject 65c82664263feddc5fe2d424be0993c28d46377 diff --git a/src/tools/miri b/src/tools/miri -Subproject 54b14b7f0110133477e7459a327a0a5cbd18fd4 +Subproject 722475ccc143d2dbf9fad5891207dcb5576e3d1 diff --git a/src/tools/rust-analyzer b/src/tools/rust-analyzer -Subproject 4e72700e38421a12993fe5fa5c33d712652bc6c +Subproject 5fae65dd28b450a437ebc800a410164c3af1d51 diff --git a/triagebot.toml b/triagebot.toml index 276587e7f13..f6f1b918f06 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -73,6 +73,13 @@ Thanks! <3 """ label = "O-riscv" +[ping.fuchsia] +message = """\ +Hey friends of Fuchsia! This issue could use some guidance on how this should be +resolved/implemented on Fuchsia. Could one of you weigh in? +""" +label = "O-fuchsia" + [prioritize] label = "I-prioritize" |
