Rollup merge of #110512 - compiler-errors:fix-elaboration-with-associated-type-bounds, r=spastorino

Fix elaboration with associated type bounds

When computing a trait's supertrait predicates, do not add any associated type *trait* bounds to that list of supertrait predicates. This is because supertrait predicates are expected to have the same `Self` type as the trait.

For example, given:

```rust
trait Foo: Bar<Assoc: Send>
```

Before, we would compute that the supertrait predicates of `T: Foo` are `T: Bar` and `<T as Bar>::Assoc: Send`. However, the last bound is a trait predicate for a totally different type than `T`, and existing code that uses supertrait bounds such as vtable construction, closure fn signature deduction, etc. all rely on the invariant that we have a list of predicates for self type `T`.

Fixes #76593

The reason for all the extra diagnostic noise is that we're recomputing predicates with a different filter now. These diagnostics should be deduplicated for any end-user though.

---

This does bring up an interesting question -- is the predicate `<T as Bar>::Assoc: Send` an implied bound of `T: Foo`? Because currently the only bounds implied by a (non-alias) trait are its supertraits. I guess I could fix this too, but it would require even more changes, and I'm inclined to punt this question along.
This commit is contained in:
Dylan DPC 2023-05-02 11:44:51 +05:30 committed by GitHub
commit be4f9f5bec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 444 additions and 145 deletions

View File

@ -56,6 +56,9 @@
#[derive(Debug)] #[derive(Debug)]
pub struct PathSeg(pub DefId, pub usize); pub struct PathSeg(pub DefId, pub usize);
#[derive(Copy, Clone, Debug)]
pub struct OnlySelfBounds(pub bool);
pub trait AstConv<'tcx> { pub trait AstConv<'tcx> {
fn tcx(&self) -> TyCtxt<'tcx>; fn tcx(&self) -> TyCtxt<'tcx>;
@ -670,6 +673,7 @@ fn instantiate_poly_trait_ref_inner(
args: &GenericArgs<'_>, args: &GenericArgs<'_>,
infer_args: bool, infer_args: bool,
self_ty: Ty<'tcx>, self_ty: Ty<'tcx>,
only_self_bounds: OnlySelfBounds,
) -> GenericArgCountResult { ) -> GenericArgCountResult {
let (substs, arg_count) = self.create_substs_for_ast_path( let (substs, arg_count) = self.create_substs_for_ast_path(
trait_ref_span, trait_ref_span,
@ -706,6 +710,7 @@ fn instantiate_poly_trait_ref_inner(
&mut dup_bindings, &mut dup_bindings,
binding_span.unwrap_or(binding.span), binding_span.unwrap_or(binding.span),
constness, constness,
only_self_bounds,
); );
// Okay to ignore `Err` because of `ErrorGuaranteed` (see above). // Okay to ignore `Err` because of `ErrorGuaranteed` (see above).
} }
@ -741,6 +746,7 @@ pub(crate) fn instantiate_poly_trait_ref(
self_ty: Ty<'tcx>, self_ty: Ty<'tcx>,
bounds: &mut Bounds<'tcx>, bounds: &mut Bounds<'tcx>,
speculative: bool, speculative: bool,
only_self_bounds: OnlySelfBounds,
) -> GenericArgCountResult { ) -> GenericArgCountResult {
let hir_id = trait_ref.hir_ref_id; let hir_id = trait_ref.hir_ref_id;
let binding_span = None; let binding_span = None;
@ -766,6 +772,7 @@ pub(crate) fn instantiate_poly_trait_ref(
args, args,
infer_args, infer_args,
self_ty, self_ty,
only_self_bounds,
) )
} }
@ -777,6 +784,7 @@ pub(crate) fn instantiate_lang_item_trait_ref(
args: &GenericArgs<'_>, args: &GenericArgs<'_>,
self_ty: Ty<'tcx>, self_ty: Ty<'tcx>,
bounds: &mut Bounds<'tcx>, bounds: &mut Bounds<'tcx>,
only_self_bounds: OnlySelfBounds,
) { ) {
let binding_span = Some(span); let binding_span = Some(span);
let constness = ty::BoundConstness::NotConst; let constness = ty::BoundConstness::NotConst;
@ -799,6 +807,7 @@ pub(crate) fn instantiate_lang_item_trait_ref(
args, args,
infer_args, infer_args,
self_ty, self_ty,
only_self_bounds,
); );
} }
@ -947,6 +956,7 @@ pub(crate) fn add_bounds<'hir, I: Iterator<Item = &'hir hir::GenericBound<'hir>>
ast_bounds: I, ast_bounds: I,
bounds: &mut Bounds<'tcx>, bounds: &mut Bounds<'tcx>,
bound_vars: &'tcx ty::List<ty::BoundVariableKind>, bound_vars: &'tcx ty::List<ty::BoundVariableKind>,
only_self_bounds: OnlySelfBounds,
) { ) {
for ast_bound in ast_bounds { for ast_bound in ast_bounds {
match ast_bound { match ast_bound {
@ -964,11 +974,18 @@ pub(crate) fn add_bounds<'hir, I: Iterator<Item = &'hir hir::GenericBound<'hir>>
param_ty, param_ty,
bounds, bounds,
false, false,
only_self_bounds,
); );
} }
&hir::GenericBound::LangItemTrait(lang_item, span, hir_id, args) => { &hir::GenericBound::LangItemTrait(lang_item, span, hir_id, args) => {
self.instantiate_lang_item_trait_ref( self.instantiate_lang_item_trait_ref(
lang_item, span, hir_id, args, param_ty, bounds, lang_item,
span,
hir_id,
args,
param_ty,
bounds,
only_self_bounds,
); );
} }
hir::GenericBound::Outlives(lifetime) => { hir::GenericBound::Outlives(lifetime) => {
@ -1006,8 +1023,19 @@ pub(crate) fn compute_bounds(
&self, &self,
param_ty: Ty<'tcx>, param_ty: Ty<'tcx>,
ast_bounds: &[hir::GenericBound<'_>], ast_bounds: &[hir::GenericBound<'_>],
only_self_bounds: OnlySelfBounds,
) -> Bounds<'tcx> { ) -> Bounds<'tcx> {
self.compute_bounds_inner(param_ty, ast_bounds) let mut bounds = Bounds::default();
self.add_bounds(
param_ty,
ast_bounds.iter(),
&mut bounds,
ty::List::empty(),
only_self_bounds,
);
debug!(?bounds);
bounds
} }
/// Convert the bounds in `ast_bounds` that refer to traits which define an associated type /// Convert the bounds in `ast_bounds` that refer to traits which define an associated type
@ -1029,17 +1057,14 @@ pub(crate) fn compute_bounds_that_match_assoc_type(
} }
} }
self.compute_bounds_inner(param_ty, &result)
}
fn compute_bounds_inner(
&self,
param_ty: Ty<'tcx>,
ast_bounds: &[hir::GenericBound<'_>],
) -> Bounds<'tcx> {
let mut bounds = Bounds::default(); let mut bounds = Bounds::default();
self.add_bounds(
self.add_bounds(param_ty, ast_bounds.iter(), &mut bounds, ty::List::empty()); param_ty,
result.iter(),
&mut bounds,
ty::List::empty(),
OnlySelfBounds(true),
);
debug!(?bounds); debug!(?bounds);
bounds bounds
@ -1062,6 +1087,7 @@ fn add_predicates_for_ast_type_binding(
dup_bindings: &mut FxHashMap<DefId, Span>, dup_bindings: &mut FxHashMap<DefId, Span>,
path_span: Span, path_span: Span,
constness: ty::BoundConstness, constness: ty::BoundConstness,
only_self_bounds: OnlySelfBounds,
) -> Result<(), ErrorGuaranteed> { ) -> Result<(), ErrorGuaranteed> {
// Given something like `U: SomeTrait<T = X>`, we want to produce a // Given something like `U: SomeTrait<T = X>`, we want to produce a
// predicate like `<U as SomeTrait>::T = X`. This is somewhat // predicate like `<U as SomeTrait>::T = X`. This is somewhat
@ -1361,8 +1387,20 @@ fn add_predicates_for_ast_type_binding(
// //
// Calling `skip_binder` is okay, because `add_bounds` expects the `param_ty` // Calling `skip_binder` is okay, because `add_bounds` expects the `param_ty`
// parameter to have a skipped binder. // parameter to have a skipped binder.
let param_ty = tcx.mk_alias(ty::Projection, projection_ty.skip_binder()); //
self.add_bounds(param_ty, ast_bounds.iter(), bounds, projection_ty.bound_vars()); // NOTE: If `only_self_bounds` is true, do NOT expand this associated
// type bound into a trait predicate, since we only want to add predicates
// for the `Self` type.
if !only_self_bounds.0 {
let param_ty = tcx.mk_alias(ty::Projection, projection_ty.skip_binder());
self.add_bounds(
param_ty,
ast_bounds.iter(),
bounds,
projection_ty.bound_vars(),
only_self_bounds,
);
}
} }
} }
Ok(()) Ok(())
@ -1403,6 +1441,10 @@ fn conv_object_ty_poly_trait_ref(
dummy_self, dummy_self,
&mut bounds, &mut bounds,
false, false,
// FIXME: This should be `true`, but we don't really handle
// associated type bounds or type aliases in objects in a way
// that makes this meaningful, I think.
OnlySelfBounds(false),
) { ) {
potential_assoc_types.extend(cur_potential_assoc_types); potential_assoc_types.extend(cur_potential_assoc_types);
} }

