mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Separate bounds and predicates for associated/opaque types
This commit is contained in:
parent
d297147e62
commit
f958e6c246
@ -432,17 +432,25 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
self.with_catch_scope(body.id, |this| {
|
||||
let mut block = this.lower_block_noalloc(body, true);
|
||||
|
||||
let try_span = this.mark_span_with_reason(
|
||||
DesugaringKind::TryBlock,
|
||||
body.span,
|
||||
this.allow_try_trait.clone(),
|
||||
);
|
||||
|
||||
// Final expression of the block (if present) or `()` with span at the end of block
|
||||
let tail_expr = block
|
||||
.expr
|
||||
.take()
|
||||
.unwrap_or_else(|| this.expr_unit(this.sess.source_map().end_point(try_span)));
|
||||
let (try_span, tail_expr) = if let Some(expr) = block.expr.take() {
|
||||
(
|
||||
this.mark_span_with_reason(
|
||||
DesugaringKind::TryBlock,
|
||||
expr.span,
|
||||
this.allow_try_trait.clone(),
|
||||
),
|
||||
expr,
|
||||
)
|
||||
} else {
|
||||
let try_span = this.mark_span_with_reason(
|
||||
DesugaringKind::TryBlock,
|
||||
this.sess.source_map().end_point(body.span),
|
||||
this.allow_try_trait.clone(),
|
||||
);
|
||||
|
||||
(try_span, this.expr_unit(try_span))
|
||||
};
|
||||
|
||||
let ok_wrapped_span =
|
||||
this.mark_span_with_reason(DesugaringKind::TryBlock, tail_expr.span, None);
|
||||
@ -1553,7 +1561,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
hir::LangItem::TryFromError,
|
||||
unstable_span,
|
||||
from_expr,
|
||||
try_span,
|
||||
unstable_span,
|
||||
);
|
||||
let thin_attrs = ThinVec::from(attrs);
|
||||
let catch_scope = self.catch_scopes.last().copied();
|
||||
|
@ -4,7 +4,6 @@ use crate::traits::{Obligation, ObligationCause, PredicateObligation};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_middle::ty::outlives::Component;
|
||||
use rustc_middle::ty::{self, ToPredicate, TyCtxt, WithConstness};
|
||||
use rustc_span::Span;
|
||||
|
||||
pub fn anonymize_predicate<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
@ -94,7 +93,11 @@ pub fn elaborate_predicates<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
predicates: impl Iterator<Item = ty::Predicate<'tcx>>,
|
||||
) -> Elaborator<'tcx> {
|
||||
let obligations = predicates.map(|predicate| predicate_obligation(predicate, None)).collect();
|
||||
let obligations = predicates
|
||||
.map(|predicate| {
|
||||
predicate_obligation(predicate, ty::ParamEnv::empty(), ObligationCause::dummy())
|
||||
})
|
||||
.collect();
|
||||
elaborate_obligations(tcx, obligations)
|
||||
}
|
||||
|
||||
@ -109,15 +112,10 @@ pub fn elaborate_obligations<'tcx>(
|
||||
|
||||
fn predicate_obligation<'tcx>(
|
||||
predicate: ty::Predicate<'tcx>,
|
||||
span: Option<Span>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
cause: ObligationCause<'tcx>,
|
||||
) -> PredicateObligation<'tcx> {
|
||||
let cause = if let Some(span) = span {
|
||||
ObligationCause::dummy_with_span(span)
|
||||
} else {
|
||||
ObligationCause::dummy()
|
||||
};
|
||||
|
||||
Obligation { cause, param_env: ty::ParamEnv::empty(), recursion_depth: 0, predicate }
|
||||
Obligation { cause, param_env, recursion_depth: 0, predicate }
|
||||
}
|
||||
|
||||
impl Elaborator<'tcx> {
|
||||
@ -133,10 +131,11 @@ impl Elaborator<'tcx> {
|
||||
// Get predicates declared on the trait.
|
||||
let predicates = tcx.super_predicates_of(data.def_id());
|
||||
|
||||
let obligations = predicates.predicates.iter().map(|&(pred, span)| {
|
||||
let obligations = predicates.predicates.iter().map(|&(pred, _)| {
|
||||
predicate_obligation(
|
||||
pred.subst_supertrait(tcx, &ty::Binder::bind(data.trait_ref)),
|
||||
Some(span),
|
||||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
)
|
||||
});
|
||||
debug!("super_predicates: data={:?}", data);
|
||||
@ -233,7 +232,13 @@ impl Elaborator<'tcx> {
|
||||
})
|
||||
.map(|predicate_kind| predicate_kind.to_predicate(tcx))
|
||||
.filter(|&predicate| visited.insert(predicate))
|
||||
.map(|predicate| predicate_obligation(predicate, None)),
|
||||
.map(|predicate| {
|
||||
predicate_obligation(
|
||||
predicate,
|
||||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
)
|
||||
}),
|
||||
);
|
||||
}
|
||||
ty::PredicateAtom::TypeWellFormedFromEnv(..) => {
|
||||
|
@ -200,7 +200,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
|
||||
ty::Adt(def, _) => check_must_use_def(cx, def.did, span, descr_pre, descr_post),
|
||||
ty::Opaque(def, _) => {
|
||||
let mut has_emitted = false;
|
||||
for (predicate, _) in cx.tcx.predicates_of(def).predicates {
|
||||
for &(predicate, _) in cx.tcx.explicit_item_bounds(def) {
|
||||
// We only look at the `DefId`, so it is safe to skip the binder here.
|
||||
if let ty::PredicateAtom::Trait(ref poly_trait_predicate, _) =
|
||||
predicate.skip_binders()
|
||||
|
@ -1266,7 +1266,10 @@ impl EncodeContext<'a, 'tcx> {
|
||||
hir::ItemKind::ForeignMod(_) => EntryKind::ForeignMod,
|
||||
hir::ItemKind::GlobalAsm(..) => EntryKind::GlobalAsm,
|
||||
hir::ItemKind::TyAlias(..) => EntryKind::Type,
|
||||
hir::ItemKind::OpaqueTy(..) => EntryKind::OpaqueTy,
|
||||
hir::ItemKind::OpaqueTy(..) => {
|
||||
self.encode_explicit_item_bounds(def_id);
|
||||
EntryKind::OpaqueTy
|
||||
}
|
||||
hir::ItemKind::Enum(..) => EntryKind::Enum(self.tcx.adt_def(def_id).repr),
|
||||
hir::ItemKind::Struct(ref struct_def, _) => {
|
||||
let adt_def = self.tcx.adt_def(def_id);
|
||||
|
@ -607,12 +607,13 @@ pub trait PrettyPrinter<'tcx>:
|
||||
}
|
||||
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
|
||||
// by looking up the projections associated with the def_id.
|
||||
let bounds = self.tcx().item_bounds(def_id).subst(self.tcx(), substs);
|
||||
let bounds = self.tcx().explicit_item_bounds(def_id);
|
||||
|
||||
let mut first = true;
|
||||
let mut is_sized = false;
|
||||
p!("impl");
|
||||
for predicate in bounds {
|
||||
for (predicate, _) in bounds {
|
||||
let predicate = predicate.subst(self.tcx(), substs);
|
||||
// Note: We can't use `to_opt_poly_trait_ref` here as `predicate`
|
||||
// may contain unbound variables. We therefore do this manually.
|
||||
//
|
||||
|
@ -194,11 +194,14 @@ where
|
||||
// The intent is to treat `impl Trait1 + Trait2` identically to
|
||||
// `dyn Trait1 + Trait2`. Therefore we ignore def-id of the opaque type itself
|
||||
// (it either has no visibility, or its visibility is insignificant, like
|
||||
// visibilities of type aliases) and recurse into predicates instead to go
|
||||
// visibilities of type aliases) and recurse into bounds instead to go
|
||||
// through the trait list (default type visitor doesn't visit those traits).
|
||||
// All traits in the list are considered the "primary" part of the type
|
||||
// and are visited by shallow visitors.
|
||||
if self.visit_predicates(tcx.predicates_of(def_id)) {
|
||||
if self.visit_predicates(ty::GenericPredicates {
|
||||
parent: None,
|
||||
predicates: tcx.explicit_item_bounds(def_id),
|
||||
}) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1800,6 +1803,14 @@ impl SearchInterfaceForPrivateItemsVisitor<'tcx> {
|
||||
self
|
||||
}
|
||||
|
||||
fn bounds(&mut self) -> &mut Self {
|
||||
self.visit_predicates(ty::GenericPredicates {
|
||||
parent: None,
|
||||
predicates: self.tcx.explicit_item_bounds(self.item_def_id),
|
||||
});
|
||||
self
|
||||
}
|
||||
|
||||
fn ty(&mut self) -> &mut Self {
|
||||
self.visit(self.tcx.type_of(self.item_def_id));
|
||||
self
|
||||
@ -1975,7 +1986,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||
hir::ItemKind::OpaqueTy(..) => {
|
||||
// `ty()` for opaque types is the underlying type,
|
||||
// it's not a part of interface, so we skip it.
|
||||
self.check(item.hir_id, item_visibility).generics().predicates();
|
||||
self.check(item.hir_id, item_visibility).generics().bounds();
|
||||
}
|
||||
hir::ItemKind::Trait(.., trait_item_refs) => {
|
||||
self.check(item.hir_id, item_visibility).generics().predicates();
|
||||
@ -1987,6 +1998,10 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||
trait_item_ref.defaultness,
|
||||
item_visibility,
|
||||
);
|
||||
|
||||
if let AssocItemKind::Type = trait_item_ref.kind {
|
||||
self.check(trait_item_ref.id.hir_id, item_visibility).bounds();
|
||||
}
|
||||
}
|
||||
}
|
||||
hir::ItemKind::TraitAlias(..) => {
|
||||
|
@ -73,18 +73,28 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
||||
}
|
||||
let bound_vars = bound_vars_for_item(self.interner.tcx, def_id);
|
||||
let binders = binders_for(&self.interner, bound_vars);
|
||||
// FIXME(chalk): this really isn't right I don't think. The functions
|
||||
// for GATs are a bit hard to figure out. Are these supposed to be where
|
||||
// clauses or bounds?
|
||||
|
||||
let where_clauses = self.where_clauses_for(def_id, bound_vars);
|
||||
|
||||
let bounds = self
|
||||
.tcx
|
||||
.explicit_item_bounds(def_id)
|
||||
.iter()
|
||||
.map(|(bound, _)| bound.subst(self.tcx, &bound_vars))
|
||||
.filter_map(|bound| {
|
||||
LowerInto::<
|
||||
Option<chalk_solve::rust_ir::QuantifiedInlineBound<RustInterner<'tcx>>>,
|
||||
>::lower_into(bound, &self.interner)
|
||||
})
|
||||
.collect();
|
||||
|
||||
Arc::new(chalk_solve::rust_ir::AssociatedTyDatum {
|
||||
trait_id: chalk_ir::TraitId(trait_def_id),
|
||||
id: assoc_type_id,
|
||||
name: (),
|
||||
binders: chalk_ir::Binders::new(
|
||||
binders,
|
||||
chalk_solve::rust_ir::AssociatedTyDatumBound { bounds: vec![], where_clauses },
|
||||
chalk_solve::rust_ir::AssociatedTyDatumBound { bounds, where_clauses },
|
||||
),
|
||||
})
|
||||
}
|
||||
@ -443,10 +453,17 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
||||
let binders = binders_for(&self.interner, bound_vars);
|
||||
let where_clauses = self.where_clauses_for(opaque_ty_id.0, bound_vars);
|
||||
|
||||
let bounds: Vec<_> = predicates
|
||||
.iter()
|
||||
.map(|(bound, _)| bound.subst(self.tcx, &bound_vars))
|
||||
.filter_map(|bound| LowerInto::<Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>>>::lower_into(bound, &self.interner))
|
||||
.collect();
|
||||
|
||||
let value = chalk_solve::rust_ir::OpaqueTyDatumBound {
|
||||
bounds: chalk_ir::Binders::new(binders.clone(), vec![]),
|
||||
bounds: chalk_ir::Binders::new(binders, bounds),
|
||||
where_clauses: chalk_ir::Binders::new(binders, where_clauses),
|
||||
};
|
||||
|
||||
Arc::new(chalk_solve::rust_ir::OpaqueTyDatum {
|
||||
opaque_ty_id,
|
||||
bound: chalk_ir::Binders::empty(&self.interner, value),
|
||||
|
@ -728,6 +728,84 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::FnSig<RustInterner<'tcx>>> for ty::Binder<t
|
||||
}
|
||||
}
|
||||
|
||||
// We lower into an Option here since there are some predicates which Chalk
|
||||
// doesn't have a representation for yet (as an `InlineBound`). The `Option` will
|
||||
// eventually be removed.
|
||||
impl<'tcx> LowerInto<'tcx, Option<chalk_solve::rust_ir::QuantifiedInlineBound<RustInterner<'tcx>>>>
|
||||
for ty::Predicate<'tcx>
|
||||
{
|
||||
fn lower_into(
|
||||
self,
|
||||
interner: &RustInterner<'tcx>,
|
||||
) -> Option<chalk_solve::rust_ir::QuantifiedInlineBound<RustInterner<'tcx>>> {
|
||||
match &self.kind() {
|
||||
ty::PredicateKind::Trait(predicate, _) => {
|
||||
let (predicate, binders, _named_regions) =
|
||||
collect_bound_vars(interner, interner.tcx, predicate);
|
||||
|
||||
Some(chalk_ir::Binders::new(
|
||||
binders,
|
||||
chalk_solve::rust_ir::InlineBound::TraitBound(
|
||||
predicate.trait_ref.lower_into(interner),
|
||||
),
|
||||
))
|
||||
}
|
||||
ty::PredicateKind::Projection(predicate) => {
|
||||
let (predicate, binders, _named_regions) =
|
||||
collect_bound_vars(interner, interner.tcx, predicate);
|
||||
|
||||
Some(chalk_ir::Binders::new(
|
||||
binders,
|
||||
chalk_solve::rust_ir::InlineBound::AliasEqBound(predicate.lower_into(interner)),
|
||||
))
|
||||
}
|
||||
ty::PredicateKind::TypeOutlives(_predicate) => None,
|
||||
ty::PredicateKind::WellFormed(_ty) => None,
|
||||
|
||||
ty::PredicateKind::RegionOutlives(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..) => bug!("unexpected predicate {}", &self),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> LowerInto<'tcx, chalk_solve::rust_ir::TraitBound<RustInterner<'tcx>>>
|
||||
for ty::TraitRef<'tcx>
|
||||
{
|
||||
fn lower_into(
|
||||
self,
|
||||
interner: &RustInterner<'tcx>,
|
||||
) -> chalk_solve::rust_ir::TraitBound<RustInterner<'tcx>> {
|
||||
chalk_solve::rust_ir::TraitBound {
|
||||
trait_id: chalk_ir::TraitId(self.def_id),
|
||||
args_no_self: self.substs[1..].iter().map(|arg| arg.lower_into(interner)).collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> LowerInto<'tcx, chalk_solve::rust_ir::AliasEqBound<RustInterner<'tcx>>>
|
||||
for ty::ProjectionPredicate<'tcx>
|
||||
{
|
||||
fn lower_into(
|
||||
self,
|
||||
interner: &RustInterner<'tcx>,
|
||||
) -> chalk_solve::rust_ir::AliasEqBound<RustInterner<'tcx>> {
|
||||
let trait_ref = self.projection_ty.trait_ref(interner.tcx);
|
||||
chalk_solve::rust_ir::AliasEqBound {
|
||||
trait_bound: trait_ref.lower_into(interner),
|
||||
associated_ty_id: chalk_ir::AssocTypeId(self.projection_ty.item_def_id),
|
||||
parameters: self.projection_ty.substs[trait_ref.substs.len()..]
|
||||
.iter()
|
||||
.map(|arg| arg.lower_into(interner))
|
||||
.collect(),
|
||||
value: self.ty.lower_into(interner),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// To collect bound vars, we have to do two passes. In the first pass, we
|
||||
/// collect all `BoundRegion`s and `ty::Bound`s. In the second pass, we then
|
||||
/// replace `BrNamed` into `BrAnon`. The two separate passes are important,
|
||||
|
@ -1,4 +1,5 @@
|
||||
use super::coercion::CoerceMany;
|
||||
use super::compare_method::check_type_bounds;
|
||||
use super::compare_method::{compare_const_impl, compare_impl_method, compare_ty_impl};
|
||||
use super::*;
|
||||
|
||||
@ -453,8 +454,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes(
|
||||
ty: None,
|
||||
};
|
||||
let prohibit_opaque = tcx
|
||||
.predicates_of(def_id)
|
||||
.predicates
|
||||
.explicit_item_bounds(def_id)
|
||||
.iter()
|
||||
.any(|(predicate, _)| predicate.visit_with(&mut visitor));
|
||||
debug!(
|
||||
@ -476,7 +476,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes(
|
||||
span,
|
||||
E0760,
|
||||
"`{}` return type cannot contain a projection or `Self` that references lifetimes from \
|
||||
a parent scope",
|
||||
a parent scope",
|
||||
if is_async { "async fn" } else { "impl Trait" },
|
||||
);
|
||||
|
||||
@ -553,9 +553,25 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) {
|
||||
|
||||
for item in items.iter() {
|
||||
let item = tcx.hir().trait_item(item.id);
|
||||
if let hir::TraitItemKind::Fn(sig, _) = &item.kind {
|
||||
let abi = sig.header.abi;
|
||||
fn_maybe_err(tcx, item.ident.span, abi);
|
||||
match item.kind {
|
||||
hir::TraitItemKind::Fn(ref sig, _) => {
|
||||
let abi = sig.header.abi;
|
||||
fn_maybe_err(tcx, item.ident.span, abi);
|
||||
}
|
||||
hir::TraitItemKind::Type(.., Some(_default)) => {
|
||||
let item_def_id = tcx.hir().local_def_id(item.hir_id).to_def_id();
|
||||
let assoc_item = tcx.associated_item(item_def_id);
|
||||
let trait_substs =
|
||||
InternalSubsts::identity_for_item(tcx, def_id.to_def_id());
|
||||
let _: Result<_, rustc_errors::ErrorReported> = check_type_bounds(
|
||||
tcx,
|
||||
assoc_item,
|
||||
assoc_item,
|
||||
item.span,
|
||||
ty::TraitRef { def_id: def_id.to_def_id(), substs: trait_substs },
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::intravisit;
|
||||
use rustc_hir::{GenericParamKind, ImplItemKind, TraitItemKind};
|
||||
use rustc_infer::infer::{self, InferOk, TyCtxtInferExt};
|
||||
use rustc_infer::traits::util;
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
||||
use rustc_middle::ty::subst::{InternalSubsts, Subst};
|
||||
@ -1170,20 +1171,13 @@ fn compare_type_predicate_entailment<'tcx>(
|
||||
/// For default associated types the normalization is not possible (the value
|
||||
/// from the impl could be overridden). We also can't normalize generic
|
||||
/// associated types (yet) because they contain bound parameters.
|
||||
fn check_type_bounds<'tcx>(
|
||||
pub fn check_type_bounds<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
trait_ty: &ty::AssocItem,
|
||||
impl_ty: &ty::AssocItem,
|
||||
impl_ty_span: Span,
|
||||
impl_trait_ref: ty::TraitRef<'tcx>,
|
||||
) -> Result<(), ErrorReported> {
|
||||
let have_gats = tcx.features().generic_associated_types;
|
||||
if impl_ty.defaultness.is_final() && !have_gats {
|
||||
// For "final", non-generic associate type implementations, we
|
||||
// don't need this as described above.
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Given
|
||||
//
|
||||
// impl<A, B> Foo<u32> for (A, B) {
|
||||
@ -1237,10 +1231,20 @@ fn check_type_bounds<'tcx>(
|
||||
ObligationCauseCode::ItemObligation(trait_ty.def_id),
|
||||
);
|
||||
|
||||
let predicates = tcx.item_bounds(trait_ty.def_id);
|
||||
debug!("check_type_bounds: item_bounds={:?}", predicates);
|
||||
let obligations = tcx
|
||||
.explicit_item_bounds(trait_ty.def_id)
|
||||
.iter()
|
||||
.map(|&(bound, span)| {
|
||||
let concrete_ty_bound =
|
||||
traits::subst_assoc_item_bound(tcx, bound, impl_ty_value, rebased_substs);
|
||||
debug!("check_type_bounds: concrete_ty_bound = {:?}", concrete_ty_bound);
|
||||
|
||||
for predicate in predicates {
|
||||
traits::Obligation::new(mk_cause(span), param_env, concrete_ty_bound)
|
||||
})
|
||||
.collect();
|
||||
debug!("check_type_bounds: item_bounds={:?}", obligations);
|
||||
|
||||
for obligation in util::elaborate_obligations(tcx, obligations) {
|
||||
let concrete_ty_predicate = predicate.subst(tcx, rebased_substs);
|
||||
debug!("compare_projection_bounds: concrete predicate = {:?}", concrete_ty_predicate);
|
||||
|
||||
@ -1252,12 +1256,7 @@ fn check_type_bounds<'tcx>(
|
||||
);
|
||||
debug!("compare_projection_bounds: normalized predicate = {:?}", normalized_predicate);
|
||||
|
||||
inh.register_predicates(obligations);
|
||||
inh.register_predicate(traits::Obligation::new(
|
||||
cause.clone(),
|
||||
param_env,
|
||||
normalized_predicate,
|
||||
));
|
||||
inh.register_predicate(obligation);
|
||||
}
|
||||
|
||||
// Check that all obligations are satisfied by the implementation's
|
||||
|
@ -420,6 +420,9 @@ fn check_associated_item(
|
||||
check_method_receiver(fcx, hir_sig, &item, self_ty);
|
||||
}
|
||||
ty::AssocKind::Type => {
|
||||
if let ty::AssocItemContainer::TraitContainer(_) = item.container {
|
||||
check_associated_type_bounds(fcx, item, span)
|
||||
}
|
||||
if item.defaultness.has_value() {
|
||||
let ty = fcx.tcx.type_of(item.def_id);
|
||||
let ty = fcx.normalize_associated_types_in(span, &ty);
|
||||
@ -571,7 +574,6 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) {
|
||||
|
||||
for_item(tcx, item).with_fcx(|fcx, _| {
|
||||
check_where_clauses(tcx, fcx, item.span, trait_def_id.to_def_id(), None);
|
||||
check_associated_type_defaults(fcx, trait_def_id.to_def_id());
|
||||
|
||||
vec![]
|
||||
});
|
||||
@ -581,96 +583,26 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) {
|
||||
///
|
||||
/// Assuming the defaults are used, check that all predicates (bounds on the
|
||||
/// assoc type and where clauses on the trait) hold.
|
||||
fn check_associated_type_defaults(fcx: &FnCtxt<'_, '_>, trait_def_id: DefId) {
|
||||
fn check_associated_type_bounds(fcx: &FnCtxt<'_, '_>, item: &ty::AssocItem, span: Span) {
|
||||
let tcx = fcx.tcx;
|
||||
let substs = InternalSubsts::identity_for_item(tcx, trait_def_id);
|
||||
|
||||
// For all assoc. types with defaults, build a map from
|
||||
// `<Self as Trait<...>>::Assoc` to the default type.
|
||||
let map = tcx
|
||||
.associated_items(trait_def_id)
|
||||
.in_definition_order()
|
||||
.filter_map(|item| {
|
||||
if item.kind == ty::AssocKind::Type && item.defaultness.has_value() {
|
||||
// `<Self as Trait<...>>::Assoc`
|
||||
let proj = ty::ProjectionTy { substs, item_def_id: item.def_id };
|
||||
let default_ty = tcx.type_of(item.def_id);
|
||||
debug!("assoc. type default mapping: {} -> {}", proj, default_ty);
|
||||
Some((proj, default_ty))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect::<FxHashMap<_, _>>();
|
||||
let bounds = tcx.explicit_item_bounds(item.def_id);
|
||||
|
||||
/// Replaces projections of associated types with their default types.
|
||||
///
|
||||
/// This does a "shallow substitution", meaning that defaults that refer to
|
||||
/// other defaulted assoc. types will still refer to the projection
|
||||
/// afterwards, not to the other default. For example:
|
||||
///
|
||||
/// ```compile_fail
|
||||
/// trait Tr {
|
||||
/// type A: Clone = Vec<Self::B>;
|
||||
/// type B = u8;
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// This will end up replacing the bound `Self::A: Clone` with
|
||||
/// `Vec<Self::B>: Clone`, not with `Vec<u8>: Clone`. If we did a deep
|
||||
/// substitution and ended up with the latter, the trait would be accepted.
|
||||
/// If an `impl` then replaced `B` with something that isn't `Clone`,
|
||||
/// suddenly the default for `A` is no longer valid. The shallow
|
||||
/// substitution forces the trait to add a `B: Clone` bound to be accepted,
|
||||
/// which means that an `impl` can replace any default without breaking
|
||||
/// others.
|
||||
///
|
||||
/// Note that this isn't needed for soundness: The defaults would still be
|
||||
/// checked in any impl that doesn't override them.
|
||||
struct DefaultNormalizer<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
map: FxHashMap<ty::ProjectionTy<'tcx>, Ty<'tcx>>,
|
||||
}
|
||||
debug!("check_associated_type_bounds: bounds={:?}", bounds);
|
||||
let wf_obligations = bounds.iter().flat_map(|&(bound, bound_span)| {
|
||||
let normalized_bound = fcx.normalize_associated_types_in(span, &bound);
|
||||
traits::wf::predicate_obligations(
|
||||
fcx,
|
||||
fcx.param_env,
|
||||
fcx.body_id,
|
||||
normalized_bound,
|
||||
bound_span,
|
||||
)
|
||||
});
|
||||
|
||||
impl<'tcx> ty::fold::TypeFolder<'tcx> for DefaultNormalizer<'tcx> {
|
||||
fn tcx<'a>(&'a self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match t.kind() {
|
||||
ty::Projection(proj_ty) => {
|
||||
if let Some(default) = self.map.get(&proj_ty) {
|
||||
default
|
||||
} else {
|
||||
t.super_fold_with(self)
|
||||
}
|
||||
}
|
||||
_ => t.super_fold_with(self),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now take all predicates defined on the trait, replace any mention of
|
||||
// the assoc. types with their default, and prove them.
|
||||
// We only consider predicates that directly mention the assoc. type.
|
||||
let mut norm = DefaultNormalizer { tcx, map };
|
||||
let predicates = fcx.tcx.predicates_of(trait_def_id);
|
||||
for &(orig_pred, span) in predicates.predicates.iter() {
|
||||
let pred = orig_pred.fold_with(&mut norm);
|
||||
if pred != orig_pred {
|
||||
// Mentions one of the defaulted assoc. types
|
||||
debug!("default suitability check: proving predicate: {} -> {}", orig_pred, pred);
|
||||
let pred = fcx.normalize_associated_types_in(span, &pred);
|
||||
let cause = traits::ObligationCause::new(
|
||||
span,
|
||||
fcx.body_id,
|
||||
traits::ItemObligation(trait_def_id),
|
||||
);
|
||||
let obligation = traits::Obligation::new(cause, fcx.param_env, pred);
|
||||
|
||||
fcx.register_predicate(obligation);
|
||||
}
|
||||
for obligation in wf_obligations {
|
||||
debug!("next obligation cause: {:?}", obligation.cause);
|
||||
fcx.register_predicate(obligation);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -711,8 +711,10 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::HirId) {
|
||||
tcx.ensure().generics_of(def_id);
|
||||
tcx.ensure().type_of(def_id);
|
||||
tcx.ensure().predicates_of(def_id);
|
||||
if let hir::ItemKind::Fn(..) = it.kind {
|
||||
tcx.ensure().fn_sig(def_id);
|
||||
match it.kind {
|
||||
hir::ItemKind::Fn(..) => tcx.ensure().fn_sig(def_id),
|
||||
hir::ItemKind::OpaqueTy(..) => tcx.ensure().item_bounds(def_id),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -733,15 +735,25 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) {
|
||||
tcx.ensure().type_of(def_id);
|
||||
}
|
||||
|
||||
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(_, Some(_)) => {
|
||||
hir::TraitItemKind::Const(..) => {
|
||||
tcx.ensure().type_of(def_id);
|
||||
// Account for `const C: _;` and `type T = _;`.
|
||||
// Account for `const C: _;`.
|
||||
let mut visitor = PlaceholderHirTyCollector::default();
|
||||
visitor.visit_trait_item(trait_item);
|
||||
placeholder_type_error(tcx, None, &[], visitor.0, false);
|
||||
}
|
||||
|
||||
hir::TraitItemKind::Type(_, Some(_)) => {
|
||||
tcx.ensure().item_bounds(def_id);
|
||||
tcx.ensure().type_of(def_id);
|
||||
// Account for `type T = _;`.
|
||||
let mut visitor = PlaceholderHirTyCollector::default();
|
||||
visitor.visit_trait_item(trait_item);
|
||||
placeholder_type_error(tcx, None, &[], visitor.0, false);
|
||||
}
|
||||
|
||||
hir::TraitItemKind::Type(_, None) => {
|
||||
tcx.ensure().item_bounds(def_id);
|
||||
// #74612: Visit and try to find bad placeholders
|
||||
// even if there is no concrete type.
|
||||
let mut visitor = PlaceholderHirTyCollector::default();
|
||||
|
@ -23,19 +23,17 @@ trait Case1 {
|
||||
Debug
|
||||
>
|
||||
> + Sync>;
|
||||
//~^^^^^^ ERROR `<<Self as Case1>::C as std::iter::Iterator>::Item` is not an iterator
|
||||
//~^^^^^^ ERROR `<<Self as Case1>::C as std::iter::Iterator>::Item` cannot be sent between threads safely
|
||||
//~^^^ ERROR `<<Self as Case1>::C as std::iter::Iterator>::Item` cannot be shared between threads safely
|
||||
}
|
||||
|
||||
pub struct S1;
|
||||
impl Case1 for S1 {
|
||||
//~^ ERROR `<L1 as Lam<&'a u8>>::App` doesn't implement `Debug` [E0277]
|
||||
type C = Once<Once<L1>>;
|
||||
}
|
||||
|
||||
fn assume_case1<T: Case1>() {
|
||||
//~^ ERROR `<_ as Lam<&'a u8>>::App` doesn't implement `Debug` [E0277]
|
||||
//~| ERROR `<<T as Case1>::C as Iterator>::Item` is not an iterator [E0277]
|
||||
//~| ERROR `<<T as Case1>::C as Iterator>::Item` cannot be sent between threads safely [E0277]
|
||||
//~| ERROR `<<T as Case1>::C as Iterator>::Item` cannot be shared between threads safely [E0277]
|
||||
fn assert_a<_0, A>() where A: Iterator<Item = _0>, _0: Debug {}
|
||||
assert_a::<_, T::A>();
|
||||
|
||||
|
@ -1,79 +1,54 @@
|
||||
error[E0277]: `<L1 as Lam<&'a u8>>::App` doesn't implement `Debug`
|
||||
--> $DIR/bad-bounds-on-assoc-in-trait.rs:29:6
|
||||
error[E0277]: `<<Self as Case1>::C as std::iter::Iterator>::Item` is not an iterator
|
||||
--> $DIR/bad-bounds-on-assoc-in-trait.rs:22:5
|
||||
|
|
||||
LL | trait Case1 {
|
||||
| ----- required by a bound in this
|
||||
...
|
||||
LL | Debug
|
||||
| ----- required by this bound in `Case1`
|
||||
...
|
||||
LL | impl Case1 for S1 {
|
||||
| ^^^^^ `<L1 as Lam<&'a u8>>::App` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
||||
LL | / type C: Clone + Iterator<Item:
|
||||
LL | | Send + Iterator<Item:
|
||||
LL | | for<'a> Lam<&'a u8, App:
|
||||
LL | | Debug
|
||||
LL | | >
|
||||
LL | | > + Sync>;
|
||||
| |__________________^ `<<Self as Case1>::C as std::iter::Iterator>::Item` is not an iterator
|
||||
|
|
||||
= help: the trait `for<'a> Debug` is not implemented for `<L1 as Lam<&'a u8>>::App`
|
||||
|
||||
error[E0277]: `<<T as Case1>::C as Iterator>::Item` is not an iterator
|
||||
--> $DIR/bad-bounds-on-assoc-in-trait.rs:34:20
|
||||
|
|
||||
LL | fn assume_case1<T: Case1>() {
|
||||
| ^^^^^ `<<T as Case1>::C as Iterator>::Item` is not an iterator
|
||||
|
|
||||
= help: the trait `Iterator` is not implemented for `<<T as Case1>::C as Iterator>::Item`
|
||||
= help: the trait `std::iter::Iterator` is not implemented for `<<Self as Case1>::C as std::iter::Iterator>::Item`
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | fn assume_case1<T: Case1>() where <<T as Case1>::C as Iterator>::Item: Iterator {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | trait Case1 where <<Self as Case1>::C as std::iter::Iterator>::Item: std::iter::Iterator {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `<<T as Case1>::C as Iterator>::Item` cannot be sent between threads safely
|
||||
--> $DIR/bad-bounds-on-assoc-in-trait.rs:34:20
|
||||
error[E0277]: `<<Self as Case1>::C as std::iter::Iterator>::Item` cannot be sent between threads safely
|
||||
--> $DIR/bad-bounds-on-assoc-in-trait.rs:23:9
|
||||
|
|
||||
LL | trait Case1 {
|
||||
| ----- required by a bound in this
|
||||
LL | type C: Clone + Iterator<Item:
|
||||
LL | Send + Iterator<Item:
|
||||
| ---- required by this bound in `Case1`
|
||||
...
|
||||
LL | fn assume_case1<T: Case1>() {
|
||||
| ^^^^^ `<<T as Case1>::C as Iterator>::Item` cannot be sent between threads safely
|
||||
| ^^^^ `<<Self as Case1>::C as std::iter::Iterator>::Item` cannot be sent between threads safely
|
||||
|
|
||||
= help: the trait `Send` is not implemented for `<<T as Case1>::C as Iterator>::Item`
|
||||
::: $SRC_DIR/libcore/marker.rs:LL:COL
|
||||
|
|
||||
LL | pub unsafe auto trait Send {
|
||||
| -------------------------- required by this bound in `std::marker::Send`
|
||||
|
|
||||
= help: the trait `std::marker::Send` is not implemented for `<<Self as Case1>::C as std::iter::Iterator>::Item`
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | fn assume_case1<T: Case1>() where <<T as Case1>::C as Iterator>::Item: Send {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | trait Case1 where <<Self as Case1>::C as std::iter::Iterator>::Item: std::marker::Send {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `<<T as Case1>::C as Iterator>::Item` cannot be shared between threads safely
|
||||
--> $DIR/bad-bounds-on-assoc-in-trait.rs:34:20
|
||||
error[E0277]: `<<Self as Case1>::C as std::iter::Iterator>::Item` cannot be shared between threads safely
|
||||
--> $DIR/bad-bounds-on-assoc-in-trait.rs:27:13
|
||||
|
|
||||
LL | trait Case1 {
|
||||
| ----- required by a bound in this
|
||||
...
|
||||
LL | > + Sync>;
|
||||
| ---- required by this bound in `Case1`
|
||||
...
|
||||
LL | fn assume_case1<T: Case1>() {
|
||||
| ^^^^^ `<<T as Case1>::C as Iterator>::Item` cannot be shared between threads safely
|
||||
| ^^^^ `<<Self as Case1>::C as std::iter::Iterator>::Item` cannot be shared between threads safely
|
||||
|
|
||||
= help: the trait `Sync` is not implemented for `<<T as Case1>::C as Iterator>::Item`
|
||||
::: $SRC_DIR/libcore/marker.rs:LL:COL
|
||||
|
|
||||
LL | pub unsafe auto trait Sync {
|
||||
| -------------------------- required by this bound in `std::marker::Sync`
|
||||
|
|
||||
= help: the trait `std::marker::Sync` is not implemented for `<<Self as Case1>::C as std::iter::Iterator>::Item`
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | fn assume_case1<T: Case1>() where <<T as Case1>::C as Iterator>::Item: Sync {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | trait Case1 where <<Self as Case1>::C as std::iter::Iterator>::Item: std::marker::Sync {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `<_ as Lam<&'a u8>>::App` doesn't implement `Debug`
|
||||
--> $DIR/bad-bounds-on-assoc-in-trait.rs:34:20
|
||||
|
|
||||
LL | trait Case1 {
|
||||
| ----- required by a bound in this
|
||||
...
|
||||
LL | Debug
|
||||
| ----- required by this bound in `Case1`
|
||||
...
|
||||
LL | fn assume_case1<T: Case1>() {
|
||||
| ^^^^^ `<_ as Lam<&'a u8>>::App` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
||||
|
|
||||
= help: the trait `for<'a> Debug` is not implemented for `<_ as Lam<&'a u8>>::App`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
@ -1,4 +1,4 @@
|
||||
// check-pass
|
||||
// ignore-tidy-linelength
|
||||
|
||||
#![feature(associated_type_bounds)]
|
||||
|
||||
@ -18,6 +18,7 @@ impl<'a, 'b> Lam<&'a &'b u8> for L2 { type App = u8; }
|
||||
|
||||
trait Case1 {
|
||||
type A: Iterator<Item: Debug>;
|
||||
//~^ ERROR `<<Self as Case1>::A as std::iter::Iterator>::Item` doesn't implement `std::fmt::Debug`
|
||||
|
||||
type B: Iterator<Item: 'static>;
|
||||
}
|
||||
@ -30,7 +31,11 @@ impl Case1 for S1 {
|
||||
|
||||
// Ensure we don't have opaque `impl Trait` desugaring:
|
||||
|
||||
// What is this supposed to mean? Rustc currently lowers `: Default` in the
|
||||
// bounds of `Out`, but trait selection can't find the bound since it applies
|
||||
// to a type other than `Self::Out`.
|
||||
pub trait Foo { type Out: Baz<Assoc: Default>; }
|
||||
//~^ ERROR trait bound `<<Self as Foo>::Out as Baz>::Assoc: std::default::Default` is not satisfied
|
||||
pub trait Baz { type Assoc; }
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -0,0 +1,36 @@
|
||||
error[E0277]: `<<Self as Case1>::A as std::iter::Iterator>::Item` doesn't implement `std::fmt::Debug`
|
||||
--> $DIR/bounds-on-assoc-in-trait.rs:20:28
|
||||
|
|
||||
LL | type A: Iterator<Item: Debug>;
|
||||
| ^^^^^ `<<Self as Case1>::A as std::iter::Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
|
||||
|
|
||||
::: $SRC_DIR/libcore/fmt/mod.rs:LL:COL
|
||||
|
|
||||
LL | pub trait Debug {
|
||||
| --------------- required by this bound in `std::fmt::Debug`
|
||||
|
|
||||
= help: the trait `std::fmt::Debug` is not implemented for `<<Self as Case1>::A as std::iter::Iterator>::Item`
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | trait Case1 where <<Self as Case1>::A as std::iter::Iterator>::Item: std::fmt::Debug {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `<<Self as Foo>::Out as Baz>::Assoc: std::default::Default` is not satisfied
|
||||
--> $DIR/bounds-on-assoc-in-trait.rs:37:38
|
||||
|
|
||||
LL | pub trait Foo { type Out: Baz<Assoc: Default>; }
|
||||
| ^^^^^^^ the trait `std::default::Default` is not implemented for `<<Self as Foo>::Out as Baz>::Assoc`
|
||||
|
|
||||
::: $SRC_DIR/libcore/default.rs:LL:COL
|
||||
|
|
||||
LL | pub trait Default: Sized {
|
||||
| ------------------------ required by this bound in `std::default::Default`
|
||||
|
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | pub trait Foo where <<Self as Foo>::Out as Baz>::Assoc: std::default::Default { type Out: Baz<Assoc: Default>; }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
@ -512,31 +512,7 @@ LL | trait TRSW3 where Self: Iterator<Item: 'static, Item: 'static> {}
|
||||
| `Item` bound here first
|
||||
|
||||
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
|
||||
--> $DIR/duplicate.rs:145:43
|
||||
|
|
||||
LL | trait TRA1 { type A: Iterator<Item: Copy, Item: Send>; }
|
||||
| ---------- ^^^^^^^^^^ re-bound here
|
||||
| |
|
||||
| `Item` bound here first
|
||||
|
||||
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
|
||||
--> $DIR/duplicate.rs:147:43
|
||||
|
|
||||
LL | trait TRA2 { type A: Iterator<Item: Copy, Item: Copy>; }
|
||||
| ---------- ^^^^^^^^^^ re-bound here
|
||||
| |
|
||||
| `Item` bound here first
|
||||
|
||||
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
|
||||
--> $DIR/duplicate.rs:149:46
|
||||
|
|
||||
LL | trait TRA3 { type A: Iterator<Item: 'static, Item: 'static>; }
|
||||
| ------------- ^^^^^^^^^^^^^ re-bound here
|
||||
| |
|
||||
| `Item` bound here first
|
||||
|
||||
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
|
||||
--> $DIR/duplicate.rs:152:40
|
||||
--> $DIR/duplicate.rs:167:40
|
||||
|
|
||||
LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>;
|
||||
| ---------- ^^^^^^^^^^ re-bound here
|
||||
|
@ -1,11 +1,14 @@
|
||||
error[E0284]: type annotations needed
|
||||
error[E0283]: type annotations needed
|
||||
--> $DIR/associated-types-unconstrained.rs:14:20
|
||||
|
|
||||
LL | fn bar() -> isize;
|
||||
| ------------------ required by `Foo::bar`
|
||||
...
|
||||
LL | let x: isize = Foo::bar();
|
||||
| ^^^^^^^^ cannot infer type
|
||||
|
|
||||
= note: cannot satisfy `<_ as Foo>::A == _`
|
||||
= note: cannot satisfy `_: Foo`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0284`.
|
||||
For more information about this error, try `rustc --explain E0283`.
|
||||
|
@ -6,11 +6,8 @@ trait Tr {
|
||||
type B = Self::A;
|
||||
}
|
||||
|
||||
// ...but is an error in any impl that doesn't override at least one of the defaults
|
||||
impl Tr for () {}
|
||||
//~^ ERROR overflow evaluating the requirement
|
||||
|
||||
// As soon as at least one is redefined, it works:
|
||||
impl Tr for u8 {
|
||||
type A = u8;
|
||||
}
|
||||
@ -24,16 +21,14 @@ impl Tr for u32 {
|
||||
type B = u8;
|
||||
}
|
||||
|
||||
// ...but only if this actually breaks the cycle
|
||||
// ...but not in an impl that redefines one of the types.
|
||||
impl Tr for bool {
|
||||
//~^ ERROR type mismatch resolving `<bool as Tr>::B == _`
|
||||
type A = Box<Self::B>;
|
||||
//~^ ERROR type mismatch resolving `<bool as Tr>::B == _`
|
||||
}
|
||||
// (the error is shown twice for some reason)
|
||||
|
||||
impl Tr for usize {
|
||||
//~^ ERROR type mismatch resolving `<usize as Tr>::B == _`
|
||||
type B = &'static Self::A;
|
||||
//~^ ERROR type mismatch resolving `<usize as Tr>::A == _`
|
||||
}
|
||||
|
@ -1,34 +1,16 @@
|
||||
error[E0275]: overflow evaluating the requirement `<() as Tr>::B == _`
|
||||
--> $DIR/defaults-cyclic-fail-1.rs:10:6
|
||||
|
|
||||
LL | impl Tr for () {}
|
||||
| ^^
|
||||
|
||||
error[E0271]: type mismatch resolving `<bool as Tr>::B == _`
|
||||
--> $DIR/defaults-cyclic-fail-1.rs:28:6
|
||||
|
|
||||
LL | impl Tr for bool {
|
||||
| ^^ cyclic type of infinite size
|
||||
|
||||
error[E0271]: type mismatch resolving `<usize as Tr>::B == _`
|
||||
--> $DIR/defaults-cyclic-fail-1.rs:35:6
|
||||
|
|
||||
LL | impl Tr for usize {
|
||||
| ^^ cyclic type of infinite size
|
||||
|
||||
error[E0271]: type mismatch resolving `<bool as Tr>::B == _`
|
||||
--> $DIR/defaults-cyclic-fail-1.rs:30:5
|
||||
error[E0275]: overflow evaluating the requirement `<bool as Tr>::B`
|
||||
--> $DIR/defaults-cyclic-fail-1.rs:26:5
|
||||
|
|
||||
LL | type A = Box<Self::B>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size
|
||||
|
||||
error[E0271]: type mismatch resolving `<usize as Tr>::A == _`
|
||||
--> $DIR/defaults-cyclic-fail-1.rs:37:5
|
||||
error[E0275]: overflow evaluating the requirement `<usize as Tr>::A`
|
||||
--> $DIR/defaults-cyclic-fail-1.rs:32:5
|
||||
|
|
||||
LL | type B = &'static Self::A;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0271, E0275.
|
||||
For more information about an error, try `rustc --explain E0271`.
|
||||
|
@ -8,11 +8,8 @@ trait Tr {
|
||||
type B = Box<Self::A>;
|
||||
}
|
||||
|
||||
// ...but is an error in any impl that doesn't override at least one of the defaults
|
||||
impl Tr for () {}
|
||||
//~^ ERROR type mismatch resolving `<() as Tr>::B == _`
|
||||
|
||||
// As soon as at least one is redefined, it works:
|
||||
impl Tr for u8 {
|
||||
type A = u8;
|
||||
}
|
||||
@ -26,16 +23,13 @@ impl Tr for u32 {
|
||||
type B = u8;
|
||||
}
|
||||
|
||||
// ...but only if this actually breaks the cycle
|
||||
impl Tr for bool {
|
||||
//~^ ERROR type mismatch resolving `<bool as Tr>::B == _`
|
||||
type A = Box<Self::B>;
|
||||
//~^ ERROR type mismatch resolving `<bool as Tr>::B == _`
|
||||
}
|
||||
// (the error is shown twice for some reason)
|
||||
|
||||
impl Tr for usize {
|
||||
//~^ ERROR type mismatch resolving `<usize as Tr>::B == _`
|
||||
type B = &'static Self::A;
|
||||
//~^ ERROR type mismatch resolving `<usize as Tr>::A == _`
|
||||
}
|
||||
|
@ -1,33 +1,15 @@
|
||||
error[E0271]: type mismatch resolving `<() as Tr>::B == _`
|
||||
--> $DIR/defaults-cyclic-fail-2.rs:12:6
|
||||
|
|
||||
LL | impl Tr for () {}
|
||||
| ^^ cyclic type of infinite size
|
||||
|
||||
error[E0271]: type mismatch resolving `<bool as Tr>::B == _`
|
||||
--> $DIR/defaults-cyclic-fail-2.rs:30:6
|
||||
|
|
||||
LL | impl Tr for bool {
|
||||
| ^^ cyclic type of infinite size
|
||||
|
||||
error[E0271]: type mismatch resolving `<usize as Tr>::B == _`
|
||||
--> $DIR/defaults-cyclic-fail-2.rs:37:6
|
||||
|
|
||||
LL | impl Tr for usize {
|
||||
| ^^ cyclic type of infinite size
|
||||
|
||||
error[E0271]: type mismatch resolving `<bool as Tr>::B == _`
|
||||
--> $DIR/defaults-cyclic-fail-2.rs:32:5
|
||||
error[E0275]: overflow evaluating the requirement `<bool as Tr>::B`
|
||||
--> $DIR/defaults-cyclic-fail-2.rs:27:5
|
||||
|
|
||||
LL | type A = Box<Self::B>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size
|
||||
|
||||
error[E0271]: type mismatch resolving `<usize as Tr>::A == _`
|
||||
--> $DIR/defaults-cyclic-fail-2.rs:39:5
|
||||
error[E0275]: overflow evaluating the requirement `<usize as Tr>::A`
|
||||
--> $DIR/defaults-cyclic-fail-2.rs:33:5
|
||||
|
|
||||
LL | type B = &'static Self::A;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0271`.
|
||||
|
@ -1,10 +1,8 @@
|
||||
//! Checks that associated type defaults are properly validated.
|
||||
//!
|
||||
//! This means:
|
||||
//! * Default types are wfchecked
|
||||
//! * Default types are checked against where clauses on the assoc. type
|
||||
//! (eg. `type Assoc: Clone = NotClone`), and also against where clauses on
|
||||
//! the trait itself when possible
|
||||
//! (eg. `type Assoc: Clone = NotClone`)
|
||||
|
||||
#![feature(associated_type_defaults)]
|
||||
|
||||
@ -17,15 +15,12 @@ trait Tr {
|
||||
}
|
||||
|
||||
// Where-clauses defined on the trait must also be considered
|
||||
trait Tr2 where Self::Ty: Clone {
|
||||
//~^ ERROR the trait bound `NotClone: Clone` is not satisfied
|
||||
trait Tr2
|
||||
where
|
||||
Self::Ty: Clone,
|
||||
{
|
||||
type Ty = NotClone;
|
||||
}
|
||||
|
||||
// Independent of where-clauses (there are none here), default types must always be wf
|
||||
trait Tr3 {
|
||||
type Ty = Vec<[u8]>;
|
||||
//~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
|
||||
//~^ ERROR the trait bound `NotClone: std::clone::Clone` is not satisfied
|
||||
}
|
||||
|
||||
// Involved type parameters must fulfill all bounds required by defaults that mention them
|
||||
@ -43,25 +38,24 @@ trait Bar: Sized {
|
||||
trait IsU8<T> {}
|
||||
impl<T> IsU8<u8> for T {}
|
||||
|
||||
// Test that mentioning the assoc. type inside where clauses works
|
||||
// Test that mentioning the assoc. type inside where clauses is not allowed
|
||||
trait C where
|
||||
Vec<Self::Assoc>: Clone,
|
||||
Self::Assoc: IsU8<Self::Assoc>,
|
||||
bool: IsU8<Self::Assoc>,
|
||||
{
|
||||
type Assoc = u8;
|
||||
//~^ ERROR the trait bound `u8: IsU8<<Self as C>::Assoc>` is not satisfied
|
||||
}
|
||||
|
||||
// Test that we get all expected errors if that default is unsuitable
|
||||
trait D where
|
||||
Vec<Self::Assoc>: Clone,
|
||||
//~^ ERROR the trait bound `NotClone: Clone` is not satisfied
|
||||
Self::Assoc: IsU8<Self::Assoc>,
|
||||
//~^ ERROR the trait bound `NotClone: IsU8<NotClone>` is not satisfied
|
||||
bool: IsU8<Self::Assoc>,
|
||||
//~^ ERROR the trait bound `bool: IsU8<NotClone>` is not satisfied
|
||||
{
|
||||
type Assoc = NotClone;
|
||||
//~^ ERROR the trait bound `NotClone: IsU8<<Self as D>::Assoc>` is not satisfied
|
||||
}
|
||||
|
||||
// Test behavior of the check when defaults refer to other defaults:
|
||||
@ -85,18 +79,20 @@ trait Foo25<T: Clone> {
|
||||
|
||||
// Adding the `Baz: Clone` bound isn't enough since the default is type
|
||||
// parameter `T`, which also might not be `Clone`.
|
||||
trait Foo3<T> where
|
||||
trait Foo3<T>
|
||||
where
|
||||
Self::Bar: Clone,
|
||||
Self::Baz: Clone,
|
||||
//~^ ERROR the trait bound `T: Clone` is not satisfied
|
||||
{
|
||||
type Bar = Vec<Self::Baz>;
|
||||
type Baz = T;
|
||||
//~^ ERROR the trait bound `T: std::clone::Clone` is not satisfied
|
||||
}
|
||||
|
||||
// This one finally works, with `Clone` bounds on all assoc. types and the type
|
||||
// parameter.
|
||||
trait Foo4<T> where
|
||||
trait Foo4<T>
|
||||
where
|
||||
T: Clone,
|
||||
{
|
||||
type Bar: Clone = Vec<Self::Baz>;
|
||||
|
@ -1,27 +1,31 @@
|
||||
error[E0277]: the trait bound `NotClone: Clone` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:15:14
|
||||
error[E0277]: the trait bound `NotClone: std::clone::Clone` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:13:5
|
||||
|
|
||||
LL | trait Tr {
|
||||
| -------- required by `Tr`
|
||||
LL | type Ty: Clone = NotClone;
|
||||
| ^^^^^ the trait `Clone` is not implemented for `NotClone`
|
||||
| ^^^^^^^^^-----^^^^^^^^^^^^
|
||||
| | |
|
||||
| | required by this bound in `Tr::Ty`
|
||||
| the trait `std::clone::Clone` is not implemented for `NotClone`
|
||||
|
||||
error[E0277]: the trait bound `NotClone: Clone` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:20:27
|
||||
error[E0277]: the trait bound `NotClone: std::clone::Clone` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:19:5
|
||||
|
|
||||
LL | trait Tr2 where Self::Ty: Clone {
|
||||
| --------------------------^^^^^
|
||||
| | |
|
||||
| | the trait `Clone` is not implemented for `NotClone`
|
||||
| required by `Tr2`
|
||||
| ----- required by this bound in `Tr2::Ty`
|
||||
LL | type Ty = NotClone;
|
||||
| ^^^^^--^^^^^^^^^^^^
|
||||
| | |
|
||||
| | required by a bound in this
|
||||
| the trait `std::clone::Clone` is not implemented for `NotClone`
|
||||
|
||||
error[E0277]: the trait bound `T: Clone` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:33:15
|
||||
error[E0277]: the trait bound `T: std::clone::Clone` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:25:5
|
||||
|
|
||||
LL | trait Foo<T> {
|
||||
| ------------ required by `Foo`
|
||||
LL | type Bar: Clone = Vec<T>;
|
||||
| ^^^^^ the trait `Clone` is not implemented for `T`
|
||||
| ^^^^^^^^^^-----^^^^^^^^^^
|
||||
| | |
|
||||
| | required by this bound in `Foo::Bar`
|
||||
| the trait `std::clone::Clone` is not implemented for `T`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `Clone` for `Vec<T>`
|
||||
help: consider restricting type parameter `T`
|
||||
@ -30,64 +34,46 @@ LL | trait Foo<T: Clone> {
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `(): Foo<Self>` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:39:17
|
||||
--> $DIR/defaults-suitability.rs:31:5
|
||||
|
|
||||
LL | trait Bar: Sized {
|
||||
| ---------------- required by `Bar`
|
||||
LL | // `(): Foo<Self>` might hold for some possible impls but not all.
|
||||
LL | type Assoc: Foo<Self> = ();
|
||||
| ^^^^^^^^^ the trait `Foo<Self>` is not implemented for `()`
|
||||
| ^^^^^^^^^^^^---------^^^^^^
|
||||
| | |
|
||||
| | required by this bound in `Bar::Assoc`
|
||||
| the trait `Foo<Self>` is not implemented for `()`
|
||||
|
||||
error[E0277]: the trait bound `NotClone: IsU8<NotClone>` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:59:18
|
||||
error[E0277]: the trait bound `u8: IsU8<<Self as C>::Assoc>` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:44:5
|
||||
|
|
||||
LL | / trait D where
|
||||
LL | | Vec<Self::Assoc>: Clone,
|
||||
LL | |
|
||||
LL | | Self::Assoc: IsU8<Self::Assoc>,
|
||||
| | ^^^^^^^^^^^^^^^^^ the trait `IsU8<NotClone>` is not implemented for `NotClone`
|
||||
... |
|
||||
LL | | type Assoc = NotClone;
|
||||
LL | | }
|
||||
| |_- required by `D`
|
||||
LL | Self::Assoc: IsU8<Self::Assoc>,
|
||||
| ----------------- required by this bound in `C::Assoc`
|
||||
...
|
||||
LL | type Assoc = u8;
|
||||
| ^^^^^-----^^^^^^
|
||||
| | |
|
||||
| | required by a bound in this
|
||||
| the trait `IsU8<<Self as C>::Assoc>` is not implemented for `u8`
|
||||
|
||||
error[E0277]: the trait bound `bool: IsU8<NotClone>` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:61:11
|
||||
error[E0277]: the trait bound `NotClone: IsU8<<Self as D>::Assoc>` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:54:5
|
||||
|
|
||||
LL | / trait D where
|
||||
LL | | Vec<Self::Assoc>: Clone,
|
||||
LL | |
|
||||
LL | | Self::Assoc: IsU8<Self::Assoc>,
|
||||
LL | |
|
||||
LL | | bool: IsU8<Self::Assoc>,
|
||||
| | ^^^^^^^^^^^^^^^^^ the trait `IsU8<NotClone>` is not implemented for `bool`
|
||||
... |
|
||||
LL | | type Assoc = NotClone;
|
||||
LL | | }
|
||||
| |_- required by `D`
|
||||
LL | Self::Assoc: IsU8<Self::Assoc>,
|
||||
| ----------------- required by this bound in `D::Assoc`
|
||||
...
|
||||
LL | type Assoc = NotClone;
|
||||
| ^^^^^-----^^^^^^^^^^^^
|
||||
| | |
|
||||
| | required by a bound in this
|
||||
| the trait `IsU8<<Self as D>::Assoc>` is not implemented for `NotClone`
|
||||
|
||||
error[E0277]: the trait bound `NotClone: Clone` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:57:23
|
||||
error[E0277]: the trait bound `<Self as Foo2<T>>::Baz: std::clone::Clone` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:63:5
|
||||
|
|
||||
LL | / trait D where
|
||||
LL | | Vec<Self::Assoc>: Clone,
|
||||
| | ^^^^^ the trait `Clone` is not implemented for `NotClone`
|
||||
LL | |
|
||||
LL | | Self::Assoc: IsU8<Self::Assoc>,
|
||||
... |
|
||||
LL | | type Assoc = NotClone;
|
||||
LL | | }
|
||||
| |_- required by `D`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `Clone` for `Vec<NotClone>`
|
||||
|
||||
error[E0277]: the trait bound `<Self as Foo2<T>>::Baz: Clone` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:72:15
|
||||
|
|
||||
LL | trait Foo2<T> {
|
||||
| ------------- required by `Foo2`
|
||||
LL | type Bar: Clone = Vec<Self::Baz>;
|
||||
| ^^^^^ the trait `Clone` is not implemented for `<Self as Foo2<T>>::Baz`
|
||||
| ^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^
|
||||
| | |
|
||||
| | required by this bound in `Foo2::Bar`
|
||||
| the trait `std::clone::Clone` is not implemented for `<Self as Foo2<T>>::Baz`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `Clone` for `Vec<<Self as Foo2<T>>::Baz>`
|
||||
help: consider further restricting the associated type
|
||||
@ -95,13 +81,14 @@ help: consider further restricting the associated type
|
||||
LL | trait Foo2<T> where <Self as Foo2<T>>::Baz: Clone {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `<Self as Foo25<T>>::Baz: Clone` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:81:15
|
||||
error[E0277]: the trait bound `<Self as Foo25<T>>::Baz: std::clone::Clone` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:72:5
|
||||
|
|
||||
LL | trait Foo25<T: Clone> {
|
||||
| --------------------- required by `Foo25`
|
||||
LL | type Bar: Clone = Vec<Self::Baz>;
|
||||
| ^^^^^ the trait `Clone` is not implemented for `<Self as Foo25<T>>::Baz`
|
||||
| ^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^
|
||||
| | |
|
||||
| | required by this bound in `Foo25::Bar`
|
||||
| the trait `std::clone::Clone` is not implemented for `<Self as Foo25<T>>::Baz`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `Clone` for `Vec<<Self as Foo25<T>>::Baz>`
|
||||
help: consider further restricting the associated type
|
||||
@ -109,37 +96,23 @@ help: consider further restricting the associated type
|
||||
LL | trait Foo25<T: Clone> where <Self as Foo25<T>>::Baz: Clone {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `T: Clone` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:90:16
|
||||
error[E0277]: the trait bound `T: std::clone::Clone` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:84:5
|
||||
|
|
||||
LL | / trait Foo3<T> where
|
||||
LL | | Self::Bar: Clone,
|
||||
LL | | Self::Baz: Clone,
|
||||
| | ^^^^^ the trait `Clone` is not implemented for `T`
|
||||
LL | |
|
||||
... |
|
||||
LL | | type Baz = T;
|
||||
LL | | }
|
||||
| |_- required by `Foo3`
|
||||
LL | Self::Baz: Clone,
|
||||
| ----- required by this bound in `Foo3::Baz`
|
||||
...
|
||||
LL | type Baz = T;
|
||||
| ^^^^^---^^^^^
|
||||
| | |
|
||||
| | required by a bound in this
|
||||
| the trait `std::clone::Clone` is not implemented for `T`
|
||||
|
|
||||
help: consider further restricting type parameter `T`
|
||||
|
|
||||
LL | Self::Baz: Clone, T: Clone
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
|
||||
--> $DIR/defaults-suitability.rs:27:5
|
||||
|
|
||||
LL | type Ty = Vec<[u8]>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
::: $SRC_DIR/alloc/src/vec.rs:LL:COL
|
||||
|
|
||||
LL | pub struct Vec<T> {
|
||||
| - required by this bound in `Vec`
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `[u8]`
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
@ -11,22 +11,13 @@
|
||||
|
||||
use std::{
|
||||
fmt::Display,
|
||||
ops::{AddAssign, Deref}
|
||||
ops::{AddAssign, Deref},
|
||||
};
|
||||
|
||||
|
||||
trait UncheckedCopy: Sized {
|
||||
// This Output is said to be Copy. Yet we default to Self
|
||||
// and it's accepted, not knowing if Self ineed is Copy
|
||||
type Output: Copy
|
||||
//~^ ERROR the trait bound `Self: Copy` is not satisfied
|
||||
+ Deref<Target = str>
|
||||
//~^ ERROR the trait bound `Self: Deref` is not satisfied
|
||||
+ AddAssign<&'static str>
|
||||
//~^ ERROR cannot add-assign `&'static str` to `Self`
|
||||
+ From<Self>
|
||||
+ Display = Self;
|
||||
//~^ ERROR `Self` doesn't implement `std::fmt::Display`
|
||||
type Output: Copy + Deref<Target = str> + AddAssign<&'static str> + From<Self> + Display = Self;
|
||||
|
||||
// We said the Output type was Copy, so we can Copy it freely!
|
||||
fn unchecked_copy(other: &Self::Output) -> Self::Output {
|
||||
@ -39,10 +30,6 @@ trait UncheckedCopy: Sized {
|
||||
}
|
||||
|
||||
impl<T> UncheckedCopy for T {}
|
||||
//~^ ERROR `T` doesn't implement `std::fmt::Display`
|
||||
//~| ERROR the trait bound `T: Deref` is not satisfied
|
||||
//~| ERROR cannot add-assign `&'static str` to `T`
|
||||
//~| ERROR the trait bound `T: Copy` is not satisfied
|
||||
|
||||
fn bug<T: UncheckedCopy>(origin: T) {
|
||||
let origin = T::make_origin(origin);
|
||||
|
@ -1,53 +1,19 @@
|
||||
error[E0277]: the trait bound `Self: Copy` is not satisfied
|
||||
--> $DIR/defaults-unsound-62211-1.rs:21:18
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized {
|
||||
| -------------------------- required by `UncheckedCopy`
|
||||
...
|
||||
LL | type Output: Copy
|
||||
| ^^^^ the trait `Copy` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized + Copy {
|
||||
| ^^^^^^
|
||||
|
||||
error[E0277]: cannot add-assign `&'static str` to `Self`
|
||||
--> $DIR/defaults-unsound-62211-1.rs:25:7
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized {
|
||||
| -------------------------- required by `UncheckedCopy`
|
||||
...
|
||||
LL | + AddAssign<&'static str>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `Self += &'static str`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized + AddAssign<&'static str> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `Self: Deref` is not satisfied
|
||||
--> $DIR/defaults-unsound-62211-1.rs:23:7
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized {
|
||||
| -------------------------- required by `UncheckedCopy`
|
||||
...
|
||||
LL | + Deref<Target = str>
|
||||
| ^^^^^^^^^^^^^^^^^^^ the trait `Deref` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized + Deref {
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0277]: `Self` doesn't implement `std::fmt::Display`
|
||||
--> $DIR/defaults-unsound-62211-1.rs:28:7
|
||||
--> $DIR/defaults-unsound-62211-1.rs:21:5
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized {
|
||||
| -------------------------- required by `UncheckedCopy`
|
||||
...
|
||||
LL | + Display = Self;
|
||||
| ^^^^^^^ `Self` cannot be formatted with the default formatter
|
||||
LL | type Output: Copy
|
||||
| ^ ------ required by a bound in this
|
||||
| _____|
|
||||
| |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | + From<Self>
|
||||
LL | | + Display = Self;
|
||||
| |___________-------_______^ `Self` cannot be formatted with the default formatter
|
||||
| |
|
||||
| required by this bound in `UncheckedCopy::Output`
|
||||
|
|
||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||
help: consider further restricting `Self`
|
||||
@ -55,75 +21,71 @@ help: consider further restricting `Self`
|
||||
LL | trait UncheckedCopy: Sized + std::fmt::Display {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `T` doesn't implement `std::fmt::Display`
|
||||
--> $DIR/defaults-unsound-62211-1.rs:41:9
|
||||
error[E0277]: the trait bound `Self: std::ops::Deref` is not satisfied
|
||||
--> $DIR/defaults-unsound-62211-1.rs:21:5
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized {
|
||||
| ------------- required by a bound in this
|
||||
...
|
||||
LL | + Display = Self;
|
||||
| ------- required by this bound in `UncheckedCopy`
|
||||
...
|
||||
LL | impl<T> UncheckedCopy for T {}
|
||||
| ^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter
|
||||
LL | type Output: Copy
|
||||
| ^ ------ required by a bound in this
|
||||
| _____|
|
||||
| |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | + Deref<Target = str>
|
||||
| | ------------------- required by this bound in `UncheckedCopy::Output`
|
||||
LL | | + AddAssign<&'static str>
|
||||
LL | | + From<Self>
|
||||
LL | | + Display = Self;
|
||||
| |_________________________^ the trait `std::ops::Deref` is not implemented for `Self`
|
||||
|
|
||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||
help: consider restricting type parameter `T`
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | impl<T: std::fmt::Display> UncheckedCopy for T {}
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
LL | trait UncheckedCopy: Sized + Deref {
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `T: Deref` is not satisfied
|
||||
--> $DIR/defaults-unsound-62211-1.rs:41:9
|
||||
error[E0277]: cannot add-assign `&'static str` to `Self`
|
||||
--> $DIR/defaults-unsound-62211-1.rs:21:5
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized {
|
||||
| ------------- required by a bound in this
|
||||
...
|
||||
LL | + Deref<Target = str>
|
||||
| ------------------- required by this bound in `UncheckedCopy`
|
||||
...
|
||||
LL | impl<T> UncheckedCopy for T {}
|
||||
| ^^^^^^^^^^^^^ the trait `Deref` is not implemented for `T`
|
||||
LL | type Output: Copy
|
||||
| ^ ------ required by a bound in this
|
||||
| _____|
|
||||
| |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | + AddAssign<&'static str>
|
||||
| | ----------------------- required by this bound in `UncheckedCopy::Output`
|
||||
LL | | + From<Self>
|
||||
LL | | + Display = Self;
|
||||
| |_________________________^ no implementation for `Self += &'static str`
|
||||
|
|
||||
help: consider restricting type parameter `T`
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | impl<T: Deref> UncheckedCopy for T {}
|
||||
| ^^^^^^^
|
||||
LL | trait UncheckedCopy: Sized + std::ops::AddAssign<&'static str> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: cannot add-assign `&'static str` to `T`
|
||||
--> $DIR/defaults-unsound-62211-1.rs:41:9
|
||||
error[E0277]: the trait bound `Self: std::marker::Copy` is not satisfied
|
||||
--> $DIR/defaults-unsound-62211-1.rs:21:5
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized {
|
||||
| ------------- required by a bound in this
|
||||
...
|
||||
LL | + AddAssign<&'static str>
|
||||
| ----------------------- required by this bound in `UncheckedCopy`
|
||||
...
|
||||
LL | impl<T> UncheckedCopy for T {}
|
||||
| ^^^^^^^^^^^^^ no implementation for `T += &'static str`
|
||||
LL | type Output: Copy
|
||||
| ^ ---- required by this bound in `UncheckedCopy::Output`
|
||||
| _____|
|
||||
| |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | + From<Self>
|
||||
LL | | + Display = Self;
|
||||
| |_________________________^ the trait `std::marker::Copy` is not implemented for `Self`
|
||||
|
|
||||
help: consider restricting type parameter `T`
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | impl<T: AddAssign<&'static str>> UncheckedCopy for T {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | trait UncheckedCopy: Sized + std::marker::Copy {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `T: Copy` is not satisfied
|
||||
--> $DIR/defaults-unsound-62211-1.rs:41:9
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized {
|
||||
| ------------- required by a bound in this
|
||||
...
|
||||
LL | type Output: Copy
|
||||
| ---- required by this bound in `UncheckedCopy`
|
||||
...
|
||||
LL | impl<T> UncheckedCopy for T {}
|
||||
| ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T`
|
||||
|
|
||||
help: consider restricting type parameter `T`
|
||||
|
|
||||
LL | impl<T: Copy> UncheckedCopy for T {}
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
@ -11,22 +11,13 @@
|
||||
|
||||
use std::{
|
||||
fmt::Display,
|
||||
ops::{AddAssign, Deref}
|
||||
ops::{AddAssign, Deref},
|
||||
};
|
||||
|
||||
|
||||
trait UncheckedCopy: Sized {
|
||||
// This Output is said to be Copy. Yet we default to Self
|
||||
// and it's accepted, not knowing if Self ineed is Copy
|
||||
type Output: Copy
|
||||
//~^ ERROR the trait bound `Self: Copy` is not satisfied
|
||||
+ Deref<Target = str>
|
||||
//~^ ERROR the trait bound `Self: Deref` is not satisfied
|
||||
+ AddAssign<&'static str>
|
||||
//~^ ERROR cannot add-assign `&'static str` to `Self`
|
||||
+ From<Self>
|
||||
+ Display = Self;
|
||||
//~^ ERROR `Self` doesn't implement `std::fmt::Display`
|
||||
type Output: Copy + Deref<Target = str> + AddAssign<&'static str> + From<Self> + Display = Self;
|
||||
|
||||
// We said the Output type was Copy, so we can Copy it freely!
|
||||
fn unchecked_copy(other: &Self::Output) -> Self::Output {
|
||||
@ -39,10 +30,6 @@ trait UncheckedCopy: Sized {
|
||||
}
|
||||
|
||||
impl<T> UncheckedCopy for T {}
|
||||
//~^ ERROR `T` doesn't implement `std::fmt::Display`
|
||||
//~| ERROR the trait bound `T: Deref` is not satisfied
|
||||
//~| ERROR cannot add-assign `&'static str` to `T`
|
||||
//~| ERROR the trait bound `T: Copy` is not satisfied
|
||||
|
||||
fn bug<T: UncheckedCopy>(origin: T) {
|
||||
let origin = T::make_origin(origin);
|
||||
|
@ -1,53 +1,19 @@
|
||||
error[E0277]: the trait bound `Self: Copy` is not satisfied
|
||||
--> $DIR/defaults-unsound-62211-2.rs:21:18
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized {
|
||||
| -------------------------- required by `UncheckedCopy`
|
||||
...
|
||||
LL | type Output: Copy
|
||||
| ^^^^ the trait `Copy` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized + Copy {
|
||||
| ^^^^^^
|
||||
|
||||
error[E0277]: cannot add-assign `&'static str` to `Self`
|
||||
--> $DIR/defaults-unsound-62211-2.rs:25:7
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized {
|
||||
| -------------------------- required by `UncheckedCopy`
|
||||
...
|
||||
LL | + AddAssign<&'static str>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `Self += &'static str`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized + AddAssign<&'static str> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `Self: Deref` is not satisfied
|
||||
--> $DIR/defaults-unsound-62211-2.rs:23:7
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized {
|
||||
| -------------------------- required by `UncheckedCopy`
|
||||
...
|
||||
LL | + Deref<Target = str>
|
||||
| ^^^^^^^^^^^^^^^^^^^ the trait `Deref` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized + Deref {
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0277]: `Self` doesn't implement `std::fmt::Display`
|
||||
--> $DIR/defaults-unsound-62211-2.rs:28:7
|
||||
--> $DIR/defaults-unsound-62211-2.rs:21:5
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized {
|
||||
| -------------------------- required by `UncheckedCopy`
|
||||
...
|
||||
LL | + Display = Self;
|
||||
| ^^^^^^^ `Self` cannot be formatted with the default formatter
|
||||
LL | type Output: Copy
|
||||
| ^ ------ required by a bound in this
|
||||
| _____|
|
||||
| |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | + From<Self>
|
||||
LL | | + Display = Self;
|
||||
| |___________-------_______^ `Self` cannot be formatted with the default formatter
|
||||
| |
|
||||
| required by this bound in `UncheckedCopy::Output`
|
||||
|
|
||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||
help: consider further restricting `Self`
|
||||
@ -55,75 +21,71 @@ help: consider further restricting `Self`
|
||||
LL | trait UncheckedCopy: Sized + std::fmt::Display {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `T` doesn't implement `std::fmt::Display`
|
||||
--> $DIR/defaults-unsound-62211-2.rs:41:9
|
||||
error[E0277]: the trait bound `Self: std::ops::Deref` is not satisfied
|
||||
--> $DIR/defaults-unsound-62211-2.rs:21:5
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized {
|
||||
| ------------- required by a bound in this
|
||||
...
|
||||
LL | + Display = Self;
|
||||
| ------- required by this bound in `UncheckedCopy`
|
||||
...
|
||||
LL | impl<T> UncheckedCopy for T {}
|
||||
| ^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter
|
||||
LL | type Output: Copy
|
||||
| ^ ------ required by a bound in this
|
||||
| _____|
|
||||
| |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | + Deref<Target = str>
|
||||
| | ------------------- required by this bound in `UncheckedCopy::Output`
|
||||
LL | | + AddAssign<&'static str>
|
||||
LL | | + From<Self>
|
||||
LL | | + Display = Self;
|
||||
| |_________________________^ the trait `std::ops::Deref` is not implemented for `Self`
|
||||
|
|
||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||
help: consider restricting type parameter `T`
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | impl<T: std::fmt::Display> UncheckedCopy for T {}
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
LL | trait UncheckedCopy: Sized + Deref {
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `T: Deref` is not satisfied
|
||||
--> $DIR/defaults-unsound-62211-2.rs:41:9
|
||||
error[E0277]: cannot add-assign `&'static str` to `Self`
|
||||
--> $DIR/defaults-unsound-62211-2.rs:21:5
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized {
|
||||
| ------------- required by a bound in this
|
||||
...
|
||||
LL | + Deref<Target = str>
|
||||
| ------------------- required by this bound in `UncheckedCopy`
|
||||
...
|
||||
LL | impl<T> UncheckedCopy for T {}
|
||||
| ^^^^^^^^^^^^^ the trait `Deref` is not implemented for `T`
|
||||
LL | type Output: Copy
|
||||
| ^ ------ required by a bound in this
|
||||
| _____|
|
||||
| |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | + AddAssign<&'static str>
|
||||
| | ----------------------- required by this bound in `UncheckedCopy::Output`
|
||||
LL | | + From<Self>
|
||||
LL | | + Display = Self;
|
||||
| |_________________________^ no implementation for `Self += &'static str`
|
||||
|
|
||||
help: consider restricting type parameter `T`
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | impl<T: Deref> UncheckedCopy for T {}
|
||||
| ^^^^^^^
|
||||
LL | trait UncheckedCopy: Sized + std::ops::AddAssign<&'static str> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: cannot add-assign `&'static str` to `T`
|
||||
--> $DIR/defaults-unsound-62211-2.rs:41:9
|
||||
error[E0277]: the trait bound `Self: std::marker::Copy` is not satisfied
|
||||
--> $DIR/defaults-unsound-62211-2.rs:21:5
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized {
|
||||
| ------------- required by a bound in this
|
||||
...
|
||||
LL | + AddAssign<&'static str>
|
||||
| ----------------------- required by this bound in `UncheckedCopy`
|
||||
...
|
||||
LL | impl<T> UncheckedCopy for T {}
|
||||
| ^^^^^^^^^^^^^ no implementation for `T += &'static str`
|
||||
LL | type Output: Copy
|
||||
| ^ ---- required by this bound in `UncheckedCopy::Output`
|
||||
| _____|
|
||||
| |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | + From<Self>
|
||||
LL | | + Display = Self;
|
||||
| |_________________________^ the trait `std::marker::Copy` is not implemented for `Self`
|
||||
|
|
||||
help: consider restricting type parameter `T`
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | impl<T: AddAssign<&'static str>> UncheckedCopy for T {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | trait UncheckedCopy: Sized + std::marker::Copy {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `T: Copy` is not satisfied
|
||||
--> $DIR/defaults-unsound-62211-2.rs:41:9
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized {
|
||||
| ------------- required by a bound in this
|
||||
...
|
||||
LL | type Output: Copy
|
||||
| ---- required by this bound in `UncheckedCopy`
|
||||
...
|
||||
LL | impl<T> UncheckedCopy for T {}
|
||||
| ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T`
|
||||
|
|
||||
help: consider restricting type parameter `T`
|
||||
|
|
||||
LL | impl<T: Copy> UncheckedCopy for T {}
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
11
src/test/ui/associated-types/defaults-wf.rs
Normal file
11
src/test/ui/associated-types/defaults-wf.rs
Normal file
@ -0,0 +1,11 @@
|
||||
// Check that associated type defaults are wf checked.
|
||||
|
||||
#![feature(associated_type_defaults)]
|
||||
|
||||
// Default types must always be wf
|
||||
trait Tr3 {
|
||||
type Ty = Vec<[u8]>;
|
||||
//~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
|
||||
}
|
||||
|
||||
fn main() {}
|
16
src/test/ui/associated-types/defaults-wf.stderr
Normal file
16
src/test/ui/associated-types/defaults-wf.stderr
Normal file
@ -0,0 +1,16 @@
|
||||
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
|
||||
--> $DIR/defaults-wf.rs:7:5
|
||||
|
|
||||
LL | type Ty = Vec<[u8]>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
::: $SRC_DIR/liballoc/vec.rs:LL:COL
|
||||
|
|
||||
LL | pub struct Vec<T> {
|
||||
| - required by this bound in `std::vec::Vec`
|
||||
|
|
||||
= help: the trait `std::marker::Sized` is not implemented for `[u8]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
@ -4,12 +4,13 @@
|
||||
// type-checked.
|
||||
|
||||
trait Foo<T: Default + ToString> {
|
||||
type Out: Default + ToString + ?Sized = dyn ToString; //~ error: not satisfied
|
||||
type Out: Default + ToString + ?Sized = dyn ToString; //~ ERROR not satisfied
|
||||
}
|
||||
|
||||
impl Foo<u32> for () {} //~ error: not satisfied
|
||||
impl Foo<u64> for () {} //~ error: not satisfied
|
||||
impl Foo<u32> for () {}
|
||||
impl Foo<u64> for () {}
|
||||
|
||||
fn main() {
|
||||
assert_eq!(<() as Foo<u32>>::Out::default().to_string(), "false");
|
||||
//~^ ERROR no function or associated item named `default` found for trait object
|
||||
}
|
||||
|
@ -1,33 +1,19 @@
|
||||
error[E0277]: the trait bound `(dyn ToString + 'static): Default` is not satisfied
|
||||
--> $DIR/issue-43924.rs:7:15
|
||||
error[E0277]: the trait bound `(dyn std::string::ToString + 'static): std::default::Default` is not satisfied
|
||||
--> $DIR/issue-43924.rs:7:5
|
||||
|
|
||||
LL | trait Foo<T: Default + ToString> {
|
||||
| -------------------------------- required by `Foo`
|
||||
LL | type Out: Default + ToString + ?Sized = dyn ToString;
|
||||
| ^^^^^^^ the trait `Default` is not implemented for `(dyn ToString + 'static)`
|
||||
| ^^^^^^^^^^-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| | |
|
||||
| | required by this bound in `Foo::Out`
|
||||
| the trait `std::default::Default` is not implemented for `(dyn std::string::ToString + 'static)`
|
||||
|
||||
error[E0277]: the trait bound `(dyn ToString + 'static): Default` is not satisfied
|
||||
--> $DIR/issue-43924.rs:10:6
|
||||
error[E0599]: no function or associated item named `default` found for trait object `(dyn std::string::ToString + 'static)` in the current scope
|
||||
--> $DIR/issue-43924.rs:14:39
|
||||
|
|
||||
LL | trait Foo<T: Default + ToString> {
|
||||
| --- required by a bound in this
|
||||
LL | type Out: Default + ToString + ?Sized = dyn ToString;
|
||||
| ------- required by this bound in `Foo`
|
||||
...
|
||||
LL | impl Foo<u32> for () {}
|
||||
| ^^^^^^^^ the trait `Default` is not implemented for `(dyn ToString + 'static)`
|
||||
LL | assert_eq!(<() as Foo<u32>>::Out::default().to_string(), "false");
|
||||
| ^^^^^^^ function or associated item not found in `(dyn std::string::ToString + 'static)`
|
||||
|
||||
error[E0277]: the trait bound `(dyn ToString + 'static): Default` is not satisfied
|
||||
--> $DIR/issue-43924.rs:11:6
|
||||
|
|
||||
LL | trait Foo<T: Default + ToString> {
|
||||
| --- required by a bound in this
|
||||
LL | type Out: Default + ToString + ?Sized = dyn ToString;
|
||||
| ------- required by this bound in `Foo`
|
||||
...
|
||||
LL | impl Foo<u64> for () {}
|
||||
| ^^^^^^^^ the trait `Default` is not implemented for `(dyn ToString + 'static)`
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
Some errors have detailed explanations: E0277, E0599.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
|
@ -1,10 +1,11 @@
|
||||
error[E0277]: the size for values of type `Self` cannot be known at compilation time
|
||||
--> $DIR/issue-63593.rs:9:5
|
||||
|
|
||||
LL | trait MyTrait {
|
||||
| ------------- required by `MyTrait`
|
||||
LL | type This = Self;
|
||||
| ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| doesn't have a size known at compile-time
|
||||
| required by this bound in `MyTrait::This`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
|
@ -14,7 +14,6 @@ trait MPU {
|
||||
struct S;
|
||||
|
||||
impl MPU for S { }
|
||||
//~^ ERROR the trait bound `T: MyDisplay` is not satisfied
|
||||
|
||||
trait MyWrite {
|
||||
fn my_write(&self, _: &dyn MyDisplay) { }
|
||||
@ -43,6 +42,7 @@ impl ProcessType for Process {
|
||||
// FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<T as MyDisplay>)),
|
||||
// depth=1),Unimplemented)
|
||||
let closure = |config: &mut <S as MPU>::MpuConfig| writer.my_write(&config);
|
||||
//~^ ERROR the trait bound `T: MyDisplay` is not satisfied
|
||||
closure(valref);
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,20 @@
|
||||
error[E0277]: the trait bound `T: MyDisplay` is not satisfied
|
||||
--> $DIR/issue-65774-1.rs:10:21
|
||||
--> $DIR/issue-65774-1.rs:10:5
|
||||
|
|
||||
LL | trait MPU {
|
||||
| --------- required by `MPU`
|
||||
LL | type MpuConfig: MyDisplay = T;
|
||||
| ^^^^^^^^^ the trait `MyDisplay` is not implemented for `T`
|
||||
| ^^^^^^^^^^^^^^^^---------^^^^^
|
||||
| | |
|
||||
| | required by this bound in `MPU::MpuConfig`
|
||||
| the trait `MyDisplay` is not implemented for `T`
|
||||
|
||||
error[E0277]: the trait bound `T: MyDisplay` is not satisfied
|
||||
--> $DIR/issue-65774-1.rs:16:6
|
||||
--> $DIR/issue-65774-1.rs:44:76
|
||||
|
|
||||
LL | trait MPU {
|
||||
| --- required by a bound in this
|
||||
LL | type MpuConfig: MyDisplay = T;
|
||||
| --------- required by this bound in `MPU`
|
||||
...
|
||||
LL | impl MPU for S { }
|
||||
| ^^^ the trait `MyDisplay` is not implemented for `T`
|
||||
LL | let closure = |config: &mut <S as MPU>::MpuConfig| writer.my_write(&config);
|
||||
| ^^^^^^^ the trait `MyDisplay` is not implemented for `T`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `MyDisplay` for `&mut T`
|
||||
= note: required for the cast to the object type `dyn MyDisplay`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -14,7 +14,6 @@ trait MPU {
|
||||
struct S;
|
||||
|
||||
impl MPU for S { }
|
||||
//~^ ERROR the trait bound `T: MyDisplay` is not satisfied
|
||||
|
||||
trait MyWrite {
|
||||
fn my_write(&self, _: &dyn MyDisplay) { }
|
||||
@ -38,6 +37,7 @@ impl ProcessType for Process {
|
||||
// // `Unimplemented` selecting `Binder(<T as MyDisplay>)` during codegen
|
||||
//
|
||||
writer.my_write(valref)
|
||||
//~^ ERROR the trait bound `T: MyDisplay` is not satisfied
|
||||
|
||||
// This one causes the ICE:
|
||||
// FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<T as MyDisplay>)),
|
||||
|
@ -1,21 +1,19 @@
|
||||
error[E0277]: the trait bound `T: MyDisplay` is not satisfied
|
||||
--> $DIR/issue-65774-2.rs:10:21
|
||||
--> $DIR/issue-65774-2.rs:10:5
|
||||
|
|
||||
LL | trait MPU {
|
||||
| --------- required by `MPU`
|
||||
LL | type MpuConfig: MyDisplay = T;
|
||||
| ^^^^^^^^^ the trait `MyDisplay` is not implemented for `T`
|
||||
| ^^^^^^^^^^^^^^^^---------^^^^^
|
||||
| | |
|
||||
| | required by this bound in `MPU::MpuConfig`
|
||||
| the trait `MyDisplay` is not implemented for `T`
|
||||
|
||||
error[E0277]: the trait bound `T: MyDisplay` is not satisfied
|
||||
--> $DIR/issue-65774-2.rs:16:6
|
||||
--> $DIR/issue-65774-2.rs:39:25
|
||||
|
|
||||
LL | trait MPU {
|
||||
| --- required by a bound in this
|
||||
LL | type MpuConfig: MyDisplay = T;
|
||||
| --------- required by this bound in `MPU`
|
||||
...
|
||||
LL | impl MPU for S { }
|
||||
| ^^^ the trait `MyDisplay` is not implemented for `T`
|
||||
LL | writer.my_write(valref)
|
||||
| ^^^^^^ the trait `MyDisplay` is not implemented for `T`
|
||||
|
|
||||
= note: required for the cast to the object type `dyn MyDisplay`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -9,9 +9,10 @@ trait Bar2 {
|
||||
struct Foo;
|
||||
struct Foo2;
|
||||
|
||||
impl Bar for Foo { //~ ERROR type mismatch resolving `<Foo2 as Bar2>::Ok == char`
|
||||
impl Bar for Foo {
|
||||
type Ok = ();
|
||||
type Sibling = Foo2;
|
||||
//~^ ERROR type mismatch resolving `<Foo2 as Bar2>::Ok == char`
|
||||
}
|
||||
impl Bar2 for Foo2 {
|
||||
type Ok = u32;
|
||||
|
@ -1,8 +1,11 @@
|
||||
error[E0271]: type mismatch resolving `<Foo2 as Bar2>::Ok == char`
|
||||
--> $DIR/issue-72806.rs:12:6
|
||||
--> $DIR/issue-72806.rs:14:5
|
||||
|
|
||||
LL | impl Bar for Foo {
|
||||
| ^^^ expected `u32`, found `char`
|
||||
LL | type Sibling: Bar2<Ok=char>;
|
||||
| ------- required by this bound in `Bar::Sibling`
|
||||
...
|
||||
LL | type Sibling = Foo2;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ expected `char`, found `u32`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -5,7 +5,9 @@ trait Foo {
|
||||
}
|
||||
|
||||
impl Foo for () {
|
||||
type Assoc = bool; //~ ERROR the trait bound `bool: Bar` is not satisfied
|
||||
// Doesn't error because we abort compilation after the errors below.
|
||||
// See point-at-type-on-obligation-failure-3.rs
|
||||
type Assoc = bool;
|
||||
}
|
||||
|
||||
trait Baz where Self::Assoc: Bar {
|
||||
|
@ -1,16 +1,5 @@
|
||||
error[E0277]: the trait bound `bool: Bar` is not satisfied
|
||||
--> $DIR/point-at-type-on-obligation-failure-2.rs:8:18
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- required by a bound in this
|
||||
LL | type Assoc: Bar;
|
||||
| --- required by this bound in `Foo`
|
||||
...
|
||||
LL | type Assoc = bool;
|
||||
| ^^^^ the trait `Bar` is not implemented for `bool`
|
||||
|
||||
error[E0277]: the trait bound `bool: Bar` is not satisfied
|
||||
--> $DIR/point-at-type-on-obligation-failure-2.rs:16:18
|
||||
--> $DIR/point-at-type-on-obligation-failure-2.rs:18:18
|
||||
|
|
||||
LL | trait Baz where Self::Assoc: Bar {
|
||||
| --- required by this bound in `Baz`
|
||||
@ -19,7 +8,7 @@ LL | type Assoc = bool;
|
||||
| ^^^^ the trait `Bar` is not implemented for `bool`
|
||||
|
||||
error[E0277]: the trait bound `bool: Bar` is not satisfied
|
||||
--> $DIR/point-at-type-on-obligation-failure-2.rs:24:18
|
||||
--> $DIR/point-at-type-on-obligation-failure-2.rs:26:18
|
||||
|
|
||||
LL | trait Bat where <Self as Bat>::Assoc: Bar {
|
||||
| --- required by this bound in `Bat`
|
||||
@ -27,6 +16,6 @@ LL | trait Bat where <Self as Bat>::Assoc: Bar {
|
||||
LL | type Assoc = bool;
|
||||
| ^^^^ the trait `Bar` is not implemented for `bool`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
@ -0,0 +1,11 @@
|
||||
trait Bar {}
|
||||
|
||||
trait Foo {
|
||||
type Assoc: Bar;
|
||||
}
|
||||
|
||||
impl Foo for () {
|
||||
type Assoc = bool; //~ ERROR the trait bound `bool: Bar` is not satisfied
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,12 @@
|
||||
error[E0277]: the trait bound `bool: Bar` is not satisfied
|
||||
--> $DIR/point-at-type-on-obligation-failure-3.rs:8:5
|
||||
|
|
||||
LL | type Assoc: Bar;
|
||||
| --- required by this bound in `Foo::Assoc`
|
||||
...
|
||||
LL | type Assoc = bool;
|
||||
| ^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `bool`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
@ -10,8 +10,9 @@ struct Foo;
|
||||
struct Foo2;
|
||||
|
||||
impl Bar for Foo {
|
||||
type Ok = (); //~ ERROR type mismatch resolving `<Foo2 as Bar2>::Ok == ()`
|
||||
type Ok = ();
|
||||
type Sibling = Foo2;
|
||||
//~^ ERROR type mismatch resolving `<Foo2 as Bar2>::Ok == ()`
|
||||
}
|
||||
impl Bar2 for Foo2 {
|
||||
type Ok = u32;
|
||||
|
@ -1,8 +1,11 @@
|
||||
error[E0271]: type mismatch resolving `<Foo2 as Bar2>::Ok == ()`
|
||||
--> $DIR/point-at-type-on-obligation-failure.rs:13:15
|
||||
--> $DIR/point-at-type-on-obligation-failure.rs:14:5
|
||||
|
|
||||
LL | type Ok = ();
|
||||
| ^^ expected `u32`, found `()`
|
||||
LL | type Sibling: Bar2<Ok=Self::Ok>;
|
||||
| ----------- required by this bound in `Bar::Sibling`
|
||||
...
|
||||
LL | type Sibling = Foo2;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `u32`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -15,19 +15,6 @@ impl Foo for str { }
|
||||
// Implicit `T: Sized` bound.
|
||||
impl<T> Foo for Option<T> { }
|
||||
|
||||
impl Bar for () {
|
||||
type Item = i32;
|
||||
}
|
||||
|
||||
impl<T> Bar for Option<T> {
|
||||
type Item = Option<T>;
|
||||
}
|
||||
|
||||
impl Bar for f32 {
|
||||
type Item = f32;
|
||||
//~^ ERROR the trait bound `f32: Foo` is not satisfied
|
||||
}
|
||||
|
||||
trait Baz<U: ?Sized> where U: Foo { }
|
||||
|
||||
impl Baz<i32> for i32 { }
|
||||
|
@ -10,18 +10,7 @@ LL | impl Foo for str { }
|
||||
= help: the trait `Sized` is not implemented for `str`
|
||||
|
||||
error[E0277]: the trait bound `f32: Foo` is not satisfied
|
||||
--> $DIR/impl_wf.rs:27:17
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- required by a bound in this
|
||||
LL | type Item: Foo;
|
||||
| --- required by this bound in `Bar`
|
||||
...
|
||||
LL | type Item = f32;
|
||||
| ^^^ the trait `Foo` is not implemented for `f32`
|
||||
|
||||
error[E0277]: the trait bound `f32: Foo` is not satisfied
|
||||
--> $DIR/impl_wf.rs:35:6
|
||||
--> $DIR/impl_wf.rs:22:6
|
||||
|
|
||||
LL | trait Baz<U: ?Sized> where U: Foo { }
|
||||
| --- required by this bound in `Baz`
|
||||
@ -29,6 +18,6 @@ LL | trait Baz<U: ?Sized> where U: Foo { }
|
||||
LL | impl Baz<f32> for f32 { }
|
||||
| ^^^^^^^^ the trait `Foo` is not implemented for `f32`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
33
src/test/ui/chalkify/impl_wf_2.rs
Normal file
33
src/test/ui/chalkify/impl_wf_2.rs
Normal file
@ -0,0 +1,33 @@
|
||||
// Split out of impl_wf.rs to work around rust aborting compilation early
|
||||
|
||||
// compile-flags: -Z chalk
|
||||
|
||||
trait Foo: Sized { }
|
||||
|
||||
trait Bar {
|
||||
type Item: Foo;
|
||||
}
|
||||
|
||||
impl Foo for i32 { }
|
||||
|
||||
// Implicit `T: Sized` bound.
|
||||
impl<T> Foo for Option<T> { }
|
||||
|
||||
impl Bar for () {
|
||||
type Item = i32;
|
||||
}
|
||||
|
||||
impl<T> Bar for Option<T> {
|
||||
type Item = Option<T>;
|
||||
}
|
||||
|
||||
impl Bar for f32 {
|
||||
type Item = f32;
|
||||
//~^ ERROR the trait bound `f32: Foo` is not satisfied
|
||||
}
|
||||
|
||||
trait Baz<U: ?Sized> where U: Foo { }
|
||||
|
||||
impl Baz<i32> for i32 { }
|
||||
|
||||
fn main() {}
|
12
src/test/ui/chalkify/impl_wf_2.stderr
Normal file
12
src/test/ui/chalkify/impl_wf_2.stderr
Normal file
@ -0,0 +1,12 @@
|
||||
error[E0277]: the trait bound `f32: Foo` is not satisfied
|
||||
--> $DIR/impl_wf_2.rs:25:5
|
||||
|
|
||||
LL | type Item: Foo;
|
||||
| --- required by this bound in `Bar::Item`
|
||||
...
|
||||
LL | type Item = f32;
|
||||
| ^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `f32`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
@ -14,6 +14,7 @@ impl Tr1 for S1 { type As1 = S2; }
|
||||
trait _Tr3 {
|
||||
type A: Iterator<Item: Copy>;
|
||||
//~^ ERROR associated type bounds are unstable
|
||||
//~| ERROR the trait bound `<<Self as _Tr3>::A as std::iter::Iterator>::Item: std::marker::Copy` is not satisfied
|
||||
|
||||
type B: Iterator<Item: 'static>;
|
||||
//~^ ERROR associated type bounds are unstable
|
||||
|
@ -8,7 +8,7 @@ LL | type A: Iterator<Item: Copy>;
|
||||
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: associated type bounds are unstable
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:18:22
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:19:22
|
||||
|
|
||||
LL | type B: Iterator<Item: 'static>;
|
||||
| ^^^^^^^^^^^^^
|
||||
@ -17,7 +17,7 @@ LL | type B: Iterator<Item: 'static>;
|
||||
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: associated type bounds are unstable
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:22:20
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:23:20
|
||||
|
|
||||
LL | struct _St1<T: Tr1<As1: Tr2>> {
|
||||
| ^^^^^^^^
|
||||
@ -26,7 +26,7 @@ LL | struct _St1<T: Tr1<As1: Tr2>> {
|
||||
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: associated type bounds are unstable
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:29:18
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:30:18
|
||||
|
|
||||
LL | enum _En1<T: Tr1<As1: Tr2>> {
|
||||
| ^^^^^^^^
|
||||
@ -35,7 +35,7 @@ LL | enum _En1<T: Tr1<As1: Tr2>> {
|
||||
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: associated type bounds are unstable
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:36:19
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:37:19
|
||||
|
|
||||
LL | union _Un1<T: Tr1<As1: Tr2>> {
|
||||
| ^^^^^^^^
|
||||
@ -44,7 +44,7 @@ LL | union _Un1<T: Tr1<As1: Tr2>> {
|
||||
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: associated type bounds are unstable
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:43:37
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:44:37
|
||||
|
|
||||
LL | type _TaWhere1<T> where T: Iterator<Item: Copy> = T;
|
||||
| ^^^^^^^^^^
|
||||
@ -53,7 +53,7 @@ LL | type _TaWhere1<T> where T: Iterator<Item: Copy> = T;
|
||||
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: associated type bounds are unstable
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:46:22
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:47:22
|
||||
|
|
||||
LL | fn _apit(_: impl Tr1<As1: Copy>) {}
|
||||
| ^^^^^^^^^
|
||||
@ -62,7 +62,7 @@ LL | fn _apit(_: impl Tr1<As1: Copy>) {}
|
||||
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: associated type bounds are unstable
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:48:26
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:49:26
|
||||
|
|
||||
LL | fn _apit_dyn(_: &dyn Tr1<As1: Copy>) {}
|
||||
| ^^^^^^^^^
|
||||
@ -71,7 +71,7 @@ LL | fn _apit_dyn(_: &dyn Tr1<As1: Copy>) {}
|
||||
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: associated type bounds are unstable
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:51:24
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:52:24
|
||||
|
|
||||
LL | fn _rpit() -> impl Tr1<As1: Copy> { S1 }
|
||||
| ^^^^^^^^^
|
||||
@ -80,7 +80,7 @@ LL | fn _rpit() -> impl Tr1<As1: Copy> { S1 }
|
||||
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: associated type bounds are unstable
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:54:31
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:55:31
|
||||
|
|
||||
LL | fn _rpit_dyn() -> Box<dyn Tr1<As1: Copy>> { Box::new(S1) }
|
||||
| ^^^^^^^^^
|
||||
@ -89,7 +89,7 @@ LL | fn _rpit_dyn() -> Box<dyn Tr1<As1: Copy>> { Box::new(S1) }
|
||||
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: associated type bounds are unstable
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:57:23
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:58:23
|
||||
|
|
||||
LL | const _cdef: impl Tr1<As1: Copy> = S1;
|
||||
| ^^^^^^^^^
|
||||
@ -98,7 +98,7 @@ LL | const _cdef: impl Tr1<As1: Copy> = S1;
|
||||
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: associated type bounds are unstable
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:63:24
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:64:24
|
||||
|
|
||||
LL | static _sdef: impl Tr1<As1: Copy> = S1;
|
||||
| ^^^^^^^^^
|
||||
@ -107,7 +107,7 @@ LL | static _sdef: impl Tr1<As1: Copy> = S1;
|
||||
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: associated type bounds are unstable
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:70:21
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:71:21
|
||||
|
|
||||
LL | let _: impl Tr1<As1: Copy> = S1;
|
||||
| ^^^^^^^^^
|
||||
@ -116,7 +116,7 @@ LL | let _: impl Tr1<As1: Copy> = S1;
|
||||
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
|
||||
|
||||
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:57:14
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:58:14
|
||||
|
|
||||
LL | const _cdef: impl Tr1<As1: Copy> = S1;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
@ -124,7 +124,7 @@ LL | const _cdef: impl Tr1<As1: Copy> = S1;
|
||||
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
|
||||
|
||||
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:63:15
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:64:15
|
||||
|
|
||||
LL | static _sdef: impl Tr1<As1: Copy> = S1;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
@ -132,14 +132,30 @@ LL | static _sdef: impl Tr1<As1: Copy> = S1;
|
||||
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
|
||||
|
||||
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:70:12
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:71:12
|
||||
|
|
||||
LL | let _: impl Tr1<As1: Copy> = S1;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to 16 previous errors
|
||||
error[E0277]: the trait bound `<<Self as _Tr3>::A as std::iter::Iterator>::Item: std::marker::Copy` is not satisfied
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:15:28
|
||||
|
|
||||
LL | type A: Iterator<Item: Copy>;
|
||||
| ^^^^ the trait `std::marker::Copy` is not implemented for `<<Self as _Tr3>::A as std::iter::Iterator>::Item`
|
||||
|
|
||||
::: $SRC_DIR/libcore/marker.rs:LL:COL
|
||||
|
|
||||
LL | pub trait Copy: Clone {
|
||||
| --------------------- required by this bound in `std::marker::Copy`
|
||||
|
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | trait _Tr3 where <<Self as _Tr3>::A as std::iter::Iterator>::Item: std::marker::Copy {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Some errors have detailed explanations: E0562, E0658.
|
||||
For more information about an error, try `rustc --explain E0562`.
|
||||
error: aborting due to 17 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0562, E0658.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
|
@ -16,6 +16,11 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t
|
||||
|
|
||||
LL | Pin::new(&mut gen).resume(());
|
||||
| ^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
::: $SRC_DIR/libcore/ops/generator.rs:LL:COL
|
||||
|
|
||||
LL | pub enum GeneratorState<Y, R> {
|
||||
| - required by this bound in `std::ops::GeneratorState`
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `str`
|
||||
|
||||
|
@ -11,7 +11,7 @@ error[E0277]: the trait bound `T: Copy` is not satisfied
|
||||
--> $DIR/issue-68641-check-gat-bounds.rs:15:5
|
||||
|
|
||||
LL | type Item<'a>: Copy;
|
||||
| -------------------- required by `UnsafeCopy::Item`
|
||||
| ---- required by this bound in `UnsafeCopy::Item`
|
||||
...
|
||||
LL | type Item<'a> = T;
|
||||
| ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T`
|
||||
|
@ -11,7 +11,7 @@ error[E0277]: expected a `Fn<()>` closure, found `T`
|
||||
--> $DIR/issue-68642-broken-llvm-ir.rs:15:5
|
||||
|
|
||||
LL | type F<'a>: Fn() -> u32;
|
||||
| ------------------------ required by `Fun::F`
|
||||
| ----------- required by this bound in `Fun::F`
|
||||
...
|
||||
LL | type F<'a> = Self;
|
||||
| ^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `T`
|
||||
|
@ -11,7 +11,7 @@ error[E0277]: expected a `Fn<()>` closure, found `T`
|
||||
--> $DIR/issue-68643-broken-mir.rs:15:5
|
||||
|
|
||||
LL | type F<'a>: Fn() -> u32;
|
||||
| ------------------------ required by `Fun::F`
|
||||
| ----------- required by this bound in `Fun::F`
|
||||
...
|
||||
LL | type F<'a> = Self;
|
||||
| ^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `T`
|
||||
|
@ -11,7 +11,7 @@ error[E0277]: expected a `Fn<()>` closure, found `T`
|
||||
--> $DIR/issue-68644-codegen-selection.rs:15:5
|
||||
|
|
||||
LL | type F<'a>: Fn() -> u32;
|
||||
| ------------------------ required by `Fun::F`
|
||||
| ----------- required by this bound in `Fun::F`
|
||||
...
|
||||
LL | type F<'a> = Self;
|
||||
| ^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `T`
|
||||
|
@ -11,7 +11,7 @@ error[E0277]: expected a `Fn<()>` closure, found `T`
|
||||
--> $DIR/issue-68645-codegen-fulfillment.rs:15:5
|
||||
|
|
||||
LL | type F<'a>: Fn() -> u32;
|
||||
| ------------------------ required by `Fun::F`
|
||||
| ----------- required by this bound in `Fun::F`
|
||||
...
|
||||
LL | type F<'a> = Self;
|
||||
| ^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `T`
|
||||
|
@ -11,7 +11,7 @@ error[E0271]: type mismatch resolving `<T as Deref>::Target == T`
|
||||
--> $DIR/issue-68656-unsized-values.rs:16:5
|
||||
|
|
||||
LL | type Item<'a>: std::ops::Deref<Target = T>;
|
||||
| ------------------------------------------- required by `UnsafeCopy::Item`
|
||||
| ---------- required by this bound in `UnsafeCopy::Item`
|
||||
...
|
||||
LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<T> for T {
|
||||
| - this type parameter
|
||||
|
@ -7,7 +7,7 @@ trait ATy {
|
||||
|
||||
impl<'b> ATy for &'b () {
|
||||
type Item<'a> = &'b ();
|
||||
//~^ ERROR does not fulfill the required lifetime
|
||||
//~^ ERROR lifetime bound not satisfied
|
||||
}
|
||||
|
||||
trait StaticTy {
|
||||
@ -16,7 +16,7 @@ trait StaticTy {
|
||||
|
||||
impl StaticTy for () {
|
||||
type Item<'a> = &'a ();
|
||||
//~^ ERROR does not fulfill the required lifetime
|
||||
//~^ ERROR lifetime bound not satisfied
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,23 +1,33 @@
|
||||
error[E0477]: the type `&'b ()` does not fulfill the required lifetime
|
||||
error[E0478]: lifetime bound not satisfied
|
||||
--> $DIR/unsatisfied-outlives-bound.rs:9:5
|
||||
|
|
||||
LL | type Item<'a> = &'b ();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: type must outlive the lifetime `'a` as defined on the associated item at 9:15
|
||||
note: lifetime parameter instantiated with the lifetime `'b` as defined on the impl at 8:6
|
||||
--> $DIR/unsatisfied-outlives-bound.rs:8:6
|
||||
|
|
||||
LL | impl<'b> ATy for &'b () {
|
||||
| ^^
|
||||
note: but lifetime parameter must outlive the lifetime `'a` as defined on the associated item at 9:15
|
||||
--> $DIR/unsatisfied-outlives-bound.rs:9:15
|
||||
|
|
||||
LL | type Item<'a> = &'b ();
|
||||
| ^^
|
||||
|
||||
error[E0477]: the type `&'a ()` does not fulfill the required lifetime
|
||||
error[E0478]: lifetime bound not satisfied
|
||||
--> $DIR/unsatisfied-outlives-bound.rs:18:5
|
||||
|
|
||||
LL | type Item<'a> = &'a ();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: type must satisfy the static lifetime
|
||||
note: lifetime parameter instantiated with the lifetime `'a` as defined on the associated item at 18:15
|
||||
--> $DIR/unsatisfied-outlives-bound.rs:18:15
|
||||
|
|
||||
LL | type Item<'a> = &'a ();
|
||||
| ^^
|
||||
= note: but lifetime parameter must outlive the static lifetime
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0477`.
|
||||
For more information about this error, try `rustc --explain E0478`.
|
||||
|
@ -7,13 +7,13 @@ LL | #![feature(impl_trait_in_bindings)]
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
|
||||
|
||||
error[E0282]: type annotations needed for `impl Future`
|
||||
--> $DIR/cannot-infer-async-enabled-impl-trait-bindings.rs:13:9
|
||||
error[E0282]: type annotations needed for `impl std::future::Future`
|
||||
--> $DIR/cannot-infer-async-enabled-impl-trait-bindings.rs:13:20
|
||||
|
|
||||
LL | let fut = async {
|
||||
| --- consider giving `fut` the explicit type `impl Future`, with the type parameters specified
|
||||
LL | make_unit()?;
|
||||
| ^^^^^^^^^^^^ cannot infer type
|
||||
| ^ cannot infer type
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/cannot-infer-async.rs:11:9
|
||||
--> $DIR/cannot-infer-async.rs:11:20
|
||||
|
|
||||
LL | let fut = async {
|
||||
| --- consider giving `fut` a type
|
||||
LL | make_unit()?;
|
||||
| ^^^^^^^^^^^^ cannot infer type
|
||||
| ^ cannot infer type
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0282]: type annotations needed for the closure `fn((), ()) -> std::result::Result<(), _>`
|
||||
--> $DIR/cannot-infer-closure.rs:3:9
|
||||
--> $DIR/cannot-infer-closure.rs:3:15
|
||||
|
|
||||
LL | Err(a)?;
|
||||
| ^^^^^^^ cannot infer type
|
||||
| ^ cannot infer type
|
||||
|
|
||||
help: give this closure an explicit return type without `_` placeholders
|
||||
|
|
||||
|
@ -4,8 +4,9 @@ error[E0277]: the size for values of type `dyn Iterator<Item = &'a mut u8>` cann
|
||||
LL | for item in *things { *item = 0 }
|
||||
| ^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `dyn Iterator<Item = &'a mut u8>`
|
||||
= note: required by `into_iter`
|
||||
= help: the trait `std::marker::Sized` is not implemented for `dyn std::iter::Iterator<Item = &'a mut u8>`
|
||||
= note: required because of the requirements on the impl of `std::iter::IntoIterator` for `dyn std::iter::Iterator<Item = &'a mut u8>`
|
||||
= note: required by `std::iter::IntoIterator::into_iter`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -28,9 +28,6 @@ impl<'a> Publisher<'a> for MyStruct<'a> {
|
||||
fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
|
||||
// Not obvious, but there is an implicit lifetime here -------^
|
||||
//~^^ ERROR cannot infer
|
||||
//~| ERROR cannot infer
|
||||
//~| ERROR mismatched types
|
||||
//~| ERROR mismatched types
|
||||
//
|
||||
// The fact that `Publisher` is using an implicit lifetime is
|
||||
// what was causing the debruijn accounting to be off, so
|
||||
|
@ -1,53 +1,3 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-20831-debruijn.rs:28:5
|
||||
|
|
||||
LL | / fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
|
||||
LL | | // Not obvious, but there is an implicit lifetime here -------^
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | self.sub = t;
|
||||
LL | | }
|
||||
| |_____^ lifetime mismatch
|
||||
|
|
||||
= note: expected type `'a`
|
||||
found type `'_`
|
||||
note: the anonymous lifetime #2 defined on the method body at 28:5...
|
||||
--> $DIR/issue-20831-debruijn.rs:28:5
|
||||
|
|
||||
LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...does not necessarily outlive the lifetime `'a` as defined on the impl at 26:6
|
||||
--> $DIR/issue-20831-debruijn.rs:26:6
|
||||
|
|
||||
LL | impl<'a> Publisher<'a> for MyStruct<'a> {
|
||||
| ^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-20831-debruijn.rs:28:5
|
||||
|
|
||||
LL | / fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
|
||||
LL | | // Not obvious, but there is an implicit lifetime here -------^
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | self.sub = t;
|
||||
LL | | }
|
||||
| |_____^ lifetime mismatch
|
||||
|
|
||||
= note: expected type `'a`
|
||||
found type `'_`
|
||||
note: the lifetime `'a` as defined on the impl at 26:6...
|
||||
--> $DIR/issue-20831-debruijn.rs:26:6
|
||||
|
|
||||
LL | impl<'a> Publisher<'a> for MyStruct<'a> {
|
||||
| ^^
|
||||
note: ...does not necessarily outlive the anonymous lifetime #2 defined on the method body at 28:5
|
||||
--> $DIR/issue-20831-debruijn.rs:28:5
|
||||
|
|
||||
LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
|
||||
--> $DIR/issue-20831-debruijn.rs:28:33
|
||||
|
|
||||
@ -57,8 +7,14 @@ LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher
|
||||
note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the method body at 28:5...
|
||||
--> $DIR/issue-20831-debruijn.rs:28:5
|
||||
|
|
||||
LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | / fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
|
||||
LL | | // Not obvious, but there is an implicit lifetime here -------^
|
||||
LL | |
|
||||
LL | | //
|
||||
... |
|
||||
LL | | self.sub = t;
|
||||
LL | | }
|
||||
| |_____^
|
||||
note: ...but the lifetime must also be valid for the lifetime `'a` as defined on the impl at 26:6...
|
||||
--> $DIR/issue-20831-debruijn.rs:26:6
|
||||
|
|
||||
@ -72,31 +28,6 @@ LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher
|
||||
= note: expected `Publisher<'_>`
|
||||
found `Publisher<'_>`
|
||||
|
||||
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
|
||||
--> $DIR/issue-20831-debruijn.rs:28:33
|
||||
|
|
||||
LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the method body at 28:5...
|
||||
--> $DIR/issue-20831-debruijn.rs:28:5
|
||||
|
|
||||
LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...but the lifetime must also be valid for the lifetime `'a` as defined on the impl at 26:6...
|
||||
--> $DIR/issue-20831-debruijn.rs:26:6
|
||||
|
|
||||
LL | impl<'a> Publisher<'a> for MyStruct<'a> {
|
||||
| ^^
|
||||
note: ...so that the types are compatible
|
||||
--> $DIR/issue-20831-debruijn.rs:28:33
|
||||
|
|
||||
LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: expected `Publisher<'_>`
|
||||
found `Publisher<'_>`
|
||||
error: aborting due to previous error
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0308, E0495.
|
||||
For more information about an error, try `rustc --explain E0308`.
|
||||
For more information about this error, try `rustc --explain E0495`.
|
||||
|
@ -5,7 +5,6 @@ trait Foo {
|
||||
struct FooStruct;
|
||||
|
||||
impl Foo for FooStruct {
|
||||
//~^ ERROR overflow evaluating the requirement `<FooStruct as Foo>::A == _`
|
||||
type A = <FooStruct as Foo>::A;
|
||||
//~^ ERROR overflow evaluating the requirement `<FooStruct as Foo>::A == _`
|
||||
}
|
||||
|
@ -1,15 +1,9 @@
|
||||
error[E0275]: overflow evaluating the requirement `<FooStruct as Foo>::A == _`
|
||||
--> $DIR/issue-21946.rs:7:6
|
||||
|
|
||||
LL | impl Foo for FooStruct {
|
||||
| ^^^
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `<FooStruct as Foo>::A == _`
|
||||
--> $DIR/issue-21946.rs:9:5
|
||||
error[E0275]: overflow evaluating the requirement `<FooStruct as Foo>::A`
|
||||
--> $DIR/issue-21946.rs:8:5
|
||||
|
|
||||
LL | type A = <FooStruct as Foo>::A;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0275`.
|
||||
|
@ -5,7 +5,6 @@ trait Next {
|
||||
struct GetNext<T: Next> { t: T }
|
||||
|
||||
impl<T: Next> Next for GetNext<T> {
|
||||
//~^ ERROR overflow evaluating the requirement
|
||||
type Next = <GetNext<T> as Next>::Next;
|
||||
//~^ ERROR overflow evaluating the requirement
|
||||
}
|
||||
|
@ -1,15 +1,9 @@
|
||||
error[E0275]: overflow evaluating the requirement `<GetNext<T> as Next>::Next == _`
|
||||
--> $DIR/issue-23122-1.rs:7:15
|
||||
|
|
||||
LL | impl<T: Next> Next for GetNext<T> {
|
||||
| ^^^^
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `<GetNext<T> as Next>::Next == _`
|
||||
--> $DIR/issue-23122-1.rs:9:5
|
||||
error[E0275]: overflow evaluating the requirement `<GetNext<T> as Next>::Next`
|
||||
--> $DIR/issue-23122-1.rs:8:5
|
||||
|
|
||||
LL | type Next = <GetNext<T> as Next>::Next;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0275`.
|
||||
|
@ -5,7 +5,6 @@ trait Next {
|
||||
struct GetNext<T: Next> { t: T }
|
||||
|
||||
impl<T: Next> Next for GetNext<T> {
|
||||
//~^ ERROR overflow evaluating the requirement
|
||||
type Next = <GetNext<T::Next> as Next>::Next;
|
||||
//~^ ERROR overflow evaluating the requirement
|
||||
}
|
||||
|
@ -1,14 +1,5 @@
|
||||
error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized`
|
||||
--> $DIR/issue-23122-2.rs:7:15
|
||||
|
|
||||
LL | impl<T: Next> Next for GetNext<T> {
|
||||
| ^^^^
|
||||
|
|
||||
= help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_23122_2`)
|
||||
= note: required because of the requirements on the impl of `Next` for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>`
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized`
|
||||
--> $DIR/issue-23122-2.rs:9:5
|
||||
error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: std::marker::Sized`
|
||||
--> $DIR/issue-23122-2.rs:8:5
|
||||
|
|
||||
LL | type Next = <GetNext<T::Next> as Next>::Next;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -16,6 +7,6 @@ LL | type Next = <GetNext<T::Next> as Next>::Next;
|
||||
= help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_23122_2`)
|
||||
= note: required because of the requirements on the impl of `Next` for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0275`.
|
||||
|
@ -12,6 +12,6 @@ trait Trait: Sized {
|
||||
}
|
||||
|
||||
fn test<T: Trait<B=i32>>(b: i32) -> T where T::A: MultiDispatch<i32> { T::new(b) }
|
||||
//~^ ERROR type mismatch resolving
|
||||
//~^ ERROR mismatched types
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,15 +1,10 @@
|
||||
error[E0271]: type mismatch resolving `<<T as Trait>::A as MultiDispatch<i32>>::O == T`
|
||||
--> $DIR/issue-24204.rs:14:12
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-24204.rs:14:72
|
||||
|
|
||||
LL | trait Trait: Sized {
|
||||
| ----- required by a bound in this
|
||||
LL | type A: MultiDispatch<Self::B, O = Self>;
|
||||
| -------- required by this bound in `Trait`
|
||||
...
|
||||
LL | fn test<T: Trait<B=i32>>(b: i32) -> T where T::A: MultiDispatch<i32> { T::new(b) }
|
||||
| - ^^^^^^^^^^^^ expected type parameter `T`, found associated type
|
||||
| |
|
||||
| this type parameter
|
||||
| - - ^^^^^^^^^ expected type parameter `T`, found associated type
|
||||
| | |
|
||||
| this type parameter expected `T` because of return type
|
||||
|
|
||||
= note: expected type parameter `T`
|
||||
found associated type `<<T as Trait>::A as MultiDispatch<i32>>::O`
|
||||
@ -17,4 +12,4 @@ LL | fn test<T: Trait<B=i32>>(b: i32) -> T where T::A: MultiDispatch<i32> { T::n
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0271`.
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
|
@ -13,8 +13,9 @@ error[E0277]: `bool` is not an iterator
|
||||
LL | for _ in false {}
|
||||
| ^^^^^ `bool` is not an iterator
|
||||
|
|
||||
= help: the trait `Iterator` is not implemented for `bool`
|
||||
= note: required by `into_iter`
|
||||
= help: the trait `std::iter::Iterator` is not implemented for `bool`
|
||||
= note: required because of the requirements on the impl of `std::iter::IntoIterator` for `bool`
|
||||
= note: required by `std::iter::IntoIterator::into_iter`
|
||||
|
||||
error[E0277]: `()` is not an iterator
|
||||
--> $DIR/issue-28098.rs:9:28
|
||||
|
@ -15,7 +15,9 @@ LL | for _ in HashMap::new().iter().cloned() {}
|
||||
|
|
||||
= note: expected tuple `(&_, &_)`
|
||||
found reference `&_`
|
||||
= note: required because of the requirements on the impl of `Iterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
|
||||
= note: required because of the requirements on the impl of `std::iter::Iterator` for `std::iter::Cloned<std::collections::hash_map::Iter<'_, _, _>>`
|
||||
= note: required because of the requirements on the impl of `std::iter::IntoIterator` for `std::iter::Cloned<std::collections::hash_map::Iter<'_, _, _>>`
|
||||
= note: required by `std::iter::IntoIterator::into_iter`
|
||||
|
||||
error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as Iterator>::Item == &_`
|
||||
--> $DIR/issue-33941.rs:4:14
|
||||
|
@ -11,7 +11,7 @@ error[E0277]: the trait bound `(): Valid` is not satisfied
|
||||
--> $DIR/issue-38091.rs:9:5
|
||||
|
|
||||
LL | type Ty: Valid;
|
||||
| --------------- required by `Iterate::Ty`
|
||||
| ----- required by this bound in `Iterate::Ty`
|
||||
...
|
||||
LL | default type Ty = ();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ the trait `Valid` is not implemented for `()`
|
||||
|
@ -1,8 +1,11 @@
|
||||
error[E0277]: the trait bound `T: Copy` is not satisfied
|
||||
--> $DIR/issue-43784-associated-type.rs:14:18
|
||||
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
|
||||
--> $DIR/issue-43784-associated-type.rs:14:5
|
||||
|
|
||||
LL | type Assoc: Partial<Self>;
|
||||
| ------------- required by this bound in `Complete::Assoc`
|
||||
...
|
||||
LL | type Assoc = T;
|
||||
| ^ the trait `Copy` is not implemented for `T`
|
||||
| ^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
|
||||
|
|
||||
help: consider restricting type parameter `T`
|
||||
|
|
||||
|
@ -1,6 +1,9 @@
|
||||
error[E0277]: the trait bound `T: Copy` is not satisfied
|
||||
--> $DIR/issue-43784-supertrait.rs:8:9
|
||||
|
|
||||
LL | pub trait Complete: Partial {
|
||||
| ------- required by this bound in `Complete`
|
||||
...
|
||||
LL | impl<T> Complete for T {}
|
||||
| ^^^^^^^^ the trait `Copy` is not implemented for `T`
|
||||
|
|
||||
|
@ -1,13 +1,11 @@
|
||||
error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
|
||||
--> $DIR/issue-65673.rs:9:16
|
||||
--> $DIR/issue-65673.rs:9:5
|
||||
|
|
||||
LL | trait WithType {
|
||||
| -------- required by a bound in this
|
||||
LL | type Ctx;
|
||||
| --------- required by this bound in `WithType`
|
||||
| --------- required by this bound in `WithType::Ctx`
|
||||
...
|
||||
LL | type Ctx = dyn Alias<T>;
|
||||
| ^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `(dyn Trait + 'static)`
|
||||
|
||||
|
@ -2,7 +2,7 @@ error[E0277]: `!` is not an iterator
|
||||
--> $DIR/issue-51506.rs:13:5
|
||||
|
|
||||
LL | type Out: Iterator<Item = u32>;
|
||||
| ------------------------------- required by `Trait::Out`
|
||||
| -------------------- required by this bound in `Trait::Out`
|
||||
...
|
||||
LL | default type Out = !;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ `!` is not an iterator
|
||||
|
@ -32,5 +32,4 @@ fn main() {
|
||||
let _x = <fn(&())>::make_f();
|
||||
//~^ higher-ranked subtype error
|
||||
//~| higher-ranked subtype error
|
||||
//~| higher-ranked subtype error
|
||||
}
|
||||
|
@ -10,11 +10,5 @@ error: higher-ranked subtype error
|
||||
LL | let _x = <fn(&())>::make_f();
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: higher-ranked subtype error
|
||||
--> $DIR/impl-fn-ignore-binder-via-bottom.rs:32:14
|
||||
|
|
||||
LL | let _x = <fn(&())>::make_f();
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -29,7 +29,11 @@ mod m {
|
||||
//~| WARN this was previously accepted
|
||||
type Alias1: PrivTr;
|
||||
type Alias2: PubTrAux1<Priv> = u8;
|
||||
//~^ WARN private type `m::Priv` in public interface
|
||||
//~| WARN this was previously accepted
|
||||
type Alias3: PubTrAux2<A = Priv> = u8;
|
||||
//~^ WARN private type `m::Priv` in public interface
|
||||
//~| WARN this was previously accepted
|
||||
|
||||
type Alias4 = Priv;
|
||||
//~^ ERROR private type `Priv` in public interface
|
||||
|
@ -10,14 +10,8 @@ LL | type A = Priv;
|
||||
warning: private trait `PrivTr` in public interface (error E0445)
|
||||
--> $DIR/private-in-public-assoc-ty.rs:23:5
|
||||
|
|
||||
LL | / pub trait PubTr {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | fn infer_exist() -> Self::Exist;
|
||||
LL | | }
|
||||
| |_____^
|
||||
LL | type Alias1: PrivTr;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(private_in_public)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
@ -26,14 +20,8 @@ LL | | }
|
||||
warning: private type `Priv` in public interface (error E0446)
|
||||
--> $DIR/private-in-public-assoc-ty.rs:23:5
|
||||
|
|
||||
LL | / pub trait PubTr {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | fn infer_exist() -> Self::Exist;
|
||||
LL | | }
|
||||
| |_____^
|
||||
LL | type Alias2: PubTrAux1<Priv> = u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
|
||||
@ -41,14 +29,8 @@ LL | | }
|
||||
warning: private type `Priv` in public interface (error E0446)
|
||||
--> $DIR/private-in-public-assoc-ty.rs:23:5
|
||||
|
|
||||
LL | / pub trait PubTr {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | fn infer_exist() -> Self::Exist;
|
||||
LL | | }
|
||||
| |_____^
|
||||
LL | type Alias3: PubTrAux2<A = Priv> = u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
|
||||
|
@ -55,9 +55,9 @@ mod traits {
|
||||
pub trait Tr2<T: PrivTr> {} //~ ERROR private trait `traits::PrivTr` in public interface
|
||||
//~^ WARNING hard error
|
||||
pub trait Tr3 {
|
||||
type Alias: PrivTr;
|
||||
//~^ ERROR private trait `traits::PrivTr` in public interface
|
||||
//~| WARNING hard error
|
||||
type Alias: PrivTr;
|
||||
fn f<T: PrivTr>(arg: T) {} //~ ERROR private trait `traits::PrivTr` in public interface
|
||||
//~^ WARNING hard error
|
||||
}
|
||||
|
@ -130,16 +130,10 @@ LL | pub trait Tr2<T: PrivTr> {}
|
||||
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
|
||||
|
||||
error: private trait `traits::PrivTr` in public interface (error E0445)
|
||||
--> $DIR/private-in-public-warn.rs:57:5
|
||||
--> $DIR/private-in-public-warn.rs:58:9
|
||||
|
|
||||
LL | / pub trait Tr3 {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | type Alias: PrivTr;
|
||||
LL | | fn f<T: PrivTr>(arg: T) {}
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_____^
|
||||
LL | type Alias: PrivTr;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
|
||||
|
@ -1,5 +1,5 @@
|
||||
// aux-crate:priv:priv_dep=priv_dep.rs
|
||||
// aux-build:pub_dep.rs
|
||||
// aux-crate:priv:priv_dep=priv_dep.rs
|
||||
// aux-build:pub_dep.rs
|
||||
#![deny(exported_private_dependencies)]
|
||||
|
||||
// This crate is a private dependency
|
||||
@ -7,20 +7,20 @@ extern crate priv_dep;
|
||||
// This crate is a public dependency
|
||||
extern crate pub_dep;
|
||||
|
||||
use priv_dep::{OtherType, OtherTrait};
|
||||
use priv_dep::{OtherTrait, OtherType};
|
||||
use pub_dep::PubType;
|
||||
|
||||
// Type from private dependency used in private
|
||||
// type - this is fine
|
||||
struct PrivateType {
|
||||
field: OtherType
|
||||
field: OtherType,
|
||||
}
|
||||
|
||||
pub struct PublicType {
|
||||
pub field: OtherType,
|
||||
//~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface
|
||||
priv_field: OtherType, // Private field - this is fine
|
||||
pub other_field: PubType // Type from public dependency - this is fine
|
||||
priv_field: OtherType, // Private field - this is fine
|
||||
pub other_field: PubType, // Type from public dependency - this is fine
|
||||
}
|
||||
|
||||
impl PublicType {
|
||||
@ -32,14 +32,13 @@ impl PublicType {
|
||||
|
||||
pub trait MyPubTrait {
|
||||
type Foo: OtherTrait;
|
||||
//~^ ERROR trait `priv_dep::OtherTrait` from private dependency 'priv_dep' in public interface
|
||||
}
|
||||
//~^^^ ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface
|
||||
|
||||
pub struct AllowedPrivType {
|
||||
#[allow(exported_private_dependencies)]
|
||||
pub allowed: OtherType
|
||||
pub allowed: OtherType,
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn main() {}
|
||||
|
@ -19,10 +19,8 @@ LL | pub fn pub_fn(param: OtherType) {}
|
||||
error: trait `OtherTrait` from private dependency 'priv_dep' in public interface
|
||||
--> $DIR/pub-priv1.rs:33:1
|
||||
|
|
||||
LL | / pub trait MyPubTrait {
|
||||
LL | | type Foo: OtherTrait;
|
||||
LL | | }
|
||||
| |_^
|
||||
LL | type Foo: OtherTrait;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
error[E0284]: type annotations needed
|
||||
error[E0283]: type annotations needed
|
||||
--> $DIR/question-mark-type-infer.rs:12:21
|
||||
|
|
||||
LL | l.iter().map(f).collect()?
|
||||
@ -12,4 +12,4 @@ LL | l.iter().map(f).collect::<B>()?
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0284`.
|
||||
For more information about this error, try `rustc --explain E0283`.
|
||||
|
@ -17,7 +17,7 @@ error[E0277]: the size for values of type `[{integer}]` cannot be known at compi
|
||||
|
|
||||
LL | let range = *arr..;
|
||||
| ^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
|
|
||||
::: $SRC_DIR/core/src/ops/range.rs:LL:COL
|
||||
|
|
||||
LL | pub struct RangeFrom<Idx> {
|
||||
|
@ -12,13 +12,13 @@ impl<'a> Foo<'a> for &'a i16 {
|
||||
}
|
||||
|
||||
impl<'a> Foo<'static> for &'a i32 {
|
||||
//~^ ERROR cannot infer
|
||||
type Value = &'a i32;
|
||||
//~^ ERROR lifetime bound not satisfied
|
||||
}
|
||||
|
||||
impl<'a,'b> Foo<'b> for &'a i64 {
|
||||
//~^ ERROR cannot infer
|
||||
type Value = &'a i32;
|
||||
//~^ ERROR lifetime bound not satisfied
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -1,57 +1,33 @@
|
||||
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
|
||||
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:10
|
||||
error[E0478]: lifetime bound not satisfied
|
||||
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:15:5
|
||||
|
|
||||
LL | impl<'a> Foo<'static> for &'a i32 {
|
||||
| ^^^^^^^^^^^^
|
||||
LL | type Value = &'a i32;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 14:6...
|
||||
note: lifetime parameter instantiated with the lifetime `'a` as defined on the impl at 14:6
|
||||
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:6
|
||||
|
|
||||
LL | impl<'a> Foo<'static> for &'a i32 {
|
||||
| ^^
|
||||
note: ...so that the types are compatible
|
||||
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:10
|
||||
|
|
||||
LL | impl<'a> Foo<'static> for &'a i32 {
|
||||
| ^^^^^^^^^^^^
|
||||
= note: expected `Foo<'static>`
|
||||
found `Foo<'static>`
|
||||
= note: but, the lifetime must be valid for the static lifetime...
|
||||
note: ...so that the type `&i32` will meet its required lifetime bounds
|
||||
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:10
|
||||
|
|
||||
LL | impl<'a> Foo<'static> for &'a i32 {
|
||||
| ^^^^^^^^^^^^
|
||||
= note: but lifetime parameter must outlive the static lifetime
|
||||
|
||||
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
|
||||
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:13
|
||||
error[E0478]: lifetime bound not satisfied
|
||||
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:20:5
|
||||
|
|
||||
LL | impl<'a,'b> Foo<'b> for &'a i64 {
|
||||
| ^^^^^^^
|
||||
LL | type Value = &'a i32;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 19:6...
|
||||
note: lifetime parameter instantiated with the lifetime `'a` as defined on the impl at 19:6
|
||||
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:6
|
||||
|
|
||||
LL | impl<'a,'b> Foo<'b> for &'a i64 {
|
||||
| ^^
|
||||
note: ...so that the types are compatible
|
||||
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:13
|
||||
|
|
||||
LL | impl<'a,'b> Foo<'b> for &'a i64 {
|
||||
| ^^^^^^^
|
||||
= note: expected `Foo<'b>`
|
||||
found `Foo<'_>`
|
||||
note: but, the lifetime must be valid for the lifetime `'b` as defined on the impl at 19:9...
|
||||
note: but lifetime parameter must outlive the lifetime `'b` as defined on the impl at 19:9
|
||||
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:9
|
||||
|
|
||||
LL | impl<'a,'b> Foo<'b> for &'a i64 {
|
||||
| ^^
|
||||
note: ...so that the type `&i32` will meet its required lifetime bounds
|
||||
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:13
|
||||
|
|
||||
LL | impl<'a,'b> Foo<'b> for &'a i64 {
|
||||
| ^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0495`.
|
||||
For more information about this error, try `rustc --explain E0478`.
|
||||
|
@ -7,8 +7,8 @@ trait Foo {
|
||||
}
|
||||
|
||||
impl<'a> Foo for &'a i32 {
|
||||
//~^ ERROR cannot infer
|
||||
type Value = &'a i32;
|
||||
//~^ ERROR lifetime bound not satisfied
|
||||
}
|
||||
|
||||
impl<'a> Foo for i32 {
|
||||
|
@ -1,28 +1,16 @@
|
||||
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
|
||||
--> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:10
|
||||
error[E0478]: lifetime bound not satisfied
|
||||
--> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:10:5
|
||||
|
|
||||
LL | impl<'a> Foo for &'a i32 {
|
||||
| ^^^
|
||||
LL | type Value = &'a i32;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 9:6...
|
||||
note: lifetime parameter instantiated with the lifetime `'a` as defined on the impl at 9:6
|
||||
--> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:6
|
||||
|
|
||||
LL | impl<'a> Foo for &'a i32 {
|
||||
| ^^
|
||||
note: ...so that the types are compatible
|
||||
--> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:10
|
||||
|
|
||||
LL | impl<'a> Foo for &'a i32 {
|
||||
| ^^^
|
||||
= note: expected `Foo`
|
||||
found `Foo`
|
||||
= note: but, the lifetime must be valid for the static lifetime...
|
||||
note: ...so that the type `&i32` will meet its required lifetime bounds
|
||||
--> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:10
|
||||
|
|
||||
LL | impl<'a> Foo for &'a i32 {
|
||||
| ^^^
|
||||
= note: but lifetime parameter must outlive the static lifetime
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0495`.
|
||||
For more information about this error, try `rustc --explain E0478`.
|
||||
|
@ -11,7 +11,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied
|
||||
--> $DIR/deafult-associated-type-bound-1.rs:18:5
|
||||
|
|
||||
LL | type U: Clone;
|
||||
| -------------- required by `X::U`
|
||||
| ----- required by this bound in `X::U`
|
||||
...
|
||||
LL | default type U = str;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str`
|
||||
|
@ -11,7 +11,7 @@ error[E0277]: can't compare `&'static B` with `B`
|
||||
--> $DIR/deafult-associated-type-bound-2.rs:16:5
|
||||
|
|
||||
LL | type U: PartialEq<T>;
|
||||
| --------------------- required by `X::U`
|
||||
| ------------ required by this bound in `X::U`
|
||||
...
|
||||
LL | default type U = &'static B;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `&'static B == B`
|
||||
|
@ -6,7 +6,7 @@
|
||||
//~^^ WARNING the feature `generic_associated_types` is incomplete
|
||||
|
||||
trait X {
|
||||
type U<'a>: PartialEq<&'a Self>;
|
||||
type U<'a>: PartialEq<&'a Self> where Self: 'a;
|
||||
fn unsafe_compare<'b>(x: Option<Self::U<'b>>, y: Option<&'b Self>) {
|
||||
match (x, y) {
|
||||
(Some(a), Some(b)) => a == b,
|
||||
|
@ -18,8 +18,8 @@ LL | #![feature(generic_associated_types)]
|
||||
error[E0277]: can't compare `T` with `T`
|
||||
--> $DIR/deafult-generic-associated-type-bound.rs:19:5
|
||||
|
|
||||
LL | type U<'a>: PartialEq<&'a Self>;
|
||||
| -------------------------------- required by `X::U`
|
||||
LL | type U<'a>: PartialEq<&'a Self> where Self: 'a;
|
||||
| ------------------- required by this bound in `X::U`
|
||||
...
|
||||
LL | default type U<'a> = &'a T;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `T == T`
|
||||
|
@ -2,7 +2,7 @@ error[E0277]: the trait bound `(): CoerceUnsized<*const [u8]>` is not satisfied
|
||||
--> $DIR/issue-44861.rs:21:5
|
||||
|
|
||||
LL | type Data2: CoerceUnsized<*const [u8]>;
|
||||
| --------------------------------------- required by `Smartass::Data2`
|
||||
| -------------------------- required by this bound in `Smartass::Data2`
|
||||
...
|
||||
LL | default type Data2 = ();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `CoerceUnsized<*const [u8]>` is not implemented for `()`
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user