1
Fork 0

Auto merge of #121123 - compiler-errors:item-assumptions, r=oli-obk

Split an item bounds and an item's super predicates

This is the moral equivalent of #107614, but instead for predicates this applies to **item bounds**. This PR splits out the item bounds (i.e. *all* predicates that are assumed to hold for the alias) from the item *super predicates*, which are the subset of item bounds which share the same self type as the alias.

## Why?

Much like #107614, there are places in the compiler where we *only* care about super-predicates, and considering predicates that possibly don't have anything to do with the alias is problematic. This includes things like closure signature inference (which is at its core searching for `Self: Fn(..)` style bounds), but also lints like `#[must_use]`, error reporting for aliases, computing type outlives predicates.

Even in cases where considering all of the `item_bounds` doesn't lead to bugs, unnecessarily considering irrelevant bounds does lead to a regression (#121121) due to doing extra work in the solver.

## Example 1 - Trait Aliases

This is best explored via an example:

```
type TAIT<T> = impl TraitAlias<T>;

trait TraitAlias<T> = A + B where T: C;
```

The item bounds list for `Tait<T>` will include:
* `Tait<T>: A`
* `Tait<T>: B`
* `T: C`

While `item_super_predicates` query will include just the first two predicates.

Side-note: You may wonder why `T: C` is included in the item bounds for `TAIT`? This is because when we elaborate `TraitAlias<T>`, we will also elaborate all the predicates on the trait.

## Example 2 - Associated Type Bounds

```
type TAIT<T> = impl Iterator<Item: A>;
```

The `item_bounds` list for `TAIT<T>` will include:
* `Tait<T>: Iterator`
* `<Tait<T> as Iterator>::Item: A`

But the `item_super_predicates` will just include the first bound, since that's the only bound that is relevant to the *alias* itself.

## So what

This leads to some diagnostics duplication just like #107614, but none of it will be user-facing. We only see it in the UI test suite because we explicitly disable diagnostic deduplication.

Regarding naming, I went with `super_predicates` kind of arbitrarily; this can easily be changed, but I'd consider better names as long as we don't block this PR in perpetuity.
This commit is contained in:
bors 2024-03-21 06:12:24 +00:00
commit 47dd709bed
74 changed files with 757 additions and 174 deletions

View file

@ -716,7 +716,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
.copied() .copied()
.find_map(find_fn_kind_from_did), .find_map(find_fn_kind_from_did),
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => tcx ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => tcx
.explicit_item_bounds(def_id) .explicit_item_super_predicates(def_id)
.iter_instantiated_copied(tcx, args) .iter_instantiated_copied(tcx, args)
.find_map(|(clause, span)| find_fn_kind_from_did((clause, span))), .find_map(|(clause, span)| find_fn_kind_from_did((clause, span))),
ty::Closure(_, args) => match args.as_closure().kind() { ty::Closure(_, args) => match args.as_closure().kind() {

View file

@ -431,7 +431,7 @@ fn fn_sig_suggestion<'tcx>(
let asyncness = if tcx.asyncness(assoc.def_id).is_async() { let asyncness = if tcx.asyncness(assoc.def_id).is_async() {
output = if let ty::Alias(_, alias_ty) = *output.kind() { output = if let ty::Alias(_, alias_ty) = *output.kind() {
tcx.explicit_item_bounds(alias_ty.def_id) tcx.explicit_item_super_predicates(alias_ty.def_id)
.iter_instantiated_copied(tcx, alias_ty.args) .iter_instantiated_copied(tcx, alias_ty.args)
.find_map(|(bound, _)| bound.as_projection_clause()?.no_bound_vars()?.term.ty()) .find_map(|(bound, _)| bound.as_projection_clause()?.no_bound_vars()?.term.ty())
.unwrap_or_else(|| { .unwrap_or_else(|| {

View file

@ -61,6 +61,9 @@ pub fn provide(providers: &mut Providers) {
type_alias_is_lazy: type_of::type_alias_is_lazy, type_alias_is_lazy: type_of::type_alias_is_lazy,
item_bounds: item_bounds::item_bounds, item_bounds: item_bounds::item_bounds,
explicit_item_bounds: item_bounds::explicit_item_bounds, explicit_item_bounds: item_bounds::explicit_item_bounds,
item_super_predicates: item_bounds::item_super_predicates,
explicit_item_super_predicates: item_bounds::explicit_item_super_predicates,
item_non_self_assumptions: item_bounds::item_non_self_assumptions,
generics_of: generics_of::generics_of, generics_of: generics_of::generics_of,
predicates_of: predicates_of::predicates_of, predicates_of: predicates_of::predicates_of,
predicates_defined_on, predicates_defined_on,
@ -633,7 +636,9 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
tcx.ensure().generics_of(def_id); tcx.ensure().generics_of(def_id);
tcx.ensure().predicates_of(def_id); tcx.ensure().predicates_of(def_id);
tcx.ensure().explicit_item_bounds(def_id); tcx.ensure().explicit_item_bounds(def_id);
tcx.ensure().explicit_item_super_predicates(def_id);
tcx.ensure().item_bounds(def_id); tcx.ensure().item_bounds(def_id);
tcx.ensure().item_super_predicates(def_id);
} }
hir::ItemKind::TyAlias(..) => { hir::ItemKind::TyAlias(..) => {
@ -689,6 +694,7 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) {
hir::TraitItemKind::Type(_, Some(_)) => { hir::TraitItemKind::Type(_, Some(_)) => {
tcx.ensure().item_bounds(def_id); tcx.ensure().item_bounds(def_id);
tcx.ensure().item_super_predicates(def_id);
tcx.ensure().type_of(def_id); tcx.ensure().type_of(def_id);
// Account for `type T = _;`. // Account for `type T = _;`.
let mut visitor = HirPlaceholderCollector::default(); let mut visitor = HirPlaceholderCollector::default();
@ -698,6 +704,7 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) {
hir::TraitItemKind::Type(_, None) => { hir::TraitItemKind::Type(_, None) => {
tcx.ensure().item_bounds(def_id); tcx.ensure().item_bounds(def_id);
tcx.ensure().item_super_predicates(def_id);
// #74612: Visit and try to find bad placeholders // #74612: Visit and try to find bad placeholders
// even if there is no concrete type. // even if there is no concrete type.
let mut visitor = HirPlaceholderCollector::default(); let mut visitor = HirPlaceholderCollector::default();

View file

@ -1,5 +1,6 @@
use super::ItemCtxt; use super::ItemCtxt;
use crate::astconv::{AstConv, PredicateFilter}; use crate::astconv::{AstConv, PredicateFilter};
use rustc_data_structures::fx::FxIndexSet;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_infer::traits::util; use rustc_infer::traits::util;
use rustc_middle::ty::GenericArgs; use rustc_middle::ty::GenericArgs;
@ -19,6 +20,7 @@ fn associated_type_bounds<'tcx>(
assoc_item_def_id: LocalDefId, assoc_item_def_id: LocalDefId,
ast_bounds: &'tcx [hir::GenericBound<'tcx>], ast_bounds: &'tcx [hir::GenericBound<'tcx>],
span: Span, span: Span,
filter: PredicateFilter,
) -> &'tcx [(ty::Clause<'tcx>, Span)] { ) -> &'tcx [(ty::Clause<'tcx>, Span)] {
let item_ty = Ty::new_projection( let item_ty = Ty::new_projection(
tcx, tcx,
@ -27,7 +29,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, PredicateFilter::All); let mut bounds = icx.astconv().compute_bounds(item_ty, ast_bounds, filter);
// 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);
@ -63,10 +65,11 @@ fn opaque_type_bounds<'tcx>(
ast_bounds: &'tcx [hir::GenericBound<'tcx>], ast_bounds: &'tcx [hir::GenericBound<'tcx>],
item_ty: Ty<'tcx>, item_ty: Ty<'tcx>,
span: Span, span: Span,
filter: PredicateFilter,
) -> &'tcx [(ty::Clause<'tcx>, Span)] { ) -> &'tcx [(ty::Clause<'tcx>, Span)] {
ty::print::with_reduced_queries!({ ty::print::with_reduced_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, PredicateFilter::All); let mut bounds = icx.astconv().compute_bounds(item_ty, ast_bounds, filter);
// 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);
@ -78,6 +81,21 @@ fn opaque_type_bounds<'tcx>(
pub(super) fn explicit_item_bounds( pub(super) fn explicit_item_bounds(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
def_id: LocalDefId, def_id: LocalDefId,
) -> ty::EarlyBinder<&'_ [(ty::Clause<'_>, Span)]> {
explicit_item_bounds_with_filter(tcx, def_id, PredicateFilter::All)
}
pub(super) fn explicit_item_super_predicates(
tcx: TyCtxt<'_>,
def_id: LocalDefId,
) -> ty::EarlyBinder<&'_ [(ty::Clause<'_>, Span)]> {
explicit_item_bounds_with_filter(tcx, def_id, PredicateFilter::SelfOnly)
}
pub(super) fn explicit_item_bounds_with_filter(
tcx: TyCtxt<'_>,
def_id: LocalDefId,
filter: PredicateFilter,
) -> ty::EarlyBinder<&'_ [(ty::Clause<'_>, Span)]> { ) -> ty::EarlyBinder<&'_ [(ty::Clause<'_>, Span)]> {
match tcx.opt_rpitit_info(def_id.to_def_id()) { match tcx.opt_rpitit_info(def_id.to_def_id()) {
// RPITIT's bounds are the same as opaque type bounds, but with // RPITIT's bounds are the same as opaque type bounds, but with
@ -95,6 +113,7 @@ pub(super) fn explicit_item_bounds(
ty::GenericArgs::identity_for_item(tcx, def_id), ty::GenericArgs::identity_for_item(tcx, def_id),
), ),
item.span, item.span,
filter,
)); ));
} }
Some(ty::ImplTraitInTraitData::Impl { .. }) => span_bug!( Some(ty::ImplTraitInTraitData::Impl { .. }) => span_bug!(
@ -109,7 +128,7 @@ pub(super) fn explicit_item_bounds(
kind: hir::TraitItemKind::Type(bounds, _), kind: hir::TraitItemKind::Type(bounds, _),
span, span,
.. ..
}) => associated_type_bounds(tcx, def_id, bounds, *span), }) => associated_type_bounds(tcx, def_id, bounds, *span, filter),
hir::Node::Item(hir::Item { hir::Node::Item(hir::Item {
kind: hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds, in_trait: false, .. }), kind: hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds, in_trait: false, .. }),
span, span,
@ -117,7 +136,7 @@ pub(super) fn explicit_item_bounds(
}) => { }) => {
let args = GenericArgs::identity_for_item(tcx, def_id); let args = GenericArgs::identity_for_item(tcx, def_id);
let item_ty = Ty::new_opaque(tcx, def_id.to_def_id(), args); let item_ty = Ty::new_opaque(tcx, def_id.to_def_id(), args);
opaque_type_bounds(tcx, def_id, bounds, item_ty, *span) opaque_type_bounds(tcx, def_id, bounds, item_ty, *span, filter)
} }
// Since RPITITs are astconv'd as projections in `ast_ty_to_ty`, when we're asking // Since RPITITs are astconv'd as projections in `ast_ty_to_ty`, when we're asking
// for the item bounds of the *opaques* in a trait's default method signature, we // for the item bounds of the *opaques* in a trait's default method signature, we
@ -135,7 +154,7 @@ pub(super) fn explicit_item_bounds(
let args = GenericArgs::identity_for_item(tcx, def_id); let args = GenericArgs::identity_for_item(tcx, def_id);
let item_ty = Ty::new_opaque(tcx, def_id.to_def_id(), args); let item_ty = Ty::new_opaque(tcx, def_id.to_def_id(), args);
tcx.arena.alloc_slice( tcx.arena.alloc_slice(
&opaque_type_bounds(tcx, def_id, bounds, item_ty, *span) &opaque_type_bounds(tcx, def_id, bounds, item_ty, *span, filter)
.to_vec() .to_vec()
.fold_with(&mut AssocTyToOpaque { tcx, fn_def_id: fn_def_id.to_def_id() }), .fold_with(&mut AssocTyToOpaque { tcx, fn_def_id: fn_def_id.to_def_id() }),
) )
@ -155,6 +174,31 @@ pub(super) fn item_bounds(
}) })
} }
pub(super) fn item_super_predicates(
tcx: TyCtxt<'_>,
def_id: DefId,
) -> ty::EarlyBinder<&'_ ty::List<ty::Clause<'_>>> {
tcx.explicit_item_super_predicates(def_id).map_bound(|bounds| {
tcx.mk_clauses_from_iter(
util::elaborate(tcx, bounds.iter().map(|&(bound, _span)| bound)).filter_only_self(),
)
})
}
pub(super) fn item_non_self_assumptions(
tcx: TyCtxt<'_>,
def_id: DefId,
) -> ty::EarlyBinder<&'_ ty::List<ty::Clause<'_>>> {
let all_bounds: FxIndexSet<_> = tcx.item_bounds(def_id).skip_binder().iter().collect();
let own_bounds: FxIndexSet<_> =
tcx.item_super_predicates(def_id).skip_binder().iter().collect();
if all_bounds.len() == own_bounds.len() {
ty::EarlyBinder::bind(ty::List::empty())
} else {
ty::EarlyBinder::bind(tcx.mk_clauses_from_iter(all_bounds.difference(&own_bounds).copied()))
}
}
struct AssocTyToOpaque<'tcx> { struct AssocTyToOpaque<'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
fn_def_id: DefId, fn_def_id: DefId,

