From bd7ea5441ec6e447d8dae1e69de7ef4320a2aa4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 3 Mar 2020 15:07:04 -0800 Subject: [PATCH] Use `PredicateObligation`s instead of `Predicate`s Keep more information about trait binding failures. --- src/librustc_infer/infer/outlives/verify.rs | 5 +- src/librustc_infer/traits/util.rs | 68 +++++++++++++------ src/librustc_mir/transform/const_prop.rs | 2 +- src/librustc_trait_selection/opaque_types.rs | 4 +- .../traits/auto_trait.rs | 3 +- .../traits/error_reporting/mod.rs | 6 +- .../error_reporting/on_unimplemented.rs | 4 +- .../traits/error_reporting/suggestions.rs | 5 +- src/librustc_trait_selection/traits/mod.rs | 4 +- .../traits/object_safety.rs | 2 +- .../traits/project.rs | 4 +- src/librustc_trait_selection/traits/wf.rs | 16 +++-- src/librustc_typeck/astconv.rs | 6 +- src/librustc_typeck/check/method/confirm.rs | 6 +- src/librustc_typeck/check/wfcheck.rs | 3 +- src/librustc_typeck/collect.rs | 2 +- .../impl_wf_check/min_specialization.rs | 5 +- .../bad-bounds-on-assoc-in-trait.stderr | 15 +++- ...associated-types-overridden-binding.stderr | 4 +- .../defaults-suitability.stderr | 6 +- src/test/ui/bad/bad-sized.stderr | 6 +- ...ds-cant-promote-superkind-in-struct.stderr | 2 +- .../ui/consts/too_generic_eval_ice.stderr | 4 +- ...derives-span-Eq-enum-struct-variant.stderr | 6 +- .../ui/derives/derives-span-Eq-enum.stderr | 6 +- .../ui/derives/derives-span-Eq-struct.stderr | 6 +- .../derives-span-Eq-tuple-struct.stderr | 6 +- src/test/ui/error-codes/E0275.stderr | 2 +- .../issue-62326-parameter-out-of-range.stderr | 4 +- .../generic-associated-types/iterable.stderr | 10 ++- src/test/ui/issues/issue-18919.rs | 5 ++ src/test/ui/issues/issue-18919.stderr | 4 +- src/test/ui/issues/issue-20005.stderr | 2 +- src/test/ui/issues/issue-20413.stderr | 4 +- src/test/ui/issues/issue-20433.stderr | 6 +- src/test/ui/issues/issue-21837.stderr | 2 +- src/test/ui/issues/issue-21974.stderr | 2 +- src/test/ui/issues/issue-23281.rs | 4 ++ src/test/ui/issues/issue-23281.stderr | 4 +- src/test/ui/issues/issue-24204.stderr | 4 +- src/test/ui/issues/issue-24424.stderr | 2 +- src/test/ui/iterators/bound.stderr | 2 +- .../recursion/recursive-requirements.stderr | 4 +- ...issing-assoc-type-bound-restriction.stderr | 10 ++- .../mut-borrow-needed-by-trait.stderr | 12 +++- .../negated-auto-traits-error.stderr | 2 +- .../traits/trait-alias/trait-alias-wf.stderr | 2 +- ...-bounds-on-structs-and-enums-in-fns.stderr | 4 +- ...ounds-on-structs-and-enums-in-impls.stderr | 2 +- ...-bounds-on-structs-and-enums-locals.stderr | 2 +- ...-bounds-on-structs-and-enums-static.stderr | 2 +- ...rait-bounds-on-structs-and-enums-xc.stderr | 10 ++- ...ait-bounds-on-structs-and-enums-xc1.stderr | 5 +- .../trait-bounds-on-structs-and-enums.stderr | 14 ++-- src/test/ui/type/type-check-defaults.stderr | 6 +- .../ui/type/type-check/issue-40294.stderr | 2 +- src/test/ui/union/union-derive-clone.stderr | 6 +- src/test/ui/union/union-derive-eq.stderr | 6 +- src/test/ui/unsized/unsized-enum.stderr | 2 +- .../unsized-inherent-impl-self-type.stderr | 2 +- src/test/ui/unsized/unsized-struct.stderr | 2 +- .../unsized-trait-impl-self-type.stderr | 2 +- src/test/ui/wf/wf-const-type.stderr | 2 +- src/test/ui/wf/wf-enum-bound.stderr | 2 +- .../wf/wf-enum-fields-struct-variant.stderr | 2 +- src/test/ui/wf/wf-enum-fields.stderr | 2 +- src/test/ui/wf/wf-fn-where-clause.rs | 3 + src/test/ui/wf/wf-fn-where-clause.stderr | 6 +- .../wf/wf-impl-associated-type-trait.stderr | 2 +- src/test/ui/wf/wf-in-fn-arg.stderr | 2 +- src/test/ui/wf/wf-in-fn-ret.stderr | 2 +- src/test/ui/wf/wf-in-fn-type-arg.stderr | 2 +- src/test/ui/wf/wf-in-fn-type-ret.stderr | 2 +- src/test/ui/wf/wf-in-fn-where-clause.stderr | 2 +- src/test/ui/wf/wf-in-obj-type-trait.stderr | 2 +- ...f-inherent-impl-method-where-clause.stderr | 2 +- .../wf/wf-inherent-impl-where-clause.stderr | 2 +- src/test/ui/wf/wf-static-type.stderr | 2 +- src/test/ui/wf/wf-struct-bound.stderr | 2 +- src/test/ui/wf/wf-struct-field.stderr | 2 +- .../wf/wf-trait-associated-type-bound.stderr | 2 +- .../wf/wf-trait-associated-type-trait.stderr | 2 +- src/test/ui/wf/wf-trait-bound.stderr | 2 +- src/test/ui/wf/wf-trait-default-fn-arg.stderr | 2 +- src/test/ui/wf/wf-trait-default-fn-ret.stderr | 2 +- .../wf-trait-default-fn-where-clause.stderr | 2 +- src/test/ui/wf/wf-trait-fn-arg.stderr | 2 +- src/test/ui/wf/wf-trait-fn-ret.stderr | 2 +- .../ui/wf/wf-trait-fn-where-clause.stderr | 2 +- src/test/ui/wf/wf-trait-superbound.stderr | 2 +- 90 files changed, 280 insertions(+), 141 deletions(-) diff --git a/src/librustc_infer/infer/outlives/verify.rs b/src/librustc_infer/infer/outlives/verify.rs index ed967f7ab3a..5b6db324e6c 100644 --- a/src/librustc_infer/infer/outlives/verify.rs +++ b/src/librustc_infer/infer/outlives/verify.rs @@ -296,7 +296,10 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> { let identity_proj = tcx.mk_projection(assoc_item_def_id, identity_substs); self.collect_outlives_from_predicate_list( move |ty| ty == identity_proj, - traits::elaborate_predicates(tcx, trait_predicates), + traits::elaborate_predicates(tcx, trait_predicates) + .into_iter() + .map(|o| o.predicate) + .collect::>(), ) .map(|b| b.1) } diff --git a/src/librustc_infer/traits/util.rs b/src/librustc_infer/traits/util.rs index 4fa74f93ddc..3f63d25fb47 100644 --- a/src/librustc_infer/traits/util.rs +++ b/src/librustc_infer/traits/util.rs @@ -1,8 +1,10 @@ use smallvec::smallvec; +use crate::traits::{Obligation, ObligationCause, PredicateObligation}; use rustc_data_structures::fx::FxHashSet; use rustc_middle::ty::outlives::Component; use rustc_middle::ty::{self, ToPolyTraitRef, ToPredicate, TyCtxt, WithConstness}; +use rustc_span::Span; pub fn anonymize_predicate<'tcx>( tcx: TyCtxt<'tcx>, @@ -87,7 +89,7 @@ impl>> Extend for PredicateSet<'tcx> { /// holds as well. Similarly, if we have `trait Foo: 'static`, and we know that /// `T: Foo`, then we know that `T: 'static`. pub struct Elaborator<'tcx> { - stack: Vec>, + stack: Vec>, visited: PredicateSet<'tcx>, } @@ -112,7 +114,29 @@ pub fn elaborate_predicates<'tcx>( ) -> Elaborator<'tcx> { let mut visited = PredicateSet::new(tcx); predicates.retain(|pred| visited.insert(pred)); - Elaborator { stack: predicates, visited } + let obligations: Vec<_> = + predicates.into_iter().map(|predicate| predicate_obligation(predicate, None)).collect(); + elaborate_obligations(tcx, obligations) +} + +pub fn elaborate_obligations<'tcx>( + tcx: TyCtxt<'tcx>, + mut obligations: Vec>, +) -> Elaborator<'tcx> { + let mut visited = PredicateSet::new(tcx); + obligations.retain(|obligation| visited.insert(&obligation.predicate)); + Elaborator { stack: obligations, visited } +} + +fn predicate_obligation<'tcx>( + predicate: ty::Predicate<'tcx>, + span: Option, +) -> PredicateObligation<'tcx> { + let mut cause = ObligationCause::dummy(); + if let Some(span) = span { + cause.span = span; + } + Obligation { cause, param_env: ty::ParamEnv::empty(), recursion_depth: 0, predicate } } impl Elaborator<'tcx> { @@ -120,27 +144,30 @@ impl Elaborator<'tcx> { FilterToTraits::new(self) } - fn elaborate(&mut self, predicate: &ty::Predicate<'tcx>) { + fn elaborate(&mut self, obligation: &PredicateObligation<'tcx>) { let tcx = self.visited.tcx; - match *predicate { + match obligation.predicate { ty::Predicate::Trait(ref data, _) => { // Get predicates declared on the trait. let predicates = tcx.super_predicates_of(data.def_id()); - let predicates = predicates - .predicates - .iter() - .map(|(pred, _)| pred.subst_supertrait(tcx, &data.to_poly_trait_ref())); - debug!("super_predicates: data={:?} predicates={:?}", data, predicates.clone()); + let obligations = predicates.predicates.iter().map(|(pred, span)| { + predicate_obligation( + pred.subst_supertrait(tcx, &data.to_poly_trait_ref()), + Some(*span), + ) + }); + debug!("super_predicates: data={:?} predicates={:?}", data, &obligations); // Only keep those bounds that we haven't already seen. // This is necessary to prevent infinite recursion in some // cases. One common case is when people define // `trait Sized: Sized { }` rather than `trait Sized { }`. let visited = &mut self.visited; - let predicates = predicates.filter(|pred| visited.insert(pred)); + let obligations = + obligations.filter(|obligation| visited.insert(&obligation.predicate)); - self.stack.extend(predicates); + self.stack.extend(obligations); } ty::Predicate::WellFormed(..) => { // Currently, we do not elaborate WF predicates, @@ -221,7 +248,8 @@ impl Elaborator<'tcx> { None } }) - .filter(|p| visited.insert(p)), + .filter(|p| visited.insert(p)) + .map(|p| predicate_obligation(p, None)), ); } } @@ -229,17 +257,17 @@ impl Elaborator<'tcx> { } impl Iterator for Elaborator<'tcx> { - type Item = ty::Predicate<'tcx>; + type Item = PredicateObligation<'tcx>; fn size_hint(&self) -> (usize, Option) { (self.stack.len(), None) } - fn next(&mut self) -> Option> { + fn next(&mut self) -> Option { // Extract next item from top-most stack frame, if any. - if let Some(pred) = self.stack.pop() { - self.elaborate(&pred); - Some(pred) + if let Some(obligation) = self.stack.pop() { + self.elaborate(&obligation); + Some(obligation) } else { None } @@ -282,12 +310,12 @@ impl FilterToTraits { } } -impl<'tcx, I: Iterator>> Iterator for FilterToTraits { +impl<'tcx, I: Iterator>> Iterator for FilterToTraits { type Item = ty::PolyTraitRef<'tcx>; fn next(&mut self) -> Option> { - while let Some(pred) = self.base_iterator.next() { - if let ty::Predicate::Trait(data, _) = pred { + while let Some(obligation) = self.base_iterator.next() { + if let ty::Predicate::Trait(data, _) = obligation.predicate { return Some(data.to_poly_trait_ref()); } } diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 25719d037f9..5a00f206a76 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -126,7 +126,7 @@ impl<'tcx> MirPass<'tcx> for ConstProp { .collect(); if !traits::normalize_and_test_predicates( tcx, - traits::elaborate_predicates(tcx, predicates).collect(), + traits::elaborate_predicates(tcx, predicates).map(|o| o.predicate).collect(), ) { trace!("ConstProp skipped for {:?}: found unsatisfiable predicates", source.def_id()); return; diff --git a/src/librustc_trait_selection/opaque_types.rs b/src/librustc_trait_selection/opaque_types.rs index 093873c849a..0cb26e08228 100644 --- a/src/librustc_trait_selection/opaque_types.rs +++ b/src/librustc_trait_selection/opaque_types.rs @@ -1255,8 +1255,8 @@ crate fn required_region_bounds( assert!(!erased_self_ty.has_escaping_bound_vars()); traits::elaborate_predicates(tcx, predicates) - .filter_map(|predicate| { - match predicate { + .filter_map(|obligation| { + match obligation.predicate { ty::Predicate::Projection(..) | ty::Predicate::Trait(..) | ty::Predicate::Subtype(..) diff --git a/src/librustc_trait_selection/traits/auto_trait.rs b/src/librustc_trait_selection/traits/auto_trait.rs index e01f5bfbcb3..b4c790eebc1 100644 --- a/src/librustc_trait_selection/traits/auto_trait.rs +++ b/src/librustc_trait_selection/traits/auto_trait.rs @@ -366,7 +366,8 @@ impl AutoTraitFinder<'tcx> { computed_preds.extend(user_computed_preds.iter().cloned()); let normalized_preds = - elaborate_predicates(tcx, computed_preds.iter().cloned().collect()); + elaborate_predicates(tcx, computed_preds.iter().cloned().collect()) + .map(|o| o.predicate); new_env = ty::ParamEnv::new(tcx.mk_predicates(normalized_preds), param_env.reveal, None); } diff --git a/src/librustc_trait_selection/traits/error_reporting/mod.rs b/src/librustc_trait_selection/traits/error_reporting/mod.rs index f0a157b3770..8cd8f679904 100644 --- a/src/librustc_trait_selection/traits/error_reporting/mod.rs +++ b/src/librustc_trait_selection/traits/error_reporting/mod.rs @@ -976,8 +976,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { } }; - for implication in super::elaborate_predicates(self.tcx, vec![*cond]) { - if let ty::Predicate::Trait(implication, _) = implication { + for obligation in super::elaborate_predicates(self.tcx, vec![*cond]) { + if let ty::Predicate::Trait(implication, _) = obligation.predicate { let error = error.to_poly_trait_ref(); let implication = implication.to_poly_trait_ref(); // FIXME: I'm just not taking associated types at all here. @@ -1387,7 +1387,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { (self.tcx.sess.source_map().span_to_snippet(span), &obligation.cause.code) { let generics = self.tcx.generics_of(*def_id); - if !generics.params.is_empty() && !snippet.ends_with('>') { + if generics.params.iter().filter(|p| p.name.as_str() != "Self").next().is_some() && !snippet.ends_with('>') { // FIXME: To avoid spurious suggestions in functions where type arguments // where already supplied, we check the snippet to make sure it doesn't // end with a turbofish. Ideally we would have access to a `PathSegment` diff --git a/src/librustc_trait_selection/traits/error_reporting/on_unimplemented.rs b/src/librustc_trait_selection/traits/error_reporting/on_unimplemented.rs index 213769d721d..1ecc7fdafc4 100644 --- a/src/librustc_trait_selection/traits/error_reporting/on_unimplemented.rs +++ b/src/librustc_trait_selection/traits/error_reporting/on_unimplemented.rs @@ -142,7 +142,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { } } - if let ObligationCauseCode::ItemObligation(item) = obligation.cause.code { + if let ObligationCauseCode::ItemObligation(item) + | ObligationCauseCode::BindingObligation(item, _) = obligation.cause.code + { // FIXME: maybe also have some way of handling methods // from other traits? That would require name resolution, // which we might want to be some sort of hygienic. diff --git a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs index a8fc56d8509..f9149b91b1f 100644 --- a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs +++ b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs @@ -1345,7 +1345,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { ObligationCauseCode::ItemObligation(item_def_id) => { let item_name = tcx.def_path_str(item_def_id); let msg = format!("required by `{}`", item_name); - if let Some(sp) = tcx.hir().span_if_local(item_def_id) { let sp = tcx.sess.source_map().guess_head_span(sp); err.span_label(sp, &msg); @@ -1357,7 +1356,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { let item_name = tcx.def_path_str(item_def_id); let msg = format!("required by this bound in `{}`", item_name); if let Some(ident) = tcx.opt_item_name(item_def_id) { - err.span_label(ident.span, ""); + if !ident.span.overlaps(span) { + err.span_label(ident.span, ""); + } } if span != DUMMY_SP { err.span_label(span, &msg); diff --git a/src/librustc_trait_selection/traits/mod.rs b/src/librustc_trait_selection/traits/mod.rs index 9a853c32eaa..6d0a3790fb0 100644 --- a/src/librustc_trait_selection/traits/mod.rs +++ b/src/librustc_trait_selection/traits/mod.rs @@ -297,7 +297,9 @@ pub fn normalize_param_env_or_error<'tcx>( ); let mut predicates: Vec<_> = - util::elaborate_predicates(tcx, unnormalized_env.caller_bounds.to_vec()).collect(); + util::elaborate_predicates(tcx, unnormalized_env.caller_bounds.to_vec()) + .map(|obligation| obligation.predicate) + .collect(); debug!("normalize_param_env_or_error: elaborated-predicates={:?}", predicates); diff --git a/src/librustc_trait_selection/traits/object_safety.rs b/src/librustc_trait_selection/traits/object_safety.rs index 3cb250891ef..117748fd064 100644 --- a/src/librustc_trait_selection/traits/object_safety.rs +++ b/src/librustc_trait_selection/traits/object_safety.rs @@ -298,7 +298,7 @@ fn generics_require_sized_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool { // Search for a predicate like `Self : Sized` amongst the trait bounds. let predicates = tcx.predicates_of(def_id); let predicates = predicates.instantiate_identity(tcx).predicates; - elaborate_predicates(tcx, predicates).any(|predicate| match predicate { + elaborate_predicates(tcx, predicates).any(|obligation| match obligation.predicate { ty::Predicate::Trait(ref trait_pred, _) => { trait_pred.def_id() == sized_def_id && trait_pred.skip_binder().self_ty().is_param(0) } diff --git a/src/librustc_trait_selection/traits/project.rs b/src/librustc_trait_selection/traits/project.rs index e4ca7d4cde7..4d02c5eb230 100644 --- a/src/librustc_trait_selection/traits/project.rs +++ b/src/librustc_trait_selection/traits/project.rs @@ -900,7 +900,7 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>( // If so, extract what we know from the trait and try to come up with a good answer. let trait_predicates = tcx.predicates_of(def_id); let bounds = trait_predicates.instantiate(tcx, substs); - let bounds = elaborate_predicates(tcx, bounds.predicates); + let bounds = elaborate_predicates(tcx, bounds.predicates).map(|o| o.predicate); assemble_candidates_from_predicates( selcx, obligation, @@ -1162,7 +1162,7 @@ fn confirm_object_candidate<'cx, 'tcx>( // select only those projections that are actually projecting an // item with the correct name - let env_predicates = env_predicates.filter_map(|p| match p { + let env_predicates = env_predicates.filter_map(|o| match o.predicate { ty::Predicate::Projection(data) => { if data.projection_def_id() == obligation.predicate.item_def_id { Some(data) diff --git a/src/librustc_trait_selection/traits/wf.rs b/src/librustc_trait_selection/traits/wf.rs index d506ddab909..63a6720b97d 100644 --- a/src/librustc_trait_selection/traits/wf.rs +++ b/src/librustc_trait_selection/traits/wf.rs @@ -312,19 +312,18 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { let item = self.item; if let Elaborate::All = elaborate { - let predicates = obligations.iter().map(|obligation| obligation.predicate).collect(); - let implied_obligations = traits::elaborate_predicates(tcx, predicates); - let implied_obligations = implied_obligations.map(|pred| { + let implied_obligations = traits::util::elaborate_obligations(tcx, obligations.clone()); + let implied_obligations = implied_obligations.map(|obligation| { let mut cause = cause.clone(); extend_cause_with_original_assoc_item_obligation( tcx, trait_ref, item, &mut cause, - &pred, + &obligation.predicate, tcx.associated_items(trait_ref.def_id).in_definition_order().copied(), ); - traits::Obligation::new(cause, param_env, pred) + traits::Obligation::new(cause, param_env, obligation.predicate) }); self.out.extend(implied_obligations); } @@ -613,11 +612,14 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { substs: SubstsRef<'tcx>, ) -> Vec> { let predicates = self.infcx.tcx.predicates_of(def_id).instantiate(self.infcx.tcx, substs); - let cause = self.cause(traits::ItemObligation(def_id)); predicates .predicates .into_iter() - .map(|pred| traits::Obligation::new(cause.clone(), self.param_env, pred)) + .zip(predicates.spans.into_iter()) + .map(|(pred, span)| { + let cause = self.cause(traits::BindingObligation(def_id, span)); + traits::Obligation::new(cause, self.param_env, pred) + }) .filter(|pred| !pred.has_escaping_bound_vars()) .collect() } diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index ed7ec1c3b10..a7a0564b9b6 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1601,12 +1601,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { for (base_trait_ref, span, constness) in regular_traits_refs_spans { assert_eq!(constness, Constness::NotConst); - for trait_ref in traits::elaborate_trait_ref(tcx, base_trait_ref) { + for obligation in traits::elaborate_trait_ref(tcx, base_trait_ref) { debug!( "conv_object_ty_poly_trait_ref: observing object predicate `{:?}`", - trait_ref + obligation.predicate ); - match trait_ref { + match obligation.predicate { ty::Predicate::Trait(pred, _) => { associated_types.entry(span).or_default().extend( tcx.associated_items(pred.def_id()) diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index a16555b3df0..210ba92e811 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -573,13 +573,15 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { }; traits::elaborate_predicates(self.tcx, predicates.predicates.clone()) - .filter_map(|predicate| match predicate { + .filter_map(|obligation| match obligation.predicate { ty::Predicate::Trait(trait_pred, _) if trait_pred.def_id() == sized_def_id => { let span = predicates .predicates .iter() .zip(predicates.spans.iter()) - .filter_map(|(p, span)| if *p == predicate { Some(*span) } else { None }) + .filter_map( + |(p, span)| if *p == obligation.predicate { Some(*span) } else { None }, + ) .next() .unwrap_or(rustc_span::DUMMY_SP); Some((trait_pred, span)) diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index b0ff17ad56d..8508c3510fa 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -1226,7 +1226,8 @@ fn check_false_global_bounds(fcx: &FnCtxt<'_, '_>, span: Span, id: hir::HirId) { // Check elaborated bounds. let implied_obligations = traits::elaborate_predicates(fcx.tcx, predicates); - for pred in implied_obligations { + for obligation in implied_obligations { + let pred = obligation.predicate; // Match the existing behavior. if pred.is_global() && !pred.has_late_bound_regions() { let pred = fcx.normalize_associated_types_in(span, &pred); diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index c5e9a288c9c..8c2040719a1 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1650,7 +1650,7 @@ fn predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicates<'_> { // prove that the trait applies to the types that were // used, and adding the predicate into this list ensures // that this is done. - let span = tcx.def_span(def_id); + let span = tcx.sess.source_map().guess_head_span(tcx.def_span(def_id)); result.predicates = tcx.arena.alloc_from_iter(result.predicates.iter().copied().chain(std::iter::once(( ty::TraitRef::identity(tcx, def_id).without_const().to_predicate(), diff --git a/src/librustc_typeck/impl_wf_check/min_specialization.rs b/src/librustc_typeck/impl_wf_check/min_specialization.rs index 559e478df06..ebfb3684eb0 100644 --- a/src/librustc_typeck/impl_wf_check/min_specialization.rs +++ b/src/librustc_typeck/impl_wf_check/min_specialization.rs @@ -348,7 +348,10 @@ fn check_predicates<'tcx>( .extend(obligations.into_iter().map(|obligation| obligation.predicate)) } } - impl2_predicates.predicates.extend(traits::elaborate_predicates(tcx, always_applicable_traits)); + impl2_predicates.predicates.extend( + traits::elaborate_predicates(tcx, always_applicable_traits) + .map(|obligation| obligation.predicate), + ); for predicate in impl1_predicates.predicates { if !impl2_predicates.predicates.contains(&predicate) { diff --git a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr index efd5a92a4fc..d5066e39ebc 100644 --- a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr +++ b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr @@ -20,7 +20,10 @@ error[E0277]: `<::C as std::iter::Iterator>::Item` cannot be sent be --> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20 | LL | trait Case1 { - | ----------- required by `Case1` + | ----- +LL | type C: Clone + Iterator() { | ^^^^^ - help: consider further restricting the associated type: `where <::C as std::iter::Iterator>::Item: std::marker::Send` @@ -33,7 +36,10 @@ error[E0277]: `<::C as std::iter::Iterator>::Item` cannot be shared --> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20 | LL | trait Case1 { - | ----------- required by `Case1` + | ----- +... +LL | > + Sync>; + | ---- required by this bound in `Case1` ... LL | fn assume_case1() { | ^^^^^ - help: consider further restricting the associated type: `where <::C as std::iter::Iterator>::Item: std::marker::Sync` @@ -46,7 +52,10 @@ error[E0277]: `<_ as Lam<&'a u8>>::App` doesn't implement `std::fmt::Debug` --> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20 | LL | trait Case1 { - | ----------- required by `Case1` + | ----- +... +LL | Debug + | ----- required by this bound in `Case1` ... LL | fn assume_case1() { | ^^^^^ `<_ as Lam<&'a u8>>::App` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` diff --git a/src/test/ui/associated-types/associated-types-overridden-binding.stderr b/src/test/ui/associated-types/associated-types-overridden-binding.stderr index 683a2ab21d9..76d00f9e6f2 100644 --- a/src/test/ui/associated-types/associated-types-overridden-binding.stderr +++ b/src/test/ui/associated-types/associated-types-overridden-binding.stderr @@ -2,7 +2,7 @@ error[E0284]: type annotations needed --> $DIR/associated-types-overridden-binding.rs:4:12 | LL | trait Foo: Iterator {} - | ------------------------------- required by `Foo` + | --- ---------- required by this bound in `Foo` LL | trait Bar: Foo {} | ^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self` | @@ -12,7 +12,7 @@ error[E0284]: type annotations needed --> $DIR/associated-types-overridden-binding.rs:7:21 | LL | trait I32Iterator = Iterator; - | ----------------------------------------- required by `I32Iterator` + | ----------- ---------- required by this bound in `I32Iterator` LL | trait U32Iterator = I32Iterator; | ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self` | diff --git a/src/test/ui/associated-types/defaults-suitability.stderr b/src/test/ui/associated-types/defaults-suitability.stderr index 54e39c4367d..3f6702da2a4 100644 --- a/src/test/ui/associated-types/defaults-suitability.stderr +++ b/src/test/ui/associated-types/defaults-suitability.stderr @@ -128,10 +128,14 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation | LL | type Ty = Vec<[u8]>; | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + ::: $SRC_DIR/liballoc/vec.rs:LL:COL + | +LL | pub struct Vec { + | - required by this bound in `std::vec::Vec` | = help: the trait `std::marker::Sized` is not implemented for `[u8]` = note: to learn more, visit - = note: required by `std::vec::Vec` error: aborting due to 11 previous errors diff --git a/src/test/ui/bad/bad-sized.stderr b/src/test/ui/bad/bad-sized.stderr index e9ded557281..5c169af4eb8 100644 --- a/src/test/ui/bad/bad-sized.stderr +++ b/src/test/ui/bad/bad-sized.stderr @@ -14,10 +14,14 @@ error[E0277]: the size for values of type `dyn Trait` cannot be known at compila | LL | let x: Vec = Vec::new(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + ::: $SRC_DIR/liballoc/vec.rs:LL:COL + | +LL | pub struct Vec { + | - required by this bound in `std::vec::Vec` | = help: the trait `std::marker::Sized` is not implemented for `dyn Trait` = note: to learn more, visit - = note: required by `std::vec::Vec` error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time --> $DIR/bad-sized.rs:4:37 diff --git a/src/test/ui/closures/closure-bounds-cant-promote-superkind-in-struct.stderr b/src/test/ui/closures/closure-bounds-cant-promote-superkind-in-struct.stderr index f565948f479..06eca0f692d 100644 --- a/src/test/ui/closures/closure-bounds-cant-promote-superkind-in-struct.stderr +++ b/src/test/ui/closures/closure-bounds-cant-promote-superkind-in-struct.stderr @@ -2,7 +2,7 @@ error[E0277]: `F` cannot be sent between threads safely --> $DIR/closure-bounds-cant-promote-superkind-in-struct.rs:5:22 | LL | struct X where F: FnOnce() + 'static + Send { - | ---------------------------------------------- required by `X` + | - ---- required by this bound in `X` ... LL | fn foo(blk: F) -> X where F: FnOnce() + 'static { | ^^^^ `F` cannot be sent between threads safely diff --git a/src/test/ui/consts/too_generic_eval_ice.stderr b/src/test/ui/consts/too_generic_eval_ice.stderr index ffa28225b79..e188d981010 100644 --- a/src/test/ui/consts/too_generic_eval_ice.stderr +++ b/src/test/ui/consts/too_generic_eval_ice.stderr @@ -15,7 +15,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim --> $DIR/too_generic_eval_ice.rs:7:13 | LL | pub struct Foo(A, B); - | --------------------------- required by `Foo` + | --- - required by this bound in `Foo` LL | LL | impl Foo { | - this type parameter needs to be `std::marker::Sized` @@ -30,7 +30,7 @@ error[E0277]: the size for values of type `B` cannot be known at compilation tim --> $DIR/too_generic_eval_ice.rs:7:13 | LL | pub struct Foo(A, B); - | --------------------------- required by `Foo` + | --- - required by this bound in `Foo` LL | LL | impl Foo { | - this type parameter needs to be `std::marker::Sized` diff --git a/src/test/ui/derives/derives-span-Eq-enum-struct-variant.stderr b/src/test/ui/derives/derives-span-Eq-enum-struct-variant.stderr index 704825c7b38..3d7487a4d92 100644 --- a/src/test/ui/derives/derives-span-Eq-enum-struct-variant.stderr +++ b/src/test/ui/derives/derives-span-Eq-enum-struct-variant.stderr @@ -3,8 +3,12 @@ error[E0277]: the trait bound `Error: std::cmp::Eq` is not satisfied | LL | x: Error | ^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `Error` + | + ::: $SRC_DIR/libcore/cmp.rs:LL:COL + | +LL | pub struct AssertParamIsEq { + | -- required by this bound in `std::cmp::AssertParamIsEq` | - = note: required by `std::cmp::AssertParamIsEq` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Eq-enum.stderr b/src/test/ui/derives/derives-span-Eq-enum.stderr index 8d2499614d8..00345243cac 100644 --- a/src/test/ui/derives/derives-span-Eq-enum.stderr +++ b/src/test/ui/derives/derives-span-Eq-enum.stderr @@ -3,8 +3,12 @@ error[E0277]: the trait bound `Error: std::cmp::Eq` is not satisfied | LL | Error | ^^^^^ the trait `std::cmp::Eq` is not implemented for `Error` + | + ::: $SRC_DIR/libcore/cmp.rs:LL:COL + | +LL | pub struct AssertParamIsEq { + | -- required by this bound in `std::cmp::AssertParamIsEq` | - = note: required by `std::cmp::AssertParamIsEq` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Eq-struct.stderr b/src/test/ui/derives/derives-span-Eq-struct.stderr index 22db0bf08b7..3d0efa1d147 100644 --- a/src/test/ui/derives/derives-span-Eq-struct.stderr +++ b/src/test/ui/derives/derives-span-Eq-struct.stderr @@ -3,8 +3,12 @@ error[E0277]: the trait bound `Error: std::cmp::Eq` is not satisfied | LL | x: Error | ^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `Error` + | + ::: $SRC_DIR/libcore/cmp.rs:LL:COL + | +LL | pub struct AssertParamIsEq { + | -- required by this bound in `std::cmp::AssertParamIsEq` | - = note: required by `std::cmp::AssertParamIsEq` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Eq-tuple-struct.stderr b/src/test/ui/derives/derives-span-Eq-tuple-struct.stderr index eaf14691ff0..2aec8ffdbe7 100644 --- a/src/test/ui/derives/derives-span-Eq-tuple-struct.stderr +++ b/src/test/ui/derives/derives-span-Eq-tuple-struct.stderr @@ -3,8 +3,12 @@ error[E0277]: the trait bound `Error: std::cmp::Eq` is not satisfied | LL | Error | ^^^^^ the trait `std::cmp::Eq` is not implemented for `Error` + | + ::: $SRC_DIR/libcore/cmp.rs:LL:COL + | +LL | pub struct AssertParamIsEq { + | -- required by this bound in `std::cmp::AssertParamIsEq` | - = note: required by `std::cmp::AssertParamIsEq` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0275.stderr b/src/test/ui/error-codes/E0275.stderr index c551a00096e..a9fd0564ff5 100644 --- a/src/test/ui/error-codes/E0275.stderr +++ b/src/test/ui/error-codes/E0275.stderr @@ -2,7 +2,7 @@ error[E0275]: overflow evaluating the requirement `Bar $DIR/E0275.rs:5:33 | LL | trait Foo {} - | --------- required by `Foo` + | --------- required by this bound in `Foo` ... LL | impl Foo for T where Bar: Foo {} | ^^^ diff --git a/src/test/ui/generic-associated-types/issue-62326-parameter-out-of-range.stderr b/src/test/ui/generic-associated-types/issue-62326-parameter-out-of-range.stderr index 68742396236..88b5c6a0a01 100644 --- a/src/test/ui/generic-associated-types/issue-62326-parameter-out-of-range.stderr +++ b/src/test/ui/generic-associated-types/issue-62326-parameter-out-of-range.stderr @@ -2,9 +2,9 @@ error[E0280]: the requirement `for<'a> ::Item<'a>: 'a` is not --> $DIR/issue-62326-parameter-out-of-range.rs:7:20 | LL | trait Iterator { - | -------------- required by `Iterator` + | -------- LL | type Item<'a>: 'a; - | ^^ + | ^^ required by this bound in `Iterator` error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/iterable.stderr b/src/test/ui/generic-associated-types/iterable.stderr index b5bc0c76c2f..dc62ee53c06 100644 --- a/src/test/ui/generic-associated-types/iterable.stderr +++ b/src/test/ui/generic-associated-types/iterable.stderr @@ -38,7 +38,10 @@ error[E0271]: type mismatch resolving `for<'a> < as Iterable>:: --> $DIR/iterable.rs:19:30 | LL | trait Iterable { - | -------------- required by `Iterable` + | -------- +LL | type Item<'a> where Self: 'a; +LL | type Iter<'a>: Iterator> where Self: 'a; + | --------------------- required by this bound in `Iterable` ... LL | fn iter<'a>(&'a self) -> Self::Iter<'a> { | ^^^^^^^^^^^^^^ expected associated type, found reference @@ -52,7 +55,10 @@ error[E0271]: type mismatch resolving `for<'a> <<[T] as Iterable>::Iter<'a> as s --> $DIR/iterable.rs:31:30 | LL | trait Iterable { - | -------------- required by `Iterable` + | -------- +LL | type Item<'a> where Self: 'a; +LL | type Iter<'a>: Iterator> where Self: 'a; + | --------------------- required by this bound in `Iterable` ... LL | fn iter<'a>(&'a self) -> Self::Iter<'a> { | ^^^^^^^^^^^^^^ expected associated type, found reference diff --git a/src/test/ui/issues/issue-18919.rs b/src/test/ui/issues/issue-18919.rs index 91fbb13cd69..f06771e9ea5 100644 --- a/src/test/ui/issues/issue-18919.rs +++ b/src/test/ui/issues/issue-18919.rs @@ -4,4 +4,9 @@ fn ho_func(f: Option) { //~^ ERROR the size for values of type } +enum Option { + Some(T), + None, +} + fn main() {} diff --git a/src/test/ui/issues/issue-18919.stderr b/src/test/ui/issues/issue-18919.stderr index c8b9045efe6..db94d00b60c 100644 --- a/src/test/ui/issues/issue-18919.stderr +++ b/src/test/ui/issues/issue-18919.stderr @@ -3,10 +3,12 @@ error[E0277]: the size for values of type `dyn for<'r> std::ops::Fn(&'r isize) - | LL | fn ho_func(f: Option) { | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time +... +LL | enum Option { + | ------ - required by this bound in `Option` | = help: the trait `std::marker::Sized` is not implemented for `dyn for<'r> std::ops::Fn(&'r isize) -> isize` = note: to learn more, visit - = note: required by `std::option::Option` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20005.stderr b/src/test/ui/issues/issue-20005.stderr index 529571a6b74..bcdebb2fa34 100644 --- a/src/test/ui/issues/issue-20005.stderr +++ b/src/test/ui/issues/issue-20005.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation --> $DIR/issue-20005.rs:10:49 | LL | trait From { - | --------------- required by `From` + | ---- --- required by this bound in `From` ... LL | ) -> >::Result where Dst: From { | ^^^^^^^^^^- help: consider further restricting `Self`: `, Self: std::marker::Sized` diff --git a/src/test/ui/issues/issue-20413.stderr b/src/test/ui/issues/issue-20413.stderr index 84e64ff74ae..ad33eef07cb 100644 --- a/src/test/ui/issues/issue-20413.stderr +++ b/src/test/ui/issues/issue-20413.stderr @@ -10,7 +10,7 @@ error[E0275]: overflow evaluating the requirement `NoData $DIR/issue-20413.rs:8:36 | LL | trait Foo { - | --------- required by `Foo` + | --------- required by this bound in `Foo` ... LL | impl Foo for T where NoData: Foo { | ^^^ @@ -148,7 +148,7 @@ error[E0275]: overflow evaluating the requirement `NoData $DIR/issue-20413.rs:8:36 | LL | trait Foo { - | --------- required by `Foo` + | --------- required by this bound in `Foo` ... LL | impl Foo for T where NoData: Foo { | ^^^ diff --git a/src/test/ui/issues/issue-20433.stderr b/src/test/ui/issues/issue-20433.stderr index abd2290952b..1dab637e489 100644 --- a/src/test/ui/issues/issue-20433.stderr +++ b/src/test/ui/issues/issue-20433.stderr @@ -3,10 +3,14 @@ error[E0277]: the size for values of type `[i32]` cannot be known at compilation | LL | fn iceman(c: Vec<[i32]>) {} | ^^^^^^^^^^ doesn't have a size known at compile-time + | + ::: $SRC_DIR/liballoc/vec.rs:LL:COL + | +LL | pub struct Vec { + | - required by this bound in `std::vec::Vec` | = help: the trait `std::marker::Sized` is not implemented for `[i32]` = note: to learn more, visit - = note: required by `std::vec::Vec` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-21837.stderr b/src/test/ui/issues/issue-21837.stderr index ff0c1ca64e2..42a61995ad9 100644 --- a/src/test/ui/issues/issue-21837.stderr +++ b/src/test/ui/issues/issue-21837.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: Bound` is not satisfied --> $DIR/issue-21837.rs:8:9 | LL | pub struct Foo(T); - | ---------------------------- required by `Foo` + | --- ----- required by this bound in `Foo` ... LL | impl Trait2 for Foo {} | ^^^^^^ the trait `Bound` is not implemented for `T` diff --git a/src/test/ui/issues/issue-21974.stderr b/src/test/ui/issues/issue-21974.stderr index d36d0dad4a1..fea2c7d5d26 100644 --- a/src/test/ui/issues/issue-21974.stderr +++ b/src/test/ui/issues/issue-21974.stderr @@ -2,7 +2,7 @@ error[E0283]: type annotations needed --> $DIR/issue-21974.rs:11:19 | LL | trait Foo { - | --------- required by `Foo` + | --------- required by this bound in `Foo` ... LL | where &'a T : Foo, | ^^^ cannot infer type for reference `&'a T` diff --git a/src/test/ui/issues/issue-23281.rs b/src/test/ui/issues/issue-23281.rs index d5f74728862..72716896426 100644 --- a/src/test/ui/issues/issue-23281.rs +++ b/src/test/ui/issues/issue-23281.rs @@ -5,4 +5,8 @@ impl Struct { //~^ ERROR the size for values of type } +struct Vec { + t: T, +} + fn main() {} diff --git a/src/test/ui/issues/issue-23281.stderr b/src/test/ui/issues/issue-23281.stderr index 68a90c6d80f..6aa6051f98a 100644 --- a/src/test/ui/issues/issue-23281.stderr +++ b/src/test/ui/issues/issue-23281.stderr @@ -3,10 +3,12 @@ error[E0277]: the size for values of type `(dyn std::ops::Fn() + 'static)` canno | LL | pub fn function(funs: Vec ()>) {} | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time +... +LL | struct Vec { + | --- - required by this bound in `Vec` | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::Fn() + 'static)` = note: to learn more, visit - = note: required by `std::vec::Vec` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-24204.stderr b/src/test/ui/issues/issue-24204.stderr index 2a714861da1..64d1b68cbed 100644 --- a/src/test/ui/issues/issue-24204.stderr +++ b/src/test/ui/issues/issue-24204.stderr @@ -2,7 +2,9 @@ error[E0271]: type mismatch resolving `<::A as MultiDispatch>:: --> $DIR/issue-24204.rs:14:12 | LL | trait Trait: Sized { - | ------------------ required by `Trait` + | ----- +LL | type A: MultiDispatch; + | -------- required by this bound in `Trait` ... LL | fn test>(b: i32) -> T where T::A: MultiDispatch { T::new(b) } | ^^^^^^^^^^^^ expected type parameter `T`, found associated type diff --git a/src/test/ui/issues/issue-24424.stderr b/src/test/ui/issues/issue-24424.stderr index f9338981408..9f5e934295b 100644 --- a/src/test/ui/issues/issue-24424.stderr +++ b/src/test/ui/issues/issue-24424.stderr @@ -2,7 +2,7 @@ error[E0283]: type annotations needed --> $DIR/issue-24424.rs:4:57 | LL | trait Trait0<'l0> {} - | ----------------- required by `Trait0` + | ----------------- required by this bound in `Trait0` LL | LL | impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {} | ^^^^^^^^^^^ cannot infer type for type parameter `T0` diff --git a/src/test/ui/iterators/bound.stderr b/src/test/ui/iterators/bound.stderr index 92a91ff4cb1..db5949b692c 100644 --- a/src/test/ui/iterators/bound.stderr +++ b/src/test/ui/iterators/bound.stderr @@ -2,7 +2,7 @@ error[E0277]: `u8` is not an iterator --> $DIR/bound.rs:2:10 | LL | struct S(I); - | ------------------------- required by `S` + | - -------- required by this bound in `S` LL | struct T(S); | ^^^^^ `u8` is not an iterator | diff --git a/src/test/ui/recursion/recursive-requirements.stderr b/src/test/ui/recursion/recursive-requirements.stderr index 9846c938ba9..5a1ef37f734 100644 --- a/src/test/ui/recursion/recursive-requirements.stderr +++ b/src/test/ui/recursion/recursive-requirements.stderr @@ -2,7 +2,7 @@ error[E0277]: `*const Bar` cannot be shared between threads safely --> $DIR/recursive-requirements.rs:16:12 | LL | struct AssertSync(PhantomData); - | ------------------------------------------- required by `AssertSync` + | ---------- ---- required by this bound in `AssertSync` ... LL | let _: AssertSync = unimplemented!(); | ^^^^^^^^^^^^^^^ `*const Bar` cannot be shared between threads safely @@ -14,7 +14,7 @@ error[E0277]: `*const Foo` cannot be shared between threads safely --> $DIR/recursive-requirements.rs:16:12 | LL | struct AssertSync(PhantomData); - | ------------------------------------------- required by `AssertSync` + | ---------- ---- required by this bound in `AssertSync` ... LL | let _: AssertSync = unimplemented!(); | ^^^^^^^^^^^^^^^ `*const Foo` cannot be shared between threads safely diff --git a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr index 31d974ed43d..6b985edae9e 100644 --- a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr +++ b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr @@ -2,7 +2,10 @@ error[E0277]: the trait bound `::Assoc: Child` is not satisfied --> $DIR/missing-assoc-type-bound-restriction.rs:17:19 | LL | trait Parent { - | ------------ required by `Parent` + | ------ +LL | type Ty; +LL | type Assoc: Child; + | --------------- required by this bound in `Parent` ... LL | impl> Parent for ParentWrapper { | ^^^^^^ - help: consider further restricting the associated type: `where ::Assoc: Child` @@ -29,7 +32,10 @@ error[E0277]: the trait bound `::Assoc: Child` is not satisfied --> $DIR/missing-assoc-type-bound-restriction.rs:20:5 | LL | trait Parent { - | ------------ required by `Parent` + | ------ +LL | type Ty; +LL | type Assoc: Child; + | --------------- required by this bound in `Parent` ... LL | impl> Parent for ParentWrapper { | - help: consider further restricting the associated type: `where ::Assoc: Child` diff --git a/src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr b/src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr index 57a389cbb49..9ccddda45e2 100644 --- a/src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr +++ b/src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr @@ -12,18 +12,26 @@ error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satis | LL | let fp = BufWriter::new(fp); | ^^^^^^^^^^^^^^ the trait `std::io::Write` is not implemented for `&dyn std::io::Write` + | + ::: $SRC_DIR/libstd/io/buffered.rs:LL:COL + | +LL | pub struct BufWriter { + | ----- required by this bound in `std::io::BufWriter` | = note: `std::io::Write` is implemented for `&mut dyn std::io::Write`, but not for `&dyn std::io::Write` - = note: required by `std::io::BufWriter` error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied --> $DIR/mut-borrow-needed-by-trait.rs:17:14 | LL | let fp = BufWriter::new(fp); | ^^^^^^^^^^^^^^^^^^ the trait `std::io::Write` is not implemented for `&dyn std::io::Write` + | + ::: $SRC_DIR/libstd/io/buffered.rs:LL:COL + | +LL | pub struct BufWriter { + | ----- required by this bound in `std::io::BufWriter` | = note: `std::io::Write` is implemented for `&mut dyn std::io::Write`, but not for `&dyn std::io::Write` - = note: required by `std::io::BufWriter` error[E0599]: no method named `write_fmt` found for struct `std::io::BufWriter<&dyn std::io::Write>` in the current scope --> $DIR/mut-borrow-needed-by-trait.rs:22:5 diff --git a/src/test/ui/traits/negative-impls/negated-auto-traits-error.stderr b/src/test/ui/traits/negative-impls/negated-auto-traits-error.stderr index 69a91b09e3e..ffed905eff2 100644 --- a/src/test/ui/traits/negative-impls/negated-auto-traits-error.stderr +++ b/src/test/ui/traits/negative-impls/negated-auto-traits-error.stderr @@ -13,7 +13,7 @@ error[E0277]: `dummy::TestType` cannot be sent between threads safely --> $DIR/negated-auto-traits-error.rs:23:5 | LL | struct Outer(T); - | ------------------------- required by `Outer` + | ----- ---- required by this bound in `Outer` ... LL | Outer(TestType); | ^^^^^^^^^^^^^^^ `dummy::TestType` cannot be sent between threads safely diff --git a/src/test/ui/traits/trait-alias/trait-alias-wf.stderr b/src/test/ui/traits/trait-alias/trait-alias-wf.stderr index ca4980ca305..84cde07ed89 100644 --- a/src/test/ui/traits/trait-alias/trait-alias-wf.stderr +++ b/src/test/ui/traits/trait-alias/trait-alias-wf.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: Foo` is not satisfied --> $DIR/trait-alias-wf.rs:5:14 | LL | trait A {} - | --------------- required by `A` + | - --- required by this bound in `A` LL | trait B = A; | ^^^^ the trait `Foo` is not implemented for `T` | diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-fns.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-fns.stderr index a2253021a7f..1b2511be6d0 100644 --- a/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-fns.stderr +++ b/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-fns.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `u32: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums-in-fns.rs:13:15 | LL | struct Foo { - | ------------------- required by `Foo` + | --- ----- required by this bound in `Foo` ... LL | fn explode(x: Foo) {} | ^^^^^^^^ the trait `Trait` is not implemented for `u32` @@ -11,7 +11,7 @@ error[E0277]: the trait bound `f32: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums-in-fns.rs:16:14 | LL | enum Bar { - | ----------------- required by `Bar` + | --- ----- required by this bound in `Bar` ... LL | fn kaboom(y: Bar) {} | ^^^^^^^^ the trait `Trait` is not implemented for `f32` diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-impls.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-impls.stderr index 7e8db610fe2..58dd68c1768 100644 --- a/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-impls.stderr +++ b/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-impls.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `u16: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums-in-impls.rs:20:6 | LL | struct Foo { - | ------------------- required by `Foo` + | --- ----- required by this bound in `Foo` ... LL | impl PolyTrait> for Struct { | ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `u16` diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-locals.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-locals.stderr index 070b7b013e5..f364fd1e14c 100644 --- a/src/test/ui/traits/trait-bounds-on-structs-and-enums-locals.stderr +++ b/src/test/ui/traits/trait-bounds-on-structs-and-enums-locals.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `usize: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums-locals.rs:15:14 | LL | struct Foo { - | ------------------- required by `Foo` + | --- ----- required by this bound in `Foo` ... LL | let baz: Foo = loop { }; | ^^^^^^^^^^ the trait `Trait` is not implemented for `usize` diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-static.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-static.stderr index 722f01750cb..17b1288bc6a 100644 --- a/src/test/ui/traits/trait-bounds-on-structs-and-enums-static.stderr +++ b/src/test/ui/traits/trait-bounds-on-structs-and-enums-static.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `usize: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums-static.rs:9:11 | LL | struct Foo { - | ------------------- required by `Foo` + | --- ----- required by this bound in `Foo` ... LL | static X: Foo = Foo { | ^^^^^^^^^^ the trait `Trait` is not implemented for `usize` diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc.stderr index c5a7746afdf..d2fa211b487 100644 --- a/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc.stderr +++ b/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc.stderr @@ -3,16 +3,22 @@ error[E0277]: the trait bound `usize: trait_bounds_on_structs_and_enums_xc::Trai | LL | fn explode(x: Foo) {} | ^^^^^^^^^^ the trait `trait_bounds_on_structs_and_enums_xc::Trait` is not implemented for `usize` + | + ::: $DIR/auxiliary/trait_bounds_on_structs_and_enums_xc.rs:5:18 | - = note: required by `trait_bounds_on_structs_and_enums_xc::Foo` +LL | pub struct Foo { + | ----- required by this bound in `trait_bounds_on_structs_and_enums_xc::Foo` error[E0277]: the trait bound `f32: trait_bounds_on_structs_and_enums_xc::Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums-xc.rs:10:14 | LL | fn kaboom(y: Bar) {} | ^^^^^^^^ the trait `trait_bounds_on_structs_and_enums_xc::Trait` is not implemented for `f32` + | + ::: $DIR/auxiliary/trait_bounds_on_structs_and_enums_xc.rs:9:16 | - = note: required by `trait_bounds_on_structs_and_enums_xc::Bar` +LL | pub enum Bar { + | ----- required by this bound in `trait_bounds_on_structs_and_enums_xc::Bar` error: aborting due to 2 previous errors diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc1.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc1.stderr index 57db65df5f3..ee3e755c953 100644 --- a/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc1.stderr +++ b/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc1.stderr @@ -3,8 +3,11 @@ error[E0277]: the trait bound `f64: trait_bounds_on_structs_and_enums_xc::Trait` | LL | let bar: Bar = return; | ^^^^^^^^ the trait `trait_bounds_on_structs_and_enums_xc::Trait` is not implemented for `f64` + | + ::: $DIR/auxiliary/trait_bounds_on_structs_and_enums_xc.rs:9:16 | - = note: required by `trait_bounds_on_structs_and_enums_xc::Bar` +LL | pub enum Bar { + | ----- required by this bound in `trait_bounds_on_structs_and_enums_xc::Bar` error[E0277]: the trait bound `{integer}: trait_bounds_on_structs_and_enums_xc::Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums-xc1.rs:8:15 diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums.stderr index 9e8e5e08145..16dba294b6c 100644 --- a/src/test/ui/traits/trait-bounds-on-structs-and-enums.stderr +++ b/src/test/ui/traits/trait-bounds-on-structs-and-enums.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums.rs:13:9 | LL | struct Foo { - | ------------------- required by `Foo` + | --- ----- required by this bound in `Foo` ... LL | impl Foo { | ^^^^^^ the trait `Trait` is not implemented for `T` @@ -16,7 +16,7 @@ error[E0277]: the trait bound `isize: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums.rs:19:5 | LL | struct Foo { - | ------------------- required by `Foo` + | --- ----- required by this bound in `Foo` ... LL | a: Foo, | ^^^^^^^^^^^^^ the trait `Trait` is not implemented for `isize` @@ -25,7 +25,7 @@ error[E0277]: the trait bound `usize: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums.rs:23:10 | LL | enum Bar { - | ----------------- required by `Bar` + | --- ----- required by this bound in `Bar` ... LL | Quux(Bar), | ^^^^^^^^^^ the trait `Trait` is not implemented for `usize` @@ -34,7 +34,7 @@ error[E0277]: the trait bound `U: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums.rs:27:5 | LL | struct Foo { - | ------------------- required by `Foo` + | --- ----- required by this bound in `Foo` ... LL | b: Foo, | ^^^^^^^^^ the trait `Trait` is not implemented for `U` @@ -48,7 +48,7 @@ error[E0277]: the trait bound `V: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums.rs:31:21 | LL | enum Bar { - | ----------------- required by `Bar` + | --- ----- required by this bound in `Bar` ... LL | EvenMoreBadness(Bar), | ^^^^^^ the trait `Trait` is not implemented for `V` @@ -62,7 +62,7 @@ error[E0277]: the trait bound `i32: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums.rs:35:5 | LL | struct Foo { - | ------------------- required by `Foo` + | --- ----- required by this bound in `Foo` ... LL | Foo, | ^^^^^^^^ the trait `Trait` is not implemented for `i32` @@ -71,7 +71,7 @@ error[E0277]: the trait bound `u8: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums.rs:39:22 | LL | enum Bar { - | ----------------- required by `Bar` + | --- ----- required by this bound in `Bar` ... LL | DictionaryLike { field: Bar }, | ^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `u8` diff --git a/src/test/ui/type/type-check-defaults.stderr b/src/test/ui/type/type-check-defaults.stderr index ca9b85bacba..4109bd70074 100644 --- a/src/test/ui/type/type-check-defaults.stderr +++ b/src/test/ui/type/type-check-defaults.stderr @@ -2,7 +2,7 @@ error[E0277]: a value of type `i32` cannot be built from an iterator over elemen --> $DIR/type-check-defaults.rs:6:19 | LL | struct Foo>(T, U); - | ---------------------------------------- required by `Foo` + | --- --------------- required by this bound in `Foo` LL | struct WellFormed>(Z); | ^ value of type `i32` cannot be built from `std::iter::Iterator` | @@ -12,7 +12,7 @@ error[E0277]: a value of type `i32` cannot be built from an iterator over elemen --> $DIR/type-check-defaults.rs:8:27 | LL | struct Foo>(T, U); - | ---------------------------------------- required by `Foo` + | --- --------------- required by this bound in `Foo` ... LL | struct WellFormedNoBounds>(Z); | ^ value of type `i32` cannot be built from `std::iter::Iterator` @@ -50,7 +50,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/type-check-defaults.rs:21:25 | LL | trait Super { } - | -------------------- required by `Super` + | ----- ---- required by this bound in `Super` LL | trait Base: Super { } | ^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` | diff --git a/src/test/ui/type/type-check/issue-40294.stderr b/src/test/ui/type/type-check/issue-40294.stderr index 7d81e0ce10c..ea7771a9c22 100644 --- a/src/test/ui/type/type-check/issue-40294.stderr +++ b/src/test/ui/type/type-check/issue-40294.stderr @@ -2,7 +2,7 @@ error[E0283]: type annotations needed --> $DIR/issue-40294.rs:6:19 | LL | trait Foo: Sized { - | ---------------- required by `Foo` + | ---------------- required by this bound in `Foo` ... LL | where &'a T : Foo, | ^^^ cannot infer type for reference `&'a T` diff --git a/src/test/ui/union/union-derive-clone.stderr b/src/test/ui/union/union-derive-clone.stderr index 66437611872..b536325810a 100644 --- a/src/test/ui/union/union-derive-clone.stderr +++ b/src/test/ui/union/union-derive-clone.stderr @@ -3,8 +3,12 @@ error[E0277]: the trait bound `U1: std::marker::Copy` is not satisfied | LL | #[derive(Clone)] | ^^^^^ the trait `std::marker::Copy` is not implemented for `U1` + | + ::: $SRC_DIR/libcore/clone.rs:LL:COL + | +LL | pub struct AssertParamIsCopy { + | ---- required by this bound in `std::clone::AssertParamIsCopy` | - = note: required by `std::clone::AssertParamIsCopy` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no method named `clone` found for union `U5` in the current scope diff --git a/src/test/ui/union/union-derive-eq.stderr b/src/test/ui/union/union-derive-eq.stderr index 0955c161871..ae0cd5af4b0 100644 --- a/src/test/ui/union/union-derive-eq.stderr +++ b/src/test/ui/union/union-derive-eq.stderr @@ -3,8 +3,12 @@ error[E0277]: the trait bound `PartialEqNotEq: std::cmp::Eq` is not satisfied | LL | a: PartialEqNotEq, | ^^^^^^^^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `PartialEqNotEq` + | + ::: $SRC_DIR/libcore/cmp.rs:LL:COL + | +LL | pub struct AssertParamIsEq { + | -- required by this bound in `std::cmp::AssertParamIsEq` | - = note: required by `std::cmp::AssertParamIsEq` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/unsized/unsized-enum.stderr b/src/test/ui/unsized/unsized-enum.stderr index 88f7b1f77ae..7f5ce5d02a5 100644 --- a/src/test/ui/unsized/unsized-enum.stderr +++ b/src/test/ui/unsized/unsized-enum.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/unsized-enum.rs:6:36 | LL | enum Foo { FooSome(U), FooNone } - | ----------- required by `Foo` + | --- - required by this bound in `Foo` LL | fn foo1() { not_sized::>() } // Hunky dory. LL | fn foo2() { not_sized::>() } | - ^^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr b/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr index 5688ae5b89a..990cea97723 100644 --- a/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr +++ b/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized-inherent-impl-self-type.rs:7:17 | LL | struct S5(Y); - | ---------------- required by `S5` + | -- - required by this bound in `S5` LL | LL | impl S5 { | - ^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/unsized/unsized-struct.stderr b/src/test/ui/unsized/unsized-struct.stderr index 653fb5c1ae8..b9e226ccbf1 100644 --- a/src/test/ui/unsized/unsized-struct.stderr +++ b/src/test/ui/unsized/unsized-struct.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/unsized-struct.rs:6:36 | LL | struct Foo { data: T } - | ------------- required by `Foo` + | --- - required by this bound in `Foo` LL | fn foo1() { not_sized::>() } // Hunky dory. LL | fn foo2() { not_sized::>() } | - ^^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/unsized/unsized-trait-impl-self-type.stderr b/src/test/ui/unsized/unsized-trait-impl-self-type.stderr index 3597073e7e6..08ceabecb27 100644 --- a/src/test/ui/unsized/unsized-trait-impl-self-type.stderr +++ b/src/test/ui/unsized/unsized-trait-impl-self-type.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized-trait-impl-self-type.rs:10:17 | LL | struct S5(Y); - | ---------------- required by `S5` + | -- - required by this bound in `S5` LL | LL | impl T3 for S5 { | - ^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/wf/wf-const-type.stderr b/src/test/ui/wf/wf-const-type.stderr index 531aadc25dd..22f31c9f79f 100644 --- a/src/test/ui/wf/wf-const-type.stderr +++ b/src/test/ui/wf/wf-const-type.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `NotCopy: std::marker::Copy` is not satisfied --> $DIR/wf-const-type.rs:10:12 | LL | struct IsCopy { t: T } - | --------------------- required by `IsCopy` + | ------ ---- required by this bound in `IsCopy` ... LL | const FOO: IsCopy> = IsCopy { t: None }; | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `NotCopy` diff --git a/src/test/ui/wf/wf-enum-bound.stderr b/src/test/ui/wf/wf-enum-bound.stderr index f70f67d414f..88d8c599022 100644 --- a/src/test/ui/wf/wf-enum-bound.stderr +++ b/src/test/ui/wf/wf-enum-bound.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied --> $DIR/wf-enum-bound.rs:10:14 | LL | trait ExtraCopy { } - | ----------------------- required by `ExtraCopy` + | --------- ---- required by this bound in `ExtraCopy` ... LL | where T: ExtraCopy | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` diff --git a/src/test/ui/wf/wf-enum-fields-struct-variant.stderr b/src/test/ui/wf/wf-enum-fields-struct-variant.stderr index 8634b7dba5c..d45ab952987 100644 --- a/src/test/ui/wf/wf-enum-fields-struct-variant.stderr +++ b/src/test/ui/wf/wf-enum-fields-struct-variant.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `A: std::marker::Copy` is not satisfied --> $DIR/wf-enum-fields-struct-variant.rs:13:9 | LL | struct IsCopy { - | --------------------- required by `IsCopy` + | ------ ---- required by this bound in `IsCopy` ... LL | f: IsCopy | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `A` diff --git a/src/test/ui/wf/wf-enum-fields.stderr b/src/test/ui/wf/wf-enum-fields.stderr index a22b2d11a91..013407bcc68 100644 --- a/src/test/ui/wf/wf-enum-fields.stderr +++ b/src/test/ui/wf/wf-enum-fields.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `A: std::marker::Copy` is not satisfied --> $DIR/wf-enum-fields.rs:12:17 | LL | struct IsCopy { - | --------------------- required by `IsCopy` + | ------ ---- required by this bound in `IsCopy` ... LL | SomeVariant(IsCopy) | ^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `A` diff --git a/src/test/ui/wf/wf-fn-where-clause.rs b/src/test/ui/wf/wf-fn-where-clause.rs index 5fd567bd32d..adae536138b 100644 --- a/src/test/ui/wf/wf-fn-where-clause.rs +++ b/src/test/ui/wf/wf-fn-where-clause.rs @@ -13,5 +13,8 @@ fn bar() where Vec:, {} //~^ ERROR E0277 //~| ERROR E0038 +struct Vec { + t: T, +} fn main() { } diff --git a/src/test/ui/wf/wf-fn-where-clause.stderr b/src/test/ui/wf/wf-fn-where-clause.stderr index cf1aeac7e3e..c5a7a5b0611 100644 --- a/src/test/ui/wf/wf-fn-where-clause.stderr +++ b/src/test/ui/wf/wf-fn-where-clause.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied --> $DIR/wf-fn-where-clause.rs:8:24 | LL | trait ExtraCopy { } - | ----------------------- required by `ExtraCopy` + | --------- ---- required by this bound in `ExtraCopy` LL | LL | fn foo() where T: ExtraCopy | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` @@ -17,10 +17,12 @@ error[E0277]: the size for values of type `(dyn std::marker::Copy + 'static)` ca | LL | fn bar() where Vec:, {} | ^^^^^^^^^^^^^ doesn't have a size known at compile-time +... +LL | struct Vec { + | --- - required by this bound in `Vec` | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::marker::Copy + 'static)` = note: to learn more, visit - = note: required by `std::vec::Vec` error[E0038]: the trait `std::marker::Copy` cannot be made into an object --> $DIR/wf-fn-where-clause.rs:12:16 diff --git a/src/test/ui/wf/wf-impl-associated-type-trait.stderr b/src/test/ui/wf/wf-impl-associated-type-trait.stderr index d44a6f01a47..7312233aa54 100644 --- a/src/test/ui/wf/wf-impl-associated-type-trait.stderr +++ b/src/test/ui/wf/wf-impl-associated-type-trait.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: MyHash` is not satisfied --> $DIR/wf-impl-associated-type-trait.rs:17:5 | LL | pub struct MySet { - | -------------------------- required by `MySet` + | ----- ------ required by this bound in `MySet` ... LL | type Bar = MySet; | ^^^^^^^^^^^^^^^^^^^^ the trait `MyHash` is not implemented for `T` diff --git a/src/test/ui/wf/wf-in-fn-arg.stderr b/src/test/ui/wf/wf-in-fn-arg.stderr index 907701440aa..67a5562b6bc 100644 --- a/src/test/ui/wf/wf-in-fn-arg.stderr +++ b/src/test/ui/wf/wf-in-fn-arg.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/wf-in-fn-arg.rs:10:14 | LL | struct MustBeCopy { - | ------------------------- required by `MustBeCopy` + | ---------- ---- required by this bound in `MustBeCopy` ... LL | fn bar(_: &MustBeCopy) | ^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/wf/wf-in-fn-ret.stderr b/src/test/ui/wf/wf-in-fn-ret.stderr index 2ed4eecefe1..545ee559b3f 100644 --- a/src/test/ui/wf/wf-in-fn-ret.stderr +++ b/src/test/ui/wf/wf-in-fn-ret.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/wf-in-fn-ret.rs:10:16 | LL | struct MustBeCopy { - | ------------------------- required by `MustBeCopy` + | ---------- ---- required by this bound in `MustBeCopy` ... LL | fn bar() -> MustBeCopy | ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/wf/wf-in-fn-type-arg.stderr b/src/test/ui/wf/wf-in-fn-type-arg.stderr index 0c699838abd..0d8c6b14c56 100644 --- a/src/test/ui/wf/wf-in-fn-type-arg.stderr +++ b/src/test/ui/wf/wf-in-fn-type-arg.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/wf-in-fn-type-arg.rs:9:5 | LL | struct MustBeCopy { - | ------------------------- required by `MustBeCopy` + | ---------- ---- required by this bound in `MustBeCopy` ... LL | x: fn(MustBeCopy) | ^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/wf/wf-in-fn-type-ret.stderr b/src/test/ui/wf/wf-in-fn-type-ret.stderr index 3429ab89ffb..b7c8bf303f3 100644 --- a/src/test/ui/wf/wf-in-fn-type-ret.stderr +++ b/src/test/ui/wf/wf-in-fn-type-ret.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/wf-in-fn-type-ret.rs:9:5 | LL | struct MustBeCopy { - | ------------------------- required by `MustBeCopy` + | ---------- ---- required by this bound in `MustBeCopy` ... LL | x: fn() -> MustBeCopy | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/wf/wf-in-fn-where-clause.stderr b/src/test/ui/wf/wf-in-fn-where-clause.stderr index d33749d795c..e54cc17ccbe 100644 --- a/src/test/ui/wf/wf-in-fn-where-clause.stderr +++ b/src/test/ui/wf/wf-in-fn-where-clause.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied --> $DIR/wf-in-fn-where-clause.rs:10:14 | LL | trait MustBeCopy { - | ------------------------ required by `MustBeCopy` + | ---------- ---- required by this bound in `MustBeCopy` ... LL | where T: MustBeCopy | ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` diff --git a/src/test/ui/wf/wf-in-obj-type-trait.stderr b/src/test/ui/wf/wf-in-obj-type-trait.stderr index 605dc497849..699c3fe1a63 100644 --- a/src/test/ui/wf/wf-in-obj-type-trait.stderr +++ b/src/test/ui/wf/wf-in-obj-type-trait.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/wf-in-obj-type-trait.rs:11:5 | LL | struct MustBeCopy { - | ------------------------- required by `MustBeCopy` + | ---------- ---- required by this bound in `MustBeCopy` ... LL | x: dyn Object> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/wf/wf-inherent-impl-method-where-clause.stderr b/src/test/ui/wf/wf-inherent-impl-method-where-clause.stderr index da2f8085a8a..172e763650a 100644 --- a/src/test/ui/wf/wf-inherent-impl-method-where-clause.stderr +++ b/src/test/ui/wf/wf-inherent-impl-method-where-clause.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied --> $DIR/wf-inherent-impl-method-where-clause.rs:12:27 | LL | trait ExtraCopy { } - | ----------------------- required by `ExtraCopy` + | --------- ---- required by this bound in `ExtraCopy` ... LL | fn foo(self) where T: ExtraCopy | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` diff --git a/src/test/ui/wf/wf-inherent-impl-where-clause.stderr b/src/test/ui/wf/wf-inherent-impl-where-clause.stderr index 28d5bc62556..1ac5aba3cad 100644 --- a/src/test/ui/wf/wf-inherent-impl-where-clause.stderr +++ b/src/test/ui/wf/wf-inherent-impl-where-clause.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied --> $DIR/wf-inherent-impl-where-clause.rs:11:29 | LL | trait ExtraCopy { } - | ----------------------- required by `ExtraCopy` + | --------- ---- required by this bound in `ExtraCopy` ... LL | impl Foo where T: ExtraCopy | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` diff --git a/src/test/ui/wf/wf-static-type.stderr b/src/test/ui/wf/wf-static-type.stderr index 05a628d7c3e..ec31710e861 100644 --- a/src/test/ui/wf/wf-static-type.stderr +++ b/src/test/ui/wf/wf-static-type.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `NotCopy: std::marker::Copy` is not satisfied --> $DIR/wf-static-type.rs:10:13 | LL | struct IsCopy { t: T } - | --------------------- required by `IsCopy` + | ------ ---- required by this bound in `IsCopy` ... LL | static FOO: IsCopy> = IsCopy { t: None }; | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `NotCopy` diff --git a/src/test/ui/wf/wf-struct-bound.stderr b/src/test/ui/wf/wf-struct-bound.stderr index 07e569ddac1..848a2eb8bee 100644 --- a/src/test/ui/wf/wf-struct-bound.stderr +++ b/src/test/ui/wf/wf-struct-bound.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied --> $DIR/wf-struct-bound.rs:10:14 | LL | trait ExtraCopy { } - | ----------------------- required by `ExtraCopy` + | --------- ---- required by this bound in `ExtraCopy` ... LL | where T: ExtraCopy | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` diff --git a/src/test/ui/wf/wf-struct-field.stderr b/src/test/ui/wf/wf-struct-field.stderr index f3bce24eace..a748a1c9c39 100644 --- a/src/test/ui/wf/wf-struct-field.stderr +++ b/src/test/ui/wf/wf-struct-field.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `A: std::marker::Copy` is not satisfied --> $DIR/wf-struct-field.rs:12:5 | LL | struct IsCopy { - | --------------------- required by `IsCopy` + | ------ ---- required by this bound in `IsCopy` ... LL | data: IsCopy | ^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `A` diff --git a/src/test/ui/wf/wf-trait-associated-type-bound.stderr b/src/test/ui/wf/wf-trait-associated-type-bound.stderr index 6cf7f2069b6..e568acabcd0 100644 --- a/src/test/ui/wf/wf-trait-associated-type-bound.stderr +++ b/src/test/ui/wf/wf-trait-associated-type-bound.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/wf-trait-associated-type-bound.rs:10:17 | LL | trait ExtraCopy { } - | ----------------------- required by `ExtraCopy` + | --------- ---- required by this bound in `ExtraCopy` ... LL | type Type1: ExtraCopy; | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/wf/wf-trait-associated-type-trait.stderr b/src/test/ui/wf/wf-trait-associated-type-trait.stderr index 93cb948cdbf..915f660f54d 100644 --- a/src/test/ui/wf/wf-trait-associated-type-trait.stderr +++ b/src/test/ui/wf/wf-trait-associated-type-trait.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `::Type1: std::marker::Copy` is --> $DIR/wf-trait-associated-type-trait.rs:11:5 | LL | struct IsCopy { x: T } - | --------------------- required by `IsCopy` + | ------ ---- required by this bound in `IsCopy` LL | LL | trait SomeTrait { | - help: consider further restricting the associated type: `where ::Type1: std::marker::Copy` diff --git a/src/test/ui/wf/wf-trait-bound.stderr b/src/test/ui/wf/wf-trait-bound.stderr index b8ffad6d180..0db29621e31 100644 --- a/src/test/ui/wf/wf-trait-bound.stderr +++ b/src/test/ui/wf/wf-trait-bound.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied --> $DIR/wf-trait-bound.rs:10:14 | LL | trait ExtraCopy { } - | ----------------------- required by `ExtraCopy` + | --------- ---- required by this bound in `ExtraCopy` ... LL | where T: ExtraCopy | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` diff --git a/src/test/ui/wf/wf-trait-default-fn-arg.stderr b/src/test/ui/wf/wf-trait-default-fn-arg.stderr index 6a97d31cf3e..55fc202ca51 100644 --- a/src/test/ui/wf/wf-trait-default-fn-arg.stderr +++ b/src/test/ui/wf/wf-trait-default-fn-arg.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied --> $DIR/wf-trait-default-fn-arg.rs:11:22 | LL | struct Bar { value: Box } - | ----------------------- required by `Bar` + | --- -- required by this bound in `Bar` ... LL | fn bar(&self, x: &Bar) { | ^^^^^^^^^^ - help: consider further restricting `Self`: `where Self: std::cmp::Eq` diff --git a/src/test/ui/wf/wf-trait-default-fn-ret.stderr b/src/test/ui/wf/wf-trait-default-fn-ret.stderr index 36c1e486269..00b153317ab 100644 --- a/src/test/ui/wf/wf-trait-default-fn-ret.stderr +++ b/src/test/ui/wf/wf-trait-default-fn-ret.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied --> $DIR/wf-trait-default-fn-ret.rs:11:22 | LL | struct Bar { value: Box } - | ----------------------- required by `Bar` + | --- -- required by this bound in `Bar` ... LL | fn bar(&self) -> Bar { | ^^^^^^^^^- help: consider further restricting `Self`: `where Self: std::cmp::Eq` diff --git a/src/test/ui/wf/wf-trait-default-fn-where-clause.stderr b/src/test/ui/wf/wf-trait-default-fn-where-clause.stderr index 6b63feaba89..97210a8aa6a 100644 --- a/src/test/ui/wf/wf-trait-default-fn-where-clause.stderr +++ b/src/test/ui/wf/wf-trait-default-fn-where-clause.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied --> $DIR/wf-trait-default-fn-where-clause.rs:11:31 | LL | trait Bar { } - | ---------------------- required by `Bar` + | --- -- required by this bound in `Bar` ... LL | fn bar(&self) where A: Bar { | ^^^^^^^^^- help: consider further restricting `Self`: `, Self: std::cmp::Eq` diff --git a/src/test/ui/wf/wf-trait-fn-arg.stderr b/src/test/ui/wf/wf-trait-fn-arg.stderr index 69e2ab72912..190721492a2 100644 --- a/src/test/ui/wf/wf-trait-fn-arg.stderr +++ b/src/test/ui/wf/wf-trait-fn-arg.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied --> $DIR/wf-trait-fn-arg.rs:10:22 | LL | struct Bar { value: Box } - | ----------------------- required by `Bar` + | --- -- required by this bound in `Bar` ... LL | fn bar(&self, x: &Bar); | ^^^^^^^^^^ - help: consider further restricting `Self`: `where Self: std::cmp::Eq` diff --git a/src/test/ui/wf/wf-trait-fn-ret.stderr b/src/test/ui/wf/wf-trait-fn-ret.stderr index bfc6265662e..b8d10f4f396 100644 --- a/src/test/ui/wf/wf-trait-fn-ret.stderr +++ b/src/test/ui/wf/wf-trait-fn-ret.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied --> $DIR/wf-trait-fn-ret.rs:10:22 | LL | struct Bar { value: Box } - | ----------------------- required by `Bar` + | --- -- required by this bound in `Bar` ... LL | fn bar(&self) -> &Bar; | ^^^^^^^^^^- help: consider further restricting `Self`: `where Self: std::cmp::Eq` diff --git a/src/test/ui/wf/wf-trait-fn-where-clause.stderr b/src/test/ui/wf/wf-trait-fn-where-clause.stderr index ec8f02c9c4f..c138da032ce 100644 --- a/src/test/ui/wf/wf-trait-fn-where-clause.stderr +++ b/src/test/ui/wf/wf-trait-fn-where-clause.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied --> $DIR/wf-trait-fn-where-clause.rs:10:49 | LL | struct Bar { value: Box } - | ----------------------- required by `Bar` + | --- -- required by this bound in `Bar` ... LL | fn bar(&self) where Self: Sized, Bar: Copy; | ^^^^- help: consider further restricting `Self`: `, Self: std::cmp::Eq` diff --git a/src/test/ui/wf/wf-trait-superbound.stderr b/src/test/ui/wf/wf-trait-superbound.stderr index 88b4bec0451..5310939af9c 100644 --- a/src/test/ui/wf/wf-trait-superbound.stderr +++ b/src/test/ui/wf/wf-trait-superbound.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/wf-trait-superbound.rs:9:21 | LL | trait ExtraCopy { } - | ----------------------- required by `ExtraCopy` + | --------- ---- required by this bound in `ExtraCopy` LL | LL | trait SomeTrait: ExtraCopy { | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`