From 3aac307ca62f6d6c5b3612d3dfe80b6eeae8ba15 Mon Sep 17 00:00:00 2001 From: Esteban Kuber Date: Mon, 13 Dec 2021 20:56:40 +0000 Subject: [PATCH 1/8] Mention implementers of unsatisfied trait When encountering an unsatisfied trait bound, if there are no other suggestions, mention all the types that *do* implement that trait: ``` error[E0277]: the trait bound `f32: Foo` is not satisfied --> $DIR/impl_wf.rs:22:6 | LL | impl Baz for f32 { } | ^^^^^^^^ the trait `Foo` is not implemented for `f32` | = help: the following other types implement trait `Foo`: Option i32 str note: required by a bound in `Baz` --> $DIR/impl_wf.rs:18:31 | LL | trait Baz where U: Foo { } | ^^^ required by this bound in `Baz` ``` Mention implementers of traits in `ImplObligation`s. Do not mention other `impl`s for closures, ranges and `?`. --- compiler/rustc_errors/src/diagnostic.rs | 6 + compiler/rustc_middle/src/ty/mod.rs | 9 +- .../src/check_packed_ref.rs | 25 +--- compiler/rustc_span/src/symbol.rs | 4 + .../src/traits/error_reporting/mod.rs | 126 +++++++++++++++--- .../src/traits/error_reporting/suggestions.rs | 44 +++--- library/core/src/ops/function.rs | 3 + library/core/src/slice/index.rs | 1 + src/test/ui/allocator/not-an-allocator.rs | 8 +- src/test/ui/allocator/not-an-allocator.stderr | 4 + .../associated-types-path-2.stderr | 12 +- .../hr-associated-type-bound-1.stderr | 3 +- .../hr-associated-type-bound-param-1.stderr | 3 +- .../hr-associated-type-bound-param-2.stderr | 9 +- .../hr-associated-type-bound-param-3.stderr | 3 +- .../hr-associated-type-bound-param-4.stderr | 3 +- .../hr-associated-type-bound-param-5.stderr | 6 +- .../ui/associated-types/issue-65774-1.stderr | 2 + .../ui/associated-types/issue-65774-2.stderr | 2 + ...ypeck-default-trait-impl-precedence.stderr | 3 +- src/test/ui/binop/binop-mul-i32-f32.stderr | 6 + src/test/ui/binop/issue-77910-1.stderr | 6 + .../ui/binop/shift-various-bad-types.stderr | 18 +++ src/test/ui/block-result/issue-22645.stderr | 3 +- src/test/ui/chalkify/generic_impls.stderr | 6 +- src/test/ui/chalkify/impl_wf.stderr | 3 +- src/test/ui/chalkify/impl_wf_2.stderr | 3 +- src/test/ui/chalkify/type_wf.stderr | 3 +- ...ce-issue-49593-box-never.nofallback.stderr | 20 +++ .../associated-type-bound-fail.stderr | 3 +- .../defaults/rp_impl_trait_fail.stderr | 6 +- .../defaults/trait_objects_fail.stderr | 6 +- .../ui/const-generics/defaults/wfness.stderr | 6 +- .../ui/const-generics/exhaustive-value.stderr | 2 +- .../occurs-check/unused-substs-1.stderr | 3 +- .../const-blocks/fn-call-in-non-const.stderr | 3 +- .../consts/const-blocks/migrate-fail.stderr | 6 +- .../ui/consts/const-blocks/nll-fail.stderr | 6 +- .../ui/consts/const-blocks/trait-error.stderr | 3 +- .../const-eval/const-eval-overflow-3b.stderr | 6 + .../const-eval/const-eval-overflow-4b.stderr | 6 + .../ui/consts/too_generic_eval_ice.stderr | 6 + ...e-21659-show-relevant-trait-impls-2.stderr | 1 - .../issue-39802-show-5-trait-impls.stderr | 3 - ...de-confusable-in-float-literal-expt.stderr | 6 + .../feature-gate-trivial_bounds.stderr | 6 + src/test/ui/fmt/ifmt-unimpl.stderr | 10 ++ .../bugs/issue-88460.stderr | 1 + src/test/ui/impl-trait/equality.stderr | 6 + .../ui/impl-trait/issues/issue-62742.stderr | 6 +- .../nested-return-type2-tait.stderr | 2 + .../nested-return-type2-tait2.stderr | 1 + .../nested-return-type2-tait3.stderr | 1 + ...impl-trait-declaration-too-subtle-2.stderr | 1 + src/test/ui/index-help.stderr | 1 + src/test/ui/indexing-requires-a-uint.stderr | 1 + src/test/ui/integral-indexing.stderr | 8 ++ src/test/ui/issues/issue-11771.stderr | 12 ++ src/test/ui/issues/issue-24352.stderr | 6 + src/test/ui/issues/issue-34334.stderr | 1 + src/test/ui/issues/issue-45801.stderr | 3 +- src/test/ui/issues/issue-50582.stderr | 6 + src/test/ui/issues/issue-59488.stderr | 6 + ...e-66923-show-error-for-correct-call.stderr | 2 + src/test/ui/kindck/kindck-copy.stderr | 4 +- .../ui/lexer/lex-bad-char-literals-6.stderr | 12 ++ src/test/ui/mismatched_types/binops.stderr | 36 +++++ .../defaulted-never-note.fallback.stderr | 2 +- .../ui/never_type/defaulted-never-note.rs | 2 +- ...diverging-fallback-no-leak.fallback.stderr | 4 +- .../ui/never_type/impl_trait_fallback2.stderr | 2 + src/test/ui/never_type/issue-13352.stderr | 6 + ...lue-fallback-issue-66757.nofallback.stderr | 3 +- .../not-suggest-float-literal.stderr | 72 ++++++++++ .../suggest-float-literal.stderr | 48 +++++++ .../ui/on-unimplemented/impl-substs.stderr | 1 + .../ui/on-unimplemented/multiple-impls.stderr | 18 +++ src/test/ui/on-unimplemented/on-impl.stderr | 2 + .../ui/on-unimplemented/slice-index.stderr | 4 + src/test/ui/range/range-1.stderr | 10 ++ .../termination-trait-test-wrong-type.stderr | 4 + src/test/ui/span/multiline-span-simple.stderr | 6 + .../default-associated-type-bound-1.stderr | 3 +- src/test/ui/str/str-idx.stderr | 3 + src/test/ui/str/str-mut-idx.stderr | 3 + ...-trait-object-literal-bound-regions.stderr | 3 +- .../imm-ref-trait-object-literal.stderr | 3 +- ...mpl-trait-return-trailing-semicolon.stderr | 2 + src/test/ui/suggestions/into-str.stderr | 1 - .../suggestions/issue-84973-negative.stderr | 3 +- .../check-trait-object-bounds-1.stderr | 3 +- .../check-trait-object-bounds-4.stderr | 3 +- src/test/ui/traits/bound/same-crate-name.rs | 2 +- .../ui/traits/bound/same-crate-name.stderr | 6 +- .../ui/traits/coercion-generic-bad.stderr | 3 +- .../repeated-supertrait-ambig.stderr | 4 + src/test/ui/traits/issue-91594.stderr | 3 +- src/test/ui/traits/map-types.stderr | 1 + .../ui/traits/reservation-impl/no-use.stderr | 3 +- .../suggest-deferences/issue-62530.stderr | 2 - .../suggest-deferences/multiple-1.stderr | 1 + .../ui/try-block/try-block-bad-type.stderr | 3 +- .../ui/try-trait/bad-interconversion.stderr | 9 +- src/test/ui/try-trait/option-to-result.stderr | 2 + src/test/ui/try-trait/try-on-option.stderr | 1 + .../type-alias-impl-trait/issue-60371.stderr | 3 +- .../nested-tait-inference.stderr | 6 +- .../self-referential-2.stderr | 6 + .../self-referential-4.stderr | 18 +++ .../self-referential.stderr | 18 +++ src/test/ui/type/type-check-defaults.stderr | 6 + src/test/ui/typeck/issue-81293.stderr | 6 + .../ui/ufcs/ufcs-qpath-self-mismatch.stderr | 6 + .../unevaluated_fixed_size_array_len.stderr | 3 +- .../ui/wf/hir-wf-check-erase-regions.stderr | 2 + 115 files changed, 690 insertions(+), 183 deletions(-) diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 00ecbbbb93b98..32c52a6a8a6d9 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -378,6 +378,12 @@ impl Diagnostic { self } + /// Add a help message attached to this diagnostic with a customizable highlighted message. + pub fn highlighted_help(&mut self, msg: Vec<(String, Style)>) -> &mut Self { + self.sub_with_highlights(Level::Help, msg, MultiSpan::new(), None); + self + } + /// Prints the span with some help above it. /// This is like [`Diagnostic::help()`], but it gets its own span. pub fn span_help>(&mut self, sp: S, msg: &str) -> &mut Self { diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 37425c91157b3..45a215354d081 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -41,7 +41,7 @@ use rustc_hir::Node; use rustc_macros::HashStable; use rustc_query_system::ich::StableHashingContext; use rustc_session::cstore::CrateStoreDyn; -use rustc_span::symbol::{kw, Ident, Symbol}; +use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::Span; use rustc_target::abi::Align; @@ -2206,7 +2206,7 @@ impl<'tcx> TyCtxt<'tcx> { self.impl_trait_ref(def_id).map(|tr| tr.def_id) } - /// If the given defid describes a method belonging to an impl, returns the + /// If the given `DefId` describes a method belonging to an impl, returns the /// `DefId` of the impl that the method belongs to; otherwise, returns `None`. pub fn impl_of_method(self, def_id: DefId) -> Option { self.opt_associated_item(def_id).and_then(|trait_item| match trait_item.container { @@ -2215,6 +2215,11 @@ impl<'tcx> TyCtxt<'tcx> { }) } + /// If the given `DefId` belongs to a trait that was automatically derived, returns `true`. + pub fn is_builtin_derive(self, def_id: DefId) -> bool { + self.has_attr(def_id, sym::automatically_derived) + } + /// Looks up the span of `impl_did` if the impl is local; otherwise returns `Err` /// with the name of the crate containing the impl. pub fn span_of_impl(self, impl_did: DefId) -> Result { diff --git a/compiler/rustc_mir_transform/src/check_packed_ref.rs b/compiler/rustc_mir_transform/src/check_packed_ref.rs index f0367958ef8c5..4bf66cd4c9f2e 100644 --- a/compiler/rustc_mir_transform/src/check_packed_ref.rs +++ b/compiler/rustc_mir_transform/src/check_packed_ref.rs @@ -1,10 +1,9 @@ -use rustc_hir::def_id::{DefId, LocalDefId}; +use rustc_hir::def_id::LocalDefId; use rustc_middle::mir::visit::{PlaceContext, Visitor}; use rustc_middle::mir::*; use rustc_middle::ty::query::Providers; use rustc_middle::ty::{self, TyCtxt}; use rustc_session::lint::builtin::UNALIGNED_REFERENCES; -use rustc_span::symbol::sym; use crate::util; use crate::MirLint; @@ -50,22 +49,6 @@ fn unsafe_derive_on_repr_packed(tcx: TyCtxt<'_>, def_id: LocalDefId) { }); } -fn builtin_derive_def_id(tcx: TyCtxt<'_>, def_id: DefId) -> Option { - debug!("builtin_derive_def_id({:?})", def_id); - if let Some(impl_def_id) = tcx.impl_of_method(def_id) { - if tcx.has_attr(impl_def_id, sym::automatically_derived) { - debug!("builtin_derive_def_id({:?}) - is {:?}", def_id, impl_def_id); - Some(impl_def_id) - } else { - debug!("builtin_derive_def_id({:?}) - not automatically derived", def_id); - None - } - } else { - debug!("builtin_derive_def_id({:?}) - not a method", def_id); - None - } -} - impl<'tcx> Visitor<'tcx> for PackedRefChecker<'_, 'tcx> { fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) { // Make sure we know where in the MIR we are. @@ -83,7 +66,11 @@ impl<'tcx> Visitor<'tcx> for PackedRefChecker<'_, 'tcx> { if context.is_borrow() { if util::is_disaligned(self.tcx, self.body, self.param_env, *place) { let def_id = self.body.source.instance.def_id(); - if let Some(impl_def_id) = builtin_derive_def_id(self.tcx, def_id) { + if let Some(impl_def_id) = self + .tcx + .impl_of_method(def_id) + .filter(|&def_id| self.tcx.is_builtin_derive(def_id)) + { // If a method is defined in the local crate, // the impl containing that method should also be. self.tcx.ensure().unsafe_derive_on_repr_packed(impl_def_id.expect_local()); diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 2737c26708bc4..f5803aaa0786e 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -180,6 +180,9 @@ symbols! { Error, File, FileType, + Fn, + FnMut, + FnOnce, FormatSpec, Formatter, From, @@ -248,6 +251,7 @@ symbols! { RustcEncodable, Send, SeqCst, + SliceIndex, Some, String, StructuralEq, diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 216aa89dd1f28..2da4c86a58e9c 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -14,6 +14,7 @@ use crate::infer::{self, InferCtxt, TyCtxtInferExt}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{ pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, + Style, }; use rustc_hir as hir; use rustc_hir::def_id::DefId; @@ -354,7 +355,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { let have_alt_message = message.is_some() || label.is_some(); let is_try_conversion = self.is_try_conversion(span, trait_ref.def_id()); let is_unsize = - { Some(trait_ref.def_id()) == self.tcx.lang_items().unsize_trait() }; + Some(trait_ref.def_id()) == self.tcx.lang_items().unsize_trait(); let (message, note, append_const_msg) = if is_try_conversion { ( Some(format!( @@ -363,7 +364,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { )), Some( "the question mark operation (`?`) implicitly performs a \ - conversion on the error value using the `From` trait" + conversion on the error value using the `From` trait" .to_owned(), ), Some(None), @@ -519,10 +520,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { } self.suggest_floating_point_literal(&obligation, &mut err, &trait_ref); - self.suggest_dereferences(&obligation, &mut err, trait_predicate); - self.suggest_fn_call(&obligation, &mut err, trait_predicate); - self.suggest_remove_reference(&obligation, &mut err, trait_predicate); - self.suggest_semicolon_removal( + let mut suggested = + self.suggest_dereferences(&obligation, &mut err, trait_predicate); + suggested |= self.suggest_fn_call(&obligation, &mut err, trait_predicate); + suggested |= + self.suggest_remove_reference(&obligation, &mut err, trait_predicate); + suggested |= self.suggest_semicolon_removal( &obligation, &mut err, span, @@ -648,10 +651,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { trait_predicate, obligation.cause.body_id, ); - } else if !have_alt_message { + } else if !suggested { // Can't show anything else useful, try to find similar impls. let impl_candidates = self.find_similar_impl_candidates(trait_ref); - self.report_similar_impl_candidates(impl_candidates, &mut err); + self.report_similar_impl_candidates( + impl_candidates, + trait_ref, + &mut err, + ); } // Changing mutability doesn't make a difference to whether we have @@ -676,7 +683,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { }); let unit_obligation = obligation.with(predicate.to_predicate(tcx)); if self.predicate_may_hold(&unit_obligation) { - err.note("this trait is implemented for `()`"); err.note( "this error might have been caused by changes to \ Rust's type-inference algorithm (see issue #48950 \ @@ -1301,8 +1307,9 @@ trait InferCtxtPrivExt<'hir, 'tcx> { fn report_similar_impl_candidates( &self, impl_candidates: Vec>, + trait_ref: ty::PolyTraitRef<'tcx>, err: &mut Diagnostic, - ); + ) -> bool; /// Gets the parent trait chain start fn get_parent_trait_ref( @@ -1313,7 +1320,11 @@ trait InferCtxtPrivExt<'hir, 'tcx> { /// If the `Self` type of the unsatisfied trait `trait_ref` implements a trait /// with the same path as `trait_ref`, a help message about /// a probable version mismatch is added to `err` - fn note_version_mismatch(&self, err: &mut Diagnostic, trait_ref: &ty::PolyTraitRef<'tcx>); + fn note_version_mismatch( + &self, + err: &mut Diagnostic, + trait_ref: &ty::PolyTraitRef<'tcx>, + ) -> bool; /// Creates a `PredicateObligation` with `new_self_ty` replacing the existing type in the /// `trait_ref`. @@ -1675,10 +1686,63 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { fn report_similar_impl_candidates( &self, impl_candidates: Vec>, + trait_ref: ty::PolyTraitRef<'tcx>, err: &mut Diagnostic, - ) { + ) -> bool { + let def_id = trait_ref.def_id(); if impl_candidates.is_empty() { - return; + if self.tcx.trait_is_auto(def_id) + || self.tcx.lang_items().items().contains(&Some(def_id)) + || self.tcx.get_diagnostic_name(def_id).is_some() + { + // Mentioning implementers of `Copy`, `Debug` and friends is not useful. + return false; + } + let mut normalized_impl_candidates: Vec<_> = self + .tcx + .all_impls(def_id) + // Ignore automatically derived impls and `!Trait` impls. + .filter(|&def_id| { + self.tcx.impl_polarity(def_id) != ty::ImplPolarity::Negative + || self.tcx.is_builtin_derive(def_id) + }) + .filter_map(|def_id| self.tcx.impl_trait_ref(def_id)) + // Avoid mentioning type parameters. + .filter(|trait_ref| !matches!(trait_ref.self_ty().kind(), ty::Param(_))) + .map(|trait_ref| format!("\n {}", trait_ref.self_ty())) + .collect(); + normalized_impl_candidates.sort(); + normalized_impl_candidates.dedup(); + let len = normalized_impl_candidates.len(); + if len == 0 { + return false; + } + if len == 1 { + err.highlighted_help(vec![ + ( + format!( + "the trait `{}` is implemented for `", + trait_ref.print_only_trait_path() + ), + Style::NoStyle, + ), + (normalized_impl_candidates[0].trim().to_string(), Style::Highlight), + ("`".to_string(), Style::NoStyle), + ]); + return true; + } + let end = if normalized_impl_candidates.len() <= 9 { + normalized_impl_candidates.len() + } else { + 8 + }; + err.help(&format!( + "the following other types implement trait `{}`:{}{}", + trait_ref.print_only_trait_path(), + normalized_impl_candidates[..end].join(""), + if len > 9 { format!("\nand {} others", len - 8) } else { String::new() } + )); + return true; } let len = impl_candidates.len(); @@ -1703,6 +1767,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { // // Prefer more similar candidates first, then sort lexicographically // by their normalized string representation. + let first_candidate = impl_candidates.get(0).map(|candidate| candidate.trait_ref); let mut normalized_impl_candidates_and_similarities = impl_candidates .into_iter() .map(|ImplCandidate { trait_ref, similarity }| { @@ -1711,17 +1776,33 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { }) .collect::>(); normalized_impl_candidates_and_similarities.sort(); + normalized_impl_candidates_and_similarities.dedup(); let normalized_impl_candidates = normalized_impl_candidates_and_similarities .into_iter() .map(|(_, normalized)| normalized) .collect::>(); - err.help(&format!( - "the following implementations were found:{}{}", - normalized_impl_candidates[..end].join(""), - if len > 5 { format!("\nand {} others", len - 4) } else { String::new() } - )); + if normalized_impl_candidates.len() == 1 { + err.highlighted_help(vec![ + ( + format!( + "the trait `{}` is implemented for `", + first_candidate.unwrap().print_only_trait_path() + ), + Style::NoStyle, + ), + (first_candidate.unwrap().self_ty().to_string(), Style::Highlight), + ("`".to_string(), Style::NoStyle), + ]); + } else { + err.help(&format!( + "the following implementations were found:{}{}", + normalized_impl_candidates[..end].join(""), + if len > 9 { format!("\nand {} others", len - 8) } else { String::new() } + )); + } + true } /// Gets the parent trait chain start @@ -1752,7 +1833,11 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { /// If the `Self` type of the unsatisfied trait `trait_ref` implements a trait /// with the same path as `trait_ref`, a help message about /// a probable version mismatch is added to `err` - fn note_version_mismatch(&self, err: &mut Diagnostic, trait_ref: &ty::PolyTraitRef<'tcx>) { + fn note_version_mismatch( + &self, + err: &mut Diagnostic, + trait_ref: &ty::PolyTraitRef<'tcx>, + ) -> bool { let get_trait_impl = |trait_def_id| { self.tcx.find_map_relevant_impl(trait_def_id, trait_ref.skip_binder().self_ty(), Some) }; @@ -1763,6 +1848,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { .filter(|trait_def_id| *trait_def_id != trait_ref.def_id()) .filter(|trait_def_id| self.tcx.def_path_str(*trait_def_id) == required_trait_path) .collect(); + let mut suggested = false; for trait_with_same_path in traits_with_same_path { if let Some(impl_def_id) = get_trait_impl(trait_with_same_path) { let impl_span = self.tcx.def_span(impl_def_id); @@ -1773,8 +1859,10 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { trait_crate ); err.note(&crate_msg); + suggested = true; } } + suggested } fn mk_trait_obligation_with_new_self_ty( diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index b49a5f6578f75..5bf9be87b57ae 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -58,7 +58,7 @@ pub trait InferCtxtExt<'tcx> { obligation: &PredicateObligation<'tcx>, err: &mut Diagnostic, trait_pred: ty::PolyTraitPredicate<'tcx>, - ); + ) -> bool; fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option; @@ -67,7 +67,7 @@ pub trait InferCtxtExt<'tcx> { obligation: &PredicateObligation<'tcx>, err: &mut Diagnostic, trait_pred: ty::PolyTraitPredicate<'tcx>, - ); + ) -> bool; fn suggest_add_reference_to_arg( &self, @@ -82,7 +82,7 @@ pub trait InferCtxtExt<'tcx> { obligation: &PredicateObligation<'tcx>, err: &mut Diagnostic, trait_pred: ty::PolyTraitPredicate<'tcx>, - ); + ) -> bool; fn suggest_remove_await(&self, obligation: &PredicateObligation<'tcx>, err: &mut Diagnostic); @@ -99,7 +99,7 @@ pub trait InferCtxtExt<'tcx> { err: &mut Diagnostic, span: Span, trait_pred: ty::PolyTraitPredicate<'tcx>, - ); + ) -> bool; fn return_type_span(&self, obligation: &PredicateObligation<'tcx>) -> Option; @@ -494,14 +494,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { obligation: &PredicateObligation<'tcx>, err: &mut Diagnostic, trait_pred: ty::PolyTraitPredicate<'tcx>, - ) { + ) -> bool { // It only make sense when suggesting dereferences for arguments let code = if let ObligationCauseCode::FunctionArgumentObligation { parent_code, .. } = obligation.cause.code() { parent_code.clone() } else { - return; + return false; }; let param_env = obligation.param_env; let body_id = obligation.cause.body_id; @@ -513,7 +513,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { _ => trait_pred, }; let Some(real_ty) = real_trait_pred.self_ty().no_bound_vars() else { - return; + return false; }; if let ty::Ref(region, base_ty, mutbl) = *real_ty.kind() { @@ -537,11 +537,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { format!("&{}{}", derefs, &src[1..]), Applicability::MachineApplicable, ); + return true; } } } } } + false } /// Given a closure's `DefId`, return the given name of the closure. @@ -584,22 +586,22 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { obligation: &PredicateObligation<'tcx>, err: &mut Diagnostic, trait_pred: ty::PolyTraitPredicate<'tcx>, - ) { + ) -> bool { let Some(self_ty) = trait_pred.self_ty().no_bound_vars() else { - return; + return false; }; let (def_id, output_ty, callable) = match *self_ty.kind() { ty::Closure(def_id, substs) => (def_id, substs.as_closure().sig().output(), "closure"), ty::FnDef(def_id, _) => (def_id, self_ty.fn_sig(self.tcx).output(), "function"), - _ => return, + _ => return false, }; let msg = format!("use parentheses to call the {}", callable); // `mk_trait_obligation_with_new_self_ty` only works for types with no escaping bound // variables, so bail out if we have any. let Some(output_ty) = output_ty.no_bound_vars() else { - return; + return false; }; let new_obligation = @@ -611,7 +613,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { | EvaluationResult::EvaluatedToOkModuloRegions | EvaluationResult::EvaluatedToAmbig, ) => {} - _ => return, + _ => return false, } let hir = self.tcx.hir(); // Get the name of the callable and the arguments to be used in the suggestion. @@ -622,7 +624,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { })) => { err.span_label(*span, "consider calling this closure"); let Some(name) = self.get_closure_name(def_id, err, &msg) else { - return; + return false; }; let args = decl.inputs.iter().map(|_| "_").collect::>().join(", "); let sugg = format!("({})", args); @@ -650,7 +652,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { let sugg = format!("({})", args); (format!("{}{}", ident, sugg), sugg) } - _ => return, + _ => return false, }; if matches!(obligation.cause.code(), ObligationCauseCode::FunctionArgumentObligation { .. }) { @@ -667,6 +669,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { } else { err.help(&format!("{}: `{}`", msg, snippet)); } + true } fn suggest_add_reference_to_arg( @@ -808,19 +811,20 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { obligation: &PredicateObligation<'tcx>, err: &mut Diagnostic, trait_pred: ty::PolyTraitPredicate<'tcx>, - ) { + ) -> bool { let span = obligation.cause.span; + let mut suggested = false; if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) { let refs_number = snippet.chars().filter(|c| !c.is_whitespace()).take_while(|c| *c == '&').count(); if let Some('\'') = snippet.chars().filter(|c| !c.is_whitespace()).nth(refs_number) { // Do not suggest removal of borrow from type arguments. - return; + return false; } let Some(mut suggested_ty) = trait_pred.self_ty().no_bound_vars() else { - return; + return false; }; for refs_remaining in 0..refs_number { @@ -856,10 +860,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { String::new(), Applicability::MachineApplicable, ); + suggested = true; break; } } } + suggested } fn suggest_remove_await(&self, obligation: &PredicateObligation<'tcx>, err: &mut Diagnostic) { @@ -996,7 +1002,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { err: &mut Diagnostic, span: Span, trait_pred: ty::PolyTraitPredicate<'tcx>, - ) { + ) -> bool { let hir = self.tcx.hir(); let parent_node = hir.get_parent_node(obligation.cause.body_id); let node = hir.find(parent_node); @@ -1015,7 +1021,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { { let sp = self.tcx.sess.source_map().end_point(stmt.span); err.span_label(sp, "consider removing this semicolon"); + return true; } + false } fn return_type_span(&self, obligation: &PredicateObligation<'tcx>) -> Option { diff --git a/library/core/src/ops/function.rs b/library/core/src/ops/function.rs index e5c4798afcbff..8383f92643550 100644 --- a/library/core/src/ops/function.rs +++ b/library/core/src/ops/function.rs @@ -53,6 +53,7 @@ /// ``` #[lang = "fn"] #[stable(feature = "rust1", since = "1.0.0")] +#[rustc_diagnostic_item = "Fn"] #[rustc_paren_sugar] #[rustc_on_unimplemented( on( @@ -133,6 +134,7 @@ pub trait Fn: FnMut { /// ``` #[lang = "fn_mut"] #[stable(feature = "rust1", since = "1.0.0")] +#[rustc_diagnostic_item = "FnMut"] #[rustc_paren_sugar] #[rustc_on_unimplemented( on( @@ -205,6 +207,7 @@ pub trait FnMut: FnOnce { /// ``` #[lang = "fn_once"] #[stable(feature = "rust1", since = "1.0.0")] +#[rustc_diagnostic_item = "FnOnce"] #[rustc_paren_sugar] #[rustc_on_unimplemented( on( diff --git a/library/core/src/slice/index.rs b/library/core/src/slice/index.rs index 880d0f80cc8a0..68de4e4e1f32a 100644 --- a/library/core/src/slice/index.rs +++ b/library/core/src/slice/index.rs @@ -140,6 +140,7 @@ mod private_slice_index { /// Implementations of this trait have to promise that if the argument /// to `get_(mut_)unchecked` is a safe reference, then so is the result. #[stable(feature = "slice_get_slice", since = "1.28.0")] +#[rustc_diagnostic_item = "SliceIndex"] #[rustc_on_unimplemented( on(T = "str", label = "string indices are ranges of `usize`",), on( diff --git a/src/test/ui/allocator/not-an-allocator.rs b/src/test/ui/allocator/not-an-allocator.rs index 417c371bdbf61..4a538d4d0a0d8 100644 --- a/src/test/ui/allocator/not-an-allocator.rs +++ b/src/test/ui/allocator/not-an-allocator.rs @@ -1,8 +1,8 @@ #[global_allocator] static A: usize = 0; -//~^ the trait bound `usize: -//~| the trait bound `usize: -//~| the trait bound `usize: -//~| the trait bound `usize: +//~^ ERROR E0277 +//~| ERROR E0277 +//~| ERROR E0277 +//~| ERROR E0277 fn main() {} diff --git a/src/test/ui/allocator/not-an-allocator.stderr b/src/test/ui/allocator/not-an-allocator.stderr index c0f6118a9f163..62bb0679f813a 100644 --- a/src/test/ui/allocator/not-an-allocator.stderr +++ b/src/test/ui/allocator/not-an-allocator.stderr @@ -6,6 +6,7 @@ LL | #[global_allocator] LL | static A: usize = 0; | ^^^^^ the trait `GlobalAlloc` is not implemented for `usize` | + = help: the trait `GlobalAlloc` is implemented for `System` = note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied @@ -16,6 +17,7 @@ LL | #[global_allocator] LL | static A: usize = 0; | ^^^^^ the trait `GlobalAlloc` is not implemented for `usize` | + = help: the trait `GlobalAlloc` is implemented for `System` = note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied @@ -26,6 +28,7 @@ LL | #[global_allocator] LL | static A: usize = 0; | ^^^^^ the trait `GlobalAlloc` is not implemented for `usize` | + = help: the trait `GlobalAlloc` is implemented for `System` = note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied @@ -36,6 +39,7 @@ LL | #[global_allocator] LL | static A: usize = 0; | ^^^^^ the trait `GlobalAlloc` is not implemented for `usize` | + = help: the trait `GlobalAlloc` is implemented for `System` = note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 4 previous errors diff --git a/src/test/ui/associated-types/associated-types-path-2.stderr b/src/test/ui/associated-types/associated-types-path-2.stderr index f56631b12aa67..2d8d513409d3a 100644 --- a/src/test/ui/associated-types/associated-types-path-2.stderr +++ b/src/test/ui/associated-types/associated-types-path-2.stderr @@ -15,8 +15,7 @@ error[E0277]: the trait bound `u32: Foo` is not satisfied LL | f1(2u32, 4u32); | ^^ the trait `Foo` is not implemented for `u32` | - = help: the following implementations were found: - + = help: the trait `Foo` is implemented for `i32` note: required by a bound in `f1` --> $DIR/associated-types-path-2.rs:13:14 | @@ -29,8 +28,7 @@ error[E0277]: the trait bound `u32: Foo` is not satisfied LL | f1(2u32, 4u32); | ^^^^ the trait `Foo` is not implemented for `u32` | - = help: the following implementations were found: - + = help: the trait `Foo` is implemented for `i32` error[E0277]: the trait bound `u32: Foo` is not satisfied --> $DIR/associated-types-path-2.rs:35:8 @@ -40,8 +38,7 @@ LL | f1(2u32, 4i32); | | | required by a bound introduced by this call | - = help: the following implementations were found: - + = help: the trait `Foo` is implemented for `i32` note: required by a bound in `f1` --> $DIR/associated-types-path-2.rs:13:14 | @@ -54,8 +51,7 @@ error[E0277]: the trait bound `u32: Foo` is not satisfied LL | f1(2u32, 4i32); | ^^^^ the trait `Foo` is not implemented for `u32` | - = help: the following implementations were found: - + = help: the trait `Foo` is implemented for `i32` error[E0308]: mismatched types --> $DIR/associated-types-path-2.rs:41:18 diff --git a/src/test/ui/associated-types/hr-associated-type-bound-1.stderr b/src/test/ui/associated-types/hr-associated-type-bound-1.stderr index ec28ca240be2b..73b5e1053fb9d 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-1.stderr +++ b/src/test/ui/associated-types/hr-associated-type-bound-1.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied LL | type U = str; | ^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - + = help: the trait `Clone` is implemented for `String` note: required by a bound in `X` --> $DIR/hr-associated-type-bound-1.rs:3:33 | diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-1.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-1.stderr index e48ef8d17d1de..af2e616896a87 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-1.stderr +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-1.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied LL | type V = str; | ^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - + = help: the trait `Clone` is implemented for `String` note: required by a bound in `Y` --> $DIR/hr-associated-type-bound-param-1.rs:4:36 | diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-2.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-2.stderr index 2fb3af38c0d9b..5809c407a5f7f 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-2.stderr +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-2.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied LL | T: Z<'a, u16>, | ^^^^^^^^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - + = help: the trait `Clone` is implemented for `String` note: required by a bound in `Z` --> $DIR/hr-associated-type-bound-param-2.rs:6:35 | @@ -21,8 +20,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied LL | T: Z<'a, u16>, | ^^^^^^^^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - + = help: the trait `Clone` is implemented for `String` note: required by a bound in `Z` --> $DIR/hr-associated-type-bound-param-2.rs:6:35 | @@ -38,8 +36,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied LL | type W = str; | ^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - + = help: the trait `Clone` is implemented for `String` note: required by a bound in `Z` --> $DIR/hr-associated-type-bound-param-2.rs:6:35 | diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-3.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-3.stderr index 775f45ca82965..84d5e0494cb69 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-3.stderr +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-3.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied LL | type U = str; | ^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - + = help: the trait `Clone` is implemented for `String` note: required by a bound in `X` --> $DIR/hr-associated-type-bound-param-3.rs:4:33 | diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-4.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-4.stderr index 4e9b64ba832ad..ee1d5d324954a 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-4.stderr +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-4.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied LL | type U = str; | ^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - + = help: the trait `Clone` is implemented for `String` note: required by a bound in `X` --> $DIR/hr-associated-type-bound-param-4.rs:4:36 | diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-5.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-5.stderr index d00abf30d3b05..ece3151ba978c 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-5.stderr +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-5.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied LL | type U = str; | ^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - + = help: the trait `Clone` is implemented for `String` note: required by a bound in `X` --> $DIR/hr-associated-type-bound-param-5.rs:17:45 | @@ -21,8 +20,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied LL | type U = str; | ^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - + = help: the trait `Clone` is implemented for `String` note: required by a bound in `X` --> $DIR/hr-associated-type-bound-param-5.rs:17:45 | diff --git a/src/test/ui/associated-types/issue-65774-1.stderr b/src/test/ui/associated-types/issue-65774-1.stderr index 82c520b99b170..e468a1b3ba484 100644 --- a/src/test/ui/associated-types/issue-65774-1.stderr +++ b/src/test/ui/associated-types/issue-65774-1.stderr @@ -4,6 +4,7 @@ error[E0277]: the trait bound `T: MyDisplay` is not satisfied LL | type MpuConfig: MyDisplay = T; | ^ the trait `MyDisplay` is not implemented for `T` | + = help: the trait `MyDisplay` is implemented for `&'a mut T` note: required by a bound in `MPU::MpuConfig` --> $DIR/issue-65774-1.rs:10:21 | @@ -16,6 +17,7 @@ error[E0277]: the trait bound `T: MyDisplay` is not satisfied LL | let closure = |config: &mut ::MpuConfig| writer.my_write(&config); | ^^^^^^^ the trait `MyDisplay` is not implemented for `T` | + = help: the trait `MyDisplay` is implemented for `&'a mut T` note: required because of the requirements on the impl of `MyDisplay` for `&mut T` --> $DIR/issue-65774-1.rs:5:24 | diff --git a/src/test/ui/associated-types/issue-65774-2.stderr b/src/test/ui/associated-types/issue-65774-2.stderr index 349cef9df72dd..4cef4db4698a7 100644 --- a/src/test/ui/associated-types/issue-65774-2.stderr +++ b/src/test/ui/associated-types/issue-65774-2.stderr @@ -4,6 +4,7 @@ error[E0277]: the trait bound `T: MyDisplay` is not satisfied LL | type MpuConfig: MyDisplay = T; | ^ the trait `MyDisplay` is not implemented for `T` | + = help: the trait `MyDisplay` is implemented for `&'a mut T` note: required by a bound in `MPU::MpuConfig` --> $DIR/issue-65774-2.rs:10:21 | @@ -16,6 +17,7 @@ error[E0277]: the trait bound `T: MyDisplay` is not satisfied LL | writer.my_write(valref) | ^^^^^^ the trait `MyDisplay` is not implemented for `T` | + = help: the trait `MyDisplay` is implemented for `&'a mut T` = note: required for the cast to the object type `dyn MyDisplay` error: aborting due to 2 previous errors diff --git a/src/test/ui/auto-traits/typeck-default-trait-impl-precedence.stderr b/src/test/ui/auto-traits/typeck-default-trait-impl-precedence.stderr index 5755778fef266..985cdce1224da 100644 --- a/src/test/ui/auto-traits/typeck-default-trait-impl-precedence.stderr +++ b/src/test/ui/auto-traits/typeck-default-trait-impl-precedence.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `u32: Signed` is not satisfied LL | is_defaulted::<&'static u32>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Signed` is not implemented for `u32` | - = help: the following implementations were found: - + = help: the trait `Signed` is implemented for `i32` note: required because of the requirements on the impl of `Defaulted` for `&'static u32` --> $DIR/typeck-default-trait-impl-precedence.rs:10:19 | diff --git a/src/test/ui/binop/binop-mul-i32-f32.stderr b/src/test/ui/binop/binop-mul-i32-f32.stderr index 4a67fe2379b8d..9fcf5d72625c5 100644 --- a/src/test/ui/binop/binop-mul-i32-f32.stderr +++ b/src/test/ui/binop/binop-mul-i32-f32.stderr @@ -5,6 +5,12 @@ LL | x * y | ^ no implementation for `i32 * f32` | = help: the trait `Mul` is not implemented for `i32` + = help: the following implementations were found: + <&'a i32 as Mul> + <&i32 as Mul<&i32>> + > + + and 49 others error: aborting due to previous error diff --git a/src/test/ui/binop/issue-77910-1.stderr b/src/test/ui/binop/issue-77910-1.stderr index db854ae80d738..9553fcc5bb204 100644 --- a/src/test/ui/binop/issue-77910-1.stderr +++ b/src/test/ui/binop/issue-77910-1.stderr @@ -16,6 +16,12 @@ LL | assert_eq!(foo, y); | ^^^^^^^^^^^^^^^^^^ `for<'r> fn(&'r i32) -> &'r i32 {foo}` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = help: the trait `Debug` is not implemented for `for<'r> fn(&'r i32) -> &'r i32 {foo}` + = help: the following implementations were found: + Ret as Debug> + Ret as Debug> + Ret as Debug> + Ret as Debug> + and 68 others = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/binop/shift-various-bad-types.stderr b/src/test/ui/binop/shift-various-bad-types.stderr index 932a435143b0c..e134095e63879 100644 --- a/src/test/ui/binop/shift-various-bad-types.stderr +++ b/src/test/ui/binop/shift-various-bad-types.stderr @@ -5,6 +5,12 @@ LL | 22 >> p.char; | ^^ no implementation for `{integer} >> char` | = help: the trait `Shr` is not implemented for `{integer}` + = help: the following implementations were found: + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + and 568 others error[E0277]: no implementation for `{integer} >> &str` --> $DIR/shift-various-bad-types.rs:12:8 @@ -13,6 +19,12 @@ LL | 22 >> p.str; | ^^ no implementation for `{integer} >> &str` | = help: the trait `Shr<&str>` is not implemented for `{integer}` + = help: the following implementations were found: + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + and 568 others error[E0277]: no implementation for `{integer} >> &Panolpy` --> $DIR/shift-various-bad-types.rs:15:8 @@ -21,6 +33,12 @@ LL | 22 >> p; | ^^ no implementation for `{integer} >> &Panolpy` | = help: the trait `Shr<&Panolpy>` is not implemented for `{integer}` + = help: the following implementations were found: + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + and 568 others error[E0308]: mismatched types --> $DIR/shift-various-bad-types.rs:25:18 diff --git a/src/test/ui/block-result/issue-22645.stderr b/src/test/ui/block-result/issue-22645.stderr index 397bdac60513e..31663e8e84d72 100644 --- a/src/test/ui/block-result/issue-22645.stderr +++ b/src/test/ui/block-result/issue-22645.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `{integer}: Scalar` is not satisfied LL | b + 3 | ^ the trait `Scalar` is not implemented for `{integer}` | - = help: the following implementations were found: - + = help: the trait `Scalar` is implemented for `f64` note: required because of the requirements on the impl of `Add<{integer}>` for `Bob` --> $DIR/issue-22645.rs:8:19 | diff --git a/src/test/ui/chalkify/generic_impls.stderr b/src/test/ui/chalkify/generic_impls.stderr index 0c7fcd04dfd2d..d4a8354d3fc80 100644 --- a/src/test/ui/chalkify/generic_impls.stderr +++ b/src/test/ui/chalkify/generic_impls.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `(Option, f32): Foo` is not satisfied LL | gimme::<(Option, f32)>(); | ^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(Option, f32)` | - = help: the following implementations were found: - <(T, u32) as Foo> + = help: the trait `Foo` is implemented for `(T, u32)` note: required by a bound in `gimme` --> $DIR/generic_impls.rs:7:13 | @@ -18,8 +17,7 @@ error[E0277]: the trait bound `(i32, f32): Foo` is not satisfied LL | gimme::<(i32, f32)>(); | ^^^^^^^^^^ the trait `Foo` is not implemented for `(i32, f32)` | - = help: the following implementations were found: - <(T, u32) as Foo> + = help: the trait `Foo` is implemented for `(T, u32)` note: required by a bound in `gimme` --> $DIR/generic_impls.rs:7:13 | diff --git a/src/test/ui/chalkify/impl_wf.stderr b/src/test/ui/chalkify/impl_wf.stderr index 2bc9f077f0285..a142459bcb4a5 100644 --- a/src/test/ui/chalkify/impl_wf.stderr +++ b/src/test/ui/chalkify/impl_wf.stderr @@ -17,8 +17,7 @@ error[E0277]: the trait bound `f32: Foo` is not satisfied LL | impl Baz for f32 { } | ^^^^^^^^ the trait `Foo` is not implemented for `f32` | - = help: the following implementations were found: - + = help: the trait `Foo` is implemented for `i32` note: required by a bound in `Baz` --> $DIR/impl_wf.rs:18:31 | diff --git a/src/test/ui/chalkify/impl_wf_2.stderr b/src/test/ui/chalkify/impl_wf_2.stderr index 30cec80b036c6..1c1df644b0610 100644 --- a/src/test/ui/chalkify/impl_wf_2.stderr +++ b/src/test/ui/chalkify/impl_wf_2.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `f32: Foo` is not satisfied LL | type Item = f32; | ^^^ the trait `Foo` is not implemented for `f32` | - = help: the following implementations were found: - + = help: the trait `Foo` is implemented for `i32` note: required by a bound in `Bar::Item` --> $DIR/impl_wf_2.rs:8:16 | diff --git a/src/test/ui/chalkify/type_wf.stderr b/src/test/ui/chalkify/type_wf.stderr index 6abd8b28760d8..7f8566082cd26 100644 --- a/src/test/ui/chalkify/type_wf.stderr +++ b/src/test/ui/chalkify/type_wf.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `{float}: Foo` is not satisfied LL | let s = S { | ^ the trait `Foo` is not implemented for `{float}` | - = help: the following implementations were found: - + = help: the trait `Foo` is implemented for `i32` note: required by a bound in `S` --> $DIR/type_wf.rs:6:13 | diff --git a/src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr b/src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr index fbaa874792a01..a4b10a4c339f9 100644 --- a/src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr +++ b/src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr @@ -4,6 +4,16 @@ error[E0277]: the trait bound `(): std::error::Error` is not satisfied LL | /* *mut $0 is coerced to Box here */ Box::<_ /* ! */>::new(x) | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()` | + = help: the following other types implement trait `std::error::Error`: + ! + &'a T + AccessError + AddrParseError + Arc + BorrowError + BorrowMutError + Box + and 42 others = note: required for the cast to the object type `dyn std::error::Error` error[E0277]: the trait bound `(): std::error::Error` is not satisfied @@ -12,6 +22,16 @@ error[E0277]: the trait bound `(): std::error::Error` is not satisfied LL | /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /* ! */>(x) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()` | + = help: the following other types implement trait `std::error::Error`: + ! + &'a T + AccessError + AddrParseError + Arc + BorrowError + BorrowMutError + Box + and 42 others = note: required for the cast to the object type `(dyn std::error::Error + 'static)` error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/associated-type-bound-fail.stderr b/src/test/ui/const-generics/associated-type-bound-fail.stderr index 9dc677ef6ed48..da2558229a758 100644 --- a/src/test/ui/const-generics/associated-type-bound-fail.stderr +++ b/src/test/ui/const-generics/associated-type-bound-fail.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `u16: Bar` is not satisfied LL | type Assoc = u16; | ^^^ the trait `Bar` is not implemented for `u16` | - = help: the following implementations were found: - > + = help: the trait `Bar<3_usize>` is implemented for `u16` note: required by a bound in `Foo::Assoc` --> $DIR/associated-type-bound-fail.rs:4:17 | diff --git a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr index 81cfcb3560661..9cadc4110e1e6 100644 --- a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr +++ b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied LL | fn rawr() -> impl Trait { | ^^^^^^^^^^ the trait `Trait` is not implemented for `Uwu<10_u32, 12_u32>` | - = help: the following implementations were found: - as Trait> + = help: the trait `Trait` is implemented for `Uwu` error[E0277]: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied --> $DIR/rp_impl_trait_fail.rs:6:25 @@ -18,8 +17,7 @@ LL | | Uwu::<10, 12> LL | | } | |_^ the trait `Trait` is not implemented for `Uwu<10_u32, 12_u32>` | - = help: the following implementations were found: - as Trait> + = help: the trait `Trait` is implemented for `Uwu` error[E0277]: the trait bound `u32: Traitor` is not satisfied --> $DIR/rp_impl_trait_fail.rs:18:26 diff --git a/src/test/ui/const-generics/defaults/trait_objects_fail.stderr b/src/test/ui/const-generics/defaults/trait_objects_fail.stderr index 13d03c2d42d31..7f8a1f742d840 100644 --- a/src/test/ui/const-generics/defaults/trait_objects_fail.stderr +++ b/src/test/ui/const-generics/defaults/trait_objects_fail.stderr @@ -6,8 +6,7 @@ LL | foo(&10_u32); | | | required by a bound introduced by this call | - = help: the following implementations were found: - > + = help: the trait `Trait<2_u8>` is implemented for `u32` = note: required for the cast to the object type `dyn Trait` error[E0277]: the trait bound `bool: Traitor<{_: u8}, {_: u8}>` is not satisfied @@ -18,8 +17,7 @@ LL | bar(&true); | | | required by a bound introduced by this call | - = help: the following implementations were found: - > + = help: the trait `Traitor<2_u8, 3_u8>` is implemented for `bool` = note: required for the cast to the object type `dyn Traitor<{_: u8}, {_: u8}>` error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/defaults/wfness.stderr b/src/test/ui/const-generics/defaults/wfness.stderr index facf0ae19f734..8b405d6753e56 100644 --- a/src/test/ui/const-generics/defaults/wfness.stderr +++ b/src/test/ui/const-generics/defaults/wfness.stderr @@ -10,8 +10,7 @@ error[E0277]: the trait bound `(): Trait<2_u8>` is not satisfied LL | struct WhereClause where (): Trait; | ^^^^^^^^ the trait `Trait<2_u8>` is not implemented for `()` | - = help: the following implementations were found: - <() as Trait<3_u8>> + = help: the trait `Trait<3_u8>` is implemented for `()` error[E0277]: the trait bound `(): Trait<1_u8>` is not satisfied --> $DIR/wfness.rs:14:13 @@ -19,8 +18,7 @@ error[E0277]: the trait bound `(): Trait<1_u8>` is not satisfied LL | fn foo() -> DependentDefaultWfness { | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<1_u8>` is not implemented for `()` | - = help: the following implementations were found: - <() as Trait<3_u8>> + = help: the trait `Trait<3_u8>` is implemented for `()` note: required by a bound in `WhereClause` --> $DIR/wfness.rs:6:47 | diff --git a/src/test/ui/const-generics/exhaustive-value.stderr b/src/test/ui/const-generics/exhaustive-value.stderr index 1a8f4abf52aa3..cb85b6cb93d91 100644 --- a/src/test/ui/const-generics/exhaustive-value.stderr +++ b/src/test/ui/const-generics/exhaustive-value.stderr @@ -9,7 +9,7 @@ LL | <() as Foo>::test() <() as Foo<100_u8>> <() as Foo<101_u8>> <() as Foo<102_u8>> - and 252 others + and 248 others error: aborting due to previous error diff --git a/src/test/ui/const-generics/occurs-check/unused-substs-1.stderr b/src/test/ui/const-generics/occurs-check/unused-substs-1.stderr index 486a298a9ffe5..aedf44658db63 100644 --- a/src/test/ui/const-generics/occurs-check/unused-substs-1.stderr +++ b/src/test/ui/const-generics/occurs-check/unused-substs-1.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `A<{_: usize}>: Bar<{_: usize}>` is not satisfied LL | let _ = A; | ^ the trait `Bar<{_: usize}>` is not implemented for `A<{_: usize}>` | - = help: the following implementations were found: - as Bar> + = help: the trait `Bar` is implemented for `A<{ 6 + 1 }>` note: required by a bound in `A` --> $DIR/unused-substs-1.rs:9:11 | diff --git a/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr b/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr index 329c6cb2b1285..52a1669e33002 100644 --- a/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr +++ b/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `Option: Copy` is not satisfied LL | let _: [Option; 2] = [no_copy(); 2]; | ^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Option` | - = help: the following implementations were found: - as Copy> + = help: the trait `Copy` is implemented for `Option` = note: the `Copy` trait is required because the repeated element will be copied = help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position, like `const VAL: Type = const_fn();` and `let x = [VAL; 42];` = help: create an inline `const` block, see RFC #2920 for more information diff --git a/src/test/ui/consts/const-blocks/migrate-fail.stderr b/src/test/ui/consts/const-blocks/migrate-fail.stderr index 0fdbbc36288e9..318fec60290ee 100644 --- a/src/test/ui/consts/const-blocks/migrate-fail.stderr +++ b/src/test/ui/consts/const-blocks/migrate-fail.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `Option: Copy` is not satisfied LL | let arr: [Option; 2] = [x; 2]; | ^^^^^^ the trait `Copy` is not implemented for `Option` | - = help: the following implementations were found: - as Copy> + = help: the trait `Copy` is implemented for `Option` = note: the `Copy` trait is required because the repeated element will be copied error[E0277]: the trait bound `Option: Copy` is not satisfied @@ -14,8 +13,7 @@ error[E0277]: the trait bound `Option: Copy` is not satisfied LL | let arr: [Option; 2] = [x; 2]; | ^^^^^^ the trait `Copy` is not implemented for `Option` | - = help: the following implementations were found: - as Copy> + = help: the trait `Copy` is implemented for `Option` = note: the `Copy` trait is required because the repeated element will be copied error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/const-blocks/nll-fail.stderr b/src/test/ui/consts/const-blocks/nll-fail.stderr index 8122085635977..5a34361aa83b6 100644 --- a/src/test/ui/consts/const-blocks/nll-fail.stderr +++ b/src/test/ui/consts/const-blocks/nll-fail.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `Option: Copy` is not satisfied LL | let arr: [Option; 2] = [x; 2]; | ^^^^^^ the trait `Copy` is not implemented for `Option` | - = help: the following implementations were found: - as Copy> + = help: the trait `Copy` is implemented for `Option` = note: the `Copy` trait is required because the repeated element will be copied error[E0277]: the trait bound `Option: Copy` is not satisfied @@ -14,8 +13,7 @@ error[E0277]: the trait bound `Option: Copy` is not satisfied LL | let arr: [Option; 2] = [x; 2]; | ^^^^^^ the trait `Copy` is not implemented for `Option` | - = help: the following implementations were found: - as Copy> + = help: the trait `Copy` is implemented for `Option` = note: the `Copy` trait is required because the repeated element will be copied error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/const-blocks/trait-error.stderr b/src/test/ui/consts/const-blocks/trait-error.stderr index 26e2848e7f7a1..6979ff36176cd 100644 --- a/src/test/ui/consts/const-blocks/trait-error.stderr +++ b/src/test/ui/consts/const-blocks/trait-error.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `Foo: Copy` is not satisfied LL | [Foo(String::new()); 4]; | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Foo` | - = help: the following implementations were found: - as Copy> + = help: the trait `Copy` is implemented for `Foo` = note: the `Copy` trait is required because the repeated element will be copied error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr index 2b96b66819286..aee7192b6eda1 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr @@ -11,6 +11,12 @@ LL | = [0; (i8::MAX + 1u8) as usize]; | ^ no implementation for `i8 + u8` | = help: the trait `Add` is not implemented for `i8` + = help: the following implementations were found: + <&'a i8 as Add> + <&i8 as Add<&i8>> + > + + and 48 others error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr index f59ff329d18ac..059447f7cacb3 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr @@ -11,6 +11,12 @@ LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | ^ no implementation for `i8 + u8` | = help: the trait `Add` is not implemented for `i8` + = help: the following implementations were found: + <&'a i8 as Add> + <&i8 as Add<&i8>> + > + + and 48 others error[E0604]: only `u8` can be cast as `char`, not `i8` --> $DIR/const-eval-overflow-4b.rs:22:13 diff --git a/src/test/ui/consts/too_generic_eval_ice.stderr b/src/test/ui/consts/too_generic_eval_ice.stderr index ac104ed4a5a58..677fa7d21aef0 100644 --- a/src/test/ui/consts/too_generic_eval_ice.stderr +++ b/src/test/ui/consts/too_generic_eval_ice.stderr @@ -21,6 +21,12 @@ LL | [5; Self::HOST_SIZE] == [6; 0] | ^^ no implementation for `[{integer}; _] == [{integer}; 0]` | = help: the trait `PartialEq<[{integer}; 0]>` is not implemented for `[{integer}; _]` + = help: the following implementations were found: + <&[B] as PartialEq<[A; N]>> + <&[T] as PartialEq>> + <&mut [B] as PartialEq<[A; N]>> + <&mut [T] as PartialEq>> + and 3 others error: aborting due to 3 previous errors diff --git a/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr index d6d5ce4d1a7d2..ea461241bf414 100644 --- a/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr +++ b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr @@ -9,7 +9,6 @@ LL | f1.foo(1usize); > > > - and 2 others error: aborting due to previous error diff --git a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr index dff980301911c..58faaf4ea9014 100644 --- a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr +++ b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr @@ -11,7 +11,6 @@ LL | Foo::::bar(&1i8); > > > - and 5 others error[E0277]: the trait bound `u8: Foo` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:25:21 @@ -26,7 +25,6 @@ LL | Foo::::bar(&1u8); > > > - and 5 others error[E0277]: the trait bound `bool: Foo` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:26:21 @@ -41,7 +39,6 @@ LL | Foo::::bar(&true); > > > - and 2 others error: aborting due to 3 previous errors diff --git a/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr b/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr index 83fc37e7e537f..c12b02a76c58a 100644 --- a/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr +++ b/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr @@ -22,6 +22,12 @@ LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e−11; // m³⋅kg⁻¹ | ^ no implementation for `{float} - {integer}` | = help: the trait `Sub<{integer}>` is not implemented for `{float}` + = help: the following implementations were found: + <&'a f32 as Sub> + <&'a f64 as Sub> + <&'a i128 as Sub> + <&'a i16 as Sub> + and 48 others error: aborting due to 3 previous errors diff --git a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr index 28c49c33bf6b5..1b87ebd9f20ce 100644 --- a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr +++ b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr @@ -4,6 +4,7 @@ error[E0277]: the trait bound `i32: Foo` is not satisfied LL | enum E where i32: Foo { V } | ^^^^^^^^ the trait `Foo` is not implemented for `i32` | + = help: the trait `Foo` is implemented for `()` = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable @@ -13,6 +14,7 @@ error[E0277]: the trait bound `i32: Foo` is not satisfied LL | struct S where i32: Foo; | ^^^^^^^^ the trait `Foo` is not implemented for `i32` | + = help: the trait `Foo` is implemented for `()` = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable @@ -22,6 +24,7 @@ error[E0277]: the trait bound `i32: Foo` is not satisfied LL | trait T where i32: Foo {} | ^^^^^^^^ the trait `Foo` is not implemented for `i32` | + = help: the trait `Foo` is implemented for `()` = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable @@ -31,6 +34,7 @@ error[E0277]: the trait bound `i32: Foo` is not satisfied LL | union U where i32: Foo { f: i32 } | ^^^^^^^^ the trait `Foo` is not implemented for `i32` | + = help: the trait `Foo` is implemented for `()` = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable @@ -40,6 +44,7 @@ error[E0277]: the trait bound `i32: Foo` is not satisfied LL | impl Foo for () where i32: Foo { | ^^^^^^^^ the trait `Foo` is not implemented for `i32` | + = help: the trait `Foo` is implemented for `()` = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable @@ -49,6 +54,7 @@ error[E0277]: the trait bound `i32: Foo` is not satisfied LL | fn f() where i32: Foo | ^^^^^^^^ the trait `Foo` is not implemented for `i32` | + = help: the trait `Foo` is implemented for `()` = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable diff --git a/src/test/ui/fmt/ifmt-unimpl.stderr b/src/test/ui/fmt/ifmt-unimpl.stderr index 6e8dd79219106..5204afa4e6bc5 100644 --- a/src/test/ui/fmt/ifmt-unimpl.stderr +++ b/src/test/ui/fmt/ifmt-unimpl.stderr @@ -4,6 +4,16 @@ error[E0277]: the trait bound `str: UpperHex` is not satisfied LL | format!("{:X}", "3"); | ^^^ the trait `UpperHex` is not implemented for `str` | + = help: the following other types implement trait `UpperHex`: + &T + &mut T + NonZeroI128 + NonZeroI16 + NonZeroI32 + NonZeroI64 + NonZeroI8 + NonZeroIsize + and 21 others = note: required because of the requirements on the impl of `UpperHex` for `&str` note: required by a bound in `ArgumentV1::<'a>::new_upper_hex` --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL diff --git a/src/test/ui/generic-associated-types/bugs/issue-88460.stderr b/src/test/ui/generic-associated-types/bugs/issue-88460.stderr index 0b83e9da1ab7a..ec8de15dc3957 100644 --- a/src/test/ui/generic-associated-types/bugs/issue-88460.stderr +++ b/src/test/ui/generic-associated-types/bugs/issue-88460.stderr @@ -4,6 +4,7 @@ error[E0277]: the trait bound `for<'a> <_ as Trait>::Assoc<'a>: Marker` is not s LL | test(Foo); | ^^^^ the trait `for<'a> Marker` is not implemented for `<_ as Trait>::Assoc<'a>` | + = help: the trait `for<'a> Marker` is implemented for `()` note: required by a bound in `test` --> $DIR/issue-88460.rs:17:27 | diff --git a/src/test/ui/impl-trait/equality.stderr b/src/test/ui/impl-trait/equality.stderr index 804ccbcc6c0ab..6592e234d9873 100644 --- a/src/test/ui/impl-trait/equality.stderr +++ b/src/test/ui/impl-trait/equality.stderr @@ -24,6 +24,12 @@ LL | n + sum_to(n - 1) | ^ no implementation for `u32 + impl Foo` | = help: the trait `Add` is not implemented for `u32` + = help: the following implementations were found: + <&'a u32 as Add> + <&u32 as Add<&u32>> + > + + and 48 others error: aborting due to 2 previous errors; 1 warning emitted diff --git a/src/test/ui/impl-trait/issues/issue-62742.stderr b/src/test/ui/impl-trait/issues/issue-62742.stderr index 28068b7548ce5..70d693b8bee95 100644 --- a/src/test/ui/impl-trait/issues/issue-62742.stderr +++ b/src/test/ui/impl-trait/issues/issue-62742.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `RawImpl<_>: Raw<_>` is not satisfied LL | WrongImpl::foo(0i32); | ^^^^^^^^^ the trait `Raw<_>` is not implemented for `RawImpl<_>` | - = help: the following implementations were found: - as Raw<[T]>> + = help: the trait `Raw<[T]>` is implemented for `RawImpl` note: required by a bound in `SafeImpl` --> $DIR/issue-62742.rs:26:35 | @@ -40,8 +39,7 @@ error[E0277]: the trait bound `RawImpl<()>: Raw<()>` is not satisfied LL | WrongImpl::<()>::foo(0i32); | ^^^^^^^^^^^^^^^ the trait `Raw<()>` is not implemented for `RawImpl<()>` | - = help: the following implementations were found: - as Raw<[T]>> + = help: the trait `Raw<[T]>` is implemented for `RawImpl` note: required by a bound in `SafeImpl` --> $DIR/issue-62742.rs:26:35 | diff --git a/src/test/ui/impl-trait/nested-return-type2-tait.stderr b/src/test/ui/impl-trait/nested-return-type2-tait.stderr index 776c06b20dfc2..81a75e39c9177 100644 --- a/src/test/ui/impl-trait/nested-return-type2-tait.stderr +++ b/src/test/ui/impl-trait/nested-return-type2-tait.stderr @@ -4,6 +4,7 @@ error[E0277]: the trait bound `Sendable: Duh` is not satisfied LL | fn foo() -> impl Trait { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Duh` is not implemented for `Sendable` | + = help: the trait `Duh` is implemented for `i32` note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait.rs:28:5: 28:10]` --> $DIR/nested-return-type2-tait.rs:14:31 | @@ -21,6 +22,7 @@ LL | | || 42 LL | | } | |_^ the trait `Duh` is not implemented for `Sendable` | + = help: the trait `Duh` is implemented for `i32` note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait.rs:28:5: 28:10]` --> $DIR/nested-return-type2-tait.rs:14:31 | diff --git a/src/test/ui/impl-trait/nested-return-type2-tait2.stderr b/src/test/ui/impl-trait/nested-return-type2-tait2.stderr index 4993202e2532e..42e65e692488d 100644 --- a/src/test/ui/impl-trait/nested-return-type2-tait2.stderr +++ b/src/test/ui/impl-trait/nested-return-type2-tait2.stderr @@ -4,6 +4,7 @@ error[E0277]: the trait bound `Sendable: Duh` is not satisfied LL | || 42 | ^^^^^ the trait `Duh` is not implemented for `Sendable` | + = help: the trait `Duh` is implemented for `i32` note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait2.rs:27:5: 27:10]` --> $DIR/nested-return-type2-tait2.rs:14:31 | diff --git a/src/test/ui/impl-trait/nested-return-type2-tait3.stderr b/src/test/ui/impl-trait/nested-return-type2-tait3.stderr index efeaf059a3bb2..4d3691d0e07fa 100644 --- a/src/test/ui/impl-trait/nested-return-type2-tait3.stderr +++ b/src/test/ui/impl-trait/nested-return-type2-tait3.stderr @@ -4,6 +4,7 @@ error[E0277]: the trait bound `impl Send: Duh` is not satisfied LL | || 42 | ^^^^^ the trait `Duh` is not implemented for `impl Send` | + = help: the trait `Duh` is implemented for `i32` note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait3.rs:26:5: 26:10]` --> $DIR/nested-return-type2-tait3.rs:14:31 | diff --git a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr index 5476bf9d27745..6cd63db44fa07 100644 --- a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr +++ b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr @@ -5,6 +5,7 @@ LL | Bar | ^^^ no implementation for `Bar == (Bar, i32)` | = help: the trait `PartialEq<(Bar, i32)>` is not implemented for `Bar` + = help: the trait `PartialEq<(Foo, i32)>` is implemented for `Bar` error: aborting due to previous error diff --git a/src/test/ui/index-help.stderr b/src/test/ui/index-help.stderr index 78a8f439a71cc..7f51a48111b78 100644 --- a/src/test/ui/index-help.stderr +++ b/src/test/ui/index-help.stderr @@ -5,6 +5,7 @@ LL | x[0i32]; | ^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[{integer}]>` is not implemented for `i32` + = help: the trait `SliceIndex<[T]>` is implemented for `usize` = note: required because of the requirements on the impl of `Index` for `Vec<{integer}>` error: aborting due to previous error diff --git a/src/test/ui/indexing-requires-a-uint.stderr b/src/test/ui/indexing-requires-a-uint.stderr index 24f42f22f37df..dae11a702fb73 100644 --- a/src/test/ui/indexing-requires-a-uint.stderr +++ b/src/test/ui/indexing-requires-a-uint.stderr @@ -5,6 +5,7 @@ LL | [0][0u8]; | ^^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[{integer}]>` is not implemented for `u8` + = help: the trait `SliceIndex<[T]>` is implemented for `usize` = note: required because of the requirements on the impl of `Index` for `[{integer}]` error[E0308]: mismatched types diff --git a/src/test/ui/integral-indexing.stderr b/src/test/ui/integral-indexing.stderr index fcd79d19aac6e..be3398552dc0a 100644 --- a/src/test/ui/integral-indexing.stderr +++ b/src/test/ui/integral-indexing.stderr @@ -5,6 +5,7 @@ LL | v[3u8]; | ^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[isize]>` is not implemented for `u8` + = help: the trait `SliceIndex<[T]>` is implemented for `usize` = note: required because of the requirements on the impl of `Index` for `Vec` error[E0277]: the type `[isize]` cannot be indexed by `i8` @@ -14,6 +15,7 @@ LL | v[3i8]; | ^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[isize]>` is not implemented for `i8` + = help: the trait `SliceIndex<[T]>` is implemented for `usize` = note: required because of the requirements on the impl of `Index` for `Vec` error[E0277]: the type `[isize]` cannot be indexed by `u32` @@ -23,6 +25,7 @@ LL | v[3u32]; | ^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[isize]>` is not implemented for `u32` + = help: the trait `SliceIndex<[T]>` is implemented for `usize` = note: required because of the requirements on the impl of `Index` for `Vec` error[E0277]: the type `[isize]` cannot be indexed by `i32` @@ -32,6 +35,7 @@ LL | v[3i32]; | ^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[isize]>` is not implemented for `i32` + = help: the trait `SliceIndex<[T]>` is implemented for `usize` = note: required because of the requirements on the impl of `Index` for `Vec` error[E0277]: the type `[u8]` cannot be indexed by `u8` @@ -41,6 +45,7 @@ LL | s.as_bytes()[3u8]; | ^^^^^^^^^^^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[u8]>` is not implemented for `u8` + = help: the trait `SliceIndex<[T]>` is implemented for `usize` = note: required because of the requirements on the impl of `Index` for `[u8]` error[E0277]: the type `[u8]` cannot be indexed by `i8` @@ -50,6 +55,7 @@ LL | s.as_bytes()[3i8]; | ^^^^^^^^^^^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[u8]>` is not implemented for `i8` + = help: the trait `SliceIndex<[T]>` is implemented for `usize` = note: required because of the requirements on the impl of `Index` for `[u8]` error[E0277]: the type `[u8]` cannot be indexed by `u32` @@ -59,6 +65,7 @@ LL | s.as_bytes()[3u32]; | ^^^^^^^^^^^^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[u8]>` is not implemented for `u32` + = help: the trait `SliceIndex<[T]>` is implemented for `usize` = note: required because of the requirements on the impl of `Index` for `[u8]` error[E0277]: the type `[u8]` cannot be indexed by `i32` @@ -68,6 +75,7 @@ LL | s.as_bytes()[3i32]; | ^^^^^^^^^^^^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[u8]>` is not implemented for `i32` + = help: the trait `SliceIndex<[T]>` is implemented for `usize` = note: required because of the requirements on the impl of `Index` for `[u8]` error: aborting due to 8 previous errors diff --git a/src/test/ui/issues/issue-11771.stderr b/src/test/ui/issues/issue-11771.stderr index 9f250925e5080..2b93d4aab27db 100644 --- a/src/test/ui/issues/issue-11771.stderr +++ b/src/test/ui/issues/issue-11771.stderr @@ -5,6 +5,12 @@ LL | 1 + | ^ no implementation for `{integer} + ()` | = help: the trait `Add<()>` is not implemented for `{integer}` + = help: the following implementations were found: + <&'a f32 as Add> + <&'a f64 as Add> + <&'a i128 as Add> + <&'a i16 as Add> + and 48 others error[E0277]: cannot add `()` to `{integer}` --> $DIR/issue-11771.rs:8:7 @@ -13,6 +19,12 @@ LL | 1 + | ^ no implementation for `{integer} + ()` | = help: the trait `Add<()>` is not implemented for `{integer}` + = help: the following implementations were found: + <&'a f32 as Add> + <&'a f64 as Add> + <&'a i128 as Add> + <&'a i16 as Add> + and 48 others error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-24352.stderr b/src/test/ui/issues/issue-24352.stderr index 69731bfe7ee7d..f61ff0bda0bbd 100644 --- a/src/test/ui/issues/issue-24352.stderr +++ b/src/test/ui/issues/issue-24352.stderr @@ -5,6 +5,12 @@ LL | 1.0f64 - 1 | ^ no implementation for `f64 - {integer}` | = help: the trait `Sub<{integer}>` is not implemented for `f64` + = help: the following implementations were found: + <&'a f64 as Sub> + <&f64 as Sub<&f64>> + > + + and 48 others help: consider using a floating-point literal by writing it with `.0` | LL | 1.0f64 - 1.0 diff --git a/src/test/ui/issues/issue-34334.stderr b/src/test/ui/issues/issue-34334.stderr index cd697445faff3..48ae2df691c3d 100644 --- a/src/test/ui/issues/issue-34334.stderr +++ b/src/test/ui/issues/issue-34334.stderr @@ -19,6 +19,7 @@ LL | let sr2: Vec<(u32, _, _)> = sr.iter().map(|(faction, th_sender, th_rece | ^^^^^^^ value of type `Vec<(u32, _, _)>` cannot be built from `std::iter::Iterator` | = help: the trait `FromIterator<()>` is not implemented for `Vec<(u32, _, _)>` + = help: the trait `FromIterator` is implemented for `Vec` note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | diff --git a/src/test/ui/issues/issue-45801.stderr b/src/test/ui/issues/issue-45801.stderr index 099cf4e383426..8967f49df02a5 100644 --- a/src/test/ui/issues/issue-45801.stderr +++ b/src/test/ui/issues/issue-45801.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `Params: Plugin` is not satisfied LL | req.get_ref::(); | ^^^^^^^ the trait `Plugin` is not implemented for `Params` | - = help: the following implementations were found: - > + = help: the trait `Plugin` is implemented for `Params` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-50582.stderr b/src/test/ui/issues/issue-50582.stderr index 465fb9baac3f0..64bcfcd6016ab 100644 --- a/src/test/ui/issues/issue-50582.stderr +++ b/src/test/ui/issues/issue-50582.stderr @@ -14,6 +14,12 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); | ^ no implementation for `{integer} + ()` | = help: the trait `Add<()>` is not implemented for `{integer}` + = help: the following implementations were found: + <&'a f32 as Add> + <&'a f64 as Add> + <&'a i128 as Add> + <&'a i16 as Add> + and 48 others error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-59488.stderr b/src/test/ui/issues/issue-59488.stderr index 47fd9fdb65472..55616d2d322ee 100644 --- a/src/test/ui/issues/issue-59488.stderr +++ b/src/test/ui/issues/issue-59488.stderr @@ -94,6 +94,12 @@ LL | assert_eq!(Foo::Bar, i); | ^^^^^^^^^^^^^^^^^^^^^^^ `fn(usize) -> Foo {Foo::Bar}` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = help: the trait `Debug` is not implemented for `fn(usize) -> Foo {Foo::Bar}` + = help: the following implementations were found: + Ret as Debug> + Ret as Debug> + Ret as Debug> + Ret as Debug> + and 68 others = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 9 previous errors diff --git a/src/test/ui/issues/issue-66923-show-error-for-correct-call.stderr b/src/test/ui/issues/issue-66923-show-error-for-correct-call.stderr index 6a96709cbacdb..d6e39251632ba 100644 --- a/src/test/ui/issues/issue-66923-show-error-for-correct-call.stderr +++ b/src/test/ui/issues/issue-66923-show-error-for-correct-call.stderr @@ -5,6 +5,7 @@ LL | let x2: Vec = x1.into_iter().collect(); | ^^^^^^^ value of type `Vec` cannot be built from `std::iter::Iterator` | = help: the trait `FromIterator<&f64>` is not implemented for `Vec` + = help: the trait `FromIterator` is implemented for `Vec` note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | @@ -18,6 +19,7 @@ LL | let x3 = x1.into_iter().collect::>(); | ^^^^^^^ value of type `Vec` cannot be built from `std::iter::Iterator` | = help: the trait `FromIterator<&f64>` is not implemented for `Vec` + = help: the trait `FromIterator` is implemented for `Vec` note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | diff --git a/src/test/ui/kindck/kindck-copy.stderr b/src/test/ui/kindck/kindck-copy.stderr index e147366a22410..6272c4b702266 100644 --- a/src/test/ui/kindck/kindck-copy.stderr +++ b/src/test/ui/kindck/kindck-copy.stderr @@ -9,7 +9,7 @@ LL | assert_copy::<&'static mut isize>(); - and 10 others + and 6 others note: required by a bound in `assert_copy` --> $DIR/kindck-copy.rs:5:18 | @@ -27,7 +27,7 @@ LL | assert_copy::<&'a mut isize>(); - and 10 others + and 6 others note: required by a bound in `assert_copy` --> $DIR/kindck-copy.rs:5:18 | diff --git a/src/test/ui/lexer/lex-bad-char-literals-6.stderr b/src/test/ui/lexer/lex-bad-char-literals-6.stderr index 4332bdefcb258..0e1851d292cf9 100644 --- a/src/test/ui/lexer/lex-bad-char-literals-6.stderr +++ b/src/test/ui/lexer/lex-bad-char-literals-6.stderr @@ -38,6 +38,12 @@ LL | if x == y {} | ^^ no implementation for `&str == char` | = help: the trait `PartialEq` is not implemented for `&str` + = help: the following implementations were found: + <&'a str as PartialEq> + <&'a str as PartialEq> + <&'b str as PartialEq>> + >> + and 4 others error[E0308]: mismatched types --> $DIR/lex-bad-char-literals-6.rs:15:20 @@ -54,6 +60,12 @@ LL | if x == z {} | ^^ no implementation for `&str == char` | = help: the trait `PartialEq` is not implemented for `&str` + = help: the following implementations were found: + <&'a str as PartialEq> + <&'a str as PartialEq> + <&'b str as PartialEq>> + >> + and 4 others error: aborting due to 6 previous errors diff --git a/src/test/ui/mismatched_types/binops.stderr b/src/test/ui/mismatched_types/binops.stderr index 19e921dd04d73..6e67a7b454529 100644 --- a/src/test/ui/mismatched_types/binops.stderr +++ b/src/test/ui/mismatched_types/binops.stderr @@ -5,6 +5,12 @@ LL | 1 + Some(1); | ^ no implementation for `{integer} + Option<{integer}>` | = help: the trait `Add>` is not implemented for `{integer}` + = help: the following implementations were found: + <&'a f32 as Add> + <&'a f64 as Add> + <&'a i128 as Add> + <&'a i16 as Add> + and 48 others error[E0277]: cannot subtract `Option<{integer}>` from `usize` --> $DIR/binops.rs:3:16 @@ -13,6 +19,12 @@ LL | 2 as usize - Some(1); | ^ no implementation for `usize - Option<{integer}>` | = help: the trait `Sub>` is not implemented for `usize` + = help: the following implementations were found: + <&'a usize as Sub> + <&usize as Sub<&usize>> + > + + and 48 others error[E0277]: cannot multiply `{integer}` by `()` --> $DIR/binops.rs:4:7 @@ -21,6 +33,12 @@ LL | 3 * (); | ^ no implementation for `{integer} * ()` | = help: the trait `Mul<()>` is not implemented for `{integer}` + = help: the following implementations were found: + <&'a f32 as Mul> + <&'a f64 as Mul> + <&'a i128 as Mul> + <&'a i16 as Mul> + and 49 others error[E0277]: cannot divide `{integer}` by `&str` --> $DIR/binops.rs:5:7 @@ -29,6 +47,12 @@ LL | 4 / ""; | ^ no implementation for `{integer} / &str` | = help: the trait `Div<&str>` is not implemented for `{integer}` + = help: the following implementations were found: + <&'a f32 as Div> + <&'a f64 as Div> + <&'a i128 as Div> + <&'a i16 as Div> + and 54 others error[E0277]: can't compare `{integer}` with `String` --> $DIR/binops.rs:6:7 @@ -37,6 +61,12 @@ LL | 5 < String::new(); | ^ no implementation for `{integer} < String` and `{integer} > String` | = help: the trait `PartialOrd` is not implemented for `{integer}` + = help: the following implementations were found: + + + + + and 6 others error[E0277]: can't compare `{integer}` with `Result<{integer}, _>` --> $DIR/binops.rs:7:7 @@ -45,6 +75,12 @@ LL | 6 == Ok(1); | ^^ no implementation for `{integer} == Result<{integer}, _>` | = help: the trait `PartialEq>` is not implemented for `{integer}` + = help: the following implementations were found: + + + + + and 6 others error: aborting due to 6 previous errors diff --git a/src/test/ui/never_type/defaulted-never-note.fallback.stderr b/src/test/ui/never_type/defaulted-never-note.fallback.stderr index b105f03f81cdd..4c8b492247352 100644 --- a/src/test/ui/never_type/defaulted-never-note.fallback.stderr +++ b/src/test/ui/never_type/defaulted-never-note.fallback.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `!: ImplementedForUnitButNotNever` is not satisfie LL | foo(_x); | ^^^ the trait `ImplementedForUnitButNotNever` is not implemented for `!` | - = note: this trait is implemented for `()` + = help: the trait `ImplementedForUnitButNotNever` is implemented for `()` = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 for more information) = help: did you intend to use the type `()` here instead? note: required by a bound in `foo` diff --git a/src/test/ui/never_type/defaulted-never-note.rs b/src/test/ui/never_type/defaulted-never-note.rs index 54f551759cb39..aefc739a0a0b0 100644 --- a/src/test/ui/never_type/defaulted-never-note.rs +++ b/src/test/ui/never_type/defaulted-never-note.rs @@ -30,7 +30,7 @@ fn smeg() { foo(_x); //[fallback]~^ ERROR the trait bound //[fallback]~| NOTE the trait `ImplementedForUnitButNotNever` is not implemented - //[fallback]~| NOTE this trait is implemented for `()` + //[fallback]~| HELP trait `ImplementedForUnitButNotNever` is implemented for `()` //[fallback]~| NOTE this error might have been caused //[fallback]~| HELP did you intend } diff --git a/src/test/ui/never_type/diverging-fallback-no-leak.fallback.stderr b/src/test/ui/never_type/diverging-fallback-no-leak.fallback.stderr index 72cd69380573e..dee2b1d704b86 100644 --- a/src/test/ui/never_type/diverging-fallback-no-leak.fallback.stderr +++ b/src/test/ui/never_type/diverging-fallback-no-leak.fallback.stderr @@ -4,7 +4,9 @@ error[E0277]: the trait bound `!: Test` is not satisfied LL | unconstrained_arg(return); | ^^^^^^^^^^^^^^^^^ the trait `Test` is not implemented for `!` | - = note: this trait is implemented for `()` + = help: the following other types implement trait `Test`: + () + i32 = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 for more information) = help: did you intend to use the type `()` here instead? note: required by a bound in `unconstrained_arg` diff --git a/src/test/ui/never_type/impl_trait_fallback2.stderr b/src/test/ui/never_type/impl_trait_fallback2.stderr index 2f50b9d245900..4a78e73e5f6d5 100644 --- a/src/test/ui/never_type/impl_trait_fallback2.stderr +++ b/src/test/ui/never_type/impl_trait_fallback2.stderr @@ -3,6 +3,8 @@ error[E0277]: the trait bound `(): T` is not satisfied | LL | fn should_ret_unit() -> impl T { | ^^^^^^ the trait `T` is not implemented for `()` + | + = help: the trait `T` is implemented for `i32` error: aborting due to previous error diff --git a/src/test/ui/never_type/issue-13352.stderr b/src/test/ui/never_type/issue-13352.stderr index b98f6c93923b9..12a6d7962f46b 100644 --- a/src/test/ui/never_type/issue-13352.stderr +++ b/src/test/ui/never_type/issue-13352.stderr @@ -5,6 +5,12 @@ LL | 2_usize + (loop {}); | ^ no implementation for `usize + ()` | = help: the trait `Add<()>` is not implemented for `usize` + = help: the following implementations were found: + <&'a usize as Add> + <&usize as Add<&usize>> + > + + and 48 others error: aborting due to previous error diff --git a/src/test/ui/never_type/never-value-fallback-issue-66757.nofallback.stderr b/src/test/ui/never_type/never-value-fallback-issue-66757.nofallback.stderr index a14253e384a3a..e2045591390e1 100644 --- a/src/test/ui/never_type/never-value-fallback-issue-66757.nofallback.stderr +++ b/src/test/ui/never_type/never-value-fallback-issue-66757.nofallback.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `E: From<()>` is not satisfied LL | >::from(never); | ^^^^^^^^^^^^^^^^^^^^ the trait `From<()>` is not implemented for `E` | - = help: the following implementations were found: - > + = help: the trait `From` is implemented for `E` error: aborting due to previous error diff --git a/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr b/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr index ce9a08a15897a..d8bba1509d868 100644 --- a/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr +++ b/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr @@ -5,6 +5,12 @@ LL | x + 100.0 | ^ no implementation for `u8 + {float}` | = help: the trait `Add<{float}>` is not implemented for `u8` + = help: the following implementations were found: + <&'a u8 as Add> + <&u8 as Add<&u8>> + > + + and 48 others error[E0277]: cannot add `&str` to `f64` --> $DIR/not-suggest-float-literal.rs:6:7 @@ -13,6 +19,12 @@ LL | x + "foo" | ^ no implementation for `f64 + &str` | = help: the trait `Add<&str>` is not implemented for `f64` + = help: the following implementations were found: + <&'a f64 as Add> + <&f64 as Add<&f64>> + > + + and 48 others error[E0277]: cannot add `{integer}` to `f64` --> $DIR/not-suggest-float-literal.rs:11:7 @@ -21,6 +33,12 @@ LL | x + y | ^ no implementation for `f64 + {integer}` | = help: the trait `Add<{integer}>` is not implemented for `f64` + = help: the following implementations were found: + <&'a f64 as Add> + <&f64 as Add<&f64>> + > + + and 48 others error[E0277]: cannot subtract `{float}` from `u8` --> $DIR/not-suggest-float-literal.rs:15:7 @@ -29,6 +47,12 @@ LL | x - 100.0 | ^ no implementation for `u8 - {float}` | = help: the trait `Sub<{float}>` is not implemented for `u8` + = help: the following implementations were found: + <&'a u8 as Sub> + <&u8 as Sub<&u8>> + > + + and 48 others error[E0277]: cannot subtract `&str` from `f64` --> $DIR/not-suggest-float-literal.rs:19:7 @@ -37,6 +61,12 @@ LL | x - "foo" | ^ no implementation for `f64 - &str` | = help: the trait `Sub<&str>` is not implemented for `f64` + = help: the following implementations were found: + <&'a f64 as Sub> + <&f64 as Sub<&f64>> + > + + and 48 others error[E0277]: cannot subtract `{integer}` from `f64` --> $DIR/not-suggest-float-literal.rs:24:7 @@ -45,6 +75,12 @@ LL | x - y | ^ no implementation for `f64 - {integer}` | = help: the trait `Sub<{integer}>` is not implemented for `f64` + = help: the following implementations were found: + <&'a f64 as Sub> + <&f64 as Sub<&f64>> + > + + and 48 others error[E0277]: cannot multiply `u8` by `{float}` --> $DIR/not-suggest-float-literal.rs:28:7 @@ -53,6 +89,12 @@ LL | x * 100.0 | ^ no implementation for `u8 * {float}` | = help: the trait `Mul<{float}>` is not implemented for `u8` + = help: the following implementations were found: + <&'a u8 as Mul> + <&u8 as Mul<&u8>> + > + + and 49 others error[E0277]: cannot multiply `f64` by `&str` --> $DIR/not-suggest-float-literal.rs:32:7 @@ -61,6 +103,12 @@ LL | x * "foo" | ^ no implementation for `f64 * &str` | = help: the trait `Mul<&str>` is not implemented for `f64` + = help: the following implementations were found: + <&'a f64 as Mul> + <&f64 as Mul<&f64>> + > + + and 49 others error[E0277]: cannot multiply `f64` by `{integer}` --> $DIR/not-suggest-float-literal.rs:37:7 @@ -69,6 +117,12 @@ LL | x * y | ^ no implementation for `f64 * {integer}` | = help: the trait `Mul<{integer}>` is not implemented for `f64` + = help: the following implementations were found: + <&'a f64 as Mul> + <&f64 as Mul<&f64>> + > + + and 49 others error[E0277]: cannot divide `u8` by `{float}` --> $DIR/not-suggest-float-literal.rs:41:7 @@ -77,6 +131,12 @@ LL | x / 100.0 | ^ no implementation for `u8 / {float}` | = help: the trait `Div<{float}>` is not implemented for `u8` + = help: the following implementations were found: + <&'a u8 as Div> + <&u8 as Div<&u8>> + > + > + and 54 others error[E0277]: cannot divide `f64` by `&str` --> $DIR/not-suggest-float-literal.rs:45:7 @@ -85,6 +145,12 @@ LL | x / "foo" | ^ no implementation for `f64 / &str` | = help: the trait `Div<&str>` is not implemented for `f64` + = help: the following implementations were found: + <&'a f64 as Div> + <&f64 as Div<&f64>> + > + + and 54 others error[E0277]: cannot divide `f64` by `{integer}` --> $DIR/not-suggest-float-literal.rs:50:7 @@ -93,6 +159,12 @@ LL | x / y | ^ no implementation for `f64 / {integer}` | = help: the trait `Div<{integer}>` is not implemented for `f64` + = help: the following implementations were found: + <&'a f64 as Div> + <&f64 as Div<&f64>> + > + + and 54 others error: aborting due to 12 previous errors diff --git a/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr b/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr index eb0be785061e6..b7591dfca99b3 100644 --- a/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr +++ b/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr @@ -5,6 +5,12 @@ LL | x + 100 | ^ no implementation for `f32 + {integer}` | = help: the trait `Add<{integer}>` is not implemented for `f32` + = help: the following implementations were found: + <&'a f32 as Add> + <&f32 as Add<&f32>> + > + + and 48 others help: consider using a floating-point literal by writing it with `.0` | LL | x + 100.0 @@ -17,6 +23,12 @@ LL | x + 100 | ^ no implementation for `f64 + {integer}` | = help: the trait `Add<{integer}>` is not implemented for `f64` + = help: the following implementations were found: + <&'a f64 as Add> + <&f64 as Add<&f64>> + > + + and 48 others help: consider using a floating-point literal by writing it with `.0` | LL | x + 100.0 @@ -29,6 +41,12 @@ LL | x - 100 | ^ no implementation for `f32 - {integer}` | = help: the trait `Sub<{integer}>` is not implemented for `f32` + = help: the following implementations were found: + <&'a f32 as Sub> + <&f32 as Sub<&f32>> + > + + and 48 others help: consider using a floating-point literal by writing it with `.0` | LL | x - 100.0 @@ -41,6 +59,12 @@ LL | x - 100 | ^ no implementation for `f64 - {integer}` | = help: the trait `Sub<{integer}>` is not implemented for `f64` + = help: the following implementations were found: + <&'a f64 as Sub> + <&f64 as Sub<&f64>> + > + + and 48 others help: consider using a floating-point literal by writing it with `.0` | LL | x - 100.0 @@ -53,6 +77,12 @@ LL | x * 100 | ^ no implementation for `f32 * {integer}` | = help: the trait `Mul<{integer}>` is not implemented for `f32` + = help: the following implementations were found: + <&'a f32 as Mul> + <&f32 as Mul<&f32>> + > + + and 49 others help: consider using a floating-point literal by writing it with `.0` | LL | x * 100.0 @@ -65,6 +95,12 @@ LL | x * 100 | ^ no implementation for `f64 * {integer}` | = help: the trait `Mul<{integer}>` is not implemented for `f64` + = help: the following implementations were found: + <&'a f64 as Mul> + <&f64 as Mul<&f64>> + > + + and 49 others help: consider using a floating-point literal by writing it with `.0` | LL | x * 100.0 @@ -77,6 +113,12 @@ LL | x / 100 | ^ no implementation for `f32 / {integer}` | = help: the trait `Div<{integer}>` is not implemented for `f32` + = help: the following implementations were found: + <&'a f32 as Div> + <&f32 as Div<&f32>> + > + + and 54 others help: consider using a floating-point literal by writing it with `.0` | LL | x / 100.0 @@ -89,6 +131,12 @@ LL | x / 100 | ^ no implementation for `f64 / {integer}` | = help: the trait `Div<{integer}>` is not implemented for `f64` + = help: the following implementations were found: + <&'a f64 as Div> + <&f64 as Div<&f64>> + > + + and 54 others help: consider using a floating-point literal by writing it with `.0` | LL | x / 100.0 diff --git a/src/test/ui/on-unimplemented/impl-substs.stderr b/src/test/ui/on-unimplemented/impl-substs.stderr index db66ab0bfaec1..a0fad0acd0b5c 100644 --- a/src/test/ui/on-unimplemented/impl-substs.stderr +++ b/src/test/ui/on-unimplemented/impl-substs.stderr @@ -7,6 +7,7 @@ LL | Foo::::foo((1i32, 1i32, 1i32)); | required by a bound introduced by this call | = help: the trait `Foo` is not implemented for `(i32, i32, i32)` + = help: the trait `Foo` is implemented for `(A, B, C)` error: aborting due to previous error diff --git a/src/test/ui/on-unimplemented/multiple-impls.stderr b/src/test/ui/on-unimplemented/multiple-impls.stderr index 76aa128e242f9..be29d31d97b8e 100644 --- a/src/test/ui/on-unimplemented/multiple-impls.stderr +++ b/src/test/ui/on-unimplemented/multiple-impls.stderr @@ -7,6 +7,9 @@ LL | Index::index(&[] as &[i32], 2u32); | required by a bound introduced by this call | = help: the trait `Index` is not implemented for `[i32]` + = help: the following implementations were found: + <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:36:18 @@ -17,6 +20,9 @@ LL | Index::index(&[] as &[i32], Foo(2u32)); | required by a bound introduced by this call | = help: the trait `Index>` is not implemented for `[i32]` + = help: the following implementations were found: + <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:39:18 @@ -27,6 +33,9 @@ LL | Index::index(&[] as &[i32], Bar(2u32)); | required by a bound introduced by this call | = help: the trait `Index>` is not implemented for `[i32]` + = help: the following implementations were found: + <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index` is not satisfied --> $DIR/multiple-impls.rs:33:5 @@ -35,6 +44,9 @@ LL | Index::index(&[] as &[i32], 2u32); | ^^^^^^^^^^^^ trait message | = help: the trait `Index` is not implemented for `[i32]` + = help: the following implementations were found: + <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:36:5 @@ -43,6 +55,9 @@ LL | Index::index(&[] as &[i32], Foo(2u32)); | ^^^^^^^^^^^^ on impl for Foo | = help: the trait `Index>` is not implemented for `[i32]` + = help: the following implementations were found: + <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:39:5 @@ -51,6 +66,9 @@ LL | Index::index(&[] as &[i32], Bar(2u32)); | ^^^^^^^^^^^^ on impl for Bar | = help: the trait `Index>` is not implemented for `[i32]` + = help: the following implementations were found: + <[i32] as Index>> + <[i32] as Index>> error: aborting due to 6 previous errors diff --git a/src/test/ui/on-unimplemented/on-impl.stderr b/src/test/ui/on-unimplemented/on-impl.stderr index 940763fae51b8..769a3d77a5726 100644 --- a/src/test/ui/on-unimplemented/on-impl.stderr +++ b/src/test/ui/on-unimplemented/on-impl.stderr @@ -7,6 +7,7 @@ LL | Index::::index(&[1, 2, 3] as &[i32], 2u32); | required by a bound introduced by this call | = help: the trait `Index` is not implemented for `[i32]` + = help: the trait `Index` is implemented for `[i32]` error[E0277]: the trait bound `[i32]: Index` is not satisfied --> $DIR/on-impl.rs:22:5 @@ -15,6 +16,7 @@ LL | Index::::index(&[1, 2, 3] as &[i32], 2u32); | ^^^^^^^^^^^^^^^^^^^ a usize is required to index into a slice | = help: the trait `Index` is not implemented for `[i32]` + = help: the trait `Index` is implemented for `[i32]` error: aborting due to 2 previous errors diff --git a/src/test/ui/on-unimplemented/slice-index.stderr b/src/test/ui/on-unimplemented/slice-index.stderr index 44b8b0d8d8444..6dc27b5d4cc56 100644 --- a/src/test/ui/on-unimplemented/slice-index.stderr +++ b/src/test/ui/on-unimplemented/slice-index.stderr @@ -5,6 +5,7 @@ LL | x[1i32]; | ^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[i32]>` is not implemented for `i32` + = help: the trait `SliceIndex<[T]>` is implemented for `usize` = note: required because of the requirements on the impl of `Index` for `[i32]` error[E0277]: the type `[i32]` cannot be indexed by `RangeTo` @@ -14,6 +15,9 @@ LL | x[..1i32]; | ^^^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[i32]>` is not implemented for `RangeTo` + = help: the following implementations were found: + as SliceIndex<[T]>> + as SliceIndex> = note: required because of the requirements on the impl of `Index>` for `[i32]` error: aborting due to 2 previous errors diff --git a/src/test/ui/range/range-1.stderr b/src/test/ui/range/range-1.stderr index 2ce4e1553d28e..0bbed8704243f 100644 --- a/src/test/ui/range/range-1.stderr +++ b/src/test/ui/range/range-1.stderr @@ -10,6 +10,16 @@ error[E0277]: the trait bound `bool: Step` is not satisfied LL | for i in false..true {} | ^^^^^^^^^^^ the trait `Step` is not implemented for `bool` | + = help: the following other types implement trait `Step`: + char + i128 + i16 + i32 + i64 + i8 + isize + u128 + and 5 others = note: required because of the requirements on the impl of `Iterator` for `std::ops::Range` = note: required because of the requirements on the impl of `IntoIterator` for `std::ops::Range` diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr index f8eaf61d7d7ec..d87eceb1c9a7b 100644 --- a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr @@ -9,6 +9,10 @@ LL | | } | |_^ `main` can only return types that implement `Termination` | = help: the trait `Termination` is not implemented for `Result` + = help: the following implementations were found: + as Termination> + as Termination> + as Termination> note: required by a bound in `assert_test_result` --> $SRC_DIR/test/src/lib.rs:LL:COL | diff --git a/src/test/ui/span/multiline-span-simple.stderr b/src/test/ui/span/multiline-span-simple.stderr index 13ef0d1820881..1542832f0129c 100644 --- a/src/test/ui/span/multiline-span-simple.stderr +++ b/src/test/ui/span/multiline-span-simple.stderr @@ -5,6 +5,12 @@ LL | foo(1 as u32 + | ^ no implementation for `u32 + ()` | = help: the trait `Add<()>` is not implemented for `u32` + = help: the following implementations were found: + <&'a u32 as Add> + <&u32 as Add<&u32>> + > + + and 48 others error: aborting due to previous error diff --git a/src/test/ui/specialization/default-associated-type-bound-1.stderr b/src/test/ui/specialization/default-associated-type-bound-1.stderr index f88acfb2e793e..af9f2f7c2e9a6 100644 --- a/src/test/ui/specialization/default-associated-type-bound-1.stderr +++ b/src/test/ui/specialization/default-associated-type-bound-1.stderr @@ -14,8 +14,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied LL | default type U = str; | ^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - + = help: the trait `Clone` is implemented for `String` note: required by a bound in `X::U` --> $DIR/default-associated-type-bound-1.rs:8:13 | diff --git a/src/test/ui/str/str-idx.stderr b/src/test/ui/str/str-idx.stderr index 9ab409bbdcdf8..45450788b9cbd 100644 --- a/src/test/ui/str/str-idx.stderr +++ b/src/test/ui/str/str-idx.stderr @@ -7,6 +7,7 @@ LL | let _: u8 = s[4]; = help: the trait `SliceIndex` is not implemented for `{integer}` = note: you can use `.chars().nth()` or `.bytes().nth()` for more information, see chapter 8 in The Book: + = help: the trait `SliceIndex<[T]>` is implemented for `usize` = note: required because of the requirements on the impl of `Index<{integer}>` for `str` error[E0277]: the type `str` cannot be indexed by `{integer}` @@ -20,6 +21,7 @@ LL | let _ = s.get(4); = help: the trait `SliceIndex` is not implemented for `{integer}` = note: you can use `.chars().nth()` or `.bytes().nth()` for more information, see chapter 8 in The Book: + = help: the trait `SliceIndex<[T]>` is implemented for `usize` note: required by a bound in `core::str::::get` --> $SRC_DIR/core/src/str/mod.rs:LL:COL | @@ -37,6 +39,7 @@ LL | let _ = s.get_unchecked(4); = help: the trait `SliceIndex` is not implemented for `{integer}` = note: you can use `.chars().nth()` or `.bytes().nth()` for more information, see chapter 8 in The Book: + = help: the trait `SliceIndex<[T]>` is implemented for `usize` note: required by a bound in `core::str::::get_unchecked` --> $SRC_DIR/core/src/str/mod.rs:LL:COL | diff --git a/src/test/ui/str/str-mut-idx.stderr b/src/test/ui/str/str-mut-idx.stderr index 5956e363b0c09..9ae085630279e 100644 --- a/src/test/ui/str/str-mut-idx.stderr +++ b/src/test/ui/str/str-mut-idx.stderr @@ -31,6 +31,7 @@ LL | s[1usize] = bot(); | ^^^^^^^^^ string indices are ranges of `usize` | = help: the trait `SliceIndex` is not implemented for `usize` + = help: the trait `SliceIndex<[T]>` is implemented for `usize` = note: required because of the requirements on the impl of `Index` for `str` error[E0277]: the type `str` cannot be indexed by `{integer}` @@ -44,6 +45,7 @@ LL | s.get_mut(1); = help: the trait `SliceIndex` is not implemented for `{integer}` = note: you can use `.chars().nth()` or `.bytes().nth()` for more information, see chapter 8 in The Book: + = help: the trait `SliceIndex<[T]>` is implemented for `usize` note: required by a bound in `core::str::::get_mut` --> $SRC_DIR/core/src/str/mod.rs:LL:COL | @@ -61,6 +63,7 @@ LL | s.get_unchecked_mut(1); = help: the trait `SliceIndex` is not implemented for `{integer}` = note: you can use `.chars().nth()` or `.bytes().nth()` for more information, see chapter 8 in The Book: + = help: the trait `SliceIndex<[T]>` is implemented for `usize` note: required by a bound in `core::str::::get_unchecked_mut` --> $SRC_DIR/core/src/str/mod.rs:LL:COL | diff --git a/src/test/ui/suggestions/imm-ref-trait-object-literal-bound-regions.stderr b/src/test/ui/suggestions/imm-ref-trait-object-literal-bound-regions.stderr index 64a62524653b7..0783f04dc9bd3 100644 --- a/src/test/ui/suggestions/imm-ref-trait-object-literal-bound-regions.stderr +++ b/src/test/ui/suggestions/imm-ref-trait-object-literal-bound-regions.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `for<'b> &'b S: Trait` is not satisfied LL | foo::(s); | ^^^^^^^^ the trait `for<'b> Trait` is not implemented for `&'b S` | - = help: the following implementations were found: - <&'a mut S as Trait> + = help: the trait `Trait` is implemented for `&'a mut S` note: required by a bound in `foo` --> $DIR/imm-ref-trait-object-literal-bound-regions.rs:11:20 | diff --git a/src/test/ui/suggestions/imm-ref-trait-object-literal.stderr b/src/test/ui/suggestions/imm-ref-trait-object-literal.stderr index 001af27b2484e..5f3f62a7b7570 100644 --- a/src/test/ui/suggestions/imm-ref-trait-object-literal.stderr +++ b/src/test/ui/suggestions/imm-ref-trait-object-literal.stderr @@ -6,8 +6,7 @@ LL | foo(&s); | | | required by a bound introduced by this call | - = help: the following implementations were found: - <&'a mut S as Trait> + = help: the trait `Trait` is implemented for `&'a mut S` note: required by a bound in `foo` --> $DIR/imm-ref-trait-object-literal.rs:7:11 | diff --git a/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr b/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr index ba6967e78e163..0de765588e5b7 100644 --- a/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr +++ b/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr @@ -15,6 +15,8 @@ LL | | 5; LL | | LL | | } | |_^ the trait `Bar` is not implemented for `()` + | + = help: the trait `Bar` is implemented for `u8` error: aborting due to 2 previous errors diff --git a/src/test/ui/suggestions/into-str.stderr b/src/test/ui/suggestions/into-str.stderr index 470c0bfcf73e5..4bdea05b06b8d 100644 --- a/src/test/ui/suggestions/into-str.stderr +++ b/src/test/ui/suggestions/into-str.stderr @@ -12,7 +12,6 @@ LL | foo(String::new()); > > >> - and 2 others = note: required because of the requirements on the impl of `Into<&str>` for `String` note: required by a bound in `foo` --> $DIR/into-str.rs:1:31 diff --git a/src/test/ui/suggestions/issue-84973-negative.stderr b/src/test/ui/suggestions/issue-84973-negative.stderr index bacab64e2642c..15559d4ae2c2f 100644 --- a/src/test/ui/suggestions/issue-84973-negative.stderr +++ b/src/test/ui/suggestions/issue-84973-negative.stderr @@ -6,8 +6,7 @@ LL | bar(a); | | | required by a bound introduced by this call | - = help: the following implementations were found: - <&f32 as Tr> + = help: the trait `Tr` is implemented for `&f32` note: required by a bound in `bar` --> $DIR/issue-84973-negative.rs:5:11 | diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-1.stderr b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-1.stderr index 907a1bd75a064..bfbbe7fd25702 100644 --- a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-1.stderr +++ b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-1.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied LL | f::>(); | ^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - + = help: the trait `Clone` is implemented for `String` note: required by a bound in `f` --> $DIR/check-trait-object-bounds-1.rs:7:9 | diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-4.stderr b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-4.stderr index b27f8d791a50f..3ca36d5d2ff19 100644 --- a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-4.stderr +++ b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-4.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied LL | f::>(); | ^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - + = help: the trait `Clone` is implemented for `String` note: required by a bound in `f` --> $DIR/check-trait-object-bounds-4.rs:10:9 | diff --git a/src/test/ui/traits/bound/same-crate-name.rs b/src/test/ui/traits/bound/same-crate-name.rs index 1012edb109336..8d646a414599c 100644 --- a/src/test/ui/traits/bound/same-crate-name.rs +++ b/src/test/ui/traits/bound/same-crate-name.rs @@ -50,6 +50,6 @@ fn main() { // impls for the correct trait where the path is not misleading. a::try_foo(other_variant_implements_correct_trait); //~^ ERROR E0277 - //~| the following implementations were found: + //~| the trait `main::a::Bar` is implemented for `ImplementsTraitForUsize` } } diff --git a/src/test/ui/traits/bound/same-crate-name.stderr b/src/test/ui/traits/bound/same-crate-name.stderr index 81e5589d6eb35..ef39a70066db6 100644 --- a/src/test/ui/traits/bound/same-crate-name.stderr +++ b/src/test/ui/traits/bound/same-crate-name.stderr @@ -12,6 +12,7 @@ help: trait impl with same name found LL | impl Bar for Foo {} | ^^^^^^^^^^^^^^^^^^^ = note: perhaps two different versions of crate `crate_a2` are being used? + = help: the trait `main::a::Bar` is implemented for `ImplementsTraitForUsize` note: required by a bound in `try_foo` --> $DIR/auxiliary/crate_a1.rs:3:24 | @@ -26,6 +27,7 @@ LL | a::try_foo(implements_no_traits); | | | required by a bound introduced by this call | + = help: the trait `main::a::Bar` is implemented for `ImplementsTraitForUsize` note: required by a bound in `try_foo` --> $DIR/auxiliary/crate_a1.rs:3:24 | @@ -46,6 +48,7 @@ help: trait impl with same name found LL | impl Bar for ImplementsWrongTraitConditionally {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: perhaps two different versions of crate `crate_a2` are being used? + = help: the trait `main::a::Bar` is implemented for `ImplementsTraitForUsize` note: required by a bound in `try_foo` --> $DIR/auxiliary/crate_a1.rs:3:24 | @@ -60,8 +63,7 @@ LL | a::try_foo(other_variant_implements_correct_trait); | | | required by a bound introduced by this call | - = help: the following implementations were found: - as main::a::Bar> + = help: the trait `main::a::Bar` is implemented for `ImplementsTraitForUsize` note: required by a bound in `try_foo` --> $DIR/auxiliary/crate_a1.rs:3:24 | diff --git a/src/test/ui/traits/coercion-generic-bad.stderr b/src/test/ui/traits/coercion-generic-bad.stderr index f367d396da0c2..b213ee635df59 100644 --- a/src/test/ui/traits/coercion-generic-bad.stderr +++ b/src/test/ui/traits/coercion-generic-bad.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `Struct: Trait` is not satisfied LL | let s: Box> = Box::new(Struct { person: "Fred" }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `Struct` | - = help: the following implementations were found: - > + = help: the trait `Trait<&'static str>` is implemented for `Struct` = note: required for the cast to the object type `dyn Trait` error: aborting due to previous error diff --git a/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr b/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr index 2bff84363e9e5..3645ad03cb9bb 100644 --- a/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr +++ b/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr @@ -3,6 +3,8 @@ error[E0277]: the trait bound `dyn CompareToInts: CompareTo` is not satisfi | LL | c.same_as(22) | ^^^^^^^ the trait `CompareTo` is not implemented for `dyn CompareToInts` + | + = help: the trait `CompareTo` is implemented for `i64` error[E0277]: the trait bound `C: CompareTo` is not satisfied --> $DIR/repeated-supertrait-ambig.rs:30:7 @@ -20,6 +22,8 @@ error[E0277]: the trait bound `dyn CompareToInts: CompareTo` is not satisfi | LL | ::same_as(c, 22) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `CompareTo` is not implemented for `dyn CompareToInts` + | + = help: the trait `CompareTo` is implemented for `i64` error[E0277]: the trait bound `C: CompareTo` is not satisfied --> $DIR/repeated-supertrait-ambig.rs:38:5 diff --git a/src/test/ui/traits/issue-91594.stderr b/src/test/ui/traits/issue-91594.stderr index 10298a0c7037a..f2b3de13beb9e 100644 --- a/src/test/ui/traits/issue-91594.stderr +++ b/src/test/ui/traits/issue-91594.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `Foo: HasComponent<()>` is not satisfied LL | impl HasComponent<>::Interface> for Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HasComponent<()>` is not implemented for `Foo` | - = help: the following implementations were found: - >::Interface>> + = help: the trait `HasComponent<>::Interface>` is implemented for `Foo` note: required because of the requirements on the impl of `Component` for `Foo` --> $DIR/issue-91594.rs:13:27 | diff --git a/src/test/ui/traits/map-types.stderr b/src/test/ui/traits/map-types.stderr index 71006e1f4e2d8..37bc5c6badc41 100644 --- a/src/test/ui/traits/map-types.stderr +++ b/src/test/ui/traits/map-types.stderr @@ -4,6 +4,7 @@ error[E0277]: the trait bound `Box>: Map` is LL | let y: Box> = Box::new(x); | ^^^^^^^^^^^ the trait `Map` is not implemented for `Box>` | + = help: the trait `Map` is implemented for `HashMap` = note: required for the cast to the object type `dyn Map` error: aborting due to previous error diff --git a/src/test/ui/traits/reservation-impl/no-use.stderr b/src/test/ui/traits/reservation-impl/no-use.stderr index 3d5bf3448bd5d..cefb2a8792f17 100644 --- a/src/test/ui/traits/reservation-impl/no-use.stderr +++ b/src/test/ui/traits/reservation-impl/no-use.stderr @@ -6,8 +6,7 @@ LL | <() as MyTrait>::foo(&()); | | | required by a bound introduced by this call | - = help: the following implementations were found: - <() as MyTrait> + = help: the trait `MyTrait` is implemented for `()` error: aborting due to previous error diff --git a/src/test/ui/traits/suggest-deferences/issue-62530.stderr b/src/test/ui/traits/suggest-deferences/issue-62530.stderr index 299219431ef11..b77af7ddf4746 100644 --- a/src/test/ui/traits/suggest-deferences/issue-62530.stderr +++ b/src/test/ui/traits/suggest-deferences/issue-62530.stderr @@ -8,8 +8,6 @@ LL | takes_type_parameter(&string); // Error | | help: consider adding dereference here: `&*string` | required by a bound introduced by this call | - = help: the following implementations were found: - <&str as SomeTrait> note: required by a bound in `takes_type_parameter` --> $DIR/issue-62530.rs:4:44 | diff --git a/src/test/ui/traits/suggest-deferences/multiple-1.stderr b/src/test/ui/traits/suggest-deferences/multiple-1.stderr index 040fbb3e3e699..6e12321c2333b 100644 --- a/src/test/ui/traits/suggest-deferences/multiple-1.stderr +++ b/src/test/ui/traits/suggest-deferences/multiple-1.stderr @@ -6,6 +6,7 @@ LL | foo(&mut baz); | | | required by a bound introduced by this call | + = help: the trait `Happy` is implemented for `&mut LDM` note: required by a bound in `foo` --> $DIR/multiple-1.rs:45:26 | diff --git a/src/test/ui/try-block/try-block-bad-type.stderr b/src/test/ui/try-block/try-block-bad-type.stderr index cf3a07808de68..f9906713f8427 100644 --- a/src/test/ui/try-block/try-block-bad-type.stderr +++ b/src/test/ui/try-block/try-block-bad-type.stderr @@ -5,8 +5,7 @@ LL | Err("")?; | ^ the trait `From<&str>` is not implemented for `TryFromSliceError` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait - = help: the following implementations were found: - > + = help: the trait `From` is implemented for `TryFromSliceError` = note: required because of the requirements on the impl of `FromResidual>` for `Result` error[E0271]: type mismatch resolving ` as Try>::Output == &str` diff --git a/src/test/ui/try-trait/bad-interconversion.stderr b/src/test/ui/try-trait/bad-interconversion.stderr index 171051156b7f2..fc2692a9a9313 100644 --- a/src/test/ui/try-trait/bad-interconversion.stderr +++ b/src/test/ui/try-trait/bad-interconversion.stderr @@ -12,7 +12,7 @@ LL | Ok(Err(123_i32)?) > > > - and 71 others + and 67 others = note: required because of the requirements on the impl of `FromResidual>` for `Result` error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result` @@ -27,6 +27,7 @@ LL | | } | |_- this function returns a `Result` | = help: the trait `FromResidual>` is not implemented for `Result` + = help: the trait `FromResidual>` is implemented for `Result` error[E0277]: the `?` operator can only be used on `Result`s in a function that returns `Result` --> $DIR/bad-interconversion.rs:17:31 @@ -39,6 +40,7 @@ LL | | } | |_- this function returns a `Result` | = help: the trait `FromResidual>` is not implemented for `Result` + = help: the trait `FromResidual>` is implemented for `Result` error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option` --> $DIR/bad-interconversion.rs:22:22 @@ -51,6 +53,7 @@ LL | | } | |_- this function returns an `Option` | = help: the trait `FromResidual>` is not implemented for `Option` + = help: the trait `FromResidual` is implemented for `Option` error[E0277]: the `?` operator can only be used on `Option`s in a function that returns `Option` --> $DIR/bad-interconversion.rs:27:33 @@ -63,6 +66,7 @@ LL | | } | |_- this function returns an `Option` | = help: the trait `FromResidual>` is not implemented for `Option` + = help: the trait `FromResidual` is implemented for `Option` error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow` --> $DIR/bad-interconversion.rs:32:39 @@ -75,6 +79,7 @@ LL | | } | |_- this function returns a `ControlFlow` | = help: the trait `FromResidual>` is not implemented for `ControlFlow` + = help: the trait `FromResidual` is implemented for `ControlFlow` error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow` --> $DIR/bad-interconversion.rs:37:12 @@ -88,6 +93,7 @@ LL | | } | |_- this function returns a `ControlFlow` | = help: the trait `FromResidual>` is not implemented for `ControlFlow` + = help: the trait `FromResidual` is implemented for `ControlFlow` error[E0277]: the `?` operator in a function that returns `ControlFlow` can only be used on other `ControlFlow`s (with the same Break type) --> $DIR/bad-interconversion.rs:43:29 @@ -102,6 +108,7 @@ LL | | } | = help: the trait `FromResidual>` is not implemented for `ControlFlow` = note: unlike `Result`, there's no `From`-conversion performed for `ControlFlow` + = help: the trait `FromResidual` is implemented for `ControlFlow` error: aborting due to 8 previous errors diff --git a/src/test/ui/try-trait/option-to-result.stderr b/src/test/ui/try-trait/option-to-result.stderr index aadfbf61f28f8..b0e4de8cb4bf5 100644 --- a/src/test/ui/try-trait/option-to-result.stderr +++ b/src/test/ui/try-trait/option-to-result.stderr @@ -10,6 +10,7 @@ LL | | } | |_- this function returns a `Result` | = help: the trait `FromResidual>` is not implemented for `Result<(), ()>` + = help: the trait `FromResidual>` is implemented for `Result` error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option` --> $DIR/option-to-result.rs:11:6 @@ -23,6 +24,7 @@ LL | | } | |_- this function returns an `Option` | = help: the trait `FromResidual>` is not implemented for `Option` + = help: the trait `FromResidual` is implemented for `Option` error: aborting due to 2 previous errors diff --git a/src/test/ui/try-trait/try-on-option.stderr b/src/test/ui/try-trait/try-on-option.stderr index 24db9f5243703..7b2a9a16f900b 100644 --- a/src/test/ui/try-trait/try-on-option.stderr +++ b/src/test/ui/try-trait/try-on-option.stderr @@ -10,6 +10,7 @@ LL | | } | |_- this function returns a `Result` | = help: the trait `FromResidual>` is not implemented for `Result` + = help: the trait `FromResidual>` is implemented for `Result` error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option.rs:11:6 diff --git a/src/test/ui/type-alias-impl-trait/issue-60371.stderr b/src/test/ui/type-alias-impl-trait/issue-60371.stderr index 5fec078956bfc..d0c04371bd793 100644 --- a/src/test/ui/type-alias-impl-trait/issue-60371.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-60371.stderr @@ -13,8 +13,7 @@ error[E0277]: the trait bound `(): Bug` is not satisfied LL | const FUN: fn() -> Self::Item = || (); | ^^ the trait `Bug` is not implemented for `()` | - = help: the following implementations were found: - <&() as Bug> + = help: the trait `Bug` is implemented for `&()` error: aborting due to 2 previous errors diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr b/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr index eb72e88769100..0df2b57d373b6 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `(): Foo` is not satisfied LL | fn foo() -> impl Foo { | ^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()` | - = help: the following implementations were found: - <() as Foo<()>> + = help: the trait `Foo<()>` is implemented for `()` error[E0277]: the trait bound `(): Foo` is not satisfied --> $DIR/nested-tait-inference.rs:12:28 @@ -19,8 +18,7 @@ LL | | () LL | | } | |_^ the trait `Foo` is not implemented for `()` | - = help: the following implementations were found: - <() as Foo<()>> + = help: the trait `Foo<()>` is implemented for `()` error: aborting due to 2 previous errors diff --git a/src/test/ui/type-alias-impl-trait/self-referential-2.stderr b/src/test/ui/type-alias-impl-trait/self-referential-2.stderr index 6997676260dd6..b93ded6a7d3e1 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential-2.stderr +++ b/src/test/ui/type-alias-impl-trait/self-referential-2.stderr @@ -5,6 +5,12 @@ LL | 42_i32 | ^^^^^^ no implementation for `i32 == Foo` | = help: the trait `PartialEq` is not implemented for `i32` + = help: the following implementations were found: + + + + + and 6 others error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/self-referential-4.stderr b/src/test/ui/type-alias-impl-trait/self-referential-4.stderr index 4a6ee2f9279d1..23ca689019634 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential-4.stderr +++ b/src/test/ui/type-alias-impl-trait/self-referential-4.stderr @@ -5,6 +5,12 @@ LL | i | ^ no implementation for `&i32 == Bar<'b, 'static>` | = help: the trait `PartialEq>` is not implemented for `&i32` + = help: the following implementations were found: + + + + + and 6 others error[E0277]: can't compare `&i32` with `Foo<'static, 'b>` --> $DIR/self-referential-4.rs:12:5 @@ -13,6 +19,12 @@ LL | i | ^ no implementation for `&i32 == Foo<'static, 'b>` | = help: the trait `PartialEq>` is not implemented for `&i32` + = help: the following implementations were found: + + + + + and 6 others error[E0277]: can't compare `&i32` with `Moo<'static, 'a>` --> $DIR/self-referential-4.rs:18:5 @@ -21,6 +33,12 @@ LL | i | ^ no implementation for `&i32 == Moo<'static, 'a>` | = help: the trait `PartialEq>` is not implemented for `&i32` + = help: the following implementations were found: + + + + + and 6 others error: aborting due to 3 previous errors diff --git a/src/test/ui/type-alias-impl-trait/self-referential.stderr b/src/test/ui/type-alias-impl-trait/self-referential.stderr index 0626e6be0d5a5..4384bc9b98a7c 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential.stderr +++ b/src/test/ui/type-alias-impl-trait/self-referential.stderr @@ -5,6 +5,12 @@ LL | i | ^ no implementation for `&i32 == Bar<'b, 'a>` | = help: the trait `PartialEq>` is not implemented for `&i32` + = help: the following implementations were found: + + + + + and 6 others error[E0277]: can't compare `&i32` with `(i32, &i32)` --> $DIR/self-referential.rs:12:10 @@ -13,6 +19,12 @@ LL | (42, i) | ^ no implementation for `&i32 == (i32, &i32)` | = help: the trait `PartialEq<(i32, &i32)>` is not implemented for `&i32` + = help: the following implementations were found: + + + + + and 6 others error[E0277]: can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})` --> $DIR/self-referential.rs:18:10 @@ -21,6 +33,12 @@ LL | (42, i) | ^ no implementation for `&i32 == (i32, Moo<'b, 'a>::{opaque#0})` | = help: the trait `PartialEq<(i32, Moo<'b, 'a>::{opaque#0})>` is not implemented for `&i32` + = help: the following implementations were found: + + + + + and 6 others error: aborting due to 3 previous errors diff --git a/src/test/ui/type/type-check-defaults.stderr b/src/test/ui/type/type-check-defaults.stderr index 2a61547997b63..80ff068ff309a 100644 --- a/src/test/ui/type/type-check-defaults.stderr +++ b/src/test/ui/type/type-check-defaults.stderr @@ -65,6 +65,12 @@ LL | trait ProjectionPred> where T::Item : Add {} | ^^^^^^^ no implementation for `i32 + u8` | = help: the trait `Add` is not implemented for `i32` + = help: the following implementations were found: + <&'a i32 as Add> + <&i32 as Add<&i32>> + > + + and 48 others error: aborting due to 7 previous errors diff --git a/src/test/ui/typeck/issue-81293.stderr b/src/test/ui/typeck/issue-81293.stderr index c545a563b0d0a..0a5ec56e91512 100644 --- a/src/test/ui/typeck/issue-81293.stderr +++ b/src/test/ui/typeck/issue-81293.stderr @@ -20,6 +20,12 @@ LL | a = c + b * 5; | ^ no implementation for `usize + u16` | = help: the trait `Add` is not implemented for `usize` + = help: the following implementations were found: + <&'a usize as Add> + <&usize as Add<&usize>> + > + + and 48 others error: aborting due to 3 previous errors diff --git a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr index d0bc432a1cd18..c769a0df7c891 100644 --- a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr +++ b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr @@ -5,6 +5,12 @@ LL | >::add(1, 2); | ^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u32` | = help: the trait `Add` is not implemented for `i32` + = help: the following implementations were found: + <&'a i32 as Add> + <&i32 as Add<&i32>> + > + + and 48 others error[E0308]: mismatched types --> $DIR/ufcs-qpath-self-mismatch.rs:6:28 diff --git a/src/test/ui/unevaluated_fixed_size_array_len.stderr b/src/test/ui/unevaluated_fixed_size_array_len.stderr index 03932d5ed0347..5e67b2c44f2be 100644 --- a/src/test/ui/unevaluated_fixed_size_array_len.stderr +++ b/src/test/ui/unevaluated_fixed_size_array_len.stderr @@ -4,8 +4,7 @@ error[E0277]: the trait bound `[(); 0]: Foo` is not satisfied LL | <[(); 0] as Foo>::foo() | ^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `[(); 0]` | - = help: the following implementations were found: - <[(); 1] as Foo> + = help: the trait `Foo` is implemented for `[(); 1]` error: aborting due to previous error diff --git a/src/test/ui/wf/hir-wf-check-erase-regions.stderr b/src/test/ui/wf/hir-wf-check-erase-regions.stderr index 0d9b9627562f9..037f8b9f33770 100644 --- a/src/test/ui/wf/hir-wf-check-erase-regions.stderr +++ b/src/test/ui/wf/hir-wf-check-erase-regions.stderr @@ -5,6 +5,7 @@ LL | type IntoIter = std::iter::Flatten>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&T` is not an iterator | = help: the trait `Iterator` is not implemented for `&T` + = help: the trait `Iterator` is implemented for `&mut I` = note: required because of the requirements on the impl of `IntoIterator` for `&T` note: required by a bound in `Flatten` --> $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL @@ -19,6 +20,7 @@ LL | fn into_iter(self) -> Self::IntoIter { | ^^^^^^^^^^^^^^ `&T` is not an iterator | = help: the trait `Iterator` is not implemented for `&T` + = help: the trait `Iterator` is implemented for `&mut I` = note: required because of the requirements on the impl of `IntoIterator` for `&T` note: required by a bound in `Flatten` --> $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL From ac8cbbd200cfa77f03a8560f0305810e4f8f1375 Mon Sep 17 00:00:00 2001 From: Esteban Kuber Date: Sat, 26 Mar 2022 21:26:02 +0000 Subject: [PATCH 2/8] Fix #90970, doesn't address #87437 --- .../src/traits/error_reporting/mod.rs | 79 +++++++++++++++++-- .../generic_const_exprs/issue-85848.stderr | 1 + .../cross-return-site-inference.stderr | 1 + .../ui/impl-trait/nested_impl_trait.stderr | 2 + src/test/ui/issues/issue-32709.stderr | 1 + .../ui/kindck/kindck-impl-type-params.stderr | 2 + .../bound/assoc-fn-bound-root-obligation.rs | 12 +++ .../assoc-fn-bound-root-obligation.stderr | 23 ++++++ 8 files changed, 115 insertions(+), 6 deletions(-) create mode 100644 src/test/ui/traits/bound/assoc-fn-bound-root-obligation.rs create mode 100644 src/test/ui/traits/bound/assoc-fn-bound-root-obligation.stderr diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 2da4c86a58e9c..65e2554a6f223 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -2,10 +2,11 @@ pub mod on_unimplemented; pub mod suggestions; use super::{ - EvaluationResult, FulfillmentContext, FulfillmentError, FulfillmentErrorCode, - MismatchedProjectionTypes, Obligation, ObligationCause, ObligationCauseCode, - OnUnimplementedDirective, OnUnimplementedNote, OutputTypeParameterMismatch, Overflow, - PredicateObligation, SelectionContext, SelectionError, TraitNotObjectSafe, + DerivedObligationCause, EvaluationResult, FulfillmentContext, FulfillmentError, + FulfillmentErrorCode, ImplDerivedObligationCause, MismatchedProjectionTypes, Obligation, + ObligationCause, ObligationCauseCode, OnUnimplementedDirective, OnUnimplementedNote, + OutputTypeParameterMismatch, Overflow, PredicateObligation, SelectionContext, SelectionError, + TraitNotObjectSafe, }; use crate::infer::error_reporting::{TyCategory, TypeAnnotationNeeded as ErrorCode}; @@ -654,11 +655,77 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { } else if !suggested { // Can't show anything else useful, try to find similar impls. let impl_candidates = self.find_similar_impl_candidates(trait_ref); - self.report_similar_impl_candidates( + if !self.report_similar_impl_candidates( impl_candidates, trait_ref, &mut err, - ); + ) { + // This is *almost* equivalent to + // `obligation.cause.code().peel_derives()`, but it gives us the + // trait predicate for that corresponding root obligation. This + // lets us get a derived obligation from a type parameter, like + // when calling `string.strip_suffix(p)` where `p` is *not* an + // implementer of `Pattern<'_>`. + let mut code = obligation.cause.code(); + let mut trait_pred = trait_predicate; + let mut peeled = false; + loop { + match &*code { + ObligationCauseCode::FunctionArgumentObligation { + parent_code, + .. + } => { + code = &parent_code; + } + ObligationCauseCode::ImplDerivedObligation( + box ImplDerivedObligationCause { + derived: + DerivedObligationCause { + parent_code, + parent_trait_pred, + }, + .. + }, + ) + | ObligationCauseCode::BuiltinDerivedObligation( + DerivedObligationCause { + parent_code, + parent_trait_pred, + }, + ) + | ObligationCauseCode::DerivedObligation( + DerivedObligationCause { + parent_code, + parent_trait_pred, + }, + ) => { + peeled = true; + code = &parent_code; + trait_pred = *parent_trait_pred; + } + _ => break, + }; + } + let def_id = trait_pred.def_id(); + // Mention *all* the `impl`s for the *top most* obligation, the + // user might have meant to use one of them, if any found. We skip + // auto-traits or fundamental traits that might not be exactly what + // the user might expect to be presented with. Instead this is + // useful for less general traits. + if peeled + && !self.tcx.trait_is_auto(def_id) + && !self.tcx.lang_items().items().contains(&Some(def_id)) + { + let trait_ref = trait_pred.to_poly_trait_ref(); + let impl_candidates = + self.find_similar_impl_candidates(trait_ref); + self.report_similar_impl_candidates( + impl_candidates, + trait_ref, + &mut err, + ); + } + } } // Changing mutability doesn't make a difference to whether we have diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-85848.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-85848.stderr index 4202cbae7eb29..27f5dce9fb266 100644 --- a/src/test/ui/const-generics/generic_const_exprs/issue-85848.stderr +++ b/src/test/ui/const-generics/generic_const_exprs/issue-85848.stderr @@ -6,6 +6,7 @@ LL | writes_to_specific_path(&cap); | | | required by a bound introduced by this call | + = help: the trait `Delegates` is implemented for `T` note: required because of the requirements on the impl of `Contains<(), true>` for `&C` --> $DIR/issue-85848.rs:21:12 | diff --git a/src/test/ui/impl-trait/cross-return-site-inference.stderr b/src/test/ui/impl-trait/cross-return-site-inference.stderr index 06afb938c5fad..d458c7be783d5 100644 --- a/src/test/ui/impl-trait/cross-return-site-inference.stderr +++ b/src/test/ui/impl-trait/cross-return-site-inference.stderr @@ -7,6 +7,7 @@ LL | Err("whoops")?; | ^ the trait `From<&str>` is not implemented for `impl Debug` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait + = help: the trait `FromResidual>` is implemented for `Result` = note: required because of the requirements on the impl of `FromResidual>` for `Result<(), impl Debug>` error[E0277]: the trait bound `impl Debug: From<&str>` is not satisfied diff --git a/src/test/ui/impl-trait/nested_impl_trait.stderr b/src/test/ui/impl-trait/nested_impl_trait.stderr index 26b48c7cdf718..bb4ae5e828254 100644 --- a/src/test/ui/impl-trait/nested_impl_trait.stderr +++ b/src/test/ui/impl-trait/nested_impl_trait.stderr @@ -52,6 +52,7 @@ error[E0277]: the trait bound `impl Debug: From>` is not satisfie LL | fn bad_in_ret_position(x: impl Into) -> impl Into { x } | ^^^^^^^^^^^^^^^^^^^^^ the trait `From>` is not implemented for `impl Debug` | + = help: the trait `Into` is implemented for `T` = note: required because of the requirements on the impl of `Into` for `impl Into` error[E0277]: the trait bound `impl Debug: From>` is not satisfied @@ -60,6 +61,7 @@ error[E0277]: the trait bound `impl Debug: From>` is not satisfie LL | fn bad(x: impl Into) -> impl Into { x } | ^^^^^^^^^^^^^^^^^^^^^ the trait `From>` is not implemented for `impl Debug` | + = help: the trait `Into` is implemented for `T` = note: required because of the requirements on the impl of `Into` for `impl Into` error: aborting due to 8 previous errors diff --git a/src/test/ui/issues/issue-32709.stderr b/src/test/ui/issues/issue-32709.stderr index b4c3f148e32b5..ed5addcbec517 100644 --- a/src/test/ui/issues/issue-32709.stderr +++ b/src/test/ui/issues/issue-32709.stderr @@ -7,6 +7,7 @@ LL | Err(5)?; | ^ the trait `From<{integer}>` is not implemented for `()` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait + = help: the trait `FromResidual>` is implemented for `Result` = note: required because of the requirements on the impl of `FromResidual>` for `Result` error: aborting due to previous error diff --git a/src/test/ui/kindck/kindck-impl-type-params.stderr b/src/test/ui/kindck/kindck-impl-type-params.stderr index 3558f0c9e6294..64bbc841b330f 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params.stderr @@ -80,6 +80,7 @@ error[E0277]: the trait bound `String: Copy` is not satisfied LL | let a = t as Box>; | ^ the trait `Copy` is not implemented for `String` | + = help: the trait `Gettable` is implemented for `S` note: required because of the requirements on the impl of `Gettable` for `S` --> $DIR/kindck-impl-type-params.rs:14:32 | @@ -93,6 +94,7 @@ error[E0277]: the trait bound `Foo: Copy` is not satisfied LL | let a: Box> = t; | ^ the trait `Copy` is not implemented for `Foo` | + = help: the trait `Gettable` is implemented for `S` note: required because of the requirements on the impl of `Gettable` for `S` --> $DIR/kindck-impl-type-params.rs:14:32 | diff --git a/src/test/ui/traits/bound/assoc-fn-bound-root-obligation.rs b/src/test/ui/traits/bound/assoc-fn-bound-root-obligation.rs new file mode 100644 index 0000000000000..2720f94a3c191 --- /dev/null +++ b/src/test/ui/traits/bound/assoc-fn-bound-root-obligation.rs @@ -0,0 +1,12 @@ +fn strip_lf(s: &str) -> &str { + s.strip_suffix(b'\n').unwrap_or(s) + //~^ ERROR expected a `FnMut<(char,)>` closure, found `u8` + //~| NOTE expected an `FnMut<(char,)>` closure, found `u8` + //~| NOTE required by a bound introduced by this call + //~| HELP the trait `FnMut<(char,)>` is not implemented for `u8` + //~| HELP the following other types implement trait `Pattern<'_>`: + //~| NOTE required because of the requirements on the impl of `Pattern<'_>` for `u8` + +} + +fn main() {} diff --git a/src/test/ui/traits/bound/assoc-fn-bound-root-obligation.stderr b/src/test/ui/traits/bound/assoc-fn-bound-root-obligation.stderr new file mode 100644 index 0000000000000..37cba4189d725 --- /dev/null +++ b/src/test/ui/traits/bound/assoc-fn-bound-root-obligation.stderr @@ -0,0 +1,23 @@ +error[E0277]: expected a `FnMut<(char,)>` closure, found `u8` + --> $DIR/assoc-fn-bound-root-obligation.rs:2:20 + | +LL | s.strip_suffix(b'\n').unwrap_or(s) + | ------------ ^^^^^ expected an `FnMut<(char,)>` closure, found `u8` + | | + | required by a bound introduced by this call + | + = help: the trait `FnMut<(char,)>` is not implemented for `u8` + = help: the following other types implement trait `Pattern<'_>`: + &'b String + &'b [char; N] + &'b [char] + &'b str + &'c &'b str + [char; N] + char + pattern::MultiCharEqPattern + = note: required because of the requirements on the impl of `Pattern<'_>` for `u8` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. From 883b93c7b7eb02ec85f4b8f9fb129efc403d4fb2 Mon Sep 17 00:00:00 2001 From: Esteban Kuber Date: Sat, 26 Mar 2022 23:01:29 +0000 Subject: [PATCH 3/8] Suggest dereferncing when possible in E0277, fix #87437 --- .../src/traits/error_reporting/suggestions.rs | 104 +++++++++++------- .../suggest-deferences/issue-39029.stderr | 2 +- .../suggest-deferences/issue-62530.stderr | 2 +- .../suggest-deferences/multiple-0.stderr | 2 +- .../suggest-deferences/root-obligation.fixed | 14 +++ .../suggest-deferences/root-obligation.rs | 14 +++ .../suggest-deferences/root-obligation.stderr | 24 ++++ 7 files changed, 121 insertions(+), 41 deletions(-) create mode 100644 src/test/ui/traits/suggest-deferences/root-obligation.fixed create mode 100644 src/test/ui/traits/suggest-deferences/root-obligation.rs create mode 100644 src/test/ui/traits/suggest-deferences/root-obligation.stderr diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 5bf9be87b57ae..b369c73387198 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -1,6 +1,6 @@ use super::{ - EvaluationResult, Obligation, ObligationCause, ObligationCauseCode, PredicateObligation, - SelectionContext, + DerivedObligationCause, EvaluationResult, ImplDerivedObligationCause, Obligation, + ObligationCause, ObligationCauseCode, PredicateObligation, SelectionContext, }; use crate::autoderef::Autoderef; @@ -496,50 +496,78 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { trait_pred: ty::PolyTraitPredicate<'tcx>, ) -> bool { // It only make sense when suggesting dereferences for arguments - let code = if let ObligationCauseCode::FunctionArgumentObligation { parent_code, .. } = - obligation.cause.code() - { - parent_code.clone() - } else { + let ObligationCauseCode::FunctionArgumentObligation { .. } = obligation.cause.code() else { return false; }; let param_env = obligation.param_env; let body_id = obligation.cause.body_id; let span = obligation.cause.span; - let real_trait_pred = match &*code { - ObligationCauseCode::ImplDerivedObligation(cause) => cause.derived.parent_trait_pred, - ObligationCauseCode::DerivedObligation(cause) - | ObligationCauseCode::BuiltinDerivedObligation(cause) => cause.parent_trait_pred, - _ => trait_pred, - }; - let Some(real_ty) = real_trait_pred.self_ty().no_bound_vars() else { - return false; - }; + let mut real_trait_pred = trait_pred; + let mut code = obligation.cause.code(); + loop { + match &code { + ObligationCauseCode::FunctionArgumentObligation { parent_code, .. } => { + code = &parent_code; + } + ObligationCauseCode::ImplDerivedObligation(box ImplDerivedObligationCause { + derived: DerivedObligationCause { parent_code, parent_trait_pred }, + .. + }) + | ObligationCauseCode::BuiltinDerivedObligation(DerivedObligationCause { + parent_code, + parent_trait_pred, + }) + | ObligationCauseCode::DerivedObligation(DerivedObligationCause { + parent_code, + parent_trait_pred, + }) => { + code = &parent_code; + real_trait_pred = *parent_trait_pred; + } + _ => break, + }; + let Some(real_ty) = real_trait_pred.self_ty().no_bound_vars() else { + continue; + }; - if let ty::Ref(region, base_ty, mutbl) = *real_ty.kind() { - let mut autoderef = Autoderef::new(self, param_env, body_id, span, base_ty, span); - if let Some(steps) = autoderef.find_map(|(ty, steps)| { - // Re-add the `&` - let ty = self.tcx.mk_ref(region, TypeAndMut { ty, mutbl }); - let obligation = - self.mk_trait_obligation_with_new_self_ty(param_env, real_trait_pred, ty); - Some(steps).filter(|_| self.predicate_may_hold(&obligation)) - }) { - if steps > 0 { - if let Ok(src) = self.tcx.sess.source_map().span_to_snippet(span) { - // Don't care about `&mut` because `DerefMut` is used less - // often and user will not expect autoderef happens. - if src.starts_with('&') && !src.starts_with("&mut ") { - let derefs = "*".repeat(steps); - err.span_suggestion( - span, - "consider adding dereference here", - format!("&{}{}", derefs, &src[1..]), - Applicability::MachineApplicable, - ); - return true; + if let ty::Ref(region, base_ty, mutbl) = *real_ty.kind() { + let mut autoderef = Autoderef::new(self, param_env, body_id, span, base_ty, span); + if let Some(steps) = autoderef.find_map(|(ty, steps)| { + // Re-add the `&` + let ty = self.tcx.mk_ref(region, TypeAndMut { ty, mutbl }); + let obligation = + self.mk_trait_obligation_with_new_self_ty(param_env, real_trait_pred, ty); + Some(steps).filter(|_| self.predicate_may_hold(&obligation)) + }) { + if steps > 0 { + if let Ok(src) = self.tcx.sess.source_map().span_to_snippet(span) { + // Don't care about `&mut` because `DerefMut` is used less + // often and user will not expect autoderef happens. + if src.starts_with('&') && !src.starts_with("&mut ") { + let derefs = "*".repeat(steps); + err.span_suggestion( + span, + "consider dereferencing here", + format!("&{}{}", derefs, &src[1..]), + Applicability::MachineApplicable, + ); + return true; + } } } + } else if real_trait_pred != trait_pred { + // This branch addresses #87437. + let obligation = + self.mk_trait_obligation_with_new_self_ty(param_env, real_trait_pred, base_ty); + if self.predicate_may_hold(&obligation) { + err.span_suggestion_verbose( + span.shrink_to_lo(), + "consider dereferencing here", + "*".to_string(), + Applicability::MachineApplicable, + ); + return true; + } } } } diff --git a/src/test/ui/traits/suggest-deferences/issue-39029.stderr b/src/test/ui/traits/suggest-deferences/issue-39029.stderr index 2c225f4311d01..5c324cd38a3ab 100644 --- a/src/test/ui/traits/suggest-deferences/issue-39029.stderr +++ b/src/test/ui/traits/suggest-deferences/issue-39029.stderr @@ -5,7 +5,7 @@ LL | let _errors = TcpListener::bind(&bad); | ----------------- ^^^^ | | | | | the trait `ToSocketAddrs` is not implemented for `NoToSocketAddrs` - | | help: consider adding dereference here: `&*bad` + | | help: consider dereferencing here: `&*bad` | required by a bound introduced by this call | = note: required because of the requirements on the impl of `ToSocketAddrs` for `&NoToSocketAddrs` diff --git a/src/test/ui/traits/suggest-deferences/issue-62530.stderr b/src/test/ui/traits/suggest-deferences/issue-62530.stderr index b77af7ddf4746..d129328dae8ef 100644 --- a/src/test/ui/traits/suggest-deferences/issue-62530.stderr +++ b/src/test/ui/traits/suggest-deferences/issue-62530.stderr @@ -5,7 +5,7 @@ LL | takes_type_parameter(&string); // Error | -------------------- ^^^^^^^ | | | | | the trait `SomeTrait` is not implemented for `&String` - | | help: consider adding dereference here: `&*string` + | | help: consider dereferencing here: `&*string` | required by a bound introduced by this call | note: required by a bound in `takes_type_parameter` diff --git a/src/test/ui/traits/suggest-deferences/multiple-0.stderr b/src/test/ui/traits/suggest-deferences/multiple-0.stderr index bf9f85f1b4595..efb3c7d123f70 100644 --- a/src/test/ui/traits/suggest-deferences/multiple-0.stderr +++ b/src/test/ui/traits/suggest-deferences/multiple-0.stderr @@ -5,7 +5,7 @@ LL | foo(&baz); | --- ^^^^ | | | | | the trait `Happy` is not implemented for `&Baz` - | | help: consider adding dereference here: `&***baz` + | | help: consider dereferencing here: `&***baz` | required by a bound introduced by this call | note: required by a bound in `foo` diff --git a/src/test/ui/traits/suggest-deferences/root-obligation.fixed b/src/test/ui/traits/suggest-deferences/root-obligation.fixed new file mode 100644 index 0000000000000..9fd1924067827 --- /dev/null +++ b/src/test/ui/traits/suggest-deferences/root-obligation.fixed @@ -0,0 +1,14 @@ +// run-rustfix + +fn get_vowel_count(string: &str) -> usize { + string + .chars() + .filter(|c| "aeiou".contains(*c)) + //~^ ERROR expected a `Fn<(char,)>` closure, found `char` + .count() +} + +fn main() { + let _ = get_vowel_count("asdf"); +} + diff --git a/src/test/ui/traits/suggest-deferences/root-obligation.rs b/src/test/ui/traits/suggest-deferences/root-obligation.rs new file mode 100644 index 0000000000000..4dd0291b62970 --- /dev/null +++ b/src/test/ui/traits/suggest-deferences/root-obligation.rs @@ -0,0 +1,14 @@ +// run-rustfix + +fn get_vowel_count(string: &str) -> usize { + string + .chars() + .filter(|c| "aeiou".contains(c)) + //~^ ERROR expected a `Fn<(char,)>` closure, found `char` + .count() +} + +fn main() { + let _ = get_vowel_count("asdf"); +} + diff --git a/src/test/ui/traits/suggest-deferences/root-obligation.stderr b/src/test/ui/traits/suggest-deferences/root-obligation.stderr new file mode 100644 index 0000000000000..16e03e79c7571 --- /dev/null +++ b/src/test/ui/traits/suggest-deferences/root-obligation.stderr @@ -0,0 +1,24 @@ +error[E0277]: expected a `Fn<(char,)>` closure, found `char` + --> $DIR/root-obligation.rs:6:38 + | +LL | .filter(|c| "aeiou".contains(c)) + | -------- ^ expected an `Fn<(char,)>` closure, found `char` + | | + | required by a bound introduced by this call + | + = help: the trait `Fn<(char,)>` is not implemented for `char` + = note: required because of the requirements on the impl of `FnOnce<(char,)>` for `&char` + = note: required because of the requirements on the impl of `Pattern<'_>` for `&char` +note: required by a bound in `core::str::::contains` + --> $SRC_DIR/core/src/str/mod.rs:LL:COL + | +LL | pub fn contains<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool { + | ^^^^^^^^^^^ required by this bound in `core::str::::contains` +help: consider dereferencing here + | +LL | .filter(|c| "aeiou".contains(*c)) + | + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. From e2bba0708a1e4b0c21f94de56c2bd5d66d3b825f Mon Sep 17 00:00:00 2001 From: Esteban Kuber Date: Sat, 26 Mar 2022 23:14:47 +0000 Subject: [PATCH 4/8] Fix list length --- .../src/traits/error_reporting/mod.rs | 2 +- src/test/ui/binop/binop-mul-i32-f32.stderr | 4 ++ src/test/ui/binop/issue-77910-1.stderr | 4 ++ .../ui/binop/shift-various-bad-types.stderr | 12 +++++ .../ui/const-generics/exhaustive-value.stderr | 4 ++ .../const-eval/const-eval-overflow-3b.stderr | 4 ++ .../const-eval/const-eval-overflow-4b.stderr | 4 ++ .../ui/consts/too_generic_eval_ice.stderr | 4 ++ ...e-21659-show-relevant-trait-impls-2.stderr | 2 + .../issue-39802-show-5-trait-impls.stderr | 12 +++++ ...de-confusable-in-float-literal-expt.stderr | 4 ++ src/test/ui/impl-trait/equality.stderr | 4 ++ src/test/ui/issues/issue-11771.stderr | 8 ++++ src/test/ui/issues/issue-24352.stderr | 4 ++ src/test/ui/issues/issue-50582.stderr | 4 ++ src/test/ui/issues/issue-59488.stderr | 4 ++ src/test/ui/kindck/kindck-copy.stderr | 8 ++++ .../ui/lexer/lex-bad-char-literals-6.stderr | 8 ++++ src/test/ui/mismatched_types/binops.stderr | 24 ++++++++++ src/test/ui/never_type/issue-13352.stderr | 4 ++ .../not-suggest-float-literal.stderr | 48 +++++++++++++++++++ .../suggest-float-literal.stderr | 32 +++++++++++++ src/test/ui/span/multiline-span-simple.stderr | 4 ++ src/test/ui/suggestions/into-str.stderr | 2 + .../ui/try-trait/bad-interconversion.stderr | 4 ++ src/test/ui/type/type-check-defaults.stderr | 4 ++ src/test/ui/typeck/issue-81293.stderr | 4 ++ .../ui/ufcs/ufcs-qpath-self-mismatch.stderr | 4 ++ 28 files changed, 225 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 65e2554a6f223..fdafb2d3d417e 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1813,7 +1813,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { } let len = impl_candidates.len(); - let end = if impl_candidates.len() <= 5 { impl_candidates.len() } else { 4 }; + let end = if impl_candidates.len() <= 9 { impl_candidates.len() } else { 8 }; let normalize = |candidate| { self.tcx.infer_ctxt().enter(|ref infcx| { diff --git a/src/test/ui/binop/binop-mul-i32-f32.stderr b/src/test/ui/binop/binop-mul-i32-f32.stderr index 9fcf5d72625c5..715e52b41e75c 100644 --- a/src/test/ui/binop/binop-mul-i32-f32.stderr +++ b/src/test/ui/binop/binop-mul-i32-f32.stderr @@ -10,6 +10,10 @@ LL | x * y <&i32 as Mul<&i32>> > + <&'a f32 as Mul> + <&'a f64 as Mul> + <&'a i128 as Mul> + <&'a i16 as Mul> and 49 others error: aborting due to previous error diff --git a/src/test/ui/binop/issue-77910-1.stderr b/src/test/ui/binop/issue-77910-1.stderr index 9553fcc5bb204..16b06a0198b27 100644 --- a/src/test/ui/binop/issue-77910-1.stderr +++ b/src/test/ui/binop/issue-77910-1.stderr @@ -21,6 +21,10 @@ LL | assert_eq!(foo, y); Ret as Debug> Ret as Debug> Ret as Debug> + Ret as Debug> + Ret as Debug> + Ret as Debug> + Ret as Debug> and 68 others = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/binop/shift-various-bad-types.stderr b/src/test/ui/binop/shift-various-bad-types.stderr index e134095e63879..8fdb377751c24 100644 --- a/src/test/ui/binop/shift-various-bad-types.stderr +++ b/src/test/ui/binop/shift-various-bad-types.stderr @@ -10,6 +10,10 @@ LL | 22 >> p.char; <&'a i128 as Shr> <&'a i128 as Shr> <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> and 568 others error[E0277]: no implementation for `{integer} >> &str` @@ -24,6 +28,10 @@ LL | 22 >> p.str; <&'a i128 as Shr> <&'a i128 as Shr> <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> and 568 others error[E0277]: no implementation for `{integer} >> &Panolpy` @@ -38,6 +46,10 @@ LL | 22 >> p; <&'a i128 as Shr> <&'a i128 as Shr> <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> + <&'a i128 as Shr> and 568 others error[E0308]: mismatched types diff --git a/src/test/ui/const-generics/exhaustive-value.stderr b/src/test/ui/const-generics/exhaustive-value.stderr index cb85b6cb93d91..fcbb41bb4fcc4 100644 --- a/src/test/ui/const-generics/exhaustive-value.stderr +++ b/src/test/ui/const-generics/exhaustive-value.stderr @@ -9,6 +9,10 @@ LL | <() as Foo>::test() <() as Foo<100_u8>> <() as Foo<101_u8>> <() as Foo<102_u8>> + <() as Foo<103_u8>> + <() as Foo<104_u8>> + <() as Foo<105_u8>> + <() as Foo<106_u8>> and 248 others error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr index aee7192b6eda1..d2d68506d4e1c 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr @@ -16,6 +16,10 @@ LL | = [0; (i8::MAX + 1u8) as usize]; <&i8 as Add<&i8>> > + <&'a f32 as Add> + <&'a f64 as Add> + <&'a i128 as Add> + <&'a i16 as Add> and 48 others error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr index 059447f7cacb3..818e3bc15b19d 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr @@ -16,6 +16,10 @@ LL | : [u32; (i8::MAX as i8 + 1u8) as usize] <&i8 as Add<&i8>> > + <&'a f32 as Add> + <&'a f64 as Add> + <&'a i128 as Add> + <&'a i16 as Add> and 48 others error[E0604]: only `u8` can be cast as `char`, not `i8` diff --git a/src/test/ui/consts/too_generic_eval_ice.stderr b/src/test/ui/consts/too_generic_eval_ice.stderr index 677fa7d21aef0..45459b931caac 100644 --- a/src/test/ui/consts/too_generic_eval_ice.stderr +++ b/src/test/ui/consts/too_generic_eval_ice.stderr @@ -26,6 +26,10 @@ LL | [5; Self::HOST_SIZE] == [6; 0] <&[T] as PartialEq>> <&mut [B] as PartialEq<[A; N]>> <&mut [T] as PartialEq>> + <[A; N] as PartialEq<&[B]>> + <[A; N] as PartialEq<&mut [B]>> + <[A; N] as PartialEq<[B; N]>> + <[A; N] as PartialEq<[B]>> and 3 others error: aborting due to 3 previous errors diff --git a/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr index ea461241bf414..f25c7ce00e548 100644 --- a/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr +++ b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr @@ -9,6 +9,8 @@ LL | f1.foo(1usize); > > > + > + > error: aborting due to previous error diff --git a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr index 58faaf4ea9014..3aa863e900f4a 100644 --- a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr +++ b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr @@ -11,6 +11,11 @@ LL | Foo::::bar(&1i8); > > > + > + > + > + > + > error[E0277]: the trait bound `u8: Foo` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:25:21 @@ -25,6 +30,11 @@ LL | Foo::::bar(&1u8); > > > + > + > + > + > + > error[E0277]: the trait bound `bool: Foo` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:26:21 @@ -39,6 +49,8 @@ LL | Foo::::bar(&true); > > > + > + > error: aborting due to 3 previous errors diff --git a/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr b/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr index c12b02a76c58a..bd9d9e086e044 100644 --- a/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr +++ b/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr @@ -27,6 +27,10 @@ LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e−11; // m³⋅kg⁻¹ <&'a f64 as Sub> <&'a i128 as Sub> <&'a i16 as Sub> + <&'a i32 as Sub> + <&'a i64 as Sub> + <&'a i8 as Sub> + <&'a isize as Sub> and 48 others error: aborting due to 3 previous errors diff --git a/src/test/ui/impl-trait/equality.stderr b/src/test/ui/impl-trait/equality.stderr index 6592e234d9873..9137183375aca 100644 --- a/src/test/ui/impl-trait/equality.stderr +++ b/src/test/ui/impl-trait/equality.stderr @@ -29,6 +29,10 @@ LL | n + sum_to(n - 1) <&u32 as Add<&u32>> > + <&'a f32 as Add> + <&'a f64 as Add> + <&'a i128 as Add> + <&'a i16 as Add> and 48 others error: aborting due to 2 previous errors; 1 warning emitted diff --git a/src/test/ui/issues/issue-11771.stderr b/src/test/ui/issues/issue-11771.stderr index 2b93d4aab27db..019677775987e 100644 --- a/src/test/ui/issues/issue-11771.stderr +++ b/src/test/ui/issues/issue-11771.stderr @@ -10,6 +10,10 @@ LL | 1 + <&'a f64 as Add> <&'a i128 as Add> <&'a i16 as Add> + <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> and 48 others error[E0277]: cannot add `()` to `{integer}` @@ -24,6 +28,10 @@ LL | 1 + <&'a f64 as Add> <&'a i128 as Add> <&'a i16 as Add> + <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> and 48 others error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-24352.stderr b/src/test/ui/issues/issue-24352.stderr index f61ff0bda0bbd..364fbbc981e64 100644 --- a/src/test/ui/issues/issue-24352.stderr +++ b/src/test/ui/issues/issue-24352.stderr @@ -10,6 +10,10 @@ LL | 1.0f64 - 1 <&f64 as Sub<&f64>> > + <&'a f32 as Sub> + <&'a i128 as Sub> + <&'a i16 as Sub> + <&'a i32 as Sub> and 48 others help: consider using a floating-point literal by writing it with `.0` | diff --git a/src/test/ui/issues/issue-50582.stderr b/src/test/ui/issues/issue-50582.stderr index 64bcfcd6016ab..a1e614807de4a 100644 --- a/src/test/ui/issues/issue-50582.stderr +++ b/src/test/ui/issues/issue-50582.stderr @@ -19,6 +19,10 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); <&'a f64 as Add> <&'a i128 as Add> <&'a i16 as Add> + <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> and 48 others error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-59488.stderr b/src/test/ui/issues/issue-59488.stderr index 55616d2d322ee..c61d44bf89526 100644 --- a/src/test/ui/issues/issue-59488.stderr +++ b/src/test/ui/issues/issue-59488.stderr @@ -99,6 +99,10 @@ LL | assert_eq!(Foo::Bar, i); Ret as Debug> Ret as Debug> Ret as Debug> + Ret as Debug> + Ret as Debug> + Ret as Debug> + Ret as Debug> and 68 others = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/kindck/kindck-copy.stderr b/src/test/ui/kindck/kindck-copy.stderr index 6272c4b702266..29c9b872b5816 100644 --- a/src/test/ui/kindck/kindck-copy.stderr +++ b/src/test/ui/kindck/kindck-copy.stderr @@ -9,6 +9,10 @@ LL | assert_copy::<&'static mut isize>(); + + + + and 6 others note: required by a bound in `assert_copy` --> $DIR/kindck-copy.rs:5:18 @@ -27,6 +31,10 @@ LL | assert_copy::<&'a mut isize>(); + + + + and 6 others note: required by a bound in `assert_copy` --> $DIR/kindck-copy.rs:5:18 diff --git a/src/test/ui/lexer/lex-bad-char-literals-6.stderr b/src/test/ui/lexer/lex-bad-char-literals-6.stderr index 0e1851d292cf9..9df6c92d1e578 100644 --- a/src/test/ui/lexer/lex-bad-char-literals-6.stderr +++ b/src/test/ui/lexer/lex-bad-char-literals-6.stderr @@ -43,6 +43,10 @@ LL | if x == y {} <&'a str as PartialEq> <&'b str as PartialEq>> >> + > + > + > + and 4 others error[E0308]: mismatched types @@ -65,6 +69,10 @@ LL | if x == z {} <&'a str as PartialEq> <&'b str as PartialEq>> >> + > + > + > + and 4 others error: aborting due to 6 previous errors diff --git a/src/test/ui/mismatched_types/binops.stderr b/src/test/ui/mismatched_types/binops.stderr index 6e67a7b454529..843ae5044c37a 100644 --- a/src/test/ui/mismatched_types/binops.stderr +++ b/src/test/ui/mismatched_types/binops.stderr @@ -10,6 +10,10 @@ LL | 1 + Some(1); <&'a f64 as Add> <&'a i128 as Add> <&'a i16 as Add> + <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> and 48 others error[E0277]: cannot subtract `Option<{integer}>` from `usize` @@ -24,6 +28,10 @@ LL | 2 as usize - Some(1); <&usize as Sub<&usize>> > + <&'a f32 as Sub> + <&'a f64 as Sub> + <&'a i128 as Sub> + <&'a i16 as Sub> and 48 others error[E0277]: cannot multiply `{integer}` by `()` @@ -38,6 +46,10 @@ LL | 3 * (); <&'a f64 as Mul> <&'a i128 as Mul> <&'a i16 as Mul> + <&'a i32 as Mul> + <&'a i64 as Mul> + <&'a i8 as Mul> + <&'a isize as Mul> and 49 others error[E0277]: cannot divide `{integer}` by `&str` @@ -52,6 +64,10 @@ LL | 4 / ""; <&'a f64 as Div> <&'a i128 as Div> <&'a i16 as Div> + <&'a i32 as Div> + <&'a i64 as Div> + <&'a i8 as Div> + <&'a isize as Div> and 54 others error[E0277]: can't compare `{integer}` with `String` @@ -66,6 +82,10 @@ LL | 5 < String::new(); + + + + and 6 others error[E0277]: can't compare `{integer}` with `Result<{integer}, _>` @@ -80,6 +100,10 @@ LL | 6 == Ok(1); + + + + and 6 others error: aborting due to 6 previous errors diff --git a/src/test/ui/never_type/issue-13352.stderr b/src/test/ui/never_type/issue-13352.stderr index 12a6d7962f46b..cfb5d28e7674b 100644 --- a/src/test/ui/never_type/issue-13352.stderr +++ b/src/test/ui/never_type/issue-13352.stderr @@ -10,6 +10,10 @@ LL | 2_usize + (loop {}); <&usize as Add<&usize>> > + <&'a f32 as Add> + <&'a f64 as Add> + <&'a i128 as Add> + <&'a i16 as Add> and 48 others error: aborting due to previous error diff --git a/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr b/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr index d8bba1509d868..431cbf81b01bd 100644 --- a/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr +++ b/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr @@ -10,6 +10,10 @@ LL | x + 100.0 <&u8 as Add<&u8>> > + <&'a f32 as Add> + <&'a f64 as Add> + <&'a i128 as Add> + <&'a i16 as Add> and 48 others error[E0277]: cannot add `&str` to `f64` @@ -24,6 +28,10 @@ LL | x + "foo" <&f64 as Add<&f64>> > + <&'a f32 as Add> + <&'a i128 as Add> + <&'a i16 as Add> + <&'a i32 as Add> and 48 others error[E0277]: cannot add `{integer}` to `f64` @@ -38,6 +46,10 @@ LL | x + y <&f64 as Add<&f64>> > + <&'a f32 as Add> + <&'a i128 as Add> + <&'a i16 as Add> + <&'a i32 as Add> and 48 others error[E0277]: cannot subtract `{float}` from `u8` @@ -52,6 +64,10 @@ LL | x - 100.0 <&u8 as Sub<&u8>> > + <&'a f32 as Sub> + <&'a f64 as Sub> + <&'a i128 as Sub> + <&'a i16 as Sub> and 48 others error[E0277]: cannot subtract `&str` from `f64` @@ -66,6 +82,10 @@ LL | x - "foo" <&f64 as Sub<&f64>> > + <&'a f32 as Sub> + <&'a i128 as Sub> + <&'a i16 as Sub> + <&'a i32 as Sub> and 48 others error[E0277]: cannot subtract `{integer}` from `f64` @@ -80,6 +100,10 @@ LL | x - y <&f64 as Sub<&f64>> > + <&'a f32 as Sub> + <&'a i128 as Sub> + <&'a i16 as Sub> + <&'a i32 as Sub> and 48 others error[E0277]: cannot multiply `u8` by `{float}` @@ -94,6 +118,10 @@ LL | x * 100.0 <&u8 as Mul<&u8>> > + <&'a f32 as Mul> + <&'a f64 as Mul> + <&'a i128 as Mul> + <&'a i16 as Mul> and 49 others error[E0277]: cannot multiply `f64` by `&str` @@ -108,6 +136,10 @@ LL | x * "foo" <&f64 as Mul<&f64>> > + <&'a f32 as Mul> + <&'a i128 as Mul> + <&'a i16 as Mul> + <&'a i32 as Mul> and 49 others error[E0277]: cannot multiply `f64` by `{integer}` @@ -122,6 +154,10 @@ LL | x * y <&f64 as Mul<&f64>> > + <&'a f32 as Mul> + <&'a i128 as Mul> + <&'a i16 as Mul> + <&'a i32 as Mul> and 49 others error[E0277]: cannot divide `u8` by `{float}` @@ -136,6 +172,10 @@ LL | x / 100.0 <&u8 as Div<&u8>> > > + + <&'a f32 as Div> + <&'a f64 as Div> + <&'a i128 as Div> and 54 others error[E0277]: cannot divide `f64` by `&str` @@ -150,6 +190,10 @@ LL | x / "foo" <&f64 as Div<&f64>> > + <&'a f32 as Div> + <&'a i128 as Div> + <&'a i16 as Div> + <&'a i32 as Div> and 54 others error[E0277]: cannot divide `f64` by `{integer}` @@ -164,6 +208,10 @@ LL | x / y <&f64 as Div<&f64>> > + <&'a f32 as Div> + <&'a i128 as Div> + <&'a i16 as Div> + <&'a i32 as Div> and 54 others error: aborting due to 12 previous errors diff --git a/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr b/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr index b7591dfca99b3..543e3137fdd09 100644 --- a/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr +++ b/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr @@ -10,6 +10,10 @@ LL | x + 100 <&f32 as Add<&f32>> > + <&'a f64 as Add> + <&'a i128 as Add> + <&'a i16 as Add> + <&'a i32 as Add> and 48 others help: consider using a floating-point literal by writing it with `.0` | @@ -28,6 +32,10 @@ LL | x + 100 <&f64 as Add<&f64>> > + <&'a f32 as Add> + <&'a i128 as Add> + <&'a i16 as Add> + <&'a i32 as Add> and 48 others help: consider using a floating-point literal by writing it with `.0` | @@ -46,6 +54,10 @@ LL | x - 100 <&f32 as Sub<&f32>> > + <&'a f64 as Sub> + <&'a i128 as Sub> + <&'a i16 as Sub> + <&'a i32 as Sub> and 48 others help: consider using a floating-point literal by writing it with `.0` | @@ -64,6 +76,10 @@ LL | x - 100 <&f64 as Sub<&f64>> > + <&'a f32 as Sub> + <&'a i128 as Sub> + <&'a i16 as Sub> + <&'a i32 as Sub> and 48 others help: consider using a floating-point literal by writing it with `.0` | @@ -82,6 +98,10 @@ LL | x * 100 <&f32 as Mul<&f32>> > + <&'a f64 as Mul> + <&'a i128 as Mul> + <&'a i16 as Mul> + <&'a i32 as Mul> and 49 others help: consider using a floating-point literal by writing it with `.0` | @@ -100,6 +120,10 @@ LL | x * 100 <&f64 as Mul<&f64>> > + <&'a f32 as Mul> + <&'a i128 as Mul> + <&'a i16 as Mul> + <&'a i32 as Mul> and 49 others help: consider using a floating-point literal by writing it with `.0` | @@ -118,6 +142,10 @@ LL | x / 100 <&f32 as Div<&f32>> > + <&'a f64 as Div> + <&'a i128 as Div> + <&'a i16 as Div> + <&'a i32 as Div> and 54 others help: consider using a floating-point literal by writing it with `.0` | @@ -136,6 +164,10 @@ LL | x / 100 <&f64 as Div<&f64>> > + <&'a f32 as Div> + <&'a i128 as Div> + <&'a i16 as Div> + <&'a i32 as Div> and 54 others help: consider using a floating-point literal by writing it with `.0` | diff --git a/src/test/ui/span/multiline-span-simple.stderr b/src/test/ui/span/multiline-span-simple.stderr index 1542832f0129c..dee457ebd7f3f 100644 --- a/src/test/ui/span/multiline-span-simple.stderr +++ b/src/test/ui/span/multiline-span-simple.stderr @@ -10,6 +10,10 @@ LL | foo(1 as u32 + <&u32 as Add<&u32>> > + <&'a f32 as Add> + <&'a f64 as Add> + <&'a i128 as Add> + <&'a i16 as Add> and 48 others error: aborting due to previous error diff --git a/src/test/ui/suggestions/into-str.stderr b/src/test/ui/suggestions/into-str.stderr index 4bdea05b06b8d..88a0f8f065027 100644 --- a/src/test/ui/suggestions/into-str.stderr +++ b/src/test/ui/suggestions/into-str.stderr @@ -12,6 +12,8 @@ LL | foo(String::new()); > > >> + >> + > = note: required because of the requirements on the impl of `Into<&str>` for `String` note: required by a bound in `foo` --> $DIR/into-str.rs:1:31 diff --git a/src/test/ui/try-trait/bad-interconversion.stderr b/src/test/ui/try-trait/bad-interconversion.stderr index fc2692a9a9313..6567eca38c81d 100644 --- a/src/test/ui/try-trait/bad-interconversion.stderr +++ b/src/test/ui/try-trait/bad-interconversion.stderr @@ -12,6 +12,10 @@ LL | Ok(Err(123_i32)?) > > > + > + > + > + > and 67 others = note: required because of the requirements on the impl of `FromResidual>` for `Result` diff --git a/src/test/ui/type/type-check-defaults.stderr b/src/test/ui/type/type-check-defaults.stderr index 80ff068ff309a..15bbfeb87c6f3 100644 --- a/src/test/ui/type/type-check-defaults.stderr +++ b/src/test/ui/type/type-check-defaults.stderr @@ -70,6 +70,10 @@ LL | trait ProjectionPred> where T::Item : Add {} <&i32 as Add<&i32>> > + <&'a f32 as Add> + <&'a f64 as Add> + <&'a i128 as Add> + <&'a i16 as Add> and 48 others error: aborting due to 7 previous errors diff --git a/src/test/ui/typeck/issue-81293.stderr b/src/test/ui/typeck/issue-81293.stderr index 0a5ec56e91512..9e2d8a6159c48 100644 --- a/src/test/ui/typeck/issue-81293.stderr +++ b/src/test/ui/typeck/issue-81293.stderr @@ -25,6 +25,10 @@ LL | a = c + b * 5; <&usize as Add<&usize>> > + <&'a f32 as Add> + <&'a f64 as Add> + <&'a i128 as Add> + <&'a i16 as Add> and 48 others error: aborting due to 3 previous errors diff --git a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr index c769a0df7c891..64da15c505536 100644 --- a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr +++ b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr @@ -10,6 +10,10 @@ LL | >::add(1, 2); <&i32 as Add<&i32>> > + <&'a f32 as Add> + <&'a f64 as Add> + <&'a i128 as Add> + <&'a i16 as Add> and 48 others error[E0308]: mismatched types From ef91519b45d2bbf0ce8c0180118160562eaaa0ca Mon Sep 17 00:00:00 2001 From: Esteban Kuber Date: Sun, 27 Mar 2022 01:49:01 +0000 Subject: [PATCH 5/8] Dedup logic and improve output for other types that impl trait --- .../src/traits/error_reporting/mod.rs | 121 +++++++++-------- .../src/traits/error_reporting/suggestions.rs | 7 +- src/test/ui/binop/binop-mul-i32-f32.stderr | 10 +- src/test/ui/binop/issue-77910-1.stderr | 18 +-- .../ui/binop/shift-various-bad-types.stderr | 6 +- .../ui/chalkify/chalk_initial_program.stderr | 6 +- src/test/ui/chalkify/type_inference.stderr | 6 +- .../defaults/rp_impl_trait_fail.stderr | 6 +- .../ui/const-generics/exhaustive-value.stderr | 2 +- .../issues/issue-67185-2.stderr | 36 +++--- .../occurs-check/unused-substs-1.stderr | 2 +- .../const-eval/const-eval-overflow-3b.stderr | 10 +- .../const-eval/const-eval-overflow-4b.stderr | 10 +- .../ui/consts/too_generic_eval_ice.stderr | 2 +- ...e-21659-show-relevant-trait-impls-1.stderr | 2 +- ...e-21659-show-relevant-trait-impls-2.stderr | 2 +- .../issue-39802-show-5-trait-impls.stderr | 14 +- ...de-confusable-in-float-literal-expt.stderr | 2 +- .../bugs/issue-88460.stderr | 2 +- src/test/ui/impl-trait/equality.stderr | 10 +- src/test/ui/issues/issue-11771.stderr | 4 +- src/test/ui/issues/issue-24352.stderr | 10 +- src/test/ui/issues/issue-50582.stderr | 2 +- src/test/ui/issues/issue-59488.stderr | 18 +-- src/test/ui/kindck/kindck-copy.stderr | 36 +++--- .../ui/lexer/lex-bad-char-literals-6.stderr | 20 +-- src/test/ui/mismatched_types/binops.stderr | 52 ++++---- src/test/ui/never_type/issue-13352.stderr | 10 +- .../not-suggest-float-literal.stderr | 122 +++++++++--------- .../suggest-float-literal.stderr | 72 +++++------ .../ui/on-unimplemented/multiple-impls.stderr | 12 +- .../ui/on-unimplemented/slice-index.stderr | 2 +- .../termination-trait-test-wrong-type.stderr | 8 +- src/test/ui/span/multiline-span-simple.stderr | 10 +- src/test/ui/suggestions/into-str.stderr | 2 +- .../issue-71394-no-from-impl.stderr | 2 +- .../bound/assoc-fn-bound-root-obligation.rs | 2 +- .../assoc-fn-bound-root-obligation.stderr | 2 +- .../repeated-supertrait-ambig.stderr | 10 +- src/test/ui/traits/issue-79458.stderr | 8 +- src/test/ui/traits/map-types.stderr | 2 +- .../ui/try-trait/bad-interconversion.stderr | 6 +- .../nested-tait-inference2.stderr | 2 +- src/test/ui/type/type-check-defaults.stderr | 10 +- src/test/ui/typeck/issue-81293.stderr | 10 +- src/test/ui/typeck/issue-90101.stderr | 2 +- .../ui/ufcs/ufcs-qpath-self-mismatch.stderr | 10 +- 47 files changed, 363 insertions(+), 357 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index fdafb2d3d417e..09b445058c0d3 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -30,7 +30,7 @@ use rustc_middle::traits::select::OverflowError; use rustc_middle::ty::error::ExpectedFound; use rustc_middle::ty::fold::TypeFolder; use rustc_middle::ty::{ - self, SubtypePredicate, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable, + self, SubtypePredicate, ToPolyTraitRef, ToPredicate, TraitRef, Ty, TyCtxt, TypeFoldable, }; use rustc_span::symbol::{kw, sym}; use rustc_span::{ExpnKind, MultiSpan, Span, DUMMY_SP}; @@ -1756,6 +1756,60 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { trait_ref: ty::PolyTraitRef<'tcx>, err: &mut Diagnostic, ) -> bool { + let report = |mut candidates: Vec>, err: &mut Diagnostic| { + candidates.sort(); + candidates.dedup(); + let len = candidates.len(); + if candidates.len() == 0 { + return false; + } + let trait_ref = candidates[0]; + if candidates.len() == 1 { + err.highlighted_help(vec![ + ( + format!( + "the trait `{}` is implemented for `", + trait_ref.print_only_trait_path() + ), + Style::NoStyle, + ), + (candidates[0].self_ty().to_string(), Style::Highlight), + ("`".to_string(), Style::NoStyle), + ]); + return true; + } + // Check if the trait is the same in all cases. If so, we'll only show the type. + // FIXME: there *has* to be a better way! + let mut traits: Vec<_> = candidates + .iter() + .map(|c| format!("{}", c).split(" as ").last().unwrap().to_string()) + .collect(); + traits.sort(); + traits.dedup(); + + let mut candidates: Vec = candidates + .into_iter() + .map(|c| { + if traits.len() == 1 { + format!("\n {}", c.self_ty()) + } else { + format!("\n {}", c) + } + }) + .collect(); + + candidates.sort(); + candidates.dedup(); + let end = if candidates.len() <= 9 { candidates.len() } else { 8 }; + err.help(&format!( + "the following other types implement trait `{}`:{}{}", + trait_ref.print_only_trait_path(), + candidates[..end].join(""), + if len > 9 { format!("\nand {} others", len - 8) } else { String::new() } + )); + true + }; + let def_id = trait_ref.def_id(); if impl_candidates.is_empty() { if self.tcx.trait_is_auto(def_id) @@ -1765,7 +1819,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { // Mentioning implementers of `Copy`, `Debug` and friends is not useful. return false; } - let mut normalized_impl_candidates: Vec<_> = self + let normalized_impl_candidates: Vec<_> = self .tcx .all_impls(def_id) // Ignore automatically derived impls and `!Trait` impls. @@ -1776,45 +1830,10 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { .filter_map(|def_id| self.tcx.impl_trait_ref(def_id)) // Avoid mentioning type parameters. .filter(|trait_ref| !matches!(trait_ref.self_ty().kind(), ty::Param(_))) - .map(|trait_ref| format!("\n {}", trait_ref.self_ty())) .collect(); - normalized_impl_candidates.sort(); - normalized_impl_candidates.dedup(); - let len = normalized_impl_candidates.len(); - if len == 0 { - return false; - } - if len == 1 { - err.highlighted_help(vec![ - ( - format!( - "the trait `{}` is implemented for `", - trait_ref.print_only_trait_path() - ), - Style::NoStyle, - ), - (normalized_impl_candidates[0].trim().to_string(), Style::Highlight), - ("`".to_string(), Style::NoStyle), - ]); - return true; - } - let end = if normalized_impl_candidates.len() <= 9 { - normalized_impl_candidates.len() - } else { - 8 - }; - err.help(&format!( - "the following other types implement trait `{}`:{}{}", - trait_ref.print_only_trait_path(), - normalized_impl_candidates[..end].join(""), - if len > 9 { format!("\nand {} others", len - 8) } else { String::new() } - )); - return true; + return report(normalized_impl_candidates, err); } - let len = impl_candidates.len(); - let end = if impl_candidates.len() <= 9 { impl_candidates.len() } else { 8 }; - let normalize = |candidate| { self.tcx.infer_ctxt().enter(|ref infcx| { let normalized = infcx @@ -1822,8 +1841,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { .normalize(candidate) .ok(); match normalized { - Some(normalized) => format!("\n {}", normalized.value), - None => format!("\n {}", candidate), + Some(normalized) => normalized.value, + None => candidate, } }) }; @@ -1834,7 +1853,6 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { // // Prefer more similar candidates first, then sort lexicographically // by their normalized string representation. - let first_candidate = impl_candidates.get(0).map(|candidate| candidate.trait_ref); let mut normalized_impl_candidates_and_similarities = impl_candidates .into_iter() .map(|ImplCandidate { trait_ref, similarity }| { @@ -1850,26 +1868,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { .map(|(_, normalized)| normalized) .collect::>(); - if normalized_impl_candidates.len() == 1 { - err.highlighted_help(vec![ - ( - format!( - "the trait `{}` is implemented for `", - first_candidate.unwrap().print_only_trait_path() - ), - Style::NoStyle, - ), - (first_candidate.unwrap().self_ty().to_string(), Style::Highlight), - ("`".to_string(), Style::NoStyle), - ]); - } else { - err.help(&format!( - "the following implementations were found:{}{}", - normalized_impl_candidates[..end].join(""), - if len > 9 { format!("\nand {} others", len - 8) } else { String::new() } - )); - } - true + report(normalized_impl_candidates, err) } /// Gets the parent trait chain start diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index b369c73387198..16ecca254c7b0 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -557,8 +557,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { } } else if real_trait_pred != trait_pred { // This branch addresses #87437. - let obligation = - self.mk_trait_obligation_with_new_self_ty(param_env, real_trait_pred, base_ty); + let obligation = self.mk_trait_obligation_with_new_self_ty( + param_env, + real_trait_pred, + base_ty, + ); if self.predicate_may_hold(&obligation) { err.span_suggestion_verbose( span.shrink_to_lo(), diff --git a/src/test/ui/binop/binop-mul-i32-f32.stderr b/src/test/ui/binop/binop-mul-i32-f32.stderr index 715e52b41e75c..453333fb56a87 100644 --- a/src/test/ui/binop/binop-mul-i32-f32.stderr +++ b/src/test/ui/binop/binop-mul-i32-f32.stderr @@ -5,15 +5,15 @@ LL | x * y | ^ no implementation for `i32 * f32` | = help: the trait `Mul` is not implemented for `i32` - = help: the following implementations were found: - <&'a i32 as Mul> - <&i32 as Mul<&i32>> - > - + = help: the following other types implement trait `Mul`: <&'a f32 as Mul> <&'a f64 as Mul> <&'a i128 as Mul> <&'a i16 as Mul> + <&'a i32 as Mul> + <&'a i64 as Mul> + <&'a i8 as Mul> + <&'a isize as Mul> and 49 others error: aborting due to previous error diff --git a/src/test/ui/binop/issue-77910-1.stderr b/src/test/ui/binop/issue-77910-1.stderr index 16b06a0198b27..95ee51a88261a 100644 --- a/src/test/ui/binop/issue-77910-1.stderr +++ b/src/test/ui/binop/issue-77910-1.stderr @@ -16,15 +16,15 @@ LL | assert_eq!(foo, y); | ^^^^^^^^^^^^^^^^^^ `for<'r> fn(&'r i32) -> &'r i32 {foo}` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = help: the trait `Debug` is not implemented for `for<'r> fn(&'r i32) -> &'r i32 {foo}` - = help: the following implementations were found: - Ret as Debug> - Ret as Debug> - Ret as Debug> - Ret as Debug> - Ret as Debug> - Ret as Debug> - Ret as Debug> - Ret as Debug> + = help: the following other types implement trait `Debug`: + extern "C" fn() -> Ret + extern "C" fn(A) -> Ret + extern "C" fn(A, ...) -> Ret + extern "C" fn(A, B) -> Ret + extern "C" fn(A, B, ...) -> Ret + extern "C" fn(A, B, C) -> Ret + extern "C" fn(A, B, C, ...) -> Ret + extern "C" fn(A, B, C, D) -> Ret and 68 others = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/binop/shift-various-bad-types.stderr b/src/test/ui/binop/shift-various-bad-types.stderr index 8fdb377751c24..bb0bb63b22df5 100644 --- a/src/test/ui/binop/shift-various-bad-types.stderr +++ b/src/test/ui/binop/shift-various-bad-types.stderr @@ -5,7 +5,7 @@ LL | 22 >> p.char; | ^^ no implementation for `{integer} >> char` | = help: the trait `Shr` is not implemented for `{integer}` - = help: the following implementations were found: + = help: the following other types implement trait `Shr`: <&'a i128 as Shr> <&'a i128 as Shr> <&'a i128 as Shr> @@ -23,7 +23,7 @@ LL | 22 >> p.str; | ^^ no implementation for `{integer} >> &str` | = help: the trait `Shr<&str>` is not implemented for `{integer}` - = help: the following implementations were found: + = help: the following other types implement trait `Shr`: <&'a i128 as Shr> <&'a i128 as Shr> <&'a i128 as Shr> @@ -41,7 +41,7 @@ LL | 22 >> p; | ^^ no implementation for `{integer} >> &Panolpy` | = help: the trait `Shr<&Panolpy>` is not implemented for `{integer}` - = help: the following implementations were found: + = help: the following other types implement trait `Shr`: <&'a i128 as Shr> <&'a i128 as Shr> <&'a i128 as Shr> diff --git a/src/test/ui/chalkify/chalk_initial_program.stderr b/src/test/ui/chalkify/chalk_initial_program.stderr index 7b0b3f85b3915..343c0a31862b9 100644 --- a/src/test/ui/chalkify/chalk_initial_program.stderr +++ b/src/test/ui/chalkify/chalk_initial_program.stderr @@ -4,9 +4,9 @@ error[E0277]: the trait bound `f32: Foo` is not satisfied LL | gimme::(); | ^^^ the trait `Foo` is not implemented for `f32` | - = help: the following implementations were found: - - + = help: the following other types implement trait `Foo`: + i32 + u32 note: required by a bound in `gimme` --> $DIR/chalk_initial_program.rs:9:13 | diff --git a/src/test/ui/chalkify/type_inference.stderr b/src/test/ui/chalkify/type_inference.stderr index 14d43c1474c57..508a6dd1388cb 100644 --- a/src/test/ui/chalkify/type_inference.stderr +++ b/src/test/ui/chalkify/type_inference.stderr @@ -6,9 +6,9 @@ LL | only_bar(x); | | | required by a bound introduced by this call | - = help: the following implementations were found: - - + = help: the following other types implement trait `Bar`: + i32 + u32 note: required by a bound in `only_bar` --> $DIR/type_inference.rs:12:16 | diff --git a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr index 9cadc4110e1e6..4c9ab6901b1f5 100644 --- a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr +++ b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr @@ -25,7 +25,7 @@ error[E0277]: the trait bound `u32: Traitor` is not satisfied LL | fn uwu() -> impl Traitor { | ^^^^^^^^^^^^^^^ the trait `Traitor` is not implemented for `u32` | - = help: the following implementations were found: + = help: the following other types implement trait `Traitor`: > > @@ -50,9 +50,9 @@ error[E0277]: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied LL | fn owo() -> impl Traitor { | ^^^^^^^^^^^^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64` | - = help: the following implementations were found: - > + = help: the following other types implement trait `Traitor`: > + > error[E0277]: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied --> $DIR/rp_impl_trait_fail.rs:24:26 diff --git a/src/test/ui/const-generics/exhaustive-value.stderr b/src/test/ui/const-generics/exhaustive-value.stderr index fcbb41bb4fcc4..5613ed27cb234 100644 --- a/src/test/ui/const-generics/exhaustive-value.stderr +++ b/src/test/ui/const-generics/exhaustive-value.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `(): Foo` is not satisfied LL | <() as Foo>::test() | ^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()` | - = help: the following implementations were found: + = help: the following other types implement trait `Foo<0_u8>`: <() as Foo<0_u8>> <() as Foo<100_u8>> <() as Foo<101_u8>> diff --git a/src/test/ui/const-generics/issues/issue-67185-2.stderr b/src/test/ui/const-generics/issues/issue-67185-2.stderr index 89aa3d395e25b..c7be8e14a10d5 100644 --- a/src/test/ui/const-generics/issues/issue-67185-2.stderr +++ b/src/test/ui/const-generics/issues/issue-67185-2.stderr @@ -4,9 +4,9 @@ error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied LL | ::Quaks: Bar, | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `[u16; 3]` | - = help: the following implementations were found: - <[[u16; 3]; 3] as Bar> - <[u16; 4] as Bar> + = help: the following other types implement trait `Bar`: + [[u16; 3]; 3] + [u16; 4] = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable @@ -16,9 +16,9 @@ error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied LL | [::Quaks; 2]: Bar, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]` | - = help: the following implementations were found: - <[[u16; 3]; 3] as Bar> - <[u16; 4] as Bar> + = help: the following other types implement trait `Bar`: + [[u16; 3]; 3] + [u16; 4] = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable @@ -28,9 +28,9 @@ error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied LL | impl Foo for FooImpl {} | ^^^ the trait `Bar` is not implemented for `[u16; 3]` | - = help: the following implementations were found: - <[[u16; 3]; 3] as Bar> - <[u16; 4] as Bar> + = help: the following other types implement trait `Bar`: + [[u16; 3]; 3] + [u16; 4] note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:15:25 | @@ -46,9 +46,9 @@ error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied LL | impl Foo for FooImpl {} | ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]` | - = help: the following implementations were found: - <[[u16; 3]; 3] as Bar> - <[u16; 4] as Bar> + = help: the following other types implement trait `Bar`: + [[u16; 3]; 3] + [u16; 4] note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:14:30 | @@ -64,9 +64,9 @@ error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied LL | fn f(_: impl Foo) {} | ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]` | - = help: the following implementations were found: - <[[u16; 3]; 3] as Bar> - <[u16; 4] as Bar> + = help: the following other types implement trait `Bar`: + [[u16; 3]; 3] + [u16; 4] note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:14:30 | @@ -82,9 +82,9 @@ error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied LL | fn f(_: impl Foo) {} | ^^^ the trait `Bar` is not implemented for `[u16; 3]` | - = help: the following implementations were found: - <[[u16; 3]; 3] as Bar> - <[u16; 4] as Bar> + = help: the following other types implement trait `Bar`: + [[u16; 3]; 3] + [u16; 4] note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:15:25 | diff --git a/src/test/ui/const-generics/occurs-check/unused-substs-1.stderr b/src/test/ui/const-generics/occurs-check/unused-substs-1.stderr index aedf44658db63..8431d989278ba 100644 --- a/src/test/ui/const-generics/occurs-check/unused-substs-1.stderr +++ b/src/test/ui/const-generics/occurs-check/unused-substs-1.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `A<{_: usize}>: Bar<{_: usize}>` is not satisfied LL | let _ = A; | ^ the trait `Bar<{_: usize}>` is not implemented for `A<{_: usize}>` | - = help: the trait `Bar` is implemented for `A<{ 6 + 1 }>` + = help: the trait `Bar` is implemented for `A<7_usize>` note: required by a bound in `A` --> $DIR/unused-substs-1.rs:9:11 | diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr index d2d68506d4e1c..5fde557a32ad7 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr @@ -11,15 +11,15 @@ LL | = [0; (i8::MAX + 1u8) as usize]; | ^ no implementation for `i8 + u8` | = help: the trait `Add` is not implemented for `i8` - = help: the following implementations were found: - <&'a i8 as Add> - <&i8 as Add<&i8>> - > - + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> <&'a i16 as Add> + <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> and 48 others error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr index 818e3bc15b19d..3c192eef14f11 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr @@ -11,15 +11,15 @@ LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | ^ no implementation for `i8 + u8` | = help: the trait `Add` is not implemented for `i8` - = help: the following implementations were found: - <&'a i8 as Add> - <&i8 as Add<&i8>> - > - + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> <&'a i16 as Add> + <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> and 48 others error[E0604]: only `u8` can be cast as `char`, not `i8` diff --git a/src/test/ui/consts/too_generic_eval_ice.stderr b/src/test/ui/consts/too_generic_eval_ice.stderr index 45459b931caac..5544350c34cba 100644 --- a/src/test/ui/consts/too_generic_eval_ice.stderr +++ b/src/test/ui/consts/too_generic_eval_ice.stderr @@ -21,7 +21,7 @@ LL | [5; Self::HOST_SIZE] == [6; 0] | ^^ no implementation for `[{integer}; _] == [{integer}; 0]` | = help: the trait `PartialEq<[{integer}; 0]>` is not implemented for `[{integer}; _]` - = help: the following implementations were found: + = help: the following other types implement trait `PartialEq<[B; N]>`: <&[B] as PartialEq<[A; N]>> <&[T] as PartialEq>> <&mut [B] as PartialEq<[A; N]>> diff --git a/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.stderr b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.stderr index 8aedb4229e6d3..1c83f75ffb937 100644 --- a/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.stderr +++ b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `Bar: Foo` is not satisfied LL | f1.foo(1usize); | ^^^ the trait `Foo` is not implemented for `Bar` | - = help: the following implementations were found: + = help: the following other types implement trait `Foo`: > > diff --git a/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr index f25c7ce00e548..85f3eba927d06 100644 --- a/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr +++ b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `Bar: Foo` is not satisfied LL | f1.foo(1usize); | ^^^ the trait `Foo` is not implemented for `Bar` | - = help: the following implementations were found: + = help: the following other types implement trait `Foo`: > > > diff --git a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr index 3aa863e900f4a..e1d80313bc46b 100644 --- a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr +++ b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr @@ -6,7 +6,7 @@ LL | Foo::::bar(&1i8); | | | required by a bound introduced by this call | - = help: the following implementations were found: + = help: the following other types implement trait `Foo`: > > > @@ -25,16 +25,16 @@ LL | Foo::::bar(&1u8); | | | required by a bound introduced by this call | - = help: the following implementations were found: - > - > - > - > + = help: the following other types implement trait `Foo`: > > > > > + > + > + > + > error[E0277]: the trait bound `bool: Foo` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:26:21 @@ -44,7 +44,7 @@ LL | Foo::::bar(&true); | | | required by a bound introduced by this call | - = help: the following implementations were found: + = help: the following other types implement trait `Foo`: > > > diff --git a/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr b/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr index bd9d9e086e044..15af2c26e8fca 100644 --- a/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr +++ b/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr @@ -22,7 +22,7 @@ LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e−11; // m³⋅kg⁻¹ | ^ no implementation for `{float} - {integer}` | = help: the trait `Sub<{integer}>` is not implemented for `{float}` - = help: the following implementations were found: + = help: the following other types implement trait `Sub`: <&'a f32 as Sub> <&'a f64 as Sub> <&'a i128 as Sub> diff --git a/src/test/ui/generic-associated-types/bugs/issue-88460.stderr b/src/test/ui/generic-associated-types/bugs/issue-88460.stderr index ec8de15dc3957..98c304cc90b53 100644 --- a/src/test/ui/generic-associated-types/bugs/issue-88460.stderr +++ b/src/test/ui/generic-associated-types/bugs/issue-88460.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `for<'a> <_ as Trait>::Assoc<'a>: Marker` is not s LL | test(Foo); | ^^^^ the trait `for<'a> Marker` is not implemented for `<_ as Trait>::Assoc<'a>` | - = help: the trait `for<'a> Marker` is implemented for `()` + = help: the trait `Marker` is implemented for `()` note: required by a bound in `test` --> $DIR/issue-88460.rs:17:27 | diff --git a/src/test/ui/impl-trait/equality.stderr b/src/test/ui/impl-trait/equality.stderr index 9137183375aca..48cfcb4ad3e0a 100644 --- a/src/test/ui/impl-trait/equality.stderr +++ b/src/test/ui/impl-trait/equality.stderr @@ -24,15 +24,15 @@ LL | n + sum_to(n - 1) | ^ no implementation for `u32 + impl Foo` | = help: the trait `Add` is not implemented for `u32` - = help: the following implementations were found: - <&'a u32 as Add> - <&u32 as Add<&u32>> - > - + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> <&'a i16 as Add> + <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> and 48 others error: aborting due to 2 previous errors; 1 warning emitted diff --git a/src/test/ui/issues/issue-11771.stderr b/src/test/ui/issues/issue-11771.stderr index 019677775987e..ef15aa5840482 100644 --- a/src/test/ui/issues/issue-11771.stderr +++ b/src/test/ui/issues/issue-11771.stderr @@ -5,7 +5,7 @@ LL | 1 + | ^ no implementation for `{integer} + ()` | = help: the trait `Add<()>` is not implemented for `{integer}` - = help: the following implementations were found: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> @@ -23,7 +23,7 @@ LL | 1 + | ^ no implementation for `{integer} + ()` | = help: the trait `Add<()>` is not implemented for `{integer}` - = help: the following implementations were found: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> diff --git a/src/test/ui/issues/issue-24352.stderr b/src/test/ui/issues/issue-24352.stderr index 364fbbc981e64..1fa2d356c68ef 100644 --- a/src/test/ui/issues/issue-24352.stderr +++ b/src/test/ui/issues/issue-24352.stderr @@ -5,15 +5,15 @@ LL | 1.0f64 - 1 | ^ no implementation for `f64 - {integer}` | = help: the trait `Sub<{integer}>` is not implemented for `f64` - = help: the following implementations were found: - <&'a f64 as Sub> - <&f64 as Sub<&f64>> - > - + = help: the following other types implement trait `Sub`: <&'a f32 as Sub> + <&'a f64 as Sub> <&'a i128 as Sub> <&'a i16 as Sub> <&'a i32 as Sub> + <&'a i64 as Sub> + <&'a i8 as Sub> + <&'a isize as Sub> and 48 others help: consider using a floating-point literal by writing it with `.0` | diff --git a/src/test/ui/issues/issue-50582.stderr b/src/test/ui/issues/issue-50582.stderr index a1e614807de4a..d4e29030c1648 100644 --- a/src/test/ui/issues/issue-50582.stderr +++ b/src/test/ui/issues/issue-50582.stderr @@ -14,7 +14,7 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); | ^ no implementation for `{integer} + ()` | = help: the trait `Add<()>` is not implemented for `{integer}` - = help: the following implementations were found: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> diff --git a/src/test/ui/issues/issue-59488.stderr b/src/test/ui/issues/issue-59488.stderr index c61d44bf89526..76a47c49bbafb 100644 --- a/src/test/ui/issues/issue-59488.stderr +++ b/src/test/ui/issues/issue-59488.stderr @@ -94,15 +94,15 @@ LL | assert_eq!(Foo::Bar, i); | ^^^^^^^^^^^^^^^^^^^^^^^ `fn(usize) -> Foo {Foo::Bar}` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = help: the trait `Debug` is not implemented for `fn(usize) -> Foo {Foo::Bar}` - = help: the following implementations were found: - Ret as Debug> - Ret as Debug> - Ret as Debug> - Ret as Debug> - Ret as Debug> - Ret as Debug> - Ret as Debug> - Ret as Debug> + = help: the following other types implement trait `Debug`: + extern "C" fn() -> Ret + extern "C" fn(A) -> Ret + extern "C" fn(A, ...) -> Ret + extern "C" fn(A, B) -> Ret + extern "C" fn(A, B, ...) -> Ret + extern "C" fn(A, B, C) -> Ret + extern "C" fn(A, B, C, ...) -> Ret + extern "C" fn(A, B, C, D) -> Ret and 68 others = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/kindck/kindck-copy.stderr b/src/test/ui/kindck/kindck-copy.stderr index 29c9b872b5816..1c61c85368be9 100644 --- a/src/test/ui/kindck/kindck-copy.stderr +++ b/src/test/ui/kindck/kindck-copy.stderr @@ -4,15 +4,15 @@ error[E0277]: the trait bound `&'static mut isize: Copy` is not satisfied LL | assert_copy::<&'static mut isize>(); | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `&'static mut isize` | - = help: the following implementations were found: - - - - - - - - + = help: the following other types implement trait `Copy`: + f32 + f64 + i128 + i16 + i32 + i64 + i8 + isize and 6 others note: required by a bound in `assert_copy` --> $DIR/kindck-copy.rs:5:18 @@ -26,15 +26,15 @@ error[E0277]: the trait bound `&'a mut isize: Copy` is not satisfied LL | assert_copy::<&'a mut isize>(); | ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `&'a mut isize` | - = help: the following implementations were found: - - - - - - - - + = help: the following other types implement trait `Copy`: + f32 + f64 + i128 + i16 + i32 + i64 + i8 + isize and 6 others note: required by a bound in `assert_copy` --> $DIR/kindck-copy.rs:5:18 diff --git a/src/test/ui/lexer/lex-bad-char-literals-6.stderr b/src/test/ui/lexer/lex-bad-char-literals-6.stderr index 9df6c92d1e578..199958bc7e416 100644 --- a/src/test/ui/lexer/lex-bad-char-literals-6.stderr +++ b/src/test/ui/lexer/lex-bad-char-literals-6.stderr @@ -38,15 +38,15 @@ LL | if x == y {} | ^^ no implementation for `&str == char` | = help: the trait `PartialEq` is not implemented for `&str` - = help: the following implementations were found: + = help: the following other types implement trait `PartialEq>`: <&'a str as PartialEq> <&'a str as PartialEq> <&'b str as PartialEq>> + > + >> + > + >> - > - > - > - and 4 others error[E0308]: mismatched types @@ -64,15 +64,15 @@ LL | if x == z {} | ^^ no implementation for `&str == char` | = help: the trait `PartialEq` is not implemented for `&str` - = help: the following implementations were found: + = help: the following other types implement trait `PartialEq>`: <&'a str as PartialEq> <&'a str as PartialEq> <&'b str as PartialEq>> + > + >> + > + >> - > - > - > - and 4 others error: aborting due to 6 previous errors diff --git a/src/test/ui/mismatched_types/binops.stderr b/src/test/ui/mismatched_types/binops.stderr index 843ae5044c37a..16d1222899340 100644 --- a/src/test/ui/mismatched_types/binops.stderr +++ b/src/test/ui/mismatched_types/binops.stderr @@ -5,7 +5,7 @@ LL | 1 + Some(1); | ^ no implementation for `{integer} + Option<{integer}>` | = help: the trait `Add>` is not implemented for `{integer}` - = help: the following implementations were found: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> @@ -23,15 +23,15 @@ LL | 2 as usize - Some(1); | ^ no implementation for `usize - Option<{integer}>` | = help: the trait `Sub>` is not implemented for `usize` - = help: the following implementations were found: - <&'a usize as Sub> - <&usize as Sub<&usize>> - > - + = help: the following other types implement trait `Sub`: <&'a f32 as Sub> <&'a f64 as Sub> <&'a i128 as Sub> <&'a i16 as Sub> + <&'a i32 as Sub> + <&'a i64 as Sub> + <&'a i8 as Sub> + <&'a isize as Sub> and 48 others error[E0277]: cannot multiply `{integer}` by `()` @@ -41,7 +41,7 @@ LL | 3 * (); | ^ no implementation for `{integer} * ()` | = help: the trait `Mul<()>` is not implemented for `{integer}` - = help: the following implementations were found: + = help: the following other types implement trait `Mul`: <&'a f32 as Mul> <&'a f64 as Mul> <&'a i128 as Mul> @@ -59,7 +59,7 @@ LL | 4 / ""; | ^ no implementation for `{integer} / &str` | = help: the trait `Div<&str>` is not implemented for `{integer}` - = help: the following implementations were found: + = help: the following other types implement trait `Div`: <&'a f32 as Div> <&'a f64 as Div> <&'a i128 as Div> @@ -77,15 +77,15 @@ LL | 5 < String::new(); | ^ no implementation for `{integer} < String` and `{integer} > String` | = help: the trait `PartialOrd` is not implemented for `{integer}` - = help: the following implementations were found: - - - - - - - - + = help: the following other types implement trait `PartialOrd`: + f32 + f64 + i128 + i16 + i32 + i64 + i8 + isize and 6 others error[E0277]: can't compare `{integer}` with `Result<{integer}, _>` @@ -95,15 +95,15 @@ LL | 6 == Ok(1); | ^^ no implementation for `{integer} == Result<{integer}, _>` | = help: the trait `PartialEq>` is not implemented for `{integer}` - = help: the following implementations were found: - - - - - - - - + = help: the following other types implement trait `PartialEq`: + f32 + f64 + i128 + i16 + i32 + i64 + i8 + isize and 6 others error: aborting due to 6 previous errors diff --git a/src/test/ui/never_type/issue-13352.stderr b/src/test/ui/never_type/issue-13352.stderr index cfb5d28e7674b..449b0756012de 100644 --- a/src/test/ui/never_type/issue-13352.stderr +++ b/src/test/ui/never_type/issue-13352.stderr @@ -5,15 +5,15 @@ LL | 2_usize + (loop {}); | ^ no implementation for `usize + ()` | = help: the trait `Add<()>` is not implemented for `usize` - = help: the following implementations were found: - <&'a usize as Add> - <&usize as Add<&usize>> - > - + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> <&'a i16 as Add> + <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> and 48 others error: aborting due to previous error diff --git a/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr b/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr index 431cbf81b01bd..72cc4f6ec6469 100644 --- a/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr +++ b/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr @@ -5,15 +5,15 @@ LL | x + 100.0 | ^ no implementation for `u8 + {float}` | = help: the trait `Add<{float}>` is not implemented for `u8` - = help: the following implementations were found: - <&'a u8 as Add> - <&u8 as Add<&u8>> - > - + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> <&'a i16 as Add> + <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> and 48 others error[E0277]: cannot add `&str` to `f64` @@ -23,15 +23,15 @@ LL | x + "foo" | ^ no implementation for `f64 + &str` | = help: the trait `Add<&str>` is not implemented for `f64` - = help: the following implementations were found: - <&'a f64 as Add> - <&f64 as Add<&f64>> - > - + = help: the following other types implement trait `Add`: <&'a f32 as Add> + <&'a f64 as Add> <&'a i128 as Add> <&'a i16 as Add> <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> and 48 others error[E0277]: cannot add `{integer}` to `f64` @@ -41,15 +41,15 @@ LL | x + y | ^ no implementation for `f64 + {integer}` | = help: the trait `Add<{integer}>` is not implemented for `f64` - = help: the following implementations were found: - <&'a f64 as Add> - <&f64 as Add<&f64>> - > - + = help: the following other types implement trait `Add`: <&'a f32 as Add> + <&'a f64 as Add> <&'a i128 as Add> <&'a i16 as Add> <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> and 48 others error[E0277]: cannot subtract `{float}` from `u8` @@ -59,15 +59,15 @@ LL | x - 100.0 | ^ no implementation for `u8 - {float}` | = help: the trait `Sub<{float}>` is not implemented for `u8` - = help: the following implementations were found: - <&'a u8 as Sub> - <&u8 as Sub<&u8>> - > - + = help: the following other types implement trait `Sub`: <&'a f32 as Sub> <&'a f64 as Sub> <&'a i128 as Sub> <&'a i16 as Sub> + <&'a i32 as Sub> + <&'a i64 as Sub> + <&'a i8 as Sub> + <&'a isize as Sub> and 48 others error[E0277]: cannot subtract `&str` from `f64` @@ -77,15 +77,15 @@ LL | x - "foo" | ^ no implementation for `f64 - &str` | = help: the trait `Sub<&str>` is not implemented for `f64` - = help: the following implementations were found: - <&'a f64 as Sub> - <&f64 as Sub<&f64>> - > - + = help: the following other types implement trait `Sub`: <&'a f32 as Sub> + <&'a f64 as Sub> <&'a i128 as Sub> <&'a i16 as Sub> <&'a i32 as Sub> + <&'a i64 as Sub> + <&'a i8 as Sub> + <&'a isize as Sub> and 48 others error[E0277]: cannot subtract `{integer}` from `f64` @@ -95,15 +95,15 @@ LL | x - y | ^ no implementation for `f64 - {integer}` | = help: the trait `Sub<{integer}>` is not implemented for `f64` - = help: the following implementations were found: - <&'a f64 as Sub> - <&f64 as Sub<&f64>> - > - + = help: the following other types implement trait `Sub`: <&'a f32 as Sub> + <&'a f64 as Sub> <&'a i128 as Sub> <&'a i16 as Sub> <&'a i32 as Sub> + <&'a i64 as Sub> + <&'a i8 as Sub> + <&'a isize as Sub> and 48 others error[E0277]: cannot multiply `u8` by `{float}` @@ -113,15 +113,15 @@ LL | x * 100.0 | ^ no implementation for `u8 * {float}` | = help: the trait `Mul<{float}>` is not implemented for `u8` - = help: the following implementations were found: - <&'a u8 as Mul> - <&u8 as Mul<&u8>> - > - + = help: the following other types implement trait `Mul`: <&'a f32 as Mul> <&'a f64 as Mul> <&'a i128 as Mul> <&'a i16 as Mul> + <&'a i32 as Mul> + <&'a i64 as Mul> + <&'a i8 as Mul> + <&'a isize as Mul> and 49 others error[E0277]: cannot multiply `f64` by `&str` @@ -131,15 +131,15 @@ LL | x * "foo" | ^ no implementation for `f64 * &str` | = help: the trait `Mul<&str>` is not implemented for `f64` - = help: the following implementations were found: - <&'a f64 as Mul> - <&f64 as Mul<&f64>> - > - + = help: the following other types implement trait `Mul`: <&'a f32 as Mul> + <&'a f64 as Mul> <&'a i128 as Mul> <&'a i16 as Mul> <&'a i32 as Mul> + <&'a i64 as Mul> + <&'a i8 as Mul> + <&'a isize as Mul> and 49 others error[E0277]: cannot multiply `f64` by `{integer}` @@ -149,15 +149,15 @@ LL | x * y | ^ no implementation for `f64 * {integer}` | = help: the trait `Mul<{integer}>` is not implemented for `f64` - = help: the following implementations were found: - <&'a f64 as Mul> - <&f64 as Mul<&f64>> - > - + = help: the following other types implement trait `Mul`: <&'a f32 as Mul> + <&'a f64 as Mul> <&'a i128 as Mul> <&'a i16 as Mul> <&'a i32 as Mul> + <&'a i64 as Mul> + <&'a i8 as Mul> + <&'a isize as Mul> and 49 others error[E0277]: cannot divide `u8` by `{float}` @@ -167,15 +167,15 @@ LL | x / 100.0 | ^ no implementation for `u8 / {float}` | = help: the trait `Div<{float}>` is not implemented for `u8` - = help: the following implementations were found: - <&'a u8 as Div> - <&u8 as Div<&u8>> - > - > - + = help: the following other types implement trait `Div`: <&'a f32 as Div> <&'a f64 as Div> <&'a i128 as Div> + <&'a i16 as Div> + <&'a i32 as Div> + <&'a i64 as Div> + <&'a i8 as Div> + <&'a isize as Div> and 54 others error[E0277]: cannot divide `f64` by `&str` @@ -185,15 +185,15 @@ LL | x / "foo" | ^ no implementation for `f64 / &str` | = help: the trait `Div<&str>` is not implemented for `f64` - = help: the following implementations were found: - <&'a f64 as Div> - <&f64 as Div<&f64>> - > - + = help: the following other types implement trait `Div`: <&'a f32 as Div> + <&'a f64 as Div> <&'a i128 as Div> <&'a i16 as Div> <&'a i32 as Div> + <&'a i64 as Div> + <&'a i8 as Div> + <&'a isize as Div> and 54 others error[E0277]: cannot divide `f64` by `{integer}` @@ -203,15 +203,15 @@ LL | x / y | ^ no implementation for `f64 / {integer}` | = help: the trait `Div<{integer}>` is not implemented for `f64` - = help: the following implementations were found: - <&'a f64 as Div> - <&f64 as Div<&f64>> - > - + = help: the following other types implement trait `Div`: <&'a f32 as Div> + <&'a f64 as Div> <&'a i128 as Div> <&'a i16 as Div> <&'a i32 as Div> + <&'a i64 as Div> + <&'a i8 as Div> + <&'a isize as Div> and 54 others error: aborting due to 12 previous errors diff --git a/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr b/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr index 543e3137fdd09..fd3996416b67a 100644 --- a/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr +++ b/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr @@ -5,15 +5,15 @@ LL | x + 100 | ^ no implementation for `f32 + {integer}` | = help: the trait `Add<{integer}>` is not implemented for `f32` - = help: the following implementations were found: + = help: the following other types implement trait `Add`: <&'a f32 as Add> - <&f32 as Add<&f32>> - > - <&'a f64 as Add> <&'a i128 as Add> <&'a i16 as Add> <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> and 48 others help: consider using a floating-point literal by writing it with `.0` | @@ -27,15 +27,15 @@ LL | x + 100 | ^ no implementation for `f64 + {integer}` | = help: the trait `Add<{integer}>` is not implemented for `f64` - = help: the following implementations were found: - <&'a f64 as Add> - <&f64 as Add<&f64>> - > - + = help: the following other types implement trait `Add`: <&'a f32 as Add> + <&'a f64 as Add> <&'a i128 as Add> <&'a i16 as Add> <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> and 48 others help: consider using a floating-point literal by writing it with `.0` | @@ -49,15 +49,15 @@ LL | x - 100 | ^ no implementation for `f32 - {integer}` | = help: the trait `Sub<{integer}>` is not implemented for `f32` - = help: the following implementations were found: + = help: the following other types implement trait `Sub`: <&'a f32 as Sub> - <&f32 as Sub<&f32>> - > - <&'a f64 as Sub> <&'a i128 as Sub> <&'a i16 as Sub> <&'a i32 as Sub> + <&'a i64 as Sub> + <&'a i8 as Sub> + <&'a isize as Sub> and 48 others help: consider using a floating-point literal by writing it with `.0` | @@ -71,15 +71,15 @@ LL | x - 100 | ^ no implementation for `f64 - {integer}` | = help: the trait `Sub<{integer}>` is not implemented for `f64` - = help: the following implementations were found: - <&'a f64 as Sub> - <&f64 as Sub<&f64>> - > - + = help: the following other types implement trait `Sub`: <&'a f32 as Sub> + <&'a f64 as Sub> <&'a i128 as Sub> <&'a i16 as Sub> <&'a i32 as Sub> + <&'a i64 as Sub> + <&'a i8 as Sub> + <&'a isize as Sub> and 48 others help: consider using a floating-point literal by writing it with `.0` | @@ -93,15 +93,15 @@ LL | x * 100 | ^ no implementation for `f32 * {integer}` | = help: the trait `Mul<{integer}>` is not implemented for `f32` - = help: the following implementations were found: + = help: the following other types implement trait `Mul`: <&'a f32 as Mul> - <&f32 as Mul<&f32>> - > - <&'a f64 as Mul> <&'a i128 as Mul> <&'a i16 as Mul> <&'a i32 as Mul> + <&'a i64 as Mul> + <&'a i8 as Mul> + <&'a isize as Mul> and 49 others help: consider using a floating-point literal by writing it with `.0` | @@ -115,15 +115,15 @@ LL | x * 100 | ^ no implementation for `f64 * {integer}` | = help: the trait `Mul<{integer}>` is not implemented for `f64` - = help: the following implementations were found: - <&'a f64 as Mul> - <&f64 as Mul<&f64>> - > - + = help: the following other types implement trait `Mul`: <&'a f32 as Mul> + <&'a f64 as Mul> <&'a i128 as Mul> <&'a i16 as Mul> <&'a i32 as Mul> + <&'a i64 as Mul> + <&'a i8 as Mul> + <&'a isize as Mul> and 49 others help: consider using a floating-point literal by writing it with `.0` | @@ -137,15 +137,15 @@ LL | x / 100 | ^ no implementation for `f32 / {integer}` | = help: the trait `Div<{integer}>` is not implemented for `f32` - = help: the following implementations were found: + = help: the following other types implement trait `Div`: <&'a f32 as Div> - <&f32 as Div<&f32>> - > - <&'a f64 as Div> <&'a i128 as Div> <&'a i16 as Div> <&'a i32 as Div> + <&'a i64 as Div> + <&'a i8 as Div> + <&'a isize as Div> and 54 others help: consider using a floating-point literal by writing it with `.0` | @@ -159,15 +159,15 @@ LL | x / 100 | ^ no implementation for `f64 / {integer}` | = help: the trait `Div<{integer}>` is not implemented for `f64` - = help: the following implementations were found: - <&'a f64 as Div> - <&f64 as Div<&f64>> - > - + = help: the following other types implement trait `Div`: <&'a f32 as Div> + <&'a f64 as Div> <&'a i128 as Div> <&'a i16 as Div> <&'a i32 as Div> + <&'a i64 as Div> + <&'a i8 as Div> + <&'a isize as Div> and 54 others help: consider using a floating-point literal by writing it with `.0` | diff --git a/src/test/ui/on-unimplemented/multiple-impls.stderr b/src/test/ui/on-unimplemented/multiple-impls.stderr index be29d31d97b8e..ebe7f1f7a34a3 100644 --- a/src/test/ui/on-unimplemented/multiple-impls.stderr +++ b/src/test/ui/on-unimplemented/multiple-impls.stderr @@ -7,7 +7,7 @@ LL | Index::index(&[] as &[i32], 2u32); | required by a bound introduced by this call | = help: the trait `Index` is not implemented for `[i32]` - = help: the following implementations were found: + = help: the following other types implement trait `Index>`: <[i32] as Index>> <[i32] as Index>> @@ -20,7 +20,7 @@ LL | Index::index(&[] as &[i32], Foo(2u32)); | required by a bound introduced by this call | = help: the trait `Index>` is not implemented for `[i32]` - = help: the following implementations were found: + = help: the following other types implement trait `Index>`: <[i32] as Index>> <[i32] as Index>> @@ -33,7 +33,7 @@ LL | Index::index(&[] as &[i32], Bar(2u32)); | required by a bound introduced by this call | = help: the trait `Index>` is not implemented for `[i32]` - = help: the following implementations were found: + = help: the following other types implement trait `Index>`: <[i32] as Index>> <[i32] as Index>> @@ -44,7 +44,7 @@ LL | Index::index(&[] as &[i32], 2u32); | ^^^^^^^^^^^^ trait message | = help: the trait `Index` is not implemented for `[i32]` - = help: the following implementations were found: + = help: the following other types implement trait `Index>`: <[i32] as Index>> <[i32] as Index>> @@ -55,7 +55,7 @@ LL | Index::index(&[] as &[i32], Foo(2u32)); | ^^^^^^^^^^^^ on impl for Foo | = help: the trait `Index>` is not implemented for `[i32]` - = help: the following implementations were found: + = help: the following other types implement trait `Index>`: <[i32] as Index>> <[i32] as Index>> @@ -66,7 +66,7 @@ LL | Index::index(&[] as &[i32], Bar(2u32)); | ^^^^^^^^^^^^ on impl for Bar | = help: the trait `Index>` is not implemented for `[i32]` - = help: the following implementations were found: + = help: the following other types implement trait `Index>`: <[i32] as Index>> <[i32] as Index>> diff --git a/src/test/ui/on-unimplemented/slice-index.stderr b/src/test/ui/on-unimplemented/slice-index.stderr index 6dc27b5d4cc56..e90d08187ed90 100644 --- a/src/test/ui/on-unimplemented/slice-index.stderr +++ b/src/test/ui/on-unimplemented/slice-index.stderr @@ -15,7 +15,7 @@ LL | x[..1i32]; | ^^^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[i32]>` is not implemented for `RangeTo` - = help: the following implementations were found: + = help: the following other types implement trait `SliceIndex`: as SliceIndex<[T]>> as SliceIndex> = note: required because of the requirements on the impl of `Index>` for `[i32]` diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr index d87eceb1c9a7b..96a899ecca581 100644 --- a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr @@ -9,10 +9,10 @@ LL | | } | |_^ `main` can only return types that implement `Termination` | = help: the trait `Termination` is not implemented for `Result` - = help: the following implementations were found: - as Termination> - as Termination> - as Termination> + = help: the following other types implement trait `Termination`: + Result + Result<(), E> + Result note: required by a bound in `assert_test_result` --> $SRC_DIR/test/src/lib.rs:LL:COL | diff --git a/src/test/ui/span/multiline-span-simple.stderr b/src/test/ui/span/multiline-span-simple.stderr index dee457ebd7f3f..81dd7d03f919c 100644 --- a/src/test/ui/span/multiline-span-simple.stderr +++ b/src/test/ui/span/multiline-span-simple.stderr @@ -5,15 +5,15 @@ LL | foo(1 as u32 + | ^ no implementation for `u32 + ()` | = help: the trait `Add<()>` is not implemented for `u32` - = help: the following implementations were found: - <&'a u32 as Add> - <&u32 as Add<&u32>> - > - + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> <&'a i16 as Add> + <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> and 48 others error: aborting due to previous error diff --git a/src/test/ui/suggestions/into-str.stderr b/src/test/ui/suggestions/into-str.stderr index 88a0f8f065027..b7b92e0353485 100644 --- a/src/test/ui/suggestions/into-str.stderr +++ b/src/test/ui/suggestions/into-str.stderr @@ -7,7 +7,7 @@ LL | foo(String::new()); | required by a bound introduced by this call | = note: to coerce a `String` into a `&str`, use `&*` as a prefix - = help: the following implementations were found: + = help: the following other types implement trait `From`: > > > diff --git a/src/test/ui/suggestions/issue-71394-no-from-impl.stderr b/src/test/ui/suggestions/issue-71394-no-from-impl.stderr index 7972437771399..0f3d0e59e19bc 100644 --- a/src/test/ui/suggestions/issue-71394-no-from-impl.stderr +++ b/src/test/ui/suggestions/issue-71394-no-from-impl.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `&[i8]: From<&[u8]>` is not satisfied LL | let _: &[i8] = data.into(); | ^^^^ the trait `From<&[u8]>` is not implemented for `&[i8]` | - = help: the following implementations were found: + = help: the following other types implement trait `From>`: <[T; LANES] as From>> <[bool; LANES] as From>> = note: required because of the requirements on the impl of `Into<&[i8]>` for `&[u8]` diff --git a/src/test/ui/traits/bound/assoc-fn-bound-root-obligation.rs b/src/test/ui/traits/bound/assoc-fn-bound-root-obligation.rs index 2720f94a3c191..1d234518056fd 100644 --- a/src/test/ui/traits/bound/assoc-fn-bound-root-obligation.rs +++ b/src/test/ui/traits/bound/assoc-fn-bound-root-obligation.rs @@ -4,7 +4,7 @@ fn strip_lf(s: &str) -> &str { //~| NOTE expected an `FnMut<(char,)>` closure, found `u8` //~| NOTE required by a bound introduced by this call //~| HELP the trait `FnMut<(char,)>` is not implemented for `u8` - //~| HELP the following other types implement trait `Pattern<'_>`: + //~| HELP the following other types implement trait `Pattern<'a>`: //~| NOTE required because of the requirements on the impl of `Pattern<'_>` for `u8` } diff --git a/src/test/ui/traits/bound/assoc-fn-bound-root-obligation.stderr b/src/test/ui/traits/bound/assoc-fn-bound-root-obligation.stderr index 37cba4189d725..115539a6dc28d 100644 --- a/src/test/ui/traits/bound/assoc-fn-bound-root-obligation.stderr +++ b/src/test/ui/traits/bound/assoc-fn-bound-root-obligation.stderr @@ -7,7 +7,7 @@ LL | s.strip_suffix(b'\n').unwrap_or(s) | required by a bound introduced by this call | = help: the trait `FnMut<(char,)>` is not implemented for `u8` - = help: the following other types implement trait `Pattern<'_>`: + = help: the following other types implement trait `Pattern<'a>`: &'b String &'b [char; N] &'b [char] diff --git a/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr b/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr index 3645ad03cb9bb..0220cf4127ebf 100644 --- a/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr +++ b/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr @@ -4,7 +4,9 @@ error[E0277]: the trait bound `dyn CompareToInts: CompareTo` is not satisfi LL | c.same_as(22) | ^^^^^^^ the trait `CompareTo` is not implemented for `dyn CompareToInts` | - = help: the trait `CompareTo` is implemented for `i64` + = help: the following other types implement trait `CompareTo`: + > + > error[E0277]: the trait bound `C: CompareTo` is not satisfied --> $DIR/repeated-supertrait-ambig.rs:30:7 @@ -23,7 +25,9 @@ error[E0277]: the trait bound `dyn CompareToInts: CompareTo` is not satisfi LL | ::same_as(c, 22) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `CompareTo` is not implemented for `dyn CompareToInts` | - = help: the trait `CompareTo` is implemented for `i64` + = help: the following other types implement trait `CompareTo`: + > + > error[E0277]: the trait bound `C: CompareTo` is not satisfied --> $DIR/repeated-supertrait-ambig.rs:38:5 @@ -42,7 +46,7 @@ error[E0277]: the trait bound `i64: CompareTo` is not satisfied LL | assert_eq!(22_i64.same_as(22), true); | ^^^^^^^ the trait `CompareTo` is not implemented for `i64` | - = help: the following implementations were found: + = help: the following other types implement trait `CompareTo`: > > diff --git a/src/test/ui/traits/issue-79458.stderr b/src/test/ui/traits/issue-79458.stderr index b970012837313..cf2e4edf9f0a9 100644 --- a/src/test/ui/traits/issue-79458.stderr +++ b/src/test/ui/traits/issue-79458.stderr @@ -7,10 +7,10 @@ LL | struct Foo<'a, T> { LL | bar: &'a mut T | ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `&mut T` | - = help: the following implementations were found: - <&T as Clone> - <*const T as Clone> - <*mut T as Clone> + = help: the following other types implement trait `Clone`: + &T + *const T + *mut T = note: `Clone` is implemented for `&T`, but not for `&mut T` = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/traits/map-types.stderr b/src/test/ui/traits/map-types.stderr index 37bc5c6badc41..a4686edb71757 100644 --- a/src/test/ui/traits/map-types.stderr +++ b/src/test/ui/traits/map-types.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `Box>: Map` is LL | let y: Box> = Box::new(x); | ^^^^^^^^^^^ the trait `Map` is not implemented for `Box>` | - = help: the trait `Map` is implemented for `HashMap` + = help: the trait `Map` is implemented for `HashMap` = note: required for the cast to the object type `dyn Map` error: aborting due to previous error diff --git a/src/test/ui/try-trait/bad-interconversion.stderr b/src/test/ui/try-trait/bad-interconversion.stderr index 6567eca38c81d..1b46252ae89ec 100644 --- a/src/test/ui/try-trait/bad-interconversion.stderr +++ b/src/test/ui/try-trait/bad-interconversion.stderr @@ -7,15 +7,15 @@ LL | Ok(Err(123_i32)?) | ^ the trait `From` is not implemented for `u8` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait - = help: the following implementations were found: - > - > + = help: the following other types implement trait `From`: > > > > > > + > + > and 67 others = note: required because of the requirements on the impl of `FromResidual>` for `Result` diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr index 1372a018667c2..2fe115927c036 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `(): Foo` is not satisfied LL | fn foo() -> impl Foo { | ^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()` | - = help: the following implementations were found: + = help: the following other types implement trait `Foo`: <() as Foo<()>> <() as Foo> diff --git a/src/test/ui/type/type-check-defaults.stderr b/src/test/ui/type/type-check-defaults.stderr index 15bbfeb87c6f3..15deade2cd8f1 100644 --- a/src/test/ui/type/type-check-defaults.stderr +++ b/src/test/ui/type/type-check-defaults.stderr @@ -65,15 +65,15 @@ LL | trait ProjectionPred> where T::Item : Add {} | ^^^^^^^ no implementation for `i32 + u8` | = help: the trait `Add` is not implemented for `i32` - = help: the following implementations were found: - <&'a i32 as Add> - <&i32 as Add<&i32>> - > - + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> <&'a i16 as Add> + <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> and 48 others error: aborting due to 7 previous errors diff --git a/src/test/ui/typeck/issue-81293.stderr b/src/test/ui/typeck/issue-81293.stderr index 9e2d8a6159c48..00f490c465345 100644 --- a/src/test/ui/typeck/issue-81293.stderr +++ b/src/test/ui/typeck/issue-81293.stderr @@ -20,15 +20,15 @@ LL | a = c + b * 5; | ^ no implementation for `usize + u16` | = help: the trait `Add` is not implemented for `usize` - = help: the following implementations were found: - <&'a usize as Add> - <&usize as Add<&usize>> - > - + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> <&'a i16 as Add> + <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> and 48 others error: aborting due to 3 previous errors diff --git a/src/test/ui/typeck/issue-90101.stderr b/src/test/ui/typeck/issue-90101.stderr index 998b636887f23..b6d02285bd237 100644 --- a/src/test/ui/typeck/issue-90101.stderr +++ b/src/test/ui/typeck/issue-90101.stderr @@ -6,7 +6,7 @@ LL | func(Path::new("hello").to_path_buf().to_string_lossy(), "world") | | | required by a bound introduced by this call | - = help: the following implementations were found: + = help: the following other types implement trait `From>`: > >> >> diff --git a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr index 64da15c505536..09208527210f9 100644 --- a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr +++ b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr @@ -5,15 +5,15 @@ LL | >::add(1, 2); | ^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u32` | = help: the trait `Add` is not implemented for `i32` - = help: the following implementations were found: - <&'a i32 as Add> - <&i32 as Add<&i32>> - > - + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> <&'a i16 as Add> + <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> and 48 others error[E0308]: mismatched types From 3109c931b495f72fb9758bef15d38aeedc354ca1 Mon Sep 17 00:00:00 2001 From: Esteban Kuber Date: Sun, 27 Mar 2022 02:02:07 +0000 Subject: [PATCH 6/8] Refer to the TraitRef::identity in the message to be clearer --- .../src/traits/error_reporting/mod.rs | 4 ++-- src/test/ui/binop/binop-mul-i32-f32.stderr | 2 +- .../ui/binop/shift-various-bad-types.stderr | 6 ++--- .../defaults/rp_impl_trait_fail.stderr | 4 ++-- .../ui/const-generics/exhaustive-value.stderr | 2 +- .../const-eval/const-eval-overflow-3b.stderr | 2 +- .../const-eval/const-eval-overflow-4b.stderr | 2 +- .../ui/consts/too_generic_eval_ice.stderr | 2 +- ...e-21659-show-relevant-trait-impls-1.stderr | 2 +- ...e-21659-show-relevant-trait-impls-2.stderr | 2 +- .../issue-39802-show-5-trait-impls.stderr | 6 ++--- ...de-confusable-in-float-literal-expt.stderr | 2 +- src/test/ui/impl-trait/equality.stderr | 2 +- src/test/ui/issues/issue-11771.stderr | 4 ++-- src/test/ui/issues/issue-24352.stderr | 2 +- src/test/ui/issues/issue-50582.stderr | 2 +- .../ui/lexer/lex-bad-char-literals-6.stderr | 4 ++-- src/test/ui/mismatched_types/binops.stderr | 12 +++++----- src/test/ui/never_type/issue-13352.stderr | 2 +- .../not-suggest-float-literal.stderr | 24 +++++++++---------- .../suggest-float-literal.stderr | 16 ++++++------- .../ui/on-unimplemented/multiple-impls.stderr | 12 +++++----- .../ui/on-unimplemented/slice-index.stderr | 2 +- src/test/ui/span/multiline-span-simple.stderr | 2 +- src/test/ui/suggestions/into-str.stderr | 2 +- .../issue-71394-no-from-impl.stderr | 2 +- .../repeated-supertrait-ambig.stderr | 6 ++--- .../ui/try-trait/bad-interconversion.stderr | 2 +- .../nested-tait-inference2.stderr | 2 +- src/test/ui/type/type-check-defaults.stderr | 2 +- src/test/ui/typeck/issue-81293.stderr | 2 +- src/test/ui/typeck/issue-90101.stderr | 2 +- .../ui/ufcs/ufcs-qpath-self-mismatch.stderr | 2 +- 33 files changed, 71 insertions(+), 71 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 09b445058c0d3..88a4b6ee06d3a 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1763,13 +1763,12 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { if candidates.len() == 0 { return false; } - let trait_ref = candidates[0]; if candidates.len() == 1 { err.highlighted_help(vec![ ( format!( "the trait `{}` is implemented for `", - trait_ref.print_only_trait_path() + candidates[0].print_only_trait_path() ), Style::NoStyle, ), @@ -1778,6 +1777,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { ]); return true; } + let trait_ref = TraitRef::identity(self.tcx, candidates[0].def_id); // Check if the trait is the same in all cases. If so, we'll only show the type. // FIXME: there *has* to be a better way! let mut traits: Vec<_> = candidates diff --git a/src/test/ui/binop/binop-mul-i32-f32.stderr b/src/test/ui/binop/binop-mul-i32-f32.stderr index 453333fb56a87..21c490965b147 100644 --- a/src/test/ui/binop/binop-mul-i32-f32.stderr +++ b/src/test/ui/binop/binop-mul-i32-f32.stderr @@ -5,7 +5,7 @@ LL | x * y | ^ no implementation for `i32 * f32` | = help: the trait `Mul` is not implemented for `i32` - = help: the following other types implement trait `Mul`: + = help: the following other types implement trait `Mul`: <&'a f32 as Mul> <&'a f64 as Mul> <&'a i128 as Mul> diff --git a/src/test/ui/binop/shift-various-bad-types.stderr b/src/test/ui/binop/shift-various-bad-types.stderr index bb0bb63b22df5..38db66f86b461 100644 --- a/src/test/ui/binop/shift-various-bad-types.stderr +++ b/src/test/ui/binop/shift-various-bad-types.stderr @@ -5,7 +5,7 @@ LL | 22 >> p.char; | ^^ no implementation for `{integer} >> char` | = help: the trait `Shr` is not implemented for `{integer}` - = help: the following other types implement trait `Shr`: + = help: the following other types implement trait `Shr`: <&'a i128 as Shr> <&'a i128 as Shr> <&'a i128 as Shr> @@ -23,7 +23,7 @@ LL | 22 >> p.str; | ^^ no implementation for `{integer} >> &str` | = help: the trait `Shr<&str>` is not implemented for `{integer}` - = help: the following other types implement trait `Shr`: + = help: the following other types implement trait `Shr`: <&'a i128 as Shr> <&'a i128 as Shr> <&'a i128 as Shr> @@ -41,7 +41,7 @@ LL | 22 >> p; | ^^ no implementation for `{integer} >> &Panolpy` | = help: the trait `Shr<&Panolpy>` is not implemented for `{integer}` - = help: the following other types implement trait `Shr`: + = help: the following other types implement trait `Shr`: <&'a i128 as Shr> <&'a i128 as Shr> <&'a i128 as Shr> diff --git a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr index 4c9ab6901b1f5..1fb6b38e4a68f 100644 --- a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr +++ b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr @@ -25,7 +25,7 @@ error[E0277]: the trait bound `u32: Traitor` is not satisfied LL | fn uwu() -> impl Traitor { | ^^^^^^^^^^^^^^^ the trait `Traitor` is not implemented for `u32` | - = help: the following other types implement trait `Traitor`: + = help: the following other types implement trait `Traitor`: > > @@ -50,7 +50,7 @@ error[E0277]: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied LL | fn owo() -> impl Traitor { | ^^^^^^^^^^^^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64` | - = help: the following other types implement trait `Traitor`: + = help: the following other types implement trait `Traitor`: > > diff --git a/src/test/ui/const-generics/exhaustive-value.stderr b/src/test/ui/const-generics/exhaustive-value.stderr index 5613ed27cb234..9c1b086f4da9a 100644 --- a/src/test/ui/const-generics/exhaustive-value.stderr +++ b/src/test/ui/const-generics/exhaustive-value.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `(): Foo` is not satisfied LL | <() as Foo>::test() | ^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()` | - = help: the following other types implement trait `Foo<0_u8>`: + = help: the following other types implement trait `Foo`: <() as Foo<0_u8>> <() as Foo<100_u8>> <() as Foo<101_u8>> diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr index 5fde557a32ad7..0e6be6d01ed69 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr @@ -11,7 +11,7 @@ LL | = [0; (i8::MAX + 1u8) as usize]; | ^ no implementation for `i8 + u8` | = help: the trait `Add` is not implemented for `i8` - = help: the following other types implement trait `Add`: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr index 3c192eef14f11..4fa017e04e97b 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr @@ -11,7 +11,7 @@ LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | ^ no implementation for `i8 + u8` | = help: the trait `Add` is not implemented for `i8` - = help: the following other types implement trait `Add`: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> diff --git a/src/test/ui/consts/too_generic_eval_ice.stderr b/src/test/ui/consts/too_generic_eval_ice.stderr index 5544350c34cba..8de61fcfb7330 100644 --- a/src/test/ui/consts/too_generic_eval_ice.stderr +++ b/src/test/ui/consts/too_generic_eval_ice.stderr @@ -21,7 +21,7 @@ LL | [5; Self::HOST_SIZE] == [6; 0] | ^^ no implementation for `[{integer}; _] == [{integer}; 0]` | = help: the trait `PartialEq<[{integer}; 0]>` is not implemented for `[{integer}; _]` - = help: the following other types implement trait `PartialEq<[B; N]>`: + = help: the following other types implement trait `PartialEq`: <&[B] as PartialEq<[A; N]>> <&[T] as PartialEq>> <&mut [B] as PartialEq<[A; N]>> diff --git a/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.stderr b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.stderr index 1c83f75ffb937..26764bc0ee5cc 100644 --- a/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.stderr +++ b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `Bar: Foo` is not satisfied LL | f1.foo(1usize); | ^^^ the trait `Foo` is not implemented for `Bar` | - = help: the following other types implement trait `Foo`: + = help: the following other types implement trait `Foo`: > > diff --git a/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr index 85f3eba927d06..bb175367e1f9e 100644 --- a/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr +++ b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `Bar: Foo` is not satisfied LL | f1.foo(1usize); | ^^^ the trait `Foo` is not implemented for `Bar` | - = help: the following other types implement trait `Foo`: + = help: the following other types implement trait `Foo`: > > > diff --git a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr index e1d80313bc46b..d27b05fe7f7df 100644 --- a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr +++ b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr @@ -6,7 +6,7 @@ LL | Foo::::bar(&1i8); | | | required by a bound introduced by this call | - = help: the following other types implement trait `Foo`: + = help: the following other types implement trait `Foo`: > > > @@ -25,7 +25,7 @@ LL | Foo::::bar(&1u8); | | | required by a bound introduced by this call | - = help: the following other types implement trait `Foo`: + = help: the following other types implement trait `Foo`: > > > @@ -44,7 +44,7 @@ LL | Foo::::bar(&true); | | | required by a bound introduced by this call | - = help: the following other types implement trait `Foo`: + = help: the following other types implement trait `Foo`: > > > diff --git a/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr b/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr index 15af2c26e8fca..26986684f0c0a 100644 --- a/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr +++ b/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr @@ -22,7 +22,7 @@ LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e−11; // m³⋅kg⁻¹ | ^ no implementation for `{float} - {integer}` | = help: the trait `Sub<{integer}>` is not implemented for `{float}` - = help: the following other types implement trait `Sub`: + = help: the following other types implement trait `Sub`: <&'a f32 as Sub> <&'a f64 as Sub> <&'a i128 as Sub> diff --git a/src/test/ui/impl-trait/equality.stderr b/src/test/ui/impl-trait/equality.stderr index 48cfcb4ad3e0a..f14b447b07730 100644 --- a/src/test/ui/impl-trait/equality.stderr +++ b/src/test/ui/impl-trait/equality.stderr @@ -24,7 +24,7 @@ LL | n + sum_to(n - 1) | ^ no implementation for `u32 + impl Foo` | = help: the trait `Add` is not implemented for `u32` - = help: the following other types implement trait `Add`: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> diff --git a/src/test/ui/issues/issue-11771.stderr b/src/test/ui/issues/issue-11771.stderr index ef15aa5840482..161fce4b0315c 100644 --- a/src/test/ui/issues/issue-11771.stderr +++ b/src/test/ui/issues/issue-11771.stderr @@ -5,7 +5,7 @@ LL | 1 + | ^ no implementation for `{integer} + ()` | = help: the trait `Add<()>` is not implemented for `{integer}` - = help: the following other types implement trait `Add`: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> @@ -23,7 +23,7 @@ LL | 1 + | ^ no implementation for `{integer} + ()` | = help: the trait `Add<()>` is not implemented for `{integer}` - = help: the following other types implement trait `Add`: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> diff --git a/src/test/ui/issues/issue-24352.stderr b/src/test/ui/issues/issue-24352.stderr index 1fa2d356c68ef..118f37f6971ef 100644 --- a/src/test/ui/issues/issue-24352.stderr +++ b/src/test/ui/issues/issue-24352.stderr @@ -5,7 +5,7 @@ LL | 1.0f64 - 1 | ^ no implementation for `f64 - {integer}` | = help: the trait `Sub<{integer}>` is not implemented for `f64` - = help: the following other types implement trait `Sub`: + = help: the following other types implement trait `Sub`: <&'a f32 as Sub> <&'a f64 as Sub> <&'a i128 as Sub> diff --git a/src/test/ui/issues/issue-50582.stderr b/src/test/ui/issues/issue-50582.stderr index d4e29030c1648..3d527eb6b4e4a 100644 --- a/src/test/ui/issues/issue-50582.stderr +++ b/src/test/ui/issues/issue-50582.stderr @@ -14,7 +14,7 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); | ^ no implementation for `{integer} + ()` | = help: the trait `Add<()>` is not implemented for `{integer}` - = help: the following other types implement trait `Add`: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> diff --git a/src/test/ui/lexer/lex-bad-char-literals-6.stderr b/src/test/ui/lexer/lex-bad-char-literals-6.stderr index 199958bc7e416..afef0cb603485 100644 --- a/src/test/ui/lexer/lex-bad-char-literals-6.stderr +++ b/src/test/ui/lexer/lex-bad-char-literals-6.stderr @@ -38,7 +38,7 @@ LL | if x == y {} | ^^ no implementation for `&str == char` | = help: the trait `PartialEq` is not implemented for `&str` - = help: the following other types implement trait `PartialEq>`: + = help: the following other types implement trait `PartialEq`: <&'a str as PartialEq> <&'a str as PartialEq> <&'b str as PartialEq>> @@ -64,7 +64,7 @@ LL | if x == z {} | ^^ no implementation for `&str == char` | = help: the trait `PartialEq` is not implemented for `&str` - = help: the following other types implement trait `PartialEq>`: + = help: the following other types implement trait `PartialEq`: <&'a str as PartialEq> <&'a str as PartialEq> <&'b str as PartialEq>> diff --git a/src/test/ui/mismatched_types/binops.stderr b/src/test/ui/mismatched_types/binops.stderr index 16d1222899340..3de652d87ec54 100644 --- a/src/test/ui/mismatched_types/binops.stderr +++ b/src/test/ui/mismatched_types/binops.stderr @@ -5,7 +5,7 @@ LL | 1 + Some(1); | ^ no implementation for `{integer} + Option<{integer}>` | = help: the trait `Add>` is not implemented for `{integer}` - = help: the following other types implement trait `Add`: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> @@ -23,7 +23,7 @@ LL | 2 as usize - Some(1); | ^ no implementation for `usize - Option<{integer}>` | = help: the trait `Sub>` is not implemented for `usize` - = help: the following other types implement trait `Sub`: + = help: the following other types implement trait `Sub`: <&'a f32 as Sub> <&'a f64 as Sub> <&'a i128 as Sub> @@ -41,7 +41,7 @@ LL | 3 * (); | ^ no implementation for `{integer} * ()` | = help: the trait `Mul<()>` is not implemented for `{integer}` - = help: the following other types implement trait `Mul`: + = help: the following other types implement trait `Mul`: <&'a f32 as Mul> <&'a f64 as Mul> <&'a i128 as Mul> @@ -59,7 +59,7 @@ LL | 4 / ""; | ^ no implementation for `{integer} / &str` | = help: the trait `Div<&str>` is not implemented for `{integer}` - = help: the following other types implement trait `Div`: + = help: the following other types implement trait `Div`: <&'a f32 as Div> <&'a f64 as Div> <&'a i128 as Div> @@ -77,7 +77,7 @@ LL | 5 < String::new(); | ^ no implementation for `{integer} < String` and `{integer} > String` | = help: the trait `PartialOrd` is not implemented for `{integer}` - = help: the following other types implement trait `PartialOrd`: + = help: the following other types implement trait `PartialOrd`: f32 f64 i128 @@ -95,7 +95,7 @@ LL | 6 == Ok(1); | ^^ no implementation for `{integer} == Result<{integer}, _>` | = help: the trait `PartialEq>` is not implemented for `{integer}` - = help: the following other types implement trait `PartialEq`: + = help: the following other types implement trait `PartialEq`: f32 f64 i128 diff --git a/src/test/ui/never_type/issue-13352.stderr b/src/test/ui/never_type/issue-13352.stderr index 449b0756012de..fed780e68957f 100644 --- a/src/test/ui/never_type/issue-13352.stderr +++ b/src/test/ui/never_type/issue-13352.stderr @@ -5,7 +5,7 @@ LL | 2_usize + (loop {}); | ^ no implementation for `usize + ()` | = help: the trait `Add<()>` is not implemented for `usize` - = help: the following other types implement trait `Add`: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> diff --git a/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr b/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr index 72cc4f6ec6469..6aa1ad8dd899f 100644 --- a/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr +++ b/src/test/ui/numbers-arithmetic/not-suggest-float-literal.stderr @@ -5,7 +5,7 @@ LL | x + 100.0 | ^ no implementation for `u8 + {float}` | = help: the trait `Add<{float}>` is not implemented for `u8` - = help: the following other types implement trait `Add`: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> @@ -23,7 +23,7 @@ LL | x + "foo" | ^ no implementation for `f64 + &str` | = help: the trait `Add<&str>` is not implemented for `f64` - = help: the following other types implement trait `Add`: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> @@ -41,7 +41,7 @@ LL | x + y | ^ no implementation for `f64 + {integer}` | = help: the trait `Add<{integer}>` is not implemented for `f64` - = help: the following other types implement trait `Add`: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> @@ -59,7 +59,7 @@ LL | x - 100.0 | ^ no implementation for `u8 - {float}` | = help: the trait `Sub<{float}>` is not implemented for `u8` - = help: the following other types implement trait `Sub`: + = help: the following other types implement trait `Sub`: <&'a f32 as Sub> <&'a f64 as Sub> <&'a i128 as Sub> @@ -77,7 +77,7 @@ LL | x - "foo" | ^ no implementation for `f64 - &str` | = help: the trait `Sub<&str>` is not implemented for `f64` - = help: the following other types implement trait `Sub`: + = help: the following other types implement trait `Sub`: <&'a f32 as Sub> <&'a f64 as Sub> <&'a i128 as Sub> @@ -95,7 +95,7 @@ LL | x - y | ^ no implementation for `f64 - {integer}` | = help: the trait `Sub<{integer}>` is not implemented for `f64` - = help: the following other types implement trait `Sub`: + = help: the following other types implement trait `Sub`: <&'a f32 as Sub> <&'a f64 as Sub> <&'a i128 as Sub> @@ -113,7 +113,7 @@ LL | x * 100.0 | ^ no implementation for `u8 * {float}` | = help: the trait `Mul<{float}>` is not implemented for `u8` - = help: the following other types implement trait `Mul`: + = help: the following other types implement trait `Mul`: <&'a f32 as Mul> <&'a f64 as Mul> <&'a i128 as Mul> @@ -131,7 +131,7 @@ LL | x * "foo" | ^ no implementation for `f64 * &str` | = help: the trait `Mul<&str>` is not implemented for `f64` - = help: the following other types implement trait `Mul`: + = help: the following other types implement trait `Mul`: <&'a f32 as Mul> <&'a f64 as Mul> <&'a i128 as Mul> @@ -149,7 +149,7 @@ LL | x * y | ^ no implementation for `f64 * {integer}` | = help: the trait `Mul<{integer}>` is not implemented for `f64` - = help: the following other types implement trait `Mul`: + = help: the following other types implement trait `Mul`: <&'a f32 as Mul> <&'a f64 as Mul> <&'a i128 as Mul> @@ -167,7 +167,7 @@ LL | x / 100.0 | ^ no implementation for `u8 / {float}` | = help: the trait `Div<{float}>` is not implemented for `u8` - = help: the following other types implement trait `Div`: + = help: the following other types implement trait `Div`: <&'a f32 as Div> <&'a f64 as Div> <&'a i128 as Div> @@ -185,7 +185,7 @@ LL | x / "foo" | ^ no implementation for `f64 / &str` | = help: the trait `Div<&str>` is not implemented for `f64` - = help: the following other types implement trait `Div`: + = help: the following other types implement trait `Div`: <&'a f32 as Div> <&'a f64 as Div> <&'a i128 as Div> @@ -203,7 +203,7 @@ LL | x / y | ^ no implementation for `f64 / {integer}` | = help: the trait `Div<{integer}>` is not implemented for `f64` - = help: the following other types implement trait `Div`: + = help: the following other types implement trait `Div`: <&'a f32 as Div> <&'a f64 as Div> <&'a i128 as Div> diff --git a/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr b/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr index fd3996416b67a..988379e582a34 100644 --- a/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr +++ b/src/test/ui/numbers-arithmetic/suggest-float-literal.stderr @@ -5,7 +5,7 @@ LL | x + 100 | ^ no implementation for `f32 + {integer}` | = help: the trait `Add<{integer}>` is not implemented for `f32` - = help: the following other types implement trait `Add`: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> @@ -27,7 +27,7 @@ LL | x + 100 | ^ no implementation for `f64 + {integer}` | = help: the trait `Add<{integer}>` is not implemented for `f64` - = help: the following other types implement trait `Add`: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> @@ -49,7 +49,7 @@ LL | x - 100 | ^ no implementation for `f32 - {integer}` | = help: the trait `Sub<{integer}>` is not implemented for `f32` - = help: the following other types implement trait `Sub`: + = help: the following other types implement trait `Sub`: <&'a f32 as Sub> <&'a f64 as Sub> <&'a i128 as Sub> @@ -71,7 +71,7 @@ LL | x - 100 | ^ no implementation for `f64 - {integer}` | = help: the trait `Sub<{integer}>` is not implemented for `f64` - = help: the following other types implement trait `Sub`: + = help: the following other types implement trait `Sub`: <&'a f32 as Sub> <&'a f64 as Sub> <&'a i128 as Sub> @@ -93,7 +93,7 @@ LL | x * 100 | ^ no implementation for `f32 * {integer}` | = help: the trait `Mul<{integer}>` is not implemented for `f32` - = help: the following other types implement trait `Mul`: + = help: the following other types implement trait `Mul`: <&'a f32 as Mul> <&'a f64 as Mul> <&'a i128 as Mul> @@ -115,7 +115,7 @@ LL | x * 100 | ^ no implementation for `f64 * {integer}` | = help: the trait `Mul<{integer}>` is not implemented for `f64` - = help: the following other types implement trait `Mul`: + = help: the following other types implement trait `Mul`: <&'a f32 as Mul> <&'a f64 as Mul> <&'a i128 as Mul> @@ -137,7 +137,7 @@ LL | x / 100 | ^ no implementation for `f32 / {integer}` | = help: the trait `Div<{integer}>` is not implemented for `f32` - = help: the following other types implement trait `Div`: + = help: the following other types implement trait `Div`: <&'a f32 as Div> <&'a f64 as Div> <&'a i128 as Div> @@ -159,7 +159,7 @@ LL | x / 100 | ^ no implementation for `f64 / {integer}` | = help: the trait `Div<{integer}>` is not implemented for `f64` - = help: the following other types implement trait `Div`: + = help: the following other types implement trait `Div`: <&'a f32 as Div> <&'a f64 as Div> <&'a i128 as Div> diff --git a/src/test/ui/on-unimplemented/multiple-impls.stderr b/src/test/ui/on-unimplemented/multiple-impls.stderr index ebe7f1f7a34a3..06e1a222af881 100644 --- a/src/test/ui/on-unimplemented/multiple-impls.stderr +++ b/src/test/ui/on-unimplemented/multiple-impls.stderr @@ -7,7 +7,7 @@ LL | Index::index(&[] as &[i32], 2u32); | required by a bound introduced by this call | = help: the trait `Index` is not implemented for `[i32]` - = help: the following other types implement trait `Index>`: + = help: the following other types implement trait `Index`: <[i32] as Index>> <[i32] as Index>> @@ -20,7 +20,7 @@ LL | Index::index(&[] as &[i32], Foo(2u32)); | required by a bound introduced by this call | = help: the trait `Index>` is not implemented for `[i32]` - = help: the following other types implement trait `Index>`: + = help: the following other types implement trait `Index`: <[i32] as Index>> <[i32] as Index>> @@ -33,7 +33,7 @@ LL | Index::index(&[] as &[i32], Bar(2u32)); | required by a bound introduced by this call | = help: the trait `Index>` is not implemented for `[i32]` - = help: the following other types implement trait `Index>`: + = help: the following other types implement trait `Index`: <[i32] as Index>> <[i32] as Index>> @@ -44,7 +44,7 @@ LL | Index::index(&[] as &[i32], 2u32); | ^^^^^^^^^^^^ trait message | = help: the trait `Index` is not implemented for `[i32]` - = help: the following other types implement trait `Index>`: + = help: the following other types implement trait `Index`: <[i32] as Index>> <[i32] as Index>> @@ -55,7 +55,7 @@ LL | Index::index(&[] as &[i32], Foo(2u32)); | ^^^^^^^^^^^^ on impl for Foo | = help: the trait `Index>` is not implemented for `[i32]` - = help: the following other types implement trait `Index>`: + = help: the following other types implement trait `Index`: <[i32] as Index>> <[i32] as Index>> @@ -66,7 +66,7 @@ LL | Index::index(&[] as &[i32], Bar(2u32)); | ^^^^^^^^^^^^ on impl for Bar | = help: the trait `Index>` is not implemented for `[i32]` - = help: the following other types implement trait `Index>`: + = help: the following other types implement trait `Index`: <[i32] as Index>> <[i32] as Index>> diff --git a/src/test/ui/on-unimplemented/slice-index.stderr b/src/test/ui/on-unimplemented/slice-index.stderr index e90d08187ed90..ae7d2e1d82393 100644 --- a/src/test/ui/on-unimplemented/slice-index.stderr +++ b/src/test/ui/on-unimplemented/slice-index.stderr @@ -15,7 +15,7 @@ LL | x[..1i32]; | ^^^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[i32]>` is not implemented for `RangeTo` - = help: the following other types implement trait `SliceIndex`: + = help: the following other types implement trait `SliceIndex`: as SliceIndex<[T]>> as SliceIndex> = note: required because of the requirements on the impl of `Index>` for `[i32]` diff --git a/src/test/ui/span/multiline-span-simple.stderr b/src/test/ui/span/multiline-span-simple.stderr index 81dd7d03f919c..c0d9a8634e487 100644 --- a/src/test/ui/span/multiline-span-simple.stderr +++ b/src/test/ui/span/multiline-span-simple.stderr @@ -5,7 +5,7 @@ LL | foo(1 as u32 + | ^ no implementation for `u32 + ()` | = help: the trait `Add<()>` is not implemented for `u32` - = help: the following other types implement trait `Add`: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> diff --git a/src/test/ui/suggestions/into-str.stderr b/src/test/ui/suggestions/into-str.stderr index b7b92e0353485..8ae5c84794734 100644 --- a/src/test/ui/suggestions/into-str.stderr +++ b/src/test/ui/suggestions/into-str.stderr @@ -7,7 +7,7 @@ LL | foo(String::new()); | required by a bound introduced by this call | = note: to coerce a `String` into a `&str`, use `&*` as a prefix - = help: the following other types implement trait `From`: + = help: the following other types implement trait `From`: > > > diff --git a/src/test/ui/suggestions/issue-71394-no-from-impl.stderr b/src/test/ui/suggestions/issue-71394-no-from-impl.stderr index 0f3d0e59e19bc..383f40d47fa44 100644 --- a/src/test/ui/suggestions/issue-71394-no-from-impl.stderr +++ b/src/test/ui/suggestions/issue-71394-no-from-impl.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `&[i8]: From<&[u8]>` is not satisfied LL | let _: &[i8] = data.into(); | ^^^^ the trait `From<&[u8]>` is not implemented for `&[i8]` | - = help: the following other types implement trait `From>`: + = help: the following other types implement trait `From`: <[T; LANES] as From>> <[bool; LANES] as From>> = note: required because of the requirements on the impl of `Into<&[i8]>` for `&[u8]` diff --git a/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr b/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr index 0220cf4127ebf..cab0ccdf710da 100644 --- a/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr +++ b/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `dyn CompareToInts: CompareTo` is not satisfi LL | c.same_as(22) | ^^^^^^^ the trait `CompareTo` is not implemented for `dyn CompareToInts` | - = help: the following other types implement trait `CompareTo`: + = help: the following other types implement trait `CompareTo`: > > @@ -25,7 +25,7 @@ error[E0277]: the trait bound `dyn CompareToInts: CompareTo` is not satisfi LL | ::same_as(c, 22) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `CompareTo` is not implemented for `dyn CompareToInts` | - = help: the following other types implement trait `CompareTo`: + = help: the following other types implement trait `CompareTo`: > > @@ -46,7 +46,7 @@ error[E0277]: the trait bound `i64: CompareTo` is not satisfied LL | assert_eq!(22_i64.same_as(22), true); | ^^^^^^^ the trait `CompareTo` is not implemented for `i64` | - = help: the following other types implement trait `CompareTo`: + = help: the following other types implement trait `CompareTo`: > > diff --git a/src/test/ui/try-trait/bad-interconversion.stderr b/src/test/ui/try-trait/bad-interconversion.stderr index 1b46252ae89ec..1a4105231dc75 100644 --- a/src/test/ui/try-trait/bad-interconversion.stderr +++ b/src/test/ui/try-trait/bad-interconversion.stderr @@ -7,7 +7,7 @@ LL | Ok(Err(123_i32)?) | ^ the trait `From` is not implemented for `u8` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait - = help: the following other types implement trait `From`: + = help: the following other types implement trait `From`: > > > diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr index 2fe115927c036..9a3fd2f4005f3 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `(): Foo` is not satisfied LL | fn foo() -> impl Foo { | ^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()` | - = help: the following other types implement trait `Foo`: + = help: the following other types implement trait `Foo`: <() as Foo<()>> <() as Foo> diff --git a/src/test/ui/type/type-check-defaults.stderr b/src/test/ui/type/type-check-defaults.stderr index 15deade2cd8f1..f292877f30ea2 100644 --- a/src/test/ui/type/type-check-defaults.stderr +++ b/src/test/ui/type/type-check-defaults.stderr @@ -65,7 +65,7 @@ LL | trait ProjectionPred> where T::Item : Add {} | ^^^^^^^ no implementation for `i32 + u8` | = help: the trait `Add` is not implemented for `i32` - = help: the following other types implement trait `Add`: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> diff --git a/src/test/ui/typeck/issue-81293.stderr b/src/test/ui/typeck/issue-81293.stderr index 00f490c465345..9658288ac8b28 100644 --- a/src/test/ui/typeck/issue-81293.stderr +++ b/src/test/ui/typeck/issue-81293.stderr @@ -20,7 +20,7 @@ LL | a = c + b * 5; | ^ no implementation for `usize + u16` | = help: the trait `Add` is not implemented for `usize` - = help: the following other types implement trait `Add`: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> diff --git a/src/test/ui/typeck/issue-90101.stderr b/src/test/ui/typeck/issue-90101.stderr index b6d02285bd237..ab9a72edfe98d 100644 --- a/src/test/ui/typeck/issue-90101.stderr +++ b/src/test/ui/typeck/issue-90101.stderr @@ -6,7 +6,7 @@ LL | func(Path::new("hello").to_path_buf().to_string_lossy(), "world") | | | required by a bound introduced by this call | - = help: the following other types implement trait `From>`: + = help: the following other types implement trait `From`: > >> >> diff --git a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr index 09208527210f9..74766d9fdd1b1 100644 --- a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr +++ b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr @@ -5,7 +5,7 @@ LL | >::add(1, 2); | ^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u32` | = help: the trait `Add` is not implemented for `i32` - = help: the following other types implement trait `Add`: + = help: the following other types implement trait `Add`: <&'a f32 as Add> <&'a f64 as Add> <&'a i128 as Add> From a6301cab5e3512bf28c69e60e28e8253911702c9 Mon Sep 17 00:00:00 2001 From: Esteban Kuber Date: Sun, 27 Mar 2022 02:08:58 +0000 Subject: [PATCH 7/8] Highlight `is` in the message for emphasis --- .../src/traits/error_reporting/mod.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 88a4b6ee06d3a..de35f545f06c5 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1766,12 +1766,11 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { if candidates.len() == 1 { err.highlighted_help(vec![ ( - format!( - "the trait `{}` is implemented for `", - candidates[0].print_only_trait_path() - ), + format!("the trait `{}` ", candidates[0].print_only_trait_path()), Style::NoStyle, ), + ("is".to_string(), Style::Highlight), + (" implemented for `".to_string(), Style::NoStyle), (candidates[0].self_ty().to_string(), Style::Highlight), ("`".to_string(), Style::NoStyle), ]); From e1ef833bca8fe21cb2cbc42795cda4b589ec6f25 Mon Sep 17 00:00:00 2001 From: Esteban Kuber Date: Sun, 27 Mar 2022 02:14:54 +0000 Subject: [PATCH 8/8] Remove hack, fix fmt and tests --- .../src/traits/error_reporting/mod.rs | 9 ++-- .../defaults/rp_impl_trait_fail.stderr | 6 +-- .../kindck/kindck-impl-type-params.nll.stderr | 2 + .../suggest-deferences/root-obligation.fixed | 1 - .../suggest-deferences/root-obligation.rs | 1 - .../nested-tait-inference2.stderr | 2 +- .../self-referential-2.stderr | 14 ++++--- .../self-referential-4.stderr | 42 ++++++++++++------- .../self-referential.stderr | 42 ++++++++++++------- 9 files changed, 72 insertions(+), 47 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index de35f545f06c5..408c2ab9675e2 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1756,7 +1756,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { trait_ref: ty::PolyTraitRef<'tcx>, err: &mut Diagnostic, ) -> bool { - let report = |mut candidates: Vec>, err: &mut Diagnostic| { + let report = |mut candidates: Vec>, err: &mut Diagnostic| { candidates.sort(); candidates.dedup(); let len = candidates.len(); @@ -1778,11 +1778,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { } let trait_ref = TraitRef::identity(self.tcx, candidates[0].def_id); // Check if the trait is the same in all cases. If so, we'll only show the type. - // FIXME: there *has* to be a better way! - let mut traits: Vec<_> = candidates - .iter() - .map(|c| format!("{}", c).split(" as ").last().unwrap().to_string()) - .collect(); + let mut traits: Vec<_> = + candidates.iter().map(|c| c.print_only_trait_path().to_string()).collect(); traits.sort(); traits.dedup(); diff --git a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr index 1fb6b38e4a68f..48c61c22e7a32 100644 --- a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr +++ b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr @@ -40,7 +40,7 @@ LL | | 1_u32 LL | | } | |_^ the trait `Traitor` is not implemented for `u32` | - = help: the following implementations were found: + = help: the following other types implement trait `Traitor`: > > @@ -65,9 +65,9 @@ LL | | 1_u64 LL | | } | |_^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64` | - = help: the following implementations were found: - > + = help: the following other types implement trait `Traitor`: > + > error: aborting due to 6 previous errors diff --git a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr index 7129bad8a978a..94f802620a302 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr @@ -72,6 +72,7 @@ error[E0277]: the trait bound `String: Copy` is not satisfied LL | let a = t as Box>; | ^ the trait `Copy` is not implemented for `String` | + = help: the trait `Gettable` is implemented for `S` note: required because of the requirements on the impl of `Gettable` for `S` --> $DIR/kindck-impl-type-params.rs:14:32 | @@ -85,6 +86,7 @@ error[E0277]: the trait bound `Foo: Copy` is not satisfied LL | let a: Box> = t; | ^ the trait `Copy` is not implemented for `Foo` | + = help: the trait `Gettable` is implemented for `S` note: required because of the requirements on the impl of `Gettable` for `S` --> $DIR/kindck-impl-type-params.rs:14:32 | diff --git a/src/test/ui/traits/suggest-deferences/root-obligation.fixed b/src/test/ui/traits/suggest-deferences/root-obligation.fixed index 9fd1924067827..7a8433f90572e 100644 --- a/src/test/ui/traits/suggest-deferences/root-obligation.fixed +++ b/src/test/ui/traits/suggest-deferences/root-obligation.fixed @@ -11,4 +11,3 @@ fn get_vowel_count(string: &str) -> usize { fn main() { let _ = get_vowel_count("asdf"); } - diff --git a/src/test/ui/traits/suggest-deferences/root-obligation.rs b/src/test/ui/traits/suggest-deferences/root-obligation.rs index 4dd0291b62970..51bac2107e3b4 100644 --- a/src/test/ui/traits/suggest-deferences/root-obligation.rs +++ b/src/test/ui/traits/suggest-deferences/root-obligation.rs @@ -11,4 +11,3 @@ fn get_vowel_count(string: &str) -> usize { fn main() { let _ = get_vowel_count("asdf"); } - diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr index 9a3fd2f4005f3..264e8024fac3a 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr @@ -19,7 +19,7 @@ LL | | () LL | | } | |_^ the trait `Foo` is not implemented for `()` | - = help: the following implementations were found: + = help: the following other types implement trait `Foo`: <() as Foo<()>> <() as Foo> diff --git a/src/test/ui/type-alias-impl-trait/self-referential-2.stderr b/src/test/ui/type-alias-impl-trait/self-referential-2.stderr index b93ded6a7d3e1..348696f25e3b5 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential-2.stderr +++ b/src/test/ui/type-alias-impl-trait/self-referential-2.stderr @@ -5,11 +5,15 @@ LL | 42_i32 | ^^^^^^ no implementation for `i32 == Foo` | = help: the trait `PartialEq` is not implemented for `i32` - = help: the following implementations were found: - - - - + = help: the following other types implement trait `PartialEq`: + f32 + f64 + i128 + i16 + i32 + i64 + i8 + isize and 6 others error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/self-referential-4.stderr b/src/test/ui/type-alias-impl-trait/self-referential-4.stderr index 23ca689019634..838264794194c 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential-4.stderr +++ b/src/test/ui/type-alias-impl-trait/self-referential-4.stderr @@ -5,11 +5,15 @@ LL | i | ^ no implementation for `&i32 == Bar<'b, 'static>` | = help: the trait `PartialEq>` is not implemented for `&i32` - = help: the following implementations were found: - - - - + = help: the following other types implement trait `PartialEq`: + f32 + f64 + i128 + i16 + i32 + i64 + i8 + isize and 6 others error[E0277]: can't compare `&i32` with `Foo<'static, 'b>` @@ -19,11 +23,15 @@ LL | i | ^ no implementation for `&i32 == Foo<'static, 'b>` | = help: the trait `PartialEq>` is not implemented for `&i32` - = help: the following implementations were found: - - - - + = help: the following other types implement trait `PartialEq`: + f32 + f64 + i128 + i16 + i32 + i64 + i8 + isize and 6 others error[E0277]: can't compare `&i32` with `Moo<'static, 'a>` @@ -33,11 +41,15 @@ LL | i | ^ no implementation for `&i32 == Moo<'static, 'a>` | = help: the trait `PartialEq>` is not implemented for `&i32` - = help: the following implementations were found: - - - - + = help: the following other types implement trait `PartialEq`: + f32 + f64 + i128 + i16 + i32 + i64 + i8 + isize and 6 others error: aborting due to 3 previous errors diff --git a/src/test/ui/type-alias-impl-trait/self-referential.stderr b/src/test/ui/type-alias-impl-trait/self-referential.stderr index 4384bc9b98a7c..2ebb15b880308 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential.stderr +++ b/src/test/ui/type-alias-impl-trait/self-referential.stderr @@ -5,11 +5,15 @@ LL | i | ^ no implementation for `&i32 == Bar<'b, 'a>` | = help: the trait `PartialEq>` is not implemented for `&i32` - = help: the following implementations were found: - - - - + = help: the following other types implement trait `PartialEq`: + f32 + f64 + i128 + i16 + i32 + i64 + i8 + isize and 6 others error[E0277]: can't compare `&i32` with `(i32, &i32)` @@ -19,11 +23,15 @@ LL | (42, i) | ^ no implementation for `&i32 == (i32, &i32)` | = help: the trait `PartialEq<(i32, &i32)>` is not implemented for `&i32` - = help: the following implementations were found: - - - - + = help: the following other types implement trait `PartialEq`: + f32 + f64 + i128 + i16 + i32 + i64 + i8 + isize and 6 others error[E0277]: can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})` @@ -33,11 +41,15 @@ LL | (42, i) | ^ no implementation for `&i32 == (i32, Moo<'b, 'a>::{opaque#0})` | = help: the trait `PartialEq<(i32, Moo<'b, 'a>::{opaque#0})>` is not implemented for `&i32` - = help: the following implementations were found: - - - - + = help: the following other types implement trait `PartialEq`: + f32 + f64 + i128 + i16 + i32 + i64 + i8 + isize and 6 others error: aborting due to 3 previous errors