diff --git a/compiler/rustc_borrowck/src/type_check/canonical.rs b/compiler/rustc_borrowck/src/type_check/canonical.rs index 0fa72ed8241bc..18a6605aa35a4 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..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,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..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,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..96bb590e3a203 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..9763991d99a1a 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..6604a4af63a7b 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..52f3f54ca4523 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..0c237347d9e24 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..1ca1c32f816a1 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..03a81397fb2f3 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..6cce57786402c 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..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,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..90b032df392d7 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..a634d17346fa3 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..df3001ab7d7d7 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..bfd956e644d71 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..0e26f31025696 100644 --- a/compiler/rustc_typeck/src/check/compare_method.rs +++ b/compiler/rustc_typeck/src/check/compare_method.rs @@ -1378,13 +1378,20 @@ 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 = |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) + ObligationCause::new( + impl_ty_span, + impl_ty_hir_id, + match () { + _ 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 +1402,12 @@ 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), + mk_cause(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..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,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/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/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/recursion/issue-26548-recursion-via-normalize.rs b/src/test/ui/recursion/issue-26548-recursion-via-normalize.rs index 4fd5622b0626c..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,18 +1,13 @@ -//~ 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 { +trait Mirror { //~ NOTE required by a bound in this type It: ?Sized; } 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 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 6042379a91887..a583e0fceb0dc 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: required by a bound in `Option` + --> $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/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 }