View File

@ -1,5 +1,5 @@
use super::ItemCtxt; use super::ItemCtxt;
use crate::astconv::AstConv; use crate::astconv::{AstConv, OnlySelfBounds};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_infer::traits::util; use rustc_infer::traits::util;
use rustc_middle::ty::subst::InternalSubsts; use rustc_middle::ty::subst::InternalSubsts;
@ -26,7 +26,7 @@ fn associated_type_bounds<'tcx>(
); );
let icx = ItemCtxt::new(tcx, assoc_item_def_id); let icx = ItemCtxt::new(tcx, assoc_item_def_id);
let mut bounds = icx.astconv().compute_bounds(item_ty, ast_bounds); let mut bounds = icx.astconv().compute_bounds(item_ty, ast_bounds, OnlySelfBounds(false));
// Associated types are implicitly sized unless a `?Sized` bound is found // Associated types are implicitly sized unless a `?Sized` bound is found
icx.astconv().add_implicitly_sized(&mut bounds, item_ty, ast_bounds, None, span); icx.astconv().add_implicitly_sized(&mut bounds, item_ty, ast_bounds, None, span);
@ -67,7 +67,7 @@ fn opaque_type_bounds<'tcx>(
) -> &'tcx [(ty::Predicate<'tcx>, Span)] { ) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
ty::print::with_no_queries!({ ty::print::with_no_queries!({
let icx = ItemCtxt::new(tcx, opaque_def_id); let icx = ItemCtxt::new(tcx, opaque_def_id);
let mut bounds = icx.astconv().compute_bounds(item_ty, ast_bounds); let mut bounds = icx.astconv().compute_bounds(item_ty, ast_bounds, OnlySelfBounds(false));
// Opaque types are implicitly sized unless a `?Sized` bound is found // Opaque types are implicitly sized unless a `?Sized` bound is found
icx.astconv().add_implicitly_sized(&mut bounds, item_ty, ast_bounds, None, span); icx.astconv().add_implicitly_sized(&mut bounds, item_ty, ast_bounds, None, span);
debug!(?bounds); debug!(?bounds);

View File

@ -1,4 +1,4 @@
use crate::astconv::AstConv; use crate::astconv::{AstConv, OnlySelfBounds};
use crate::bounds::Bounds; use crate::bounds::Bounds;
use crate::collect::ItemCtxt; use crate::collect::ItemCtxt;
use crate::constrained_generic_params as cgp; use crate::constrained_generic_params as cgp;
@ -14,9 +14,6 @@
use rustc_span::symbol::{sym, Ident}; use rustc_span::symbol::{sym, Ident};
use rustc_span::{Span, DUMMY_SP}; use rustc_span::{Span, DUMMY_SP};
#[derive(Debug)]
struct OnlySelfBounds(bool);
/// Returns a list of all type predicates (explicit and implicit) for the definition with /// Returns a list of all type predicates (explicit and implicit) for the definition with
/// ID `def_id`. This includes all predicates returned by `predicates_defined_on`, plus /// ID `def_id`. This includes all predicates returned by `predicates_defined_on`, plus
/// `Self: Trait` predicates for traits. /// `Self: Trait` predicates for traits.
@ -99,8 +96,9 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
| ItemKind::Struct(_, generics) | ItemKind::Struct(_, generics)
| ItemKind::Union(_, generics) => generics, | ItemKind::Union(_, generics) => generics,
ItemKind::Trait(_, _, generics, ..) | ItemKind::TraitAlias(generics, _) => { ItemKind::Trait(_, _, generics, self_bounds, ..)
is_trait = Some(ty::TraitRef::identity(tcx, def_id.to_def_id())); | ItemKind::TraitAlias(generics, self_bounds) => {
is_trait = Some(self_bounds);
generics generics
} }
ItemKind::OpaqueTy(OpaqueTy { generics, .. }) => generics, ItemKind::OpaqueTy(OpaqueTy { generics, .. }) => generics,
@ -122,10 +120,14 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
// Below we'll consider the bounds on the type parameters (including `Self`) // Below we'll consider the bounds on the type parameters (including `Self`)
// and the explicit where-clauses, but to get the full set of predicates // and the explicit where-clauses, but to get the full set of predicates
// on a trait we need to add in the supertrait bounds and bounds found on // on a trait we must also consider the bounds that follow the trait's name,
// associated types. // like `trait Foo: A + B + C`.
if let Some(_trait_ref) = is_trait { if let Some(self_bounds) = is_trait {
predicates.extend(tcx.implied_predicates_of(def_id).predicates.iter().cloned()); predicates.extend(
icx.astconv()
.compute_bounds(tcx.types.self_param, self_bounds, OnlySelfBounds(false))
.predicates(),
);
} }
// In default impls, we can assume that the self type implements // In default impls, we can assume that the self type implements
@ -225,7 +227,13 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
} }
let mut bounds = Bounds::default(); let mut bounds = Bounds::default();
icx.astconv().add_bounds(ty, bound_pred.bounds.iter(), &mut bounds, bound_vars); icx.astconv().add_bounds(
ty,
bound_pred.bounds.iter(),
&mut bounds,
bound_vars,
OnlySelfBounds(false),
);
predicates.extend(bounds.predicates()); predicates.extend(bounds.predicates());
} }
@ -608,7 +616,7 @@ pub(super) fn implied_predicates_with_filter(
let (superbounds, where_bounds_that_match) = match filter { let (superbounds, where_bounds_that_match) = match filter {
PredicateFilter::All => ( PredicateFilter::All => (
// Convert the bounds that follow the colon (or equal in trait aliases) // Convert the bounds that follow the colon (or equal in trait aliases)
icx.astconv().compute_bounds(self_param_ty, bounds), icx.astconv().compute_bounds(self_param_ty, bounds, OnlySelfBounds(false)),
// Also include all where clause bounds // Also include all where clause bounds
icx.type_parameter_bounds_in_generics( icx.type_parameter_bounds_in_generics(
generics, generics,
@ -620,7 +628,7 @@ pub(super) fn implied_predicates_with_filter(
), ),
PredicateFilter::SelfOnly => ( PredicateFilter::SelfOnly => (
// Convert the bounds that follow the colon (or equal in trait aliases) // Convert the bounds that follow the colon (or equal in trait aliases)
icx.astconv().compute_bounds(self_param_ty, bounds), icx.astconv().compute_bounds(self_param_ty, bounds, OnlySelfBounds(true)),
// Include where clause bounds for `Self` // Include where clause bounds for `Self`
icx.type_parameter_bounds_in_generics( icx.type_parameter_bounds_in_generics(
generics, generics,
@ -774,32 +782,35 @@ fn type_parameter_bounds_in_generics(
only_self_bounds: OnlySelfBounds, only_self_bounds: OnlySelfBounds,
assoc_name: Option<Ident>, assoc_name: Option<Ident>,
) -> Vec<(ty::Predicate<'tcx>, Span)> { ) -> Vec<(ty::Predicate<'tcx>, Span)> {
ast_generics let mut bounds = Bounds::default();
.predicates
.iter()
.filter_map(|wp| match wp {
hir::WherePredicate::BoundPredicate(bp) => Some(bp),
_ => None,
})
.flat_map(|bp| {
let bt = if bp.is_param_bound(param_def_id.to_def_id()) {
Some(ty)
} else if !only_self_bounds.0 {
Some(self.to_ty(bp.bounded_ty))
} else {
None
};
let bvars = self.tcx.late_bound_vars(bp.hir_id);
bp.bounds.iter().filter_map(move |b| bt.map(|bt| (bt, b, bvars))).filter( for predicate in ast_generics.predicates {
|(_, b, _)| match assoc_name { let hir::WherePredicate::BoundPredicate(predicate) = predicate else {
Some(assoc_name) => self.bound_defines_assoc_item(b, assoc_name), continue;
None => true, };
},
) let bound_ty = if predicate.is_param_bound(param_def_id.to_def_id()) {
}) ty
.flat_map(|(bt, b, bvars)| predicates_from_bound(self, bt, b, bvars)) } else if !only_self_bounds.0 {
.collect() self.to_ty(predicate.bounded_ty)
} else {
continue;
};
let bound_vars = self.tcx.late_bound_vars(predicate.hir_id);
self.astconv().add_bounds(
bound_ty,
predicate.bounds.iter().filter(|bound| {
assoc_name
.map_or(true, |assoc_name| self.bound_defines_assoc_item(bound, assoc_name))
}),
&mut bounds,
bound_vars,
only_self_bounds,
);
}
bounds.predicates().collect()
} }
#[instrument(level = "trace", skip(self))] #[instrument(level = "trace", skip(self))]
@ -817,19 +828,3 @@ fn bound_defines_assoc_item(&self, b: &hir::GenericBound<'_>, assoc_name: Ident)
} }
} }
} }
/// Converts a specific `GenericBound` from the AST into a set of
/// predicates that apply to the self type. A vector is returned
/// because this can be anywhere from zero predicates (`T: ?Sized` adds no
/// predicates) to one (`T: Foo`) to many (`T: Bar<X = i32>` adds `T: Bar`
/// and `<T as Bar>::X == i32`).
fn predicates_from_bound<'tcx>(
astconv: &dyn AstConv<'tcx>,
param_ty: Ty<'tcx>,
bound: &'tcx hir::GenericBound<'tcx>,
bound_vars: &'tcx ty::List<ty::BoundVariableKind>,
) -> Vec<(ty::Predicate<'tcx>, Span)> {
let mut bounds = Bounds::default();
astconv.add_bounds(param_ty, [bound].into_iter(), &mut bounds, bound_vars);
bounds.predicates().collect()
}

View File

@ -116,7 +116,7 @@
use std::ops::Not; use std::ops::Not;
use astconv::AstConv; use astconv::{AstConv, OnlySelfBounds};
use bounds::Bounds; use bounds::Bounds;
fluent_messages! { "../messages.ftl" } fluent_messages! { "../messages.ftl" }
@ -531,6 +531,7 @@ pub fn hir_trait_to_predicates<'tcx>(
self_ty, self_ty,
&mut bounds, &mut bounds,
true, true,
OnlySelfBounds(false),
); );
bounds bounds

View File

@ -19,6 +19,8 @@ pub trait SVec: Index<
//~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
Output = <Index<<Self as SVec>::Item, Output = <Index<<Self as SVec>::Item,
//~^ expected 1 lifetime argument //~^ expected 1 lifetime argument
//~| expected 1 generic argument //~| expected 1 generic argument
@ -26,6 +28,8 @@ pub trait SVec: Index<
//~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
Output = <Self as SVec>::Item> as SVec>::Item, Output = <Self as SVec>::Item> as SVec>::Item,
//~^ expected 1 lifetime argument //~^ expected 1 lifetime argument
//~| expected 1 generic argument //~| expected 1 generic argument
@ -34,11 +38,15 @@ pub trait SVec: Index<
//~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
//~| expected 1 generic argument //~| expected 1 generic argument
//~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
> { > {
type Item<'a, T>; type Item<'a, T>;

View File

@ -5,7 +5,7 @@ LL | <Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument | ^^^^ expected 1 lifetime argument
| |
note: associated type defined here, with 1 lifetime parameter: `'a` note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ -- | ^^^^ --
@ -21,7 +21,7 @@ LL | <Self as SVec>::Item,
| ^^^^ expected 1 generic argument | ^^^^ expected 1 generic argument
| |
note: associated type defined here, with 1 generic parameter: `T` note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ - | ^^^^ -
@ -31,13 +31,13 @@ LL | <Self as SVec>::Item<T>,
| +++ | +++
error[E0107]: missing generics for associated type `SVec::Item` error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:22:37 --> $DIR/issue-105742.rs:24:37
| |
LL | Output = <Index<<Self as SVec>::Item, LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument | ^^^^ expected 1 lifetime argument
| |
note: associated type defined here, with 1 lifetime parameter: `'a` note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ -- | ^^^^ --
@ -47,13 +47,13 @@ LL | Output = <Index<<Self as SVec>::Item<'a>,
| ++++ | ++++
error[E0107]: missing generics for associated type `SVec::Item` error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:22:37 --> $DIR/issue-105742.rs:24:37
| |
LL | Output = <Index<<Self as SVec>::Item, LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 generic argument | ^^^^ expected 1 generic argument
| |
note: associated type defined here, with 1 generic parameter: `T` note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ - | ^^^^ -
@ -63,13 +63,13 @@ LL | Output = <Index<<Self as SVec>::Item<T>,
| +++ | +++
error[E0107]: missing generics for associated type `SVec::Item` error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:29:30 --> $DIR/issue-105742.rs:33:30
| |
LL | Output = <Self as SVec>::Item> as SVec>::Item, LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument | ^^^^ expected 1 lifetime argument
| |
note: associated type defined here, with 1 lifetime parameter: `'a` note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ -- | ^^^^ --
@ -79,13 +79,13 @@ LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
| ++++ | ++++
error[E0107]: missing generics for associated type `SVec::Item` error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:29:30 --> $DIR/issue-105742.rs:33:30
| |
LL | Output = <Self as SVec>::Item> as SVec>::Item, LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument | ^^^^ expected 1 generic argument
| |
note: associated type defined here, with 1 generic parameter: `T` note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ - | ^^^^ -
@ -95,13 +95,13 @@ LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
| +++ | +++
error[E0107]: missing generics for associated type `SVec::Item` error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:29:46 --> $DIR/issue-105742.rs:33:46
| |
LL | Output = <Self as SVec>::Item> as SVec>::Item, LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument | ^^^^ expected 1 lifetime argument
| |
note: associated type defined here, with 1 lifetime parameter: `'a` note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ -- | ^^^^ --
@ -111,13 +111,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
| ++++ | ++++
error[E0107]: missing generics for associated type `SVec::Item` error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:29:46 --> $DIR/issue-105742.rs:33:46
| |
LL | Output = <Self as SVec>::Item> as SVec>::Item, LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument | ^^^^ expected 1 generic argument
| |
note: associated type defined here, with 1 generic parameter: `T` note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ - | ^^^^ -
@ -133,7 +133,7 @@ LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
| ^^^^ expected 1 lifetime argument | ^^^^ expected 1 lifetime argument
| |
note: associated type defined here, with 1 lifetime parameter: `'a` note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ -- | ^^^^ --
@ -149,7 +149,7 @@ LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
| ^^^^ expected 1 generic argument | ^^^^ expected 1 generic argument
| |
note: associated type defined here, with 1 generic parameter: `T` note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ - | ^^^^ -
@ -165,7 +165,7 @@ LL | <Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument | ^^^^ expected 1 lifetime argument
| |
note: associated type defined here, with 1 lifetime parameter: `'a` note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ -- | ^^^^ --
@ -181,7 +181,7 @@ LL | <Self as SVec>::Item,
| ^^^^ expected 1 generic argument | ^^^^ expected 1 generic argument
| |
note: associated type defined here, with 1 generic parameter: `T` note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ - | ^^^^ -
@ -191,13 +191,13 @@ LL | <Self as SVec>::Item<T>,
| +++ | +++
error[E0107]: missing generics for associated type `SVec::Item` error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:22:37 --> $DIR/issue-105742.rs:24:37
| |
LL | Output = <Index<<Self as SVec>::Item, LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument | ^^^^ expected 1 lifetime argument
| |
note: associated type defined here, with 1 lifetime parameter: `'a` note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ -- | ^^^^ --
@ -207,13 +207,13 @@ LL | Output = <Index<<Self as SVec>::Item<'a>,
| ++++ | ++++
error[E0107]: missing generics for associated type `SVec::Item` error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:22:37 --> $DIR/issue-105742.rs:24:37
| |
LL | Output = <Index<<Self as SVec>::Item, LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 generic argument | ^^^^ expected 1 generic argument
| |
note: associated type defined here, with 1 generic parameter: `T` note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ - | ^^^^ -
@ -223,13 +223,13 @@ LL | Output = <Index<<Self as SVec>::Item<T>,
| +++ | +++
error[E0107]: missing generics for associated type `SVec::Item` error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:29:30 --> $DIR/issue-105742.rs:33:30
| |
LL | Output = <Self as SVec>::Item> as SVec>::Item, LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument | ^^^^ expected 1 lifetime argument
| |
note: associated type defined here, with 1 lifetime parameter: `'a` note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ -- | ^^^^ --
@ -239,13 +239,13 @@ LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
| ++++ | ++++
error[E0107]: missing generics for associated type `SVec::Item` error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:29:30 --> $DIR/issue-105742.rs:33:30
| |
LL | Output = <Self as SVec>::Item> as SVec>::Item, LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument | ^^^^ expected 1 generic argument
| |
note: associated type defined here, with 1 generic parameter: `T` note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ - | ^^^^ -
@ -255,13 +255,13 @@ LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
| +++ | +++
error[E0107]: missing generics for associated type `SVec::Item` error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:29:46 --> $DIR/issue-105742.rs:33:46
| |
LL | Output = <Self as SVec>::Item> as SVec>::Item, LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument | ^^^^ expected 1 lifetime argument
| |
note: associated type defined here, with 1 lifetime parameter: `'a` note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ -- | ^^^^ --
@ -271,13 +271,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
| ++++ | ++++
error[E0107]: missing generics for associated type `SVec::Item` error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:29:46 --> $DIR/issue-105742.rs:33:46
| |
LL | Output = <Self as SVec>::Item> as SVec>::Item, LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument | ^^^^ expected 1 generic argument
| |
note: associated type defined here, with 1 generic parameter: `T` note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ - | ^^^^ -
@ -317,13 +317,141 @@ LL | | > {
| |__^ ...because it uses `Self` as a type parameter | |__^ ...because it uses `Self` as a type parameter
error[E0107]: missing generics for associated type `SVec::Item` error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:45:38 --> $DIR/issue-105742.rs:15:21
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:51:10
|
LL | type Item<'a, T>;
| ^^^^ --
help: add missing lifetime argument
|
LL | <Self as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:15:21
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:51:10
|
LL | type Item<'a, T>;
| ^^^^ -
help: add missing generic argument
|
LL | <Self as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:24:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:51:10
|
LL | type Item<'a, T>;
| ^^^^ --
help: add missing lifetime argument
|
LL | Output = <Index<<Self as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:24:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:51:10
|
LL | type Item<'a, T>;
| ^^^^ -
help: add missing generic argument
|
LL | Output = <Index<<Self as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:33:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:51:10
|
LL | type Item<'a, T>;
| ^^^^ --
help: add missing lifetime argument
|
LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:33:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:51:10
|
LL | type Item<'a, T>;
| ^^^^ -
help: add missing generic argument
|
LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:33:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:51:10
|
LL | type Item<'a, T>;
| ^^^^ --
help: add missing lifetime argument
|
LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:33:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:51:10
|
LL | type Item<'a, T>;
| ^^^^ -
help: add missing generic argument
|
LL | Output = <Self as SVec>::Item> as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:53:38
| |
LL | fn len(&self) -> <Self as SVec>::Item; LL | fn len(&self) -> <Self as SVec>::Item;
| ^^^^ expected 1 lifetime argument | ^^^^ expected 1 lifetime argument
| |
note: associated type defined here, with 1 lifetime parameter: `'a` note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ -- | ^^^^ --
@ -333,13 +461,13 @@ LL | fn len(&self) -> <Self as SVec>::Item<'_>;
| ++++ | ++++
error[E0107]: missing generics for associated type `SVec::Item` error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:45:38 --> $DIR/issue-105742.rs:53:38
| |
LL | fn len(&self) -> <Self as SVec>::Item; LL | fn len(&self) -> <Self as SVec>::Item;
| ^^^^ expected 1 generic argument | ^^^^ expected 1 generic argument
| |
note: associated type defined here, with 1 generic parameter: `T` note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:43:10 --> $DIR/issue-105742.rs:51:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ - | ^^^^ -
@ -348,7 +476,7 @@ help: add missing generic argument
LL | fn len(&self) -> <Self as SVec>::Item<T>; LL | fn len(&self) -> <Self as SVec>::Item<T>;
| +++ | +++
error: aborting due to 21 previous errors error: aborting due to 29 previous errors
Some errors have detailed explanations: E0038, E0107. Some errors have detailed explanations: E0038, E0107.
For more information about an error, try `rustc --explain E0038`. For more information about an error, try `rustc --explain E0038`.

View File

@ -193,10 +193,13 @@ trait TRI3<T: Iterator<Item: 'static, Item: 'static>> {}
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
trait TRS1: Iterator<Item: Copy, Item: Send> {} trait TRS1: Iterator<Item: Copy, Item: Send> {}
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
//~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
trait TRS2: Iterator<Item: Copy, Item: Copy> {} trait TRS2: Iterator<Item: Copy, Item: Copy> {}
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
//~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
trait TRS3: Iterator<Item: 'static, Item: 'static> {} trait TRS3: Iterator<Item: 'static, Item: 'static> {}
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
//~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
trait TRW1<T> trait TRW1<T>
where where
T: Iterator<Item: Copy, Item: Send>, T: Iterator<Item: Copy, Item: Send>,

View File

@ -367,7 +367,15 @@ LL | trait TRS1: Iterator<Item: Copy, Item: Send> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:196:34 --> $DIR/duplicate.rs:194:34
|
LL | trait TRS1: Iterator<Item: Copy, Item: Send> {}
| ---------- ^^^^^^^^^^ 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:197:34
| |
LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {} LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -375,7 +383,15 @@ LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:198:37 --> $DIR/duplicate.rs:197:34
|
LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {}
| ---------- ^^^^^^^^^^ 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:200:37
| |
LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {} LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {}
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -383,7 +399,15 @@ LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:202:29 --> $DIR/duplicate.rs:200:37
|
LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {}
| ------------- ^^^^^^^^^^^^^ 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:205:29
| |
LL | T: Iterator<Item: Copy, Item: Send>, LL | T: Iterator<Item: Copy, Item: Send>,
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -391,7 +415,7 @@ LL | T: Iterator<Item: Copy, Item: Send>,
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:208:29 --> $DIR/duplicate.rs:211:29
| |
LL | T: Iterator<Item: Copy, Item: Copy>, LL | T: Iterator<Item: Copy, Item: Copy>,
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -399,7 +423,7 @@ LL | T: Iterator<Item: Copy, Item: Copy>,
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:214:32 --> $DIR/duplicate.rs:217:32
| |
LL | T: Iterator<Item: 'static, Item: 'static>, LL | T: Iterator<Item: 'static, Item: 'static>,
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -407,7 +431,7 @@ LL | T: Iterator<Item: 'static, Item: 'static>,
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:220:32 --> $DIR/duplicate.rs:223:32
| |
LL | Self: Iterator<Item: Copy, Item: Send>, LL | Self: Iterator<Item: Copy, Item: Send>,
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -415,7 +439,7 @@ LL | Self: Iterator<Item: Copy, Item: Send>,
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:220:32 --> $DIR/duplicate.rs:223:32
| |
LL | Self: Iterator<Item: Copy, Item: Send>, LL | Self: Iterator<Item: Copy, Item: Send>,
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -423,7 +447,7 @@ LL | Self: Iterator<Item: Copy, Item: Send>,
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:227:32 --> $DIR/duplicate.rs:230:32
| |
LL | Self: Iterator<Item: Copy, Item: Copy>, LL | Self: Iterator<Item: Copy, Item: Copy>,
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -431,7 +455,7 @@ LL | Self: Iterator<Item: Copy, Item: Copy>,
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:227:32 --> $DIR/duplicate.rs:230:32
| |
LL | Self: Iterator<Item: Copy, Item: Copy>, LL | Self: Iterator<Item: Copy, Item: Copy>,
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -439,7 +463,7 @@ LL | Self: Iterator<Item: Copy, Item: Copy>,
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:234:35 --> $DIR/duplicate.rs:237:35
| |
LL | Self: Iterator<Item: 'static, Item: 'static>, LL | Self: Iterator<Item: 'static, Item: 'static>,
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -447,7 +471,7 @@ LL | Self: Iterator<Item: 'static, Item: 'static>,
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:234:35 --> $DIR/duplicate.rs:237:35
| |
LL | Self: Iterator<Item: 'static, Item: 'static>, LL | Self: Iterator<Item: 'static, Item: 'static>,
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -455,7 +479,7 @@ LL | Self: Iterator<Item: 'static, Item: 'static>,
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:252:40 --> $DIR/duplicate.rs:255:40
| |
LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>; LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -463,7 +487,7 @@ LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:254:44 --> $DIR/duplicate.rs:257:44
| |
LL | type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>; LL | type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -471,7 +495,7 @@ LL | type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:256:43 --> $DIR/duplicate.rs:259:43
| |
LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>; LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>;
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -479,7 +503,7 @@ LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:240:34 --> $DIR/duplicate.rs:243:34
| |
LL | type A: Iterator<Item: Copy, Item: Send>; LL | type A: Iterator<Item: Copy, Item: Send>;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -487,7 +511,7 @@ LL | type A: Iterator<Item: Copy, Item: Send>;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:244:34 --> $DIR/duplicate.rs:247:34
| |
LL | type A: Iterator<Item: Copy, Item: Copy>; LL | type A: Iterator<Item: Copy, Item: Copy>;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -495,13 +519,13 @@ LL | type A: Iterator<Item: Copy, Item: Copy>;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:248:37 --> $DIR/duplicate.rs:251:37
| |
LL | type A: Iterator<Item: 'static, Item: 'static>; LL | type A: Iterator<Item: 'static, Item: 'static>;
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
| | | |
| `Item` bound here first | `Item` bound here first
error: aborting due to 63 previous errors error: aborting due to 66 previous errors
For more information about this error, try `rustc --explain E0719`. For more information about this error, try `rustc --explain E0719`.

View File

@ -0,0 +1,26 @@
// check-pass
// Make sure that we don't look into associated type bounds when looking for
// supertraits that define an associated type. Fixes #76593.
#![feature(associated_type_bounds)]
trait Load: Sized {
type Blob;
}
trait Primitive: Load<Blob = Self> {}
trait BlobPtr: Primitive {}
trait CleanPtr: Load<Blob: BlobPtr> {
fn to_blob(&self) -> Self::Blob;
}
impl Load for () {
type Blob = Self;
}
impl Primitive for () {}
impl BlobPtr for () {}
fn main() {}

View File

@ -10,6 +10,7 @@ pub trait Parse {
pub trait CoolStuff: Parse<MODE = Mode::Cool> {} pub trait CoolStuff: Parse<MODE = Mode::Cool> {}
//~^ ERROR expected associated constant bound //~^ ERROR expected associated constant bound
//~| ERROR expected associated constant bound
//~| ERROR expected type //~| ERROR expected type
fn no_help() -> Mode::Cool {} fn no_help() -> Mode::Cool {}

View File

@ -8,7 +8,7 @@ LL | pub trait CoolStuff: Parse<MODE = Mode::Cool> {}
| help: try using the variant's enum: `Mode` | help: try using the variant's enum: `Mode`
error[E0573]: expected type, found variant `Mode::Cool` error[E0573]: expected type, found variant `Mode::Cool`
--> $DIR/assoc_const_eq_diagnostic.rs:15:17 --> $DIR/assoc_const_eq_diagnostic.rs:16:17
| |
LL | fn no_help() -> Mode::Cool {} LL | fn no_help() -> Mode::Cool {}
| ^^^^^^^^^^ | ^^^^^^^^^^
@ -28,6 +28,18 @@ note: associated constant defined here
LL | const MODE: Mode; LL | const MODE: Mode;
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
error: aborting due to 3 previous errors error: expected associated constant bound, found type
--> $DIR/assoc_const_eq_diagnostic.rs:11:28
|
LL | pub trait CoolStuff: Parse<MODE = Mode::Cool> {}
| ^^^^^^^^^^^^^^^^^ help: if equating a const, try wrapping with braces: `MODE = { const }`
|
note: associated constant defined here
--> $DIR/assoc_const_eq_diagnostic.rs:8:5
|
LL | const MODE: Mode;
| ^^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0573`. For more information about this error, try `rustc --explain E0573`.

View File

@ -1,5 +1,6 @@
trait Foo: Iterator<Item = i32, Item = i32> {} trait Foo: Iterator<Item = i32, Item = i32> {}
//~^ ERROR is already specified //~^ ERROR is already specified
//~| ERROR is already specified
type Unit = (); type Unit = ();

View File

@ -7,13 +7,21 @@ LL | trait Foo: Iterator<Item = i32, Item = i32> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/E0719.rs:6:42 --> $DIR/E0719.rs:1:33
|
LL | trait Foo: Iterator<Item = i32, Item = i32> {}
| ---------- ^^^^^^^^^^ re-bound here
| |
| `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/E0719.rs:7:42
| |
LL | fn test() -> Box<dyn Iterator<Item = (), Item = Unit>> { LL | fn test() -> Box<dyn Iterator<Item = (), Item = Unit>> {
| --------- ^^^^^^^^^^^ re-bound here | --------- ^^^^^^^^^^^ re-bound here
| | | |
| `Item` bound here first | `Item` bound here first
error: aborting due to 2 previous errors error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0719`. For more information about this error, try `rustc --explain E0719`.

View File

@ -4,5 +4,11 @@ error: ~const can only be applied to `#[const_trait]` traits
LL | trait Bar: ~const Foo {} LL | trait Bar: ~const Foo {}
| ^^^ | ^^^
error: aborting due to previous error error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-2.rs:11:19
|
LL | trait Bar: ~const Foo {}
| ^^^
error: aborting due to 2 previous errors

View File

@ -4,5 +4,11 @@ error: ~const can only be applied to `#[const_trait]` traits
LL | trait Bar: ~const Foo {} LL | trait Bar: ~const Foo {}
| ^^^ | ^^^
error: aborting due to previous error error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-2.rs:11:19
|
LL | trait Bar: ~const Foo {}
| ^^^
error: aborting due to 2 previous errors

View File

@ -10,6 +10,7 @@ trait Foo {
#[cfg_attr(any(yy, ny), const_trait)] #[cfg_attr(any(yy, ny), const_trait)]
trait Bar: ~const Foo {} trait Bar: ~const Foo {}
//[ny,nn]~^ ERROR: ~const can only be applied to `#[const_trait]` //[ny,nn]~^ ERROR: ~const can only be applied to `#[const_trait]`
//[ny,nn]~| ERROR: ~const can only be applied to `#[const_trait]`
const fn foo<T: Bar>(x: &T) { const fn foo<T: Bar>(x: &T) {
x.a(); x.a();

View File

@ -1,11 +1,11 @@
error[E0277]: the trait bound `T: ~const Foo` is not satisfied error[E0277]: the trait bound `T: ~const Foo` is not satisfied
--> $DIR/super-traits-fail-2.rs:15:7 --> $DIR/super-traits-fail-2.rs:16:7
| |
LL | x.a(); LL | x.a();
| ^ the trait `~const Foo` is not implemented for `T` | ^ the trait `~const Foo` is not implemented for `T`
| |
note: the trait `Foo` is implemented for `T`, but that implementation is not `const` note: the trait `Foo` is implemented for `T`, but that implementation is not `const`
--> $DIR/super-traits-fail-2.rs:15:5 --> $DIR/super-traits-fail-2.rs:16:5
| |
LL | x.a(); LL | x.a();
| ^ | ^

View File

@ -1,11 +1,11 @@
error[E0277]: the trait bound `T: ~const Foo` is not satisfied error[E0277]: the trait bound `T: ~const Foo` is not satisfied
--> $DIR/super-traits-fail-2.rs:15:7 --> $DIR/super-traits-fail-2.rs:16:7
| |
LL | x.a(); LL | x.a();
| ^ the trait `~const Foo` is not implemented for `T` | ^ the trait `~const Foo` is not implemented for `T`
| |
note: the trait `Foo` is implemented for `T`, but that implementation is not `const` note: the trait `Foo` is implemented for `T`, but that implementation is not `const`
--> $DIR/super-traits-fail-2.rs:15:5 --> $DIR/super-traits-fail-2.rs:16:5
| |
LL | x.a(); LL | x.a();
| ^ | ^

View File

@ -5,10 +5,16 @@ LL | trait Bar: ~const Foo {}
| ^^^ | ^^^
error: ~const can only be applied to `#[const_trait]` traits error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:15:24 --> $DIR/super-traits-fail-3.rs:12:19
|
LL | trait Bar: ~const Foo {}
| ^^^
error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:16:24
| |
LL | const fn foo<T: ~const Bar>(x: &T) { LL | const fn foo<T: ~const Bar>(x: &T) {
| ^^^ | ^^^
error: aborting due to 2 previous errors error: aborting due to 3 previous errors

View File

@ -4,5 +4,11 @@ error: ~const can only be applied to `#[const_trait]` traits
LL | trait Bar: ~const Foo {} LL | trait Bar: ~const Foo {}
| ^^^ | ^^^
error: aborting due to previous error error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:12:19
|
LL | trait Bar: ~const Foo {}
| ^^^
error: aborting due to 2 previous errors

View File

@ -11,6 +11,7 @@ trait Foo {
#[cfg_attr(any(yy, ny), const_trait)] #[cfg_attr(any(yy, ny), const_trait)]
trait Bar: ~const Foo {} trait Bar: ~const Foo {}
//[ny,nn]~^ ERROR: ~const can only be applied to `#[const_trait]` //[ny,nn]~^ ERROR: ~const can only be applied to `#[const_trait]`
//[ny,nn]~| ERROR: ~const can only be applied to `#[const_trait]`
const fn foo<T: ~const Bar>(x: &T) { const fn foo<T: ~const Bar>(x: &T) {
//[yn,nn]~^ ERROR: ~const can only be applied to `#[const_trait]` //[yn,nn]~^ ERROR: ~const can only be applied to `#[const_trait]`

View File

@ -1,5 +1,5 @@
error: ~const can only be applied to `#[const_trait]` traits error: ~const can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:15:24 --> $DIR/super-traits-fail-3.rs:16:24
| |
LL | const fn foo<T: ~const Bar>(x: &T) { LL | const fn foo<T: ~const Bar>(x: &T) {
| ^^^ | ^^^

View File

@ -2,5 +2,6 @@ trait A<T>: std::ops::Add<Self> + Sized {}
trait B<T>: A<T> {} trait B<T>: A<T> {}
trait C<T>: A<dyn B<T, Output=usize>> {} trait C<T>: A<dyn B<T, Output=usize>> {}
//~^ ERROR the trait `B` cannot be made into an object //~^ ERROR the trait `B` cannot be made into an object
//~| ERROR the trait `B` cannot be made into an object
fn main() {} fn main() {}

View File

@ -12,6 +12,20 @@ LL | trait A<T>: std::ops::Add<Self> + Sized {}
LL | trait B<T>: A<T> {} LL | trait B<T>: A<T> {}
| - this trait cannot be made into an object... | - this trait cannot be made into an object...
error: aborting due to previous error error[E0038]: the trait `B` cannot be made into an object
--> $DIR/issue-38404.rs:3:15
|
LL | trait C<T>: A<dyn B<T, Output=usize>> {}
| ^^^^^^^^^^^^^^^^^^^^^^ `B` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-38404.rs:1:13
|
LL | trait A<T>: std::ops::Add<Self> + Sized {}
| ^^^^^^^^^^^^^^^^^^^ ...because it uses `Self` as a type parameter
LL | trait B<T>: A<T> {}
| - this trait cannot be made into an object...
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0038`. For more information about this error, try `rustc --explain E0038`.

View File

@ -3,6 +3,7 @@ fn foo1<T:Copy<U>, U>(x: T) {}
trait Trait: Copy<dyn Send> {} trait Trait: Copy<dyn Send> {}
//~^ ERROR trait takes 0 generic arguments but 1 generic argument was supplied //~^ ERROR trait takes 0 generic arguments but 1 generic argument was supplied
//~| ERROR trait takes 0 generic arguments but 1 generic argument was supplied
struct MyStruct1<T: Copy<T>>; struct MyStruct1<T: Copy<T>>;
//~^ ERROR trait takes 0 generic arguments but 1 generic argument was supplied //~^ ERROR trait takes 0 generic arguments but 1 generic argument was supplied

View File

@ -15,7 +15,15 @@ LL | trait Trait: Copy<dyn Send> {}
| expected 0 generic arguments | expected 0 generic arguments
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/typeck-builtin-bound-type-parameters.rs:7:21 --> $DIR/typeck-builtin-bound-type-parameters.rs:4:14
|
LL | trait Trait: Copy<dyn Send> {}
| ^^^^---------- help: remove these generics
| |
| expected 0 generic arguments
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/typeck-builtin-bound-type-parameters.rs:8:21
| |
LL | struct MyStruct1<T: Copy<T>>; LL | struct MyStruct1<T: Copy<T>>;
| ^^^^--- help: remove these generics | ^^^^--- help: remove these generics
@ -23,7 +31,7 @@ LL | struct MyStruct1<T: Copy<T>>;
| expected 0 generic arguments | expected 0 generic arguments
error[E0107]: trait takes 0 lifetime arguments but 1 lifetime argument was supplied error[E0107]: trait takes 0 lifetime arguments but 1 lifetime argument was supplied
--> $DIR/typeck-builtin-bound-type-parameters.rs:10:25 --> $DIR/typeck-builtin-bound-type-parameters.rs:11:25
| |
LL | struct MyStruct2<'a, T: Copy<'a>>; LL | struct MyStruct2<'a, T: Copy<'a>>;
| ^^^^---- help: remove these generics | ^^^^---- help: remove these generics
@ -31,7 +39,7 @@ LL | struct MyStruct2<'a, T: Copy<'a>>;
| expected 0 lifetime arguments | expected 0 lifetime arguments
error[E0107]: trait takes 0 lifetime arguments but 1 lifetime argument was supplied error[E0107]: trait takes 0 lifetime arguments but 1 lifetime argument was supplied
--> $DIR/typeck-builtin-bound-type-parameters.rs:13:15 --> $DIR/typeck-builtin-bound-type-parameters.rs:14:15
| |
LL | fn foo2<'a, T:Copy<'a, U>, U>(x: T) {} LL | fn foo2<'a, T:Copy<'a, U>, U>(x: T) {}
| ^^^^ -- help: remove this lifetime argument | ^^^^ -- help: remove this lifetime argument
@ -39,13 +47,13 @@ LL | fn foo2<'a, T:Copy<'a, U>, U>(x: T) {}
| expected 0 lifetime arguments | expected 0 lifetime arguments
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/typeck-builtin-bound-type-parameters.rs:13:15 --> $DIR/typeck-builtin-bound-type-parameters.rs:14:15
| |
LL | fn foo2<'a, T:Copy<'a, U>, U>(x: T) {} LL | fn foo2<'a, T:Copy<'a, U>, U>(x: T) {}
| ^^^^ - help: remove this generic argument | ^^^^ - help: remove this generic argument
| | | |
| expected 0 generic arguments | expected 0 generic arguments
error: aborting due to 6 previous errors error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0107`. For more information about this error, try `rustc --explain E0107`.