View file

@ -645,7 +645,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
for ty in [first_ty, second_ty] { for ty in [first_ty, second_ty] {
for (clause, _) in self for (clause, _) in self
.tcx .tcx
.explicit_item_bounds(rpit_def_id) .explicit_item_super_predicates(rpit_def_id)
.iter_instantiated_copied(self.tcx, args) .iter_instantiated_copied(self.tcx, args)
{ {
let pred = clause.kind().rebind(match clause.kind().skip_binder() { let pred = clause.kind().rebind(match clause.kind().skip_binder() {

View file

@ -329,7 +329,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
expected_ty, expected_ty,
closure_kind, closure_kind,
self.tcx self.tcx
.explicit_item_bounds(def_id) .explicit_item_super_predicates(def_id)
.iter_instantiated_copied(self.tcx, args) .iter_instantiated_copied(self.tcx, args)
.map(|(c, s)| (c.as_predicate(), s)), .map(|(c, s)| (c.as_predicate(), s)),
), ),
@ -906,7 +906,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => self ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => self
.tcx .tcx
.explicit_item_bounds(def_id) .explicit_item_super_predicates(def_id)
.iter_instantiated_copied(self.tcx, args) .iter_instantiated_copied(self.tcx, args)
.find_map(|(p, s)| get_future_output(p.as_predicate(), s))?, .find_map(|(p, s)| get_future_output(p.as_predicate(), s))?,
ty::Error(_) => return Some(ret_ty), ty::Error(_) => return Some(ret_ty),

View file

@ -403,8 +403,10 @@ impl<'tcx> InferCtxt<'tcx> {
let future_trait = self.tcx.require_lang_item(LangItem::Future, None); let future_trait = self.tcx.require_lang_item(LangItem::Future, None);
let item_def_id = self.tcx.associated_item_def_ids(future_trait)[0]; let item_def_id = self.tcx.associated_item_def_ids(future_trait)[0];
self.tcx.explicit_item_bounds(def_id).iter_instantiated_copied(self.tcx, args).find_map( self.tcx
|(predicate, _)| { .explicit_item_super_predicates(def_id)
.iter_instantiated_copied(self.tcx, args)
.find_map(|(predicate, _)| {
predicate predicate
.kind() .kind()
.map_bound(|kind| match kind { .map_bound(|kind| match kind {
@ -417,8 +419,7 @@ impl<'tcx> InferCtxt<'tcx> {
}) })
.no_bound_vars() .no_bound_vars()
.flatten() .flatten()
}, })
)
} }
} }

View file

@ -299,8 +299,11 @@ impl<T> Trait<T> for X {
} }
(ty::Dynamic(t, _, ty::DynKind::Dyn), ty::Alias(ty::Opaque, alias)) (ty::Dynamic(t, _, ty::DynKind::Dyn), ty::Alias(ty::Opaque, alias))
if let Some(def_id) = t.principal_def_id() if let Some(def_id) = t.principal_def_id()
&& tcx.explicit_item_bounds(alias.def_id).skip_binder().iter().any( && tcx
|(pred, _span)| match pred.kind().skip_binder() { .explicit_item_super_predicates(alias.def_id)
.skip_binder()
.iter()
.any(|(pred, _span)| match pred.kind().skip_binder() {
ty::ClauseKind::Trait(trait_predicate) ty::ClauseKind::Trait(trait_predicate)
if trait_predicate.polarity if trait_predicate.polarity
== ty::ImplPolarity::Positive => == ty::ImplPolarity::Positive =>
@ -308,8 +311,7 @@ impl<T> Trait<T> for X {
trait_predicate.def_id() == def_id trait_predicate.def_id() == def_id
} }
_ => false, _ => false,
}, }) =>
) =>
{ {
diag.help(format!( diag.help(format!(
"you can box the `{}` to coerce it to `Box<{}>`, but you'll have to \ "you can box the `{}` to coerce it to `Box<{}>`, but you'll have to \
@ -412,7 +414,7 @@ impl<T> Trait<T> for X {
ty::Alias(..) => values.expected, ty::Alias(..) => values.expected,
_ => values.found, _ => values.found,
}; };
let preds = tcx.explicit_item_bounds(opaque_ty.def_id); let preds = tcx.explicit_item_super_predicates(opaque_ty.def_id);
for (pred, _span) in preds.skip_binder() { for (pred, _span) in preds.skip_binder() {
let ty::ClauseKind::Trait(trait_predicate) = pred.kind().skip_binder() let ty::ClauseKind::Trait(trait_predicate) = pred.kind().skip_binder()
else { else {

View file

@ -300,7 +300,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
alias_ty: ty::AliasTy<'tcx>, alias_ty: ty::AliasTy<'tcx>,
) -> impl Iterator<Item = ty::Region<'tcx>> { ) -> impl Iterator<Item = ty::Region<'tcx>> {
let tcx = self.tcx; let tcx = self.tcx;
let bounds = tcx.item_bounds(alias_ty.def_id); let bounds = tcx.item_super_predicates(alias_ty.def_id);
trace!("{:#?}", bounds.skip_binder()); trace!("{:#?}", bounds.skip_binder());
bounds bounds
.iter_instantiated(tcx, alias_ty.args) .iter_instantiated(tcx, alias_ty.args)

View file

@ -295,7 +295,9 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
ty::Alias(ty::Opaque | ty::Projection, ty::AliasTy { def_id: def, .. }) => { ty::Alias(ty::Opaque | ty::Projection, ty::AliasTy { def_id: def, .. }) => {
elaborate( elaborate(
cx.tcx, cx.tcx,
cx.tcx.explicit_item_bounds(def).instantiate_identity_iter_copied(), cx.tcx
.explicit_item_super_predicates(def)
.instantiate_identity_iter_copied(),
) )
// We only care about self bounds for the impl-trait // We only care about self bounds for the impl-trait
.filter_only_self() .filter_only_self()

View file

@ -1063,6 +1063,20 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
ty::EarlyBinder::bind(&*output) ty::EarlyBinder::bind(&*output)
} }
fn get_explicit_item_super_predicates(
self,
index: DefIndex,
tcx: TyCtxt<'tcx>,
) -> ty::EarlyBinder<&'tcx [(ty::Clause<'tcx>, Span)]> {
let lazy = self.root.tables.explicit_item_super_predicates.get(self, index);
let output = if lazy.is_default() {
&mut []
} else {
tcx.arena.alloc_from_iter(lazy.decode((self, tcx)))
};
ty::EarlyBinder::bind(&*output)
}
fn get_variant( fn get_variant(
self, self,
kind: DefKind, kind: DefKind,

View file

@ -206,6 +206,7 @@ impl IntoArgs for (CrateNum, SimplifiedType) {
provide! { tcx, def_id, other, cdata, provide! { tcx, def_id, other, cdata,
explicit_item_bounds => { cdata.get_explicit_item_bounds(def_id.index, tcx) } explicit_item_bounds => { cdata.get_explicit_item_bounds(def_id.index, tcx) }
explicit_item_super_predicates => { cdata.get_explicit_item_super_predicates(def_id.index, tcx) }
explicit_predicates_of => { table } explicit_predicates_of => { table }
generics_of => { table } generics_of => { table }
inferred_outlives_of => { table_defaulted_array } inferred_outlives_of => { table_defaulted_array }

View file

@ -1491,6 +1491,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
} }
if let DefKind::OpaqueTy = def_kind { if let DefKind::OpaqueTy = def_kind {
self.encode_explicit_item_bounds(def_id); self.encode_explicit_item_bounds(def_id);
self.encode_explicit_item_super_predicates(def_id);
self.tables self.tables
.is_type_alias_impl_trait .is_type_alias_impl_trait
.set(def_id.index, self.tcx.is_type_alias_impl_trait(def_id)); .set(def_id.index, self.tcx.is_type_alias_impl_trait(def_id));
@ -1599,6 +1600,12 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
record_defaulted_array!(self.tables.explicit_item_bounds[def_id] <- bounds); record_defaulted_array!(self.tables.explicit_item_bounds[def_id] <- bounds);
} }
fn encode_explicit_item_super_predicates(&mut self, def_id: DefId) {
debug!("EncodeContext::encode_explicit_item_super_predicates({:?})", def_id);
let bounds = self.tcx.explicit_item_super_predicates(def_id).skip_binder();
record_defaulted_array!(self.tables.explicit_item_super_predicates[def_id] <- bounds);
}
#[instrument(level = "debug", skip(self))] #[instrument(level = "debug", skip(self))]
fn encode_info_for_assoc_item(&mut self, def_id: DefId) { fn encode_info_for_assoc_item(&mut self, def_id: DefId) {
let tcx = self.tcx; let tcx = self.tcx;
@ -1611,6 +1618,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
AssocItemContainer::TraitContainer => { AssocItemContainer::TraitContainer => {
if let ty::AssocKind::Type = item.kind { if let ty::AssocKind::Type = item.kind {
self.encode_explicit_item_bounds(def_id); self.encode_explicit_item_bounds(def_id);
self.encode_explicit_item_super_predicates(def_id);
} }
} }
AssocItemContainer::ImplContainer => { AssocItemContainer::ImplContainer => {

View file

@ -387,6 +387,7 @@ define_tables! {
// corresponding DefPathHash. // corresponding DefPathHash.
def_path_hashes: Table<DefIndex, u64>, def_path_hashes: Table<DefIndex, u64>,
explicit_item_bounds: Table<DefIndex, LazyArray<(ty::Clause<'static>, Span)>>, explicit_item_bounds: Table<DefIndex, LazyArray<(ty::Clause<'static>, Span)>>,
explicit_item_super_predicates: Table<DefIndex, LazyArray<(ty::Clause<'static>, Span)>>,
inferred_outlives_of: Table<DefIndex, LazyArray<(ty::Clause<'static>, Span)>>, inferred_outlives_of: Table<DefIndex, LazyArray<(ty::Clause<'static>, Span)>>,
inherent_impls: Table<DefIndex, LazyArray<DefIndex>>, inherent_impls: Table<DefIndex, LazyArray<DefIndex>>,
associated_types_for_impl_traits_in_associated_fn: Table<DefIndex, LazyArray<DefId>>, associated_types_for_impl_traits_in_associated_fn: Table<DefIndex, LazyArray<DefId>>,

View file

@ -343,11 +343,14 @@ rustc_queries! {
} }
} }
/// Returns the list of bounds that can be used for /// Returns the list of bounds that are required to be satsified
/// `SelectionCandidate::ProjectionCandidate(_)` and /// by a implementation or definition. For associated types, these
/// `ProjectionTyCandidate::TraitDef`. /// must be satisfied for an implementation to be well-formed,
/// Specifically this is the bounds written on the trait's type /// and for opaque types, these are required to be satisfied by
/// definition, or those after the `impl` keyword /// the hidden-type of the opaque.
///
/// Syntactially, these are the bounds written on the trait's type
/// definition, or those after the `impl` keyword for an opaque:
/// ///
/// ```ignore (incomplete) /// ```ignore (incomplete)
/// type X: Bound + 'lt /// type X: Bound + 'lt
@ -363,7 +366,16 @@ rustc_queries! {
desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) } desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) }
cache_on_disk_if { key.is_local() } cache_on_disk_if { key.is_local() }
separate_provide_extern separate_provide_extern
feedable }
/// The set of item bounds (see [`TyCtxt::explicit_item_bounds`]) that
/// share the `Self` type of the item. These are a subset of the bounds
/// that may explicitly be used for things like closure signature
/// deduction.
query explicit_item_super_predicates(key: DefId) -> ty::EarlyBinder<&'tcx [(ty::Clause<'tcx>, Span)]> {
desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) }
cache_on_disk_if { key.is_local() }
separate_provide_extern
} }
/// Elaborated version of the predicates from `explicit_item_bounds`. /// Elaborated version of the predicates from `explicit_item_bounds`.
@ -390,6 +402,14 @@ rustc_queries! {
desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) } desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) }
} }
query item_super_predicates(key: DefId) -> ty::EarlyBinder<&'tcx ty::List<ty::Clause<'tcx>>> {
desc { |tcx| "elaborating item assumptions for `{}`", tcx.def_path_str(key) }
}
query item_non_self_assumptions(key: DefId) -> ty::EarlyBinder<&'tcx ty::List<ty::Clause<'tcx>>> {
desc { |tcx| "elaborating item assumptions for `{}`", tcx.def_path_str(key) }
}
/// Look up all native libraries this crate depends on. /// Look up all native libraries this crate depends on.
/// These are assembled from the following places: /// These are assembled from the following places:
/// - `extern` blocks (depending on their `link` attributes) /// - `extern` blocks (depending on their `link` attributes)

