From c846d9fe8b04dc643aca6eea3d5497d9b931fdb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 28 May 2021 20:16:07 -0700 Subject: [PATCH 1/4] Tweak assoc type obligation spans * Mention where implicit `Sized` obligations come from on E0277 * New predicate field for `Sized` obligations * Suggest `T: ?Sized` in more places --- .../src/type_check/canonical.rs | 1 + .../src/transform/check_consts/check.rs | 1 + .../src/transform/check_consts/qualifs.rs | 1 + .../src/infer/outlives/obligations.rs | 3 +- compiler/rustc_middle/src/traits/mod.rs | 3 + compiler/rustc_middle/src/ty/mod.rs | 40 +++++++++-- compiler/rustc_middle/src/ty/relate.rs | 16 +++++ .../rustc_middle/src/ty/structural_impls.rs | 1 + compiler/rustc_middle/src/ty/sty.rs | 1 + compiler/rustc_privacy/src/lib.rs | 1 + .../src/traits/auto_trait.rs | 1 + .../src/traits/error_reporting/mod.rs | 7 +- .../error_reporting/on_unimplemented.rs | 3 +- .../src/traits/error_reporting/suggestions.rs | 57 ++++++++++++++++ .../rustc_trait_selection/src/traits/mod.rs | 1 + .../src/traits/relationships.rs | 1 + .../src/traits/select/candidate_assembly.rs | 2 + .../rustc_trait_selection/src/traits/util.rs | 8 ++- .../rustc_trait_selection/src/traits/wf.rs | 11 +-- compiler/rustc_typeck/src/bounds.rs | 16 +++-- compiler/rustc_typeck/src/check/_match.rs | 1 + compiler/rustc_typeck/src/check/cast.rs | 3 +- .../rustc_typeck/src/check/compare_method.rs | 26 ++++--- .../src/impl_wf_check/min_specialization.rs | 2 + .../ui/associated-types/defaults-wf.stderr | 2 +- .../ui/associated-types/issue-20005.stderr | 2 +- .../ui/associated-types/issue-63593.stderr | 8 ++- ...with-supertraits-needing-sized-self.stderr | 2 +- src/test/ui/box/into-boxed-slice-fail.stderr | 4 +- .../generic_const_exprs/issue-80742.stderr | 2 +- src/test/ui/dst/dst-sized-trait-param.stderr | 2 +- src/test/ui/error-codes/E0275.stderr | 11 ++- .../ui/extern/extern-types-unsized.stderr | 8 +-- src/test/ui/generator/sized-yield.stderr | 2 +- .../issue-74816.stderr | 8 ++- .../projection-bound-cycle-generic.stderr | 4 +- .../projection-bound-cycle.stderr | 4 +- ...e-param-can-reference-self-in-trait.stderr | 4 +- .../issue-60283.stderr | 2 +- .../issue-62529-1.stderr | 2 +- .../cannot-infer-partial-try-return.rs | 4 +- .../cannot-infer-partial-try-return.stderr | 6 +- src/test/ui/issues/issue-10412.stderr | 2 +- src/test/ui/issues/issue-17651.stderr | 2 +- src/test/ui/issues/issue-18919.stderr | 2 +- src/test/ui/issues/issue-20413.stderr | 68 ++++++++++++------- src/test/ui/issues/issue-20433.stderr | 2 +- src/test/ui/issues/issue-23281.stderr | 2 +- src/test/ui/issues/issue-87199.stderr | 2 +- src/test/ui/range/range-1.rs | 1 + src/test/ui/range/range-1.stderr | 15 +++- .../issue-26548-recursion-via-normalize.rs | 11 +-- ...issue-26548-recursion-via-normalize.stderr | 22 ++++-- src/test/ui/str/str-mut-idx.stderr | 2 +- ...adt-param-with-implicit-sized-bound.stderr | 10 +-- .../ui/suggestions/bound-suggestions.stderr | 10 +-- .../suggestions/issue-84973-blacklist.stderr | 2 +- ...unsized-indirection-in-where-clause.stderr | 2 +- ...re-clause-before-suggesting-unsized.stderr | 2 +- src/test/ui/trait-bounds/unsized-bound.stderr | 18 ++--- src/test/ui/traits/bad-sized.stderr | 6 +- src/test/ui/traits/issue-65673.stderr | 8 ++- .../mutual-recursion-issue-75860.stderr | 3 +- .../ui/traits/suggest-where-clause.stderr | 8 +-- .../ui/unsized/unsized-bare-typaram.stderr | 2 +- src/test/ui/unsized/unsized-enum.stderr | 2 +- .../unsized-inherent-impl-self-type.stderr | 2 +- src/test/ui/unsized/unsized-struct.stderr | 4 +- .../unsized-trait-impl-self-type.stderr | 2 +- .../unsized-trait-impl-trait-arg.stderr | 2 +- src/test/ui/unsized/unsized3.stderr | 6 +- src/test/ui/unsized/unsized7.stderr | 2 +- src/test/ui/wf/wf-fn-where-clause.stderr | 2 +- src/test/ui/wf/wf-impl-self-type.stderr | 2 +- .../wf/wf-in-foreign-fn-decls-issue-80468.rs | 4 +- 75 files changed, 357 insertions(+), 157 deletions(-) diff --git a/compiler/rustc_borrowck/src/type_check/canonical.rs b/compiler/rustc_borrowck/src/type_check/canonical.rs index 0fa72ed8241bc..57a5584421139 100644 --- a/compiler/rustc_borrowck/src/type_check/canonical.rs +++ b/compiler/rustc_borrowck/src/type_check/canonical.rs @@ -95,6 +95,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { trait_ref, constness: ty::BoundConstness::NotConst, polarity: ty::ImplPolarity::Positive, + implicit: ty::ImplicitBound::No, }))), locations, category, diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index 5a4aa06f3bbae..a64229b42b69e 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -813,6 +813,7 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> { trait_ref, constness: ty::BoundConstness::ConstIfConst, polarity: ty::ImplPolarity::Positive, + implicit: ty::ImplicitBound::No, }), ); diff --git a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs index 43612292f5283..fc19617617745 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs @@ -162,6 +162,7 @@ impl Qualif for NeedsNonConstDrop { trait_ref, constness: ty::BoundConstness::ConstIfConst, polarity: ty::ImplPolarity::Positive, + implicit: ty::ImplicitBound::No, }), ); diff --git a/compiler/rustc_infer/src/infer/outlives/obligations.rs b/compiler/rustc_infer/src/infer/outlives/obligations.rs index 91a22ecc5a994..4044d10e71b48 100644 --- a/compiler/rustc_infer/src/infer/outlives/obligations.rs +++ b/compiler/rustc_infer/src/infer/outlives/obligations.rs @@ -103,7 +103,8 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { cause.span, sup_type, match cause.code.peel_derives() { - ObligationCauseCode::BindingObligation(_, span) => Some(*span), + ObligationCauseCode::BindingObligation(_, span) + | ObligationCauseCode::ImplicitSizedObligation(_, span) => Some(*span), _ => None, }, ) diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 33ddc4f954a28..56af878a92c17 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -204,6 +204,9 @@ pub enum ObligationCauseCode<'tcx> { /// Like `ItemObligation`, but with extra detail on the source of the obligation. BindingObligation(DefId, Span), + /// Like `ItemObligation`, but with extra detail on the source of the obligation. + ImplicitSizedObligation(DefId, Span), + /// A type like `&'a T` is WF only if `T: 'a`. ReferenceOutlivesReferent(Ty<'tcx>), diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index d0d2a46fc4c1d..215d4a041befe 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -165,6 +165,25 @@ pub struct ImplHeader<'tcx> { pub predicates: Vec>, } +#[derive( + Copy, + Clone, + PartialEq, + Eq, + Hash, + TyEncodable, + TyDecodable, + HashStable, + Debug, + TypeFoldable +)] +pub enum ImplicitBound { + /// `T: Trait` + No, + /// implicit `T: Sized` + Yes, +} + #[derive( Copy, Clone, @@ -518,13 +537,17 @@ impl<'tcx> Predicate<'tcx> { .inner .kind .map_bound(|kind| match kind { - PredicateKind::Trait(TraitPredicate { trait_ref, constness, polarity }) => { - Some(PredicateKind::Trait(TraitPredicate { - trait_ref, - constness, - polarity: polarity.flip()?, - })) - } + PredicateKind::Trait(TraitPredicate { + trait_ref, + constness, + polarity, + implicit, + }) => Some(PredicateKind::Trait(TraitPredicate { + trait_ref, + constness, + polarity: polarity.flip()?, + implicit, + })), _ => None, }) @@ -729,6 +752,8 @@ pub struct TraitPredicate<'tcx> { pub constness: BoundConstness, pub polarity: ImplPolarity, + + pub implicit: ImplicitBound, } pub type PolyTraitPredicate<'tcx> = ty::Binder<'tcx, TraitPredicate<'tcx>>; @@ -1425,6 +1450,7 @@ impl PolyTraitRef<'tcx> { trait_ref, constness, polarity: ty::ImplPolarity::Positive, + implicit: ty::ImplicitBound::No, }) } #[inline] diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs index b6aadf27bb08b..7c2cc6509433f 100644 --- a/compiler/rustc_middle/src/ty/relate.rs +++ b/compiler/rustc_middle/src/ty/relate.rs @@ -788,6 +788,21 @@ impl<'tcx> Relate<'tcx> for GenericArg<'tcx> { } } +impl<'tcx> Relate<'tcx> for ty::ImplicitBound { + fn relate>( + _relation: &mut R, + a: ty::ImplicitBound, + b: ty::ImplicitBound, + ) -> RelateResult<'tcx, ty::ImplicitBound> { + match (a, b) { + (ty::ImplicitBound::No, ty::ty::ImplicitBound::No) => Ok(ty::ImplicitBound::No), + (ty::ImplicitBound::Yes, ty::ty::ImplicitBound::Yes) + | (ty::ImplicitBound::Yes, ty::ty::ImplicitBound::No) + | (ty::ImplicitBound::No, ty::ty::ImplicitBound::Yes) => Ok(ty::ImplicitBound::Yes), + } + } +} + impl<'tcx> Relate<'tcx> for ty::ImplPolarity { fn relate>( relation: &mut R, @@ -812,6 +827,7 @@ impl<'tcx> Relate<'tcx> for ty::TraitPredicate<'tcx> { trait_ref: relation.relate(a.trait_ref, b.trait_ref)?, constness: relation.relate(a.constness, b.constness)?, polarity: relation.relate(a.polarity, b.polarity)?, + implicit: relation.relate(a.implicit, b.implicit)?, }) } } diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 30ed008a5deeb..dfb0ac201f1a8 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -369,6 +369,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> { trait_ref, constness: self.constness, polarity: self.polarity, + implicit: ty::ImplicitBound::No, }) } } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index a80fe6a3362b4..4d434e820f823 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -944,6 +944,7 @@ impl<'tcx> PolyTraitRef<'tcx> { trait_ref, constness: ty::BoundConstness::NotConst, polarity: ty::ImplPolarity::Positive, + implicit: ty::ImplicitBound::No, }) } } diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index e3d2c9837cf51..4b9296fc10666 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -128,6 +128,7 @@ where trait_ref, constness: _, polarity: _, + implicit: _, }) => self.visit_trait(trait_ref), ty::PredicateKind::Projection(ty::ProjectionPredicate { projection_ty, ty }) => { ty.visit_with(self)?; diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index 3642aebaec2fb..a1c614d74b5d4 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -290,6 +290,7 @@ impl AutoTraitFinder<'tcx> { constness: ty::BoundConstness::NotConst, // Auto traits are positive polarity: ty::ImplPolarity::Positive, + implicit: ty::ImplicitBound::No, })); let computed_preds = param_env.caller_bounds().iter(); 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 310eecc6e85f2..9781dd9bbbde5 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1307,6 +1307,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { obligation.cause.code.peel_derives(), ObligationCauseCode::ItemObligation(_) | ObligationCauseCode::BindingObligation(_, _) + | ObligationCauseCode::ImplicitSizedObligation(_, _) | ObligationCauseCode::ObjectCastObligation(_) | ObligationCauseCode::OpaqueType ); @@ -1702,7 +1703,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { self.suggest_fully_qualified_path(&mut err, def_id, span, trait_ref.def_id()); } else if let ( Ok(ref snippet), - ObligationCauseCode::BindingObligation(ref def_id, _), + ObligationCauseCode::BindingObligation(ref def_id, _) + | ObligationCauseCode::ImplicitSizedObligation(ref def_id, _), ) = (self.tcx.sess.source_map().span_to_snippet(span), &obligation.cause.code) { @@ -2005,7 +2007,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { { ( ty::PredicateKind::Trait(pred), - &ObligationCauseCode::BindingObligation(item_def_id, span), + &ObligationCauseCode::BindingObligation(item_def_id, span) + | &ObligationCauseCode::ImplicitSizedObligation(item_def_id, span), ) => (pred, item_def_id, span), _ => return, }; diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs index d9a5aea4d95fc..57f38f23ae7a8 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs @@ -141,7 +141,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { } if let ObligationCauseCode::ItemObligation(item) - | ObligationCauseCode::BindingObligation(item, _) = obligation.cause.code + | ObligationCauseCode::BindingObligation(item, _) + | ObligationCauseCode::ImplicitSizedObligation(item, _) = obligation.cause.code { // FIXME: maybe also have some way of handling methods // from other traits? That would require name resolution, 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 286c9c9900b95..5b721efd24c17 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -802,6 +802,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { if let ObligationCauseCode::ImplDerivedObligation(obligation) = &*code { try_borrowing(obligation.parent_trait_ref, &[]) } else if let ObligationCauseCode::BindingObligation(_, _) + | ObligationCauseCode::ImplicitSizedObligation(..) | ObligationCauseCode::ItemObligation(_) = &*code { try_borrowing(*poly_trait_ref, &never_suggest_borrow) @@ -1961,6 +1962,62 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { // We hold the `DefId` of the item introducing the obligation, but displaying it // doesn't add user usable information. It always point at an associated item. } + ObligationCauseCode::ImplicitSizedObligation(item_def_id, span) => { + let item_name = tcx.def_path_str(item_def_id); + let mut sp: MultiSpan = span.into(); + match self.tcx.hir().get_if_local(item_def_id) { + Some(hir::Node::TraitItem(hir::TraitItem { + kind: hir::TraitItemKind::Type(bounds, _), + ident, + .. + })) => { + sp.push_span_label( + span, + format!("required by associated type `{}`", item_name), + ); + err.span_note(sp, "associated types have an implicit `Sized` obligation"); + + let sized_trait = self.tcx.lang_items().sized_trait(); + if bounds.len() == 0 { + err.span_suggestion_verbose( + ident.span.shrink_to_hi(), + "consider relaxing the `Sized` obligation", + ": ?Sized".to_string(), + Applicability::MaybeIncorrect, + ); + } else if bounds.iter().all(|bound| { + bound.trait_ref().and_then(|tr| tr.trait_def_id()) != sized_trait + }) { + err.span_suggestion_verbose( + bounds.iter().last().unwrap().span().shrink_to_hi(), + "consider relaxing the `Sized` obligation", + " + ?Sized".to_string(), + Applicability::MaybeIncorrect, + ); + } + } + Some(hir::Node::ImplItem(hir::ImplItem { + kind: hir::ImplItemKind::TyAlias(_), + .. + })) => { + let msg = "associated types on `impl` blocks for types, have an implicit \ + mandatory `Sized` obligation; associated types from `trait`s can be \ + relaxed to `?Sized`"; + sp.push_span_label( + span, + format!("required by associated type `{}`", item_name), + ); + err.span_note(sp, msg); + } + _ => { + sp.push_span_label( + span, + format!("required by this bound in `{}`", item_name), + ); + err.span_note(sp, "type parameters have an implicit `Sized` obligation"); + } + } + } ObligationCauseCode::BindingObligation(item_def_id, span) => { let item_name = tcx.def_path_str(item_def_id); let mut multispan = MultiSpan::from(span); diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index d81b6949cae62..0f43db479679d 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -826,6 +826,7 @@ pub fn vtable_trait_upcasting_coercion_new_vptr_slot( trait_ref, constness: ty::BoundConstness::NotConst, polarity: ty::ImplPolarity::Positive, + implicit: ty::ImplicitBound::No, }), ); diff --git a/compiler/rustc_trait_selection/src/traits/relationships.rs b/compiler/rustc_trait_selection/src/traits/relationships.rs index e0098cc92d515..6c75f75f2dcb5 100644 --- a/compiler/rustc_trait_selection/src/traits/relationships.rs +++ b/compiler/rustc_trait_selection/src/traits/relationships.rs @@ -45,6 +45,7 @@ pub(crate) fn update<'tcx, T>( trait_ref, constness: predicate.constness, polarity: predicate.polarity, + implicit: predicate.implicit, }) }) .to_predicate(infcx.tcx), diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index 017f47d4357fb..89d71ab33acfb 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -935,6 +935,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { }, constness: ty::BoundConstness::NotConst, polarity: ty::ImplPolarity::Positive, + implicit: ty::ImplicitBound::No, })); copy_obligation.recursion_depth = depth + 1; self.assemble_candidates_from_impls(©_obligation, &mut new_candidates); @@ -951,6 +952,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { }, constness: ty::BoundConstness::ConstIfConst, polarity: ty::ImplPolarity::Positive, + implicit: ty::ImplicitBound::No, })); let const_drop_stack = self.push_stack(obligation_stack.list(), &const_drop_obligation); diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs index 5577e98e89321..f2c7b7ecb4b07 100644 --- a/compiler/rustc_trait_selection/src/traits/util.rs +++ b/compiler/rustc_trait_selection/src/traits/util.rs @@ -236,7 +236,13 @@ pub fn predicates_for_generics<'tcx>( traits::ItemObligation(def_id) if !span.is_dummy() => traits::ObligationCause::new( cause.span, cause.body_id, - traits::BindingObligation(def_id, span), + match predicate.kind().skip_binder() { + ty::PredicateKind::Trait(ty::TraitPredicate { + implicit: ty::ImplicitBound::Yes, + .. + }) => traits::ImplicitSizedObligation(def_id, span), + _ => traits::BindingObligation(def_id, span), + }, ), _ => cause.clone(), }; diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 5875b764e9f36..342b78bbe654b 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -710,10 +710,13 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { iter::zip(iter::zip(predicates.predicates, predicates.spans), origins.into_iter().rev()) .map(|((pred, span), origin_def_id)| { - let code = if span.is_dummy() { - traits::MiscObligation - } else { - traits::BindingObligation(origin_def_id, span) + let code = match pred.kind().skip_binder() { + _ if span.is_dummy() => traits::MiscObligation, + ty::PredicateKind::Trait(ty::TraitPredicate { + implicit: ty::ImplicitBound::Yes, + .. + }) => traits::ImplicitSizedObligation(origin_def_id, span), + _ => traits::BindingObligation(origin_def_id, span), }; let cause = self.cause(code); traits::Obligation::with_depth(cause, self.recursion_depth, self.param_env, pred) diff --git a/compiler/rustc_typeck/src/bounds.rs b/compiler/rustc_typeck/src/bounds.rs index 8bc3a48e5b506..17459a491f5c5 100644 --- a/compiler/rustc_typeck/src/bounds.rs +++ b/compiler/rustc_typeck/src/bounds.rs @@ -56,11 +56,17 @@ impl<'tcx> Bounds<'tcx> { // If it could be sized, and is, add the `Sized` predicate. let sized_predicate = self.implicitly_sized.and_then(|span| { tcx.lang_items().sized_trait().map(|sized| { - let trait_ref = ty::Binder::dummy(ty::TraitRef { - def_id: sized, - substs: tcx.mk_substs_trait(param_ty, &[]), - }); - (trait_ref.without_const().to_predicate(tcx), span) + let pred = ty::Binder::dummy(ty::PredicateKind::Trait(ty::TraitPredicate { + trait_ref: ty::TraitRef { + def_id: sized, + substs: tcx.mk_substs_trait(param_ty, &[]), + }, + constness: ty::BoundConstness::NotConst, + polarity: ty::ImplPolarity::Positive, + implicit: ty::ImplicitBound::Yes, + })) + .to_predicate(tcx); + (pred, span) }) }); diff --git a/compiler/rustc_typeck/src/check/_match.rs b/compiler/rustc_typeck/src/check/_match.rs index a8160313228b6..d4112a149c8e6 100644 --- a/compiler/rustc_typeck/src/check/_match.rs +++ b/compiler/rustc_typeck/src/check/_match.rs @@ -531,6 +531,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }, constness: t.constness, polarity: t.polarity, + implicit: t.implicit, })); let obl = Obligation::new( o.cause.clone(), diff --git a/compiler/rustc_typeck/src/check/cast.rs b/compiler/rustc_typeck/src/check/cast.rs index a397ee771af59..6419acfce9969 100644 --- a/compiler/rustc_typeck/src/check/cast.rs +++ b/compiler/rustc_typeck/src/check/cast.rs @@ -625,8 +625,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { fcx.ty_to_string(t_cast) )) .help(&format!( - "cast can be replaced by coercion; this might \ - require {}a temporary variable", + "cast can be replaced by coercion; this might require {}a temporary variable", type_asc_or )) .emit(); diff --git a/compiler/rustc_typeck/src/check/compare_method.rs b/compiler/rustc_typeck/src/check/compare_method.rs index 11560f51822f8..41166d01914b8 100644 --- a/compiler/rustc_typeck/src/check/compare_method.rs +++ b/compiler/rustc_typeck/src/check/compare_method.rs @@ -1378,13 +1378,19 @@ pub fn check_type_bounds<'tcx>( let impl_ty_hir_id = tcx.hir().local_def_id_to_hir_id(impl_ty.def_id.expect_local()); let normalize_cause = traits::ObligationCause::misc(impl_ty_span, impl_ty_hir_id); - let mk_cause = |span: Span| { - let code = if span.is_dummy() { - traits::MiscObligation - } else { - traits::BindingObligation(trait_ty.def_id, span) - }; - ObligationCause::new(impl_ty_span, impl_ty_hir_id, code) + let mk_cause = |bound, span: Span| { + ObligationCause::new( + impl_ty_span, + impl_ty_hir_id, + match bound { + _ if span.is_dummy() => traits::MiscObligation, + ty::PredicateKind::Trait(ty::TraitPredicate { + implicit: ty::ImplicitBound::Yes, + .. + }) => traits::ImplicitSizedObligation(trait_ty.def_id, span), + _ => ObligationCauseCode::BindingObligation(trait_ty.def_id, span), + }, + ) }; let obligations = tcx @@ -1395,7 +1401,11 @@ pub fn check_type_bounds<'tcx>( let concrete_ty_bound = bound.subst(tcx, rebased_substs); debug!("check_type_bounds: concrete_ty_bound = {:?}", concrete_ty_bound); - traits::Obligation::new(mk_cause(span), param_env, concrete_ty_bound) + traits::Obligation::new( + mk_cause(bound.kind().skip_binder(), span), + param_env, + concrete_ty_bound, + ) }) .collect(); debug!("check_type_bounds: item_bounds={:?}", obligations); diff --git a/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs b/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs index 4fb422c801b1d..61169a6ca3636 100644 --- a/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs +++ b/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs @@ -383,6 +383,7 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tc trait_ref, constness: ty::BoundConstness::NotConst, polarity: _, + implicit: _, }) => { if !matches!( trait_predicate_kind(tcx, predicate), @@ -415,6 +416,7 @@ fn trait_predicate_kind<'tcx>( trait_ref, constness: ty::BoundConstness::NotConst, polarity: _, + implicit: _, }) => Some(tcx.trait_def(trait_ref.def_id).specialization_kind), ty::PredicateKind::Trait(_) | ty::PredicateKind::RegionOutlives(_) diff --git a/src/test/ui/associated-types/defaults-wf.stderr b/src/test/ui/associated-types/defaults-wf.stderr index 8455f88f18e7a..186bc6316406a 100644 --- a/src/test/ui/associated-types/defaults-wf.stderr +++ b/src/test/ui/associated-types/defaults-wf.stderr @@ -5,7 +5,7 @@ LL | type Ty = Vec<[u8]>; | ^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` -note: required by a bound in `Vec` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | LL | pub struct Vec { diff --git a/src/test/ui/associated-types/issue-20005.stderr b/src/test/ui/associated-types/issue-20005.stderr index c8e57df0d9fee..3dcc85201a020 100644 --- a/src/test/ui/associated-types/issue-20005.stderr +++ b/src/test/ui/associated-types/issue-20005.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | ) -> >::Result where Dst: From { | ^^^^^^^^^^ doesn't have a size known at compile-time | -note: required by a bound in `From` +note: type parameters have an implicit `Sized` obligation --> $DIR/issue-20005.rs:1:12 | LL | trait From { diff --git a/src/test/ui/associated-types/issue-63593.stderr b/src/test/ui/associated-types/issue-63593.stderr index f643ec3ff1fdc..2070e09c848b1 100644 --- a/src/test/ui/associated-types/issue-63593.stderr +++ b/src/test/ui/associated-types/issue-63593.stderr @@ -4,15 +4,19 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | type This = Self; | ^^^^ doesn't have a size known at compile-time | -note: required by a bound in `MyTrait::This` +note: associated types have an implicit `Sized` obligation --> $DIR/issue-63593.rs:9:5 | LL | type This = Self; - | ^^^^^^^^^^^^^^^^^ required by this bound in `MyTrait::This` + | ^^^^^^^^^^^^^^^^^ required by associated type `MyTrait::This` help: consider further restricting `Self` | LL | trait MyTrait: Sized { | +++++++ +help: consider relaxing the `Sized` obligation + | +LL | type This: ?Sized = Self; + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/associated-types/trait-with-supertraits-needing-sized-self.stderr b/src/test/ui/associated-types/trait-with-supertraits-needing-sized-self.stderr index 558b0f5c8a368..017d34a2492b2 100644 --- a/src/test/ui/associated-types/trait-with-supertraits-needing-sized-self.stderr +++ b/src/test/ui/associated-types/trait-with-supertraits-needing-sized-self.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | trait ArithmeticOps: Add + Sub + Mul + Div {} | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | -note: required by a bound in `Add` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/core/src/ops/arith.rs:LL:COL | LL | pub trait Add { diff --git a/src/test/ui/box/into-boxed-slice-fail.stderr b/src/test/ui/box/into-boxed-slice-fail.stderr index de654fdc1a4b5..18ad72a87e199 100644 --- a/src/test/ui/box/into-boxed-slice-fail.stderr +++ b/src/test/ui/box/into-boxed-slice-fail.stderr @@ -7,7 +7,7 @@ LL | let _ = Box::into_boxed_slice(boxed_slice); | required by a bound introduced by this call | = help: the trait `Sized` is not implemented for `[u8]` -note: required by a bound in `Box::::into_boxed_slice` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/alloc/src/boxed.rs:LL:COL | LL | impl Box { @@ -31,7 +31,7 @@ LL | let _ = Box::into_boxed_slice(boxed_trait); | required by a bound introduced by this call | = help: the trait `Sized` is not implemented for `dyn Debug` -note: required by a bound in `Box::::into_boxed_slice` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/alloc/src/boxed.rs:LL:COL | LL | impl Box { diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-80742.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-80742.stderr index 56cb11bacbe6b..459e710b98f7a 100644 --- a/src/test/ui/const-generics/generic_const_exprs/issue-80742.stderr +++ b/src/test/ui/const-generics/generic_const_exprs/issue-80742.stderr @@ -56,7 +56,7 @@ LL | let dst = Inline::::new(0); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `dyn Debug` -note: required by a bound in `Inline` +note: type parameters have an implicit `Sized` obligation --> $DIR/issue-80742.rs:12:15 | LL | struct Inline diff --git a/src/test/ui/dst/dst-sized-trait-param.stderr b/src/test/ui/dst/dst-sized-trait-param.stderr index 8ec94f5a3c0ad..5b599d0e4d0e1 100644 --- a/src/test/ui/dst/dst-sized-trait-param.stderr +++ b/src/test/ui/dst/dst-sized-trait-param.stderr @@ -5,7 +5,7 @@ LL | impl Foo<[isize]> for usize { } | ^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[isize]` -note: required by a bound in `Foo` +note: type parameters have an implicit `Sized` obligation --> $DIR/dst-sized-trait-param.rs:5:11 | LL | trait Foo : Sized { fn take(self, x: &T) { } } // Note: T is sized diff --git a/src/test/ui/error-codes/E0275.stderr b/src/test/ui/error-codes/E0275.stderr index dfffbb182ad31..a4d01f65384c2 100644 --- a/src/test/ui/error-codes/E0275.stderr +++ b/src/test/ui/error-codes/E0275.stderr @@ -1,16 +1,21 @@ -error[E0275]: overflow evaluating the requirement `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Foo` +error[E0275]: overflow evaluating the requirement `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Sized` --> $DIR/E0275.rs:5:33 | LL | impl Foo for T where Bar: Foo {} | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`E0275`) -note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` +note: required because it appears within the type `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/E0275.rs:3:8 + | +LL | struct Bar(T); + | ^^^ +note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` --> $DIR/E0275.rs:5:9 | LL | impl Foo for T where Bar: Foo {} | ^^^ ^ - = note: 127 redundant requirements hidden + = note: 126 redundant requirements hidden = note: required because of the requirements on the impl of `Foo` for `Bar` error: aborting due to previous error diff --git a/src/test/ui/extern/extern-types-unsized.stderr b/src/test/ui/extern/extern-types-unsized.stderr index 8d6713261d5ec..41b67ebfa50d1 100644 --- a/src/test/ui/extern/extern-types-unsized.stderr +++ b/src/test/ui/extern/extern-types-unsized.stderr @@ -5,7 +5,7 @@ LL | assert_sized::(); | ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `A` -note: required by a bound in `assert_sized` +note: type parameters have an implicit `Sized` obligation --> $DIR/extern-types-unsized.rs:19:17 | LL | fn assert_sized() {} @@ -27,7 +27,7 @@ note: required because it appears within the type `Foo` | LL | struct Foo { | ^^^ -note: required by a bound in `assert_sized` +note: type parameters have an implicit `Sized` obligation --> $DIR/extern-types-unsized.rs:19:17 | LL | fn assert_sized() {} @@ -49,7 +49,7 @@ note: required because it appears within the type `Bar` | LL | struct Bar { | ^^^ -note: required by a bound in `assert_sized` +note: type parameters have an implicit `Sized` obligation --> $DIR/extern-types-unsized.rs:19:17 | LL | fn assert_sized() {} @@ -71,7 +71,7 @@ note: required because it appears within the type `Bar` | LL | struct Bar { | ^^^ -note: required by a bound in `assert_sized` +note: type parameters have an implicit `Sized` obligation --> $DIR/extern-types-unsized.rs:19:17 | LL | fn assert_sized() {} diff --git a/src/test/ui/generator/sized-yield.stderr b/src/test/ui/generator/sized-yield.stderr index ea2a48d13cee6..4f47adb4d85e9 100644 --- a/src/test/ui/generator/sized-yield.stderr +++ b/src/test/ui/generator/sized-yield.stderr @@ -18,7 +18,7 @@ LL | Pin::new(&mut gen).resume(()); | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` -note: required by a bound in `GeneratorState` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/core/src/ops/generator.rs:LL:COL | LL | pub enum GeneratorState { diff --git a/src/test/ui/generic-associated-types/issue-74816.stderr b/src/test/ui/generic-associated-types/issue-74816.stderr index 9eaa74e343e4b..1cc6fc381e8f0 100644 --- a/src/test/ui/generic-associated-types/issue-74816.stderr +++ b/src/test/ui/generic-associated-types/issue-74816.stderr @@ -20,15 +20,19 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | type Associated: Trait1 = Self; | ^^^^ doesn't have a size known at compile-time | -note: required by a bound in `Trait2::Associated` +note: associated types have an implicit `Sized` obligation --> $DIR/issue-74816.rs:9:5 | LL | type Associated: Trait1 = Self; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Trait2::Associated` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by associated type `Trait2::Associated` help: consider further restricting `Self` | LL | trait Trait2: Sized { | +++++++ +help: consider relaxing the `Sized` obligation + | +LL | type Associated: Trait1 + ?Sized = Self; + | ++++++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr b/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr index 2b57c439fe9a0..a1b0264e04a78 100644 --- a/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr +++ b/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr @@ -5,10 +5,10 @@ LL | type Assoc = OnlySized<::Item>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: required by a bound in `OnlySized` - --> $DIR/projection-bound-cycle-generic.rs:28:18 + --> $DIR/projection-bound-cycle-generic.rs:28:30 | LL | struct OnlySized where T: Sized { f: T } - | ^ required by this bound in `OnlySized` + | ^^^^^ required by this bound in `OnlySized` error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/projection-bound-cycle.stderr b/src/test/ui/generic-associated-types/projection-bound-cycle.stderr index d9d0bf4274bd7..38b5164d79c9c 100644 --- a/src/test/ui/generic-associated-types/projection-bound-cycle.stderr +++ b/src/test/ui/generic-associated-types/projection-bound-cycle.stderr @@ -5,10 +5,10 @@ LL | type Assoc = OnlySized<::Item>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: required by a bound in `OnlySized` - --> $DIR/projection-bound-cycle.rs:30:18 + --> $DIR/projection-bound-cycle.rs:30:30 | LL | struct OnlySized where T: Sized { f: T } - | ^ required by this bound in `OnlySized` + | ^^^^^ required by this bound in `OnlySized` error: aborting due to previous error diff --git a/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr b/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr index 2c397d80b013e..50f90618e4db7 100644 --- a/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr +++ b/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr @@ -6,10 +6,10 @@ LL | impl Tsized for () {} | = help: the trait `Sized` is not implemented for `[()]` note: required by a bound in `Tsized` - --> $DIR/issue-61631-default-type-param-can-reference-self-in-trait.rs:17:14 + --> $DIR/issue-61631-default-type-param-can-reference-self-in-trait.rs:17:17 | LL | trait Tsized {} - | ^ required by this bound in `Tsized` + | ^^^^^ required by this bound in `Tsized` error: aborting due to previous error diff --git a/src/test/ui/higher-rank-trait-bounds/issue-60283.stderr b/src/test/ui/higher-rank-trait-bounds/issue-60283.stderr index 34893cd8f19d9..4b46f5d16a2d5 100644 --- a/src/test/ui/higher-rank-trait-bounds/issue-60283.stderr +++ b/src/test/ui/higher-rank-trait-bounds/issue-60283.stderr @@ -26,7 +26,7 @@ LL | foo((), drop) | required by a bound introduced by this call | = help: the trait `Sized` is not implemented for `<() as Trait<'_>>::Item` -note: required by a bound in `std::mem::drop` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub fn drop(_x: T) {} diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.stderr b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.stderr index 01b14660b6531..ffb9a0dc2425a 100644 --- a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.stderr +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.stderr @@ -14,7 +14,7 @@ LL | | )); | |_____^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `impl Execute` -note: required by a bound in `task` +note: type parameters have an implicit `Sized` obligation --> $DIR/issue-62529-1.rs:69:9 | LL | fn task

