From d08ab945de8ede93366c6ffc12ed58068a73b4a0 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Fri, 14 Aug 2020 21:41:20 +0100 Subject: [PATCH] Fix rebase --- .../src/traits/fulfill.rs | 4 +- .../rustc_trait_selection/src/traits/mod.rs | 1 - .../src/traits/select/mod.rs | 2 +- .../rustc_trait_selection/src/traits/util.rs | 67 +------------------ .../rustc_trait_selection/src/traits/wf.rs | 2 +- compiler/rustc_traits/src/chalk/lowering.rs | 26 +++---- .../rustc_typeck/src/check/compare_method.rs | 23 +++---- compiler/rustc_typeck/src/collect.rs | 16 ++--- .../rustc_typeck/src/collect/item_bounds.rs | 10 ++- .../bounds-on-assoc-in-trait.stderr | 4 +- .../associated-types/defaults-suitability.rs | 3 +- .../defaults-suitability.stderr | 26 ++----- .../ui/associated-types/defaults-wf.stderr | 2 +- ...feature-gate-associated_type_bounds.stderr | 2 +- .../feature-gate-generic_associated_types.rs | 1 + ...ature-gate-generic_associated_types.stderr | 20 ++++-- src/test/ui/generator/sized-yield.stderr | 2 +- .../generic-associated-types-where.rs | 3 +- .../generic-associated-types-where.stderr | 19 +++++- .../generic-associated-types/impl_bounds.rs | 1 + .../impl_bounds.stderr | 2 +- .../impl_bounds_ok.rs | 5 +- .../unsatisfied-outlives-bound.rs | 4 +- .../unsatisfied-outlives-bound.stderr | 20 ++---- src/test/ui/issues/issue-60283.stderr | 2 +- ...ssoc-type-region-bound-in-trait-not-met.rs | 10 +-- ...-type-region-bound-in-trait-not-met.stderr | 26 +++---- ...ssoc-type-static-bound-in-trait-not-met.rs | 6 +- ...-type-static-bound-in-trait-not-met.stderr | 11 +-- 29 files changed, 120 insertions(+), 200 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index 289e0e0ba63..27751eb554d 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -376,7 +376,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> { | ty::PredicateAtom::Subtype(_) | ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateAtom::ConstEquate(..) => { - let (pred, _) = infcx.replace_bound_vars_with_placeholders(binder); + let pred = infcx.replace_bound_vars_with_placeholders(binder); ProcessResult::Changed(mk_pending(vec![ obligation.with(pred.to_predicate(self.selcx.tcx())), ])) @@ -673,7 +673,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> { Ok(Ok(None)) => { *stalled_on = trait_ref_infer_vars( self.selcx, - project_obligation.predicate.to_poly_trait_ref(self.selcx.tcx()), + project_obligation.predicate.to_poly_trait_ref(tcx), ); ProcessResult::Unchanged } diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index d819740b596..c93087a18cf 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -59,7 +59,6 @@ pub use self::specialize::specialization_graph::FutureCompatOverlapErrorKind; pub use self::specialize::{specialization_graph, translate_substs, OverlapError}; pub use self::structural_match::search_for_structural_match_violation; pub use self::structural_match::NonStructuralMatchTy; -pub use self::util::subst_assoc_item_bound; pub use self::util::{elaborate_predicates, elaborate_trait_ref, elaborate_trait_refs}; pub use self::util::{expand_trait_aliases, TraitAliasExpander}; pub use self::util::{ diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index d0c0e658c92..6527d8277f8 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -38,7 +38,7 @@ use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::relate::TypeRelation; use rustc_middle::ty::subst::{GenericArgKind, Subst, SubstsRef}; use rustc_middle::ty::{self, PolyProjectionPredicate, ToPolyTraitRef, ToPredicate}; -use rustc_middle::ty::{Ty, TyCtxt, TypeFoldable}; +use rustc_middle::ty::{Ty, TyCtxt, TypeFoldable, WithConstness}; use rustc_span::symbol::sym; use std::cell::{Cell, RefCell}; diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs index 0a4ce34c7f8..f626bb0b7e3 100644 --- a/compiler/rustc_trait_selection/src/traits/util.rs +++ b/compiler/rustc_trait_selection/src/traits/util.rs @@ -6,13 +6,11 @@ use smallvec::SmallVec; use rustc_data_structures::fx::FxHashSet; use rustc_hir::def_id::DefId; use rustc_middle::ty::subst::{GenericArg, Subst, SubstsRef}; -use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness}; +use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, WithConstness}; use super::{Normalized, Obligation, ObligationCause, PredicateObligation, SelectionContext}; pub use rustc_infer::traits::util::*; -use std::iter; - /////////////////////////////////////////////////////////////////////////// // `TraitAliasExpander` iterator /////////////////////////////////////////////////////////////////////////// @@ -359,69 +357,6 @@ pub fn impl_item_is_final(tcx: TyCtxt<'_>, assoc_item: &ty::AssocItem) -> bool { assoc_item.defaultness.is_final() && tcx.impl_defaultness(assoc_item.container.id()).is_final() } -/// Map a bound from an associated item to apply to some other type. -/// For example, given the following trait -/// -/// trait X { type Y<'a>: PartialEq } -/// -/// Say that we know that `<() as X>::Y<'c> = i32` and we need to check that -/// the `PartialEq` bound applies. We would then call this function with: -/// -/// - `bound` = `>::Y<'a>: PartialEq` -/// - `normalized_projection_ty` = `i32` -/// - `assoc_item_substs` = `[(), B, 'c]` -/// -/// This method would then return `i32: PartialEq`. -pub fn subst_assoc_item_bound<'tcx>( - tcx: TyCtxt<'tcx>, - bound: ty::Predicate<'tcx>, - normalized_projection_ty: Ty<'tcx>, - assoc_item_substs: &[GenericArg<'tcx>], -) -> ty::Predicate<'tcx> { - // We're substituting these inside the closure passed to map_bound, so they - // can't have escaping bound regions. - assert!(!normalized_projection_ty.has_escaping_bound_vars()); - assert!(!assoc_item_substs.iter().all(|arg| arg.has_escaping_bound_vars())); - - let translate_predicate_substs = move |predicate_substs: SubstsRef<'tcx>| { - tcx.mk_substs( - iter::once(normalized_projection_ty.into()) - .chain(predicate_substs[1..].iter().map(|s| s.subst(tcx, assoc_item_substs))), - ) - }; - - match bound.kind() { - ty::PredicateKind::Trait(poly_tr, c) => poly_tr - .map_bound(|tr| { - let trait_substs = translate_predicate_substs(tr.trait_ref.substs); - ty::TraitRef { def_id: tr.def_id(), substs: trait_substs } - }) - .with_constness(*c) - .to_predicate(tcx), - ty::PredicateKind::Projection(poly_projection) => poly_projection - .map_bound(|projection| { - let projection_substs = translate_predicate_substs(projection.projection_ty.substs); - ty::ProjectionPredicate { - projection_ty: ty::ProjectionTy { - substs: projection_substs, - item_def_id: projection.projection_ty.item_def_id, - }, - ty: projection.ty.subst(tcx, assoc_item_substs), - } - }) - .to_predicate(tcx), - ty::PredicateKind::TypeOutlives(poly_outlives) => poly_outlives - .map_bound(|outlives| { - ty::OutlivesPredicate( - normalized_projection_ty, - outlives.1.subst(tcx, assoc_item_substs), - ) - }) - .to_predicate(tcx), - _ => bug!("unexepected projection bound: `{:?}`", bound), - } -} - pub enum TupleArgumentsFlag { Yes, No, diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 0b4edf5e71b..d66bfd48206 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -391,7 +391,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { cause.clone(), depth, param_env, - ty::PredicateKind::WellFormed(arg).to_predicate(tcx), + ty::PredicateAtom::WellFormed(arg).to_predicate(tcx), ) }), ); diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index 0602f5ea4dc..a59c81aa9b8 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -738,10 +738,10 @@ impl<'tcx> LowerInto<'tcx, Option, ) -> Option>> { - match &self.kind() { - ty::PredicateKind::Trait(predicate, _) => { + match self.bound_atom(interner.tcx).skip_binder() { + ty::PredicateAtom::Trait(predicate, _) => { let (predicate, binders, _named_regions) = - collect_bound_vars(interner, interner.tcx, predicate); + collect_bound_vars(interner, interner.tcx, &ty::Binder::bind(predicate)); Some(chalk_ir::Binders::new( binders, @@ -750,24 +750,24 @@ impl<'tcx> LowerInto<'tcx, Option { + ty::PredicateAtom::Projection(predicate) => { let (predicate, binders, _named_regions) = - collect_bound_vars(interner, interner.tcx, predicate); + collect_bound_vars(interner, interner.tcx, &ty::Binder::bind(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::PredicateAtom::TypeOutlives(_predicate) => None, + ty::PredicateAtom::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), + ty::PredicateAtom::RegionOutlives(..) + | ty::PredicateAtom::ObjectSafe(..) + | ty::PredicateAtom::ClosureKind(..) + | ty::PredicateAtom::Subtype(..) + | ty::PredicateAtom::ConstEvaluatable(..) + | ty::PredicateAtom::ConstEquate(..) => bug!("unexpected predicate {}", &self), } } } diff --git a/compiler/rustc_typeck/src/check/compare_method.rs b/compiler/rustc_typeck/src/check/compare_method.rs index 788590e50f3..817b4070754 100644 --- a/compiler/rustc_typeck/src/check/compare_method.rs +++ b/compiler/rustc_typeck/src/check/compare_method.rs @@ -1225,18 +1225,19 @@ pub fn check_type_bounds<'tcx>( let impl_ty_hir_id = tcx.hir().local_def_id_to_hir_id(impl_ty.def_id.expect_local()); let normalize_cause = traits::ObligationCause::misc(impl_ty_span, impl_ty_hir_id); - let cause = ObligationCause::new( - impl_ty_span, - impl_ty_hir_id, - ObligationCauseCode::ItemObligation(trait_ty.def_id), - ); + let mk_cause = |span| { + ObligationCause::new( + impl_ty_span, + impl_ty_hir_id, + ObligationCauseCode::BindingObligation(trait_ty.def_id, span), + ) + }; 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); + let concrete_ty_bound = bound.subst(tcx, rebased_substs); debug!("check_type_bounds: concrete_ty_bound = {:?}", concrete_ty_bound); traits::Obligation::new(mk_cause(span), param_env, concrete_ty_bound) @@ -1244,17 +1245,15 @@ pub fn check_type_bounds<'tcx>( .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); - + for mut obligation in util::elaborate_obligations(tcx, obligations) { let traits::Normalized { value: normalized_predicate, obligations } = traits::normalize( &mut selcx, normalize_param_env, normalize_cause.clone(), - &concrete_ty_predicate, + &obligation.predicate, ); debug!("compare_projection_bounds: normalized predicate = {:?}", normalized_predicate); + obligation.predicate = normalized_predicate; inh.register_predicates(obligations); inh.register_predicate(obligation); diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index 7e125481671..ad306fc1a0b 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -2137,8 +2137,8 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat // associated type: // * It must use the identity substs of the item. // * Since any generic parameters on the item are not in scope, - // this means that the item is not a GAT, and its identity substs - // are the same as the trait's. + // this means that the item is not a GAT, and its identity + // substs are the same as the trait's. // * It must be an associated type for this trait (*not* a // supertrait). if let ty::Projection(projection) = ty.kind { @@ -2158,14 +2158,12 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat .predicates .iter() .copied() - .filter(|(pred, _)| match pred.kind() { - ty::PredicateKind::Trait(tr, _) => !is_assoc_item_ty(tr.skip_binder().self_ty()), - ty::PredicateKind::Projection(proj) => { - !is_assoc_item_ty(proj.skip_binder().projection_ty.self_ty()) - } - ty::PredicateKind::TypeOutlives(outlives) => { - !is_assoc_item_ty(outlives.skip_binder().0) + .filter(|(pred, _)| match pred.skip_binders() { + ty::PredicateAtom::Trait(tr, _) => !is_assoc_item_ty(tr.self_ty()), + ty::PredicateAtom::Projection(proj) => { + !is_assoc_item_ty(proj.projection_ty.self_ty()) } + ty::PredicateAtom::TypeOutlives(outlives) => !is_assoc_item_ty(outlives.0), _ => true, }) .collect(); diff --git a/compiler/rustc_typeck/src/collect/item_bounds.rs b/compiler/rustc_typeck/src/collect/item_bounds.rs index c9af86f70fd..9c29ceeb593 100644 --- a/compiler/rustc_typeck/src/collect/item_bounds.rs +++ b/compiler/rustc_typeck/src/collect/item_bounds.rs @@ -37,12 +37,10 @@ fn associated_type_bounds<'tcx>( let trait_predicates = tcx.trait_explicit_predicates_and_bounds(trait_def_id.expect_local()); let bounds_from_parent = - trait_predicates.predicates.iter().copied().filter(|(pred, _)| match pred.kind() { - ty::PredicateKind::Trait(tr, _) => tr.skip_binder().self_ty() == item_ty, - ty::PredicateKind::Projection(proj) => { - proj.skip_binder().projection_ty.self_ty() == item_ty - } - ty::PredicateKind::TypeOutlives(outlives) => outlives.skip_binder().0 == item_ty, + trait_predicates.predicates.iter().copied().filter(|(pred, _)| match pred.skip_binders() { + ty::PredicateAtom::Trait(tr, _) => tr.self_ty() == item_ty, + ty::PredicateAtom::Projection(proj) => proj.projection_ty.self_ty() == item_ty, + ty::PredicateAtom::TypeOutlives(outlives) => outlives.0 == item_ty, _ => false, }); 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 index 2be37285e29..cc0b58188e6 100644 --- 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 @@ -4,7 +4,7 @@ error[E0277]: `<::A as std::iter::Iterator>::Item` doesn't implem 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 + ::: $SRC_DIR/core/src/fmt/mod.rs:LL:COL | LL | pub trait Debug { | --------------- required by this bound in `std::fmt::Debug` @@ -21,7 +21,7 @@ error[E0277]: the trait bound `<::Out as Baz>::Assoc: std::default: 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 + ::: $SRC_DIR/core/src/default.rs:LL:COL | LL | pub trait Default: Sized { | ------------------------ required by this bound in `std::default::Default` diff --git a/src/test/ui/associated-types/defaults-suitability.rs b/src/test/ui/associated-types/defaults-suitability.rs index 69be300b16f..44cc7738d7e 100644 --- a/src/test/ui/associated-types/defaults-suitability.rs +++ b/src/test/ui/associated-types/defaults-suitability.rs @@ -45,7 +45,6 @@ trait C where 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 @@ -55,7 +54,7 @@ trait D where bool: IsU8, { type Assoc = NotClone; - //~^ ERROR the trait bound `NotClone: IsU8<::Assoc>` is not satisfied + //~^ ERROR the trait bound `NotClone: IsU8` is not satisfied } // Test behavior of the check when defaults refer to other defaults: diff --git a/src/test/ui/associated-types/defaults-suitability.stderr b/src/test/ui/associated-types/defaults-suitability.stderr index 4d8e6f1584d..5ee800e1913 100644 --- a/src/test/ui/associated-types/defaults-suitability.stderr +++ b/src/test/ui/associated-types/defaults-suitability.stderr @@ -42,20 +42,8 @@ LL | type Assoc: Foo = (); | | required by this bound in `Bar::Assoc` | the trait `Foo` is not implemented for `()` -error[E0277]: the trait bound `u8: IsU8<::Assoc>` is not satisfied - --> $DIR/defaults-suitability.rs:44:5 - | -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 `NotClone: IsU8<::Assoc>` is not satisfied - --> $DIR/defaults-suitability.rs:54:5 +error[E0277]: the trait bound `NotClone: IsU8` is not satisfied + --> $DIR/defaults-suitability.rs:53:5 | LL | Self::Assoc: IsU8, | ----------------- required by this bound in `D::Assoc` @@ -64,10 +52,10 @@ LL | type Assoc = NotClone; | ^^^^^-----^^^^^^^^^^^^ | | | | | required by a bound in this - | the trait `IsU8<::Assoc>` is not implemented for `NotClone` + | the trait `IsU8` is not implemented for `NotClone` error[E0277]: the trait bound `>::Baz: std::clone::Clone` is not satisfied - --> $DIR/defaults-suitability.rs:63:5 + --> $DIR/defaults-suitability.rs:62:5 | LL | type Bar: Clone = Vec; | ^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^ @@ -82,7 +70,7 @@ LL | trait Foo2 where >::Baz: Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `>::Baz: std::clone::Clone` is not satisfied - --> $DIR/defaults-suitability.rs:72:5 + --> $DIR/defaults-suitability.rs:71:5 | LL | type Bar: Clone = Vec; | ^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^ @@ -97,7 +85,7 @@ LL | trait Foo25 where >::Baz: Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `T: std::clone::Clone` is not satisfied - --> $DIR/defaults-suitability.rs:84:5 + --> $DIR/defaults-suitability.rs:83:5 | LL | Self::Baz: Clone, | ----- required by this bound in `Foo3::Baz` @@ -113,6 +101,6 @@ help: consider further restricting type parameter `T` LL | Self::Baz: Clone, T: Clone | ^^^^^^^^^^ -error: aborting due to 9 previous errors +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/defaults-wf.stderr b/src/test/ui/associated-types/defaults-wf.stderr index aeb7b6cae19..d1832cdbc0c 100644 --- a/src/test/ui/associated-types/defaults-wf.stderr +++ b/src/test/ui/associated-types/defaults-wf.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation LL | type Ty = Vec<[u8]>; | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - ::: $SRC_DIR/liballoc/vec.rs:LL:COL + ::: $SRC_DIR/alloc/src/vec.rs:LL:COL | LL | pub struct Vec { | - required by this bound in `std::vec::Vec` 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 03011bd1e32..987b6787581 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 @@ -145,7 +145,7 @@ error[E0277]: the trait bound `<::A as std::iter::Iterator>::Item: 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 + ::: $SRC_DIR/core/src/marker.rs:LL:COL | LL | pub trait Copy: Clone { | --------------------- required by this bound in `std::marker::Copy` diff --git a/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs b/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs index 17548d7b9e8..34823cbafd3 100644 --- a/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs +++ b/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs @@ -15,6 +15,7 @@ impl PointerFamily for Foo { //~^ ERROR generic associated types are unstable type Pointer2 = Box; //~^ ERROR generic associated types are unstable + //~| ERROR the trait bound `U32: std::clone::Clone` is not satisfied } trait Bar { diff --git a/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr b/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr index 8499b1ab70f..e04a129dbbb 100644 --- a/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr +++ b/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr @@ -44,7 +44,7 @@ LL | type Pointer2 = Box; = help: add `#![feature(generic_associated_types)]` to the crate attributes to enable error[E0658]: where clauses on associated types are unstable - --> $DIR/feature-gate-generic_associated_types.rs:21:5 + --> $DIR/feature-gate-generic_associated_types.rs:22:5 | LL | type Assoc where Self: Sized; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -53,7 +53,7 @@ LL | type Assoc where Self: Sized; = help: add `#![feature(generic_associated_types)]` to the crate attributes to enable error[E0658]: where clauses on associated types are unstable - --> $DIR/feature-gate-generic_associated_types.rs:26:5 + --> $DIR/feature-gate-generic_associated_types.rs:27:5 | LL | type Assoc where Self: Sized = Foo; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,6 +61,18 @@ LL | type Assoc where Self: Sized = Foo; = note: see issue #44265 for more information = help: add `#![feature(generic_associated_types)]` to the crate attributes to enable -error: aborting due to 7 previous errors +error[E0277]: the trait bound `U32: std::clone::Clone` is not satisfied + --> $DIR/feature-gate-generic_associated_types.rs:16:5 + | +LL | type Pointer2 = Box; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `U32` + | +help: consider restricting type parameter `U32` + | +LL | type Pointer2 = Box; + | ^^^^^^^^^^^^^^^^^^^ -For more information about this error, try `rustc --explain E0658`. +error: aborting due to 8 previous errors + +Some errors have detailed explanations: E0277, 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 e49dc91ec66..19658528a0b 100644 --- a/src/test/ui/generator/sized-yield.stderr +++ b/src/test/ui/generator/sized-yield.stderr @@ -17,7 +17,7 @@ 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 + ::: $SRC_DIR/core/src/ops/generator.rs:LL:COL | LL | pub enum GeneratorState { | - required by this bound in `std::ops::GeneratorState` diff --git a/src/test/ui/generic-associated-types/generic-associated-types-where.rs b/src/test/ui/generic-associated-types/generic-associated-types-where.rs index 1a94796535c..27970b15a41 100644 --- a/src/test/ui/generic-associated-types/generic-associated-types-where.rs +++ b/src/test/ui/generic-associated-types/generic-associated-types-where.rs @@ -19,8 +19,9 @@ struct Bar; impl Foo for Bar { type Assoc = usize; type Assoc2 = Vec; + //~^ ERROR `T` doesn't implement `std::fmt::Display` type Assoc3 where T: Iterator = Vec; - //~^ impl has stricter requirements than trait + //~^ ERROR impl has stricter requirements than trait type WithDefault<'a, T: Debug + 'a> = &'a dyn Iterator; type NoGenerics = ::std::cell::Cell; } diff --git a/src/test/ui/generic-associated-types/generic-associated-types-where.stderr b/src/test/ui/generic-associated-types/generic-associated-types-where.stderr index c95765d906c..da8b625ea7f 100644 --- a/src/test/ui/generic-associated-types/generic-associated-types-where.stderr +++ b/src/test/ui/generic-associated-types/generic-associated-types-where.stderr @@ -1,5 +1,17 @@ +error[E0277]: `T` doesn't implement `std::fmt::Display` + --> $DIR/generic-associated-types-where.rs:21:5 + | +LL | type Assoc2 = Vec; + | ^^^^^^^^^^^^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter + | + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead +help: consider restricting type parameter `T` + | +LL | type Assoc2 = Vec; + | ^^^^^^^^^^^^^^^^^^^ + error[E0276]: impl has stricter requirements than trait - --> $DIR/generic-associated-types-where.rs:22:5 + --> $DIR/generic-associated-types-where.rs:23:5 | LL | type Assoc3; | --------------- definition of `Assoc3` from trait @@ -7,6 +19,7 @@ LL | type Assoc3; LL | type Assoc3 where T: Iterator = Vec; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: Iterator` -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0276`. +Some errors have detailed explanations: E0276, E0277. +For more information about an error, try `rustc --explain E0276`. diff --git a/src/test/ui/generic-associated-types/impl_bounds.rs b/src/test/ui/generic-associated-types/impl_bounds.rs index 77bebc9854a..089a214667e 100644 --- a/src/test/ui/generic-associated-types/impl_bounds.rs +++ b/src/test/ui/generic-associated-types/impl_bounds.rs @@ -16,6 +16,7 @@ impl Foo for Fooy { //~^ ERROR the parameter type `T` may not live long enough type B<'a, 'b> where 'b: 'a = (&'a(), &'b ()); //~^ ERROR lifetime bound not satisfied + //~| ERROR lifetime bound not satisfied type C where Self: Copy = String; //~^ ERROR the trait bound `T: Copy` is not satisfied } diff --git a/src/test/ui/generic-associated-types/impl_bounds.stderr b/src/test/ui/generic-associated-types/impl_bounds.stderr index 0546e38a33d..e6f27a45a3c 100644 --- a/src/test/ui/generic-associated-types/impl_bounds.stderr +++ b/src/test/ui/generic-associated-types/impl_bounds.stderr @@ -37,7 +37,7 @@ help: consider restricting type parameter `T` LL | impl Foo for Fooy { | ^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0277, E0310, E0478. For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/generic-associated-types/impl_bounds_ok.rs b/src/test/ui/generic-associated-types/impl_bounds_ok.rs index 2387b891755..98aa82aba83 100644 --- a/src/test/ui/generic-associated-types/impl_bounds_ok.rs +++ b/src/test/ui/generic-associated-types/impl_bounds_ok.rs @@ -10,11 +10,12 @@ trait Foo { type C where Self: Clone; } +#[derive(Clone)] struct Fooy; impl Foo for Fooy { type A<'a> = (&'a ()); - type B<'a, 'b> = (&'a(), &'b ()); + type B<'a: 'b, 'b> = (&'a(), &'b ()); type C = String; } @@ -24,7 +25,7 @@ struct Fooer(T); impl Foo for Fooer { type A<'x> where T: 'x = (&'x ()); type B<'u, 'v> where 'u: 'v = (&'v &'u ()); - type C where Self: ToOwned = String; + type C where Self: Clone + ToOwned = String; } fn main() {} 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 d957cae3081..99d5bcf2bac 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 lifetime bound not satisfied + //~^ ERROR the type `&'b ()` does not fulfill the required lifetime } trait StaticTy { @@ -16,7 +16,7 @@ trait StaticTy { impl StaticTy for () { type Item<'a> = &'a (); - //~^ ERROR lifetime bound not satisfied + //~^ ERROR the type `&'a ()` does not fulfill the required lifetime } 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 f8b96ef3b8a..5d612284a21 100644 --- a/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.stderr +++ b/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.stderr @@ -1,33 +1,23 @@ -error[E0478]: lifetime bound not satisfied +error[E0477]: the type `&'b ()` does not fulfill the required lifetime --> $DIR/unsatisfied-outlives-bound.rs:9:5 | LL | type Item<'a> = &'b (); | ^^^^^^^^^^^^^^^^^^^^^^^ | -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 +note: type 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[E0478]: lifetime bound not satisfied +error[E0477]: the type `&'a ()` does not fulfill the required lifetime --> $DIR/unsatisfied-outlives-bound.rs:18:5 | LL | type Item<'a> = &'a (); | ^^^^^^^^^^^^^^^^^^^^^^^ | -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 + = note: type must satisfy the static lifetime error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0478`. +For more information about this error, try `rustc --explain E0477`. diff --git a/src/test/ui/issues/issue-60283.stderr b/src/test/ui/issues/issue-60283.stderr index 2922eb87e82..80f118e12c4 100644 --- a/src/test/ui/issues/issue-60283.stderr +++ b/src/test/ui/issues/issue-60283.stderr @@ -19,7 +19,7 @@ error[E0277]: the size for values of type `<() as Trait<'_>>::Item` cannot be kn LL | foo((), drop) | ^^^^ doesn't have a size known at compile-time | - ::: $SRC_DIR/libcore/mem/mod.rs:LL:COL + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub fn drop(_x: T) {} | - required by this bound in `std::mem::drop` 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 0f86e37b7e5..575dfafe15e 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 @@ -3,7 +3,7 @@ trait Foo<'a> { type Value: 'a; - fn dummy(&'a self) { } + fn dummy(&'a self) {} } impl<'a> Foo<'a> for &'a i16 { @@ -13,12 +13,12 @@ impl<'a> Foo<'a> for &'a i16 { impl<'a> Foo<'static> for &'a i32 { type Value = &'a i32; - //~^ ERROR lifetime bound not satisfied + //~^ ERROR the type `&'a i32` does not fulfill the required lifetime } -impl<'a,'b> Foo<'b> for &'a i64 { +impl<'a, 'b> Foo<'b> for &'a i64 { type Value = &'a i32; - //~^ ERROR lifetime bound not satisfied + //~^ ERROR the type `&'a i32` does not fulfill the required lifetime } -fn main() { } +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 feb9c90bc8f..03da33ae11f 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,33 +1,23 @@ -error[E0478]: lifetime bound not satisfied +error[E0477]: the type `&'a i32` does not fulfill the required lifetime --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:15:5 | LL | type Value = &'a i32; | ^^^^^^^^^^^^^^^^^^^^^ | -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: but lifetime parameter must outlive the static lifetime + = note: type must satisfy the static lifetime -error[E0478]: lifetime bound not satisfied +error[E0477]: the type `&'a i32` does not fulfill the required lifetime --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:20:5 | LL | type Value = &'a i32; | ^^^^^^^^^^^^^^^^^^^^^ | -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 +note: type must outlive the lifetime `'b` as defined on the impl at 19:10 + --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:10 | -LL | impl<'a,'b> Foo<'b> for &'a i64 { - | ^^ -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 { - | ^^ +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 E0478`. +For more information about this error, try `rustc --explain E0477`. 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 65b54b45a0a..00100e0e9ea 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 @@ -3,12 +3,12 @@ trait Foo { type Value: 'static; - fn dummy(&self) { } + fn dummy(&self) {} } impl<'a> Foo for &'a i32 { type Value = &'a i32; - //~^ ERROR lifetime bound not satisfied + //~^ ERROR the type `&'a i32` does not fulfill the required lifetime } impl<'a> Foo for i32 { @@ -16,4 +16,4 @@ impl<'a> Foo for i32 { type Value = i32; } -fn main() { } +fn main() {} 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 9b98d14a978..d8efeac5b8a 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,16 +1,11 @@ -error[E0478]: lifetime bound not satisfied +error[E0477]: the type `&'a i32` does not fulfill the required lifetime --> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:10:5 | LL | type Value = &'a i32; | ^^^^^^^^^^^^^^^^^^^^^ | -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: but lifetime parameter must outlive the static lifetime + = note: type must satisfy the static lifetime error: aborting due to previous error -For more information about this error, try `rustc --explain E0478`. +For more information about this error, try `rustc --explain E0477`.