View file

@ -1828,7 +1828,7 @@ impl<'tcx> TyCtxt<'tcx> {
let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = ty.kind() else { return false }; let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = ty.kind() else { return false };
let future_trait = self.require_lang_item(LangItem::Future, None); let future_trait = self.require_lang_item(LangItem::Future, None);
self.explicit_item_bounds(def_id).skip_binder().iter().any(|&(predicate, _)| { self.explicit_item_super_predicates(def_id).skip_binder().iter().any(|&(predicate, _)| {
let ty::ClauseKind::Trait(trait_predicate) = predicate.kind().skip_binder() else { let ty::ClauseKind::Trait(trait_predicate) = predicate.kind().skip_binder() else {
return false; return false;
}; };

View file

@ -1098,8 +1098,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
)) ))
} }
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => { ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => {
self.tcx.item_bounds(def_id).instantiate(self.tcx, args).iter().find_map( self.tcx
|pred| { .item_super_predicates(def_id)
.instantiate(self.tcx, args)
.iter()
.find_map(|pred| {
if let ty::ClauseKind::Projection(proj) = pred.kind().skip_binder() if let ty::ClauseKind::Projection(proj) = pred.kind().skip_binder()
&& Some(proj.projection_ty.def_id) == self.tcx.lang_items().fn_once_output() && Some(proj.projection_ty.def_id) == self.tcx.lang_items().fn_once_output()
// args tuple will always be args[1] // args tuple will always be args[1]
@ -1113,8 +1116,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
} else { } else {
None None
} }
}, })
)
} }
ty::Dynamic(data, _, ty::Dyn) => { ty::Dynamic(data, _, ty::Dyn) => {
data.iter().find_map(|pred| { data.iter().find_map(|pred| {

View file

@ -1617,21 +1617,17 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
_ => return ControlFlow::Continue(()), _ => return ControlFlow::Continue(()),
}; };
for bound in // HACK: On subsequent recursions, we only care about bounds that don't
self.tcx().item_bounds(alias_ty.def_id).instantiate(self.tcx(), alias_ty.args) // share the same type as `self_ty`. This is because for truly rigid
{ // projections, we will never be able to equate, e.g. `<T as Tr>::A`
// HACK: On subsequent recursions, we only care about bounds that don't // with `<<T as Tr>::A as Tr>::A`.
// share the same type as `self_ty`. This is because for truly rigid let relevant_bounds = if in_parent_alias_type {
// projections, we will never be able to equate, e.g. `<T as Tr>::A` self.tcx().item_non_self_assumptions(alias_ty.def_id)
// with `<<T as Tr>::A as Tr>::A`. } else {
if in_parent_alias_type { self.tcx().item_super_predicates(alias_ty.def_id)
match bound.kind().skip_binder() { };
ty::ClauseKind::Trait(tr) if tr.self_ty() == self_ty => continue,
ty::ClauseKind::Projection(p) if p.self_ty() == self_ty => continue,
_ => {}
}
}
for bound in relevant_bounds.instantiate(self.tcx(), alias_ty.args) {
for_each(self, bound, idx)?; for_each(self, bound, idx)?;
idx += 1; idx += 1;
} }

View file

@ -64,7 +64,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
} }
let ret_ty = return_ty(cx, cx.tcx.local_def_id_to_hir_id(fn_def_id).expect_owner()); let ret_ty = return_ty(cx, cx.tcx.local_def_id_to_hir_id(fn_def_id).expect_owner());
if let ty::Alias(ty::Opaque, AliasTy { def_id, args, .. }) = *ret_ty.kind() { if let ty::Alias(ty::Opaque, AliasTy { def_id, args, .. }) = *ret_ty.kind() {
let preds = cx.tcx.explicit_item_bounds(def_id); let preds = cx.tcx.explicit_item_super_predicates(def_id);
let mut is_future = false; let mut is_future = false;
for (p, _span) in preds.iter_instantiated_copied(cx.tcx, args) { for (p, _span) in preds.iter_instantiated_copied(cx.tcx, args) {
if let Some(trait_pred) = p.as_trait_clause() { if let Some(trait_pred) = p.as_trait_clause() {

View file

@ -96,7 +96,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
return false; return false;
} }
for (predicate, _span) in cx.tcx.explicit_item_bounds(def_id).instantiate_identity_iter_copied() { for (predicate, _span) in cx.tcx.explicit_item_super_predicates(def_id).instantiate_identity_iter_copied() {
match predicate.kind().skip_binder() { match predicate.kind().skip_binder() {
// For `impl Trait<U>`, it will register a predicate of `T: Trait<U>`, so we go through // For `impl Trait<U>`, it will register a predicate of `T: Trait<U>`, so we go through
// and check substitutions to find `U`. // and check substitutions to find `U`.
@ -328,7 +328,7 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
}, },
ty::Tuple(args) => args.iter().any(|ty| is_must_use_ty(cx, ty)), ty::Tuple(args) => args.iter().any(|ty| is_must_use_ty(cx, ty)),
ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => { ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => {
for (predicate, _) in cx.tcx.explicit_item_bounds(def_id).skip_binder() { for (predicate, _) in cx.tcx.explicit_item_super_predicates(def_id).skip_binder() {
if let ty::ClauseKind::Trait(trait_predicate) = predicate.kind().skip_binder() { if let ty::ClauseKind::Trait(trait_predicate) = predicate.kind().skip_binder() {
if cx.tcx.has_attr(trait_predicate.trait_ref.def_id, sym::must_use) { if cx.tcx.has_attr(trait_predicate.trait_ref.def_id, sym::must_use) {
return true; return true;
@ -729,7 +729,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<ExprFnSig<'t
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => sig_from_bounds( ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => sig_from_bounds(
cx, cx,
ty, ty,
cx.tcx.item_bounds(def_id).iter_instantiated(cx.tcx, args), cx.tcx.item_super_predicates(def_id).iter_instantiated(cx.tcx, args),
cx.tcx.opt_parent(def_id), cx.tcx.opt_parent(def_id),
), ),
ty::FnPtr(sig) => Some(ExprFnSig::Sig(sig, None)), ty::FnPtr(sig) => Some(ExprFnSig::Sig(sig, None)),
@ -807,7 +807,7 @@ fn sig_for_projection<'tcx>(cx: &LateContext<'tcx>, ty: AliasTy<'tcx>) -> Option
for (pred, _) in cx for (pred, _) in cx
.tcx .tcx
.explicit_item_bounds(ty.def_id) .explicit_item_super_predicates(ty.def_id)
.iter_instantiated_copied(cx.tcx, ty.args) .iter_instantiated_copied(cx.tcx, ty.args)
{ {
match pred.kind().skip_binder() { match pred.kind().skip_binder() {

View file

@ -3,6 +3,7 @@
trait T { trait T {
type A: S<C<X = 0i32> = 34>; type A: S<C<X = 0i32> = 34>;
//~^ ERROR associated type bindings are not allowed here //~^ ERROR associated type bindings are not allowed here
//~| ERROR associated type bindings are not allowed here
} }
trait S { trait S {

View file

@ -4,6 +4,14 @@ error[E0229]: associated type bindings are not allowed here
LL | type A: S<C<X = 0i32> = 34>; LL | type A: S<C<X = 0i32> = 34>;
| ^^^^^^^^ associated type not allowed here | ^^^^^^^^ associated type not allowed here
error: aborting due to 1 previous error error[E0229]: associated type bindings are not allowed here
--> $DIR/invalid_associated_const.rs:4:17
|
LL | type A: S<C<X = 0i32> = 34>;
| ^^^^^^^^ associated type not allowed here
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0229`. For more information about this error, try `rustc --explain E0229`.

View file

@ -6,6 +6,7 @@
trait T { trait T {
type A: S<C<X = 0i32> = 34>; type A: S<C<X = 0i32> = 34>;
//~^ ERROR associated type bindings are not allowed here //~^ ERROR associated type bindings are not allowed here
//~| ERROR associated type bindings are not allowed here
} }
trait S { trait S {

View file

@ -4,6 +4,14 @@ error[E0229]: associated type bindings are not allowed here
LL | type A: S<C<X = 0i32> = 34>; LL | type A: S<C<X = 0i32> = 34>;
| ^^^^^^^^ associated type not allowed here | ^^^^^^^^ associated type not allowed here
error: aborting due to 1 previous error error[E0229]: associated type bindings are not allowed here
--> $DIR/issue-102467.rs:7:17
|
LL | type A: S<C<X = 0i32> = 34>;
| ^^^^^^^^ associated type not allowed here
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0229`. For more information about this error, try `rustc --explain E0229`.

View file

@ -6,6 +6,7 @@ pub trait TraitWithAssoc {
pub type Foo<V> = impl Trait<V::Assoc>; pub type Foo<V> = impl Trait<V::Assoc>;
//~^ ERROR //~^ ERROR
//~| ERROR
pub trait Trait<U> {} pub trait Trait<U> {}

View file

@ -9,6 +9,18 @@ help: consider restricting type parameter `V`
LL | pub type Foo<V: TraitWithAssoc> = impl Trait<V::Assoc>; LL | pub type Foo<V: TraitWithAssoc> = impl Trait<V::Assoc>;
| ++++++++++++++++ | ++++++++++++++++
error: aborting due to 1 previous error error[E0220]: associated type `Assoc` not found for `V`
--> $DIR/issue-96287.rs:7:33
|
LL | pub type Foo<V> = impl Trait<V::Assoc>;
| ^^^^^ there is an associated type `Assoc` in the trait `TraitWithAssoc`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: consider restricting type parameter `V`
|
LL | pub type Foo<V: TraitWithAssoc> = impl Trait<V::Assoc>;
| ++++++++++++++++
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0220`. For more information about this error, try `rustc --explain E0220`.

View file

@ -37,8 +37,10 @@ fn take2<P: Project<SELF = {}>>(_: P) {}
trait Iface<'r> { trait Iface<'r> {
//~^ NOTE the lifetime parameter `'r` is defined here //~^ NOTE the lifetime parameter `'r` is defined here
//~| NOTE the lifetime parameter `'r` is defined here
type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }> type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
//~^ ERROR the type of the associated constant `K` must not depend on generic parameters //~^ ERROR the type of the associated constant `K` must not depend on generic parameters
//~| ERROR the type of the associated constant `K` must not depend on generic parameters
//~| NOTE its type must not depend on the lifetime parameter `'r` //~| NOTE its type must not depend on the lifetime parameter `'r`
//~| NOTE `K` has type `&'r [Self; Q]` //~| NOTE `K` has type `&'r [Self; Q]`
//~| ERROR the type of the associated constant `K` must not depend on `Self` //~| ERROR the type of the associated constant `K` must not depend on `Self`
@ -48,6 +50,18 @@ trait Iface<'r> {
//~| NOTE its type must not depend on the const parameter `Q` //~| NOTE its type must not depend on the const parameter `Q`
//~| NOTE the const parameter `Q` is defined here //~| NOTE the const parameter `Q` is defined here
//~| NOTE `K` has type `&'r [Self; Q]` //~| NOTE `K` has type `&'r [Self; Q]`
//~| NOTE its type must not depend on the lifetime parameter `'r`
//~| NOTE `K` has type `&'r [Self; Q]`
//~| ERROR the type of the associated constant `K` must not depend on `Self`
//~| NOTE its type must not depend on `Self`
//~| NOTE `K` has type `&'r [Self; Q]`
//~| ERROR the type of the associated constant `K` must not depend on generic parameters
//~| NOTE its type must not depend on the const parameter `Q`
//~| NOTE the const parameter `Q` is defined here
//~| NOTE `K` has type `&'r [Self; Q]`
//~| NOTE duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
//~| NOTE duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
//~| NOTE duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
where where
Self: Sized + 'r; Self: Sized + 'r;
} }

View file

@ -44,18 +44,18 @@ LL | fn take2<P: Project<SELF = {}>>(_: P) {}
= note: `SELF` has type `P` = note: `SELF` has type `P`
error: the type of the associated constant `K` must not depend on generic parameters error: the type of the associated constant `K` must not depend on generic parameters
--> $DIR/assoc-const-eq-param-in-ty.rs:40:52 --> $DIR/assoc-const-eq-param-in-ty.rs:41:52
| |
LL | trait Iface<'r> { LL | trait Iface<'r> {
| -- the lifetime parameter `'r` is defined here | -- the lifetime parameter `'r` is defined here
LL | ...
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }> LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
| ^ its type must not depend on the lifetime parameter `'r` | ^ its type must not depend on the lifetime parameter `'r`
| |
= note: `K` has type `&'r [Self; Q]` = note: `K` has type `&'r [Self; Q]`
error: the type of the associated constant `K` must not depend on `Self` error: the type of the associated constant `K` must not depend on `Self`
--> $DIR/assoc-const-eq-param-in-ty.rs:40:52 --> $DIR/assoc-const-eq-param-in-ty.rs:41:52
| |
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }> LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
| ^ its type must not depend on `Self` | ^ its type must not depend on `Self`
@ -63,7 +63,7 @@ LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
= note: `K` has type `&'r [Self; Q]` = note: `K` has type `&'r [Self; Q]`
error: the type of the associated constant `K` must not depend on generic parameters error: the type of the associated constant `K` must not depend on generic parameters
--> $DIR/assoc-const-eq-param-in-ty.rs:40:52 --> $DIR/assoc-const-eq-param-in-ty.rs:41:52
| |
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }> LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
| - ^ its type must not depend on the const parameter `Q` | - ^ its type must not depend on the const parameter `Q`
@ -72,5 +72,37 @@ LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
| |
= note: `K` has type `&'r [Self; Q]` = note: `K` has type `&'r [Self; Q]`
error: aborting due to 8 previous errors error: the type of the associated constant `K` must not depend on generic parameters
--> $DIR/assoc-const-eq-param-in-ty.rs:41:52
|
LL | trait Iface<'r> {
| -- the lifetime parameter `'r` is defined here
...
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
| ^ its type must not depend on the lifetime parameter `'r`
|
= note: `K` has type `&'r [Self; Q]`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: the type of the associated constant `K` must not depend on `Self`
--> $DIR/assoc-const-eq-param-in-ty.rs:41:52
|
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
| ^ its type must not depend on `Self`
|
= note: `K` has type `&'r [Self; Q]`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: the type of the associated constant `K` must not depend on generic parameters
--> $DIR/assoc-const-eq-param-in-ty.rs:41:52
|
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
| - ^ its type must not depend on the const parameter `Q`
| |
| the const parameter `Q` is defined here
|
= note: `K` has type `&'r [Self; Q]`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 11 previous errors

View file

@ -3,6 +3,7 @@
trait T { trait T {
type A: S<C<X = 0i32> = 34>; type A: S<C<X = 0i32> = 34>;
//~^ ERROR associated type bindings are not allowed here //~^ ERROR associated type bindings are not allowed here
//~| ERROR associated type bindings are not allowed here
} }
trait S { trait S {

View file

@ -4,6 +4,14 @@ error[E0229]: associated type bindings are not allowed here
LL | type A: S<C<X = 0i32> = 34>; LL | type A: S<C<X = 0i32> = 34>;
| ^^^^^^^^ associated type not allowed here | ^^^^^^^^ associated type not allowed here
error: aborting due to 1 previous error error[E0229]: associated type bindings are not allowed here
--> $DIR/issue-102335-const.rs:4:17
|
LL | type A: S<C<X = 0i32> = 34>;
| ^^^^^^^^ associated type not allowed here
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0229`. For more information about this error, try `rustc --explain E0229`.

View file

@ -7,7 +7,9 @@ impl Lexer<i32> {
type Cursor = (); type Cursor = ();
} }
type X = impl for<T> Fn() -> Lexer<T>::Cursor; //~ ERROR associated type `Cursor` not found for `Lexer<T>` in the current scope type X = impl for<T> Fn() -> Lexer<T>::Cursor;
//~^ ERROR: unconstrained opaque type //~^ ERROR associated type `Cursor` not found for `Lexer<T>` in the current scope
//~| ERROR associated type `Cursor` not found for `Lexer<T>` in the current scope
//~| ERROR: unconstrained opaque type
fn main() {} fn main() {}

View file

@ -10,6 +10,19 @@ LL | type X = impl for<T> Fn() -> Lexer<T>::Cursor;
= note: the associated type was found for = note: the associated type was found for
- `Lexer<i32>` - `Lexer<i32>`
error[E0220]: associated type `Cursor` not found for `Lexer<T>` in the current scope
--> $DIR/issue-109299-1.rs:10:40
|
LL | struct Lexer<T>(T);
| --------------- associated item `Cursor` not found for this struct
...
LL | type X = impl for<T> Fn() -> Lexer<T>::Cursor;
| ^^^^^^ associated item not found in `Lexer<T>`
|
= note: the associated type was found for
- `Lexer<i32>`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: unconstrained opaque type error: unconstrained opaque type
--> $DIR/issue-109299-1.rs:10:10 --> $DIR/issue-109299-1.rs:10:10
| |
@ -18,6 +31,6 @@ LL | type X = impl for<T> Fn() -> Lexer<T>::Cursor;
| |
= note: `X` must be used in combination with a concrete type within the same module = note: `X` must be used in combination with a concrete type within the same module
error: aborting due to 2 previous errors error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0220`. For more information about this error, try `rustc --explain E0220`.

View file

@ -0,0 +1,21 @@
//@ check-pass
#![feature(type_alias_impl_trait)]
trait IsPtr {
type Assoc;
}
impl<T> IsPtr for T {
type Assoc = fn(i32);
}
type Tait = impl IsPtr<Assoc: Fn(i32)> + Fn(u32);
fn hello()
where
Tait:,
{
let _: Tait = |x| {};
}
fn main() {}

View file

@ -132,16 +132,19 @@ where
fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> { fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> {
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
iter::empty() iter::empty()
//~^ ERROR type annotations needed //~^ ERROR type annotations needed
} }
fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> { fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> {
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
iter::empty() iter::empty()
//~^ ERROR type annotations needed //~^ ERROR type annotations needed
} }
fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> { fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> {
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
iter::empty() iter::empty()
//~^ ERROR type annotations needed //~^ ERROR type annotations needed
} }
@ -182,10 +185,13 @@ type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy;
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
type ETAI4 = impl Iterator<Item: Copy, Item: Send>; type ETAI4 = impl Iterator<Item: Copy, Item: Send>;
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
type ETAI5 = impl Iterator<Item: Copy, Item: Copy>; type ETAI5 = impl Iterator<Item: Copy, Item: Copy>;
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
type ETAI6 = impl Iterator<Item: 'static, Item: 'static>; type ETAI6 = impl Iterator<Item: 'static, Item: 'static>;
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
trait TRI1<T: Iterator<Item: Copy, Item: Send>> {} trait TRI1<T: Iterator<Item: Copy, Item: Send>> {}
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
@ -250,14 +256,17 @@ where
trait TRA1 { trait TRA1 {
type A: Iterator<Item: Copy, Item: Send>; type A: Iterator<Item: Copy, Item: Send>;
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
} }
trait TRA2 { trait TRA2 {
type A: Iterator<Item: Copy, Item: Copy>; type A: Iterator<Item: Copy, Item: Copy>;
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
} }
trait TRA3 { trait TRA3 {
type A: Iterator<Item: 'static, Item: 'static>; type A: Iterator<Item: 'static, Item: 'static>;
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
} }
fn main() {} fn main() {}

View file

@ -198,8 +198,18 @@ LL | fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> {
| | | |
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:133:42
|
LL | fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> {
| ---------- ^^^^^^^^^^ re-bound here
| |
| `Item` bound here first
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0282]: type annotations needed error[E0282]: type annotations needed
--> $DIR/duplicate.rs:135:5 --> $DIR/duplicate.rs:136:5
| |
LL | iter::empty() LL | iter::empty()
| ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty` | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty`
@ -210,15 +220,25 @@ LL | iter::empty::<T>()
| +++++ | +++++
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:138:42 --> $DIR/duplicate.rs:139:42
| |
LL | fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> { LL | fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> {
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
| | | |
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:139:42
|
LL | fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> {
| ---------- ^^^^^^^^^^ re-bound here
| |
| `Item` bound here first
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0282]: type annotations needed error[E0282]: type annotations needed
--> $DIR/duplicate.rs:140:5 --> $DIR/duplicate.rs:142:5
| |
LL | iter::empty() LL | iter::empty()
| ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty` | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty`
@ -229,15 +249,25 @@ LL | iter::empty::<T>()
| +++++ | +++++
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:143:45 --> $DIR/duplicate.rs:145:45
| |
LL | fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> { LL | fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> {
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
| | | |
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:145:45
|
LL | fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> {
| ------------- ^^^^^^^^^^^^^ re-bound here
| |
| `Item` bound here first
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0282]: type annotations needed error[E0282]: type annotations needed
--> $DIR/duplicate.rs:145:5 --> $DIR/duplicate.rs:148:5
| |
LL | iter::empty() LL | iter::empty()
| ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty` | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty`
@ -248,7 +278,7 @@ LL | iter::empty::<T>()
| +++++ | +++++
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:148:40 --> $DIR/duplicate.rs:151:40
| |
LL | fn FAPIT1(_: impl Iterator<Item: Copy, Item: Send>) {} LL | fn FAPIT1(_: impl Iterator<Item: Copy, Item: Send>) {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -256,7 +286,7 @@ LL | fn FAPIT1(_: impl Iterator<Item: Copy, Item: Send>) {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:150:40 --> $DIR/duplicate.rs:153:40
| |
LL | fn FAPIT2(_: impl Iterator<Item: Copy, Item: Copy>) {} LL | fn FAPIT2(_: impl Iterator<Item: Copy, Item: Copy>) {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -264,7 +294,7 @@ LL | fn FAPIT2(_: impl Iterator<Item: Copy, Item: Copy>) {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:152:43 --> $DIR/duplicate.rs:155:43
| |
LL | fn FAPIT3(_: impl Iterator<Item: 'static, Item: 'static>) {} LL | fn FAPIT3(_: impl Iterator<Item: 'static, Item: 'static>) {}
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -272,7 +302,7 @@ LL | fn FAPIT3(_: impl Iterator<Item: 'static, Item: 'static>) {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:155:35 --> $DIR/duplicate.rs:158:35
| |
LL | type TAI1<T: Iterator<Item: Copy, Item: Send>> = T; LL | type TAI1<T: Iterator<Item: Copy, Item: Send>> = T;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -280,7 +310,7 @@ LL | type TAI1<T: Iterator<Item: Copy, Item: Send>> = T;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:157:35 --> $DIR/duplicate.rs:160:35
| |
LL | type TAI2<T: Iterator<Item: Copy, Item: Copy>> = T; LL | type TAI2<T: Iterator<Item: Copy, Item: Copy>> = T;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -288,7 +318,7 @@ LL | type TAI2<T: Iterator<Item: Copy, Item: Copy>> = T;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:159:38 --> $DIR/duplicate.rs:162:38
| |
LL | type TAI3<T: Iterator<Item: 'static, Item: 'static>> = T; LL | type TAI3<T: Iterator<Item: 'static, Item: 'static>> = T;
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -296,7 +326,7 @@ LL | type TAI3<T: Iterator<Item: 'static, Item: 'static>> = T;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:163:29 --> $DIR/duplicate.rs:166:29
| |
LL | T: Iterator<Item: Copy, Item: Send>, LL | T: Iterator<Item: Copy, Item: Send>,
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -304,7 +334,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` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:168:29 --> $DIR/duplicate.rs:171:29
| |
LL | T: Iterator<Item: Copy, Item: Copy>, LL | T: Iterator<Item: Copy, Item: Copy>,
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -312,7 +342,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` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:173:32 --> $DIR/duplicate.rs:176:32
| |
LL | T: Iterator<Item: 'static, Item: 'static>, LL | T: Iterator<Item: 'static, Item: 'static>,
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -320,7 +350,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` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:177:36 --> $DIR/duplicate.rs:180:36
| |
LL | type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy; LL | type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -328,7 +358,7 @@ LL | type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:179:36 --> $DIR/duplicate.rs:182:36
| |
LL | type ETAI2<T: Iterator<Item: Copy, Item: Copy>> = impl Copy; LL | type ETAI2<T: Iterator<Item: Copy, Item: Copy>> = impl Copy;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -336,7 +366,7 @@ LL | type ETAI2<T: Iterator<Item: Copy, Item: Copy>> = impl Copy;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:181:39 --> $DIR/duplicate.rs:184:39
| |
LL | type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy; LL | type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy;
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -344,7 +374,7 @@ LL | type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:183:40 --> $DIR/duplicate.rs:186:40
| |
LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>; LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -352,7 +382,17 @@ LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:185:40 --> $DIR/duplicate.rs:186:40
|
LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>;
| ---------- ^^^^^^^^^^ re-bound here
| |
| `Item` bound here first
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:189:40
| |
LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>; LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -360,7 +400,17 @@ LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:187:43 --> $DIR/duplicate.rs:189:40
|
LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>;
| ---------- ^^^^^^^^^^ re-bound here
| |
| `Item` bound here first
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:192:43
| |
LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>; LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>;
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -368,7 +418,17 @@ LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:190:36 --> $DIR/duplicate.rs:192:43
|
LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>;
| ------------- ^^^^^^^^^^^^^ re-bound here
| |
| `Item` bound here first
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:196:36
| |
LL | trait TRI1<T: Iterator<Item: Copy, Item: Send>> {} LL | trait TRI1<T: Iterator<Item: Copy, Item: Send>> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -376,7 +436,7 @@ LL | trait TRI1<T: Iterator<Item: Copy, Item: Send>> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:192:36 --> $DIR/duplicate.rs:198:36
| |
LL | trait TRI2<T: Iterator<Item: Copy, Item: Copy>> {} LL | trait TRI2<T: Iterator<Item: Copy, Item: Copy>> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -384,7 +444,7 @@ LL | trait TRI2<T: Iterator<Item: Copy, Item: Copy>> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:194:39 --> $DIR/duplicate.rs:200:39
| |
LL | trait TRI3<T: Iterator<Item: 'static, Item: 'static>> {} LL | trait TRI3<T: Iterator<Item: 'static, Item: 'static>> {}
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -392,7 +452,7 @@ LL | trait TRI3<T: Iterator<Item: 'static, Item: 'static>> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:196:34 --> $DIR/duplicate.rs:202:34
| |
LL | trait TRS1: Iterator<Item: Copy, Item: Send> {} LL | trait TRS1: Iterator<Item: Copy, Item: Send> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -400,7 +460,7 @@ 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` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:196:34 --> $DIR/duplicate.rs:202:34
| |
LL | trait TRS1: Iterator<Item: Copy, Item: Send> {} LL | trait TRS1: Iterator<Item: Copy, Item: Send> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -410,7 +470,7 @@ LL | trait TRS1: Iterator<Item: Copy, Item: Send> {}
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:196:34 --> $DIR/duplicate.rs:202:34
| |
LL | trait TRS1: Iterator<Item: Copy, Item: Send> {} LL | trait TRS1: Iterator<Item: Copy, Item: Send> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -420,7 +480,7 @@ LL | trait TRS1: Iterator<Item: Copy, Item: Send> {}
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:200:34 --> $DIR/duplicate.rs:206:34
| |
LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {} LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -428,7 +488,7 @@ 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` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:200:34 --> $DIR/duplicate.rs:206:34
| |
LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {} LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -438,7 +498,7 @@ LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {}
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:200:34 --> $DIR/duplicate.rs:206:34
| |
LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {} LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -448,7 +508,7 @@ LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {}
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:204:37 --> $DIR/duplicate.rs:210:37
| |
LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {} LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {}
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -456,7 +516,7 @@ 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` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:204:37 --> $DIR/duplicate.rs:210:37
| |
LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {} LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {}
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -466,7 +526,7 @@ LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {}
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:204:37 --> $DIR/duplicate.rs:210:37
| |
LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {} LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {}
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -476,7 +536,7 @@ LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {}
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:210:29 --> $DIR/duplicate.rs:216:29
| |
LL | T: Iterator<Item: Copy, Item: Send>, LL | T: Iterator<Item: Copy, Item: Send>,
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -484,7 +544,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` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:216:29 --> $DIR/duplicate.rs:222:29
| |
LL | T: Iterator<Item: Copy, Item: Copy>, LL | T: Iterator<Item: Copy, Item: Copy>,
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -492,7 +552,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` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:222:32 --> $DIR/duplicate.rs:228:32
| |
LL | T: Iterator<Item: 'static, Item: 'static>, LL | T: Iterator<Item: 'static, Item: 'static>,
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -500,7 +560,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` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:228:32 --> $DIR/duplicate.rs:234:32
| |
LL | Self: Iterator<Item: Copy, Item: Send>, LL | Self: Iterator<Item: Copy, Item: Send>,
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -508,7 +568,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` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:228:32 --> $DIR/duplicate.rs:234:32
| |
LL | Self: Iterator<Item: Copy, Item: Send>, LL | Self: Iterator<Item: Copy, Item: Send>,
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -518,7 +578,7 @@ LL | Self: Iterator<Item: Copy, Item: Send>,
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:228:32 --> $DIR/duplicate.rs:234:32
| |
LL | Self: Iterator<Item: Copy, Item: Send>, LL | Self: Iterator<Item: Copy, Item: Send>,
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -528,7 +588,7 @@ LL | Self: Iterator<Item: Copy, Item: Send>,
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:236:32 --> $DIR/duplicate.rs:242:32
| |
LL | Self: Iterator<Item: Copy, Item: Copy>, LL | Self: Iterator<Item: Copy, Item: Copy>,
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -536,7 +596,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` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:236:32 --> $DIR/duplicate.rs:242:32
| |
LL | Self: Iterator<Item: Copy, Item: Copy>, LL | Self: Iterator<Item: Copy, Item: Copy>,
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -546,7 +606,7 @@ LL | Self: Iterator<Item: Copy, Item: Copy>,
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:236:32 --> $DIR/duplicate.rs:242:32
| |
LL | Self: Iterator<Item: Copy, Item: Copy>, LL | Self: Iterator<Item: Copy, Item: Copy>,
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -556,7 +616,7 @@ LL | Self: Iterator<Item: Copy, Item: Copy>,
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:244:35 --> $DIR/duplicate.rs:250:35
| |
LL | Self: Iterator<Item: 'static, Item: 'static>, LL | Self: Iterator<Item: 'static, Item: 'static>,
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -564,7 +624,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` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:244:35 --> $DIR/duplicate.rs:250:35
| |
LL | Self: Iterator<Item: 'static, Item: 'static>, LL | Self: Iterator<Item: 'static, Item: 'static>,
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -574,7 +634,7 @@ LL | Self: Iterator<Item: 'static, Item: 'static>,
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:244:35 --> $DIR/duplicate.rs:250:35
| |
LL | Self: Iterator<Item: 'static, Item: 'static>, LL | Self: Iterator<Item: 'static, Item: 'static>,
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -584,7 +644,7 @@ LL | Self: Iterator<Item: 'static, Item: 'static>,
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:251:34 --> $DIR/duplicate.rs:257:34
| |
LL | type A: Iterator<Item: Copy, Item: Send>; LL | type A: Iterator<Item: Copy, Item: Send>;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -592,7 +652,17 @@ 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` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:255:34 --> $DIR/duplicate.rs:257:34
|
LL | type A: Iterator<Item: Copy, Item: Send>;
| ---------- ^^^^^^^^^^ re-bound here
| |
| `Item` bound here first
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:262:34
| |
LL | type A: Iterator<Item: Copy, Item: Copy>; LL | type A: Iterator<Item: Copy, Item: Copy>;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -600,14 +670,34 @@ 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` in trait `Iterator` is already specified error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:259:37 --> $DIR/duplicate.rs:262:34
|
LL | type A: Iterator<Item: Copy, Item: Copy>;
| ---------- ^^^^^^^^^^ re-bound here
| |
| `Item` bound here first
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:267: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 72 previous errors error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> $DIR/duplicate.rs:267:37
|
LL | type A: Iterator<Item: 'static, Item: 'static>;
| ------------- ^^^^^^^^^^^^^ re-bound here
| |
| `Item` bound here first
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 81 previous errors
Some errors have detailed explanations: E0282, E0719. Some errors have detailed explanations: E0282, E0719.
For more information about an error, try `rustc --explain E0282`. For more information about an error, try `rustc --explain E0282`.

View file

@ -1,6 +1,7 @@
trait T { trait T {
type A: S<C<i32 = u32> = ()>; type A: S<C<i32 = u32> = ()>;
//~^ ERROR associated type bindings are not allowed here //~^ ERROR associated type bindings are not allowed here
//~| ERROR associated type bindings are not allowed here
} }
trait Q {} trait Q {}

View file

@ -4,6 +4,14 @@ error[E0229]: associated type bindings are not allowed here
LL | type A: S<C<i32 = u32> = ()>; LL | type A: S<C<i32 = u32> = ()>;
| ^^^^^^^^^ associated type not allowed here | ^^^^^^^^^ associated type not allowed here
error: aborting due to 1 previous error error[E0229]: associated type bindings are not allowed here
--> $DIR/issue-102335-ty.rs:2:17
|
LL | type A: S<C<i32 = u32> = ()>;
| ^^^^^^^^^ associated type not allowed here
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0229`. For more information about this error, try `rustc --explain E0229`.

View file

@ -1,5 +1,6 @@
fn get_iter(vec: &[i32]) -> impl Iterator<Item = {}> + '_ { fn get_iter(vec: &[i32]) -> impl Iterator<Item = {}> + '_ {
//~^ ERROR expected type, found constant //~^ ERROR expected type, found constant
//~| ERROR expected type, found constant
//~| ERROR associated const equality is incomplete //~| ERROR associated const equality is incomplete
vec.iter() vec.iter()
} }

View file

@ -19,6 +19,18 @@ LL | fn get_iter(vec: &[i32]) -> impl Iterator<Item = {}> + '_ {
note: the associated type is defined here note: the associated type is defined here
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error: aborting due to 2 previous errors error: expected type, found constant
--> $DIR/issue-99828.rs:1:50
|
LL | fn get_iter(vec: &[i32]) -> impl Iterator<Item = {}> + '_ {
| ---- ^^ unexpected constant
| |
| expected a type because of this associated type
|
note: the associated type is defined here
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.

View file

@ -4,6 +4,7 @@
async fn copy() -> Result<()> async fn copy() -> Result<()>
//~^ ERROR enum takes 2 generic arguments //~^ ERROR enum takes 2 generic arguments
//~| ERROR enum takes 2 generic arguments
{ {
Ok(()) Ok(())
} }

View file

@ -11,6 +11,20 @@ help: add missing generic argument
LL | async fn copy() -> Result<(), E> LL | async fn copy() -> Result<(), E>
| +++ | +++
error: aborting due to 1 previous error error[E0107]: enum takes 2 generic arguments but 1 generic argument was supplied
--> $DIR/issue-65159.rs:5:20
|
LL | async fn copy() -> Result<()>
| ^^^^^^ -- supplied 1 generic argument
| |
| expected 2 generic arguments
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing generic argument
|
LL | async fn copy() -> Result<(), E>
| +++
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0107`. For more information about this error, try `rustc --explain E0107`.

View file

@ -15,7 +15,9 @@ impl MarketMultiplier {
async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_> { async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_> {
//~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument was supplied //~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument was supplied
//~^^ ERROR struct takes 1 generic argument but 0 generic arguments were supplied //~| ERROR struct takes 1 generic argument but 0 generic arguments were supplied
//~| ERROR struct takes 0 lifetime arguments but 1 lifetime argument was supplied
//~| ERROR struct takes 1 generic argument but 0 generic arguments were supplied
LockedMarket(coroutine.lock().unwrap().buy()) LockedMarket(coroutine.lock().unwrap().buy())
} }

View file

@ -7,7 +7,7 @@ LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_>
| expected 0 lifetime arguments | expected 0 lifetime arguments
| |
note: struct defined here, with 0 lifetime parameters note: struct defined here, with 0 lifetime parameters
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:22:8 --> $DIR/issue-82126-mismatched-subst-and-hir.rs:24:8
| |
LL | struct LockedMarket<T>(T); LL | struct LockedMarket<T>(T);
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
@ -19,7 +19,7 @@ LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_>
| ^^^^^^^^^^^^ expected 1 generic argument | ^^^^^^^^^^^^ expected 1 generic argument
| |
note: struct defined here, with 1 generic parameter: `T` note: struct defined here, with 1 generic parameter: `T`
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:22:8 --> $DIR/issue-82126-mismatched-subst-and-hir.rs:24:8
| |
LL | struct LockedMarket<T>(T); LL | struct LockedMarket<T>(T);
| ^^^^^^^^^^^^ - | ^^^^^^^^^^^^ -
@ -28,6 +28,38 @@ help: add missing generic argument
LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_, T> { LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_, T> {
| +++ | +++
error: aborting due to 2 previous errors error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supplied
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:16:59
|
LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_> {
| ^^^^^^^^^^^^---- help: remove these generics
| |
| expected 0 lifetime arguments
|
note: struct defined here, with 0 lifetime parameters
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:24:8
|
LL | struct LockedMarket<T>(T);
| ^^^^^^^^^^^^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0107]: struct takes 1 generic argument but 0 generic arguments were supplied
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:16:59
|
LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_> {
| ^^^^^^^^^^^^ expected 1 generic argument
|
note: struct defined here, with 1 generic parameter: `T`
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:24:8
|
LL | struct LockedMarket<T>(T);
| ^^^^^^^^^^^^ -
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing generic argument
|
LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_, T> {
| +++
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0107`. For more information about this error, try `rustc --explain E0107`.

View file

@ -13,6 +13,7 @@ impl<const N: usize> Marker<N> for Example<N> {}
fn make_marker() -> impl Marker<gimme_a_const!(marker)> { fn make_marker() -> impl Marker<gimme_a_const!(marker)> {
//~^ ERROR: type provided when a constant was expected //~^ ERROR: type provided when a constant was expected
//~| ERROR: type provided when a constant was expected
Example::<gimme_a_const!(marker)> Example::<gimme_a_const!(marker)>
//~^ ERROR: type provided when a constant was expected //~^ ERROR: type provided when a constant was expected
} }

View file

@ -1,5 +1,5 @@
error: expected type, found `{` error: expected type, found `{`
--> $DIR/macro-fail.rs:29:27 --> $DIR/macro-fail.rs:30:27
| |
LL | fn make_marker() -> impl Marker<gimme_a_const!(marker)> { LL | fn make_marker() -> impl Marker<gimme_a_const!(marker)> {
| ---------------------- | ----------------------
@ -13,7 +13,7 @@ LL | ($rusty: ident) => {{ let $rusty = 3; *&$rusty }}
= note: this error originates in the macro `gimme_a_const` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `gimme_a_const` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected type, found `{` error: expected type, found `{`
--> $DIR/macro-fail.rs:29:27 --> $DIR/macro-fail.rs:30:27
| |
LL | Example::<gimme_a_const!(marker)> LL | Example::<gimme_a_const!(marker)>
| ---------------------- | ----------------------
@ -41,7 +41,7 @@ LL | let _fail = Example::<external_macro!()>;
= note: this error originates in the macro `external_macro` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `external_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
error: unexpected end of macro invocation error: unexpected end of macro invocation
--> $DIR/macro-fail.rs:39:25 --> $DIR/macro-fail.rs:40:25
| |
LL | macro_rules! gimme_a_const { LL | macro_rules! gimme_a_const {
| -------------------------- when calling this macro | -------------------------- when calling this macro
@ -50,7 +50,7 @@ LL | let _fail = Example::<gimme_a_const!()>;
| ^^^^^^^^^^^^^^^^ missing tokens in macro arguments | ^^^^^^^^^^^^^^^^ missing tokens in macro arguments
| |
note: while trying to match meta-variable `$rusty:ident` note: while trying to match meta-variable `$rusty:ident`
--> $DIR/macro-fail.rs:29:8 --> $DIR/macro-fail.rs:30:8
| |
LL | ($rusty: ident) => {{ let $rusty = 3; *&$rusty }} LL | ($rusty: ident) => {{ let $rusty = 3; *&$rusty }}
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
@ -62,23 +62,31 @@ LL | fn make_marker() -> impl Marker<gimme_a_const!(marker)> {
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
error[E0747]: type provided when a constant was expected error[E0747]: type provided when a constant was expected
--> $DIR/macro-fail.rs:16:13 --> $DIR/macro-fail.rs:14:33
|
LL | fn make_marker() -> impl Marker<gimme_a_const!(marker)> {
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0747]: type provided when a constant was expected
--> $DIR/macro-fail.rs:17:13
| |
LL | Example::<gimme_a_const!(marker)> LL | Example::<gimme_a_const!(marker)>
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
error[E0747]: type provided when a constant was expected error[E0747]: type provided when a constant was expected
--> $DIR/macro-fail.rs:36:25 --> $DIR/macro-fail.rs:37:25
| |
LL | let _fail = Example::<external_macro!()>; LL | let _fail = Example::<external_macro!()>;
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
error[E0747]: type provided when a constant was expected error[E0747]: type provided when a constant was expected
--> $DIR/macro-fail.rs:39:25 --> $DIR/macro-fail.rs:40:25
| |
LL | let _fail = Example::<gimme_a_const!()>; LL | let _fail = Example::<gimme_a_const!()>;
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
error: aborting due to 8 previous errors error: aborting due to 9 previous errors
For more information about this error, try `rustc --explain E0747`. For more information about this error, try `rustc --explain E0747`.

View file

@ -1,6 +1,7 @@
trait T { trait T {
type A: S<C<(), i32 = ()> = ()>; type A: S<C<(), i32 = ()> = ()>;
//~^ ERROR associated type bindings are not allowed here //~^ ERROR associated type bindings are not allowed here
//~| ERROR associated type bindings are not allowed here
} }
trait Q {} trait Q {}

View file

@ -4,6 +4,14 @@ error[E0229]: associated type bindings are not allowed here
LL | type A: S<C<(), i32 = ()> = ()>; LL | type A: S<C<(), i32 = ()> = ()>;
| ^^^^^^^^ associated type not allowed here | ^^^^^^^^ associated type not allowed here
error: aborting due to 1 previous error error[E0229]: associated type bindings are not allowed here
--> $DIR/issue-102335-gat.rs:2:21
|
LL | type A: S<C<(), i32 = ()> = ()>;
| ^^^^^^^^ associated type not allowed here
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0229`. For more information about this error, try `rustc --explain E0229`.

View file

@ -13,6 +13,7 @@ trait C {
trait D<T> { trait D<T> {
type CType: C<DType = Self>; type CType: C<DType = Self>;
//~^ ERROR missing generics for associated type //~^ ERROR missing generics for associated type
//~| ERROR missing generics for associated type
} }
fn main() {} fn main() {}

View file

@ -14,6 +14,23 @@ help: add missing generic argument
LL | type CType: C<DType<T> = Self>; LL | type CType: C<DType<T> = Self>;
| +++ | +++
error: aborting due to 1 previous error error[E0107]: missing generics for associated type `C::DType`
--> $DIR/issue-81712-cyclic-traits.rs:14:19
|
LL | type CType: C<DType = Self>;
| ^^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-81712-cyclic-traits.rs:11:10
|
LL | type DType<T>: D<T, CType = Self>;
| ^^^^^ -
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing generic argument
|
LL | type CType: C<DType<T> = Self>;
| +++
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0107`. For more information about this error, try `rustc --explain E0107`.

View file

@ -5,6 +5,8 @@
fn ice() -> impl AsRef<Fn(&())> { fn ice() -> impl AsRef<Fn(&())> {
//~^ WARN trait objects without an explicit `dyn` are deprecated //~^ WARN trait objects without an explicit `dyn` are deprecated
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
//~| WARN trait objects without an explicit `dyn` are deprecated
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
Foo Foo
} }

View file

@ -12,5 +12,19 @@ help: if this is an object-safe trait, use `dyn`
LL | fn ice() -> impl AsRef<dyn Fn(&())> { LL | fn ice() -> impl AsRef<dyn Fn(&())> {
| +++ | +++
warning: 1 warning emitted warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/fresh-lifetime-from-bare-trait-obj-114664.rs:5:24
|
LL | fn ice() -> impl AsRef<Fn(&())> {
| ^^^^^^^
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: if this is an object-safe trait, use `dyn`
|
LL | fn ice() -> impl AsRef<dyn Fn(&())> {
| +++
warning: 2 warnings emitted

View file

@ -12,6 +12,7 @@ impl<'a, I: 'a + Iterable> Iterable for &'a I {
fn iter(&self) -> impl for<'missing> Iterator<Item = Self::Item<'missing>> {} fn iter(&self) -> impl for<'missing> Iterator<Item = Self::Item<'missing>> {}
//~^ ERROR binding for associated type `Item` references lifetime `'missing` //~^ ERROR binding for associated type `Item` references lifetime `'missing`
//~| ERROR binding for associated type `Item` references lifetime `'missing`
//~| ERROR `()` is not an iterator //~| ERROR `()` is not an iterator
} }

View file

@ -4,6 +4,14 @@ error[E0582]: binding for associated type `Item` references lifetime `'missing`,
LL | fn iter(&self) -> impl for<'missing> Iterator<Item = Self::Item<'missing>> {} LL | fn iter(&self) -> impl for<'missing> Iterator<Item = Self::Item<'missing>> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0582]: binding for associated type `Item` references lifetime `'missing`, which does not appear in the trait input types
--> $DIR/span-bug-issue-121457.rs:13:51
|
LL | fn iter(&self) -> impl for<'missing> Iterator<Item = Self::Item<'missing>> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0195]: lifetime parameters or bounds on type `Item` do not match the trait declaration error[E0195]: lifetime parameters or bounds on type `Item` do not match the trait declaration
--> $DIR/span-bug-issue-121457.rs:10:14 --> $DIR/span-bug-issue-121457.rs:10:14
| |
@ -24,7 +32,7 @@ LL | fn iter(&self) -> impl for<'missing> Iterator<Item = Self::Item<'missin
| |
= help: the trait `Iterator` is not implemented for `()` = help: the trait `Iterator` is not implemented for `()`
error: aborting due to 3 previous errors error: aborting due to 4 previous errors
Some errors have detailed explanations: E0195, E0277, E0582. Some errors have detailed explanations: E0195, E0277, E0582.
For more information about an error, try `rustc --explain E0195`. For more information about an error, try `rustc --explain E0195`.

View file

@ -4,6 +4,7 @@ use std::iter;
fn f<T>(data: &[T]) -> impl Iterator<Item = Vec> { fn f<T>(data: &[T]) -> impl Iterator<Item = Vec> {
//~^ ERROR: missing generics for struct `Vec` [E0107] //~^ ERROR: missing generics for struct `Vec` [E0107]
//~| ERROR: missing generics for struct `Vec` [E0107]
iter::empty() iter::empty()
} }

View file

@ -9,6 +9,18 @@ help: add missing generic argument
LL | fn f<T>(data: &[T]) -> impl Iterator<Item = Vec<T>> { LL | fn f<T>(data: &[T]) -> impl Iterator<Item = Vec<T>> {
| +++ | +++
error: aborting due to 1 previous error error[E0107]: missing generics for struct `Vec`
--> $DIR/issue-92305.rs:5:45
|
LL | fn f<T>(data: &[T]) -> impl Iterator<Item = Vec> {
| ^^^ expected at least 1 generic argument
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing generic argument
|
LL | fn f<T>(data: &[T]) -> impl Iterator<Item = Vec<T>> {
| +++
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0107`. For more information about this error, try `rustc --explain E0107`.

View file

@ -7,6 +7,7 @@ fn frob() -> impl Fn<P, Output = T> + '_ {}
//~| ERROR cannot find type `P` //~| ERROR cannot find type `P`
//~| ERROR cannot find type `T` //~| ERROR cannot find type `T`
//~| ERROR `Fn`-family traits' type parameters is subject to change //~| ERROR `Fn`-family traits' type parameters is subject to change
//~| ERROR `Fn`-family traits' type parameters is subject to change
fn open_parent<'path>() { fn open_parent<'path>() {
todo!() todo!()

View file

@ -42,8 +42,19 @@ LL | fn frob() -> impl Fn<P, Output = T> + '_ {}
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change
--> $DIR/opaque-used-in-extraneous-argument.rs:5:19
|
LL | fn frob() -> impl Fn<P, Output = T> + '_ {}
| ^^^^^^^^^^^^^^^^^ help: use parenthetical notation instead: `Fn(P) -> T`
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0061]: this function takes 0 arguments but 1 argument was supplied error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/opaque-used-in-extraneous-argument.rs:16:20 --> $DIR/opaque-used-in-extraneous-argument.rs:17:20
| |
LL | let old_path = frob("hello"); LL | let old_path = frob("hello");
| ^^^^ ------- | ^^^^ -------
@ -58,7 +69,7 @@ LL | fn frob() -> impl Fn<P, Output = T> + '_ {}
| ^^^^ | ^^^^
error[E0061]: this function takes 0 arguments but 1 argument was supplied error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/opaque-used-in-extraneous-argument.rs:19:5 --> $DIR/opaque-used-in-extraneous-argument.rs:20:5
| |
LL | open_parent(&old_path) LL | open_parent(&old_path)
| ^^^^^^^^^^^ --------- | ^^^^^^^^^^^ ---------
@ -67,12 +78,12 @@ LL | open_parent(&old_path)
| help: remove the extra argument | help: remove the extra argument
| |
note: function defined here note: function defined here
--> $DIR/opaque-used-in-extraneous-argument.rs:11:4 --> $DIR/opaque-used-in-extraneous-argument.rs:12:4
| |
LL | fn open_parent<'path>() { LL | fn open_parent<'path>() {
| ^^^^^^^^^^^ | ^^^^^^^^^^^
error: aborting due to 6 previous errors error: aborting due to 7 previous errors
Some errors have detailed explanations: E0061, E0106, E0412, E0658. Some errors have detailed explanations: E0061, E0106, E0412, E0658.
For more information about an error, try `rustc --explain E0061`. For more information about an error, try `rustc --explain E0061`.

View file

@ -7,6 +7,7 @@ impl Trait for i32 {}
// ICE in this case. // ICE in this case.
fn produce<T>() -> impl Trait<Assoc = impl Trait> { fn produce<T>() -> impl Trait<Assoc = impl Trait> {
//~^ ERROR associated type `Assoc` not found for `Trait` //~^ ERROR associated type `Assoc` not found for `Trait`
//~| ERROR associated type `Assoc` not found for `Trait`
16 16
} }

View file

@ -4,6 +4,14 @@ error[E0220]: associated type `Assoc` not found for `Trait`
LL | fn produce<T>() -> impl Trait<Assoc = impl Trait> { LL | fn produce<T>() -> impl Trait<Assoc = impl Trait> {
| ^^^^^ associated type `Assoc` not found | ^^^^^ associated type `Assoc` not found
error: aborting due to 1 previous error error[E0220]: associated type `Assoc` not found for `Trait`
--> $DIR/stranded-opaque.rs:8:31
|
LL | fn produce<T>() -> impl Trait<Assoc = impl Trait> {
| ^^^^^ associated type `Assoc` not found
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0220`. For more information about this error, try `rustc --explain E0220`.

View file

@ -11,6 +11,7 @@ fn ref_arg<T: ?Send>(_: &T) {}
//~^ warning: relaxing a default bound only does something for `?Sized` //~^ warning: relaxing a default bound only does something for `?Sized`
fn ret() -> impl Iterator<Item = ()> + ?Send { std::iter::empty() } fn ret() -> impl Iterator<Item = ()> + ?Send { std::iter::empty() }
//~^ warning: relaxing a default bound only does something for `?Sized` //~^ warning: relaxing a default bound only does something for `?Sized`
//~| warning: relaxing a default bound only does something for `?Sized`
// Check that there's no `?Sized` relaxation! // Check that there's no `?Sized` relaxation!
fn main() { fn main() {

View file

@ -16,8 +16,16 @@ warning: relaxing a default bound only does something for `?Sized`; all other tr
LL | fn ret() -> impl Iterator<Item = ()> + ?Send { std::iter::empty() } LL | fn ret() -> impl Iterator<Item = ()> + ?Send { std::iter::empty() }
| ^^^^^ | ^^^^^
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/issue-87199.rs:12:40
|
LL | fn ret() -> impl Iterator<Item = ()> + ?Send { std::iter::empty() }
| ^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
--> $DIR/issue-87199.rs:18:15 --> $DIR/issue-87199.rs:19:15
| |
LL | ref_arg::<[i32]>(&[5]); LL | ref_arg::<[i32]>(&[5]);
| ^^^^^ doesn't have a size known at compile-time | ^^^^^ doesn't have a size known at compile-time
@ -33,6 +41,6 @@ help: consider relaxing the implicit `Sized` restriction
LL | fn ref_arg<T: ?Send + ?Sized>(_: &T) {} LL | fn ref_arg<T: ?Send + ?Sized>(_: &T) {}
| ++++++++ | ++++++++
error: aborting due to 1 previous error; 3 warnings emitted error: aborting due to 1 previous error; 4 warnings emitted
For more information about this error, try `rustc --explain E0277`. For more information about this error, try `rustc --explain E0277`.

View file

@ -0,0 +1,21 @@
//@ check-pass
#![deny(unused_must_use)]
use std::future::Future;
use std::pin::Pin;
trait Factory {
type Output;
}
impl Factory for () {
type Output = Pin<Box<dyn Future<Output = ()> + 'static>>;
}
// Make sure we don't get an `unused_must_use` error on the *associated type bound*.
fn f() -> impl Factory<Output: Future> {}
fn main() {
f();
}

View file

@ -1,5 +1,6 @@
fn bug() -> impl for <'r> Fn() -> &'r () { || { &() } } fn bug() -> impl for <'r> Fn() -> &'r () { || { &() } }
//~^ ERROR binding for associated type `Output` references lifetime `'r` //~^ ERROR binding for associated type `Output` references lifetime `'r`
//~| ERROR binding for associated type `Output` references lifetime `'r`
fn main() { fn main() {
let f = bug(); let f = bug();

View file

@ -4,6 +4,14 @@ error[E0582]: binding for associated type `Output` references lifetime `'r`, whi
LL | fn bug() -> impl for <'r> Fn() -> &'r () { || { &() } } LL | fn bug() -> impl for <'r> Fn() -> &'r () { || { &() } }
| ^^^^^^ | ^^^^^^
error: aborting due to 1 previous error error[E0582]: binding for associated type `Output` references lifetime `'r`, which does not appear in the trait input types
--> $DIR/issue-54189.rs:1:35
|
LL | fn bug() -> impl for <'r> Fn() -> &'r () { || { &() } }
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0582`. For more information about this error, try `rustc --explain E0582`.

View file

@ -4,5 +4,13 @@ error: `~const` can only be applied to `#[const_trait]` traits
LL | const fn test() -> impl ~const Fn() { LL | const fn test() -> impl ~const Fn() {
| ^^^^ | ^^^^
error: aborting due to 1 previous error error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-closure-parse-not-item.rs:7:32
|
LL | const fn test() -> impl ~const Fn() {
| ^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors

View file

@ -1,7 +1,9 @@
#![feature(const_trait_impl, effects)] #![feature(const_trait_impl, effects)]
const fn test() -> impl ~const Fn() { //~ ERROR `~const` can only be applied to `#[const_trait]` traits const fn test() -> impl ~const Fn() {
//~^ ERROR cycle detected //~^ ERROR `~const` can only be applied to `#[const_trait]` traits
//~| ERROR `~const` can only be applied to `#[const_trait]` traits
//~| ERROR cycle detected
const move || { //~ ERROR const closures are experimental const move || { //~ ERROR const closures are experimental
let sl: &[u8] = b"foo"; let sl: &[u8] = b"foo";

View file

@ -1,5 +1,5 @@
error[E0658]: const closures are experimental error[E0658]: const closures are experimental
--> $DIR/ice-112822-expected-type-for-param.rs:5:5 --> $DIR/ice-112822-expected-type-for-param.rs:7:5
| |
LL | const move || { LL | const move || {
| ^^^^^ | ^^^^^
@ -14,8 +14,16 @@ error: `~const` can only be applied to `#[const_trait]` traits
LL | const fn test() -> impl ~const Fn() { LL | const fn test() -> impl ~const Fn() {
| ^^^^ | ^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/ice-112822-expected-type-for-param.rs:3:32
|
LL | const fn test() -> impl ~const Fn() {
| ^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: can't compare `&u8` with `&u8` error[E0277]: can't compare `&u8` with `&u8`
--> $DIR/ice-112822-expected-type-for-param.rs:10:17 --> $DIR/ice-112822-expected-type-for-param.rs:12:17
| |
LL | assert_eq!(first, &b'f'); LL | assert_eq!(first, &b'f');
| ^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `&u8 == &u8` | ^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `&u8 == &u8`
@ -54,7 +62,7 @@ LL | const fn test() -> impl ~const Fn() {
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
error: aborting due to 4 previous errors error: aborting due to 5 previous errors
Some errors have detailed explanations: E0277, E0391, E0658. Some errors have detailed explanations: E0277, E0391, E0658.
For more information about an error, try `rustc --explain E0277`. For more information about an error, try `rustc --explain E0277`.

View file

@ -4,6 +4,9 @@ trait Foo {
//~^ ERROR associated type takes 1 lifetime argument but 0 lifetime arguments were supplied //~^ ERROR associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
//~| ERROR associated type bindings are not allowed here //~| ERROR associated type bindings are not allowed here
//~| HELP add missing //~| HELP add missing
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
//~| ERROR associated type bindings are not allowed here
//~| HELP add missing
} }
fn main() {} fn main() {}

View file

@ -20,7 +20,32 @@ error[E0229]: associated type bindings are not allowed here
LL | type Bar<'a>: Deref<Target = <Self>::Bar<Target = Self>>; LL | type Bar<'a>: Deref<Target = <Self>::Bar<Target = Self>>;
| ^^^^^^^^^^^^^ associated type not allowed here | ^^^^^^^^^^^^^ associated type not allowed here
error: aborting due to 2 previous errors error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/issue-85347.rs:3:42
|
LL | type Bar<'a>: Deref<Target = <Self>::Bar<Target = Self>>;
| ^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-85347.rs:3:10
|
LL | type Bar<'a>: Deref<Target = <Self>::Bar<Target = Self>>;
| ^^^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | type Bar<'a>: Deref<Target = <Self>::Bar<'a, Target = Self>>;
| +++
error[E0229]: associated type bindings are not allowed here
--> $DIR/issue-85347.rs:3:46
|
LL | type Bar<'a>: Deref<Target = <Self>::Bar<Target = Self>>;
| ^^^^^^^^^^^^^ associated type not allowed here
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0107, E0229. Some errors have detailed explanations: E0107, E0229.
For more information about an error, try `rustc --explain E0107`. For more information about an error, try `rustc --explain E0107`.

View file

@ -20,6 +20,7 @@ impl<T, S> Trait<T, S> for () {}
fn func<T: Trait<u32, String>>(t: T) -> impl Trait<(), i32> { fn func<T: Trait<u32, String>>(t: T) -> impl Trait<(), i32> {
//~^ ERROR trait takes 1 generic argument but 2 generic arguments were supplied //~^ ERROR trait takes 1 generic argument but 2 generic arguments were supplied
//~| ERROR trait takes 1 generic argument but 2 generic arguments were supplied //~| ERROR trait takes 1 generic argument but 2 generic arguments were supplied
//~| ERROR trait takes 1 generic argument but 2 generic arguments were supplied
//~| ERROR type annotations needed //~| ERROR type annotations needed
3 3
} }

View file

@ -54,6 +54,23 @@ help: replace the generic bound with the associated type
LL | fn func<T: Trait<u32, String>>(t: T) -> impl Trait<(), Assoc = i32> { LL | fn func<T: Trait<u32, String>>(t: T) -> impl Trait<(), Assoc = i32> {
| +++++++ | +++++++
error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied
--> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:20:46
|
LL | fn func<T: Trait<u32, String>>(t: T) -> impl Trait<(), i32> {
| ^^^^^ expected 1 generic argument
|
note: trait defined here, with 1 generic parameter: `T`
--> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:5:11
|
LL | pub trait Trait<T> {
| ^^^^^ -
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: replace the generic bound with the associated type
|
LL | fn func<T: Trait<u32, String>>(t: T) -> impl Trait<(), Assoc = i32> {
| +++++++
error[E0282]: type annotations needed error[E0282]: type annotations needed
--> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:20:41 --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:20:41
| |
@ -61,7 +78,7 @@ LL | fn func<T: Trait<u32, String>>(t: T) -> impl Trait<(), i32> {
| ^^^^^^^^^^^^^^^^^^^ cannot infer type | ^^^^^^^^^^^^^^^^^^^ cannot infer type
error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied
--> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:27:18 --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:28:18
| |
LL | struct Struct<T: Trait<u32, String>> { LL | struct Struct<T: Trait<u32, String>> {
| ^^^^^ expected 1 generic argument | ^^^^^ expected 1 generic argument
@ -77,7 +94,7 @@ LL | struct Struct<T: Trait<u32, Assoc = String>> {
| +++++++ | +++++++
error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied
--> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:32:23 --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:33:23
| |
LL | trait AnotherTrait<T: Trait<T, i32>> {} LL | trait AnotherTrait<T: Trait<T, i32>> {}
| ^^^^^ expected 1 generic argument | ^^^^^ expected 1 generic argument
@ -93,7 +110,7 @@ LL | trait AnotherTrait<T: Trait<T, Assoc = i32>> {}
| +++++++ | +++++++
error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied
--> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:35:9 --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:36:9
| |
LL | impl<T: Trait<u32, String>> Struct<T> {} LL | impl<T: Trait<u32, String>> Struct<T> {}
| ^^^^^ expected 1 generic argument | ^^^^^ expected 1 generic argument
@ -109,7 +126,7 @@ LL | impl<T: Trait<u32, Assoc = String>> Struct<T> {}
| +++++++ | +++++++
error[E0107]: struct takes 1 generic argument but 2 generic arguments were supplied error[E0107]: struct takes 1 generic argument but 2 generic arguments were supplied
--> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:41:58 --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:42:58
| |
LL | impl<T: Trait<u32, Assoc=String>, U> YetAnotherTrait for Struct<T, U> {} LL | impl<T: Trait<u32, Assoc=String>, U> YetAnotherTrait for Struct<T, U> {}
| ^^^^^^ - help: remove this generic argument | ^^^^^^ - help: remove this generic argument
@ -117,12 +134,12 @@ LL | impl<T: Trait<u32, Assoc=String>, U> YetAnotherTrait for Struct<T, U> {}
| expected 1 generic argument | expected 1 generic argument
| |
note: struct defined here, with 1 generic parameter: `T` note: struct defined here, with 1 generic parameter: `T`
--> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:27:8 --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:28:8
| |
LL | struct Struct<T: Trait<u32, String>> { LL | struct Struct<T: Trait<u32, String>> {
| ^^^^^^ - | ^^^^^^ -
error: aborting due to 10 previous errors error: aborting due to 11 previous errors
Some errors have detailed explanations: E0107, E0207, E0282. Some errors have detailed explanations: E0107, E0207, E0282.
For more information about an error, try `rustc --explain E0107`. For more information about an error, try `rustc --explain E0107`.

View file

@ -1,19 +0,0 @@
//@ run-rustfix
#![feature(type_alias_impl_trait)]
#![allow(dead_code)]
fn main() {}
trait TraitWithAssoc {
type Assoc;
}
type Foo<V: TraitWithAssoc> = impl Trait<V::Assoc>; //~ associated type `Assoc` not found for `V`
trait Trait<U> {}
impl<W> Trait<W> for () {}
fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T> {
()
}

View file

@ -1,4 +1,4 @@
//@ run-rustfix // Can't rustfix because we apply the suggestion twice :^(
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]
#![allow(dead_code)] #![allow(dead_code)]
@ -8,7 +8,9 @@ trait TraitWithAssoc {
type Assoc; type Assoc;
} }
type Foo<V> = impl Trait<V::Assoc>; //~ associated type `Assoc` not found for `V` type Foo<V> = impl Trait<V::Assoc>;
//~^ associated type `Assoc` not found for `V`
//~| associated type `Assoc` not found for `V`
trait Trait<U> {} trait Trait<U> {}

View file

@ -9,6 +9,18 @@ help: consider restricting type parameter `V`
LL | type Foo<V: TraitWithAssoc> = impl Trait<V::Assoc>; LL | type Foo<V: TraitWithAssoc> = impl Trait<V::Assoc>;
| ++++++++++++++++ | ++++++++++++++++
error: aborting due to 1 previous error error[E0220]: associated type `Assoc` not found for `V`
--> $DIR/not_well_formed.rs:11:29
|
LL | type Foo<V> = impl Trait<V::Assoc>;
| ^^^^^ there is an associated type `Assoc` in the trait `TraitWithAssoc`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: consider restricting type parameter `V`
|
LL | type Foo<V: TraitWithAssoc> = impl Trait<V::Assoc>;
| ++++++++++++++++
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0220`. For more information about this error, try `rustc --explain E0220`.