(processor: P) -> Task diff --git a/src/test/ui/inference/cannot-infer-partial-try-return.rs b/src/test/ui/inference/cannot-infer-partial-try-return.rs index 6e897a3edfdc3..f6f49504f2e94 100644 --- a/src/test/ui/inference/cannot-infer-partial-try-return.rs +++ b/src/test/ui/inference/cannot-infer-partial-try-return.rs @@ -15,8 +15,8 @@ fn infallible() -> Result<(), std::convert::Infallible> { } fn main() { - let x = || -> Result<_, QualifiedError<_>> { - infallible()?; //~ ERROR type annotations needed + let x = || -> Result<_, QualifiedError<_>> { //~ ERROR type annotations needed + infallible()?; Ok(()) }; } diff --git a/src/test/ui/inference/cannot-infer-partial-try-return.stderr b/src/test/ui/inference/cannot-infer-partial-try-return.stderr index 3542eb6848caf..70eac527fd89c 100644 --- a/src/test/ui/inference/cannot-infer-partial-try-return.stderr +++ b/src/test/ui/inference/cannot-infer-partial-try-return.stderr @@ -1,8 +1,8 @@ error[E0282]: type annotations needed for the closure `fn() -> Result<(), QualifiedError<_>>` - --> $DIR/cannot-infer-partial-try-return.rs:19:9 + --> $DIR/cannot-infer-partial-try-return.rs:18:19 | -LL | infallible()?; - | ^^^^^^^^^^^^^ cannot infer type +LL | let x = || -> Result<_, QualifiedError<_>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type | help: give this closure an explicit return type without `_` placeholders | diff --git a/src/test/ui/issues/issue-10412.stderr b/src/test/ui/issues/issue-10412.stderr index 053a93e6cd8c7..55daf4135dbdb 100644 --- a/src/test/ui/issues/issue-10412.stderr +++ b/src/test/ui/issues/issue-10412.stderr @@ -55,7 +55,7 @@ LL | impl<'self> Serializable for &'self str { | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` -note: required by a bound in `Serializable` +note: type parameters have an implicit `Sized` obligation --> $DIR/issue-10412.rs:1:27 | LL | trait Serializable<'self, T> { diff --git a/src/test/ui/issues/issue-17651.stderr b/src/test/ui/issues/issue-17651.stderr index efaaeeda2fab6..a68a9c9c59bd7 100644 --- a/src/test/ui/issues/issue-17651.stderr +++ b/src/test/ui/issues/issue-17651.stderr @@ -7,7 +7,7 @@ LL | (|| Box::new(*(&[0][..])))(); | required by a bound introduced by this call | = help: the trait `Sized` is not implemented for `[{integer}]` -note: required by a bound in `Box::::new` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/alloc/src/boxed.rs:LL:COL | LL | impl Box { diff --git a/src/test/ui/issues/issue-18919.stderr b/src/test/ui/issues/issue-18919.stderr index d7dbb8299b9ef..11342e26948c5 100644 --- a/src/test/ui/issues/issue-18919.stderr +++ b/src/test/ui/issues/issue-18919.stderr @@ -5,7 +5,7 @@ LL | fn ho_func(f: Option) { | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `dyn for<'r> Fn(&'r isize) -> isize` -note: required by a bound in `Option` +note: type parameters have an implicit `Sized` obligation --> $DIR/issue-18919.rs:7:13 | LL | enum Option { diff --git a/src/test/ui/issues/issue-20413.stderr b/src/test/ui/issues/issue-20413.stderr index 2935214140419..15666410098a0 100644 --- a/src/test/ui/issues/issue-20413.stderr +++ b/src/test/ui/issues/issue-20413.stderr @@ -37,84 +37,104 @@ LL | impl Foo for T where NoData: Foo { = note: 127 redundant requirements hidden = note: required because of the requirements on the impl of `Foo` for `NoData` -error[E0275]: overflow evaluating the requirement `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Baz` +error[E0275]: overflow evaluating the requirement `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Sized` --> $DIR/issue-20413.rs:28:42 | LL | impl Bar for T where EvenLessData: Baz { | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) -note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/issue-20413.rs:28:9 +note: required because it appears within the type `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:26:8 | -LL | impl Bar for T where EvenLessData: Baz { - | ^^^ ^ +LL | struct EvenLessData(Option); + | ^^^^^^^^^^^^ note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` --> $DIR/issue-20413.rs:36:9 | LL | impl Baz for T where AlmostNoData: Bar { | ^^^ ^ - = note: 126 redundant requirements hidden +note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:28:9 + | +LL | impl Bar for T where EvenLessData: Baz { + | ^^^ ^ + = note: 125 redundant requirements hidden = note: required because of the requirements on the impl of `Baz` for `EvenLessData` -error[E0275]: overflow evaluating the requirement `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Baz` +error[E0275]: overflow evaluating the requirement `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Sized` --> $DIR/issue-20413.rs:28:42 | LL | impl Bar for T where EvenLessData: Baz { | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) -note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/issue-20413.rs:28:9 +note: required because it appears within the type `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:26:8 | -LL | impl Bar for T where EvenLessData: Baz { - | ^^^ ^ +LL | struct EvenLessData(Option); + | ^^^^^^^^^^^^ note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` --> $DIR/issue-20413.rs:36:9 | LL | impl Baz for T where AlmostNoData: Bar { | ^^^ ^ - = note: 126 redundant requirements hidden +note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:28:9 + | +LL | impl Bar for T where EvenLessData: Baz { + | ^^^ ^ + = note: 125 redundant requirements hidden = note: required because of the requirements on the impl of `Baz` for `EvenLessData` -error[E0275]: overflow evaluating the requirement `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Bar` +error[E0275]: overflow evaluating the requirement `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Sized` --> $DIR/issue-20413.rs:36:42 | LL | impl Baz for T where AlmostNoData: Bar { | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) -note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/issue-20413.rs:36:9 +note: required because it appears within the type `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:24:8 | -LL | impl Baz for T where AlmostNoData: Bar { - | ^^^ ^ +LL | struct AlmostNoData(Option); + | ^^^^^^^^^^^^ note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` --> $DIR/issue-20413.rs:28:9 | LL | impl Bar for T where EvenLessData: Baz { | ^^^ ^ - = note: 126 redundant requirements hidden +note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:36:9 + | +LL | impl Baz for T where AlmostNoData: Bar { + | ^^^ ^ + = note: 125 redundant requirements hidden = note: required because of the requirements on the impl of `Bar` for `AlmostNoData` -error[E0275]: overflow evaluating the requirement `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Bar` +error[E0275]: overflow evaluating the requirement `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Sized` --> $DIR/issue-20413.rs:36:42 | LL | impl Baz for T where AlmostNoData: Bar { | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) -note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/issue-20413.rs:36:9 +note: required because it appears within the type `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:24:8 | -LL | impl Baz for T where AlmostNoData: Bar { - | ^^^ ^ +LL | struct AlmostNoData(Option); + | ^^^^^^^^^^^^ note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` --> $DIR/issue-20413.rs:28:9 | LL | impl Bar for T where EvenLessData: Baz { | ^^^ ^ - = note: 126 redundant requirements hidden +note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:36:9 + | +LL | impl Baz for T where AlmostNoData: Bar { + | ^^^ ^ + = note: 125 redundant requirements hidden = note: required because of the requirements on the impl of `Bar` for `AlmostNoData` error: aborting due to 7 previous errors diff --git a/src/test/ui/issues/issue-20433.stderr b/src/test/ui/issues/issue-20433.stderr index 9d3bb8b924d61..5a28f0233a15f 100644 --- a/src/test/ui/issues/issue-20433.stderr +++ b/src/test/ui/issues/issue-20433.stderr @@ -5,7 +5,7 @@ LL | fn iceman(c: Vec<[i32]>) {} | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[i32]` -note: required by a bound in `Vec` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | LL | pub struct Vec { diff --git a/src/test/ui/issues/issue-23281.stderr b/src/test/ui/issues/issue-23281.stderr index 804334c9b0d24..69f687df68238 100644 --- a/src/test/ui/issues/issue-23281.stderr +++ b/src/test/ui/issues/issue-23281.stderr @@ -5,7 +5,7 @@ LL | pub fn function(funs: Vec ()>) {} | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Fn() + 'static)` -note: required by a bound in `Vec` +note: type parameters have an implicit `Sized` obligation --> $DIR/issue-23281.rs:8:12 | LL | struct Vec { diff --git a/src/test/ui/issues/issue-87199.stderr b/src/test/ui/issues/issue-87199.stderr index 0ec5e73f39a85..2bca376e4e4b3 100644 --- a/src/test/ui/issues/issue-87199.stderr +++ b/src/test/ui/issues/issue-87199.stderr @@ -25,7 +25,7 @@ LL | ref_arg::<[i32]>(&[5]); | required by a bound introduced by this call | = help: the trait `Sized` is not implemented for `[i32]` -note: required by a bound in `ref_arg` +note: type parameters have an implicit `Sized` obligation --> $DIR/issue-87199.rs:10:12 | LL | fn ref_arg(_: &T) {} diff --git a/src/test/ui/range/range-1.rs b/src/test/ui/range/range-1.rs index 192426fe228fe..c020f2531bc02 100644 --- a/src/test/ui/range/range-1.rs +++ b/src/test/ui/range/range-1.rs @@ -13,4 +13,5 @@ pub fn main() { let arr: &[_] = &[1, 2, 3]; let range = *arr..; //~^ ERROR the size for values of type + //~| ERROR the size for values of type } diff --git a/src/test/ui/range/range-1.stderr b/src/test/ui/range/range-1.stderr index 2ce4e1553d28e..1d82e3c3e177b 100644 --- a/src/test/ui/range/range-1.stderr +++ b/src/test/ui/range/range-1.stderr @@ -20,13 +20,24 @@ LL | let range = *arr..; | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[{integer}]` -note: required by a bound in `RangeFrom` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/core/src/ops/range.rs:LL:COL | LL | pub struct RangeFrom { | ^^^ required by this bound in `RangeFrom` -error: aborting due to 3 previous errors +error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time + --> $DIR/range-1.rs:14:9 + | +LL | let range = *arr..; + | ^^^^^ doesn't have a size known at compile-time + | + = help: within `RangeFrom<[{integer}]>`, the trait `Sized` is not implemented for `[{integer}]` + = note: required because it appears within the type `RangeFrom<[{integer}]>` + = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature + +error: aborting due to 4 previous errors Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/recursion/issue-26548-recursion-via-normalize.rs b/src/test/ui/recursion/issue-26548-recursion-via-normalize.rs index 4fd5622b0626c..b9f8fa1749a0d 100644 --- a/src/test/ui/recursion/issue-26548-recursion-via-normalize.rs +++ b/src/test/ui/recursion/issue-26548-recursion-via-normalize.rs @@ -1,11 +1,3 @@ -//~ ERROR cycle detected when computing layout of `S` -//~| NOTE ...which requires computing layout of `core::option::Option<::It>`... -//~| NOTE ...which requires computing layout of `core::option::Option`... -//~| NOTE ...which again requires computing layout of `S`, completing the cycle -//~| NOTE cycle used when computing layout of `core::option::Option` - -// build-fail - trait Mirror { type It: ?Sized; } @@ -13,6 +5,9 @@ impl Mirror for T { type It = Self; } struct S(Option<::It>); +//~^ ERROR overflow evaluating the requirement `S: Sized` +//~| NOTE required because it appears within the type `S` +//~| NOTE type parameters have an implicit `Sized` obligation fn main() { let _s = S(None); diff --git a/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr b/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr index 6042379a91887..be318a3508108 100644 --- a/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr +++ b/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr @@ -1,10 +1,20 @@ -error[E0391]: cycle detected when computing layout of `S` +error[E0275]: overflow evaluating the requirement `S: Sized` + --> $DIR/issue-26548-recursion-via-normalize.rs:7:10 | - = note: ...which requires computing layout of `core::option::Option<::It>`... - = note: ...which requires computing layout of `core::option::Option`... - = note: ...which again requires computing layout of `S`, completing the cycle - = note: cycle used when computing layout of `core::option::Option` +LL | struct S(Option<::It>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: required because it appears within the type `S` + --> $DIR/issue-26548-recursion-via-normalize.rs:7:8 + | +LL | struct S(Option<::It>); + | ^ +note: type parameters have an implicit `Sized` obligation + --> $SRC_DIR/core/src/option.rs:LL:COL + | +LL | pub enum Option { + | ^ required by this bound in `Option` error: aborting due to previous error -For more information about this error, try `rustc --explain E0391`. +For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/str/str-mut-idx.stderr b/src/test/ui/str/str-mut-idx.stderr index 2559ee9eb49b2..a87681ded1954 100644 --- a/src/test/ui/str/str-mut-idx.stderr +++ b/src/test/ui/str/str-mut-idx.stderr @@ -5,7 +5,7 @@ LL | s[1..2] = bot(); | ^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` -note: required by a bound in `bot` +note: type parameters have an implicit `Sized` obligation --> $DIR/str-mut-idx.rs:1:8 | LL | fn bot() -> T { loop {} } diff --git a/src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr b/src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr index fb40c260e2d0c..43f774d6231dc 100644 --- a/src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr +++ b/src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | fn func1() -> Struct1; | ^^^^^^^^^^^^^ doesn't have a size known at compile-time | -note: required by a bound in `Struct1` +note: type parameters have an implicit `Sized` obligation --> $DIR/adt-param-with-implicit-sized-bound.rs:8:16 | LL | struct Struct1{ @@ -24,7 +24,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | fn func2<'a>() -> Struct2<'a, Self>; | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | -note: required by a bound in `Struct2` +note: type parameters have an implicit `Sized` obligation --> $DIR/adt-param-with-implicit-sized-bound.rs:11:20 | LL | struct Struct2<'a, T>{ @@ -44,7 +44,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | fn func3() -> Struct3; | ^^^^^^^^^^^^^ doesn't have a size known at compile-time | -note: required by a bound in `Struct3` +note: type parameters have an implicit `Sized` obligation --> $DIR/adt-param-with-implicit-sized-bound.rs:14:16 | LL | struct Struct3{ @@ -67,7 +67,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | fn func4() -> Struct4; | ^^^^^^^^^^^^^ doesn't have a size known at compile-time | -note: required by a bound in `Struct4` +note: type parameters have an implicit `Sized` obligation --> $DIR/adt-param-with-implicit-sized-bound.rs:20:16 | LL | struct Struct4{ @@ -89,7 +89,7 @@ LL | struct Struct5{ LL | _t: X, | ^^^^ doesn't have a size known at compile-time | -note: required by a bound in `X` +note: type parameters have an implicit `Sized` obligation --> $DIR/adt-param-with-implicit-sized-bound.rs:18:10 | LL | struct X(T); diff --git a/src/test/ui/suggestions/bound-suggestions.stderr b/src/test/ui/suggestions/bound-suggestions.stderr index 04f233a1e87af..11bc913fb91b8 100644 --- a/src/test/ui/suggestions/bound-suggestions.stderr +++ b/src/test/ui/suggestions/bound-suggestions.stderr @@ -76,7 +76,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | const SIZE: usize = core::mem::size_of::(); | ^^^^ doesn't have a size known at compile-time | -note: required by a bound in `std::mem::size_of` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { @@ -92,7 +92,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | const SIZE: usize = core::mem::size_of::(); | ^^^^ doesn't have a size known at compile-time | -note: required by a bound in `std::mem::size_of` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { @@ -108,7 +108,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | const SIZE: usize = core::mem::size_of::(); | ^^^^ doesn't have a size known at compile-time | -note: required by a bound in `std::mem::size_of` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { @@ -124,7 +124,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | const SIZE: usize = core::mem::size_of::(); | ^^^^ doesn't have a size known at compile-time | -note: required by a bound in `std::mem::size_of` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { @@ -140,7 +140,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | const SIZE: usize = core::mem::size_of::(); | ^^^^ doesn't have a size known at compile-time | -note: required by a bound in `std::mem::size_of` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { diff --git a/src/test/ui/suggestions/issue-84973-blacklist.stderr b/src/test/ui/suggestions/issue-84973-blacklist.stderr index ae55c96702ada..aca88293d2b63 100644 --- a/src/test/ui/suggestions/issue-84973-blacklist.stderr +++ b/src/test/ui/suggestions/issue-84973-blacklist.stderr @@ -48,7 +48,7 @@ LL | f_sized(*ref_cl); | required by a bound introduced by this call | = help: the trait `Sized` is not implemented for `dyn Fn()` -note: required by a bound in `f_sized` +note: type parameters have an implicit `Sized` obligation --> $DIR/issue-84973-blacklist.rs:9:12 | LL | fn f_sized(t: T) {} diff --git a/src/test/ui/suggestions/issue-85943-no-suggest-unsized-indirection-in-where-clause.stderr b/src/test/ui/suggestions/issue-85943-no-suggest-unsized-indirection-in-where-clause.stderr index 752533cdc1213..c95f1fb366e65 100644 --- a/src/test/ui/suggestions/issue-85943-no-suggest-unsized-indirection-in-where-clause.stderr +++ b/src/test/ui/suggestions/issue-85943-no-suggest-unsized-indirection-in-where-clause.stderr @@ -5,7 +5,7 @@ LL | struct B(A<[u8]>); | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` -note: required by a bound in `A` +note: type parameters have an implicit `Sized` obligation --> $DIR/issue-85943-no-suggest-unsized-indirection-in-where-clause.rs:4:10 | LL | struct A(T) where T: Send; diff --git a/src/test/ui/suggestions/issue-85945-check-where-clause-before-suggesting-unsized.stderr b/src/test/ui/suggestions/issue-85945-check-where-clause-before-suggesting-unsized.stderr index 92be9f764cc4b..981b210c13613 100644 --- a/src/test/ui/suggestions/issue-85945-check-where-clause-before-suggesting-unsized.stderr +++ b/src/test/ui/suggestions/issue-85945-check-where-clause-before-suggesting-unsized.stderr @@ -7,7 +7,7 @@ LL | fn bar() { foo(""); } | required by a bound introduced by this call | = help: the trait `Sized` is not implemented for `str` -note: required by a bound in `foo` +note: type parameters have an implicit `Sized` obligation --> $DIR/issue-85945-check-where-clause-before-suggesting-unsized.rs:3:8 | LL | fn foo(_: &T) where T: Sized {} diff --git a/src/test/ui/trait-bounds/unsized-bound.stderr b/src/test/ui/trait-bounds/unsized-bound.stderr index 0c758c9ba266f..d7621de3dccc2 100644 --- a/src/test/ui/trait-bounds/unsized-bound.stderr +++ b/src/test/ui/trait-bounds/unsized-bound.stderr @@ -7,7 +7,7 @@ LL | impl Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} | this type parameter needs to be `std::marker::Sized` | = note: required because it appears within the type `(A, B)` -note: required by a bound in `Trait` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized-bound.rs:1:13 | LL | trait Trait {} @@ -46,7 +46,7 @@ LL | impl Trait<(A, B, C)> for (A, B, C) where A: ?Size | this type parameter needs to be `std::marker::Sized` | = note: required because it appears within the type `(A, B, C)` -note: required by a bound in `Trait` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized-bound.rs:1:13 | LL | trait Trait {} @@ -100,7 +100,7 @@ LL | impl Trait2<(A, B)> for (A, B) {} | this type parameter needs to be `std::marker::Sized` | = note: required because it appears within the type `(A, B)` -note: required by a bound in `Trait2` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized-bound.rs:9:14 | LL | trait Trait2 {} @@ -138,7 +138,7 @@ LL | impl Trait3 for A where A: ?Sized {} | | | this type parameter needs to be `std::marker::Sized` | -note: required by a bound in `Trait3` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized-bound.rs:13:14 | LL | trait Trait3 {} @@ -161,7 +161,7 @@ LL | impl Trait4 for A {} | | | this type parameter needs to be `std::marker::Sized` | -note: required by a bound in `Trait4` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized-bound.rs:16:14 | LL | trait Trait4 {} @@ -184,7 +184,7 @@ LL | impl Trait5 for X where X: ?Sized {} | | | this type parameter needs to be `std::marker::Sized` | -note: required by a bound in `Trait5` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized-bound.rs:19:14 | LL | trait Trait5 {} @@ -207,7 +207,7 @@ LL | impl Trait6 for X {} | | | this type parameter needs to be `std::marker::Sized` | -note: required by a bound in `Trait6` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized-bound.rs:22:14 | LL | trait Trait6 {} @@ -230,7 +230,7 @@ LL | impl Trait7 for X where Y: ?Sized {} | | | this type parameter needs to be `std::marker::Sized` | -note: required by a bound in `Trait7` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized-bound.rs:25:17 | LL | trait Trait7 {} @@ -253,7 +253,7 @@ LL | impl Trait8 for X {} | | | this type parameter needs to be `std::marker::Sized` | -note: required by a bound in `Trait8` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized-bound.rs:28:17 | LL | trait Trait8 {} diff --git a/src/test/ui/traits/bad-sized.stderr b/src/test/ui/traits/bad-sized.stderr index 6f9113fff5161..7ea1a235233d5 100644 --- a/src/test/ui/traits/bad-sized.stderr +++ b/src/test/ui/traits/bad-sized.stderr @@ -16,7 +16,7 @@ LL | let x: Vec = Vec::new(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `dyn Trait` -note: required by a bound in `Vec` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | LL | pub struct Vec { @@ -29,7 +29,7 @@ LL | let x: Vec = Vec::new(); | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `dyn Trait` -note: required by a bound in `Vec::::new` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | LL | impl Vec { @@ -42,7 +42,7 @@ LL | let x: Vec = Vec::new(); | ^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `dyn Trait` -note: required by a bound in `Vec` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | LL | pub struct Vec { diff --git a/src/test/ui/traits/issue-65673.stderr b/src/test/ui/traits/issue-65673.stderr index 245c4ee525eab..5e8231213c048 100644 --- a/src/test/ui/traits/issue-65673.stderr +++ b/src/test/ui/traits/issue-65673.stderr @@ -5,11 +5,15 @@ LL | type Ctx = dyn Alias; | ^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Trait + 'static)` -note: required by a bound in `WithType::Ctx` +note: associated types have an implicit `Sized` obligation --> $DIR/issue-65673.rs:4:5 | LL | type Ctx; - | ^^^^^^^^^ required by this bound in `WithType::Ctx` + | ^^^^^^^^^ required by associated type `WithType::Ctx` +help: consider relaxing the `Sized` obligation + | +LL | type Ctx: ?Sized; + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/traits/mutual-recursion-issue-75860.stderr b/src/test/ui/traits/mutual-recursion-issue-75860.stderr index 920f66121e098..ae59d4db2144b 100644 --- a/src/test/ui/traits/mutual-recursion-issue-75860.stderr +++ b/src/test/ui/traits/mutual-recursion-issue-75860.stderr @@ -5,7 +5,8 @@ LL | iso(left, right) | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`mutual_recursion_issue_75860`) -note: required by a bound in `Option` + = note: required because it appears within the type `Option>` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/core/src/option.rs:LL:COL | LL | pub enum Option { diff --git a/src/test/ui/traits/suggest-where-clause.stderr b/src/test/ui/traits/suggest-where-clause.stderr index e2cdd368888a8..5f6bb89542231 100644 --- a/src/test/ui/traits/suggest-where-clause.stderr +++ b/src/test/ui/traits/suggest-where-clause.stderr @@ -7,7 +7,7 @@ LL | // suggest a where-clause, if needed LL | mem::size_of::(); | ^ doesn't have a size known at compile-time | -note: required by a bound in `std::mem::size_of` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { @@ -32,7 +32,7 @@ note: required because it appears within the type `Misc` | LL | struct Misc(T); | ^^^^ -note: required by a bound in `std::mem::size_of` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { @@ -78,7 +78,7 @@ LL | mem::size_of::<[T]>(); | ^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[T]` -note: required by a bound in `std::mem::size_of` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { @@ -91,7 +91,7 @@ LL | mem::size_of::<[&U]>(); | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[&U]` -note: required by a bound in `std::mem::size_of` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { diff --git a/src/test/ui/unsized/unsized-bare-typaram.stderr b/src/test/ui/unsized/unsized-bare-typaram.stderr index 531e9b4c9c955..fe997ea4d8b1d 100644 --- a/src/test/ui/unsized/unsized-bare-typaram.stderr +++ b/src/test/ui/unsized/unsized-bare-typaram.stderr @@ -6,7 +6,7 @@ LL | fn foo() { bar::() } | | | this type parameter needs to be `std::marker::Sized` | -note: required by a bound in `bar` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized-bare-typaram.rs:1:8 | LL | fn bar() { } diff --git a/src/test/ui/unsized/unsized-enum.stderr b/src/test/ui/unsized/unsized-enum.stderr index 980dee87e58b4..fdff56aa82377 100644 --- a/src/test/ui/unsized/unsized-enum.stderr +++ b/src/test/ui/unsized/unsized-enum.stderr @@ -6,7 +6,7 @@ LL | fn foo2() { not_sized::>() } | | | this type parameter needs to be `std::marker::Sized` | -note: required by a bound in `Foo` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized-enum.rs:4:10 | LL | enum Foo { FooSome(U), FooNone } 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 1a3c7d788f0b8..1c0b7bd985593 100644 --- a/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr +++ b/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr @@ -6,7 +6,7 @@ LL | impl S5 { | | | this type parameter needs to be `std::marker::Sized` | -note: required by a bound in `S5` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized-inherent-impl-self-type.rs:5:11 | LL | struct S5(Y); diff --git a/src/test/ui/unsized/unsized-struct.stderr b/src/test/ui/unsized/unsized-struct.stderr index 1c70a840c77dc..a2abef2de08f9 100644 --- a/src/test/ui/unsized/unsized-struct.stderr +++ b/src/test/ui/unsized/unsized-struct.stderr @@ -6,7 +6,7 @@ LL | fn foo2() { not_sized::>() } | | | this type parameter needs to be `std::marker::Sized` | -note: required by a bound in `Foo` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized-struct.rs:4:12 | LL | struct Foo { data: T } @@ -37,7 +37,7 @@ note: required because it appears within the type `Bar` | LL | struct Bar { data: T } | ^^^ -note: required by a bound in `is_sized` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized-struct.rs:1:13 | LL | fn is_sized() { } 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 da251d4078b3e..b6a014994355e 100644 --- a/src/test/ui/unsized/unsized-trait-impl-self-type.stderr +++ b/src/test/ui/unsized/unsized-trait-impl-self-type.stderr @@ -6,7 +6,7 @@ LL | impl T3 for S5 { | | | this type parameter needs to be `std::marker::Sized` | -note: required by a bound in `S5` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized-trait-impl-self-type.rs:8:11 | LL | struct S5(Y); diff --git a/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr b/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr index e91419070f5f9..c526d46753384 100644 --- a/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr +++ b/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr @@ -6,7 +6,7 @@ LL | impl T2 for S4 { | | | this type parameter needs to be `std::marker::Sized` | -note: required by a bound in `T2` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized-trait-impl-trait-arg.rs:4:10 | LL | trait T2 { diff --git a/src/test/ui/unsized/unsized3.stderr b/src/test/ui/unsized/unsized3.stderr index ae89f2f997728..42636a7765686 100644 --- a/src/test/ui/unsized/unsized3.stderr +++ b/src/test/ui/unsized/unsized3.stderr @@ -8,7 +8,7 @@ LL | f2::(x); | | | required by a bound introduced by this call | -note: required by a bound in `f2` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized3.rs:10:7 | LL | fn f2(x: &X) { @@ -33,7 +33,7 @@ LL | f4::(x); | | | required by a bound introduced by this call | -note: required by a bound in `f4` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized3.rs:21:7 | LL | fn f4(x: &X) { @@ -63,7 +63,7 @@ note: required because it appears within the type `S` | LL | struct S { | ^ -note: required by a bound in `f5` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized3.rs:24:7 | LL | fn f5(x: &Y) {} diff --git a/src/test/ui/unsized/unsized7.stderr b/src/test/ui/unsized/unsized7.stderr index 3246e26e6eb7d..70447575edb9f 100644 --- a/src/test/ui/unsized/unsized7.stderr +++ b/src/test/ui/unsized/unsized7.stderr @@ -6,7 +6,7 @@ LL | impl T1 for S3 { | | | this type parameter needs to be `std::marker::Sized` | -note: required by a bound in `T1` +note: type parameters have an implicit `Sized` obligation --> $DIR/unsized7.rs:7:10 | LL | trait T1 { diff --git a/src/test/ui/wf/wf-fn-where-clause.stderr b/src/test/ui/wf/wf-fn-where-clause.stderr index 2aec641e71edc..ec470e6cf96e7 100644 --- a/src/test/ui/wf/wf-fn-where-clause.stderr +++ b/src/test/ui/wf/wf-fn-where-clause.stderr @@ -21,7 +21,7 @@ LL | fn bar() where Vec:, {} | ^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Copy + 'static)` -note: required by a bound in `Vec` +note: type parameters have an implicit `Sized` obligation --> $DIR/wf-fn-where-clause.rs:16:12 | LL | struct Vec { diff --git a/src/test/ui/wf/wf-impl-self-type.stderr b/src/test/ui/wf/wf-impl-self-type.stderr index 371321793adf8..fc31cd2cfe094 100644 --- a/src/test/ui/wf/wf-impl-self-type.stderr +++ b/src/test/ui/wf/wf-impl-self-type.stderr @@ -5,7 +5,7 @@ LL | impl Foo for Option<[u8]> {} | ^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` -note: required by a bound in `Option` +note: type parameters have an implicit `Sized` obligation --> $SRC_DIR/core/src/option.rs:LL:COL | LL | pub enum Option { diff --git a/src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.rs b/src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.rs index 4fcf8f403bbb6..151adbc3af235 100644 --- a/src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.rs +++ b/src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.rs @@ -10,8 +10,8 @@ pub struct Wrapper(T); #[repr(transparent)] pub struct Ref<'a>(&'a u8); -impl Trait for Ref {} //~ ERROR: implicit elided lifetime not allowed here +impl Trait for Ref {} //~ ERROR implicit elided lifetime not allowed here extern "C" { - pub fn repro(_: Wrapper); //~ ERROR: incompatible lifetime on type + pub fn repro(_: Wrapper); //~ ERROR incompatible lifetime on type } From bed395e823c874783908a4d6966d27c4e79cacbb Mon Sep 17 00:00:00 2001 From: Esteban Kuber Date: Mon, 13 Dec 2021 22:05:05 +0000 Subject: [PATCH 2/4] try to speed up try_fast_path sizedness check --- .../src/traits/query/type_op/prove_predicate.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs index 081308ac73e05..1be47bf78c989 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs @@ -16,6 +16,9 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> { // we have to prove. No need to canonicalize and all that for // such cases. if let ty::PredicateKind::Trait(trait_ref) = key.value.predicate.kind().skip_binder() { + if trait_ref.implicit == ty::ImplicitBound::Yes { + return Some(()); + } if let Some(sized_def_id) = tcx.lang_items().sized_trait() { if trait_ref.def_id() == sized_def_id { if trait_ref.self_ty().is_trivially_sized(tcx) { From d445c129eaa67a630089b824cba75105a8fd032a Mon Sep 17 00:00:00 2001 From: Esteban Kuber Date: Mon, 13 Dec 2021 22:50:17 +0000 Subject: [PATCH 3/4] TEST see if these were introducing a lot of evaluation churn --- .../rustc_trait_selection/src/traits/wf.rs | 10 +++++----- .../rustc_typeck/src/check/compare_method.rs | 16 +++++++++------- .../ui/associated-types/defaults-wf.stderr | 2 +- .../ui/associated-types/issue-20005.stderr | 2 +- .../ui/associated-types/issue-63593.stderr | 8 ++------ ...-with-supertraits-needing-sized-self.stderr | 2 +- .../generic_const_exprs/issue-80742.stderr | 2 +- src/test/ui/dst/dst-sized-trait-param.stderr | 2 +- src/test/ui/generator/sized-yield.stderr | 2 +- .../issue-74816.stderr | 8 ++------ src/test/ui/issues/issue-10412.stderr | 2 +- src/test/ui/issues/issue-18919.stderr | 2 +- src/test/ui/issues/issue-20433.stderr | 2 +- src/test/ui/issues/issue-23281.stderr | 2 +- .../issue-26548-recursion-via-normalize.rs | 4 ++-- .../issue-26548-recursion-via-normalize.stderr | 2 +- .../adt-param-with-implicit-sized-bound.stderr | 10 +++++----- ...-unsized-indirection-in-where-clause.stderr | 2 +- src/test/ui/trait-bounds/unsized-bound.stderr | 18 +++++++++--------- src/test/ui/traits/bad-sized.stderr | 4 ++-- src/test/ui/traits/issue-65673.stderr | 8 ++------ .../traits/mutual-recursion-issue-75860.stderr | 2 +- 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 +- .../unsized-trait-impl-trait-arg.stderr | 2 +- src/test/ui/unsized/unsized7.stderr | 2 +- src/test/ui/wf/wf-fn-where-clause.stderr | 2 +- src/test/ui/wf/wf-impl-self-type.stderr | 2 +- 30 files changed, 59 insertions(+), 69 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 342b78bbe654b..a634d17346fa3 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -710,12 +710,12 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { iter::zip(iter::zip(predicates.predicates, predicates.spans), origins.into_iter().rev()) .map(|((pred, span), origin_def_id)| { - let code = match pred.kind().skip_binder() { + let code = match () {// pred.kind().skip_binder() { _ if span.is_dummy() => traits::MiscObligation, - ty::PredicateKind::Trait(ty::TraitPredicate { - implicit: ty::ImplicitBound::Yes, - .. - }) => traits::ImplicitSizedObligation(origin_def_id, span), + // ty::PredicateKind::Trait(ty::TraitPredicate { + // implicit: ty::ImplicitBound::Yes, + // .. + // }) => traits::ImplicitSizedObligation(origin_def_id, span), _ => traits::BindingObligation(origin_def_id, span), }; let cause = self.cause(code); diff --git a/compiler/rustc_typeck/src/check/compare_method.rs b/compiler/rustc_typeck/src/check/compare_method.rs index 41166d01914b8..0e26f31025696 100644 --- a/compiler/rustc_typeck/src/check/compare_method.rs +++ b/compiler/rustc_typeck/src/check/compare_method.rs @@ -1378,16 +1378,17 @@ pub fn check_type_bounds<'tcx>( let impl_ty_hir_id = tcx.hir().local_def_id_to_hir_id(impl_ty.def_id.expect_local()); let normalize_cause = traits::ObligationCause::misc(impl_ty_span, impl_ty_hir_id); - let mk_cause = |bound, span: Span| { + // let mk_cause = |bound, span: Span| { + let mk_cause = |span: Span| { ObligationCause::new( impl_ty_span, impl_ty_hir_id, - match bound { + match () { _ if span.is_dummy() => traits::MiscObligation, - ty::PredicateKind::Trait(ty::TraitPredicate { - implicit: ty::ImplicitBound::Yes, - .. - }) => traits::ImplicitSizedObligation(trait_ty.def_id, span), + // ty::PredicateKind::Trait(ty::TraitPredicate { + // implicit: ty::ImplicitBound::Yes, + // .. + // }) => traits::ImplicitSizedObligation(trait_ty.def_id, span), _ => ObligationCauseCode::BindingObligation(trait_ty.def_id, span), }, ) @@ -1402,7 +1403,8 @@ pub fn check_type_bounds<'tcx>( debug!("check_type_bounds: concrete_ty_bound = {:?}", concrete_ty_bound); traits::Obligation::new( - mk_cause(bound.kind().skip_binder(), span), + // mk_cause(bound.kind().skip_binder(), span), + mk_cause(span), param_env, concrete_ty_bound, ) diff --git a/src/test/ui/associated-types/defaults-wf.stderr b/src/test/ui/associated-types/defaults-wf.stderr index 186bc6316406a..8455f88f18e7a 100644 --- a/src/test/ui/associated-types/defaults-wf.stderr +++ b/src/test/ui/associated-types/defaults-wf.stderr @@ -5,7 +5,7 @@ LL | type Ty = Vec<[u8]>; | ^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Vec` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | LL | pub struct Vec { diff --git a/src/test/ui/associated-types/issue-20005.stderr b/src/test/ui/associated-types/issue-20005.stderr index 3dcc85201a020..c8e57df0d9fee 100644 --- a/src/test/ui/associated-types/issue-20005.stderr +++ b/src/test/ui/associated-types/issue-20005.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | ) -> >::Result where Dst: From { | ^^^^^^^^^^ doesn't have a size known at compile-time | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `From` --> $DIR/issue-20005.rs:1:12 | LL | trait From { diff --git a/src/test/ui/associated-types/issue-63593.stderr b/src/test/ui/associated-types/issue-63593.stderr index 2070e09c848b1..f643ec3ff1fdc 100644 --- a/src/test/ui/associated-types/issue-63593.stderr +++ b/src/test/ui/associated-types/issue-63593.stderr @@ -4,19 +4,15 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | type This = Self; | ^^^^ doesn't have a size known at compile-time | -note: associated types have an implicit `Sized` obligation +note: required by a bound in `MyTrait::This` --> $DIR/issue-63593.rs:9:5 | LL | type This = Self; - | ^^^^^^^^^^^^^^^^^ required by associated type `MyTrait::This` + | ^^^^^^^^^^^^^^^^^ required by this bound in `MyTrait::This` help: consider further restricting `Self` | LL | trait MyTrait: Sized { | +++++++ -help: consider relaxing the `Sized` obligation - | -LL | type This: ?Sized = Self; - | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/associated-types/trait-with-supertraits-needing-sized-self.stderr b/src/test/ui/associated-types/trait-with-supertraits-needing-sized-self.stderr index 017d34a2492b2..558b0f5c8a368 100644 --- a/src/test/ui/associated-types/trait-with-supertraits-needing-sized-self.stderr +++ b/src/test/ui/associated-types/trait-with-supertraits-needing-sized-self.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | trait ArithmeticOps: Add + Sub + Mul + Div {} | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Add` --> $SRC_DIR/core/src/ops/arith.rs:LL:COL | LL | pub trait Add { diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-80742.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-80742.stderr index 459e710b98f7a..56cb11bacbe6b 100644 --- a/src/test/ui/const-generics/generic_const_exprs/issue-80742.stderr +++ b/src/test/ui/const-generics/generic_const_exprs/issue-80742.stderr @@ -56,7 +56,7 @@ LL | let dst = Inline::::new(0); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `dyn Debug` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Inline` --> $DIR/issue-80742.rs:12:15 | LL | struct Inline diff --git a/src/test/ui/dst/dst-sized-trait-param.stderr b/src/test/ui/dst/dst-sized-trait-param.stderr index 5b599d0e4d0e1..8ec94f5a3c0ad 100644 --- a/src/test/ui/dst/dst-sized-trait-param.stderr +++ b/src/test/ui/dst/dst-sized-trait-param.stderr @@ -5,7 +5,7 @@ LL | impl Foo<[isize]> for usize { } | ^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[isize]` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Foo` --> $DIR/dst-sized-trait-param.rs:5:11 | LL | trait Foo : Sized { fn take(self, x: &T) { } } // Note: T is sized diff --git a/src/test/ui/generator/sized-yield.stderr b/src/test/ui/generator/sized-yield.stderr index 4f47adb4d85e9..ea2a48d13cee6 100644 --- a/src/test/ui/generator/sized-yield.stderr +++ b/src/test/ui/generator/sized-yield.stderr @@ -18,7 +18,7 @@ LL | Pin::new(&mut gen).resume(()); | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `GeneratorState` --> $SRC_DIR/core/src/ops/generator.rs:LL:COL | LL | pub enum GeneratorState { diff --git a/src/test/ui/generic-associated-types/issue-74816.stderr b/src/test/ui/generic-associated-types/issue-74816.stderr index 1cc6fc381e8f0..9eaa74e343e4b 100644 --- a/src/test/ui/generic-associated-types/issue-74816.stderr +++ b/src/test/ui/generic-associated-types/issue-74816.stderr @@ -20,19 +20,15 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | type Associated: Trait1 = Self; | ^^^^ doesn't have a size known at compile-time | -note: associated types have an implicit `Sized` obligation +note: required by a bound in `Trait2::Associated` --> $DIR/issue-74816.rs:9:5 | LL | type Associated: Trait1 = Self; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by associated type `Trait2::Associated` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Trait2::Associated` help: consider further restricting `Self` | LL | trait Trait2: Sized { | +++++++ -help: consider relaxing the `Sized` obligation - | -LL | type Associated: Trait1 + ?Sized = Self; - | ++++++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-10412.stderr b/src/test/ui/issues/issue-10412.stderr index 55daf4135dbdb..053a93e6cd8c7 100644 --- a/src/test/ui/issues/issue-10412.stderr +++ b/src/test/ui/issues/issue-10412.stderr @@ -55,7 +55,7 @@ LL | impl<'self> Serializable for &'self str { | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Serializable` --> $DIR/issue-10412.rs:1:27 | LL | trait Serializable<'self, T> { diff --git a/src/test/ui/issues/issue-18919.stderr b/src/test/ui/issues/issue-18919.stderr index 11342e26948c5..d7dbb8299b9ef 100644 --- a/src/test/ui/issues/issue-18919.stderr +++ b/src/test/ui/issues/issue-18919.stderr @@ -5,7 +5,7 @@ LL | fn ho_func(f: Option) { | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `dyn for<'r> Fn(&'r isize) -> isize` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Option` --> $DIR/issue-18919.rs:7:13 | LL | enum Option { diff --git a/src/test/ui/issues/issue-20433.stderr b/src/test/ui/issues/issue-20433.stderr index 5a28f0233a15f..9d3bb8b924d61 100644 --- a/src/test/ui/issues/issue-20433.stderr +++ b/src/test/ui/issues/issue-20433.stderr @@ -5,7 +5,7 @@ LL | fn iceman(c: Vec<[i32]>) {} | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[i32]` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Vec` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | LL | pub struct Vec { diff --git a/src/test/ui/issues/issue-23281.stderr b/src/test/ui/issues/issue-23281.stderr index 69f687df68238..804334c9b0d24 100644 --- a/src/test/ui/issues/issue-23281.stderr +++ b/src/test/ui/issues/issue-23281.stderr @@ -5,7 +5,7 @@ LL | pub fn function(funs: Vec ()>) {} | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Fn() + 'static)` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Vec` --> $DIR/issue-23281.rs:8:12 | LL | struct Vec { diff --git a/src/test/ui/recursion/issue-26548-recursion-via-normalize.rs b/src/test/ui/recursion/issue-26548-recursion-via-normalize.rs index b9f8fa1749a0d..8fdc9c2294551 100644 --- a/src/test/ui/recursion/issue-26548-recursion-via-normalize.rs +++ b/src/test/ui/recursion/issue-26548-recursion-via-normalize.rs @@ -1,4 +1,4 @@ -trait Mirror { +trait Mirror { //~ NOTE required by a bound in this type It: ?Sized; } impl Mirror for T { @@ -7,7 +7,7 @@ impl Mirror for T { struct S(Option<::It>); //~^ ERROR overflow evaluating the requirement `S: Sized` //~| NOTE required because it appears within the type `S` -//~| NOTE type parameters have an implicit `Sized` obligation +//~| NOTE required by a bound in `Option` fn main() { let _s = S(None); diff --git a/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr b/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr index be318a3508108..a583e0fceb0dc 100644 --- a/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr +++ b/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr @@ -9,7 +9,7 @@ note: required because it appears within the type `S` | LL | struct S(Option<::It>); | ^ -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Option` --> $SRC_DIR/core/src/option.rs:LL:COL | LL | pub enum Option { diff --git a/src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr b/src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr index 43f774d6231dc..fb40c260e2d0c 100644 --- a/src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr +++ b/src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | fn func1() -> Struct1; | ^^^^^^^^^^^^^ doesn't have a size known at compile-time | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Struct1` --> $DIR/adt-param-with-implicit-sized-bound.rs:8:16 | LL | struct Struct1{ @@ -24,7 +24,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | fn func2<'a>() -> Struct2<'a, Self>; | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Struct2` --> $DIR/adt-param-with-implicit-sized-bound.rs:11:20 | LL | struct Struct2<'a, T>{ @@ -44,7 +44,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | fn func3() -> Struct3; | ^^^^^^^^^^^^^ doesn't have a size known at compile-time | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Struct3` --> $DIR/adt-param-with-implicit-sized-bound.rs:14:16 | LL | struct Struct3{ @@ -67,7 +67,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | fn func4() -> Struct4; | ^^^^^^^^^^^^^ doesn't have a size known at compile-time | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Struct4` --> $DIR/adt-param-with-implicit-sized-bound.rs:20:16 | LL | struct Struct4{ @@ -89,7 +89,7 @@ LL | struct Struct5{ LL | _t: X, | ^^^^ doesn't have a size known at compile-time | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `X` --> $DIR/adt-param-with-implicit-sized-bound.rs:18:10 | LL | struct X(T); diff --git a/src/test/ui/suggestions/issue-85943-no-suggest-unsized-indirection-in-where-clause.stderr b/src/test/ui/suggestions/issue-85943-no-suggest-unsized-indirection-in-where-clause.stderr index c95f1fb366e65..752533cdc1213 100644 --- a/src/test/ui/suggestions/issue-85943-no-suggest-unsized-indirection-in-where-clause.stderr +++ b/src/test/ui/suggestions/issue-85943-no-suggest-unsized-indirection-in-where-clause.stderr @@ -5,7 +5,7 @@ LL | struct B(A<[u8]>); | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `A` --> $DIR/issue-85943-no-suggest-unsized-indirection-in-where-clause.rs:4:10 | LL | struct A(T) where T: Send; diff --git a/src/test/ui/trait-bounds/unsized-bound.stderr b/src/test/ui/trait-bounds/unsized-bound.stderr index d7621de3dccc2..0c758c9ba266f 100644 --- a/src/test/ui/trait-bounds/unsized-bound.stderr +++ b/src/test/ui/trait-bounds/unsized-bound.stderr @@ -7,7 +7,7 @@ LL | impl Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} | this type parameter needs to be `std::marker::Sized` | = note: required because it appears within the type `(A, B)` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Trait` --> $DIR/unsized-bound.rs:1:13 | LL | trait Trait {} @@ -46,7 +46,7 @@ LL | impl Trait<(A, B, C)> for (A, B, C) where A: ?Size | this type parameter needs to be `std::marker::Sized` | = note: required because it appears within the type `(A, B, C)` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Trait` --> $DIR/unsized-bound.rs:1:13 | LL | trait Trait {} @@ -100,7 +100,7 @@ LL | impl Trait2<(A, B)> for (A, B) {} | this type parameter needs to be `std::marker::Sized` | = note: required because it appears within the type `(A, B)` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Trait2` --> $DIR/unsized-bound.rs:9:14 | LL | trait Trait2 {} @@ -138,7 +138,7 @@ LL | impl Trait3 for A where A: ?Sized {} | | | this type parameter needs to be `std::marker::Sized` | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Trait3` --> $DIR/unsized-bound.rs:13:14 | LL | trait Trait3 {} @@ -161,7 +161,7 @@ LL | impl Trait4 for A {} | | | this type parameter needs to be `std::marker::Sized` | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Trait4` --> $DIR/unsized-bound.rs:16:14 | LL | trait Trait4 {} @@ -184,7 +184,7 @@ LL | impl Trait5 for X where X: ?Sized {} | | | this type parameter needs to be `std::marker::Sized` | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Trait5` --> $DIR/unsized-bound.rs:19:14 | LL | trait Trait5 {} @@ -207,7 +207,7 @@ LL | impl Trait6 for X {} | | | this type parameter needs to be `std::marker::Sized` | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Trait6` --> $DIR/unsized-bound.rs:22:14 | LL | trait Trait6 {} @@ -230,7 +230,7 @@ LL | impl Trait7 for X where Y: ?Sized {} | | | this type parameter needs to be `std::marker::Sized` | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Trait7` --> $DIR/unsized-bound.rs:25:17 | LL | trait Trait7 {} @@ -253,7 +253,7 @@ LL | impl Trait8 for X {} | | | this type parameter needs to be `std::marker::Sized` | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Trait8` --> $DIR/unsized-bound.rs:28:17 | LL | trait Trait8 {} diff --git a/src/test/ui/traits/bad-sized.stderr b/src/test/ui/traits/bad-sized.stderr index 7ea1a235233d5..27d568b7c0bea 100644 --- a/src/test/ui/traits/bad-sized.stderr +++ b/src/test/ui/traits/bad-sized.stderr @@ -16,7 +16,7 @@ LL | let x: Vec = Vec::new(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `dyn Trait` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Vec` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | LL | pub struct Vec { @@ -42,7 +42,7 @@ LL | let x: Vec = Vec::new(); | ^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `dyn Trait` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Vec` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | LL | pub struct Vec { diff --git a/src/test/ui/traits/issue-65673.stderr b/src/test/ui/traits/issue-65673.stderr index 5e8231213c048..245c4ee525eab 100644 --- a/src/test/ui/traits/issue-65673.stderr +++ b/src/test/ui/traits/issue-65673.stderr @@ -5,15 +5,11 @@ LL | type Ctx = dyn Alias; | ^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Trait + 'static)` -note: associated types have an implicit `Sized` obligation +note: required by a bound in `WithType::Ctx` --> $DIR/issue-65673.rs:4:5 | LL | type Ctx; - | ^^^^^^^^^ required by associated type `WithType::Ctx` -help: consider relaxing the `Sized` obligation - | -LL | type Ctx: ?Sized; - | ++++++++ + | ^^^^^^^^^ required by this bound in `WithType::Ctx` error: aborting due to previous error diff --git a/src/test/ui/traits/mutual-recursion-issue-75860.stderr b/src/test/ui/traits/mutual-recursion-issue-75860.stderr index ae59d4db2144b..aa229cc4256ee 100644 --- a/src/test/ui/traits/mutual-recursion-issue-75860.stderr +++ b/src/test/ui/traits/mutual-recursion-issue-75860.stderr @@ -6,7 +6,7 @@ LL | iso(left, right) | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`mutual_recursion_issue_75860`) = note: required because it appears within the type `Option>` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Option` --> $SRC_DIR/core/src/option.rs:LL:COL | LL | pub enum Option { diff --git a/src/test/ui/unsized/unsized-enum.stderr b/src/test/ui/unsized/unsized-enum.stderr index fdff56aa82377..980dee87e58b4 100644 --- a/src/test/ui/unsized/unsized-enum.stderr +++ b/src/test/ui/unsized/unsized-enum.stderr @@ -6,7 +6,7 @@ LL | fn foo2() { not_sized::>() } | | | this type parameter needs to be `std::marker::Sized` | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Foo` --> $DIR/unsized-enum.rs:4:10 | LL | enum Foo { FooSome(U), FooNone } 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 1c0b7bd985593..1a3c7d788f0b8 100644 --- a/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr +++ b/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr @@ -6,7 +6,7 @@ LL | impl S5 { | | | this type parameter needs to be `std::marker::Sized` | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `S5` --> $DIR/unsized-inherent-impl-self-type.rs:5:11 | LL | struct S5(Y); diff --git a/src/test/ui/unsized/unsized-struct.stderr b/src/test/ui/unsized/unsized-struct.stderr index a2abef2de08f9..daa3088fa8c8a 100644 --- a/src/test/ui/unsized/unsized-struct.stderr +++ b/src/test/ui/unsized/unsized-struct.stderr @@ -6,7 +6,7 @@ LL | fn foo2() { not_sized::>() } | | | this type parameter needs to be `std::marker::Sized` | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Foo` --> $DIR/unsized-struct.rs:4:12 | LL | struct Foo { data: T } 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 b6a014994355e..da251d4078b3e 100644 --- a/src/test/ui/unsized/unsized-trait-impl-self-type.stderr +++ b/src/test/ui/unsized/unsized-trait-impl-self-type.stderr @@ -6,7 +6,7 @@ LL | impl T3 for S5 { | | | this type parameter needs to be `std::marker::Sized` | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `S5` --> $DIR/unsized-trait-impl-self-type.rs:8:11 | LL | struct S5(Y); diff --git a/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr b/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr index c526d46753384..e91419070f5f9 100644 --- a/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr +++ b/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr @@ -6,7 +6,7 @@ LL | impl T2 for S4 { | | | this type parameter needs to be `std::marker::Sized` | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `T2` --> $DIR/unsized-trait-impl-trait-arg.rs:4:10 | LL | trait T2 { diff --git a/src/test/ui/unsized/unsized7.stderr b/src/test/ui/unsized/unsized7.stderr index 70447575edb9f..3246e26e6eb7d 100644 --- a/src/test/ui/unsized/unsized7.stderr +++ b/src/test/ui/unsized/unsized7.stderr @@ -6,7 +6,7 @@ LL | impl T1 for S3 { | | | this type parameter needs to be `std::marker::Sized` | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `T1` --> $DIR/unsized7.rs:7:10 | LL | trait T1 { diff --git a/src/test/ui/wf/wf-fn-where-clause.stderr b/src/test/ui/wf/wf-fn-where-clause.stderr index ec470e6cf96e7..2aec641e71edc 100644 --- a/src/test/ui/wf/wf-fn-where-clause.stderr +++ b/src/test/ui/wf/wf-fn-where-clause.stderr @@ -21,7 +21,7 @@ LL | fn bar() where Vec:, {} | ^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Copy + 'static)` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Vec` --> $DIR/wf-fn-where-clause.rs:16:12 | LL | struct Vec { diff --git a/src/test/ui/wf/wf-impl-self-type.stderr b/src/test/ui/wf/wf-impl-self-type.stderr index fc31cd2cfe094..371321793adf8 100644 --- a/src/test/ui/wf/wf-impl-self-type.stderr +++ b/src/test/ui/wf/wf-impl-self-type.stderr @@ -5,7 +5,7 @@ LL | impl Foo for Option<[u8]> {} | ^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Option` --> $SRC_DIR/core/src/option.rs:LL:COL | LL | pub enum Option { From 979937e1ecf1ddd59d722b3772ecda4721bbb81c Mon Sep 17 00:00:00 2001 From: Esteban Kuber Date: Wed, 15 Dec 2021 02:37:30 +0000 Subject: [PATCH 4/4] remove implicit field --- .../src/type_check/canonical.rs | 2 +- .../src/transform/check_consts/check.rs | 2 +- .../src/transform/check_consts/qualifs.rs | 2 +- compiler/rustc_middle/src/ty/mod.rs | 44 ++++++------ compiler/rustc_middle/src/ty/relate.rs | 30 ++++---- .../rustc_middle/src/ty/structural_impls.rs | 2 +- compiler/rustc_middle/src/ty/sty.rs | 2 +- compiler/rustc_privacy/src/lib.rs | 2 +- .../src/traits/auto_trait.rs | 2 +- .../rustc_trait_selection/src/traits/mod.rs | 2 +- .../traits/query/type_op/prove_predicate.rs | 3 - .../src/traits/relationships.rs | 2 +- .../src/traits/select/candidate_assembly.rs | 4 +- .../rustc_trait_selection/src/traits/util.rs | 8 +-- compiler/rustc_typeck/src/bounds.rs | 2 +- compiler/rustc_typeck/src/check/_match.rs | 2 +- .../src/impl_wf_check/min_specialization.rs | 4 +- src/test/ui/box/into-boxed-slice-fail.stderr | 4 +- src/test/ui/error-codes/E0275.stderr | 11 +-- .../ui/extern/extern-types-unsized.stderr | 8 +-- .../projection-bound-cycle-generic.stderr | 4 +- .../projection-bound-cycle.stderr | 4 +- ...e-param-can-reference-self-in-trait.stderr | 4 +- .../issue-60283.stderr | 2 +- .../issue-62529-1.stderr | 2 +- .../cannot-infer-partial-try-return.stderr | 6 +- src/test/ui/issues/issue-17651.stderr | 2 +- src/test/ui/issues/issue-20413.stderr | 68 +++++++------------ src/test/ui/issues/issue-87199.stderr | 2 +- src/test/ui/range/range-1.stderr | 15 +--- src/test/ui/str/str-mut-idx.stderr | 2 +- .../ui/suggestions/bound-suggestions.stderr | 10 +-- .../suggestions/issue-84973-blacklist.stderr | 2 +- ...re-clause-before-suggesting-unsized.stderr | 2 +- src/test/ui/traits/bad-sized.stderr | 2 +- .../mutual-recursion-issue-75860.stderr | 1 - .../ui/traits/suggest-where-clause.stderr | 8 +-- .../ui/unsized/unsized-bare-typaram.stderr | 2 +- src/test/ui/unsized/unsized-struct.stderr | 2 +- src/test/ui/unsized/unsized3.stderr | 6 +- 40 files changed, 122 insertions(+), 162 deletions(-) diff --git a/compiler/rustc_borrowck/src/type_check/canonical.rs b/compiler/rustc_borrowck/src/type_check/canonical.rs index 57a5584421139..18a6605aa35a4 100644 --- a/compiler/rustc_borrowck/src/type_check/canonical.rs +++ b/compiler/rustc_borrowck/src/type_check/canonical.rs @@ -95,7 +95,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { trait_ref, constness: ty::BoundConstness::NotConst, polarity: ty::ImplPolarity::Positive, - implicit: ty::ImplicitBound::No, + // implicit: ty::ImplicitBound::No, }))), locations, category, diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index a64229b42b69e..0e74015b1d290 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -813,7 +813,7 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> { trait_ref, constness: ty::BoundConstness::ConstIfConst, polarity: ty::ImplPolarity::Positive, - implicit: ty::ImplicitBound::No, + // implicit: ty::ImplicitBound::No, }), ); diff --git a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs index fc19617617745..2939b2b32eb83 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs @@ -162,7 +162,7 @@ impl Qualif for NeedsNonConstDrop { trait_ref, constness: ty::BoundConstness::ConstIfConst, polarity: ty::ImplPolarity::Positive, - implicit: ty::ImplicitBound::No, + // implicit: ty::ImplicitBound::No, }), ); diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 215d4a041befe..96bb590e3a203 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -165,24 +165,24 @@ pub struct ImplHeader<'tcx> { pub predicates: Vec>, } -#[derive( - Copy, - Clone, - PartialEq, - Eq, - Hash, - TyEncodable, - TyDecodable, - HashStable, - Debug, - TypeFoldable -)] -pub enum ImplicitBound { - /// `T: Trait` - No, - /// implicit `T: Sized` - Yes, -} +// #[derive( +// Copy, +// Clone, +// PartialEq, +// Eq, +// Hash, +// TyEncodable, +// TyDecodable, +// HashStable, +// Debug, +// TypeFoldable +// )] +// pub enum ImplicitBound { +// /// `T: Trait` +// No, +// /// implicit `T: Sized` +// Yes, +// } #[derive( Copy, @@ -541,12 +541,12 @@ impl<'tcx> Predicate<'tcx> { trait_ref, constness, polarity, - implicit, + // implicit, }) => Some(PredicateKind::Trait(TraitPredicate { trait_ref, constness, polarity: polarity.flip()?, - implicit, + // implicit, })), _ => None, @@ -753,7 +753,7 @@ pub struct TraitPredicate<'tcx> { pub polarity: ImplPolarity, - pub implicit: ImplicitBound, + // pub implicit: ImplicitBound, } pub type PolyTraitPredicate<'tcx> = ty::Binder<'tcx, TraitPredicate<'tcx>>; @@ -1450,7 +1450,7 @@ impl PolyTraitRef<'tcx> { trait_ref, constness, polarity: ty::ImplPolarity::Positive, - implicit: ty::ImplicitBound::No, + // implicit: ty::ImplicitBound::No, }) } #[inline] diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs index 7c2cc6509433f..9763991d99a1a 100644 --- a/compiler/rustc_middle/src/ty/relate.rs +++ b/compiler/rustc_middle/src/ty/relate.rs @@ -788,20 +788,20 @@ impl<'tcx> Relate<'tcx> for GenericArg<'tcx> { } } -impl<'tcx> Relate<'tcx> for ty::ImplicitBound { - fn relate>( - _relation: &mut R, - a: ty::ImplicitBound, - b: ty::ImplicitBound, - ) -> RelateResult<'tcx, ty::ImplicitBound> { - match (a, b) { - (ty::ImplicitBound::No, ty::ty::ImplicitBound::No) => Ok(ty::ImplicitBound::No), - (ty::ImplicitBound::Yes, ty::ty::ImplicitBound::Yes) - | (ty::ImplicitBound::Yes, ty::ty::ImplicitBound::No) - | (ty::ImplicitBound::No, ty::ty::ImplicitBound::Yes) => Ok(ty::ImplicitBound::Yes), - } - } -} +// impl<'tcx> Relate<'tcx> for ty::ImplicitBound { +// fn relate>( +// _relation: &mut R, +// a: ty::ImplicitBound, +// b: ty::ImplicitBound, +// ) -> RelateResult<'tcx, ty::ImplicitBound> { +// match (a, b) { +// (ty::ImplicitBound::No, ty::ty::ImplicitBound::No) => Ok(ty::ImplicitBound::No), +// (ty::ImplicitBound::Yes, ty::ty::ImplicitBound::Yes) +// | (ty::ImplicitBound::Yes, ty::ty::ImplicitBound::No) +// | (ty::ImplicitBound::No, ty::ty::ImplicitBound::Yes) => Ok(ty::ImplicitBound::Yes), +// } +// } +// } impl<'tcx> Relate<'tcx> for ty::ImplPolarity { fn relate>( @@ -827,7 +827,7 @@ impl<'tcx> Relate<'tcx> for ty::TraitPredicate<'tcx> { trait_ref: relation.relate(a.trait_ref, b.trait_ref)?, constness: relation.relate(a.constness, b.constness)?, polarity: relation.relate(a.polarity, b.polarity)?, - implicit: relation.relate(a.implicit, b.implicit)?, + // implicit: relation.relate(a.implicit, b.implicit)?, }) } } diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index dfb0ac201f1a8..6604a4af63a7b 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -369,7 +369,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> { trait_ref, constness: self.constness, polarity: self.polarity, - implicit: ty::ImplicitBound::No, + // implicit: ty::ImplicitBound::No, }) } } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 4d434e820f823..52f3f54ca4523 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -944,7 +944,7 @@ impl<'tcx> PolyTraitRef<'tcx> { trait_ref, constness: ty::BoundConstness::NotConst, polarity: ty::ImplPolarity::Positive, - implicit: ty::ImplicitBound::No, + // implicit: ty::ImplicitBound::No, }) } } diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 4b9296fc10666..0c237347d9e24 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -128,7 +128,7 @@ where trait_ref, constness: _, polarity: _, - implicit: _, + // implicit: _, }) => self.visit_trait(trait_ref), ty::PredicateKind::Projection(ty::ProjectionPredicate { projection_ty, ty }) => { ty.visit_with(self)?; diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index a1c614d74b5d4..1ca1c32f816a1 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -290,7 +290,7 @@ impl AutoTraitFinder<'tcx> { constness: ty::BoundConstness::NotConst, // Auto traits are positive polarity: ty::ImplPolarity::Positive, - implicit: ty::ImplicitBound::No, + // implicit: ty::ImplicitBound::No, })); let computed_preds = param_env.caller_bounds().iter(); diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 0f43db479679d..03a81397fb2f3 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -826,7 +826,7 @@ pub fn vtable_trait_upcasting_coercion_new_vptr_slot( trait_ref, constness: ty::BoundConstness::NotConst, polarity: ty::ImplPolarity::Positive, - implicit: ty::ImplicitBound::No, + // implicit: ty::ImplicitBound::No, }), ); diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs index 1be47bf78c989..081308ac73e05 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs @@ -16,9 +16,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> { // we have to prove. No need to canonicalize and all that for // such cases. if let ty::PredicateKind::Trait(trait_ref) = key.value.predicate.kind().skip_binder() { - if trait_ref.implicit == ty::ImplicitBound::Yes { - return Some(()); - } if let Some(sized_def_id) = tcx.lang_items().sized_trait() { if trait_ref.def_id() == sized_def_id { if trait_ref.self_ty().is_trivially_sized(tcx) { diff --git a/compiler/rustc_trait_selection/src/traits/relationships.rs b/compiler/rustc_trait_selection/src/traits/relationships.rs index 6c75f75f2dcb5..6cce57786402c 100644 --- a/compiler/rustc_trait_selection/src/traits/relationships.rs +++ b/compiler/rustc_trait_selection/src/traits/relationships.rs @@ -45,7 +45,7 @@ pub(crate) fn update<'tcx, T>( trait_ref, constness: predicate.constness, polarity: predicate.polarity, - implicit: predicate.implicit, + // implicit: predicate.implicit, }) }) .to_predicate(infcx.tcx), diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index 89d71ab33acfb..b537dd30fba8c 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -935,7 +935,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { }, constness: ty::BoundConstness::NotConst, polarity: ty::ImplPolarity::Positive, - implicit: ty::ImplicitBound::No, + // implicit: ty::ImplicitBound::No, })); copy_obligation.recursion_depth = depth + 1; self.assemble_candidates_from_impls(©_obligation, &mut new_candidates); @@ -952,7 +952,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { }, constness: ty::BoundConstness::ConstIfConst, polarity: ty::ImplPolarity::Positive, - implicit: ty::ImplicitBound::No, + // implicit: ty::ImplicitBound::No, })); let const_drop_stack = self.push_stack(obligation_stack.list(), &const_drop_obligation); diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs index f2c7b7ecb4b07..90b032df392d7 100644 --- a/compiler/rustc_trait_selection/src/traits/util.rs +++ b/compiler/rustc_trait_selection/src/traits/util.rs @@ -237,10 +237,10 @@ pub fn predicates_for_generics<'tcx>( cause.span, cause.body_id, match predicate.kind().skip_binder() { - ty::PredicateKind::Trait(ty::TraitPredicate { - implicit: ty::ImplicitBound::Yes, - .. - }) => traits::ImplicitSizedObligation(def_id, span), + // ty::PredicateKind::Trait(ty::TraitPredicate { + // implicit: ty::ImplicitBound::Yes, + // .. + // }) => traits::ImplicitSizedObligation(def_id, span), _ => traits::BindingObligation(def_id, span), }, ), diff --git a/compiler/rustc_typeck/src/bounds.rs b/compiler/rustc_typeck/src/bounds.rs index 17459a491f5c5..df3001ab7d7d7 100644 --- a/compiler/rustc_typeck/src/bounds.rs +++ b/compiler/rustc_typeck/src/bounds.rs @@ -63,7 +63,7 @@ impl<'tcx> Bounds<'tcx> { }, constness: ty::BoundConstness::NotConst, polarity: ty::ImplPolarity::Positive, - implicit: ty::ImplicitBound::Yes, + // implicit: ty::ImplicitBound::Yes, })) .to_predicate(tcx); (pred, span) diff --git a/compiler/rustc_typeck/src/check/_match.rs b/compiler/rustc_typeck/src/check/_match.rs index d4112a149c8e6..bfd956e644d71 100644 --- a/compiler/rustc_typeck/src/check/_match.rs +++ b/compiler/rustc_typeck/src/check/_match.rs @@ -531,7 +531,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }, constness: t.constness, polarity: t.polarity, - implicit: t.implicit, + // implicit: t.implicit, })); let obl = Obligation::new( o.cause.clone(), diff --git a/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs b/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs index 61169a6ca3636..6a41d8f775618 100644 --- a/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs +++ b/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs @@ -383,7 +383,7 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tc trait_ref, constness: ty::BoundConstness::NotConst, polarity: _, - implicit: _, + // implicit: _, }) => { if !matches!( trait_predicate_kind(tcx, predicate), @@ -416,7 +416,7 @@ fn trait_predicate_kind<'tcx>( trait_ref, constness: ty::BoundConstness::NotConst, polarity: _, - implicit: _, + // implicit: _, }) => Some(tcx.trait_def(trait_ref.def_id).specialization_kind), ty::PredicateKind::Trait(_) | ty::PredicateKind::RegionOutlives(_) diff --git a/src/test/ui/box/into-boxed-slice-fail.stderr b/src/test/ui/box/into-boxed-slice-fail.stderr index 18ad72a87e199..de654fdc1a4b5 100644 --- a/src/test/ui/box/into-boxed-slice-fail.stderr +++ b/src/test/ui/box/into-boxed-slice-fail.stderr @@ -7,7 +7,7 @@ LL | let _ = Box::into_boxed_slice(boxed_slice); | required by a bound introduced by this call | = help: the trait `Sized` is not implemented for `[u8]` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Box::::into_boxed_slice` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL | LL | impl Box { @@ -31,7 +31,7 @@ LL | let _ = Box::into_boxed_slice(boxed_trait); | required by a bound introduced by this call | = help: the trait `Sized` is not implemented for `dyn Debug` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Box::::into_boxed_slice` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL | LL | impl Box { diff --git a/src/test/ui/error-codes/E0275.stderr b/src/test/ui/error-codes/E0275.stderr index a4d01f65384c2..dfffbb182ad31 100644 --- a/src/test/ui/error-codes/E0275.stderr +++ b/src/test/ui/error-codes/E0275.stderr @@ -1,21 +1,16 @@ -error[E0275]: overflow evaluating the requirement `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Sized` +error[E0275]: overflow evaluating the requirement `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Foo` --> $DIR/E0275.rs:5:33 | LL | impl Foo for T where Bar: Foo {} | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`E0275`) -note: required because it appears within the type `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/E0275.rs:3:8 - | -LL | struct Bar(T); - | ^^^ -note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` +note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` --> $DIR/E0275.rs:5:9 | LL | impl Foo for T where Bar: Foo {} | ^^^ ^ - = note: 126 redundant requirements hidden + = note: 127 redundant requirements hidden = note: required because of the requirements on the impl of `Foo` for `Bar` error: aborting due to previous error diff --git a/src/test/ui/extern/extern-types-unsized.stderr b/src/test/ui/extern/extern-types-unsized.stderr index 41b67ebfa50d1..8d6713261d5ec 100644 --- a/src/test/ui/extern/extern-types-unsized.stderr +++ b/src/test/ui/extern/extern-types-unsized.stderr @@ -5,7 +5,7 @@ LL | assert_sized::(); | ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `A` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `assert_sized` --> $DIR/extern-types-unsized.rs:19:17 | LL | fn assert_sized() {} @@ -27,7 +27,7 @@ note: required because it appears within the type `Foo` | LL | struct Foo { | ^^^ -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `assert_sized` --> $DIR/extern-types-unsized.rs:19:17 | LL | fn assert_sized() {} @@ -49,7 +49,7 @@ note: required because it appears within the type `Bar` | LL | struct Bar { | ^^^ -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `assert_sized` --> $DIR/extern-types-unsized.rs:19:17 | LL | fn assert_sized() {} @@ -71,7 +71,7 @@ note: required because it appears within the type `Bar` | LL | struct Bar { | ^^^ -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `assert_sized` --> $DIR/extern-types-unsized.rs:19:17 | LL | fn assert_sized() {} diff --git a/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr b/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr index a1b0264e04a78..2b57c439fe9a0 100644 --- a/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr +++ b/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr @@ -5,10 +5,10 @@ LL | type Assoc = OnlySized<::Item>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: required by a bound in `OnlySized` - --> $DIR/projection-bound-cycle-generic.rs:28:30 + --> $DIR/projection-bound-cycle-generic.rs:28:18 | LL | struct OnlySized where T: Sized { f: T } - | ^^^^^ required by this bound in `OnlySized` + | ^ required by this bound in `OnlySized` error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/projection-bound-cycle.stderr b/src/test/ui/generic-associated-types/projection-bound-cycle.stderr index 38b5164d79c9c..d9d0bf4274bd7 100644 --- a/src/test/ui/generic-associated-types/projection-bound-cycle.stderr +++ b/src/test/ui/generic-associated-types/projection-bound-cycle.stderr @@ -5,10 +5,10 @@ LL | type Assoc = OnlySized<::Item>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: required by a bound in `OnlySized` - --> $DIR/projection-bound-cycle.rs:30:30 + --> $DIR/projection-bound-cycle.rs:30:18 | LL | struct OnlySized where T: Sized { f: T } - | ^^^^^ required by this bound in `OnlySized` + | ^ required by this bound in `OnlySized` error: aborting due to previous error diff --git a/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr b/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr index 50f90618e4db7..2c397d80b013e 100644 --- a/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr +++ b/src/test/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr @@ -6,10 +6,10 @@ LL | impl Tsized for () {} | = help: the trait `Sized` is not implemented for `[()]` note: required by a bound in `Tsized` - --> $DIR/issue-61631-default-type-param-can-reference-self-in-trait.rs:17:17 + --> $DIR/issue-61631-default-type-param-can-reference-self-in-trait.rs:17:14 | LL | trait Tsized {} - | ^^^^^ required by this bound in `Tsized` + | ^ required by this bound in `Tsized` error: aborting due to previous error diff --git a/src/test/ui/higher-rank-trait-bounds/issue-60283.stderr b/src/test/ui/higher-rank-trait-bounds/issue-60283.stderr index 4b46f5d16a2d5..34893cd8f19d9 100644 --- a/src/test/ui/higher-rank-trait-bounds/issue-60283.stderr +++ b/src/test/ui/higher-rank-trait-bounds/issue-60283.stderr @@ -26,7 +26,7 @@ LL | foo((), drop) | required by a bound introduced by this call | = help: the trait `Sized` is not implemented for `<() as Trait<'_>>::Item` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `std::mem::drop` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub fn drop(_x: T) {} diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.stderr b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.stderr index ffb9a0dc2425a..01b14660b6531 100644 --- a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.stderr +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.stderr @@ -14,7 +14,7 @@ LL | | )); | |_____^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `impl Execute` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `task` --> $DIR/issue-62529-1.rs:69:9 | LL | fn task

(processor: P) -> Task diff --git a/src/test/ui/inference/cannot-infer-partial-try-return.stderr b/src/test/ui/inference/cannot-infer-partial-try-return.stderr index 70eac527fd89c..3542eb6848caf 100644 --- a/src/test/ui/inference/cannot-infer-partial-try-return.stderr +++ b/src/test/ui/inference/cannot-infer-partial-try-return.stderr @@ -1,8 +1,8 @@ error[E0282]: type annotations needed for the closure `fn() -> Result<(), QualifiedError<_>>` - --> $DIR/cannot-infer-partial-try-return.rs:18:19 + --> $DIR/cannot-infer-partial-try-return.rs:19:9 | -LL | let x = || -> Result<_, QualifiedError<_>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type +LL | infallible()?; + | ^^^^^^^^^^^^^ cannot infer type | help: give this closure an explicit return type without `_` placeholders | diff --git a/src/test/ui/issues/issue-17651.stderr b/src/test/ui/issues/issue-17651.stderr index a68a9c9c59bd7..efaaeeda2fab6 100644 --- a/src/test/ui/issues/issue-17651.stderr +++ b/src/test/ui/issues/issue-17651.stderr @@ -7,7 +7,7 @@ LL | (|| Box::new(*(&[0][..])))(); | required by a bound introduced by this call | = help: the trait `Sized` is not implemented for `[{integer}]` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Box::::new` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL | LL | impl Box { diff --git a/src/test/ui/issues/issue-20413.stderr b/src/test/ui/issues/issue-20413.stderr index 15666410098a0..2935214140419 100644 --- a/src/test/ui/issues/issue-20413.stderr +++ b/src/test/ui/issues/issue-20413.stderr @@ -37,104 +37,84 @@ LL | impl Foo for T where NoData: Foo { = note: 127 redundant requirements hidden = note: required because of the requirements on the impl of `Foo` for `NoData` -error[E0275]: overflow evaluating the requirement `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Sized` +error[E0275]: overflow evaluating the requirement `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Baz` --> $DIR/issue-20413.rs:28:42 | LL | impl Bar for T where EvenLessData: Baz { | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) -note: required because it appears within the type `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/issue-20413.rs:26:8 +note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:28:9 | -LL | struct EvenLessData(Option); - | ^^^^^^^^^^^^ +LL | impl Bar for T where EvenLessData: Baz { + | ^^^ ^ note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` --> $DIR/issue-20413.rs:36:9 | LL | impl Baz for T where AlmostNoData: Bar { | ^^^ ^ -note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/issue-20413.rs:28:9 - | -LL | impl Bar for T where EvenLessData: Baz { - | ^^^ ^ - = note: 125 redundant requirements hidden + = note: 126 redundant requirements hidden = note: required because of the requirements on the impl of `Baz` for `EvenLessData` -error[E0275]: overflow evaluating the requirement `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Sized` +error[E0275]: overflow evaluating the requirement `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Baz` --> $DIR/issue-20413.rs:28:42 | LL | impl Bar for T where EvenLessData: Baz { | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) -note: required because it appears within the type `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/issue-20413.rs:26:8 +note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:28:9 | -LL | struct EvenLessData(Option); - | ^^^^^^^^^^^^ +LL | impl Bar for T where EvenLessData: Baz { + | ^^^ ^ note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` --> $DIR/issue-20413.rs:36:9 | LL | impl Baz for T where AlmostNoData: Bar { | ^^^ ^ -note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/issue-20413.rs:28:9 - | -LL | impl Bar for T where EvenLessData: Baz { - | ^^^ ^ - = note: 125 redundant requirements hidden + = note: 126 redundant requirements hidden = note: required because of the requirements on the impl of `Baz` for `EvenLessData` -error[E0275]: overflow evaluating the requirement `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Sized` +error[E0275]: overflow evaluating the requirement `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Bar` --> $DIR/issue-20413.rs:36:42 | LL | impl Baz for T where AlmostNoData: Bar { | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) -note: required because it appears within the type `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/issue-20413.rs:24:8 +note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:36:9 | -LL | struct AlmostNoData(Option); - | ^^^^^^^^^^^^ +LL | impl Baz for T where AlmostNoData: Bar { + | ^^^ ^ note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` --> $DIR/issue-20413.rs:28:9 | LL | impl Bar for T where EvenLessData: Baz { | ^^^ ^ -note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/issue-20413.rs:36:9 - | -LL | impl Baz for T where AlmostNoData: Bar { - | ^^^ ^ - = note: 125 redundant requirements hidden + = note: 126 redundant requirements hidden = note: required because of the requirements on the impl of `Bar` for `AlmostNoData` -error[E0275]: overflow evaluating the requirement `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Sized` +error[E0275]: overflow evaluating the requirement `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Bar` --> $DIR/issue-20413.rs:36:42 | LL | impl Baz for T where AlmostNoData: Bar { | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) -note: required because it appears within the type `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/issue-20413.rs:24:8 +note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-20413.rs:36:9 | -LL | struct AlmostNoData(Option); - | ^^^^^^^^^^^^ +LL | impl Baz for T where AlmostNoData: Bar { + | ^^^ ^ note: required because of the requirements on the impl of `Bar` for `AlmostNoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` --> $DIR/issue-20413.rs:28:9 | LL | impl Bar for T where EvenLessData: Baz { | ^^^ ^ -note: required because of the requirements on the impl of `Baz` for `EvenLessData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/issue-20413.rs:36:9 - | -LL | impl Baz for T where AlmostNoData: Bar { - | ^^^ ^ - = note: 125 redundant requirements hidden + = note: 126 redundant requirements hidden = note: required because of the requirements on the impl of `Bar` for `AlmostNoData` error: aborting due to 7 previous errors diff --git a/src/test/ui/issues/issue-87199.stderr b/src/test/ui/issues/issue-87199.stderr index 2bca376e4e4b3..0ec5e73f39a85 100644 --- a/src/test/ui/issues/issue-87199.stderr +++ b/src/test/ui/issues/issue-87199.stderr @@ -25,7 +25,7 @@ LL | ref_arg::<[i32]>(&[5]); | required by a bound introduced by this call | = help: the trait `Sized` is not implemented for `[i32]` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `ref_arg` --> $DIR/issue-87199.rs:10:12 | LL | fn ref_arg(_: &T) {} diff --git a/src/test/ui/range/range-1.stderr b/src/test/ui/range/range-1.stderr index 1d82e3c3e177b..2ce4e1553d28e 100644 --- a/src/test/ui/range/range-1.stderr +++ b/src/test/ui/range/range-1.stderr @@ -20,24 +20,13 @@ LL | let range = *arr..; | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[{integer}]` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `RangeFrom` --> $SRC_DIR/core/src/ops/range.rs:LL:COL | LL | pub struct RangeFrom { | ^^^ required by this bound in `RangeFrom` -error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time - --> $DIR/range-1.rs:14:9 - | -LL | let range = *arr..; - | ^^^^^ doesn't have a size known at compile-time - | - = help: within `RangeFrom<[{integer}]>`, the trait `Sized` is not implemented for `[{integer}]` - = note: required because it appears within the type `RangeFrom<[{integer}]>` - = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature - -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/str/str-mut-idx.stderr b/src/test/ui/str/str-mut-idx.stderr index a87681ded1954..2559ee9eb49b2 100644 --- a/src/test/ui/str/str-mut-idx.stderr +++ b/src/test/ui/str/str-mut-idx.stderr @@ -5,7 +5,7 @@ LL | s[1..2] = bot(); | ^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `bot` --> $DIR/str-mut-idx.rs:1:8 | LL | fn bot() -> T { loop {} } diff --git a/src/test/ui/suggestions/bound-suggestions.stderr b/src/test/ui/suggestions/bound-suggestions.stderr index 11bc913fb91b8..04f233a1e87af 100644 --- a/src/test/ui/suggestions/bound-suggestions.stderr +++ b/src/test/ui/suggestions/bound-suggestions.stderr @@ -76,7 +76,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | const SIZE: usize = core::mem::size_of::(); | ^^^^ doesn't have a size known at compile-time | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `std::mem::size_of` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { @@ -92,7 +92,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | const SIZE: usize = core::mem::size_of::(); | ^^^^ doesn't have a size known at compile-time | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `std::mem::size_of` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { @@ -108,7 +108,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | const SIZE: usize = core::mem::size_of::(); | ^^^^ doesn't have a size known at compile-time | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `std::mem::size_of` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { @@ -124,7 +124,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | const SIZE: usize = core::mem::size_of::(); | ^^^^ doesn't have a size known at compile-time | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `std::mem::size_of` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { @@ -140,7 +140,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | const SIZE: usize = core::mem::size_of::(); | ^^^^ doesn't have a size known at compile-time | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `std::mem::size_of` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { diff --git a/src/test/ui/suggestions/issue-84973-blacklist.stderr b/src/test/ui/suggestions/issue-84973-blacklist.stderr index aca88293d2b63..ae55c96702ada 100644 --- a/src/test/ui/suggestions/issue-84973-blacklist.stderr +++ b/src/test/ui/suggestions/issue-84973-blacklist.stderr @@ -48,7 +48,7 @@ LL | f_sized(*ref_cl); | required by a bound introduced by this call | = help: the trait `Sized` is not implemented for `dyn Fn()` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `f_sized` --> $DIR/issue-84973-blacklist.rs:9:12 | LL | fn f_sized(t: T) {} diff --git a/src/test/ui/suggestions/issue-85945-check-where-clause-before-suggesting-unsized.stderr b/src/test/ui/suggestions/issue-85945-check-where-clause-before-suggesting-unsized.stderr index 981b210c13613..92be9f764cc4b 100644 --- a/src/test/ui/suggestions/issue-85945-check-where-clause-before-suggesting-unsized.stderr +++ b/src/test/ui/suggestions/issue-85945-check-where-clause-before-suggesting-unsized.stderr @@ -7,7 +7,7 @@ LL | fn bar() { foo(""); } | required by a bound introduced by this call | = help: the trait `Sized` is not implemented for `str` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `foo` --> $DIR/issue-85945-check-where-clause-before-suggesting-unsized.rs:3:8 | LL | fn foo(_: &T) where T: Sized {} diff --git a/src/test/ui/traits/bad-sized.stderr b/src/test/ui/traits/bad-sized.stderr index 27d568b7c0bea..6f9113fff5161 100644 --- a/src/test/ui/traits/bad-sized.stderr +++ b/src/test/ui/traits/bad-sized.stderr @@ -29,7 +29,7 @@ LL | let x: Vec = Vec::new(); | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `dyn Trait` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `Vec::::new` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | LL | impl Vec { diff --git a/src/test/ui/traits/mutual-recursion-issue-75860.stderr b/src/test/ui/traits/mutual-recursion-issue-75860.stderr index aa229cc4256ee..920f66121e098 100644 --- a/src/test/ui/traits/mutual-recursion-issue-75860.stderr +++ b/src/test/ui/traits/mutual-recursion-issue-75860.stderr @@ -5,7 +5,6 @@ LL | iso(left, right) | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`mutual_recursion_issue_75860`) - = note: required because it appears within the type `Option>` note: required by a bound in `Option` --> $SRC_DIR/core/src/option.rs:LL:COL | diff --git a/src/test/ui/traits/suggest-where-clause.stderr b/src/test/ui/traits/suggest-where-clause.stderr index 5f6bb89542231..e2cdd368888a8 100644 --- a/src/test/ui/traits/suggest-where-clause.stderr +++ b/src/test/ui/traits/suggest-where-clause.stderr @@ -7,7 +7,7 @@ LL | // suggest a where-clause, if needed LL | mem::size_of::(); | ^ doesn't have a size known at compile-time | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `std::mem::size_of` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { @@ -32,7 +32,7 @@ note: required because it appears within the type `Misc` | LL | struct Misc(T); | ^^^^ -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `std::mem::size_of` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { @@ -78,7 +78,7 @@ LL | mem::size_of::<[T]>(); | ^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[T]` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `std::mem::size_of` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { @@ -91,7 +91,7 @@ LL | mem::size_of::<[&U]>(); | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[&U]` -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `std::mem::size_of` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of() -> usize { diff --git a/src/test/ui/unsized/unsized-bare-typaram.stderr b/src/test/ui/unsized/unsized-bare-typaram.stderr index fe997ea4d8b1d..531e9b4c9c955 100644 --- a/src/test/ui/unsized/unsized-bare-typaram.stderr +++ b/src/test/ui/unsized/unsized-bare-typaram.stderr @@ -6,7 +6,7 @@ LL | fn foo() { bar::() } | | | this type parameter needs to be `std::marker::Sized` | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `bar` --> $DIR/unsized-bare-typaram.rs:1:8 | LL | fn bar() { } diff --git a/src/test/ui/unsized/unsized-struct.stderr b/src/test/ui/unsized/unsized-struct.stderr index daa3088fa8c8a..1c70a840c77dc 100644 --- a/src/test/ui/unsized/unsized-struct.stderr +++ b/src/test/ui/unsized/unsized-struct.stderr @@ -37,7 +37,7 @@ note: required because it appears within the type `Bar` | LL | struct Bar { data: T } | ^^^ -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `is_sized` --> $DIR/unsized-struct.rs:1:13 | LL | fn is_sized() { } diff --git a/src/test/ui/unsized/unsized3.stderr b/src/test/ui/unsized/unsized3.stderr index 42636a7765686..ae89f2f997728 100644 --- a/src/test/ui/unsized/unsized3.stderr +++ b/src/test/ui/unsized/unsized3.stderr @@ -8,7 +8,7 @@ LL | f2::(x); | | | required by a bound introduced by this call | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `f2` --> $DIR/unsized3.rs:10:7 | LL | fn f2(x: &X) { @@ -33,7 +33,7 @@ LL | f4::(x); | | | required by a bound introduced by this call | -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `f4` --> $DIR/unsized3.rs:21:7 | LL | fn f4(x: &X) { @@ -63,7 +63,7 @@ note: required because it appears within the type `S` | LL | struct S { | ^ -note: type parameters have an implicit `Sized` obligation +note: required by a bound in `f5` --> $DIR/unsized3.rs:24:7 | LL | fn f5(x: &Y) {}