diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index c97f80cf09b..4676ad5c31f 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -432,17 +432,25 @@ impl<'hir> LoweringContext<'_, 'hir> { self.with_catch_scope(body.id, |this| { let mut block = this.lower_block_noalloc(body, true); - let try_span = this.mark_span_with_reason( - DesugaringKind::TryBlock, - body.span, - this.allow_try_trait.clone(), - ); - // Final expression of the block (if present) or `()` with span at the end of block - let tail_expr = block - .expr - .take() - .unwrap_or_else(|| this.expr_unit(this.sess.source_map().end_point(try_span))); + let (try_span, tail_expr) = if let Some(expr) = block.expr.take() { + ( + this.mark_span_with_reason( + DesugaringKind::TryBlock, + expr.span, + this.allow_try_trait.clone(), + ), + expr, + ) + } else { + let try_span = this.mark_span_with_reason( + DesugaringKind::TryBlock, + this.sess.source_map().end_point(body.span), + this.allow_try_trait.clone(), + ); + + (try_span, this.expr_unit(try_span)) + }; let ok_wrapped_span = this.mark_span_with_reason(DesugaringKind::TryBlock, tail_expr.span, None); @@ -1553,7 +1561,7 @@ impl<'hir> LoweringContext<'_, 'hir> { hir::LangItem::TryFromError, unstable_span, from_expr, - try_span, + unstable_span, ); let thin_attrs = ThinVec::from(attrs); let catch_scope = self.catch_scopes.last().copied(); diff --git a/compiler/rustc_infer/src/traits/util.rs b/compiler/rustc_infer/src/traits/util.rs index 9c0d934a035..1b7269706a7 100644 --- a/compiler/rustc_infer/src/traits/util.rs +++ b/compiler/rustc_infer/src/traits/util.rs @@ -4,7 +4,6 @@ use crate::traits::{Obligation, ObligationCause, PredicateObligation}; use rustc_data_structures::fx::FxHashSet; use rustc_middle::ty::outlives::Component; use rustc_middle::ty::{self, ToPredicate, TyCtxt, WithConstness}; -use rustc_span::Span; pub fn anonymize_predicate<'tcx>( tcx: TyCtxt<'tcx>, @@ -94,7 +93,11 @@ pub fn elaborate_predicates<'tcx>( tcx: TyCtxt<'tcx>, predicates: impl Iterator>, ) -> Elaborator<'tcx> { - let obligations = predicates.map(|predicate| predicate_obligation(predicate, None)).collect(); + let obligations = predicates + .map(|predicate| { + predicate_obligation(predicate, ty::ParamEnv::empty(), ObligationCause::dummy()) + }) + .collect(); elaborate_obligations(tcx, obligations) } @@ -109,15 +112,10 @@ pub fn elaborate_obligations<'tcx>( fn predicate_obligation<'tcx>( predicate: ty::Predicate<'tcx>, - span: Option, + param_env: ty::ParamEnv<'tcx>, + cause: ObligationCause<'tcx>, ) -> PredicateObligation<'tcx> { - let cause = if let Some(span) = span { - ObligationCause::dummy_with_span(span) - } else { - ObligationCause::dummy() - }; - - Obligation { cause, param_env: ty::ParamEnv::empty(), recursion_depth: 0, predicate } + Obligation { cause, param_env, recursion_depth: 0, predicate } } impl Elaborator<'tcx> { @@ -133,10 +131,11 @@ impl Elaborator<'tcx> { // Get predicates declared on the trait. let predicates = tcx.super_predicates_of(data.def_id()); - let obligations = predicates.predicates.iter().map(|&(pred, span)| { + let obligations = predicates.predicates.iter().map(|&(pred, _)| { predicate_obligation( pred.subst_supertrait(tcx, &ty::Binder::bind(data.trait_ref)), - Some(span), + obligation.param_env, + obligation.cause.clone(), ) }); debug!("super_predicates: data={:?}", data); @@ -233,7 +232,13 @@ impl Elaborator<'tcx> { }) .map(|predicate_kind| predicate_kind.to_predicate(tcx)) .filter(|&predicate| visited.insert(predicate)) - .map(|predicate| predicate_obligation(predicate, None)), + .map(|predicate| { + predicate_obligation( + predicate, + obligation.param_env, + obligation.cause.clone(), + ) + }), ); } ty::PredicateAtom::TypeWellFormedFromEnv(..) => { diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 1e8c30071e7..3abd9a6325d 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -200,7 +200,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { ty::Adt(def, _) => check_must_use_def(cx, def.did, span, descr_pre, descr_post), ty::Opaque(def, _) => { let mut has_emitted = false; - for (predicate, _) in cx.tcx.predicates_of(def).predicates { + for &(predicate, _) in cx.tcx.explicit_item_bounds(def) { // We only look at the `DefId`, so it is safe to skip the binder here. if let ty::PredicateAtom::Trait(ref poly_trait_predicate, _) = predicate.skip_binders() diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 9f12edf9cb2..f0911928e81 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1266,7 +1266,10 @@ impl EncodeContext<'a, 'tcx> { hir::ItemKind::ForeignMod(_) => EntryKind::ForeignMod, hir::ItemKind::GlobalAsm(..) => EntryKind::GlobalAsm, hir::ItemKind::TyAlias(..) => EntryKind::Type, - hir::ItemKind::OpaqueTy(..) => EntryKind::OpaqueTy, + hir::ItemKind::OpaqueTy(..) => { + self.encode_explicit_item_bounds(def_id); + EntryKind::OpaqueTy + } hir::ItemKind::Enum(..) => EntryKind::Enum(self.tcx.adt_def(def_id).repr), hir::ItemKind::Struct(ref struct_def, _) => { let adt_def = self.tcx.adt_def(def_id); diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 5cd8f3e7877..e1f02d0f704 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -607,12 +607,13 @@ pub trait PrettyPrinter<'tcx>: } // Grab the "TraitA + TraitB" from `impl TraitA + TraitB`, // by looking up the projections associated with the def_id. - let bounds = self.tcx().item_bounds(def_id).subst(self.tcx(), substs); + let bounds = self.tcx().explicit_item_bounds(def_id); let mut first = true; let mut is_sized = false; p!("impl"); - for predicate in bounds { + for (predicate, _) in bounds { + let predicate = predicate.subst(self.tcx(), substs); // Note: We can't use `to_opt_poly_trait_ref` here as `predicate` // may contain unbound variables. We therefore do this manually. // diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 8d1b826ea35..8f93bce6e99 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -194,11 +194,14 @@ where // The intent is to treat `impl Trait1 + Trait2` identically to // `dyn Trait1 + Trait2`. Therefore we ignore def-id of the opaque type itself // (it either has no visibility, or its visibility is insignificant, like - // visibilities of type aliases) and recurse into predicates instead to go + // visibilities of type aliases) and recurse into bounds instead to go // through the trait list (default type visitor doesn't visit those traits). // All traits in the list are considered the "primary" part of the type // and are visited by shallow visitors. - if self.visit_predicates(tcx.predicates_of(def_id)) { + if self.visit_predicates(ty::GenericPredicates { + parent: None, + predicates: tcx.explicit_item_bounds(def_id), + }) { return true; } } @@ -1800,6 +1803,14 @@ impl SearchInterfaceForPrivateItemsVisitor<'tcx> { self } + fn bounds(&mut self) -> &mut Self { + self.visit_predicates(ty::GenericPredicates { + parent: None, + predicates: self.tcx.explicit_item_bounds(self.item_def_id), + }); + self + } + fn ty(&mut self) -> &mut Self { self.visit(self.tcx.type_of(self.item_def_id)); self @@ -1975,7 +1986,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> hir::ItemKind::OpaqueTy(..) => { // `ty()` for opaque types is the underlying type, // it's not a part of interface, so we skip it. - self.check(item.hir_id, item_visibility).generics().predicates(); + self.check(item.hir_id, item_visibility).generics().bounds(); } hir::ItemKind::Trait(.., trait_item_refs) => { self.check(item.hir_id, item_visibility).generics().predicates(); @@ -1987,6 +1998,10 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> trait_item_ref.defaultness, item_visibility, ); + + if let AssocItemKind::Type = trait_item_ref.kind { + self.check(trait_item_ref.id.hir_id, item_visibility).bounds(); + } } } hir::ItemKind::TraitAlias(..) => { diff --git a/compiler/rustc_traits/src/chalk/db.rs b/compiler/rustc_traits/src/chalk/db.rs index 828ee6dea62..35b1064d2e4 100644 --- a/compiler/rustc_traits/src/chalk/db.rs +++ b/compiler/rustc_traits/src/chalk/db.rs @@ -73,18 +73,28 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t } let bound_vars = bound_vars_for_item(self.interner.tcx, def_id); let binders = binders_for(&self.interner, bound_vars); - // FIXME(chalk): this really isn't right I don't think. The functions - // for GATs are a bit hard to figure out. Are these supposed to be where - // clauses or bounds? + let where_clauses = self.where_clauses_for(def_id, bound_vars); + let bounds = self + .tcx + .explicit_item_bounds(def_id) + .iter() + .map(|(bound, _)| bound.subst(self.tcx, &bound_vars)) + .filter_map(|bound| { + LowerInto::< + Option>>, + >::lower_into(bound, &self.interner) + }) + .collect(); + Arc::new(chalk_solve::rust_ir::AssociatedTyDatum { trait_id: chalk_ir::TraitId(trait_def_id), id: assoc_type_id, name: (), binders: chalk_ir::Binders::new( binders, - chalk_solve::rust_ir::AssociatedTyDatumBound { bounds: vec![], where_clauses }, + chalk_solve::rust_ir::AssociatedTyDatumBound { bounds, where_clauses }, ), }) } @@ -443,10 +453,17 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t let binders = binders_for(&self.interner, bound_vars); let where_clauses = self.where_clauses_for(opaque_ty_id.0, bound_vars); + let bounds: Vec<_> = predicates + .iter() + .map(|(bound, _)| bound.subst(self.tcx, &bound_vars)) + .filter_map(|bound| LowerInto::>>>::lower_into(bound, &self.interner)) + .collect(); + let value = chalk_solve::rust_ir::OpaqueTyDatumBound { - bounds: chalk_ir::Binders::new(binders.clone(), vec![]), + bounds: chalk_ir::Binders::new(binders, bounds), where_clauses: chalk_ir::Binders::new(binders, where_clauses), }; + Arc::new(chalk_solve::rust_ir::OpaqueTyDatum { opaque_ty_id, bound: chalk_ir::Binders::empty(&self.interner, value), diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index 1e1841a57f8..0602f5ea4dc 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -728,6 +728,84 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::FnSig>> for ty::Binder LowerInto<'tcx, Option>>> + for ty::Predicate<'tcx> +{ + fn lower_into( + self, + interner: &RustInterner<'tcx>, + ) -> Option>> { + match &self.kind() { + ty::PredicateKind::Trait(predicate, _) => { + let (predicate, binders, _named_regions) = + collect_bound_vars(interner, interner.tcx, predicate); + + Some(chalk_ir::Binders::new( + binders, + chalk_solve::rust_ir::InlineBound::TraitBound( + predicate.trait_ref.lower_into(interner), + ), + )) + } + ty::PredicateKind::Projection(predicate) => { + let (predicate, binders, _named_regions) = + collect_bound_vars(interner, interner.tcx, predicate); + + Some(chalk_ir::Binders::new( + binders, + chalk_solve::rust_ir::InlineBound::AliasEqBound(predicate.lower_into(interner)), + )) + } + ty::PredicateKind::TypeOutlives(_predicate) => None, + ty::PredicateKind::WellFormed(_ty) => None, + + ty::PredicateKind::RegionOutlives(..) + | ty::PredicateKind::ObjectSafe(..) + | ty::PredicateKind::ClosureKind(..) + | ty::PredicateKind::Subtype(..) + | ty::PredicateKind::ConstEvaluatable(..) + | ty::PredicateKind::ConstEquate(..) => bug!("unexpected predicate {}", &self), + } + } +} + +impl<'tcx> LowerInto<'tcx, chalk_solve::rust_ir::TraitBound>> + for ty::TraitRef<'tcx> +{ + fn lower_into( + self, + interner: &RustInterner<'tcx>, + ) -> chalk_solve::rust_ir::TraitBound> { + chalk_solve::rust_ir::TraitBound { + trait_id: chalk_ir::TraitId(self.def_id), + args_no_self: self.substs[1..].iter().map(|arg| arg.lower_into(interner)).collect(), + } + } +} + +impl<'tcx> LowerInto<'tcx, chalk_solve::rust_ir::AliasEqBound>> + for ty::ProjectionPredicate<'tcx> +{ + fn lower_into( + self, + interner: &RustInterner<'tcx>, + ) -> chalk_solve::rust_ir::AliasEqBound> { + let trait_ref = self.projection_ty.trait_ref(interner.tcx); + chalk_solve::rust_ir::AliasEqBound { + trait_bound: trait_ref.lower_into(interner), + associated_ty_id: chalk_ir::AssocTypeId(self.projection_ty.item_def_id), + parameters: self.projection_ty.substs[trait_ref.substs.len()..] + .iter() + .map(|arg| arg.lower_into(interner)) + .collect(), + value: self.ty.lower_into(interner), + } + } +} + /// To collect bound vars, we have to do two passes. In the first pass, we /// collect all `BoundRegion`s and `ty::Bound`s. In the second pass, we then /// replace `BrNamed` into `BrAnon`. The two separate passes are important, diff --git a/compiler/rustc_typeck/src/check/check.rs b/compiler/rustc_typeck/src/check/check.rs index 0647be2dfde..2df9007195f 100644 --- a/compiler/rustc_typeck/src/check/check.rs +++ b/compiler/rustc_typeck/src/check/check.rs @@ -1,4 +1,5 @@ use super::coercion::CoerceMany; +use super::compare_method::check_type_bounds; use super::compare_method::{compare_const_impl, compare_impl_method, compare_ty_impl}; use super::*; @@ -453,8 +454,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes( ty: None, }; let prohibit_opaque = tcx - .predicates_of(def_id) - .predicates + .explicit_item_bounds(def_id) .iter() .any(|(predicate, _)| predicate.visit_with(&mut visitor)); debug!( @@ -476,7 +476,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes( span, E0760, "`{}` return type cannot contain a projection or `Self` that references lifetimes from \ - a parent scope", + a parent scope", if is_async { "async fn" } else { "impl Trait" }, ); @@ -553,9 +553,25 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) { for item in items.iter() { let item = tcx.hir().trait_item(item.id); - if let hir::TraitItemKind::Fn(sig, _) = &item.kind { - let abi = sig.header.abi; - fn_maybe_err(tcx, item.ident.span, abi); + match item.kind { + hir::TraitItemKind::Fn(ref sig, _) => { + let abi = sig.header.abi; + fn_maybe_err(tcx, item.ident.span, abi); + } + hir::TraitItemKind::Type(.., Some(_default)) => { + let item_def_id = tcx.hir().local_def_id(item.hir_id).to_def_id(); + let assoc_item = tcx.associated_item(item_def_id); + let trait_substs = + InternalSubsts::identity_for_item(tcx, def_id.to_def_id()); + let _: Result<_, rustc_errors::ErrorReported> = check_type_bounds( + tcx, + assoc_item, + assoc_item, + item.span, + ty::TraitRef { def_id: def_id.to_def_id(), substs: trait_substs }, + ); + } + _ => {} } } } diff --git a/compiler/rustc_typeck/src/check/compare_method.rs b/compiler/rustc_typeck/src/check/compare_method.rs index 8111a0bad9f..3515fb12e4c 100644 --- a/compiler/rustc_typeck/src/check/compare_method.rs +++ b/compiler/rustc_typeck/src/check/compare_method.rs @@ -5,6 +5,7 @@ use rustc_hir::def::{DefKind, Res}; use rustc_hir::intravisit; use rustc_hir::{GenericParamKind, ImplItemKind, TraitItemKind}; use rustc_infer::infer::{self, InferOk, TyCtxtInferExt}; +use rustc_infer::traits::util; use rustc_middle::ty; use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::subst::{InternalSubsts, Subst}; @@ -1170,20 +1171,13 @@ fn compare_type_predicate_entailment<'tcx>( /// For default associated types the normalization is not possible (the value /// from the impl could be overridden). We also can't normalize generic /// associated types (yet) because they contain bound parameters. -fn check_type_bounds<'tcx>( +pub fn check_type_bounds<'tcx>( tcx: TyCtxt<'tcx>, trait_ty: &ty::AssocItem, impl_ty: &ty::AssocItem, impl_ty_span: Span, impl_trait_ref: ty::TraitRef<'tcx>, ) -> Result<(), ErrorReported> { - let have_gats = tcx.features().generic_associated_types; - if impl_ty.defaultness.is_final() && !have_gats { - // For "final", non-generic associate type implementations, we - // don't need this as described above. - return Ok(()); - } - // Given // // impl Foo for (A, B) { @@ -1237,10 +1231,20 @@ fn check_type_bounds<'tcx>( ObligationCauseCode::ItemObligation(trait_ty.def_id), ); - let predicates = tcx.item_bounds(trait_ty.def_id); - debug!("check_type_bounds: item_bounds={:?}", predicates); + let obligations = tcx + .explicit_item_bounds(trait_ty.def_id) + .iter() + .map(|&(bound, span)| { + let concrete_ty_bound = + traits::subst_assoc_item_bound(tcx, bound, impl_ty_value, rebased_substs); + debug!("check_type_bounds: concrete_ty_bound = {:?}", concrete_ty_bound); - for predicate in predicates { + traits::Obligation::new(mk_cause(span), param_env, concrete_ty_bound) + }) + .collect(); + debug!("check_type_bounds: item_bounds={:?}", obligations); + + for obligation in util::elaborate_obligations(tcx, obligations) { let concrete_ty_predicate = predicate.subst(tcx, rebased_substs); debug!("compare_projection_bounds: concrete predicate = {:?}", concrete_ty_predicate); @@ -1252,12 +1256,7 @@ fn check_type_bounds<'tcx>( ); debug!("compare_projection_bounds: normalized predicate = {:?}", normalized_predicate); - inh.register_predicates(obligations); - inh.register_predicate(traits::Obligation::new( - cause.clone(), - param_env, - normalized_predicate, - )); + inh.register_predicate(obligation); } // Check that all obligations are satisfied by the implementation's diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index 5203f3fa8f1..f31ba886d52 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -420,6 +420,9 @@ fn check_associated_item( check_method_receiver(fcx, hir_sig, &item, self_ty); } ty::AssocKind::Type => { + if let ty::AssocItemContainer::TraitContainer(_) = item.container { + check_associated_type_bounds(fcx, item, span) + } if item.defaultness.has_value() { let ty = fcx.tcx.type_of(item.def_id); let ty = fcx.normalize_associated_types_in(span, &ty); @@ -571,7 +574,6 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) { for_item(tcx, item).with_fcx(|fcx, _| { check_where_clauses(tcx, fcx, item.span, trait_def_id.to_def_id(), None); - check_associated_type_defaults(fcx, trait_def_id.to_def_id()); vec![] }); @@ -581,96 +583,26 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) { /// /// Assuming the defaults are used, check that all predicates (bounds on the /// assoc type and where clauses on the trait) hold. -fn check_associated_type_defaults(fcx: &FnCtxt<'_, '_>, trait_def_id: DefId) { +fn check_associated_type_bounds(fcx: &FnCtxt<'_, '_>, item: &ty::AssocItem, span: Span) { let tcx = fcx.tcx; - let substs = InternalSubsts::identity_for_item(tcx, trait_def_id); - // For all assoc. types with defaults, build a map from - // `>::Assoc` to the default type. - let map = tcx - .associated_items(trait_def_id) - .in_definition_order() - .filter_map(|item| { - if item.kind == ty::AssocKind::Type && item.defaultness.has_value() { - // `>::Assoc` - let proj = ty::ProjectionTy { substs, item_def_id: item.def_id }; - let default_ty = tcx.type_of(item.def_id); - debug!("assoc. type default mapping: {} -> {}", proj, default_ty); - Some((proj, default_ty)) - } else { - None - } - }) - .collect::>(); + let bounds = tcx.explicit_item_bounds(item.def_id); - /// Replaces projections of associated types with their default types. - /// - /// This does a "shallow substitution", meaning that defaults that refer to - /// other defaulted assoc. types will still refer to the projection - /// afterwards, not to the other default. For example: - /// - /// ```compile_fail - /// trait Tr { - /// type A: Clone = Vec; - /// type B = u8; - /// } - /// ``` - /// - /// This will end up replacing the bound `Self::A: Clone` with - /// `Vec: Clone`, not with `Vec: Clone`. If we did a deep - /// substitution and ended up with the latter, the trait would be accepted. - /// If an `impl` then replaced `B` with something that isn't `Clone`, - /// suddenly the default for `A` is no longer valid. The shallow - /// substitution forces the trait to add a `B: Clone` bound to be accepted, - /// which means that an `impl` can replace any default without breaking - /// others. - /// - /// Note that this isn't needed for soundness: The defaults would still be - /// checked in any impl that doesn't override them. - struct DefaultNormalizer<'tcx> { - tcx: TyCtxt<'tcx>, - map: FxHashMap, Ty<'tcx>>, - } + debug!("check_associated_type_bounds: bounds={:?}", bounds); + let wf_obligations = bounds.iter().flat_map(|&(bound, bound_span)| { + let normalized_bound = fcx.normalize_associated_types_in(span, &bound); + traits::wf::predicate_obligations( + fcx, + fcx.param_env, + fcx.body_id, + normalized_bound, + bound_span, + ) + }); - impl<'tcx> ty::fold::TypeFolder<'tcx> for DefaultNormalizer<'tcx> { - fn tcx<'a>(&'a self) -> TyCtxt<'tcx> { - self.tcx - } - - fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { - match t.kind() { - ty::Projection(proj_ty) => { - if let Some(default) = self.map.get(&proj_ty) { - default - } else { - t.super_fold_with(self) - } - } - _ => t.super_fold_with(self), - } - } - } - - // Now take all predicates defined on the trait, replace any mention of - // the assoc. types with their default, and prove them. - // We only consider predicates that directly mention the assoc. type. - let mut norm = DefaultNormalizer { tcx, map }; - let predicates = fcx.tcx.predicates_of(trait_def_id); - for &(orig_pred, span) in predicates.predicates.iter() { - let pred = orig_pred.fold_with(&mut norm); - if pred != orig_pred { - // Mentions one of the defaulted assoc. types - debug!("default suitability check: proving predicate: {} -> {}", orig_pred, pred); - let pred = fcx.normalize_associated_types_in(span, &pred); - let cause = traits::ObligationCause::new( - span, - fcx.body_id, - traits::ItemObligation(trait_def_id), - ); - let obligation = traits::Obligation::new(cause, fcx.param_env, pred); - - fcx.register_predicate(obligation); - } + for obligation in wf_obligations { + debug!("next obligation cause: {:?}", obligation.cause); + fcx.register_predicate(obligation); } } diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index 4df5135cca5..737bc3a753d 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -711,8 +711,10 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::HirId) { tcx.ensure().generics_of(def_id); tcx.ensure().type_of(def_id); tcx.ensure().predicates_of(def_id); - if let hir::ItemKind::Fn(..) = it.kind { - tcx.ensure().fn_sig(def_id); + match it.kind { + hir::ItemKind::Fn(..) => tcx.ensure().fn_sig(def_id), + hir::ItemKind::OpaqueTy(..) => tcx.ensure().item_bounds(def_id), + _ => (), } } } @@ -733,15 +735,25 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) { tcx.ensure().type_of(def_id); } - hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(_, Some(_)) => { + hir::TraitItemKind::Const(..) => { tcx.ensure().type_of(def_id); - // Account for `const C: _;` and `type T = _;`. + // Account for `const C: _;`. + let mut visitor = PlaceholderHirTyCollector::default(); + visitor.visit_trait_item(trait_item); + placeholder_type_error(tcx, None, &[], visitor.0, false); + } + + hir::TraitItemKind::Type(_, Some(_)) => { + tcx.ensure().item_bounds(def_id); + tcx.ensure().type_of(def_id); + // Account for `type T = _;`. let mut visitor = PlaceholderHirTyCollector::default(); visitor.visit_trait_item(trait_item); placeholder_type_error(tcx, None, &[], visitor.0, false); } hir::TraitItemKind::Type(_, None) => { + tcx.ensure().item_bounds(def_id); // #74612: Visit and try to find bad placeholders // even if there is no concrete type. let mut visitor = PlaceholderHirTyCollector::default(); diff --git a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.rs b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.rs index 556d8900d1a..4c78f17a6a3 100644 --- a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.rs +++ b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.rs @@ -23,19 +23,17 @@ trait Case1 { Debug > > + Sync>; + //~^^^^^^ ERROR `<::C as std::iter::Iterator>::Item` is not an iterator + //~^^^^^^ ERROR `<::C as std::iter::Iterator>::Item` cannot be sent between threads safely + //~^^^ ERROR `<::C as std::iter::Iterator>::Item` cannot be shared between threads safely } pub struct S1; impl Case1 for S1 { -//~^ ERROR `>::App` doesn't implement `Debug` [E0277] type C = Once>; } fn assume_case1() { -//~^ ERROR `<_ as Lam<&'a u8>>::App` doesn't implement `Debug` [E0277] -//~| ERROR `<::C as Iterator>::Item` is not an iterator [E0277] -//~| ERROR `<::C as Iterator>::Item` cannot be sent between threads safely [E0277] -//~| ERROR `<::C as Iterator>::Item` cannot be shared between threads safely [E0277] fn assert_a<_0, A>() where A: Iterator, _0: Debug {} assert_a::<_, T::A>(); diff --git a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr index 49b5e7fbb89..20a087a85a6 100644 --- a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr +++ b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr @@ -1,79 +1,54 @@ -error[E0277]: `>::App` doesn't implement `Debug` - --> $DIR/bad-bounds-on-assoc-in-trait.rs:29:6 +error[E0277]: `<::C as std::iter::Iterator>::Item` is not an iterator + --> $DIR/bad-bounds-on-assoc-in-trait.rs:22:5 | -LL | trait Case1 { - | ----- required by a bound in this -... -LL | Debug - | ----- required by this bound in `Case1` -... -LL | impl Case1 for S1 { - | ^^^^^ `>::App` cannot be formatted using `{:?}` because it doesn't implement `Debug` +LL | / type C: Clone + Iterator Lam<&'a u8, App: +LL | | Debug +LL | | > +LL | | > + Sync>; + | |__________________^ `<::C as std::iter::Iterator>::Item` is not an iterator | - = help: the trait `for<'a> Debug` is not implemented for `>::App` - -error[E0277]: `<::C as Iterator>::Item` is not an iterator - --> $DIR/bad-bounds-on-assoc-in-trait.rs:34:20 - | -LL | fn assume_case1() { - | ^^^^^ `<::C as Iterator>::Item` is not an iterator - | - = help: the trait `Iterator` is not implemented for `<::C as Iterator>::Item` + = help: the trait `std::iter::Iterator` is not implemented for `<::C as std::iter::Iterator>::Item` help: consider further restricting the associated type | -LL | fn assume_case1() where <::C as Iterator>::Item: Iterator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Case1 where <::C as std::iter::Iterator>::Item: std::iter::Iterator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: `<::C as Iterator>::Item` cannot be sent between threads safely - --> $DIR/bad-bounds-on-assoc-in-trait.rs:34:20 +error[E0277]: `<::C as std::iter::Iterator>::Item` cannot be sent between threads safely + --> $DIR/bad-bounds-on-assoc-in-trait.rs:23:9 | -LL | trait Case1 { - | ----- required by a bound in this -LL | type C: Clone + Iterator() { - | ^^^^^ `<::C as Iterator>::Item` cannot be sent between threads safely + | ^^^^ `<::C as std::iter::Iterator>::Item` cannot be sent between threads safely | - = help: the trait `Send` is not implemented for `<::C as Iterator>::Item` + ::: $SRC_DIR/libcore/marker.rs:LL:COL + | +LL | pub unsafe auto trait Send { + | -------------------------- required by this bound in `std::marker::Send` + | + = help: the trait `std::marker::Send` is not implemented for `<::C as std::iter::Iterator>::Item` help: consider further restricting the associated type | -LL | fn assume_case1() where <::C as Iterator>::Item: Send { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Case1 where <::C as std::iter::Iterator>::Item: std::marker::Send { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: `<::C as Iterator>::Item` cannot be shared between threads safely - --> $DIR/bad-bounds-on-assoc-in-trait.rs:34:20 +error[E0277]: `<::C as std::iter::Iterator>::Item` cannot be shared between threads safely + --> $DIR/bad-bounds-on-assoc-in-trait.rs:27:13 | -LL | trait Case1 { - | ----- required by a bound in this -... LL | > + Sync>; - | ---- required by this bound in `Case1` -... -LL | fn assume_case1() { - | ^^^^^ `<::C as Iterator>::Item` cannot be shared between threads safely + | ^^^^ `<::C as std::iter::Iterator>::Item` cannot be shared between threads safely | - = help: the trait `Sync` is not implemented for `<::C as Iterator>::Item` + ::: $SRC_DIR/libcore/marker.rs:LL:COL + | +LL | pub unsafe auto trait Sync { + | -------------------------- required by this bound in `std::marker::Sync` + | + = help: the trait `std::marker::Sync` is not implemented for `<::C as std::iter::Iterator>::Item` help: consider further restricting the associated type | -LL | fn assume_case1() where <::C as Iterator>::Item: Sync { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Case1 where <::C as std::iter::Iterator>::Item: std::marker::Sync { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: `<_ as Lam<&'a u8>>::App` doesn't implement `Debug` - --> $DIR/bad-bounds-on-assoc-in-trait.rs:34:20 - | -LL | trait Case1 { - | ----- required by a bound in this -... -LL | Debug - | ----- required by this bound in `Case1` -... -LL | fn assume_case1() { - | ^^^^^ `<_ as Lam<&'a u8>>::App` cannot be formatted using `{:?}` because it doesn't implement `Debug` - | - = help: the trait `for<'a> Debug` is not implemented for `<_ as Lam<&'a u8>>::App` - -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs b/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs index ceca54b7cd7..4025e0fc5e1 100644 --- a/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs +++ b/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs @@ -1,4 +1,4 @@ -// check-pass +// ignore-tidy-linelength #![feature(associated_type_bounds)] @@ -18,6 +18,7 @@ impl<'a, 'b> Lam<&'a &'b u8> for L2 { type App = u8; } trait Case1 { type A: Iterator; + //~^ ERROR `<::A as std::iter::Iterator>::Item` doesn't implement `std::fmt::Debug` type B: Iterator; } @@ -30,7 +31,11 @@ impl Case1 for S1 { // Ensure we don't have opaque `impl Trait` desugaring: +// What is this supposed to mean? Rustc currently lowers `: Default` in the +// bounds of `Out`, but trait selection can't find the bound since it applies +// to a type other than `Self::Out`. pub trait Foo { type Out: Baz; } +//~^ ERROR trait bound `<::Out as Baz>::Assoc: std::default::Default` is not satisfied pub trait Baz { type Assoc; } #[derive(Default)] diff --git a/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.stderr b/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.stderr new file mode 100644 index 00000000000..2be37285e29 --- /dev/null +++ b/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.stderr @@ -0,0 +1,36 @@ +error[E0277]: `<::A as std::iter::Iterator>::Item` doesn't implement `std::fmt::Debug` + --> $DIR/bounds-on-assoc-in-trait.rs:20:28 + | +LL | type A: Iterator; + | ^^^^^ `<::A as std::iter::Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` + | + ::: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + | +LL | pub trait Debug { + | --------------- required by this bound in `std::fmt::Debug` + | + = help: the trait `std::fmt::Debug` is not implemented for `<::A as std::iter::Iterator>::Item` +help: consider further restricting the associated type + | +LL | trait Case1 where <::A as std::iter::Iterator>::Item: std::fmt::Debug { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `<::Out as Baz>::Assoc: std::default::Default` is not satisfied + --> $DIR/bounds-on-assoc-in-trait.rs:37:38 + | +LL | pub trait Foo { type Out: Baz; } + | ^^^^^^^ the trait `std::default::Default` is not implemented for `<::Out as Baz>::Assoc` + | + ::: $SRC_DIR/libcore/default.rs:LL:COL + | +LL | pub trait Default: Sized { + | ------------------------ required by this bound in `std::default::Default` + | +help: consider further restricting the associated type + | +LL | pub trait Foo where <::Out as Baz>::Assoc: std::default::Default { type Out: Baz; } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-type-bounds/duplicate.stderr b/src/test/ui/associated-type-bounds/duplicate.stderr index 77cd88e524f..b5941fb80c7 100644 --- a/src/test/ui/associated-type-bounds/duplicate.stderr +++ b/src/test/ui/associated-type-bounds/duplicate.stderr @@ -512,31 +512,7 @@ LL | trait TRSW3 where Self: Iterator {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:145:43 - | -LL | trait TRA1 { type A: Iterator; } - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:147:43 - | -LL | trait TRA2 { type A: Iterator; } - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:149:46 - | -LL | trait TRA3 { type A: Iterator; } - | ------------- ^^^^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:152:40 + --> $DIR/duplicate.rs:167:40 | LL | type TADyn1 = dyn Iterator; | ---------- ^^^^^^^^^^ re-bound here diff --git a/src/test/ui/associated-types/associated-types-unconstrained.stderr b/src/test/ui/associated-types/associated-types-unconstrained.stderr index 2914a7f868b..9d084203e3a 100644 --- a/src/test/ui/associated-types/associated-types-unconstrained.stderr +++ b/src/test/ui/associated-types/associated-types-unconstrained.stderr @@ -1,11 +1,14 @@ -error[E0284]: type annotations needed +error[E0283]: type annotations needed --> $DIR/associated-types-unconstrained.rs:14:20 | +LL | fn bar() -> isize; + | ------------------ required by `Foo::bar` +... LL | let x: isize = Foo::bar(); | ^^^^^^^^ cannot infer type | - = note: cannot satisfy `<_ as Foo>::A == _` + = note: cannot satisfy `_: Foo` error: aborting due to previous error -For more information about this error, try `rustc --explain E0284`. +For more information about this error, try `rustc --explain E0283`. diff --git a/src/test/ui/associated-types/defaults-cyclic-fail-1.rs b/src/test/ui/associated-types/defaults-cyclic-fail-1.rs index fa75f6bc152..afb2b3df716 100644 --- a/src/test/ui/associated-types/defaults-cyclic-fail-1.rs +++ b/src/test/ui/associated-types/defaults-cyclic-fail-1.rs @@ -6,11 +6,8 @@ trait Tr { type B = Self::A; } -// ...but is an error in any impl that doesn't override at least one of the defaults impl Tr for () {} -//~^ ERROR overflow evaluating the requirement -// As soon as at least one is redefined, it works: impl Tr for u8 { type A = u8; } @@ -24,16 +21,14 @@ impl Tr for u32 { type B = u8; } -// ...but only if this actually breaks the cycle +// ...but not in an impl that redefines one of the types. impl Tr for bool { - //~^ ERROR type mismatch resolving `::B == _` type A = Box; //~^ ERROR type mismatch resolving `::B == _` } // (the error is shown twice for some reason) impl Tr for usize { - //~^ ERROR type mismatch resolving `::B == _` type B = &'static Self::A; //~^ ERROR type mismatch resolving `::A == _` } diff --git a/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr b/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr index 0aea30b1112..28decb0934c 100644 --- a/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr +++ b/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr @@ -1,34 +1,16 @@ -error[E0275]: overflow evaluating the requirement `<() as Tr>::B == _` - --> $DIR/defaults-cyclic-fail-1.rs:10:6 - | -LL | impl Tr for () {} - | ^^ - -error[E0271]: type mismatch resolving `::B == _` - --> $DIR/defaults-cyclic-fail-1.rs:28:6 - | -LL | impl Tr for bool { - | ^^ cyclic type of infinite size - -error[E0271]: type mismatch resolving `::B == _` - --> $DIR/defaults-cyclic-fail-1.rs:35:6 - | -LL | impl Tr for usize { - | ^^ cyclic type of infinite size - -error[E0271]: type mismatch resolving `::B == _` - --> $DIR/defaults-cyclic-fail-1.rs:30:5 +error[E0275]: overflow evaluating the requirement `::B` + --> $DIR/defaults-cyclic-fail-1.rs:26:5 | LL | type A = Box; | ^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size -error[E0271]: type mismatch resolving `::A == _` - --> $DIR/defaults-cyclic-fail-1.rs:37:5 +error[E0275]: overflow evaluating the requirement `::A` + --> $DIR/defaults-cyclic-fail-1.rs:32:5 | LL | type B = &'static Self::A; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0271, E0275. For more information about an error, try `rustc --explain E0271`. diff --git a/src/test/ui/associated-types/defaults-cyclic-fail-2.rs b/src/test/ui/associated-types/defaults-cyclic-fail-2.rs index edcd310908a..ba4bb0d5a29 100644 --- a/src/test/ui/associated-types/defaults-cyclic-fail-2.rs +++ b/src/test/ui/associated-types/defaults-cyclic-fail-2.rs @@ -8,11 +8,8 @@ trait Tr { type B = Box; } -// ...but is an error in any impl that doesn't override at least one of the defaults impl Tr for () {} -//~^ ERROR type mismatch resolving `<() as Tr>::B == _` -// As soon as at least one is redefined, it works: impl Tr for u8 { type A = u8; } @@ -26,16 +23,13 @@ impl Tr for u32 { type B = u8; } -// ...but only if this actually breaks the cycle impl Tr for bool { - //~^ ERROR type mismatch resolving `::B == _` type A = Box; //~^ ERROR type mismatch resolving `::B == _` } // (the error is shown twice for some reason) impl Tr for usize { - //~^ ERROR type mismatch resolving `::B == _` type B = &'static Self::A; //~^ ERROR type mismatch resolving `::A == _` } diff --git a/src/test/ui/associated-types/defaults-cyclic-fail-2.stderr b/src/test/ui/associated-types/defaults-cyclic-fail-2.stderr index f39021c30ed..6b6d5348c15 100644 --- a/src/test/ui/associated-types/defaults-cyclic-fail-2.stderr +++ b/src/test/ui/associated-types/defaults-cyclic-fail-2.stderr @@ -1,33 +1,15 @@ -error[E0271]: type mismatch resolving `<() as Tr>::B == _` - --> $DIR/defaults-cyclic-fail-2.rs:12:6 - | -LL | impl Tr for () {} - | ^^ cyclic type of infinite size - -error[E0271]: type mismatch resolving `::B == _` - --> $DIR/defaults-cyclic-fail-2.rs:30:6 - | -LL | impl Tr for bool { - | ^^ cyclic type of infinite size - -error[E0271]: type mismatch resolving `::B == _` - --> $DIR/defaults-cyclic-fail-2.rs:37:6 - | -LL | impl Tr for usize { - | ^^ cyclic type of infinite size - -error[E0271]: type mismatch resolving `::B == _` - --> $DIR/defaults-cyclic-fail-2.rs:32:5 +error[E0275]: overflow evaluating the requirement `::B` + --> $DIR/defaults-cyclic-fail-2.rs:27:5 | LL | type A = Box; | ^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size -error[E0271]: type mismatch resolving `::A == _` - --> $DIR/defaults-cyclic-fail-2.rs:39:5 +error[E0275]: overflow evaluating the requirement `::A` + --> $DIR/defaults-cyclic-fail-2.rs:33:5 | LL | type B = &'static Self::A; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/associated-types/defaults-suitability.rs b/src/test/ui/associated-types/defaults-suitability.rs index 30c2555df8b..69be300b16f 100644 --- a/src/test/ui/associated-types/defaults-suitability.rs +++ b/src/test/ui/associated-types/defaults-suitability.rs @@ -1,10 +1,8 @@ //! Checks that associated type defaults are properly validated. //! //! This means: -//! * Default types are wfchecked //! * Default types are checked against where clauses on the assoc. type -//! (eg. `type Assoc: Clone = NotClone`), and also against where clauses on -//! the trait itself when possible +//! (eg. `type Assoc: Clone = NotClone`) #![feature(associated_type_defaults)] @@ -17,15 +15,12 @@ trait Tr { } // Where-clauses defined on the trait must also be considered -trait Tr2 where Self::Ty: Clone { - //~^ ERROR the trait bound `NotClone: Clone` is not satisfied +trait Tr2 +where + Self::Ty: Clone, +{ type Ty = NotClone; -} - -// Independent of where-clauses (there are none here), default types must always be wf -trait Tr3 { - type Ty = Vec<[u8]>; - //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time + //~^ ERROR the trait bound `NotClone: std::clone::Clone` is not satisfied } // Involved type parameters must fulfill all bounds required by defaults that mention them @@ -43,25 +38,24 @@ trait Bar: Sized { trait IsU8 {} impl IsU8 for T {} -// Test that mentioning the assoc. type inside where clauses works +// Test that mentioning the assoc. type inside where clauses is not allowed trait C where Vec: Clone, Self::Assoc: IsU8, bool: IsU8, { type Assoc = u8; + //~^ ERROR the trait bound `u8: IsU8<::Assoc>` is not satisfied } // Test that we get all expected errors if that default is unsuitable trait D where Vec: Clone, - //~^ ERROR the trait bound `NotClone: Clone` is not satisfied Self::Assoc: IsU8, - //~^ ERROR the trait bound `NotClone: IsU8` is not satisfied bool: IsU8, - //~^ ERROR the trait bound `bool: IsU8` is not satisfied { type Assoc = NotClone; + //~^ ERROR the trait bound `NotClone: IsU8<::Assoc>` is not satisfied } // Test behavior of the check when defaults refer to other defaults: @@ -85,18 +79,20 @@ trait Foo25 { // Adding the `Baz: Clone` bound isn't enough since the default is type // parameter `T`, which also might not be `Clone`. -trait Foo3 where +trait Foo3 +where Self::Bar: Clone, Self::Baz: Clone, - //~^ ERROR the trait bound `T: Clone` is not satisfied { type Bar = Vec; type Baz = T; + //~^ ERROR the trait bound `T: std::clone::Clone` is not satisfied } // This one finally works, with `Clone` bounds on all assoc. types and the type // parameter. -trait Foo4 where +trait Foo4 +where T: Clone, { type Bar: Clone = Vec; diff --git a/src/test/ui/associated-types/defaults-suitability.stderr b/src/test/ui/associated-types/defaults-suitability.stderr index c2ad4c5824e..4d8e6f1584d 100644 --- a/src/test/ui/associated-types/defaults-suitability.stderr +++ b/src/test/ui/associated-types/defaults-suitability.stderr @@ -1,27 +1,31 @@ -error[E0277]: the trait bound `NotClone: Clone` is not satisfied - --> $DIR/defaults-suitability.rs:15:14 +error[E0277]: the trait bound `NotClone: std::clone::Clone` is not satisfied + --> $DIR/defaults-suitability.rs:13:5 | -LL | trait Tr { - | -------- required by `Tr` LL | type Ty: Clone = NotClone; - | ^^^^^ the trait `Clone` is not implemented for `NotClone` + | ^^^^^^^^^-----^^^^^^^^^^^^ + | | | + | | required by this bound in `Tr::Ty` + | the trait `std::clone::Clone` is not implemented for `NotClone` -error[E0277]: the trait bound `NotClone: Clone` is not satisfied - --> $DIR/defaults-suitability.rs:20:27 +error[E0277]: the trait bound `NotClone: std::clone::Clone` is not satisfied + --> $DIR/defaults-suitability.rs:19:5 | LL | trait Tr2 where Self::Ty: Clone { - | --------------------------^^^^^ - | | | - | | the trait `Clone` is not implemented for `NotClone` - | required by `Tr2` + | ----- required by this bound in `Tr2::Ty` +LL | type Ty = NotClone; + | ^^^^^--^^^^^^^^^^^^ + | | | + | | required by a bound in this + | the trait `std::clone::Clone` is not implemented for `NotClone` -error[E0277]: the trait bound `T: Clone` is not satisfied - --> $DIR/defaults-suitability.rs:33:15 +error[E0277]: the trait bound `T: std::clone::Clone` is not satisfied + --> $DIR/defaults-suitability.rs:25:5 | -LL | trait Foo { - | ------------ required by `Foo` LL | type Bar: Clone = Vec; - | ^^^^^ the trait `Clone` is not implemented for `T` + | ^^^^^^^^^^-----^^^^^^^^^^ + | | | + | | required by this bound in `Foo::Bar` + | the trait `std::clone::Clone` is not implemented for `T` | = note: required because of the requirements on the impl of `Clone` for `Vec` help: consider restricting type parameter `T` @@ -30,64 +34,46 @@ LL | trait Foo { | ^^^^^^^ error[E0277]: the trait bound `(): Foo` is not satisfied - --> $DIR/defaults-suitability.rs:39:17 + --> $DIR/defaults-suitability.rs:31:5 | -LL | trait Bar: Sized { - | ---------------- required by `Bar` -LL | // `(): Foo` might hold for some possible impls but not all. LL | type Assoc: Foo = (); - | ^^^^^^^^^ the trait `Foo` is not implemented for `()` + | ^^^^^^^^^^^^---------^^^^^^ + | | | + | | required by this bound in `Bar::Assoc` + | the trait `Foo` is not implemented for `()` -error[E0277]: the trait bound `NotClone: IsU8` is not satisfied - --> $DIR/defaults-suitability.rs:59:18 +error[E0277]: the trait bound `u8: IsU8<::Assoc>` is not satisfied + --> $DIR/defaults-suitability.rs:44:5 | -LL | / trait D where -LL | | Vec: Clone, -LL | | -LL | | Self::Assoc: IsU8, - | | ^^^^^^^^^^^^^^^^^ the trait `IsU8` is not implemented for `NotClone` -... | -LL | | type Assoc = NotClone; -LL | | } - | |_- required by `D` +LL | Self::Assoc: IsU8, + | ----------------- required by this bound in `C::Assoc` +... +LL | type Assoc = u8; + | ^^^^^-----^^^^^^ + | | | + | | required by a bound in this + | the trait `IsU8<::Assoc>` is not implemented for `u8` -error[E0277]: the trait bound `bool: IsU8` is not satisfied - --> $DIR/defaults-suitability.rs:61:11 +error[E0277]: the trait bound `NotClone: IsU8<::Assoc>` is not satisfied + --> $DIR/defaults-suitability.rs:54:5 | -LL | / trait D where -LL | | Vec: Clone, -LL | | -LL | | Self::Assoc: IsU8, -LL | | -LL | | bool: IsU8, - | | ^^^^^^^^^^^^^^^^^ the trait `IsU8` is not implemented for `bool` -... | -LL | | type Assoc = NotClone; -LL | | } - | |_- required by `D` +LL | Self::Assoc: IsU8, + | ----------------- required by this bound in `D::Assoc` +... +LL | type Assoc = NotClone; + | ^^^^^-----^^^^^^^^^^^^ + | | | + | | required by a bound in this + | the trait `IsU8<::Assoc>` is not implemented for `NotClone` -error[E0277]: the trait bound `NotClone: Clone` is not satisfied - --> $DIR/defaults-suitability.rs:57:23 +error[E0277]: the trait bound `>::Baz: std::clone::Clone` is not satisfied + --> $DIR/defaults-suitability.rs:63:5 | -LL | / trait D where -LL | | Vec: Clone, - | | ^^^^^ the trait `Clone` is not implemented for `NotClone` -LL | | -LL | | Self::Assoc: IsU8, -... | -LL | | type Assoc = NotClone; -LL | | } - | |_- required by `D` - | - = note: required because of the requirements on the impl of `Clone` for `Vec` - -error[E0277]: the trait bound `>::Baz: Clone` is not satisfied - --> $DIR/defaults-suitability.rs:72:15 - | -LL | trait Foo2 { - | ------------- required by `Foo2` LL | type Bar: Clone = Vec; - | ^^^^^ the trait `Clone` is not implemented for `>::Baz` + | ^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^ + | | | + | | required by this bound in `Foo2::Bar` + | the trait `std::clone::Clone` is not implemented for `>::Baz` | = note: required because of the requirements on the impl of `Clone` for `Vec<>::Baz>` help: consider further restricting the associated type @@ -95,13 +81,14 @@ help: consider further restricting the associated type LL | trait Foo2 where >::Baz: Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `>::Baz: Clone` is not satisfied - --> $DIR/defaults-suitability.rs:81:15 +error[E0277]: the trait bound `>::Baz: std::clone::Clone` is not satisfied + --> $DIR/defaults-suitability.rs:72:5 | -LL | trait Foo25 { - | --------------------- required by `Foo25` LL | type Bar: Clone = Vec; - | ^^^^^ the trait `Clone` is not implemented for `>::Baz` + | ^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^ + | | | + | | required by this bound in `Foo25::Bar` + | the trait `std::clone::Clone` is not implemented for `>::Baz` | = note: required because of the requirements on the impl of `Clone` for `Vec<>::Baz>` help: consider further restricting the associated type @@ -109,37 +96,23 @@ help: consider further restricting the associated type LL | trait Foo25 where >::Baz: Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `T: Clone` is not satisfied - --> $DIR/defaults-suitability.rs:90:16 +error[E0277]: the trait bound `T: std::clone::Clone` is not satisfied + --> $DIR/defaults-suitability.rs:84:5 | -LL | / trait Foo3 where -LL | | Self::Bar: Clone, -LL | | Self::Baz: Clone, - | | ^^^^^ the trait `Clone` is not implemented for `T` -LL | | -... | -LL | | type Baz = T; -LL | | } - | |_- required by `Foo3` +LL | Self::Baz: Clone, + | ----- required by this bound in `Foo3::Baz` +... +LL | type Baz = T; + | ^^^^^---^^^^^ + | | | + | | required by a bound in this + | the trait `std::clone::Clone` is not implemented for `T` | help: consider further restricting type parameter `T` | LL | Self::Baz: Clone, T: Clone | ^^^^^^^^^^ -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/defaults-suitability.rs:27:5 - | -LL | type Ty = Vec<[u8]>; - | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - ::: $SRC_DIR/alloc/src/vec.rs:LL:COL - | -LL | pub struct Vec { - | - required by this bound in `Vec` - | - = help: the trait `Sized` is not implemented for `[u8]` - -error: aborting due to 11 previous errors +error: aborting due to 9 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/defaults-unsound-62211-1.rs b/src/test/ui/associated-types/defaults-unsound-62211-1.rs index f283d22b3c7..093e32f66be 100644 --- a/src/test/ui/associated-types/defaults-unsound-62211-1.rs +++ b/src/test/ui/associated-types/defaults-unsound-62211-1.rs @@ -11,22 +11,13 @@ use std::{ fmt::Display, - ops::{AddAssign, Deref} + ops::{AddAssign, Deref}, }; - trait UncheckedCopy: Sized { // This Output is said to be Copy. Yet we default to Self // and it's accepted, not knowing if Self ineed is Copy - type Output: Copy - //~^ ERROR the trait bound `Self: Copy` is not satisfied - + Deref - //~^ ERROR the trait bound `Self: Deref` is not satisfied - + AddAssign<&'static str> - //~^ ERROR cannot add-assign `&'static str` to `Self` - + From - + Display = Self; - //~^ ERROR `Self` doesn't implement `std::fmt::Display` + type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; // We said the Output type was Copy, so we can Copy it freely! fn unchecked_copy(other: &Self::Output) -> Self::Output { @@ -39,10 +30,6 @@ trait UncheckedCopy: Sized { } impl UncheckedCopy for T {} -//~^ ERROR `T` doesn't implement `std::fmt::Display` -//~| ERROR the trait bound `T: Deref` is not satisfied -//~| ERROR cannot add-assign `&'static str` to `T` -//~| ERROR the trait bound `T: Copy` is not satisfied fn bug(origin: T) { let origin = T::make_origin(origin); diff --git a/src/test/ui/associated-types/defaults-unsound-62211-1.stderr b/src/test/ui/associated-types/defaults-unsound-62211-1.stderr index 29a7c2eab41..a8584d6dc5c 100644 --- a/src/test/ui/associated-types/defaults-unsound-62211-1.stderr +++ b/src/test/ui/associated-types/defaults-unsound-62211-1.stderr @@ -1,53 +1,19 @@ -error[E0277]: the trait bound `Self: Copy` is not satisfied - --> $DIR/defaults-unsound-62211-1.rs:21:18 - | -LL | trait UncheckedCopy: Sized { - | -------------------------- required by `UncheckedCopy` -... -LL | type Output: Copy - | ^^^^ the trait `Copy` is not implemented for `Self` - | -help: consider further restricting `Self` - | -LL | trait UncheckedCopy: Sized + Copy { - | ^^^^^^ - -error[E0277]: cannot add-assign `&'static str` to `Self` - --> $DIR/defaults-unsound-62211-1.rs:25:7 - | -LL | trait UncheckedCopy: Sized { - | -------------------------- required by `UncheckedCopy` -... -LL | + AddAssign<&'static str> - | ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `Self += &'static str` - | -help: consider further restricting `Self` - | -LL | trait UncheckedCopy: Sized + AddAssign<&'static str> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: the trait bound `Self: Deref` is not satisfied - --> $DIR/defaults-unsound-62211-1.rs:23:7 - | -LL | trait UncheckedCopy: Sized { - | -------------------------- required by `UncheckedCopy` -... -LL | + Deref - | ^^^^^^^^^^^^^^^^^^^ the trait `Deref` is not implemented for `Self` - | -help: consider further restricting `Self` - | -LL | trait UncheckedCopy: Sized + Deref { - | ^^^^^^^ - error[E0277]: `Self` doesn't implement `std::fmt::Display` - --> $DIR/defaults-unsound-62211-1.rs:28:7 + --> $DIR/defaults-unsound-62211-1.rs:21:5 | -LL | trait UncheckedCopy: Sized { - | -------------------------- required by `UncheckedCopy` -... -LL | + Display = Self; - | ^^^^^^^ `Self` cannot be formatted with the default formatter +LL | type Output: Copy + | ^ ------ required by a bound in this + | _____| + | | +LL | | +LL | | +LL | | +... | +LL | | + From +LL | | + Display = Self; + | |___________-------_______^ `Self` cannot be formatted with the default formatter + | | + | required by this bound in `UncheckedCopy::Output` | = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead help: consider further restricting `Self` @@ -55,75 +21,71 @@ help: consider further restricting `Self` LL | trait UncheckedCopy: Sized + std::fmt::Display { | ^^^^^^^^^^^^^^^^^^^ -error[E0277]: `T` doesn't implement `std::fmt::Display` - --> $DIR/defaults-unsound-62211-1.rs:41:9 +error[E0277]: the trait bound `Self: std::ops::Deref` is not satisfied + --> $DIR/defaults-unsound-62211-1.rs:21:5 | -LL | trait UncheckedCopy: Sized { - | ------------- required by a bound in this -... -LL | + Display = Self; - | ------- required by this bound in `UncheckedCopy` -... -LL | impl UncheckedCopy for T {} - | ^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter +LL | type Output: Copy + | ^ ------ required by a bound in this + | _____| + | | +LL | | +LL | | +LL | | +LL | | +LL | | + Deref + | | ------------------- required by this bound in `UncheckedCopy::Output` +LL | | + AddAssign<&'static str> +LL | | + From +LL | | + Display = Self; + | |_________________________^ the trait `std::ops::Deref` is not implemented for `Self` | - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead -help: consider restricting type parameter `T` +help: consider further restricting `Self` | -LL | impl UncheckedCopy for T {} - | ^^^^^^^^^^^^^^^^^^^ +LL | trait UncheckedCopy: Sized + Deref { + | ^^^^^^^ -error[E0277]: the trait bound `T: Deref` is not satisfied - --> $DIR/defaults-unsound-62211-1.rs:41:9 +error[E0277]: cannot add-assign `&'static str` to `Self` + --> $DIR/defaults-unsound-62211-1.rs:21:5 | -LL | trait UncheckedCopy: Sized { - | ------------- required by a bound in this -... -LL | + Deref - | ------------------- required by this bound in `UncheckedCopy` -... -LL | impl UncheckedCopy for T {} - | ^^^^^^^^^^^^^ the trait `Deref` is not implemented for `T` +LL | type Output: Copy + | ^ ------ required by a bound in this + | _____| + | | +LL | | +LL | | +LL | | +... | +LL | | + AddAssign<&'static str> + | | ----------------------- required by this bound in `UncheckedCopy::Output` +LL | | + From +LL | | + Display = Self; + | |_________________________^ no implementation for `Self += &'static str` | -help: consider restricting type parameter `T` +help: consider further restricting `Self` | -LL | impl UncheckedCopy for T {} - | ^^^^^^^ +LL | trait UncheckedCopy: Sized + std::ops::AddAssign<&'static str> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: cannot add-assign `&'static str` to `T` - --> $DIR/defaults-unsound-62211-1.rs:41:9 +error[E0277]: the trait bound `Self: std::marker::Copy` is not satisfied + --> $DIR/defaults-unsound-62211-1.rs:21:5 | -LL | trait UncheckedCopy: Sized { - | ------------- required by a bound in this -... -LL | + AddAssign<&'static str> - | ----------------------- required by this bound in `UncheckedCopy` -... -LL | impl UncheckedCopy for T {} - | ^^^^^^^^^^^^^ no implementation for `T += &'static str` +LL | type Output: Copy + | ^ ---- required by this bound in `UncheckedCopy::Output` + | _____| + | | +LL | | +LL | | +LL | | +... | +LL | | + From +LL | | + Display = Self; + | |_________________________^ the trait `std::marker::Copy` is not implemented for `Self` | -help: consider restricting type parameter `T` +help: consider further restricting `Self` | -LL | impl> UncheckedCopy for T {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait UncheckedCopy: Sized + std::marker::Copy { + | ^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/defaults-unsound-62211-1.rs:41:9 - | -LL | trait UncheckedCopy: Sized { - | ------------- required by a bound in this -... -LL | type Output: Copy - | ---- required by this bound in `UncheckedCopy` -... -LL | impl UncheckedCopy for T {} - | ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` - | -help: consider restricting type parameter `T` - | -LL | impl UncheckedCopy for T {} - | ^^^^^^ - -error: aborting due to 8 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/defaults-unsound-62211-2.rs b/src/test/ui/associated-types/defaults-unsound-62211-2.rs index 5518cda3708..44bbdc9f52b 100644 --- a/src/test/ui/associated-types/defaults-unsound-62211-2.rs +++ b/src/test/ui/associated-types/defaults-unsound-62211-2.rs @@ -11,22 +11,13 @@ use std::{ fmt::Display, - ops::{AddAssign, Deref} + ops::{AddAssign, Deref}, }; - trait UncheckedCopy: Sized { // This Output is said to be Copy. Yet we default to Self // and it's accepted, not knowing if Self ineed is Copy - type Output: Copy - //~^ ERROR the trait bound `Self: Copy` is not satisfied - + Deref - //~^ ERROR the trait bound `Self: Deref` is not satisfied - + AddAssign<&'static str> - //~^ ERROR cannot add-assign `&'static str` to `Self` - + From - + Display = Self; - //~^ ERROR `Self` doesn't implement `std::fmt::Display` + type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; // We said the Output type was Copy, so we can Copy it freely! fn unchecked_copy(other: &Self::Output) -> Self::Output { @@ -39,10 +30,6 @@ trait UncheckedCopy: Sized { } impl UncheckedCopy for T {} -//~^ ERROR `T` doesn't implement `std::fmt::Display` -//~| ERROR the trait bound `T: Deref` is not satisfied -//~| ERROR cannot add-assign `&'static str` to `T` -//~| ERROR the trait bound `T: Copy` is not satisfied fn bug(origin: T) { let origin = T::make_origin(origin); diff --git a/src/test/ui/associated-types/defaults-unsound-62211-2.stderr b/src/test/ui/associated-types/defaults-unsound-62211-2.stderr index 49c66093bf0..6a8e3ff7b62 100644 --- a/src/test/ui/associated-types/defaults-unsound-62211-2.stderr +++ b/src/test/ui/associated-types/defaults-unsound-62211-2.stderr @@ -1,53 +1,19 @@ -error[E0277]: the trait bound `Self: Copy` is not satisfied - --> $DIR/defaults-unsound-62211-2.rs:21:18 - | -LL | trait UncheckedCopy: Sized { - | -------------------------- required by `UncheckedCopy` -... -LL | type Output: Copy - | ^^^^ the trait `Copy` is not implemented for `Self` - | -help: consider further restricting `Self` - | -LL | trait UncheckedCopy: Sized + Copy { - | ^^^^^^ - -error[E0277]: cannot add-assign `&'static str` to `Self` - --> $DIR/defaults-unsound-62211-2.rs:25:7 - | -LL | trait UncheckedCopy: Sized { - | -------------------------- required by `UncheckedCopy` -... -LL | + AddAssign<&'static str> - | ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `Self += &'static str` - | -help: consider further restricting `Self` - | -LL | trait UncheckedCopy: Sized + AddAssign<&'static str> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: the trait bound `Self: Deref` is not satisfied - --> $DIR/defaults-unsound-62211-2.rs:23:7 - | -LL | trait UncheckedCopy: Sized { - | -------------------------- required by `UncheckedCopy` -... -LL | + Deref - | ^^^^^^^^^^^^^^^^^^^ the trait `Deref` is not implemented for `Self` - | -help: consider further restricting `Self` - | -LL | trait UncheckedCopy: Sized + Deref { - | ^^^^^^^ - error[E0277]: `Self` doesn't implement `std::fmt::Display` - --> $DIR/defaults-unsound-62211-2.rs:28:7 + --> $DIR/defaults-unsound-62211-2.rs:21:5 | -LL | trait UncheckedCopy: Sized { - | -------------------------- required by `UncheckedCopy` -... -LL | + Display = Self; - | ^^^^^^^ `Self` cannot be formatted with the default formatter +LL | type Output: Copy + | ^ ------ required by a bound in this + | _____| + | | +LL | | +LL | | +LL | | +... | +LL | | + From +LL | | + Display = Self; + | |___________-------_______^ `Self` cannot be formatted with the default formatter + | | + | required by this bound in `UncheckedCopy::Output` | = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead help: consider further restricting `Self` @@ -55,75 +21,71 @@ help: consider further restricting `Self` LL | trait UncheckedCopy: Sized + std::fmt::Display { | ^^^^^^^^^^^^^^^^^^^ -error[E0277]: `T` doesn't implement `std::fmt::Display` - --> $DIR/defaults-unsound-62211-2.rs:41:9 +error[E0277]: the trait bound `Self: std::ops::Deref` is not satisfied + --> $DIR/defaults-unsound-62211-2.rs:21:5 | -LL | trait UncheckedCopy: Sized { - | ------------- required by a bound in this -... -LL | + Display = Self; - | ------- required by this bound in `UncheckedCopy` -... -LL | impl UncheckedCopy for T {} - | ^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter +LL | type Output: Copy + | ^ ------ required by a bound in this + | _____| + | | +LL | | +LL | | +LL | | +LL | | +LL | | + Deref + | | ------------------- required by this bound in `UncheckedCopy::Output` +LL | | + AddAssign<&'static str> +LL | | + From +LL | | + Display = Self; + | |_________________________^ the trait `std::ops::Deref` is not implemented for `Self` | - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead -help: consider restricting type parameter `T` +help: consider further restricting `Self` | -LL | impl UncheckedCopy for T {} - | ^^^^^^^^^^^^^^^^^^^ +LL | trait UncheckedCopy: Sized + Deref { + | ^^^^^^^ -error[E0277]: the trait bound `T: Deref` is not satisfied - --> $DIR/defaults-unsound-62211-2.rs:41:9 +error[E0277]: cannot add-assign `&'static str` to `Self` + --> $DIR/defaults-unsound-62211-2.rs:21:5 | -LL | trait UncheckedCopy: Sized { - | ------------- required by a bound in this -... -LL | + Deref - | ------------------- required by this bound in `UncheckedCopy` -... -LL | impl UncheckedCopy for T {} - | ^^^^^^^^^^^^^ the trait `Deref` is not implemented for `T` +LL | type Output: Copy + | ^ ------ required by a bound in this + | _____| + | | +LL | | +LL | | +LL | | +... | +LL | | + AddAssign<&'static str> + | | ----------------------- required by this bound in `UncheckedCopy::Output` +LL | | + From +LL | | + Display = Self; + | |_________________________^ no implementation for `Self += &'static str` | -help: consider restricting type parameter `T` +help: consider further restricting `Self` | -LL | impl UncheckedCopy for T {} - | ^^^^^^^ +LL | trait UncheckedCopy: Sized + std::ops::AddAssign<&'static str> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: cannot add-assign `&'static str` to `T` - --> $DIR/defaults-unsound-62211-2.rs:41:9 +error[E0277]: the trait bound `Self: std::marker::Copy` is not satisfied + --> $DIR/defaults-unsound-62211-2.rs:21:5 | -LL | trait UncheckedCopy: Sized { - | ------------- required by a bound in this -... -LL | + AddAssign<&'static str> - | ----------------------- required by this bound in `UncheckedCopy` -... -LL | impl UncheckedCopy for T {} - | ^^^^^^^^^^^^^ no implementation for `T += &'static str` +LL | type Output: Copy + | ^ ---- required by this bound in `UncheckedCopy::Output` + | _____| + | | +LL | | +LL | | +LL | | +... | +LL | | + From +LL | | + Display = Self; + | |_________________________^ the trait `std::marker::Copy` is not implemented for `Self` | -help: consider restricting type parameter `T` +help: consider further restricting `Self` | -LL | impl> UncheckedCopy for T {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait UncheckedCopy: Sized + std::marker::Copy { + | ^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/defaults-unsound-62211-2.rs:41:9 - | -LL | trait UncheckedCopy: Sized { - | ------------- required by a bound in this -... -LL | type Output: Copy - | ---- required by this bound in `UncheckedCopy` -... -LL | impl UncheckedCopy for T {} - | ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` - | -help: consider restricting type parameter `T` - | -LL | impl UncheckedCopy for T {} - | ^^^^^^ - -error: aborting due to 8 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/defaults-wf.rs b/src/test/ui/associated-types/defaults-wf.rs new file mode 100644 index 00000000000..99b51250334 --- /dev/null +++ b/src/test/ui/associated-types/defaults-wf.rs @@ -0,0 +1,11 @@ +// Check that associated type defaults are wf checked. + +#![feature(associated_type_defaults)] + +// Default types must always be wf +trait Tr3 { + type Ty = Vec<[u8]>; + //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time +} + +fn main() {} diff --git a/src/test/ui/associated-types/defaults-wf.stderr b/src/test/ui/associated-types/defaults-wf.stderr new file mode 100644 index 00000000000..aeb7b6cae19 --- /dev/null +++ b/src/test/ui/associated-types/defaults-wf.stderr @@ -0,0 +1,16 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/defaults-wf.rs:7:5 + | +LL | type Ty = Vec<[u8]>; + | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + ::: $SRC_DIR/liballoc/vec.rs:LL:COL + | +LL | pub struct Vec { + | - required by this bound in `std::vec::Vec` + | + = help: the trait `std::marker::Sized` is not implemented for `[u8]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/issue-43924.rs b/src/test/ui/associated-types/issue-43924.rs index 26f1183c6bd..6a63b3e0936 100644 --- a/src/test/ui/associated-types/issue-43924.rs +++ b/src/test/ui/associated-types/issue-43924.rs @@ -4,12 +4,13 @@ // type-checked. trait Foo { - type Out: Default + ToString + ?Sized = dyn ToString; //~ error: not satisfied + type Out: Default + ToString + ?Sized = dyn ToString; //~ ERROR not satisfied } -impl Foo for () {} //~ error: not satisfied -impl Foo for () {} //~ error: not satisfied +impl Foo for () {} +impl Foo for () {} fn main() { assert_eq!(<() as Foo>::Out::default().to_string(), "false"); + //~^ ERROR no function or associated item named `default` found for trait object } diff --git a/src/test/ui/associated-types/issue-43924.stderr b/src/test/ui/associated-types/issue-43924.stderr index 661730bcd75..9bcedb05ed4 100644 --- a/src/test/ui/associated-types/issue-43924.stderr +++ b/src/test/ui/associated-types/issue-43924.stderr @@ -1,33 +1,19 @@ -error[E0277]: the trait bound `(dyn ToString + 'static): Default` is not satisfied - --> $DIR/issue-43924.rs:7:15 +error[E0277]: the trait bound `(dyn std::string::ToString + 'static): std::default::Default` is not satisfied + --> $DIR/issue-43924.rs:7:5 | -LL | trait Foo { - | -------------------------------- required by `Foo` LL | type Out: Default + ToString + ?Sized = dyn ToString; - | ^^^^^^^ the trait `Default` is not implemented for `(dyn ToString + 'static)` + | ^^^^^^^^^^-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | + | | required by this bound in `Foo::Out` + | the trait `std::default::Default` is not implemented for `(dyn std::string::ToString + 'static)` -error[E0277]: the trait bound `(dyn ToString + 'static): Default` is not satisfied - --> $DIR/issue-43924.rs:10:6 +error[E0599]: no function or associated item named `default` found for trait object `(dyn std::string::ToString + 'static)` in the current scope + --> $DIR/issue-43924.rs:14:39 | -LL | trait Foo { - | --- required by a bound in this -LL | type Out: Default + ToString + ?Sized = dyn ToString; - | ------- required by this bound in `Foo` -... -LL | impl Foo for () {} - | ^^^^^^^^ the trait `Default` is not implemented for `(dyn ToString + 'static)` +LL | assert_eq!(<() as Foo>::Out::default().to_string(), "false"); + | ^^^^^^^ function or associated item not found in `(dyn std::string::ToString + 'static)` -error[E0277]: the trait bound `(dyn ToString + 'static): Default` is not satisfied - --> $DIR/issue-43924.rs:11:6 - | -LL | trait Foo { - | --- required by a bound in this -LL | type Out: Default + ToString + ?Sized = dyn ToString; - | ------- required by this bound in `Foo` -... -LL | impl Foo for () {} - | ^^^^^^^^ the trait `Default` is not implemented for `(dyn ToString + 'static)` +error: aborting due to 2 previous errors -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0277, E0599. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/issue-63593.stderr b/src/test/ui/associated-types/issue-63593.stderr index ddc0bf436f6..16ae07687e2 100644 --- a/src/test/ui/associated-types/issue-63593.stderr +++ b/src/test/ui/associated-types/issue-63593.stderr @@ -1,10 +1,11 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation time --> $DIR/issue-63593.rs:9:5 | -LL | trait MyTrait { - | ------------- required by `MyTrait` LL | type This = Self; - | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^^ + | | + | doesn't have a size known at compile-time + | required by this bound in `MyTrait::This` | help: consider further restricting `Self` | diff --git a/src/test/ui/associated-types/issue-65774-1.rs b/src/test/ui/associated-types/issue-65774-1.rs index 0ffd6cc2cf2..9345140558b 100644 --- a/src/test/ui/associated-types/issue-65774-1.rs +++ b/src/test/ui/associated-types/issue-65774-1.rs @@ -14,7 +14,6 @@ trait MPU { struct S; impl MPU for S { } -//~^ ERROR the trait bound `T: MyDisplay` is not satisfied trait MyWrite { fn my_write(&self, _: &dyn MyDisplay) { } @@ -43,6 +42,7 @@ impl ProcessType for Process { // FulfillmentError(Obligation(predicate=Binder(TraitPredicate()), // depth=1),Unimplemented) let closure = |config: &mut ::MpuConfig| writer.my_write(&config); + //~^ ERROR the trait bound `T: MyDisplay` is not satisfied closure(valref); } } diff --git a/src/test/ui/associated-types/issue-65774-1.stderr b/src/test/ui/associated-types/issue-65774-1.stderr index 72f47df5d80..f644eb5a1f4 100644 --- a/src/test/ui/associated-types/issue-65774-1.stderr +++ b/src/test/ui/associated-types/issue-65774-1.stderr @@ -1,21 +1,20 @@ error[E0277]: the trait bound `T: MyDisplay` is not satisfied - --> $DIR/issue-65774-1.rs:10:21 + --> $DIR/issue-65774-1.rs:10:5 | -LL | trait MPU { - | --------- required by `MPU` LL | type MpuConfig: MyDisplay = T; - | ^^^^^^^^^ the trait `MyDisplay` is not implemented for `T` + | ^^^^^^^^^^^^^^^^---------^^^^^ + | | | + | | required by this bound in `MPU::MpuConfig` + | the trait `MyDisplay` is not implemented for `T` error[E0277]: the trait bound `T: MyDisplay` is not satisfied - --> $DIR/issue-65774-1.rs:16:6 + --> $DIR/issue-65774-1.rs:44:76 | -LL | trait MPU { - | --- required by a bound in this -LL | type MpuConfig: MyDisplay = T; - | --------- required by this bound in `MPU` -... -LL | impl MPU for S { } - | ^^^ the trait `MyDisplay` is not implemented for `T` +LL | let closure = |config: &mut ::MpuConfig| writer.my_write(&config); + | ^^^^^^^ the trait `MyDisplay` is not implemented for `T` + | + = note: required because of the requirements on the impl of `MyDisplay` for `&mut T` + = note: required for the cast to the object type `dyn MyDisplay` error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/issue-65774-2.rs b/src/test/ui/associated-types/issue-65774-2.rs index 31e203a81d3..171e0893b47 100644 --- a/src/test/ui/associated-types/issue-65774-2.rs +++ b/src/test/ui/associated-types/issue-65774-2.rs @@ -14,7 +14,6 @@ trait MPU { struct S; impl MPU for S { } -//~^ ERROR the trait bound `T: MyDisplay` is not satisfied trait MyWrite { fn my_write(&self, _: &dyn MyDisplay) { } @@ -38,6 +37,7 @@ impl ProcessType for Process { // // `Unimplemented` selecting `Binder()` during codegen // writer.my_write(valref) + //~^ ERROR the trait bound `T: MyDisplay` is not satisfied // This one causes the ICE: // FulfillmentError(Obligation(predicate=Binder(TraitPredicate()), diff --git a/src/test/ui/associated-types/issue-65774-2.stderr b/src/test/ui/associated-types/issue-65774-2.stderr index aef70885af3..572a9cf1909 100644 --- a/src/test/ui/associated-types/issue-65774-2.stderr +++ b/src/test/ui/associated-types/issue-65774-2.stderr @@ -1,21 +1,19 @@ error[E0277]: the trait bound `T: MyDisplay` is not satisfied - --> $DIR/issue-65774-2.rs:10:21 + --> $DIR/issue-65774-2.rs:10:5 | -LL | trait MPU { - | --------- required by `MPU` LL | type MpuConfig: MyDisplay = T; - | ^^^^^^^^^ the trait `MyDisplay` is not implemented for `T` + | ^^^^^^^^^^^^^^^^---------^^^^^ + | | | + | | required by this bound in `MPU::MpuConfig` + | the trait `MyDisplay` is not implemented for `T` error[E0277]: the trait bound `T: MyDisplay` is not satisfied - --> $DIR/issue-65774-2.rs:16:6 + --> $DIR/issue-65774-2.rs:39:25 | -LL | trait MPU { - | --- required by a bound in this -LL | type MpuConfig: MyDisplay = T; - | --------- required by this bound in `MPU` -... -LL | impl MPU for S { } - | ^^^ the trait `MyDisplay` is not implemented for `T` +LL | writer.my_write(valref) + | ^^^^^^ the trait `MyDisplay` is not implemented for `T` + | + = note: required for the cast to the object type `dyn MyDisplay` error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/issue-72806.rs b/src/test/ui/associated-types/issue-72806.rs index ae63781d568..94758250346 100644 --- a/src/test/ui/associated-types/issue-72806.rs +++ b/src/test/ui/associated-types/issue-72806.rs @@ -9,9 +9,10 @@ trait Bar2 { struct Foo; struct Foo2; -impl Bar for Foo { //~ ERROR type mismatch resolving `::Ok == char` +impl Bar for Foo { type Ok = (); type Sibling = Foo2; + //~^ ERROR type mismatch resolving `::Ok == char` } impl Bar2 for Foo2 { type Ok = u32; diff --git a/src/test/ui/associated-types/issue-72806.stderr b/src/test/ui/associated-types/issue-72806.stderr index 03a6565848d..23fabbee1c5 100644 --- a/src/test/ui/associated-types/issue-72806.stderr +++ b/src/test/ui/associated-types/issue-72806.stderr @@ -1,8 +1,11 @@ error[E0271]: type mismatch resolving `::Ok == char` - --> $DIR/issue-72806.rs:12:6 + --> $DIR/issue-72806.rs:14:5 | -LL | impl Bar for Foo { - | ^^^ expected `u32`, found `char` +LL | type Sibling: Bar2; + | ------- required by this bound in `Bar::Sibling` +... +LL | type Sibling = Foo2; + | ^^^^^^^^^^^^^^^^^^^^ expected `char`, found `u32` error: aborting due to previous error diff --git a/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.rs b/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.rs index 67b7c78071c..4bd3ccab834 100644 --- a/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.rs +++ b/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.rs @@ -5,7 +5,9 @@ trait Foo { } impl Foo for () { - type Assoc = bool; //~ ERROR the trait bound `bool: Bar` is not satisfied + // Doesn't error because we abort compilation after the errors below. + // See point-at-type-on-obligation-failure-3.rs + type Assoc = bool; } trait Baz where Self::Assoc: Bar { diff --git a/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr b/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr index 3118a9c5352..f4971105499 100644 --- a/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr +++ b/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr @@ -1,16 +1,5 @@ error[E0277]: the trait bound `bool: Bar` is not satisfied - --> $DIR/point-at-type-on-obligation-failure-2.rs:8:18 - | -LL | trait Foo { - | --- required by a bound in this -LL | type Assoc: Bar; - | --- required by this bound in `Foo` -... -LL | type Assoc = bool; - | ^^^^ the trait `Bar` is not implemented for `bool` - -error[E0277]: the trait bound `bool: Bar` is not satisfied - --> $DIR/point-at-type-on-obligation-failure-2.rs:16:18 + --> $DIR/point-at-type-on-obligation-failure-2.rs:18:18 | LL | trait Baz where Self::Assoc: Bar { | --- required by this bound in `Baz` @@ -19,7 +8,7 @@ LL | type Assoc = bool; | ^^^^ the trait `Bar` is not implemented for `bool` error[E0277]: the trait bound `bool: Bar` is not satisfied - --> $DIR/point-at-type-on-obligation-failure-2.rs:24:18 + --> $DIR/point-at-type-on-obligation-failure-2.rs:26:18 | LL | trait Bat where ::Assoc: Bar { | --- required by this bound in `Bat` @@ -27,6 +16,6 @@ LL | trait Bat where ::Assoc: Bar { LL | type Assoc = bool; | ^^^^ the trait `Bar` is not implemented for `bool` -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/point-at-type-on-obligation-failure-3.rs b/src/test/ui/associated-types/point-at-type-on-obligation-failure-3.rs new file mode 100644 index 00000000000..9360d96f05e --- /dev/null +++ b/src/test/ui/associated-types/point-at-type-on-obligation-failure-3.rs @@ -0,0 +1,11 @@ +trait Bar {} + +trait Foo { + type Assoc: Bar; +} + +impl Foo for () { + type Assoc = bool; //~ ERROR the trait bound `bool: Bar` is not satisfied +} + +fn main() {} diff --git a/src/test/ui/associated-types/point-at-type-on-obligation-failure-3.stderr b/src/test/ui/associated-types/point-at-type-on-obligation-failure-3.stderr new file mode 100644 index 00000000000..6ab3d94e102 --- /dev/null +++ b/src/test/ui/associated-types/point-at-type-on-obligation-failure-3.stderr @@ -0,0 +1,12 @@ +error[E0277]: the trait bound `bool: Bar` is not satisfied + --> $DIR/point-at-type-on-obligation-failure-3.rs:8:5 + | +LL | type Assoc: Bar; + | --- required by this bound in `Foo::Assoc` +... +LL | type Assoc = bool; + | ^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `bool` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/point-at-type-on-obligation-failure.rs b/src/test/ui/associated-types/point-at-type-on-obligation-failure.rs index dc43dbaf54b..66666006887 100644 --- a/src/test/ui/associated-types/point-at-type-on-obligation-failure.rs +++ b/src/test/ui/associated-types/point-at-type-on-obligation-failure.rs @@ -10,8 +10,9 @@ struct Foo; struct Foo2; impl Bar for Foo { - type Ok = (); //~ ERROR type mismatch resolving `::Ok == ()` + type Ok = (); type Sibling = Foo2; + //~^ ERROR type mismatch resolving `::Ok == ()` } impl Bar2 for Foo2 { type Ok = u32; diff --git a/src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr b/src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr index 818702b7afe..7417a5aa3d4 100644 --- a/src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr +++ b/src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr @@ -1,8 +1,11 @@ error[E0271]: type mismatch resolving `::Ok == ()` - --> $DIR/point-at-type-on-obligation-failure.rs:13:15 + --> $DIR/point-at-type-on-obligation-failure.rs:14:5 | -LL | type Ok = (); - | ^^ expected `u32`, found `()` +LL | type Sibling: Bar2; + | ----------- required by this bound in `Bar::Sibling` +... +LL | type Sibling = Foo2; + | ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `u32` error: aborting due to previous error diff --git a/src/test/ui/chalkify/impl_wf.rs b/src/test/ui/chalkify/impl_wf.rs index 465eb10241e..66f57c2d110 100644 --- a/src/test/ui/chalkify/impl_wf.rs +++ b/src/test/ui/chalkify/impl_wf.rs @@ -15,19 +15,6 @@ impl Foo for str { } // Implicit `T: Sized` bound. impl Foo for Option { } -impl Bar for () { - type Item = i32; -} - -impl Bar for Option { - type Item = Option; -} - -impl Bar for f32 { - type Item = f32; - //~^ ERROR the trait bound `f32: Foo` is not satisfied -} - trait Baz where U: Foo { } impl Baz for i32 { } diff --git a/src/test/ui/chalkify/impl_wf.stderr b/src/test/ui/chalkify/impl_wf.stderr index 4ca5ae472f2..24c7f0d82bd 100644 --- a/src/test/ui/chalkify/impl_wf.stderr +++ b/src/test/ui/chalkify/impl_wf.stderr @@ -10,18 +10,7 @@ LL | impl Foo for str { } = help: the trait `Sized` is not implemented for `str` error[E0277]: the trait bound `f32: Foo` is not satisfied - --> $DIR/impl_wf.rs:27:17 - | -LL | trait Bar { - | --- required by a bound in this -LL | type Item: Foo; - | --- required by this bound in `Bar` -... -LL | type Item = f32; - | ^^^ the trait `Foo` is not implemented for `f32` - -error[E0277]: the trait bound `f32: Foo` is not satisfied - --> $DIR/impl_wf.rs:35:6 + --> $DIR/impl_wf.rs:22:6 | LL | trait Baz where U: Foo { } | --- required by this bound in `Baz` @@ -29,6 +18,6 @@ LL | trait Baz where U: Foo { } LL | impl Baz for f32 { } | ^^^^^^^^ the trait `Foo` is not implemented for `f32` -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/chalkify/impl_wf_2.rs b/src/test/ui/chalkify/impl_wf_2.rs new file mode 100644 index 00000000000..758a7185e39 --- /dev/null +++ b/src/test/ui/chalkify/impl_wf_2.rs @@ -0,0 +1,33 @@ +// Split out of impl_wf.rs to work around rust aborting compilation early + +// compile-flags: -Z chalk + +trait Foo: Sized { } + +trait Bar { + type Item: Foo; +} + +impl Foo for i32 { } + +// Implicit `T: Sized` bound. +impl Foo for Option { } + +impl Bar for () { + type Item = i32; +} + +impl Bar for Option { + type Item = Option; +} + +impl Bar for f32 { + type Item = f32; + //~^ ERROR the trait bound `f32: Foo` is not satisfied +} + +trait Baz where U: Foo { } + +impl Baz for i32 { } + +fn main() {} diff --git a/src/test/ui/chalkify/impl_wf_2.stderr b/src/test/ui/chalkify/impl_wf_2.stderr new file mode 100644 index 00000000000..1da2144c0a5 --- /dev/null +++ b/src/test/ui/chalkify/impl_wf_2.stderr @@ -0,0 +1,12 @@ +error[E0277]: the trait bound `f32: Foo` is not satisfied + --> $DIR/impl_wf_2.rs:25:5 + | +LL | type Item: Foo; + | --- required by this bound in `Bar::Item` +... +LL | type Item = f32; + | ^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `f32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs index 9bce274027e..c5c8c5c1eca 100644 --- a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs +++ b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs @@ -14,6 +14,7 @@ impl Tr1 for S1 { type As1 = S2; } trait _Tr3 { type A: Iterator; //~^ ERROR associated type bounds are unstable + //~| ERROR the trait bound `<::A as std::iter::Iterator>::Item: std::marker::Copy` is not satisfied type B: Iterator; //~^ ERROR associated type bounds are unstable diff --git a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr index 7f2704e1bc3..db78e287d65 100644 --- a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr +++ b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr @@ -8,7 +8,7 @@ LL | type A: Iterator; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:18:22 + --> $DIR/feature-gate-associated_type_bounds.rs:19:22 | LL | type B: Iterator; | ^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | type B: Iterator; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:22:20 + --> $DIR/feature-gate-associated_type_bounds.rs:23:20 | LL | struct _St1> { | ^^^^^^^^ @@ -26,7 +26,7 @@ LL | struct _St1> { = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:29:18 + --> $DIR/feature-gate-associated_type_bounds.rs:30:18 | LL | enum _En1> { | ^^^^^^^^ @@ -35,7 +35,7 @@ LL | enum _En1> { = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:36:19 + --> $DIR/feature-gate-associated_type_bounds.rs:37:19 | LL | union _Un1> { | ^^^^^^^^ @@ -44,7 +44,7 @@ LL | union _Un1> { = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:43:37 + --> $DIR/feature-gate-associated_type_bounds.rs:44:37 | LL | type _TaWhere1 where T: Iterator = T; | ^^^^^^^^^^ @@ -53,7 +53,7 @@ LL | type _TaWhere1 where T: Iterator = T; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:46:22 + --> $DIR/feature-gate-associated_type_bounds.rs:47:22 | LL | fn _apit(_: impl Tr1) {} | ^^^^^^^^^ @@ -62,7 +62,7 @@ LL | fn _apit(_: impl Tr1) {} = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:48:26 + --> $DIR/feature-gate-associated_type_bounds.rs:49:26 | LL | fn _apit_dyn(_: &dyn Tr1) {} | ^^^^^^^^^ @@ -71,7 +71,7 @@ LL | fn _apit_dyn(_: &dyn Tr1) {} = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:51:24 + --> $DIR/feature-gate-associated_type_bounds.rs:52:24 | LL | fn _rpit() -> impl Tr1 { S1 } | ^^^^^^^^^ @@ -80,7 +80,7 @@ LL | fn _rpit() -> impl Tr1 { S1 } = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:54:31 + --> $DIR/feature-gate-associated_type_bounds.rs:55:31 | LL | fn _rpit_dyn() -> Box> { Box::new(S1) } | ^^^^^^^^^ @@ -89,7 +89,7 @@ LL | fn _rpit_dyn() -> Box> { Box::new(S1) } = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:57:23 + --> $DIR/feature-gate-associated_type_bounds.rs:58:23 | LL | const _cdef: impl Tr1 = S1; | ^^^^^^^^^ @@ -98,7 +98,7 @@ LL | const _cdef: impl Tr1 = S1; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:63:24 + --> $DIR/feature-gate-associated_type_bounds.rs:64:24 | LL | static _sdef: impl Tr1 = S1; | ^^^^^^^^^ @@ -107,7 +107,7 @@ LL | static _sdef: impl Tr1 = S1; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:70:21 + --> $DIR/feature-gate-associated_type_bounds.rs:71:21 | LL | let _: impl Tr1 = S1; | ^^^^^^^^^ @@ -116,7 +116,7 @@ LL | let _: impl Tr1 = S1; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-associated_type_bounds.rs:57:14 + --> $DIR/feature-gate-associated_type_bounds.rs:58:14 | LL | const _cdef: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ @@ -124,7 +124,7 @@ LL | const _cdef: impl Tr1 = S1; = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-associated_type_bounds.rs:63:15 + --> $DIR/feature-gate-associated_type_bounds.rs:64:15 | LL | static _sdef: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ @@ -132,14 +132,30 @@ LL | static _sdef: impl Tr1 = S1; = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-associated_type_bounds.rs:70:12 + --> $DIR/feature-gate-associated_type_bounds.rs:71:12 | LL | let _: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ | = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable -error: aborting due to 16 previous errors +error[E0277]: the trait bound `<::A as std::iter::Iterator>::Item: std::marker::Copy` is not satisfied + --> $DIR/feature-gate-associated_type_bounds.rs:15:28 + | +LL | type A: Iterator; + | ^^^^ the trait `std::marker::Copy` is not implemented for `<::A as std::iter::Iterator>::Item` + | + ::: $SRC_DIR/libcore/marker.rs:LL:COL + | +LL | pub trait Copy: Clone { + | --------------------- required by this bound in `std::marker::Copy` + | +help: consider further restricting the associated type + | +LL | trait _Tr3 where <::A as std::iter::Iterator>::Item: std::marker::Copy { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Some errors have detailed explanations: E0562, E0658. -For more information about an error, try `rustc --explain E0562`. +error: aborting due to 17 previous errors + +Some errors have detailed explanations: E0277, E0562, E0658. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/generator/sized-yield.stderr b/src/test/ui/generator/sized-yield.stderr index 2bcf66dbeae..e49dc91ec66 100644 --- a/src/test/ui/generator/sized-yield.stderr +++ b/src/test/ui/generator/sized-yield.stderr @@ -16,6 +16,11 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t | LL | Pin::new(&mut gen).resume(()); | ^^^^^^ doesn't have a size known at compile-time + | + ::: $SRC_DIR/libcore/ops/generator.rs:LL:COL + | +LL | pub enum GeneratorState { + | - required by this bound in `std::ops::GeneratorState` | = help: the trait `Sized` is not implemented for `str` diff --git a/src/test/ui/generic-associated-types/issue-68641-check-gat-bounds.stderr b/src/test/ui/generic-associated-types/issue-68641-check-gat-bounds.stderr index 6ba79dd5437..b380f0da2ea 100644 --- a/src/test/ui/generic-associated-types/issue-68641-check-gat-bounds.stderr +++ b/src/test/ui/generic-associated-types/issue-68641-check-gat-bounds.stderr @@ -11,7 +11,7 @@ error[E0277]: the trait bound `T: Copy` is not satisfied --> $DIR/issue-68641-check-gat-bounds.rs:15:5 | LL | type Item<'a>: Copy; - | -------------------- required by `UnsafeCopy::Item` + | ---- required by this bound in `UnsafeCopy::Item` ... LL | type Item<'a> = T; | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` diff --git a/src/test/ui/generic-associated-types/issue-68642-broken-llvm-ir.stderr b/src/test/ui/generic-associated-types/issue-68642-broken-llvm-ir.stderr index 15a66e25b19..61950478c32 100644 --- a/src/test/ui/generic-associated-types/issue-68642-broken-llvm-ir.stderr +++ b/src/test/ui/generic-associated-types/issue-68642-broken-llvm-ir.stderr @@ -11,7 +11,7 @@ error[E0277]: expected a `Fn<()>` closure, found `T` --> $DIR/issue-68642-broken-llvm-ir.rs:15:5 | LL | type F<'a>: Fn() -> u32; - | ------------------------ required by `Fun::F` + | ----------- required by this bound in `Fun::F` ... LL | type F<'a> = Self; | ^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `T` diff --git a/src/test/ui/generic-associated-types/issue-68643-broken-mir.stderr b/src/test/ui/generic-associated-types/issue-68643-broken-mir.stderr index 9b2ddb23267..13980618987 100644 --- a/src/test/ui/generic-associated-types/issue-68643-broken-mir.stderr +++ b/src/test/ui/generic-associated-types/issue-68643-broken-mir.stderr @@ -11,7 +11,7 @@ error[E0277]: expected a `Fn<()>` closure, found `T` --> $DIR/issue-68643-broken-mir.rs:15:5 | LL | type F<'a>: Fn() -> u32; - | ------------------------ required by `Fun::F` + | ----------- required by this bound in `Fun::F` ... LL | type F<'a> = Self; | ^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `T` diff --git a/src/test/ui/generic-associated-types/issue-68644-codegen-selection.stderr b/src/test/ui/generic-associated-types/issue-68644-codegen-selection.stderr index f7bfab35052..81124251469 100644 --- a/src/test/ui/generic-associated-types/issue-68644-codegen-selection.stderr +++ b/src/test/ui/generic-associated-types/issue-68644-codegen-selection.stderr @@ -11,7 +11,7 @@ error[E0277]: expected a `Fn<()>` closure, found `T` --> $DIR/issue-68644-codegen-selection.rs:15:5 | LL | type F<'a>: Fn() -> u32; - | ------------------------ required by `Fun::F` + | ----------- required by this bound in `Fun::F` ... LL | type F<'a> = Self; | ^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `T` diff --git a/src/test/ui/generic-associated-types/issue-68645-codegen-fulfillment.stderr b/src/test/ui/generic-associated-types/issue-68645-codegen-fulfillment.stderr index 6c2d330a19a..22f50b39498 100644 --- a/src/test/ui/generic-associated-types/issue-68645-codegen-fulfillment.stderr +++ b/src/test/ui/generic-associated-types/issue-68645-codegen-fulfillment.stderr @@ -11,7 +11,7 @@ error[E0277]: expected a `Fn<()>` closure, found `T` --> $DIR/issue-68645-codegen-fulfillment.rs:15:5 | LL | type F<'a>: Fn() -> u32; - | ------------------------ required by `Fun::F` + | ----------- required by this bound in `Fun::F` ... LL | type F<'a> = Self; | ^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `T` diff --git a/src/test/ui/generic-associated-types/issue-68656-unsized-values.stderr b/src/test/ui/generic-associated-types/issue-68656-unsized-values.stderr index a9336151b6a..c4ee2c4e618 100644 --- a/src/test/ui/generic-associated-types/issue-68656-unsized-values.stderr +++ b/src/test/ui/generic-associated-types/issue-68656-unsized-values.stderr @@ -11,7 +11,7 @@ error[E0271]: type mismatch resolving `::Target == T` --> $DIR/issue-68656-unsized-values.rs:16:5 | LL | type Item<'a>: std::ops::Deref; - | ------------------------------------------- required by `UnsafeCopy::Item` + | ---------- required by this bound in `UnsafeCopy::Item` ... LL | impl UnsafeCopy for T { | - this type parameter diff --git a/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.rs b/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.rs index 7510c58d574..d957cae3081 100644 --- a/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.rs +++ b/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.rs @@ -7,7 +7,7 @@ trait ATy { impl<'b> ATy for &'b () { type Item<'a> = &'b (); - //~^ ERROR does not fulfill the required lifetime + //~^ ERROR lifetime bound not satisfied } trait StaticTy { @@ -16,7 +16,7 @@ trait StaticTy { impl StaticTy for () { type Item<'a> = &'a (); - //~^ ERROR does not fulfill the required lifetime + //~^ ERROR lifetime bound not satisfied } fn main() {} diff --git a/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.stderr b/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.stderr index 5d612284a21..f8b96ef3b8a 100644 --- a/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.stderr +++ b/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.stderr @@ -1,23 +1,33 @@ -error[E0477]: the type `&'b ()` does not fulfill the required lifetime +error[E0478]: lifetime bound not satisfied --> $DIR/unsatisfied-outlives-bound.rs:9:5 | LL | type Item<'a> = &'b (); | ^^^^^^^^^^^^^^^^^^^^^^^ | -note: type must outlive the lifetime `'a` as defined on the associated item at 9:15 +note: lifetime parameter instantiated with the lifetime `'b` as defined on the impl at 8:6 + --> $DIR/unsatisfied-outlives-bound.rs:8:6 + | +LL | impl<'b> ATy for &'b () { + | ^^ +note: but lifetime parameter must outlive the lifetime `'a` as defined on the associated item at 9:15 --> $DIR/unsatisfied-outlives-bound.rs:9:15 | LL | type Item<'a> = &'b (); | ^^ -error[E0477]: the type `&'a ()` does not fulfill the required lifetime +error[E0478]: lifetime bound not satisfied --> $DIR/unsatisfied-outlives-bound.rs:18:5 | LL | type Item<'a> = &'a (); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: type must satisfy the static lifetime +note: lifetime parameter instantiated with the lifetime `'a` as defined on the associated item at 18:15 + --> $DIR/unsatisfied-outlives-bound.rs:18:15 + | +LL | type Item<'a> = &'a (); + | ^^ + = note: but lifetime parameter must outlive the static lifetime error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0477`. +For more information about this error, try `rustc --explain E0478`. diff --git a/src/test/ui/inference/cannot-infer-async-enabled-impl-trait-bindings.stderr b/src/test/ui/inference/cannot-infer-async-enabled-impl-trait-bindings.stderr index b6e3bb190ea..ec03d18924f 100644 --- a/src/test/ui/inference/cannot-infer-async-enabled-impl-trait-bindings.stderr +++ b/src/test/ui/inference/cannot-infer-async-enabled-impl-trait-bindings.stderr @@ -7,13 +7,13 @@ LL | #![feature(impl_trait_in_bindings)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #63065 for more information -error[E0282]: type annotations needed for `impl Future` - --> $DIR/cannot-infer-async-enabled-impl-trait-bindings.rs:13:9 +error[E0282]: type annotations needed for `impl std::future::Future` + --> $DIR/cannot-infer-async-enabled-impl-trait-bindings.rs:13:20 | LL | let fut = async { | --- consider giving `fut` the explicit type `impl Future`, with the type parameters specified LL | make_unit()?; - | ^^^^^^^^^^^^ cannot infer type + | ^ cannot infer type error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/inference/cannot-infer-async.stderr b/src/test/ui/inference/cannot-infer-async.stderr index bf31fb85cf6..92a9045f6db 100644 --- a/src/test/ui/inference/cannot-infer-async.stderr +++ b/src/test/ui/inference/cannot-infer-async.stderr @@ -1,10 +1,10 @@ error[E0282]: type annotations needed - --> $DIR/cannot-infer-async.rs:11:9 + --> $DIR/cannot-infer-async.rs:11:20 | LL | let fut = async { | --- consider giving `fut` a type LL | make_unit()?; - | ^^^^^^^^^^^^ cannot infer type + | ^ cannot infer type error: aborting due to previous error diff --git a/src/test/ui/inference/cannot-infer-closure.stderr b/src/test/ui/inference/cannot-infer-closure.stderr index c26c24f1dc5..d5366e422db 100644 --- a/src/test/ui/inference/cannot-infer-closure.stderr +++ b/src/test/ui/inference/cannot-infer-closure.stderr @@ -1,8 +1,8 @@ error[E0282]: type annotations needed for the closure `fn((), ()) -> std::result::Result<(), _>` - --> $DIR/cannot-infer-closure.rs:3:9 + --> $DIR/cannot-infer-closure.rs:3:15 | LL | Err(a)?; - | ^^^^^^^ cannot infer type + | ^ cannot infer type | help: give this closure an explicit return type without `_` placeholders | diff --git a/src/test/ui/issues/issue-20605.stderr b/src/test/ui/issues/issue-20605.stderr index e8d16a55e92..25fa575fc60 100644 --- a/src/test/ui/issues/issue-20605.stderr +++ b/src/test/ui/issues/issue-20605.stderr @@ -4,8 +4,9 @@ error[E0277]: the size for values of type `dyn Iterator` cann LL | for item in *things { *item = 0 } | ^^^^^^^ doesn't have a size known at compile-time | - = help: the trait `Sized` is not implemented for `dyn Iterator` - = note: required by `into_iter` + = help: the trait `std::marker::Sized` is not implemented for `dyn std::iter::Iterator` + = note: required because of the requirements on the impl of `std::iter::IntoIterator` for `dyn std::iter::Iterator` + = note: required by `std::iter::IntoIterator::into_iter` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20831-debruijn.rs b/src/test/ui/issues/issue-20831-debruijn.rs index d0e15cb393a..20d980763ea 100644 --- a/src/test/ui/issues/issue-20831-debruijn.rs +++ b/src/test/ui/issues/issue-20831-debruijn.rs @@ -28,9 +28,6 @@ impl<'a> Publisher<'a> for MyStruct<'a> { fn subscribe(&mut self, t : Box::Output> + 'a>) { // Not obvious, but there is an implicit lifetime here -------^ //~^^ ERROR cannot infer - //~| ERROR cannot infer - //~| ERROR mismatched types - //~| ERROR mismatched types // // The fact that `Publisher` is using an implicit lifetime is // what was causing the debruijn accounting to be off, so diff --git a/src/test/ui/issues/issue-20831-debruijn.stderr b/src/test/ui/issues/issue-20831-debruijn.stderr index 1ab89e818e3..1764dd3cf67 100644 --- a/src/test/ui/issues/issue-20831-debruijn.stderr +++ b/src/test/ui/issues/issue-20831-debruijn.stderr @@ -1,53 +1,3 @@ -error[E0308]: mismatched types - --> $DIR/issue-20831-debruijn.rs:28:5 - | -LL | / fn subscribe(&mut self, t : Box::Output> + 'a>) { -LL | | // Not obvious, but there is an implicit lifetime here -------^ -LL | | -LL | | -... | -LL | | self.sub = t; -LL | | } - | |_____^ lifetime mismatch - | - = note: expected type `'a` - found type `'_` -note: the anonymous lifetime #2 defined on the method body at 28:5... - --> $DIR/issue-20831-debruijn.rs:28:5 - | -LL | fn subscribe(&mut self, t : Box::Output> + 'a>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...does not necessarily outlive the lifetime `'a` as defined on the impl at 26:6 - --> $DIR/issue-20831-debruijn.rs:26:6 - | -LL | impl<'a> Publisher<'a> for MyStruct<'a> { - | ^^ - -error[E0308]: mismatched types - --> $DIR/issue-20831-debruijn.rs:28:5 - | -LL | / fn subscribe(&mut self, t : Box::Output> + 'a>) { -LL | | // Not obvious, but there is an implicit lifetime here -------^ -LL | | -LL | | -... | -LL | | self.sub = t; -LL | | } - | |_____^ lifetime mismatch - | - = note: expected type `'a` - found type `'_` -note: the lifetime `'a` as defined on the impl at 26:6... - --> $DIR/issue-20831-debruijn.rs:26:6 - | -LL | impl<'a> Publisher<'a> for MyStruct<'a> { - | ^^ -note: ...does not necessarily outlive the anonymous lifetime #2 defined on the method body at 28:5 - --> $DIR/issue-20831-debruijn.rs:28:5 - | -LL | fn subscribe(&mut self, t : Box::Output> + 'a>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements --> $DIR/issue-20831-debruijn.rs:28:33 | @@ -57,8 +7,14 @@ LL | fn subscribe(&mut self, t : Box $DIR/issue-20831-debruijn.rs:28:5 | -LL | fn subscribe(&mut self, t : Box::Output> + 'a>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | / fn subscribe(&mut self, t : Box::Output> + 'a>) { +LL | | // Not obvious, but there is an implicit lifetime here -------^ +LL | | +LL | | // +... | +LL | | self.sub = t; +LL | | } + | |_____^ note: ...but the lifetime must also be valid for the lifetime `'a` as defined on the impl at 26:6... --> $DIR/issue-20831-debruijn.rs:26:6 | @@ -72,31 +28,6 @@ LL | fn subscribe(&mut self, t : Box` found `Publisher<'_>` -error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/issue-20831-debruijn.rs:28:33 - | -LL | fn subscribe(&mut self, t : Box::Output> + 'a>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the method body at 28:5... - --> $DIR/issue-20831-debruijn.rs:28:5 - | -LL | fn subscribe(&mut self, t : Box::Output> + 'a>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...but the lifetime must also be valid for the lifetime `'a` as defined on the impl at 26:6... - --> $DIR/issue-20831-debruijn.rs:26:6 - | -LL | impl<'a> Publisher<'a> for MyStruct<'a> { - | ^^ -note: ...so that the types are compatible - --> $DIR/issue-20831-debruijn.rs:28:33 - | -LL | fn subscribe(&mut self, t : Box::Output> + 'a>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: expected `Publisher<'_>` - found `Publisher<'_>` +error: aborting due to previous error -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0308, E0495. -For more information about an error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/issues/issue-21946.rs b/src/test/ui/issues/issue-21946.rs index 0a9f8f50bdc..d0c052cb2fd 100644 --- a/src/test/ui/issues/issue-21946.rs +++ b/src/test/ui/issues/issue-21946.rs @@ -5,7 +5,6 @@ trait Foo { struct FooStruct; impl Foo for FooStruct { - //~^ ERROR overflow evaluating the requirement `::A == _` type A = ::A; //~^ ERROR overflow evaluating the requirement `::A == _` } diff --git a/src/test/ui/issues/issue-21946.stderr b/src/test/ui/issues/issue-21946.stderr index 582ce393d7f..8b96e0f3382 100644 --- a/src/test/ui/issues/issue-21946.stderr +++ b/src/test/ui/issues/issue-21946.stderr @@ -1,15 +1,9 @@ -error[E0275]: overflow evaluating the requirement `::A == _` - --> $DIR/issue-21946.rs:7:6 - | -LL | impl Foo for FooStruct { - | ^^^ - -error[E0275]: overflow evaluating the requirement `::A == _` - --> $DIR/issue-21946.rs:9:5 +error[E0275]: overflow evaluating the requirement `::A` + --> $DIR/issue-21946.rs:8:5 | LL | type A = ::A; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/issues/issue-23122-1.rs b/src/test/ui/issues/issue-23122-1.rs index d6f64650f36..0937e029ef4 100644 --- a/src/test/ui/issues/issue-23122-1.rs +++ b/src/test/ui/issues/issue-23122-1.rs @@ -5,7 +5,6 @@ trait Next { struct GetNext { t: T } impl Next for GetNext { - //~^ ERROR overflow evaluating the requirement type Next = as Next>::Next; //~^ ERROR overflow evaluating the requirement } diff --git a/src/test/ui/issues/issue-23122-1.stderr b/src/test/ui/issues/issue-23122-1.stderr index 4e2e837c07c..f8374905370 100644 --- a/src/test/ui/issues/issue-23122-1.stderr +++ b/src/test/ui/issues/issue-23122-1.stderr @@ -1,15 +1,9 @@ -error[E0275]: overflow evaluating the requirement ` as Next>::Next == _` - --> $DIR/issue-23122-1.rs:7:15 - | -LL | impl Next for GetNext { - | ^^^^ - -error[E0275]: overflow evaluating the requirement ` as Next>::Next == _` - --> $DIR/issue-23122-1.rs:9:5 +error[E0275]: overflow evaluating the requirement ` as Next>::Next` + --> $DIR/issue-23122-1.rs:8:5 | LL | type Next = as Next>::Next; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/issues/issue-23122-2.rs b/src/test/ui/issues/issue-23122-2.rs index 695712d2cc9..84abebf6b74 100644 --- a/src/test/ui/issues/issue-23122-2.rs +++ b/src/test/ui/issues/issue-23122-2.rs @@ -5,7 +5,6 @@ trait Next { struct GetNext { t: T } impl Next for GetNext { - //~^ ERROR overflow evaluating the requirement type Next = as Next>::Next; //~^ ERROR overflow evaluating the requirement } diff --git a/src/test/ui/issues/issue-23122-2.stderr b/src/test/ui/issues/issue-23122-2.stderr index 60dbb15d0f9..0d645bbcea5 100644 --- a/src/test/ui/issues/issue-23122-2.stderr +++ b/src/test/ui/issues/issue-23122-2.stderr @@ -1,14 +1,5 @@ -error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized` - --> $DIR/issue-23122-2.rs:7:15 - | -LL | impl Next for GetNext { - | ^^^^ - | - = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_23122_2`) - = note: required because of the requirements on the impl of `Next` for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` - -error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized` - --> $DIR/issue-23122-2.rs:9:5 +error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: std::marker::Sized` + --> $DIR/issue-23122-2.rs:8:5 | LL | type Next = as Next>::Next; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,6 +7,6 @@ LL | type Next = as Next>::Next; = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_23122_2`) = note: required because of the requirements on the impl of `Next` for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/issues/issue-24204.rs b/src/test/ui/issues/issue-24204.rs index 61671b32e9b..df72283de23 100644 --- a/src/test/ui/issues/issue-24204.rs +++ b/src/test/ui/issues/issue-24204.rs @@ -12,6 +12,6 @@ trait Trait: Sized { } fn test>(b: i32) -> T where T::A: MultiDispatch { T::new(b) } -//~^ ERROR type mismatch resolving +//~^ ERROR mismatched types fn main() {} diff --git a/src/test/ui/issues/issue-24204.stderr b/src/test/ui/issues/issue-24204.stderr index d5cbcf786bf..9d66c9ff0a8 100644 --- a/src/test/ui/issues/issue-24204.stderr +++ b/src/test/ui/issues/issue-24204.stderr @@ -1,15 +1,10 @@ -error[E0271]: type mismatch resolving `<::A as MultiDispatch>::O == T` - --> $DIR/issue-24204.rs:14:12 +error[E0308]: mismatched types + --> $DIR/issue-24204.rs:14:72 | -LL | trait Trait: Sized { - | ----- required by a bound in this -LL | type A: MultiDispatch; - | -------- required by this bound in `Trait` -... LL | fn test>(b: i32) -> T where T::A: MultiDispatch { T::new(b) } - | - ^^^^^^^^^^^^ expected type parameter `T`, found associated type - | | - | this type parameter + | - - ^^^^^^^^^ expected type parameter `T`, found associated type + | | | + | this type parameter expected `T` because of return type | = note: expected type parameter `T` found associated type `<::A as MultiDispatch>::O` @@ -17,4 +12,4 @@ LL | fn test>(b: i32) -> T where T::A: MultiDispatch { T::n error: aborting due to previous error -For more information about this error, try `rustc --explain E0271`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/issues/issue-28098.stderr b/src/test/ui/issues/issue-28098.stderr index df552fc2d0e..04075911111 100644 --- a/src/test/ui/issues/issue-28098.stderr +++ b/src/test/ui/issues/issue-28098.stderr @@ -13,8 +13,9 @@ error[E0277]: `bool` is not an iterator LL | for _ in false {} | ^^^^^ `bool` is not an iterator | - = help: the trait `Iterator` is not implemented for `bool` - = note: required by `into_iter` + = help: the trait `std::iter::Iterator` is not implemented for `bool` + = note: required because of the requirements on the impl of `std::iter::IntoIterator` for `bool` + = note: required by `std::iter::IntoIterator::into_iter` error[E0277]: `()` is not an iterator --> $DIR/issue-28098.rs:9:28 diff --git a/src/test/ui/issues/issue-33941.stderr b/src/test/ui/issues/issue-33941.stderr index aeab923d2df..81d97bdbf12 100644 --- a/src/test/ui/issues/issue-33941.stderr +++ b/src/test/ui/issues/issue-33941.stderr @@ -15,7 +15,9 @@ LL | for _ in HashMap::new().iter().cloned() {} | = note: expected tuple `(&_, &_)` found reference `&_` - = note: required because of the requirements on the impl of `Iterator` for `Cloned>` + = note: required because of the requirements on the impl of `std::iter::Iterator` for `std::iter::Cloned>` + = note: required because of the requirements on the impl of `std::iter::IntoIterator` for `std::iter::Cloned>` + = note: required by `std::iter::IntoIterator::into_iter` error[E0271]: type mismatch resolving ` as Iterator>::Item == &_` --> $DIR/issue-33941.rs:4:14 diff --git a/src/test/ui/issues/issue-38091.stderr b/src/test/ui/issues/issue-38091.stderr index 81beec80263..f47fd8d1b0d 100644 --- a/src/test/ui/issues/issue-38091.stderr +++ b/src/test/ui/issues/issue-38091.stderr @@ -11,7 +11,7 @@ error[E0277]: the trait bound `(): Valid` is not satisfied --> $DIR/issue-38091.rs:9:5 | LL | type Ty: Valid; - | --------------- required by `Iterate::Ty` + | ----- required by this bound in `Iterate::Ty` ... LL | default type Ty = (); | ^^^^^^^^^^^^^^^^^^^^^ the trait `Valid` is not implemented for `()` diff --git a/src/test/ui/issues/issue-43784-associated-type.stderr b/src/test/ui/issues/issue-43784-associated-type.stderr index 039852ad165..7b656ef8559 100644 --- a/src/test/ui/issues/issue-43784-associated-type.stderr +++ b/src/test/ui/issues/issue-43784-associated-type.stderr @@ -1,8 +1,11 @@ -error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/issue-43784-associated-type.rs:14:18 +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/issue-43784-associated-type.rs:14:5 | +LL | type Assoc: Partial; + | ------------- required by this bound in `Complete::Assoc` +... LL | type Assoc = T; - | ^ the trait `Copy` is not implemented for `T` + | ^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` | help: consider restricting type parameter `T` | diff --git a/src/test/ui/issues/issue-43784-supertrait.stderr b/src/test/ui/issues/issue-43784-supertrait.stderr index d92e4fa9e4a..c73536ba973 100644 --- a/src/test/ui/issues/issue-43784-supertrait.stderr +++ b/src/test/ui/issues/issue-43784-supertrait.stderr @@ -1,6 +1,9 @@ error[E0277]: the trait bound `T: Copy` is not satisfied --> $DIR/issue-43784-supertrait.rs:8:9 | +LL | pub trait Complete: Partial { + | ------- required by this bound in `Complete` +... LL | impl Complete for T {} | ^^^^^^^^ the trait `Copy` is not implemented for `T` | diff --git a/src/test/ui/issues/issue-65673.stderr b/src/test/ui/issues/issue-65673.stderr index aa43ac9414f..64cc0bab3f3 100644 --- a/src/test/ui/issues/issue-65673.stderr +++ b/src/test/ui/issues/issue-65673.stderr @@ -1,13 +1,11 @@ error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time - --> $DIR/issue-65673.rs:9:16 + --> $DIR/issue-65673.rs:9:5 | -LL | trait WithType { - | -------- required by a bound in this LL | type Ctx; - | --------- required by this bound in `WithType` + | --------- required by this bound in `WithType::Ctx` ... LL | type Ctx = dyn Alias; - | ^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Trait + 'static)` diff --git a/src/test/ui/never_type/issue-51506.stderr b/src/test/ui/never_type/issue-51506.stderr index c54cbe9b4d1..16d93c18900 100644 --- a/src/test/ui/never_type/issue-51506.stderr +++ b/src/test/ui/never_type/issue-51506.stderr @@ -2,7 +2,7 @@ error[E0277]: `!` is not an iterator --> $DIR/issue-51506.rs:13:5 | LL | type Out: Iterator; - | ------------------------------- required by `Trait::Out` + | -------------------- required by this bound in `Trait::Out` ... LL | default type Out = !; | ^^^^^^^^^^^^^^^^^^^^^ `!` is not an iterator diff --git a/src/test/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs b/src/test/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs index d3964a7f515..44dcd191d1b 100644 --- a/src/test/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs +++ b/src/test/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs @@ -32,5 +32,4 @@ fn main() { let _x = ::make_f(); //~^ higher-ranked subtype error //~| higher-ranked subtype error - //~| higher-ranked subtype error } diff --git a/src/test/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.stderr b/src/test/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.stderr index 70fb877d716..190b520c678 100644 --- a/src/test/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.stderr +++ b/src/test/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.stderr @@ -10,11 +10,5 @@ error: higher-ranked subtype error LL | let _x = ::make_f(); | ^^^^^^^^^^^^^^^^^^^ -error: higher-ranked subtype error - --> $DIR/impl-fn-ignore-binder-via-bottom.rs:32:14 - | -LL | let _x = ::make_f(); - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff --git a/src/test/ui/privacy/private-in-public-assoc-ty.rs b/src/test/ui/privacy/private-in-public-assoc-ty.rs index 5238894a974..fdf0bc38391 100644 --- a/src/test/ui/privacy/private-in-public-assoc-ty.rs +++ b/src/test/ui/privacy/private-in-public-assoc-ty.rs @@ -29,7 +29,11 @@ mod m { //~| WARN this was previously accepted type Alias1: PrivTr; type Alias2: PubTrAux1 = u8; + //~^ WARN private type `m::Priv` in public interface + //~| WARN this was previously accepted type Alias3: PubTrAux2 = u8; + //~^ WARN private type `m::Priv` in public interface + //~| WARN this was previously accepted type Alias4 = Priv; //~^ ERROR private type `Priv` in public interface diff --git a/src/test/ui/privacy/private-in-public-assoc-ty.stderr b/src/test/ui/privacy/private-in-public-assoc-ty.stderr index acc6e20cf33..768dca17e07 100644 --- a/src/test/ui/privacy/private-in-public-assoc-ty.stderr +++ b/src/test/ui/privacy/private-in-public-assoc-ty.stderr @@ -10,14 +10,8 @@ LL | type A = Priv; warning: private trait `PrivTr` in public interface (error E0445) --> $DIR/private-in-public-assoc-ty.rs:23:5 | -LL | / pub trait PubTr { -LL | | -LL | | -LL | | -... | -LL | | fn infer_exist() -> Self::Exist; -LL | | } - | |_____^ +LL | type Alias1: PrivTr; + | ^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(private_in_public)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! @@ -26,14 +20,8 @@ LL | | } warning: private type `Priv` in public interface (error E0446) --> $DIR/private-in-public-assoc-ty.rs:23:5 | -LL | / pub trait PubTr { -LL | | -LL | | -LL | | -... | -LL | | fn infer_exist() -> Self::Exist; -LL | | } - | |_____^ +LL | type Alias2: PubTrAux1 = u8; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #34537 @@ -41,14 +29,8 @@ LL | | } warning: private type `Priv` in public interface (error E0446) --> $DIR/private-in-public-assoc-ty.rs:23:5 | -LL | / pub trait PubTr { -LL | | -LL | | -LL | | -... | -LL | | fn infer_exist() -> Self::Exist; -LL | | } - | |_____^ +LL | type Alias3: PubTrAux2 = u8; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #34537 diff --git a/src/test/ui/privacy/private-in-public-warn.rs b/src/test/ui/privacy/private-in-public-warn.rs index 3022b470b7d..1c8706d8ad2 100644 --- a/src/test/ui/privacy/private-in-public-warn.rs +++ b/src/test/ui/privacy/private-in-public-warn.rs @@ -55,9 +55,9 @@ mod traits { pub trait Tr2 {} //~ ERROR private trait `traits::PrivTr` in public interface //~^ WARNING hard error pub trait Tr3 { + type Alias: PrivTr; //~^ ERROR private trait `traits::PrivTr` in public interface //~| WARNING hard error - type Alias: PrivTr; fn f(arg: T) {} //~ ERROR private trait `traits::PrivTr` in public interface //~^ WARNING hard error } diff --git a/src/test/ui/privacy/private-in-public-warn.stderr b/src/test/ui/privacy/private-in-public-warn.stderr index 36577a60102..f50dc48f8ad 100644 --- a/src/test/ui/privacy/private-in-public-warn.stderr +++ b/src/test/ui/privacy/private-in-public-warn.stderr @@ -130,16 +130,10 @@ LL | pub trait Tr2 {} = note: for more information, see issue #34537 error: private trait `traits::PrivTr` in public interface (error E0445) - --> $DIR/private-in-public-warn.rs:57:5 + --> $DIR/private-in-public-warn.rs:58:9 | -LL | / pub trait Tr3 { -LL | | -LL | | -LL | | type Alias: PrivTr; -LL | | fn f(arg: T) {} -LL | | -LL | | } - | |_____^ +LL | type Alias: PrivTr; + | ^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #34537 diff --git a/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs b/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs index e485263affc..5476e35b5f6 100644 --- a/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs +++ b/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs @@ -1,5 +1,5 @@ - // aux-crate:priv:priv_dep=priv_dep.rs - // aux-build:pub_dep.rs +// aux-crate:priv:priv_dep=priv_dep.rs +// aux-build:pub_dep.rs #![deny(exported_private_dependencies)] // This crate is a private dependency @@ -7,20 +7,20 @@ extern crate priv_dep; // This crate is a public dependency extern crate pub_dep; -use priv_dep::{OtherType, OtherTrait}; +use priv_dep::{OtherTrait, OtherType}; use pub_dep::PubType; // Type from private dependency used in private // type - this is fine struct PrivateType { - field: OtherType + field: OtherType, } pub struct PublicType { pub field: OtherType, //~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface - priv_field: OtherType, // Private field - this is fine - pub other_field: PubType // Type from public dependency - this is fine + priv_field: OtherType, // Private field - this is fine + pub other_field: PubType, // Type from public dependency - this is fine } impl PublicType { @@ -32,14 +32,13 @@ impl PublicType { pub trait MyPubTrait { type Foo: OtherTrait; + //~^ ERROR trait `priv_dep::OtherTrait` from private dependency 'priv_dep' in public interface } //~^^^ ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface pub struct AllowedPrivType { #[allow(exported_private_dependencies)] - pub allowed: OtherType + pub allowed: OtherType, } - - fn main() {} diff --git a/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr b/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr index 3b5b7823443..e6fd6fc7bb8 100644 --- a/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr +++ b/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr @@ -19,10 +19,8 @@ LL | pub fn pub_fn(param: OtherType) {} error: trait `OtherTrait` from private dependency 'priv_dep' in public interface --> $DIR/pub-priv1.rs:33:1 | -LL | / pub trait MyPubTrait { -LL | | type Foo: OtherTrait; -LL | | } - | |_^ +LL | type Foo: OtherTrait; + | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/question-mark-type-infer.stderr b/src/test/ui/question-mark-type-infer.stderr index f530534ec80..a896d587533 100644 --- a/src/test/ui/question-mark-type-infer.stderr +++ b/src/test/ui/question-mark-type-infer.stderr @@ -1,4 +1,4 @@ -error[E0284]: type annotations needed +error[E0283]: type annotations needed --> $DIR/question-mark-type-infer.rs:12:21 | LL | l.iter().map(f).collect()? @@ -12,4 +12,4 @@ LL | l.iter().map(f).collect::()? error: aborting due to previous error -For more information about this error, try `rustc --explain E0284`. +For more information about this error, try `rustc --explain E0283`. diff --git a/src/test/ui/range/range-1.stderr b/src/test/ui/range/range-1.stderr index a7557320faa..e380e5b2f91 100644 --- a/src/test/ui/range/range-1.stderr +++ b/src/test/ui/range/range-1.stderr @@ -17,7 +17,7 @@ error[E0277]: the size for values of type `[{integer}]` cannot be known at compi | LL | let range = *arr..; | ^^^^^^ doesn't have a size known at compile-time - | + | ::: $SRC_DIR/core/src/ops/range.rs:LL:COL | LL | pub struct RangeFrom { diff --git a/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.rs b/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.rs index 26cb40bb5c2..0f86e37b7e5 100644 --- a/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.rs +++ b/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.rs @@ -12,13 +12,13 @@ impl<'a> Foo<'a> for &'a i16 { } impl<'a> Foo<'static> for &'a i32 { - //~^ ERROR cannot infer type Value = &'a i32; + //~^ ERROR lifetime bound not satisfied } impl<'a,'b> Foo<'b> for &'a i64 { - //~^ ERROR cannot infer type Value = &'a i32; + //~^ ERROR lifetime bound not satisfied } fn main() { } diff --git a/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.stderr b/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.stderr index c134b3b3ed5..feb9c90bc8f 100644 --- a/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.stderr +++ b/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.stderr @@ -1,57 +1,33 @@ -error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:10 +error[E0478]: lifetime bound not satisfied + --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:15:5 | -LL | impl<'a> Foo<'static> for &'a i32 { - | ^^^^^^^^^^^^ +LL | type Value = &'a i32; + | ^^^^^^^^^^^^^^^^^^^^^ | -note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 14:6... +note: lifetime parameter instantiated with the lifetime `'a` as defined on the impl at 14:6 --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:6 | LL | impl<'a> Foo<'static> for &'a i32 { | ^^ -note: ...so that the types are compatible - --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:10 - | -LL | impl<'a> Foo<'static> for &'a i32 { - | ^^^^^^^^^^^^ - = note: expected `Foo<'static>` - found `Foo<'static>` - = note: but, the lifetime must be valid for the static lifetime... -note: ...so that the type `&i32` will meet its required lifetime bounds - --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:10 - | -LL | impl<'a> Foo<'static> for &'a i32 { - | ^^^^^^^^^^^^ + = note: but lifetime parameter must outlive the static lifetime -error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:13 +error[E0478]: lifetime bound not satisfied + --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:20:5 | -LL | impl<'a,'b> Foo<'b> for &'a i64 { - | ^^^^^^^ +LL | type Value = &'a i32; + | ^^^^^^^^^^^^^^^^^^^^^ | -note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 19:6... +note: lifetime parameter instantiated with the lifetime `'a` as defined on the impl at 19:6 --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:6 | LL | impl<'a,'b> Foo<'b> for &'a i64 { | ^^ -note: ...so that the types are compatible - --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:13 - | -LL | impl<'a,'b> Foo<'b> for &'a i64 { - | ^^^^^^^ - = note: expected `Foo<'b>` - found `Foo<'_>` -note: but, the lifetime must be valid for the lifetime `'b` as defined on the impl at 19:9... +note: but lifetime parameter must outlive the lifetime `'b` as defined on the impl at 19:9 --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:9 | LL | impl<'a,'b> Foo<'b> for &'a i64 { | ^^ -note: ...so that the type `&i32` will meet its required lifetime bounds - --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:13 - | -LL | impl<'a,'b> Foo<'b> for &'a i64 { - | ^^^^^^^ error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0495`. +For more information about this error, try `rustc --explain E0478`. diff --git a/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.rs b/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.rs index 599cd0bb756..65b54b45a0a 100644 --- a/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.rs +++ b/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.rs @@ -7,8 +7,8 @@ trait Foo { } impl<'a> Foo for &'a i32 { - //~^ ERROR cannot infer type Value = &'a i32; + //~^ ERROR lifetime bound not satisfied } impl<'a> Foo for i32 { diff --git a/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.stderr b/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.stderr index ac8c55ccc8f..9b98d14a978 100644 --- a/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.stderr +++ b/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.stderr @@ -1,28 +1,16 @@ -error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:10 +error[E0478]: lifetime bound not satisfied + --> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:10:5 | -LL | impl<'a> Foo for &'a i32 { - | ^^^ +LL | type Value = &'a i32; + | ^^^^^^^^^^^^^^^^^^^^^ | -note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 9:6... +note: lifetime parameter instantiated with the lifetime `'a` as defined on the impl at 9:6 --> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:6 | LL | impl<'a> Foo for &'a i32 { | ^^ -note: ...so that the types are compatible - --> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:10 - | -LL | impl<'a> Foo for &'a i32 { - | ^^^ - = note: expected `Foo` - found `Foo` - = note: but, the lifetime must be valid for the static lifetime... -note: ...so that the type `&i32` will meet its required lifetime bounds - --> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:10 - | -LL | impl<'a> Foo for &'a i32 { - | ^^^ + = note: but lifetime parameter must outlive the static lifetime error: aborting due to previous error -For more information about this error, try `rustc --explain E0495`. +For more information about this error, try `rustc --explain E0478`. diff --git a/src/test/ui/specialization/deafult-associated-type-bound-1.stderr b/src/test/ui/specialization/deafult-associated-type-bound-1.stderr index 612e22c204f..4c21f8db8fa 100644 --- a/src/test/ui/specialization/deafult-associated-type-bound-1.stderr +++ b/src/test/ui/specialization/deafult-associated-type-bound-1.stderr @@ -11,7 +11,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied --> $DIR/deafult-associated-type-bound-1.rs:18:5 | LL | type U: Clone; - | -------------- required by `X::U` + | ----- required by this bound in `X::U` ... LL | default type U = str; | ^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str` diff --git a/src/test/ui/specialization/deafult-associated-type-bound-2.stderr b/src/test/ui/specialization/deafult-associated-type-bound-2.stderr index a14024c160f..8c9da81d277 100644 --- a/src/test/ui/specialization/deafult-associated-type-bound-2.stderr +++ b/src/test/ui/specialization/deafult-associated-type-bound-2.stderr @@ -11,7 +11,7 @@ error[E0277]: can't compare `&'static B` with `B` --> $DIR/deafult-associated-type-bound-2.rs:16:5 | LL | type U: PartialEq; - | --------------------- required by `X::U` + | ------------ required by this bound in `X::U` ... LL | default type U = &'static B; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `&'static B == B` diff --git a/src/test/ui/specialization/deafult-generic-associated-type-bound.rs b/src/test/ui/specialization/deafult-generic-associated-type-bound.rs index 8a94ea658d2..f14588e6e02 100644 --- a/src/test/ui/specialization/deafult-generic-associated-type-bound.rs +++ b/src/test/ui/specialization/deafult-generic-associated-type-bound.rs @@ -6,7 +6,7 @@ //~^^ WARNING the feature `generic_associated_types` is incomplete trait X { - type U<'a>: PartialEq<&'a Self>; + type U<'a>: PartialEq<&'a Self> where Self: 'a; fn unsafe_compare<'b>(x: Option>, y: Option<&'b Self>) { match (x, y) { (Some(a), Some(b)) => a == b, diff --git a/src/test/ui/specialization/deafult-generic-associated-type-bound.stderr b/src/test/ui/specialization/deafult-generic-associated-type-bound.stderr index 556feda642b..f145b90f216 100644 --- a/src/test/ui/specialization/deafult-generic-associated-type-bound.stderr +++ b/src/test/ui/specialization/deafult-generic-associated-type-bound.stderr @@ -18,8 +18,8 @@ LL | #![feature(generic_associated_types)] error[E0277]: can't compare `T` with `T` --> $DIR/deafult-generic-associated-type-bound.rs:19:5 | -LL | type U<'a>: PartialEq<&'a Self>; - | -------------------------------- required by `X::U` +LL | type U<'a>: PartialEq<&'a Self> where Self: 'a; + | ------------------- required by this bound in `X::U` ... LL | default type U<'a> = &'a T; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `T == T` diff --git a/src/test/ui/specialization/issue-44861.stderr b/src/test/ui/specialization/issue-44861.stderr index be7196a63ce..3935a4a5f99 100644 --- a/src/test/ui/specialization/issue-44861.stderr +++ b/src/test/ui/specialization/issue-44861.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `(): CoerceUnsized<*const [u8]>` is not satisfied --> $DIR/issue-44861.rs:21:5 | LL | type Data2: CoerceUnsized<*const [u8]>; - | --------------------------------------- required by `Smartass::Data2` + | -------------------------- required by this bound in `Smartass::Data2` ... LL | default type Data2 = (); | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `CoerceUnsized<*const [u8]>` is not implemented for `()` diff --git a/src/test/ui/specialization/issue-59435.stderr b/src/test/ui/specialization/issue-59435.stderr index ee5c0615927..f3f8b022b01 100644 --- a/src/test/ui/specialization/issue-59435.stderr +++ b/src/test/ui/specialization/issue-59435.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `MyStruct: Default` is not satisfied --> $DIR/issue-59435.rs:11:5 | LL | type MyType: Default; - | --------------------- required by `MyTrait::MyType` + | ------- required by this bound in `MyTrait::MyType` ... LL | default type MyType = MyStruct; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `MyStruct` diff --git a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.rs b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.rs index 394512c5794..8218fecc3f1 100644 --- a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.rs +++ b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.rs @@ -15,11 +15,9 @@ impl Child for ChildWrapper where T: Child {} struct ParentWrapper(T); impl> Parent for ParentWrapper { - //~^ ERROR the trait bound `::Assoc: Child` is not satisfied type Ty = A; type Assoc = ChildWrapper; //~^ ERROR the trait bound `::Assoc: Child` is not satisfied - //~| ERROR the trait bound `::Assoc: Child` is not satisfied } fn main() {} diff --git a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr index a8ea2147961..676e2fb1a51 100644 --- a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr +++ b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr @@ -1,31 +1,11 @@ error[E0277]: the trait bound `::Assoc: Child` is not satisfied - --> $DIR/missing-assoc-type-bound-restriction.rs:17:19 + --> $DIR/missing-assoc-type-bound-restriction.rs:19:5 | -LL | trait Parent { - | ------ required by a bound in this -LL | type Ty; LL | type Assoc: Child; - | --------------- required by this bound in `Parent` -... -LL | impl> Parent for ParentWrapper { - | ^^^^^^ the trait `Child` is not implemented for `::Assoc` - | -help: consider further restricting the associated type - | -LL | impl> Parent for ParentWrapper where ::Assoc: Child { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: the trait bound `::Assoc: Child` is not satisfied - --> $DIR/missing-assoc-type-bound-restriction.rs:20:18 - | -LL | trait Parent { - | ------ required by a bound in this -LL | type Ty; -LL | type Assoc: Child; - | --------------- required by this bound in `Parent` + | --------------- required by this bound in `Parent::Assoc` ... LL | type Assoc = ChildWrapper; - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Child` is not implemented for `::Assoc` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Child` is not implemented for `::Assoc` | = note: required because of the requirements on the impl of `Child` for `ChildWrapper<::Assoc>` help: consider further restricting the associated type @@ -33,23 +13,6 @@ help: consider further restricting the associated type LL | impl> Parent for ParentWrapper where ::Assoc: Child { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `::Assoc: Child` is not satisfied - --> $DIR/missing-assoc-type-bound-restriction.rs:20:5 - | -LL | trait Parent { - | ------ required by a bound in this -LL | type Ty; -LL | type Assoc: Child; - | --------------- required by this bound in `Parent` -... -LL | type Assoc = ChildWrapper; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Child` is not implemented for `::Assoc` - | -help: consider further restricting the associated type - | -LL | impl> Parent for ParentWrapper where ::Assoc: Child { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/traits/cycle-cache-err-60010.rs b/src/test/ui/traits/cycle-cache-err-60010.rs index cbddef082be..62d558fde88 100644 --- a/src/test/ui/traits/cycle-cache-err-60010.rs +++ b/src/test/ui/traits/cycle-cache-err-60010.rs @@ -28,7 +28,9 @@ struct SalsaStorage { } impl Database for RootDatabase { - type Storage = SalsaStorage; //~ ERROR overflow + // This would also be an error if we didn't abort compilation on the error + // above. + type Storage = SalsaStorage; } impl HasQueryGroup for RootDatabase {} impl Query for ParseQuery diff --git a/src/test/ui/traits/traits-inductive-overflow-two-traits.rs b/src/test/ui/traits/traits-inductive-overflow-two-traits.rs index 63dd1419200..463b55d8581 100644 --- a/src/test/ui/traits/traits-inductive-overflow-two-traits.rs +++ b/src/test/ui/traits/traits-inductive-overflow-two-traits.rs @@ -9,6 +9,7 @@ pub trait Magic { } impl Magic for T { type X = Self; + //~^ ERROR E0277 } fn check() {} diff --git a/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr b/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr index f66cfce55c9..dbe0146cafa 100644 --- a/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr +++ b/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr @@ -1,5 +1,19 @@ +error[E0277]: `T` cannot be shared between threads safely + --> $DIR/traits-inductive-overflow-two-traits.rs:11:5 + | +LL | type X: Trait; + | ----- required by this bound in `Magic::X` +... +LL | type X = Self; + | ^^^^^^^^^^^^^^ `T` cannot be shared between threads safely + | +help: consider further restricting this bound + | +LL | impl Magic for T { + | ^^^^^^^^^^^^^^^^^^^ + error[E0275]: overflow evaluating the requirement `*mut (): Magic` - --> $DIR/traits-inductive-overflow-two-traits.rs:19:5 + --> $DIR/traits-inductive-overflow-two-traits.rs:20:5 | LL | fn wizard() { check::<::X>(); } | ----- required by this bound in `wizard` @@ -7,6 +21,7 @@ LL | fn wizard() { check::<::X>(); } LL | wizard::<*mut ()>(); | ^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0275`. +Some errors have detailed explanations: E0275, E0277. +For more information about an error, try `rustc --explain E0275`. diff --git a/src/test/ui/try-block/try-block-bad-type.stderr b/src/test/ui/try-block/try-block-bad-type.stderr index 03d5d3661dd..dfc1c342a50 100644 --- a/src/test/ui/try-block/try-block-bad-type.stderr +++ b/src/test/ui/try-block/try-block-bad-type.stderr @@ -41,7 +41,7 @@ LL | let res: i32 = try { 5 }; | = note: required by `from_ok` -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors Some errors have detailed explanations: E0271, E0277. For more information about an error, try `rustc --explain E0271`.