squash OpaqueTy and ProjectionTy into AliasTy
This commit is contained in:
parent
5c6afb850c
commit
c13bd83528
66 changed files with 182 additions and 197 deletions
|
@ -697,7 +697,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
.map_bound(|p| p.predicates),
|
.map_bound(|p| p.predicates),
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => {
|
ty::Opaque(ty::AliasTy { def_id, substs }) => {
|
||||||
find_fn_kind_from_did(tcx.bound_explicit_item_bounds(*def_id), Some(*substs))
|
find_fn_kind_from_did(tcx.bound_explicit_item_bounds(*def_id), Some(*substs))
|
||||||
}
|
}
|
||||||
ty::Closure(_, substs) => match substs.as_closure().kind() {
|
ty::Closure(_, substs) => match substs.as_closure().kind() {
|
||||||
|
|
|
@ -504,7 +504,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||||
let ErrorConstraintInfo { outlived_fr, span, .. } = errci;
|
let ErrorConstraintInfo { outlived_fr, span, .. } = errci;
|
||||||
|
|
||||||
let mut output_ty = self.regioncx.universal_regions().unnormalized_output_ty;
|
let mut output_ty = self.regioncx.universal_regions().unnormalized_output_ty;
|
||||||
if let ty::Opaque(ty::OpaqueTy { def_id, substs: _ }) = *output_ty.kind() {
|
if let ty::Opaque(ty::AliasTy { def_id, substs: _ }) = *output_ty.kind() {
|
||||||
output_ty = self.infcx.tcx.type_of(def_id)
|
output_ty = self.infcx.tcx.type_of(def_id)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ pub(crate) fn eval_nullary_intrinsic<'tcx>(
|
||||||
ConstValue::from_machine_usize(adt.variants().len() as u64, &tcx)
|
ConstValue::from_machine_usize(adt.variants().len() as u64, &tcx)
|
||||||
}
|
}
|
||||||
ty::Projection(_)
|
ty::Projection(_)
|
||||||
| ty::Opaque(ty::OpaqueTy { def_id: _, substs: _ })
|
| ty::Opaque(ty::AliasTy { def_id: _, substs: _ })
|
||||||
| ty::Param(_)
|
| ty::Param(_)
|
||||||
| ty::Placeholder(_)
|
| ty::Placeholder(_)
|
||||||
| ty::Infer(_) => throw_inval!(TooGeneric),
|
| ty::Infer(_) => throw_inval!(TooGeneric),
|
||||||
|
|
|
@ -241,7 +241,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let kind = match parent_ty.ty.kind() {
|
let kind = match parent_ty.ty.kind() {
|
||||||
&ty::Opaque(ty::OpaqueTy { def_id, substs }) => {
|
&ty::Opaque(ty::AliasTy { def_id, substs }) => {
|
||||||
self.tcx.bound_type_of(def_id).subst(self.tcx, substs).kind()
|
self.tcx.bound_type_of(def_id).subst(self.tcx, substs).kind()
|
||||||
}
|
}
|
||||||
kind => kind,
|
kind => kind,
|
||||||
|
|
|
@ -58,8 +58,8 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
|
||||||
// Types with identity (print the module path).
|
// Types with identity (print the module path).
|
||||||
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), substs)
|
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), substs)
|
||||||
| ty::FnDef(def_id, substs)
|
| ty::FnDef(def_id, substs)
|
||||||
| ty::Opaque(ty::OpaqueTy { def_id, substs })
|
| ty::Opaque(ty::AliasTy { def_id, substs })
|
||||||
| ty::Projection(ty::ProjectionTy { def_id, substs })
|
| ty::Projection(ty::AliasTy { def_id, substs })
|
||||||
| ty::Closure(def_id, substs)
|
| ty::Closure(def_id, substs)
|
||||||
| ty::Generator(def_id, substs, _) => self.print_def_path(def_id, substs),
|
| ty::Generator(def_id, substs, _) => self.print_def_path(def_id, substs),
|
||||||
ty::Foreign(def_id) => self.print_def_path(def_id, &[]),
|
ty::Foreign(def_id) => self.print_def_path(def_id, &[]),
|
||||||
|
|
|
@ -1146,7 +1146,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
|
|
||||||
debug!(?substs_trait_ref_and_assoc_item);
|
debug!(?substs_trait_ref_and_assoc_item);
|
||||||
|
|
||||||
ty::ProjectionTy { def_id: assoc_item.def_id, substs: substs_trait_ref_and_assoc_item }
|
ty::AliasTy { def_id: assoc_item.def_id, substs: substs_trait_ref_and_assoc_item }
|
||||||
});
|
});
|
||||||
|
|
||||||
if !speculative {
|
if !speculative {
|
||||||
|
|
|
@ -1440,7 +1440,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'_>, def_id: LocalDefId, span: Span) -> E
|
||||||
impl<'tcx> ty::visit::TypeVisitor<'tcx> for OpaqueTypeCollector {
|
impl<'tcx> ty::visit::TypeVisitor<'tcx> for OpaqueTypeCollector {
|
||||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||||
match *t.kind() {
|
match *t.kind() {
|
||||||
ty::Opaque(ty::OpaqueTy { def_id: def, substs: _ }) => {
|
ty::Opaque(ty::AliasTy { def_id: def, substs: _ }) => {
|
||||||
self.0.push(def);
|
self.0.push(def);
|
||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
|
|
|
@ -1746,7 +1746,7 @@ pub fn check_type_bounds<'tcx>(
|
||||||
_ => predicates.push(
|
_ => predicates.push(
|
||||||
ty::Binder::bind_with_vars(
|
ty::Binder::bind_with_vars(
|
||||||
ty::ProjectionPredicate {
|
ty::ProjectionPredicate {
|
||||||
projection_ty: ty::ProjectionTy {
|
projection_ty: ty::AliasTy {
|
||||||
def_id: trait_ty.def_id,
|
def_id: trait_ty.def_id,
|
||||||
substs: rebased_substs,
|
substs: rebased_substs,
|
||||||
},
|
},
|
||||||
|
|
|
@ -253,7 +253,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
||||||
self.add_constraints_from_invariant_substs(current, data.substs, variance);
|
self.add_constraints_from_invariant_substs(current, data.substs, variance);
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::Opaque(ty::OpaqueTy { def_id: _, substs }) => {
|
ty::Opaque(ty::AliasTy { def_id: _, substs }) => {
|
||||||
self.add_constraints_from_invariant_substs(current, substs, variance);
|
self.add_constraints_from_invariant_substs(current, substs, variance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,9 +110,9 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc
|
||||||
|
|
||||||
#[instrument(level = "trace", skip(self), ret)]
|
#[instrument(level = "trace", skip(self), ret)]
|
||||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||||
// FIXME(alias): merge these
|
// FIXME(alias): merge these
|
||||||
match t.kind() {
|
match t.kind() {
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => self.visit_opaque(*def_id, substs),
|
ty::Opaque(ty::AliasTy { def_id, substs }) => self.visit_opaque(*def_id, substs),
|
||||||
ty::Projection(proj)
|
ty::Projection(proj)
|
||||||
if self.tcx.def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder =>
|
if self.tcx.def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder =>
|
||||||
{
|
{
|
||||||
|
@ -168,7 +168,7 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Clause(ty::Clause::Projection(ty::ProjectionPredicate {
|
ty::PredicateKind::Clause(ty::Clause::Projection(ty::ProjectionPredicate {
|
||||||
projection_ty: ty::ProjectionTy { substs, def_id: _ },
|
projection_ty: ty::AliasTy { substs, def_id: _ },
|
||||||
term,
|
term,
|
||||||
})) => {
|
})) => {
|
||||||
for subst in &substs[1..] {
|
for subst in &substs[1..] {
|
||||||
|
|
|
@ -518,7 +518,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
let substs = sig.output().walk().find_map(|arg| {
|
let substs = sig.output().walk().find_map(|arg| {
|
||||||
if let ty::GenericArgKind::Type(ty) = arg.unpack()
|
if let ty::GenericArgKind::Type(ty) = arg.unpack()
|
||||||
&& let ty::Opaque(ty::OpaqueTy { def_id, substs }) = *ty.kind()
|
&& let ty::Opaque(ty::AliasTy { def_id, substs }) = *ty.kind()
|
||||||
&& def_id == rpit_def_id
|
&& def_id == rpit_def_id
|
||||||
{
|
{
|
||||||
Some(substs)
|
Some(substs)
|
||||||
|
|
|
@ -76,7 +76,7 @@ enum PointerKind<'tcx> {
|
||||||
/// Slice
|
/// Slice
|
||||||
Length,
|
Length,
|
||||||
/// The unsize info of this projection
|
/// The unsize info of this projection
|
||||||
OfProjection(ty::ProjectionTy<'tcx>),
|
OfProjection(ty::AliasTy<'tcx>),
|
||||||
/// The unsize info of this opaque ty
|
/// The unsize info of this opaque ty
|
||||||
OfOpaque(DefId, SubstsRef<'tcx>),
|
OfOpaque(DefId, SubstsRef<'tcx>),
|
||||||
/// The unsize info of this parameter
|
/// The unsize info of this parameter
|
||||||
|
@ -119,7 +119,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
ty::Foreign(..) => Some(PointerKind::Thin),
|
ty::Foreign(..) => Some(PointerKind::Thin),
|
||||||
// We should really try to normalize here.
|
// We should really try to normalize here.
|
||||||
ty::Projection(pi) => Some(PointerKind::OfProjection(pi)),
|
ty::Projection(pi) => Some(PointerKind::OfProjection(pi)),
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => {
|
ty::Opaque(ty::AliasTy { def_id, substs }) => {
|
||||||
Some(PointerKind::OfOpaque(def_id, substs))
|
Some(PointerKind::OfOpaque(def_id, substs))
|
||||||
}
|
}
|
||||||
ty::Param(p) => Some(PointerKind::OfParam(p)),
|
ty::Param(p) => Some(PointerKind::OfParam(p)),
|
||||||
|
|
|
@ -167,7 +167,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
expected_ty: Ty<'tcx>,
|
expected_ty: Ty<'tcx>,
|
||||||
) -> (Option<ExpectedSig<'tcx>>, Option<ty::ClosureKind>) {
|
) -> (Option<ExpectedSig<'tcx>>, Option<ty::ClosureKind>) {
|
||||||
match *expected_ty.kind() {
|
match *expected_ty.kind() {
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => self.deduce_signature_from_predicates(
|
ty::Opaque(ty::AliasTy { def_id, substs }) => self.deduce_signature_from_predicates(
|
||||||
self.tcx.bound_explicit_item_bounds(def_id).subst_iter_copied(self.tcx, substs),
|
self.tcx.bound_explicit_item_bounds(def_id).subst_iter_copied(self.tcx, substs),
|
||||||
),
|
),
|
||||||
ty::Dynamic(ref object_type, ..) => {
|
ty::Dynamic(ref object_type, ..) => {
|
||||||
|
@ -677,7 +677,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
get_future_output(obligation.predicate, obligation.cause.span)
|
get_future_output(obligation.predicate, obligation.cause.span)
|
||||||
})?
|
})?
|
||||||
}
|
}
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => self
|
ty::Opaque(ty::AliasTy { def_id, substs }) => self
|
||||||
.tcx
|
.tcx
|
||||||
.bound_explicit_item_bounds(def_id)
|
.bound_explicit_item_bounds(def_id)
|
||||||
.subst_iter_copied(self.tcx, substs)
|
.subst_iter_copied(self.tcx, substs)
|
||||||
|
|
|
@ -1805,7 +1805,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
||||||
{
|
{
|
||||||
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(fcx, ty);
|
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(fcx, ty);
|
||||||
// Get the `impl Trait`'s `DefId`.
|
// Get the `impl Trait`'s `DefId`.
|
||||||
if let ty::Opaque(ty::OpaqueTy { def_id, substs: _ }) = ty.kind()
|
if let ty::Opaque(ty::AliasTy { def_id, substs: _ }) = ty.kind()
|
||||||
// Get the `impl Trait`'s `Item` so that we can get its trait bounds and
|
// Get the `impl Trait`'s `Item` so that we can get its trait bounds and
|
||||||
// get the `Trait`'s `DefId`.
|
// get the `Trait`'s `DefId`.
|
||||||
&& let hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds, .. }) =
|
&& let hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds, .. }) =
|
||||||
|
|
|
@ -2391,7 +2391,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
ty::Param(param_ty) => {
|
ty::Param(param_ty) => {
|
||||||
self.point_at_param_definition(&mut err, param_ty);
|
self.point_at_param_definition(&mut err, param_ty);
|
||||||
}
|
}
|
||||||
ty::Opaque(ty::OpaqueTy { def_id: _, substs: _ }) => {
|
ty::Opaque(ty::AliasTy { def_id: _, substs: _ }) => {
|
||||||
self.suggest_await_on_field_access(&mut err, ident, base, base_ty.peel_refs());
|
self.suggest_await_on_field_access(&mut err, ident, base, base_ty.peel_refs());
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
@ -716,7 +716,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
if formal_ret.has_infer_types() {
|
if formal_ret.has_infer_types() {
|
||||||
for ty in ret_ty.walk() {
|
for ty in ret_ty.walk() {
|
||||||
if let ty::subst::GenericArgKind::Type(ty) = ty.unpack()
|
if let ty::subst::GenericArgKind::Type(ty) = ty.unpack()
|
||||||
&& let ty::Opaque(ty::OpaqueTy { def_id, substs: _ }) = *ty.kind()
|
&& let ty::Opaque(ty::AliasTy { def_id, substs: _ }) = *ty.kind()
|
||||||
&& let Some(def_id) = def_id.as_local()
|
&& let Some(def_id) = def_id.as_local()
|
||||||
&& self.opaque_type_origin(def_id, DUMMY_SP).is_some() {
|
&& self.opaque_type_origin(def_id, DUMMY_SP).is_some() {
|
||||||
return None;
|
return None;
|
||||||
|
|
|
@ -2124,7 +2124,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::Opaque(ty::OpaqueTy { def_id: new_def_id, substs: _ })
|
ty::Opaque(ty::AliasTy { def_id: new_def_id, substs: _ })
|
||||||
| ty::Closure(new_def_id, _)
|
| ty::Closure(new_def_id, _)
|
||||||
| ty::FnDef(new_def_id, _) => {
|
| ty::FnDef(new_def_id, _) => {
|
||||||
def_id = new_def_id;
|
def_id = new_def_id;
|
||||||
|
|
|
@ -174,7 +174,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let fn_sig = substs.as_closure().sig();
|
let fn_sig = substs.as_closure().sig();
|
||||||
Some((DefIdOrName::DefId(def_id), fn_sig.output(), fn_sig.inputs().map_bound(|inputs| &inputs[1..])))
|
Some((DefIdOrName::DefId(def_id), fn_sig.output(), fn_sig.inputs().map_bound(|inputs| &inputs[1..])))
|
||||||
}
|
}
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => {
|
ty::Opaque(ty::AliasTy { def_id, substs }) => {
|
||||||
self.tcx.bound_item_bounds(def_id).subst(self.tcx, substs).iter().find_map(|pred| {
|
self.tcx.bound_item_bounds(def_id).subst(self.tcx, substs).iter().find_map(|pred| {
|
||||||
if let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) = pred.kind().skip_binder()
|
if let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) = pred.kind().skip_binder()
|
||||||
&& Some(proj.projection_ty.def_id) == self.tcx.lang_items().fn_once_output()
|
&& Some(proj.projection_ty.def_id) == self.tcx.lang_items().fn_once_output()
|
||||||
|
|
|
@ -563,7 +563,7 @@ fn check_must_not_suspend_ty<'tcx>(
|
||||||
}
|
}
|
||||||
ty::Adt(def, _) => check_must_not_suspend_def(fcx.tcx, def.did(), hir_id, data),
|
ty::Adt(def, _) => check_must_not_suspend_def(fcx.tcx, def.did(), hir_id, data),
|
||||||
// FIXME: support adding the attribute to TAITs
|
// FIXME: support adding the attribute to TAITs
|
||||||
ty::Opaque(ty::OpaqueTy { def_id: def, substs: _ }) => {
|
ty::Opaque(ty::AliasTy { def_id: def, substs: _ }) => {
|
||||||
let mut has_emitted = false;
|
let mut has_emitted = false;
|
||||||
for &(predicate, _) in fcx.tcx.explicit_item_bounds(def) {
|
for &(predicate, _) in fcx.tcx.explicit_item_bounds(def) {
|
||||||
// We only look at the `DefId`, so it is safe to skip the binder here.
|
// We only look at the `DefId`, so it is safe to skip the binder here.
|
||||||
|
|
|
@ -557,7 +557,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
.chain(projection_ty.substs.iter().skip(1)),
|
.chain(projection_ty.substs.iter().skip(1)),
|
||||||
);
|
);
|
||||||
|
|
||||||
let quiet_projection_ty = ty::ProjectionTy {
|
let quiet_projection_ty = ty::AliasTy {
|
||||||
substs: substs_with_infer_self,
|
substs: substs_with_infer_self,
|
||||||
def_id: projection_ty.def_id,
|
def_id: projection_ty.def_id,
|
||||||
};
|
};
|
||||||
|
|
|
@ -546,7 +546,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||||
impl<'tcx> ty::TypeVisitor<'tcx> for RecursionChecker {
|
impl<'tcx> ty::TypeVisitor<'tcx> for RecursionChecker {
|
||||||
type BreakTy = ();
|
type BreakTy = ();
|
||||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||||
if let ty::Opaque(ty::OpaqueTy { def_id, substs: _ }) = *t.kind() {
|
if let ty::Opaque(ty::AliasTy { def_id, substs: _ }) = *t.kind() {
|
||||||
if def_id == self.def_id.to_def_id() {
|
if def_id == self.def_id.to_def_id() {
|
||||||
return ControlFlow::Break(());
|
return ControlFlow::Break(());
|
||||||
}
|
}
|
||||||
|
|
|
@ -411,7 +411,7 @@ impl<'tcx> ToTrace<'tcx> for ty::PolyTraitRef<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> ToTrace<'tcx> for ty::ProjectionTy<'tcx> {
|
impl<'tcx> ToTrace<'tcx> for ty::AliasTy<'tcx> {
|
||||||
fn to_trace(
|
fn to_trace(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
cause: &ObligationCause<'tcx>,
|
cause: &ObligationCause<'tcx>,
|
||||||
|
|
|
@ -675,7 +675,7 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
|
||||||
// relatable.
|
// relatable.
|
||||||
Ok(t)
|
Ok(t)
|
||||||
}
|
}
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => {
|
ty::Opaque(ty::AliasTy { def_id, substs }) => {
|
||||||
let s = self.relate(substs, substs)?;
|
let s = self.relate(substs, substs)?;
|
||||||
Ok(if s == substs { t } else { self.infcx.tcx.mk_opaque(def_id, s) })
|
Ok(if s == substs { t } else { self.infcx.tcx.mk_opaque(def_id, s) })
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,13 +101,13 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
(
|
(
|
||||||
&ty::Opaque(ty::OpaqueTy { def_id: a_def_id, substs: _ }),
|
&ty::Opaque(ty::AliasTy { def_id: a_def_id, substs: _ }),
|
||||||
&ty::Opaque(ty::OpaqueTy { def_id: b_def_id, substs: _ }),
|
&ty::Opaque(ty::AliasTy { def_id: b_def_id, substs: _ }),
|
||||||
) if a_def_id == b_def_id => {
|
) if a_def_id == b_def_id => {
|
||||||
self.fields.infcx.super_combine_tys(self, a, b)?;
|
self.fields.infcx.super_combine_tys(self, a, b)?;
|
||||||
}
|
}
|
||||||
(&ty::Opaque(ty::OpaqueTy { def_id, substs: _ }), _)
|
(&ty::Opaque(ty::AliasTy { def_id, substs: _ }), _)
|
||||||
| (_, &ty::Opaque(ty::OpaqueTy { def_id, substs: _ }))
|
| (_, &ty::Opaque(ty::AliasTy { def_id, substs: _ }))
|
||||||
if self.fields.define_opaque_types && def_id.is_local() =>
|
if self.fields.define_opaque_types && def_id.is_local() =>
|
||||||
{
|
{
|
||||||
self.fields.obligations.extend(
|
self.fields.obligations.extend(
|
||||||
|
|
|
@ -340,7 +340,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
pub fn get_impl_future_output_ty(&self, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
|
pub fn get_impl_future_output_ty(&self, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
|
||||||
// FIXME(alias): Merge these
|
// FIXME(alias): Merge these
|
||||||
let (def_id, substs) = match *ty.kind() {
|
let (def_id, substs) = match *ty.kind() {
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => (def_id, substs),
|
ty::Opaque(ty::AliasTy { def_id, substs }) => (def_id, substs),
|
||||||
ty::Projection(data)
|
ty::Projection(data)
|
||||||
if self.tcx.def_kind(data.def_id) == DefKind::ImplTraitPlaceholder =>
|
if self.tcx.def_kind(data.def_id) == DefKind::ImplTraitPlaceholder =>
|
||||||
{
|
{
|
||||||
|
@ -1732,7 +1732,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
let sort_string = |ty: Ty<'tcx>, path: Option<PathBuf>| {
|
let sort_string = |ty: Ty<'tcx>, path: Option<PathBuf>| {
|
||||||
// FIXME(alias): Merge these
|
// FIXME(alias): Merge these
|
||||||
let mut s = match (extra, ty.kind()) {
|
let mut s = match (extra, ty.kind()) {
|
||||||
(true, ty::Opaque(ty::OpaqueTy { def_id, .. })) => {
|
(true, ty::Opaque(ty::AliasTy { def_id, .. })) => {
|
||||||
let sm = self.tcx.sess.source_map();
|
let sm = self.tcx.sess.source_map();
|
||||||
let pos = sm.lookup_char_pos(self.tcx.def_span(*def_id).lo());
|
let pos = sm.lookup_char_pos(self.tcx.def_span(*def_id).lo());
|
||||||
format!(
|
format!(
|
||||||
|
@ -2386,7 +2386,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
// suggest:
|
// suggest:
|
||||||
// fn get_later<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
|
// fn get_later<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
|
||||||
ty::Closure(_, _substs)
|
ty::Closure(_, _substs)
|
||||||
| ty::Opaque(ty::OpaqueTy { def_id: _, substs: _substs })
|
| ty::Opaque(ty::AliasTy { def_id: _, substs: _substs })
|
||||||
if return_impl_trait =>
|
if return_impl_trait =>
|
||||||
{
|
{
|
||||||
new_binding_suggestion(&mut err, type_param_span);
|
new_binding_suggestion(&mut err, type_param_span);
|
||||||
|
@ -2770,7 +2770,7 @@ impl TyCategory {
|
||||||
pub fn from_ty(tcx: TyCtxt<'_>, ty: Ty<'_>) -> Option<(Self, DefId)> {
|
pub fn from_ty(tcx: TyCtxt<'_>, ty: Ty<'_>) -> Option<(Self, DefId)> {
|
||||||
match *ty.kind() {
|
match *ty.kind() {
|
||||||
ty::Closure(def_id, _) => Some((Self::Closure, def_id)),
|
ty::Closure(def_id, _) => Some((Self::Closure, def_id)),
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs: _ }) => Some((Self::Opaque, def_id)),
|
ty::Opaque(ty::AliasTy { def_id, substs: _ }) => Some((Self::Opaque, def_id)),
|
||||||
ty::Generator(def_id, ..) => {
|
ty::Generator(def_id, ..) => {
|
||||||
Some((Self::Generator(tcx.generator_kind(def_id).unwrap()), def_id))
|
Some((Self::Generator(tcx.generator_kind(def_id).unwrap()), def_id))
|
||||||
}
|
}
|
||||||
|
|
|
@ -487,12 +487,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
StatementAsExpression::CorrectType
|
StatementAsExpression::CorrectType
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
ty::Opaque(ty::OpaqueTy { def_id: last_def_id, substs: _ }),
|
ty::Opaque(ty::AliasTy { def_id: last_def_id, substs: _ }),
|
||||||
ty::Opaque(ty::OpaqueTy { def_id: exp_def_id, substs: _ }),
|
ty::Opaque(ty::AliasTy { def_id: exp_def_id, substs: _ }),
|
||||||
) if last_def_id == exp_def_id => StatementAsExpression::CorrectType,
|
) if last_def_id == exp_def_id => StatementAsExpression::CorrectType,
|
||||||
(
|
(
|
||||||
ty::Opaque(ty::OpaqueTy { def_id: last_def_id, substs: last_bounds }),
|
ty::Opaque(ty::AliasTy { def_id: last_def_id, substs: last_bounds }),
|
||||||
ty::Opaque(ty::OpaqueTy { def_id: exp_def_id, substs: exp_bounds }),
|
ty::Opaque(ty::AliasTy { def_id: exp_def_id, substs: exp_bounds }),
|
||||||
) => {
|
) => {
|
||||||
debug!(
|
debug!(
|
||||||
"both opaque, likely future {:?} {:?} {:?} {:?}",
|
"both opaque, likely future {:?} {:?} {:?} {:?}",
|
||||||
|
|
|
@ -106,11 +106,11 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
(
|
(
|
||||||
&ty::Opaque(ty::OpaqueTy { def_id: a_def_id, substs: _ }),
|
&ty::Opaque(ty::AliasTy { def_id: a_def_id, substs: _ }),
|
||||||
&ty::Opaque(ty::OpaqueTy { def_id: b_def_id, substs: _ }),
|
&ty::Opaque(ty::AliasTy { def_id: b_def_id, substs: _ }),
|
||||||
) if a_def_id == b_def_id => infcx.super_combine_tys(this, a, b),
|
) if a_def_id == b_def_id => infcx.super_combine_tys(this, a, b),
|
||||||
(&ty::Opaque(ty::OpaqueTy { def_id, substs: _ }), _)
|
(&ty::Opaque(ty::AliasTy { def_id, substs: _ }), _)
|
||||||
| (_, &ty::Opaque(ty::OpaqueTy { def_id, substs: _ }))
|
| (_, &ty::Opaque(ty::AliasTy { def_id, substs: _ }))
|
||||||
if this.define_opaque_types() && def_id.is_local() =>
|
if this.define_opaque_types() && def_id.is_local() =>
|
||||||
{
|
{
|
||||||
this.add_obligations(
|
this.add_obligations(
|
||||||
|
|
|
@ -275,7 +275,7 @@ where
|
||||||
/// `ProjectionEq(projection = ?U)`, `ProjectionEq(other_projection = ?U)`.
|
/// `ProjectionEq(projection = ?U)`, `ProjectionEq(other_projection = ?U)`.
|
||||||
fn relate_projection_ty(
|
fn relate_projection_ty(
|
||||||
&mut self,
|
&mut self,
|
||||||
projection_ty: ty::ProjectionTy<'tcx>,
|
projection_ty: ty::AliasTy<'tcx>,
|
||||||
value_ty: Ty<'tcx>,
|
value_ty: Ty<'tcx>,
|
||||||
) -> Ty<'tcx> {
|
) -> Ty<'tcx> {
|
||||||
use rustc_span::DUMMY_SP;
|
use rustc_span::DUMMY_SP;
|
||||||
|
@ -609,8 +609,8 @@ where
|
||||||
(&ty::Infer(ty::TyVar(vid)), _) => self.relate_ty_var((vid, b)),
|
(&ty::Infer(ty::TyVar(vid)), _) => self.relate_ty_var((vid, b)),
|
||||||
|
|
||||||
(
|
(
|
||||||
&ty::Opaque(ty::OpaqueTy { def_id: a_def_id, substs: _ }),
|
&ty::Opaque(ty::AliasTy { def_id: a_def_id, substs: _ }),
|
||||||
&ty::Opaque(ty::OpaqueTy { def_id: b_def_id, substs: _ }),
|
&ty::Opaque(ty::AliasTy { def_id: b_def_id, substs: _ }),
|
||||||
) if a_def_id == b_def_id => infcx.super_combine_tys(self, a, b).or_else(|err| {
|
) if a_def_id == b_def_id => infcx.super_combine_tys(self, a, b).or_else(|err| {
|
||||||
self.tcx().sess.delay_span_bug(
|
self.tcx().sess.delay_span_bug(
|
||||||
self.delegate.span(),
|
self.delegate.span(),
|
||||||
|
@ -618,8 +618,8 @@ where
|
||||||
);
|
);
|
||||||
if a_def_id.is_local() { self.relate_opaques(a, b) } else { Err(err) }
|
if a_def_id.is_local() { self.relate_opaques(a, b) } else { Err(err) }
|
||||||
}),
|
}),
|
||||||
(&ty::Opaque(ty::OpaqueTy { def_id, substs: _ }), _)
|
(&ty::Opaque(ty::AliasTy { def_id, substs: _ }), _)
|
||||||
| (_, &ty::Opaque(ty::OpaqueTy { def_id, substs: _ }))
|
| (_, &ty::Opaque(ty::AliasTy { def_id, substs: _ }))
|
||||||
if def_id.is_local() =>
|
if def_id.is_local() =>
|
||||||
{
|
{
|
||||||
self.relate_opaques(a, b)
|
self.relate_opaques(a, b)
|
||||||
|
|
|
@ -66,7 +66,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
lt_op: |lt| lt,
|
lt_op: |lt| lt,
|
||||||
ct_op: |ct| ct,
|
ct_op: |ct| ct,
|
||||||
ty_op: |ty| match *ty.kind() {
|
ty_op: |ty| match *ty.kind() {
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs: _substs })
|
ty::Opaque(ty::AliasTy { def_id, substs: _substs })
|
||||||
if replace_opaque_type(def_id) =>
|
if replace_opaque_type(def_id) =>
|
||||||
{
|
{
|
||||||
let def_span = self.tcx.def_span(def_id);
|
let def_span = self.tcx.def_span(def_id);
|
||||||
|
@ -106,7 +106,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
}
|
}
|
||||||
let (a, b) = if a_is_expected { (a, b) } else { (b, a) };
|
let (a, b) = if a_is_expected { (a, b) } else { (b, a) };
|
||||||
let process = |a: Ty<'tcx>, b: Ty<'tcx>, a_is_expected| match *a.kind() {
|
let process = |a: Ty<'tcx>, b: Ty<'tcx>, a_is_expected| match *a.kind() {
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) if def_id.is_local() => {
|
ty::Opaque(ty::AliasTy { def_id, substs }) if def_id.is_local() => {
|
||||||
let def_id = def_id.expect_local();
|
let def_id = def_id.expect_local();
|
||||||
let origin = match self.defining_use_anchor {
|
let origin = match self.defining_use_anchor {
|
||||||
DefiningAnchor::Bind(_) => {
|
DefiningAnchor::Bind(_) => {
|
||||||
|
@ -149,7 +149,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
DefiningAnchor::Bubble => self.opaque_ty_origin_unchecked(def_id, cause.span),
|
DefiningAnchor::Bubble => self.opaque_ty_origin_unchecked(def_id, cause.span),
|
||||||
DefiningAnchor::Error => return None,
|
DefiningAnchor::Error => return None,
|
||||||
};
|
};
|
||||||
if let ty::Opaque(ty::OpaqueTy { def_id: b_def_id, substs: _ }) = *b.kind() {
|
if let ty::Opaque(ty::AliasTy { def_id: b_def_id, substs: _ }) = *b.kind() {
|
||||||
// We could accept this, but there are various ways to handle this situation, and we don't
|
// We could accept this, but there are various ways to handle this situation, and we don't
|
||||||
// want to make a decision on it right now. Likely this case is so super rare anyway, that
|
// want to make a decision on it right now. Likely this case is so super rare anyway, that
|
||||||
// no one encounters it in practice.
|
// no one encounters it in practice.
|
||||||
|
@ -478,7 +478,7 @@ where
|
||||||
substs.as_generator().resume_ty().visit_with(self);
|
substs.as_generator().resume_ty().visit_with(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, ref substs }) => {
|
ty::Opaque(ty::AliasTy { def_id, ref substs }) => {
|
||||||
// Skip lifetime paramters that are not captures.
|
// Skip lifetime paramters that are not captures.
|
||||||
let variances = self.tcx.variances_of(*def_id);
|
let variances = self.tcx.variances_of(*def_id);
|
||||||
|
|
||||||
|
@ -581,7 +581,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
}
|
}
|
||||||
// Replace all other mentions of the same opaque type with the hidden type,
|
// Replace all other mentions of the same opaque type with the hidden type,
|
||||||
// as the bounds must hold on the hidden type after all.
|
// as the bounds must hold on the hidden type after all.
|
||||||
ty::Opaque(ty::OpaqueTy { def_id: def_id2, substs: substs2 })
|
ty::Opaque(ty::AliasTy { def_id: def_id2, substs: substs2 })
|
||||||
if def_id.to_def_id() == def_id2 && substs == substs2 =>
|
if def_id.to_def_id() == def_id2 && substs == substs2 =>
|
||||||
{
|
{
|
||||||
hidden_ty
|
hidden_ty
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub enum Component<'tcx> {
|
||||||
// is not in a position to judge which is the best technique, so
|
// is not in a position to judge which is the best technique, so
|
||||||
// we just product the projection as a component and leave it to
|
// we just product the projection as a component and leave it to
|
||||||
// the consumer to decide (but see `EscapingProjection` below).
|
// the consumer to decide (but see `EscapingProjection` below).
|
||||||
Projection(ty::ProjectionTy<'tcx>),
|
Projection(ty::AliasTy<'tcx>),
|
||||||
|
|
||||||
// In the case where a projection has escaping regions -- meaning
|
// In the case where a projection has escaping regions -- meaning
|
||||||
// regions bound within the type itself -- we always use
|
// regions bound within the type itself -- we always use
|
||||||
|
@ -130,7 +130,7 @@ fn compute_components<'tcx>(
|
||||||
// outlives any other lifetime, which is unsound.
|
// outlives any other lifetime, which is unsound.
|
||||||
// See https://github.com/rust-lang/rust/issues/84305 for
|
// See https://github.com/rust-lang/rust/issues/84305 for
|
||||||
// more details.
|
// more details.
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => {
|
ty::Opaque(ty::AliasTy { def_id, substs }) => {
|
||||||
out.push(Component::Opaque(def_id, substs));
|
out.push(Component::Opaque(def_id, substs));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -338,7 +338,7 @@ where
|
||||||
substs,
|
substs,
|
||||||
true,
|
true,
|
||||||
|ty| match *ty.kind() {
|
|ty| match *ty.kind() {
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => (def_id, substs),
|
ty::Opaque(ty::AliasTy { def_id, substs }) => (def_id, substs),
|
||||||
_ => bug!("expected only projection types from env, not {:?}", ty),
|
_ => bug!("expected only projection types from env, not {:?}", ty),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -349,7 +349,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
origin: infer::SubregionOrigin<'tcx>,
|
origin: infer::SubregionOrigin<'tcx>,
|
||||||
region: ty::Region<'tcx>,
|
region: ty::Region<'tcx>,
|
||||||
projection_ty: ty::ProjectionTy<'tcx>,
|
projection_ty: ty::AliasTy<'tcx>,
|
||||||
) {
|
) {
|
||||||
self.generic_must_outlive(
|
self.generic_must_outlive(
|
||||||
origin,
|
origin,
|
||||||
|
|
|
@ -16,7 +16,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
pub fn infer_projection(
|
pub fn infer_projection(
|
||||||
&self,
|
&self,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
projection_ty: ty::ProjectionTy<'tcx>,
|
projection_ty: ty::AliasTy<'tcx>,
|
||||||
cause: ObligationCause<'tcx>,
|
cause: ObligationCause<'tcx>,
|
||||||
recursion_depth: usize,
|
recursion_depth: usize,
|
||||||
obligations: &mut Vec<PredicateObligation<'tcx>>,
|
obligations: &mut Vec<PredicateObligation<'tcx>>,
|
||||||
|
|
|
@ -169,7 +169,7 @@ pub struct Verify<'tcx> {
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, TypeFoldable, TypeVisitable)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, TypeFoldable, TypeVisitable)]
|
||||||
pub enum GenericKind<'tcx> {
|
pub enum GenericKind<'tcx> {
|
||||||
Param(ty::ParamTy),
|
Param(ty::ParamTy),
|
||||||
Projection(ty::ProjectionTy<'tcx>),
|
Projection(ty::AliasTy<'tcx>),
|
||||||
Opaque(DefId, SubstsRef<'tcx>),
|
Opaque(DefId, SubstsRef<'tcx>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,14 +131,14 @@ impl<'tcx> TypeRelation<'tcx> for Sub<'_, '_, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
(
|
(
|
||||||
&ty::Opaque(ty::OpaqueTy { def_id: a_def_id, substs: _ }),
|
&ty::Opaque(ty::AliasTy { def_id: a_def_id, substs: _ }),
|
||||||
&ty::Opaque(ty::OpaqueTy { def_id: b_def_id, substs: _ }),
|
&ty::Opaque(ty::AliasTy { def_id: b_def_id, substs: _ }),
|
||||||
) if a_def_id == b_def_id => {
|
) if a_def_id == b_def_id => {
|
||||||
self.fields.infcx.super_combine_tys(self, a, b)?;
|
self.fields.infcx.super_combine_tys(self, a, b)?;
|
||||||
Ok(a)
|
Ok(a)
|
||||||
}
|
}
|
||||||
(&ty::Opaque(ty::OpaqueTy { def_id, substs: _ }), _)
|
(&ty::Opaque(ty::AliasTy { def_id, substs: _ }), _)
|
||||||
| (_, &ty::Opaque(ty::OpaqueTy { def_id, substs: _ }))
|
| (_, &ty::Opaque(ty::AliasTy { def_id, substs: _ }))
|
||||||
if self.fields.define_opaque_types && def_id.is_local() =>
|
if self.fields.define_opaque_types && def_id.is_local() =>
|
||||||
{
|
{
|
||||||
self.fields.obligations.extend(
|
self.fields.obligations.extend(
|
||||||
|
|
|
@ -77,11 +77,11 @@ pub struct ProjectionCacheStorage<'tcx> {
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
|
||||||
pub struct ProjectionCacheKey<'tcx> {
|
pub struct ProjectionCacheKey<'tcx> {
|
||||||
ty: ty::ProjectionTy<'tcx>,
|
ty: ty::AliasTy<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> ProjectionCacheKey<'tcx> {
|
impl<'tcx> ProjectionCacheKey<'tcx> {
|
||||||
pub fn new(ty: ty::ProjectionTy<'tcx>) -> Self {
|
pub fn new(ty: ty::AliasTy<'tcx>) -> Self {
|
||||||
Self { ty }
|
Self { ty }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
|
||||||
// then we can emit a suggestion to add the bound.
|
// then we can emit a suggestion to add the bound.
|
||||||
let add_bound = match (proj_term.kind(), assoc_pred.kind().skip_binder()) {
|
let add_bound = match (proj_term.kind(), assoc_pred.kind().skip_binder()) {
|
||||||
(
|
(
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs: _ }),
|
ty::Opaque(ty::AliasTy { def_id, substs: _ }),
|
||||||
ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)),
|
ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)),
|
||||||
) => Some(AddBound {
|
) => Some(AddBound {
|
||||||
suggest_span: cx.tcx.def_span(*def_id).shrink_to_hi(),
|
suggest_span: cx.tcx.def_span(*def_id).shrink_to_hi(),
|
||||||
|
|
|
@ -96,7 +96,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
|
||||||
|
|
||||||
if let hir::ExprKind::Match(await_expr, _arms, hir::MatchSource::AwaitDesugar) = expr.kind
|
if let hir::ExprKind::Match(await_expr, _arms, hir::MatchSource::AwaitDesugar) = expr.kind
|
||||||
&& let ty = cx.typeck_results().expr_ty(&await_expr)
|
&& let ty = cx.typeck_results().expr_ty(&await_expr)
|
||||||
&& let ty::Opaque(ty::OpaqueTy { def_id: future_def_id, substs: _ }) = ty.kind()
|
&& let ty::Opaque(ty::AliasTy { def_id: future_def_id, substs: _ }) = ty.kind()
|
||||||
&& cx.tcx.ty_is_opaque_future(ty)
|
&& cx.tcx.ty_is_opaque_future(ty)
|
||||||
// FIXME: This also includes non-async fns that return `impl Future`.
|
// FIXME: This also includes non-async fns that return `impl Future`.
|
||||||
&& let async_fn_def_id = cx.tcx.parent(*future_def_id)
|
&& let async_fn_def_id = cx.tcx.parent(*future_def_id)
|
||||||
|
@ -251,7 +251,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
|
||||||
.map(|inner| MustUsePath::Boxed(Box::new(inner)))
|
.map(|inner| MustUsePath::Boxed(Box::new(inner)))
|
||||||
}
|
}
|
||||||
ty::Adt(def, _) => is_def_must_use(cx, def.did(), span),
|
ty::Adt(def, _) => is_def_must_use(cx, def.did(), span),
|
||||||
ty::Opaque(ty::OpaqueTy { def_id: def, substs: _ }) => {
|
ty::Opaque(ty::AliasTy { def_id: def, substs: _ }) => {
|
||||||
elaborate_predicates_with_span(
|
elaborate_predicates_with_span(
|
||||||
cx.tcx,
|
cx.tcx,
|
||||||
cx.tcx.explicit_item_bounds(def).iter().cloned(),
|
cx.tcx.explicit_item_bounds(def).iter().cloned(),
|
||||||
|
|
|
@ -250,7 +250,7 @@ pub enum ObligationCauseCode<'tcx> {
|
||||||
TupleElem,
|
TupleElem,
|
||||||
|
|
||||||
/// This is the trait reference from the given projection.
|
/// This is the trait reference from the given projection.
|
||||||
ProjectionWf(ty::ProjectionTy<'tcx>),
|
ProjectionWf(ty::AliasTy<'tcx>),
|
||||||
|
|
||||||
/// Must satisfy all of the where-clause predicates of the
|
/// Must satisfy all of the where-clause predicates of the
|
||||||
/// given item.
|
/// given item.
|
||||||
|
|
|
@ -76,8 +76,7 @@ pub mod type_op {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type CanonicalProjectionGoal<'tcx> =
|
pub type CanonicalProjectionGoal<'tcx> = Canonical<'tcx, ty::ParamEnvAnd<'tcx, ty::AliasTy<'tcx>>>;
|
||||||
Canonical<'tcx, ty::ParamEnvAnd<'tcx, ty::ProjectionTy<'tcx>>>;
|
|
||||||
|
|
||||||
pub type CanonicalTyGoal<'tcx> = Canonical<'tcx, ty::ParamEnvAnd<'tcx, Ty<'tcx>>>;
|
pub type CanonicalTyGoal<'tcx> = Canonical<'tcx, ty::ParamEnvAnd<'tcx, Ty<'tcx>>>;
|
||||||
|
|
||||||
|
@ -218,6 +217,6 @@ pub struct NormalizationResult<'tcx> {
|
||||||
pub enum OutlivesBound<'tcx> {
|
pub enum OutlivesBound<'tcx> {
|
||||||
RegionSubRegion(ty::Region<'tcx>, ty::Region<'tcx>),
|
RegionSubRegion(ty::Region<'tcx>, ty::Region<'tcx>),
|
||||||
RegionSubParam(ty::Region<'tcx>, ty::ParamTy),
|
RegionSubParam(ty::Region<'tcx>, ty::ParamTy),
|
||||||
RegionSubProjection(ty::Region<'tcx>, ty::ProjectionTy<'tcx>),
|
RegionSubProjection(ty::Region<'tcx>, ty::AliasTy<'tcx>),
|
||||||
RegionSubOpaque(ty::Region<'tcx>, DefId, SubstsRef<'tcx>),
|
RegionSubOpaque(ty::Region<'tcx>, DefId, SubstsRef<'tcx>),
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,11 @@ use crate::thir::Thir;
|
||||||
use crate::traits;
|
use crate::traits;
|
||||||
use crate::ty::query::{self, TyCtxtAt};
|
use crate::ty::query::{self, TyCtxtAt};
|
||||||
use crate::ty::{
|
use crate::ty::{
|
||||||
self, AdtDef, AdtDefData, AdtKind, Binder, BindingMode, BoundVar, CanonicalPolyFnSig,
|
self, AdtDef, AdtDefData, AdtKind, AliasTy, Binder, BindingMode, BoundVar, CanonicalPolyFnSig,
|
||||||
ClosureSizeProfileData, Const, ConstS, DefIdTree, FloatTy, FloatVar, FloatVid,
|
ClosureSizeProfileData, Const, ConstS, DefIdTree, FloatTy, FloatVar, FloatVid,
|
||||||
GenericParamDefKind, InferTy, IntTy, IntVar, IntVid, List, ParamConst, ParamTy,
|
GenericParamDefKind, InferTy, IntTy, IntVar, IntVid, List, ParamConst, ParamTy,
|
||||||
PolyExistentialPredicate, PolyFnSig, Predicate, PredicateKind, ProjectionTy, Region,
|
PolyExistentialPredicate, PolyFnSig, Predicate, PredicateKind, Region, RegionKind, ReprOptions,
|
||||||
RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyVar, TyVid, TypeAndMut, UintTy,
|
TraitObjectVisitor, Ty, TyKind, TyVar, TyVid, TypeAndMut, UintTy, Visibility,
|
||||||
Visibility,
|
|
||||||
};
|
};
|
||||||
use crate::ty::{GenericArg, GenericArgKind, InternalSubsts, SubstsRef, UserSubsts};
|
use crate::ty::{GenericArg, GenericArgKind, InternalSubsts, SubstsRef, UserSubsts};
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
|
@ -116,8 +115,8 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
|
||||||
type ListBinderExistentialPredicate = &'tcx List<PolyExistentialPredicate<'tcx>>;
|
type ListBinderExistentialPredicate = &'tcx List<PolyExistentialPredicate<'tcx>>;
|
||||||
type BinderListTy = Binder<'tcx, &'tcx List<Ty<'tcx>>>;
|
type BinderListTy = Binder<'tcx, &'tcx List<Ty<'tcx>>>;
|
||||||
type ListTy = &'tcx List<Ty<'tcx>>;
|
type ListTy = &'tcx List<Ty<'tcx>>;
|
||||||
type ProjectionTy = ty::ProjectionTy<'tcx>;
|
type ProjectionTy = ty::AliasTy<'tcx>;
|
||||||
type OpaqueTy = ty::OpaqueTy<'tcx>;
|
type OpaqueTy = ty::AliasTy<'tcx>;
|
||||||
type ParamTy = ParamTy;
|
type ParamTy = ParamTy;
|
||||||
type BoundTy = ty::BoundTy;
|
type BoundTy = ty::BoundTy;
|
||||||
type PlaceholderType = ty::PlaceholderType;
|
type PlaceholderType = ty::PlaceholderType;
|
||||||
|
@ -2324,7 +2323,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
|
|
||||||
/// Given a `ty`, return whether it's an `impl Future<...>`.
|
/// Given a `ty`, return whether it's an `impl Future<...>`.
|
||||||
pub fn ty_is_opaque_future(self, ty: Ty<'_>) -> bool {
|
pub fn ty_is_opaque_future(self, ty: Ty<'_>) -> bool {
|
||||||
let ty::Opaque(ty::OpaqueTy { def_id, substs: _ }) = ty.kind() else { return false };
|
let ty::Opaque(ty::AliasTy { def_id, substs: _ }) = ty.kind() else { return false };
|
||||||
let future_trait = self.require_lang_item(LangItem::Future, None);
|
let future_trait = self.require_lang_item(LangItem::Future, None);
|
||||||
|
|
||||||
self.explicit_item_bounds(def_id).iter().any(|(predicate, _)| {
|
self.explicit_item_bounds(def_id).iter().any(|(predicate, _)| {
|
||||||
|
@ -2599,7 +2598,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
substs.len(),
|
substs.len(),
|
||||||
"wrong number of generic parameters for {item_def_id:?}: {substs:?}",
|
"wrong number of generic parameters for {item_def_id:?}: {substs:?}",
|
||||||
);
|
);
|
||||||
self.mk_ty(Projection(ProjectionTy { def_id: item_def_id, substs }))
|
self.mk_ty(Projection(AliasTy { def_id: item_def_id, substs }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -2669,7 +2668,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn mk_opaque(self, def_id: DefId, substs: SubstsRef<'tcx>) -> Ty<'tcx> {
|
pub fn mk_opaque(self, def_id: DefId, substs: SubstsRef<'tcx>) -> Ty<'tcx> {
|
||||||
self.mk_ty(Opaque(ty::OpaqueTy { def_id, substs }))
|
self.mk_ty(Opaque(ty::AliasTy { def_id, substs }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mk_place_field(self, place: Place<'tcx>, f: Field, ty: Ty<'tcx>) -> Place<'tcx> {
|
pub fn mk_place_field(self, place: Place<'tcx>, f: Field, ty: Ty<'tcx>) -> Place<'tcx> {
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
use crate::ty::{
|
use crate::ty::{
|
||||||
visit::TypeVisitable, Const, ConstKind, DefIdTree, ExistentialPredicate, InferConst, InferTy,
|
visit::TypeVisitable, AliasTy, Const, ConstKind, DefIdTree, ExistentialPredicate, InferConst,
|
||||||
OpaqueTy, PolyTraitPredicate, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor,
|
InferTy, PolyTraitPredicate, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor,
|
||||||
};
|
};
|
||||||
|
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
|
@ -457,10 +457,10 @@ impl<'tcx> TypeVisitor<'tcx> for IsSuggestableVisitor<'tcx> {
|
||||||
return ControlFlow::Break(());
|
return ControlFlow::Break(());
|
||||||
}
|
}
|
||||||
|
|
||||||
Opaque(OpaqueTy { def_id, substs: _ }) => {
|
Opaque(AliasTy { def_id, substs: _ }) => {
|
||||||
let parent = self.tcx.parent(*def_id);
|
let parent = self.tcx.parent(*def_id);
|
||||||
if let hir::def::DefKind::TyAlias | hir::def::DefKind::AssocTy = self.tcx.def_kind(parent)
|
if let hir::def::DefKind::TyAlias | hir::def::DefKind::AssocTy = self.tcx.def_kind(parent)
|
||||||
&& let Opaque(OpaqueTy { def_id: parent_opaque_def_id, substs: _ }) = self.tcx.type_of(parent).kind()
|
&& let Opaque(AliasTy { def_id: parent_opaque_def_id, substs: _ }) = self.tcx.type_of(parent).kind()
|
||||||
&& parent_opaque_def_id == def_id
|
&& parent_opaque_def_id == def_id
|
||||||
{
|
{
|
||||||
// Okay
|
// Okay
|
||||||
|
|
|
@ -624,7 +624,7 @@ impl<T> Trait<T> for X {
|
||||||
diag: &mut Diagnostic,
|
diag: &mut Diagnostic,
|
||||||
msg: &str,
|
msg: &str,
|
||||||
body_owner_def_id: DefId,
|
body_owner_def_id: DefId,
|
||||||
proj_ty: &ty::ProjectionTy<'tcx>,
|
proj_ty: &ty::AliasTy<'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let assoc = self.associated_item(proj_ty.def_id);
|
let assoc = self.associated_item(proj_ty.def_id);
|
||||||
|
@ -680,7 +680,7 @@ impl<T> Trait<T> for X {
|
||||||
fn expected_projection(
|
fn expected_projection(
|
||||||
self,
|
self,
|
||||||
diag: &mut Diagnostic,
|
diag: &mut Diagnostic,
|
||||||
proj_ty: &ty::ProjectionTy<'tcx>,
|
proj_ty: &ty::AliasTy<'tcx>,
|
||||||
values: ExpectedFound<Ty<'tcx>>,
|
values: ExpectedFound<Ty<'tcx>>,
|
||||||
body_owner_def_id: DefId,
|
body_owner_def_id: DefId,
|
||||||
cause_code: &ObligationCauseCode<'_>,
|
cause_code: &ObligationCauseCode<'_>,
|
||||||
|
@ -775,11 +775,11 @@ fn foo(&self) -> Self::T { String::new() }
|
||||||
self,
|
self,
|
||||||
diag: &mut Diagnostic,
|
diag: &mut Diagnostic,
|
||||||
msg: &str,
|
msg: &str,
|
||||||
proj_ty: &ty::ProjectionTy<'tcx>,
|
proj_ty: &ty::AliasTy<'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let assoc = self.associated_item(proj_ty.def_id);
|
let assoc = self.associated_item(proj_ty.def_id);
|
||||||
if let ty::Opaque(ty::OpaqueTy { def_id, substs: _ }) = *proj_ty.self_ty().kind() {
|
if let ty::Opaque(ty::AliasTy { def_id, substs: _ }) = *proj_ty.self_ty().kind() {
|
||||||
let opaque_local_def_id = def_id.as_local();
|
let opaque_local_def_id = def_id.as_local();
|
||||||
let opaque_hir_ty = if let Some(opaque_local_def_id) = opaque_local_def_id {
|
let opaque_hir_ty = if let Some(opaque_local_def_id) = opaque_local_def_id {
|
||||||
match &self.hir().expect_item(opaque_local_def_id).kind {
|
match &self.hir().expect_item(opaque_local_def_id).kind {
|
||||||
|
@ -828,7 +828,7 @@ fn foo(&self) -> Self::T { String::new() }
|
||||||
.filter_map(|(_, item)| {
|
.filter_map(|(_, item)| {
|
||||||
let method = self.fn_sig(item.def_id);
|
let method = self.fn_sig(item.def_id);
|
||||||
match *method.output().skip_binder().kind() {
|
match *method.output().skip_binder().kind() {
|
||||||
ty::Projection(ty::ProjectionTy { def_id: item_def_id, .. })
|
ty::Projection(ty::AliasTy { def_id: item_def_id, .. })
|
||||||
if item_def_id == proj_ty_item_def_id =>
|
if item_def_id == proj_ty_item_def_id =>
|
||||||
{
|
{
|
||||||
Some((
|
Some((
|
||||||
|
|
|
@ -160,7 +160,7 @@ impl FlagComputation {
|
||||||
self.add_projection_ty(data);
|
self.add_projection_ty(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
&ty::Opaque(ty::OpaqueTy { def_id: _, substs }) => {
|
&ty::Opaque(ty::AliasTy { def_id: _, substs }) => {
|
||||||
self.add_flags(TypeFlags::HAS_TY_OPAQUE);
|
self.add_flags(TypeFlags::HAS_TY_OPAQUE);
|
||||||
self.add_substs(substs);
|
self.add_substs(substs);
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ impl FlagComputation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_projection_ty(&mut self, projection_ty: ty::ProjectionTy<'_>) {
|
fn add_projection_ty(&mut self, projection_ty: ty::AliasTy<'_>) {
|
||||||
self.add_substs(projection_ty.substs);
|
self.add_substs(projection_ty.substs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,14 +93,13 @@ pub use self::parameterized::ParameterizedOverTcx;
|
||||||
pub use self::rvalue_scopes::RvalueScopes;
|
pub use self::rvalue_scopes::RvalueScopes;
|
||||||
pub use self::sty::BoundRegionKind::*;
|
pub use self::sty::BoundRegionKind::*;
|
||||||
pub use self::sty::{
|
pub use self::sty::{
|
||||||
Article, Binder, BoundRegion, BoundRegionKind, BoundTy, BoundTyKind, BoundVar,
|
AliasTy, Article, Binder, BoundRegion, BoundRegionKind, BoundTy, BoundTyKind, BoundVar,
|
||||||
BoundVariableKind, CanonicalPolyFnSig, ClosureSubsts, ClosureSubstsParts, ConstVid,
|
BoundVariableKind, CanonicalPolyFnSig, ClosureSubsts, ClosureSubstsParts, ConstVid,
|
||||||
EarlyBoundRegion, ExistentialPredicate, ExistentialProjection, ExistentialTraitRef, FnSig,
|
EarlyBoundRegion, ExistentialPredicate, ExistentialProjection, ExistentialTraitRef, FnSig,
|
||||||
FreeRegion, GenSig, GeneratorSubsts, GeneratorSubstsParts, InlineConstSubsts,
|
FreeRegion, GenSig, GeneratorSubsts, GeneratorSubstsParts, InlineConstSubsts,
|
||||||
InlineConstSubstsParts, OpaqueTy, ParamConst, ParamTy, PolyExistentialPredicate,
|
InlineConstSubstsParts, ParamConst, ParamTy, PolyExistentialPredicate,
|
||||||
PolyExistentialProjection, PolyExistentialTraitRef, PolyFnSig, PolyGenSig, PolyTraitRef,
|
PolyExistentialProjection, PolyExistentialTraitRef, PolyFnSig, PolyGenSig, PolyTraitRef,
|
||||||
ProjectionTy, Region, RegionKind, RegionVid, TraitRef, TyKind, TypeAndMut, UpvarSubsts,
|
Region, RegionKind, RegionVid, TraitRef, TyKind, TypeAndMut, UpvarSubsts, VarianceDiagInfo,
|
||||||
VarianceDiagInfo,
|
|
||||||
};
|
};
|
||||||
pub use self::trait_def::TraitDef;
|
pub use self::trait_def::TraitDef;
|
||||||
|
|
||||||
|
@ -1010,7 +1009,7 @@ impl<'tcx> TermKind<'tcx> {
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
|
||||||
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
|
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
|
||||||
pub struct ProjectionPredicate<'tcx> {
|
pub struct ProjectionPredicate<'tcx> {
|
||||||
pub projection_ty: ProjectionTy<'tcx>,
|
pub projection_ty: AliasTy<'tcx>,
|
||||||
pub term: Term<'tcx>,
|
pub term: Term<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -728,7 +728,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::Placeholder(placeholder) => p!(write("Placeholder({:?})", placeholder)),
|
ty::Placeholder(placeholder) => p!(write("Placeholder({:?})", placeholder)),
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => {
|
ty::Opaque(ty::AliasTy { def_id, substs }) => {
|
||||||
// FIXME(eddyb) print this with `print_def_path`.
|
// FIXME(eddyb) print this with `print_def_path`.
|
||||||
// We use verbose printing in 'NO_QUERIES' mode, to
|
// We use verbose printing in 'NO_QUERIES' mode, to
|
||||||
// avoid needing to call `predicates_of`. This should
|
// avoid needing to call `predicates_of`. This should
|
||||||
|
@ -743,7 +743,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
let parent = self.tcx().parent(def_id);
|
let parent = self.tcx().parent(def_id);
|
||||||
match self.tcx().def_kind(parent) {
|
match self.tcx().def_kind(parent) {
|
||||||
DefKind::TyAlias | DefKind::AssocTy => {
|
DefKind::TyAlias | DefKind::AssocTy => {
|
||||||
if let ty::Opaque(ty::OpaqueTy { def_id: d, substs: _ }) =
|
if let ty::Opaque(ty::AliasTy { def_id: d, substs: _ }) =
|
||||||
*self.tcx().type_of(parent).kind()
|
*self.tcx().type_of(parent).kind()
|
||||||
{
|
{
|
||||||
if d == def_id {
|
if d == def_id {
|
||||||
|
@ -2742,7 +2742,7 @@ define_print_and_forward_display! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::ProjectionTy<'tcx> {
|
ty::AliasTy<'tcx> {
|
||||||
p!(print_def_path(self.def_id, self.substs));
|
p!(print_def_path(self.def_id, self.substs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -270,17 +270,17 @@ impl<'tcx> Relate<'tcx> for abi::Abi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for ty::ProjectionTy<'tcx> {
|
impl<'tcx> Relate<'tcx> for ty::AliasTy<'tcx> {
|
||||||
fn relate<R: TypeRelation<'tcx>>(
|
fn relate<R: TypeRelation<'tcx>>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: ty::ProjectionTy<'tcx>,
|
a: ty::AliasTy<'tcx>,
|
||||||
b: ty::ProjectionTy<'tcx>,
|
b: ty::AliasTy<'tcx>,
|
||||||
) -> RelateResult<'tcx, ty::ProjectionTy<'tcx>> {
|
) -> RelateResult<'tcx, ty::AliasTy<'tcx>> {
|
||||||
if a.def_id != b.def_id {
|
if a.def_id != b.def_id {
|
||||||
Err(TypeError::ProjectionMismatched(expected_found(relation, a.def_id, b.def_id)))
|
Err(TypeError::ProjectionMismatched(expected_found(relation, a.def_id, b.def_id)))
|
||||||
} else {
|
} else {
|
||||||
let substs = relation.relate(a.substs, b.substs)?;
|
let substs = relation.relate(a.substs, b.substs)?;
|
||||||
Ok(ty::ProjectionTy { def_id: a.def_id, substs: &substs })
|
Ok(ty::AliasTy { def_id: a.def_id, substs: &substs })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -557,8 +557,8 @@ pub fn super_relate_tys<'tcx, R: TypeRelation<'tcx>>(
|
||||||
}
|
}
|
||||||
|
|
||||||
(
|
(
|
||||||
&ty::Opaque(ty::OpaqueTy { def_id: a_def_id, substs: a_substs }),
|
&ty::Opaque(ty::AliasTy { def_id: a_def_id, substs: a_substs }),
|
||||||
&ty::Opaque(ty::OpaqueTy { def_id: b_def_id, substs: b_substs }),
|
&ty::Opaque(ty::AliasTy { def_id: b_def_id, substs: b_substs }),
|
||||||
) if a_def_id == b_def_id => {
|
) if a_def_id == b_def_id => {
|
||||||
if relation.intercrate() {
|
if relation.intercrate() {
|
||||||
// During coherence, opaque types should be treated as equal to each other, even if their generic params
|
// During coherence, opaque types should be treated as equal to each other, even if their generic params
|
||||||
|
|
|
@ -652,8 +652,8 @@ impl<'tcx> TypeSuperFoldable<'tcx> for Ty<'tcx> {
|
||||||
ty::GeneratorWitness(types) => ty::GeneratorWitness(types.try_fold_with(folder)?),
|
ty::GeneratorWitness(types) => ty::GeneratorWitness(types.try_fold_with(folder)?),
|
||||||
ty::Closure(did, substs) => ty::Closure(did, substs.try_fold_with(folder)?),
|
ty::Closure(did, substs) => ty::Closure(did, substs.try_fold_with(folder)?),
|
||||||
ty::Projection(data) => ty::Projection(data.try_fold_with(folder)?),
|
ty::Projection(data) => ty::Projection(data.try_fold_with(folder)?),
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => {
|
ty::Opaque(ty::AliasTy { def_id, substs }) => {
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs: substs.try_fold_with(folder)? })
|
ty::Opaque(ty::AliasTy { def_id, substs: substs.try_fold_with(folder)? })
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::Bool
|
ty::Bool
|
||||||
|
@ -700,7 +700,7 @@ impl<'tcx> TypeSuperVisitable<'tcx> for Ty<'tcx> {
|
||||||
ty::GeneratorWitness(ref types) => types.visit_with(visitor),
|
ty::GeneratorWitness(ref types) => types.visit_with(visitor),
|
||||||
ty::Closure(_did, ref substs) => substs.visit_with(visitor),
|
ty::Closure(_did, ref substs) => substs.visit_with(visitor),
|
||||||
ty::Projection(ref data) => data.visit_with(visitor),
|
ty::Projection(ref data) => data.visit_with(visitor),
|
||||||
ty::Opaque(ty::OpaqueTy { def_id: _, ref substs }) => substs.visit_with(visitor),
|
ty::Opaque(ty::AliasTy { def_id: _, ref substs }) => substs.visit_with(visitor),
|
||||||
|
|
||||||
ty::Bool
|
ty::Bool
|
||||||
| ty::Char
|
| ty::Char
|
||||||
|
|
|
@ -1139,15 +1139,19 @@ impl<'tcx, T: IntoIterator> Binder<'tcx, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents the projection of an associated type. In explicit UFCS
|
/// Represents the projection of an associated type.
|
||||||
/// form this would be written `<T as Trait<..>>::N`.
|
///
|
||||||
|
/// For a projection, this would be `<Ty as Trait<...>>::N`.
|
||||||
|
///
|
||||||
|
/// For an opaque type, there is no explicit syntax.
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)]
|
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)]
|
||||||
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
|
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
|
||||||
pub struct ProjectionTy<'tcx> {
|
pub struct AliasTy<'tcx> {
|
||||||
/// The parameters of the associated item.
|
/// The parameters of the associated or opaque item.
|
||||||
pub substs: SubstsRef<'tcx>,
|
pub substs: SubstsRef<'tcx>,
|
||||||
|
|
||||||
/// The `DefId` of the `TraitItem` for the associated type `N`.
|
/// The `DefId` of the `TraitItem` for the associated type `N` if this is a projection,
|
||||||
|
/// or the `OpaqueType` item if this is an opaque.
|
||||||
///
|
///
|
||||||
/// Note that this is not the `DefId` of the `TraitRef` containing this
|
/// Note that this is not the `DefId` of the `TraitRef` containing this
|
||||||
/// associated type, which is in `tcx.associated_item(item_def_id).container`,
|
/// associated type, which is in `tcx.associated_item(item_def_id).container`,
|
||||||
|
@ -1155,7 +1159,7 @@ pub struct ProjectionTy<'tcx> {
|
||||||
pub def_id: DefId,
|
pub def_id: DefId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> ProjectionTy<'tcx> {
|
impl<'tcx> AliasTy<'tcx> {
|
||||||
pub fn trait_def_id(&self, tcx: TyCtxt<'tcx>) -> DefId {
|
pub fn trait_def_id(&self, tcx: TyCtxt<'tcx>) -> DefId {
|
||||||
match tcx.def_kind(self.def_id) {
|
match tcx.def_kind(self.def_id) {
|
||||||
DefKind::AssocTy | DefKind::AssocConst => tcx.parent(self.def_id),
|
DefKind::AssocTy | DefKind::AssocConst => tcx.parent(self.def_id),
|
||||||
|
@ -1173,11 +1177,14 @@ impl<'tcx> ProjectionTy<'tcx> {
|
||||||
&self,
|
&self,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
) -> (ty::TraitRef<'tcx>, &'tcx [ty::GenericArg<'tcx>]) {
|
) -> (ty::TraitRef<'tcx>, &'tcx [ty::GenericArg<'tcx>]) {
|
||||||
let def_id = tcx.parent(self.def_id);
|
debug_assert!(matches!(tcx.def_kind(self.def_id), DefKind::AssocTy | DefKind::AssocConst));
|
||||||
assert_eq!(tcx.def_kind(def_id), DefKind::Trait);
|
let trait_def_id = self.trait_def_id(tcx);
|
||||||
let trait_generics = tcx.generics_of(def_id);
|
let trait_generics = tcx.generics_of(trait_def_id);
|
||||||
(
|
(
|
||||||
ty::TraitRef { def_id, substs: self.substs.truncate_to(tcx, trait_generics) },
|
ty::TraitRef {
|
||||||
|
def_id: trait_def_id,
|
||||||
|
substs: self.substs.truncate_to(tcx, trait_generics),
|
||||||
|
},
|
||||||
&self.substs[trait_generics.count()..],
|
&self.substs[trait_generics.count()..],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1199,16 +1206,6 @@ impl<'tcx> ProjectionTy<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)]
|
|
||||||
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
|
|
||||||
pub struct OpaqueTy<'tcx> {
|
|
||||||
/// The parameters of the opaque.
|
|
||||||
pub substs: SubstsRef<'tcx>,
|
|
||||||
|
|
||||||
/// The `DefId` of the `impl Trait`.
|
|
||||||
pub def_id: DefId,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable, Lift)]
|
#[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable, Lift)]
|
||||||
pub struct GenSig<'tcx> {
|
pub struct GenSig<'tcx> {
|
||||||
pub resume_ty: Ty<'tcx>,
|
pub resume_ty: Ty<'tcx>,
|
||||||
|
@ -1443,7 +1440,7 @@ impl<'tcx> ExistentialProjection<'tcx> {
|
||||||
debug_assert!(!self_ty.has_escaping_bound_vars());
|
debug_assert!(!self_ty.has_escaping_bound_vars());
|
||||||
|
|
||||||
ty::ProjectionPredicate {
|
ty::ProjectionPredicate {
|
||||||
projection_ty: ty::ProjectionTy {
|
projection_ty: ty::AliasTy {
|
||||||
def_id: self.def_id,
|
def_id: self.def_id,
|
||||||
substs: tcx.mk_substs_trait(self_ty, self.substs),
|
substs: tcx.mk_substs_trait(self_ty, self.substs),
|
||||||
},
|
},
|
||||||
|
|
|
@ -826,7 +826,7 @@ impl<'tcx> TypeFolder<'tcx> for OpaqueTypeExpander<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
if let ty::Opaque(ty::OpaqueTy { def_id, substs }) = *t.kind() {
|
if let ty::Opaque(ty::AliasTy { def_id, substs }) = *t.kind() {
|
||||||
self.expand_opaque_ty(def_id, substs).unwrap_or(t)
|
self.expand_opaque_ty(def_id, substs).unwrap_or(t)
|
||||||
} else if t.has_opaque_types() {
|
} else if t.has_opaque_types() {
|
||||||
t.super_fold_with(self)
|
t.super_fold_with(self)
|
||||||
|
|
|
@ -188,7 +188,7 @@ fn push_inner<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent: GenericArg<'tcx>)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
ty::Adt(_, substs)
|
ty::Adt(_, substs)
|
||||||
| ty::Opaque(ty::OpaqueTy { def_id: _, substs })
|
| ty::Opaque(ty::AliasTy { def_id: _, substs })
|
||||||
| ty::Closure(_, substs)
|
| ty::Closure(_, substs)
|
||||||
| ty::Generator(_, substs, _)
|
| ty::Generator(_, substs, _)
|
||||||
| ty::FnDef(_, substs) => {
|
| ty::FnDef(_, substs) => {
|
||||||
|
|
|
@ -849,7 +849,7 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let kind = match parent_ty.ty.kind() {
|
let kind = match parent_ty.ty.kind() {
|
||||||
&ty::Opaque(ty::OpaqueTy { def_id, substs }) => {
|
&ty::Opaque(ty::AliasTy { def_id, substs }) => {
|
||||||
self.tcx.bound_type_of(def_id).subst(self.tcx, substs).kind()
|
self.tcx.bound_type_of(def_id).subst(self.tcx, substs).kind()
|
||||||
}
|
}
|
||||||
kind => kind,
|
kind => kind,
|
||||||
|
|
|
@ -88,10 +88,7 @@ trait DefIdVisitor<'tcx> {
|
||||||
fn visit_trait(&mut self, trait_ref: TraitRef<'tcx>) -> ControlFlow<Self::BreakTy> {
|
fn visit_trait(&mut self, trait_ref: TraitRef<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||||
self.skeleton().visit_trait(trait_ref)
|
self.skeleton().visit_trait(trait_ref)
|
||||||
}
|
}
|
||||||
fn visit_projection_ty(
|
fn visit_projection_ty(&mut self, projection: ty::AliasTy<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||||
&mut self,
|
|
||||||
projection: ty::ProjectionTy<'tcx>,
|
|
||||||
) -> ControlFlow<Self::BreakTy> {
|
|
||||||
self.skeleton().visit_projection_ty(projection)
|
self.skeleton().visit_projection_ty(projection)
|
||||||
}
|
}
|
||||||
fn visit_predicates(
|
fn visit_predicates(
|
||||||
|
@ -118,10 +115,7 @@ where
|
||||||
if self.def_id_visitor.shallow() { ControlFlow::CONTINUE } else { substs.visit_with(self) }
|
if self.def_id_visitor.shallow() { ControlFlow::CONTINUE } else { substs.visit_with(self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_projection_ty(
|
fn visit_projection_ty(&mut self, projection: ty::AliasTy<'tcx>) -> ControlFlow<V::BreakTy> {
|
||||||
&mut self,
|
|
||||||
projection: ty::ProjectionTy<'tcx>,
|
|
||||||
) -> ControlFlow<V::BreakTy> {
|
|
||||||
let tcx = self.def_id_visitor.tcx();
|
let tcx = self.def_id_visitor.tcx();
|
||||||
let (trait_ref, assoc_substs) = if tcx.def_kind(projection.def_id)
|
let (trait_ref, assoc_substs) = if tcx.def_kind(projection.def_id)
|
||||||
!= DefKind::ImplTraitPlaceholder
|
!= DefKind::ImplTraitPlaceholder
|
||||||
|
@ -241,7 +235,7 @@ where
|
||||||
self.def_id_visitor.visit_def_id(def_id, "trait", &trait_ref)?;
|
self.def_id_visitor.visit_def_id(def_id, "trait", &trait_ref)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs: _ }) => {
|
ty::Opaque(ty::AliasTy { def_id, substs: _ }) => {
|
||||||
// Skip repeated `Opaque`s to avoid infinite recursion.
|
// Skip repeated `Opaque`s to avoid infinite recursion.
|
||||||
if self.visited_opaque_tys.insert(def_id) {
|
if self.visited_opaque_tys.insert(def_id) {
|
||||||
// The intent is to treat `impl Trait1 + Trait2` identically to
|
// The intent is to treat `impl Trait1 + Trait2` identically to
|
||||||
|
|
|
@ -216,8 +216,8 @@ impl<'tcx> Printer<'tcx> for &mut SymbolPrinter<'tcx> {
|
||||||
match *ty.kind() {
|
match *ty.kind() {
|
||||||
// Print all nominal types as paths (unlike `pretty_print_type`).
|
// Print all nominal types as paths (unlike `pretty_print_type`).
|
||||||
ty::FnDef(def_id, substs)
|
ty::FnDef(def_id, substs)
|
||||||
| ty::Opaque(ty::OpaqueTy { def_id, substs })
|
| ty::Opaque(ty::AliasTy { def_id, substs })
|
||||||
| ty::Projection(ty::ProjectionTy { def_id, substs })
|
| ty::Projection(ty::AliasTy { def_id, substs })
|
||||||
| ty::Closure(def_id, substs)
|
| ty::Closure(def_id, substs)
|
||||||
| ty::Generator(def_id, substs, _) => self.print_def_path(def_id, substs),
|
| ty::Generator(def_id, substs, _) => self.print_def_path(def_id, substs),
|
||||||
|
|
||||||
|
|
|
@ -439,8 +439,8 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
|
||||||
// Mangle all nominal types as paths.
|
// Mangle all nominal types as paths.
|
||||||
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), substs)
|
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), substs)
|
||||||
| ty::FnDef(def_id, substs)
|
| ty::FnDef(def_id, substs)
|
||||||
| ty::Opaque(ty::OpaqueTy { def_id, substs })
|
| ty::Opaque(ty::AliasTy { def_id, substs })
|
||||||
| ty::Projection(ty::ProjectionTy { def_id, substs })
|
| ty::Projection(ty::AliasTy { def_id, substs })
|
||||||
| ty::Closure(def_id, substs)
|
| ty::Closure(def_id, substs)
|
||||||
| ty::Generator(def_id, substs, _) => {
|
| ty::Generator(def_id, substs, _) => {
|
||||||
self = self.print_def_path(def_id, substs)?;
|
self = self.print_def_path(def_id, substs)?;
|
||||||
|
|
|
@ -369,7 +369,7 @@ fn suggest_restriction<'tcx>(
|
||||||
msg: &str,
|
msg: &str,
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
fn_sig: Option<&hir::FnSig<'_>>,
|
fn_sig: Option<&hir::FnSig<'_>>,
|
||||||
projection: Option<&ty::ProjectionTy<'_>>,
|
projection: Option<&ty::AliasTy<'_>>,
|
||||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||||
// When we are dealing with a trait, `super_traits` will be `Some`:
|
// When we are dealing with a trait, `super_traits` will be `Some`:
|
||||||
// Given `trait T: A + B + C {}`
|
// Given `trait T: A + B + C {}`
|
||||||
|
@ -855,7 +855,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
fn_sig.inputs().map_bound(|inputs| &inputs[1..]),
|
fn_sig.inputs().map_bound(|inputs| &inputs[1..]),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => {
|
ty::Opaque(ty::AliasTy { def_id, substs }) => {
|
||||||
self.tcx.bound_item_bounds(def_id).subst(self.tcx, substs).iter().find_map(|pred| {
|
self.tcx.bound_item_bounds(def_id).subst(self.tcx, substs).iter().find_map(|pred| {
|
||||||
if let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) = pred.kind().skip_binder()
|
if let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) = pred.kind().skip_binder()
|
||||||
&& Some(proj.projection_ty.def_id) == self.tcx.lang_items().fn_once_output()
|
&& Some(proj.projection_ty.def_id) == self.tcx.lang_items().fn_once_output()
|
||||||
|
@ -2644,7 +2644,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
Some(ident) => err.span_note(ident.span, &msg),
|
Some(ident) => err.span_note(ident.span, &msg),
|
||||||
None => err.note(&msg),
|
None => err.note(&msg),
|
||||||
},
|
},
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs: _ }) => {
|
ty::Opaque(ty::AliasTy { def_id, substs: _ }) => {
|
||||||
// Avoid printing the future from `core::future::identity_future`, it's not helpful
|
// Avoid printing the future from `core::future::identity_future`, it's not helpful
|
||||||
if tcx.parent(*def_id) == identity_future {
|
if tcx.parent(*def_id) == identity_future {
|
||||||
break 'print;
|
break 'print;
|
||||||
|
@ -3248,7 +3248,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
// This corresponds to `<ExprTy as Iterator>::Item = _`.
|
// This corresponds to `<ExprTy as Iterator>::Item = _`.
|
||||||
let trait_ref = ty::Binder::dummy(ty::PredicateKind::Clause(
|
let trait_ref = ty::Binder::dummy(ty::PredicateKind::Clause(
|
||||||
ty::Clause::Projection(ty::ProjectionPredicate {
|
ty::Clause::Projection(ty::ProjectionPredicate {
|
||||||
projection_ty: ty::ProjectionTy { substs, def_id: proj.def_id },
|
projection_ty: ty::AliasTy { substs, def_id: proj.def_id },
|
||||||
term: ty_var.into(),
|
term: ty_var.into(),
|
||||||
}),
|
}),
|
||||||
));
|
));
|
||||||
|
|
|
@ -45,7 +45,7 @@ pub type PolyProjectionObligation<'tcx> = Obligation<'tcx, ty::PolyProjectionPre
|
||||||
|
|
||||||
pub type ProjectionObligation<'tcx> = Obligation<'tcx, ty::ProjectionPredicate<'tcx>>;
|
pub type ProjectionObligation<'tcx> = Obligation<'tcx, ty::ProjectionPredicate<'tcx>>;
|
||||||
|
|
||||||
pub type ProjectionTyObligation<'tcx> = Obligation<'tcx, ty::ProjectionTy<'tcx>>;
|
pub type ProjectionTyObligation<'tcx> = Obligation<'tcx, ty::AliasTy<'tcx>>;
|
||||||
|
|
||||||
pub(super) struct InProgress;
|
pub(super) struct InProgress;
|
||||||
|
|
||||||
|
@ -496,7 +496,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
|
||||||
// This is really important. While we *can* handle this, this has
|
// This is really important. While we *can* handle this, this has
|
||||||
// severe performance implications for large opaque types with
|
// severe performance implications for large opaque types with
|
||||||
// late-bound regions. See `issue-88862` benchmark.
|
// late-bound regions. See `issue-88862` benchmark.
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) if !substs.has_escaping_bound_vars() => {
|
ty::Opaque(ty::AliasTy { def_id, substs }) if !substs.has_escaping_bound_vars() => {
|
||||||
// Only normalize `impl Trait` outside of type inference, usually in codegen.
|
// Only normalize `impl Trait` outside of type inference, usually in codegen.
|
||||||
match self.param_env.reveal() {
|
match self.param_env.reveal() {
|
||||||
Reveal::UserFacing => ty.super_fold_with(self),
|
Reveal::UserFacing => ty.super_fold_with(self),
|
||||||
|
@ -957,7 +957,7 @@ impl<'tcx> TypeFolder<'tcx> for PlaceholderReplacer<'_, 'tcx> {
|
||||||
pub fn normalize_projection_type<'a, 'b, 'tcx>(
|
pub fn normalize_projection_type<'a, 'b, 'tcx>(
|
||||||
selcx: &'a mut SelectionContext<'b, 'tcx>,
|
selcx: &'a mut SelectionContext<'b, 'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
projection_ty: ty::ProjectionTy<'tcx>,
|
projection_ty: ty::AliasTy<'tcx>,
|
||||||
cause: ObligationCause<'tcx>,
|
cause: ObligationCause<'tcx>,
|
||||||
depth: usize,
|
depth: usize,
|
||||||
obligations: &mut Vec<PredicateObligation<'tcx>>,
|
obligations: &mut Vec<PredicateObligation<'tcx>>,
|
||||||
|
@ -995,7 +995,7 @@ pub fn normalize_projection_type<'a, 'b, 'tcx>(
|
||||||
fn opt_normalize_projection_type<'a, 'b, 'tcx>(
|
fn opt_normalize_projection_type<'a, 'b, 'tcx>(
|
||||||
selcx: &'a mut SelectionContext<'b, 'tcx>,
|
selcx: &'a mut SelectionContext<'b, 'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
projection_ty: ty::ProjectionTy<'tcx>,
|
projection_ty: ty::AliasTy<'tcx>,
|
||||||
cause: ObligationCause<'tcx>,
|
cause: ObligationCause<'tcx>,
|
||||||
depth: usize,
|
depth: usize,
|
||||||
obligations: &mut Vec<PredicateObligation<'tcx>>,
|
obligations: &mut Vec<PredicateObligation<'tcx>>,
|
||||||
|
@ -1177,7 +1177,7 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>(
|
||||||
fn normalize_to_error<'a, 'tcx>(
|
fn normalize_to_error<'a, 'tcx>(
|
||||||
selcx: &mut SelectionContext<'a, 'tcx>,
|
selcx: &mut SelectionContext<'a, 'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
projection_ty: ty::ProjectionTy<'tcx>,
|
projection_ty: ty::AliasTy<'tcx>,
|
||||||
cause: ObligationCause<'tcx>,
|
cause: ObligationCause<'tcx>,
|
||||||
depth: usize,
|
depth: usize,
|
||||||
) -> NormalizedTy<'tcx> {
|
) -> NormalizedTy<'tcx> {
|
||||||
|
@ -1376,7 +1376,7 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>(
|
||||||
// If so, extract what we know from the trait and try to come up with a good answer.
|
// If so, extract what we know from the trait and try to come up with a good answer.
|
||||||
let bounds = match *obligation.predicate.self_ty().kind() {
|
let bounds = match *obligation.predicate.self_ty().kind() {
|
||||||
ty::Projection(ref data) => tcx.bound_item_bounds(data.def_id).subst(tcx, data.substs),
|
ty::Projection(ref data) => tcx.bound_item_bounds(data.def_id).subst(tcx, data.substs),
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => {
|
ty::Opaque(ty::AliasTy { def_id, substs }) => {
|
||||||
tcx.bound_item_bounds(def_id).subst(tcx, substs)
|
tcx.bound_item_bounds(def_id).subst(tcx, substs)
|
||||||
}
|
}
|
||||||
ty::Infer(ty::TyVar(_)) => {
|
ty::Infer(ty::TyVar(_)) => {
|
||||||
|
@ -1870,7 +1870,7 @@ fn confirm_generator_candidate<'cx, 'tcx>(
|
||||||
};
|
};
|
||||||
|
|
||||||
ty::ProjectionPredicate {
|
ty::ProjectionPredicate {
|
||||||
projection_ty: ty::ProjectionTy {
|
projection_ty: ty::AliasTy {
|
||||||
substs: trait_ref.substs,
|
substs: trait_ref.substs,
|
||||||
def_id: obligation.predicate.def_id,
|
def_id: obligation.predicate.def_id,
|
||||||
},
|
},
|
||||||
|
@ -1912,7 +1912,7 @@ fn confirm_future_candidate<'cx, 'tcx>(
|
||||||
debug_assert_eq!(tcx.associated_item(obligation.predicate.def_id).name, sym::Output);
|
debug_assert_eq!(tcx.associated_item(obligation.predicate.def_id).name, sym::Output);
|
||||||
|
|
||||||
ty::ProjectionPredicate {
|
ty::ProjectionPredicate {
|
||||||
projection_ty: ty::ProjectionTy {
|
projection_ty: ty::AliasTy {
|
||||||
substs: trait_ref.substs,
|
substs: trait_ref.substs,
|
||||||
def_id: obligation.predicate.def_id,
|
def_id: obligation.predicate.def_id,
|
||||||
},
|
},
|
||||||
|
@ -1969,7 +1969,7 @@ fn confirm_builtin_candidate<'cx, 'tcx>(
|
||||||
};
|
};
|
||||||
|
|
||||||
let predicate = ty::ProjectionPredicate {
|
let predicate = ty::ProjectionPredicate {
|
||||||
projection_ty: ty::ProjectionTy { substs, def_id: item_def_id },
|
projection_ty: ty::AliasTy { substs, def_id: item_def_id },
|
||||||
term,
|
term,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2040,7 +2040,7 @@ fn confirm_callable_candidate<'cx, 'tcx>(
|
||||||
flag,
|
flag,
|
||||||
)
|
)
|
||||||
.map_bound(|(trait_ref, ret_type)| ty::ProjectionPredicate {
|
.map_bound(|(trait_ref, ret_type)| ty::ProjectionPredicate {
|
||||||
projection_ty: ty::ProjectionTy { substs: trait_ref.substs, def_id: fn_once_output_def_id },
|
projection_ty: ty::AliasTy { substs: trait_ref.substs, def_id: fn_once_output_def_id },
|
||||||
term: ret_type.into(),
|
term: ret_type.into(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
|
||||||
// This is really important. While we *can* handle this, this has
|
// This is really important. While we *can* handle this, this has
|
||||||
// severe performance implications for large opaque types with
|
// severe performance implications for large opaque types with
|
||||||
// late-bound regions. See `issue-88862` benchmark.
|
// late-bound regions. See `issue-88862` benchmark.
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) if !substs.has_escaping_bound_vars() => {
|
ty::Opaque(ty::AliasTy { def_id, substs }) if !substs.has_escaping_bound_vars() => {
|
||||||
// Only normalize `impl Trait` outside of type inference, usually in codegen.
|
// Only normalize `impl Trait` outside of type inference, usually in codegen.
|
||||||
match self.param_env.reveal() {
|
match self.param_env.reveal() {
|
||||||
Reveal::UserFacing => ty.try_super_fold_with(self),
|
Reveal::UserFacing => ty.try_super_fold_with(self),
|
||||||
|
|
|
@ -536,10 +536,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
let ty = traits::normalize_projection_type(
|
let ty = traits::normalize_projection_type(
|
||||||
self,
|
self,
|
||||||
param_env,
|
param_env,
|
||||||
ty::ProjectionTy {
|
ty::AliasTy { def_id: tcx.lang_items().deref_target()?, substs: trait_ref.substs },
|
||||||
def_id: tcx.lang_items().deref_target()?,
|
|
||||||
substs: trait_ref.substs,
|
|
||||||
},
|
|
||||||
cause.clone(),
|
cause.clone(),
|
||||||
0,
|
0,
|
||||||
// We're *intentionally* throwing these away,
|
// We're *intentionally* throwing these away,
|
||||||
|
@ -830,7 +827,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
| ty::GeneratorWitness(_)
|
| ty::GeneratorWitness(_)
|
||||||
| ty::Never
|
| ty::Never
|
||||||
| ty::Projection(_)
|
| ty::Projection(_)
|
||||||
| ty::Opaque(ty::OpaqueTy { def_id: _, substs: _ })
|
| ty::Opaque(ty::AliasTy { def_id: _, substs: _ })
|
||||||
| ty::Param(_)
|
| ty::Param(_)
|
||||||
| ty::Bound(_, _)
|
| ty::Bound(_, _)
|
||||||
| ty::Error(_)
|
| ty::Error(_)
|
||||||
|
|
|
@ -156,7 +156,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
let placeholder_trait_predicate = ty::Binder::dummy(placeholder_trait_predicate);
|
let placeholder_trait_predicate = ty::Binder::dummy(placeholder_trait_predicate);
|
||||||
let (def_id, substs) = match *placeholder_self_ty.kind() {
|
let (def_id, substs) = match *placeholder_self_ty.kind() {
|
||||||
ty::Projection(proj) => (proj.def_id, proj.substs),
|
ty::Projection(proj) => (proj.def_id, proj.substs),
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => (def_id, substs),
|
ty::Opaque(ty::AliasTy { def_id, substs }) => (def_id, substs),
|
||||||
_ => bug!("projection candidate for unexpected type: {:?}", placeholder_self_ty),
|
_ => bug!("projection candidate for unexpected type: {:?}", placeholder_self_ty),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1596,7 +1596,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
let tcx = self.infcx.tcx;
|
let tcx = self.infcx.tcx;
|
||||||
let (def_id, substs) = match *placeholder_trait_predicate.trait_ref.self_ty().kind() {
|
let (def_id, substs) = match *placeholder_trait_predicate.trait_ref.self_ty().kind() {
|
||||||
ty::Projection(ref data) => (data.def_id, data.substs),
|
ty::Projection(ref data) => (data.def_id, data.substs),
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => (def_id, substs),
|
ty::Opaque(ty::AliasTy { def_id, substs }) => (def_id, substs),
|
||||||
_ => {
|
_ => {
|
||||||
span_bug!(
|
span_bug!(
|
||||||
obligation.cause.span,
|
obligation.cause.span,
|
||||||
|
@ -2260,7 +2260,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
t.rebind(def.all_fields().map(|f| f.ty(self.tcx(), substs)).collect())
|
t.rebind(def.all_fields().map(|f| f.ty(self.tcx(), substs)).collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => {
|
ty::Opaque(ty::AliasTy { def_id, substs }) => {
|
||||||
// We can resolve the `impl Trait` to its concrete type,
|
// We can resolve the `impl Trait` to its concrete type,
|
||||||
// which enforces a DAG between the functions requiring
|
// which enforces a DAG between the functions requiring
|
||||||
// the auto trait bounds in question.
|
// the auto trait bounds in question.
|
||||||
|
|
|
@ -249,7 +249,7 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>(
|
||||||
// An associated item obligation born out of the `trait` failed to be met. An example
|
// An associated item obligation born out of the `trait` failed to be met. An example
|
||||||
// can be seen in `ui/associated-types/point-at-type-on-obligation-failure-2.rs`.
|
// can be seen in `ui/associated-types/point-at-type-on-obligation-failure-2.rs`.
|
||||||
debug!("extended_cause_with_original_assoc_item_obligation trait proj {:?}", pred);
|
debug!("extended_cause_with_original_assoc_item_obligation trait proj {:?}", pred);
|
||||||
if let ty::Projection(ty::ProjectionTy { def_id, .. }) = *pred.self_ty().kind()
|
if let ty::Projection(ty::AliasTy { def_id, .. }) = *pred.self_ty().kind()
|
||||||
&& let Some(&impl_item_id) =
|
&& let Some(&impl_item_id) =
|
||||||
tcx.impl_item_implementor_ids(impl_def_id).get(&def_id)
|
tcx.impl_item_implementor_ids(impl_def_id).get(&def_id)
|
||||||
&& let Some(impl_item_span) = items
|
&& let Some(impl_item_span) = items
|
||||||
|
@ -369,7 +369,7 @@ impl<'tcx> WfPredicates<'tcx> {
|
||||||
|
|
||||||
/// Pushes the obligations required for `trait_ref::Item` to be WF
|
/// Pushes the obligations required for `trait_ref::Item` to be WF
|
||||||
/// into `self.out`.
|
/// into `self.out`.
|
||||||
fn compute_projection(&mut self, data: ty::ProjectionTy<'tcx>) {
|
fn compute_projection(&mut self, data: ty::AliasTy<'tcx>) {
|
||||||
// A projection is well-formed if
|
// A projection is well-formed if
|
||||||
//
|
//
|
||||||
// (a) its predicates hold (*)
|
// (a) its predicates hold (*)
|
||||||
|
@ -648,7 +648,7 @@ impl<'tcx> WfPredicates<'tcx> {
|
||||||
// types appearing in the fn signature
|
// types appearing in the fn signature
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => {
|
ty::Opaque(ty::AliasTy { def_id, substs }) => {
|
||||||
// All of the requirements on type parameters
|
// All of the requirements on type parameters
|
||||||
// have already been checked for `impl Trait` in
|
// have already been checked for `impl Trait` in
|
||||||
// return position. We do need to check type-alias-impl-trait though.
|
// return position. We do need to check type-alias-impl-trait though.
|
||||||
|
|
|
@ -432,7 +432,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
||||||
(ast::Mutability::Not, chalk_ir::Mutability::Not) => true,
|
(ast::Mutability::Not, chalk_ir::Mutability::Not) => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(&ty::Opaque(ty::OpaqueTy { def_id, substs: _ }), OpaqueType(opaque_ty_id, ..)) => {
|
(&ty::Opaque(ty::AliasTy { def_id, substs: _ }), OpaqueType(opaque_ty_id, ..)) => {
|
||||||
def_id == opaque_ty_id.0
|
def_id == opaque_ty_id.0
|
||||||
}
|
}
|
||||||
(&ty::FnDef(def_id, ..), FnDef(fn_def_id, ..)) => def_id == fn_def_id.0,
|
(&ty::FnDef(def_id, ..), FnDef(fn_def_id, ..)) => def_id == fn_def_id.0,
|
||||||
|
@ -788,7 +788,7 @@ impl<'tcx> ty::TypeFolder<'tcx> for ReplaceOpaqueTyFolder<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
if let ty::Opaque(ty::OpaqueTy { def_id, substs }) = *ty.kind() {
|
if let ty::Opaque(ty::AliasTy { def_id, substs }) = *ty.kind() {
|
||||||
if def_id == self.opaque_ty_id.0 && substs == self.identity_substs {
|
if def_id == self.opaque_ty_id.0 && substs == self.identity_substs {
|
||||||
return self.tcx.mk_ty(ty::Bound(
|
return self.tcx.mk_ty(ty::Bound(
|
||||||
self.binder_index,
|
self.binder_index,
|
||||||
|
|
|
@ -66,7 +66,7 @@ impl<'tcx> LowerInto<'tcx, SubstsRef<'tcx>> for &chalk_ir::Substitution<RustInte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> LowerInto<'tcx, chalk_ir::AliasTy<RustInterner<'tcx>>> for ty::ProjectionTy<'tcx> {
|
impl<'tcx> LowerInto<'tcx, chalk_ir::AliasTy<RustInterner<'tcx>>> for ty::AliasTy<'tcx> {
|
||||||
fn lower_into(self, interner: RustInterner<'tcx>) -> chalk_ir::AliasTy<RustInterner<'tcx>> {
|
fn lower_into(self, interner: RustInterner<'tcx>) -> chalk_ir::AliasTy<RustInterner<'tcx>> {
|
||||||
chalk_ir::AliasTy::Projection(chalk_ir::ProjectionTy {
|
chalk_ir::AliasTy::Projection(chalk_ir::ProjectionTy {
|
||||||
associated_ty_id: chalk_ir::AssocTypeId(self.def_id),
|
associated_ty_id: chalk_ir::AssocTypeId(self.def_id),
|
||||||
|
@ -354,7 +354,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
|
||||||
chalk_ir::TyKind::Tuple(types.len(), types.as_substs().lower_into(interner))
|
chalk_ir::TyKind::Tuple(types.len(), types.as_substs().lower_into(interner))
|
||||||
}
|
}
|
||||||
ty::Projection(proj) => chalk_ir::TyKind::Alias(proj.lower_into(interner)),
|
ty::Projection(proj) => chalk_ir::TyKind::Alias(proj.lower_into(interner)),
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => {
|
ty::Opaque(ty::AliasTy { def_id, substs }) => {
|
||||||
chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(chalk_ir::OpaqueTy {
|
chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(chalk_ir::OpaqueTy {
|
||||||
opaque_ty_id: chalk_ir::OpaqueTyId(def_id),
|
opaque_ty_id: chalk_ir::OpaqueTyId(def_id),
|
||||||
substitution: substs.lower_into(interner),
|
substitution: substs.lower_into(interner),
|
||||||
|
@ -442,11 +442,11 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
|
||||||
mutbl.lower_into(interner),
|
mutbl.lower_into(interner),
|
||||||
),
|
),
|
||||||
TyKind::Str => ty::Str,
|
TyKind::Str => ty::Str,
|
||||||
TyKind::OpaqueType(opaque_ty, substitution) => ty::Opaque(ty::OpaqueTy {
|
TyKind::OpaqueType(opaque_ty, substitution) => ty::Opaque(ty::AliasTy {
|
||||||
def_id: opaque_ty.0,
|
def_id: opaque_ty.0,
|
||||||
substs: substitution.lower_into(interner),
|
substs: substitution.lower_into(interner),
|
||||||
}),
|
}),
|
||||||
TyKind::AssociatedType(assoc_ty, substitution) => ty::Projection(ty::ProjectionTy {
|
TyKind::AssociatedType(assoc_ty, substitution) => ty::Projection(ty::AliasTy {
|
||||||
substs: substitution.lower_into(interner),
|
substs: substitution.lower_into(interner),
|
||||||
def_id: assoc_ty.0,
|
def_id: assoc_ty.0,
|
||||||
}),
|
}),
|
||||||
|
@ -457,11 +457,11 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
|
||||||
name: ty::BoundVar::from_usize(placeholder.idx),
|
name: ty::BoundVar::from_usize(placeholder.idx),
|
||||||
}),
|
}),
|
||||||
TyKind::Alias(alias_ty) => match alias_ty {
|
TyKind::Alias(alias_ty) => match alias_ty {
|
||||||
chalk_ir::AliasTy::Projection(projection) => ty::Projection(ty::ProjectionTy {
|
chalk_ir::AliasTy::Projection(projection) => ty::Projection(ty::AliasTy {
|
||||||
def_id: projection.associated_ty_id.0,
|
def_id: projection.associated_ty_id.0,
|
||||||
substs: projection.substitution.lower_into(interner),
|
substs: projection.substitution.lower_into(interner),
|
||||||
}),
|
}),
|
||||||
chalk_ir::AliasTy::Opaque(opaque) => ty::Opaque(ty::OpaqueTy {
|
chalk_ir::AliasTy::Opaque(opaque) => ty::Opaque(ty::AliasTy {
|
||||||
def_id: opaque.opaque_ty_id.0,
|
def_id: opaque.opaque_ty_id.0,
|
||||||
substs: opaque.substitution.lower_into(interner),
|
substs: opaque.substitution.lower_into(interner),
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -414,7 +414,7 @@ fn clean_projection_predicate<'tcx>(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clean_projection<'tcx>(
|
fn clean_projection<'tcx>(
|
||||||
ty: ty::Binder<'tcx, ty::ProjectionTy<'tcx>>,
|
ty: ty::Binder<'tcx, ty::AliasTy<'tcx>>,
|
||||||
cx: &mut DocContext<'tcx>,
|
cx: &mut DocContext<'tcx>,
|
||||||
def_id: Option<DefId>,
|
def_id: Option<DefId>,
|
||||||
) -> Type {
|
) -> Type {
|
||||||
|
@ -453,7 +453,7 @@ fn compute_should_show_cast(self_def_id: Option<DefId>, trait_: &Path, self_type
|
||||||
}
|
}
|
||||||
|
|
||||||
fn projection_to_path_segment<'tcx>(
|
fn projection_to_path_segment<'tcx>(
|
||||||
ty: ty::Binder<'tcx, ty::ProjectionTy<'tcx>>,
|
ty: ty::Binder<'tcx, ty::AliasTy<'tcx>>,
|
||||||
cx: &mut DocContext<'tcx>,
|
cx: &mut DocContext<'tcx>,
|
||||||
) -> PathSegment {
|
) -> PathSegment {
|
||||||
let item = cx.tcx.associated_item(ty.skip_binder().def_id);
|
let item = cx.tcx.associated_item(ty.skip_binder().def_id);
|
||||||
|
@ -1833,7 +1833,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs }) => {
|
ty::Opaque(ty::AliasTy { def_id, substs }) => {
|
||||||
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
|
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
|
||||||
// by looking up the bounds associated with the def_id.
|
// by looking up the bounds associated with the def_id.
|
||||||
let bounds = cx
|
let bounds = cx
|
||||||
|
|
|
@ -4,7 +4,7 @@ use rustc_hir::intravisit::FnKind;
|
||||||
use rustc_hir::{Body, FnDecl, HirId};
|
use rustc_hir::{Body, FnDecl, HirId};
|
||||||
use rustc_infer::infer::TyCtxtInferExt;
|
use rustc_infer::infer::TyCtxtInferExt;
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_middle::ty::{Clause, EarlyBinder, Opaque, OpaqueTy, PredicateKind};
|
use rustc_middle::ty::{AliasTy, Clause, EarlyBinder, Opaque, PredicateKind};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::{sym, Span};
|
use rustc_span::{sym, Span};
|
||||||
use rustc_trait_selection::traits::error_reporting::suggestions::TypeErrCtxtExt;
|
use rustc_trait_selection::traits::error_reporting::suggestions::TypeErrCtxtExt;
|
||||||
|
@ -62,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let ret_ty = return_ty(cx, hir_id);
|
let ret_ty = return_ty(cx, hir_id);
|
||||||
if let Opaque(OpaqueTy { def_id, substs }) = *ret_ty.kind() {
|
if let Opaque(AliasTy { def_id, substs }) = *ret_ty.kind() {
|
||||||
let preds = cx.tcx.explicit_item_bounds(def_id);
|
let preds = cx.tcx.explicit_item_bounds(def_id);
|
||||||
let mut is_future = false;
|
let mut is_future = false;
|
||||||
for &(p, _span) in preds {
|
for &(p, _span) in preds {
|
||||||
|
|
|
@ -17,7 +17,7 @@ use rustc_lint::LateContext;
|
||||||
use rustc_middle::mir::interpret::{ConstValue, Scalar};
|
use rustc_middle::mir::interpret::{ConstValue, Scalar};
|
||||||
use rustc_middle::ty::{
|
use rustc_middle::ty::{
|
||||||
self, AdtDef, AssocKind, Binder, BoundRegion, DefIdTree, FnSig, IntTy, List, ParamEnv, Predicate, PredicateKind,
|
self, AdtDef, AssocKind, Binder, BoundRegion, DefIdTree, FnSig, IntTy, List, ParamEnv, Predicate, PredicateKind,
|
||||||
ProjectionTy, Region, RegionKind, SubstsRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor, UintTy,
|
AliasTy, Region, RegionKind, SubstsRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor, UintTy,
|
||||||
VariantDef, VariantDiscr,
|
VariantDef, VariantDiscr,
|
||||||
};
|
};
|
||||||
use rustc_middle::ty::{GenericArg, GenericArgKind};
|
use rustc_middle::ty::{GenericArg, GenericArgKind};
|
||||||
|
@ -79,7 +79,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let ty::Opaque(ty::OpaqueTy { def_id, substs: _ }) = *inner_ty.kind() {
|
if let ty::Opaque(ty::AliasTy { def_id, substs: _ }) = *inner_ty.kind() {
|
||||||
for &(predicate, _span) in cx.tcx.explicit_item_bounds(def_id) {
|
for &(predicate, _span) in cx.tcx.explicit_item_bounds(def_id) {
|
||||||
match predicate.kind().skip_binder() {
|
match predicate.kind().skip_binder() {
|
||||||
// For `impl Trait<U>`, it will register a predicate of `T: Trait<U>`, so we go through
|
// For `impl Trait<U>`, it will register a predicate of `T: Trait<U>`, so we go through
|
||||||
|
@ -250,7 +250,7 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||||
is_must_use_ty(cx, *ty)
|
is_must_use_ty(cx, *ty)
|
||||||
},
|
},
|
||||||
ty::Tuple(substs) => substs.iter().any(|ty| is_must_use_ty(cx, ty)),
|
ty::Tuple(substs) => substs.iter().any(|ty| is_must_use_ty(cx, ty)),
|
||||||
ty::Opaque(ty::OpaqueTy { def_id, substs: _ }) => {
|
ty::Opaque(ty::AliasTy { def_id, substs: _ }) => {
|
||||||
for (predicate, _) in cx.tcx.explicit_item_bounds(*def_id) {
|
for (predicate, _) in cx.tcx.explicit_item_bounds(*def_id) {
|
||||||
if let ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) = predicate.kind().skip_binder() {
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) = predicate.kind().skip_binder() {
|
||||||
if cx.tcx.has_attr(trait_predicate.trait_ref.def_id, sym::must_use) {
|
if cx.tcx.has_attr(trait_predicate.trait_ref.def_id, sym::must_use) {
|
||||||
|
@ -631,7 +631,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<ExprFnSig<'t
|
||||||
Some(ExprFnSig::Closure(decl, subs.as_closure().sig()))
|
Some(ExprFnSig::Closure(decl, subs.as_closure().sig()))
|
||||||
},
|
},
|
||||||
ty::FnDef(id, subs) => Some(ExprFnSig::Sig(cx.tcx.bound_fn_sig(id).subst(cx.tcx, subs), Some(id))),
|
ty::FnDef(id, subs) => Some(ExprFnSig::Sig(cx.tcx.bound_fn_sig(id).subst(cx.tcx, subs), Some(id))),
|
||||||
ty::Opaque(ty::OpaqueTy{ def_id, substs: _ }) => sig_from_bounds(cx, ty, cx.tcx.item_bounds(def_id), cx.tcx.opt_parent(def_id)),
|
ty::Opaque(ty::AliasTy { def_id, substs: _ }) => sig_from_bounds(cx, ty, cx.tcx.item_bounds(def_id), cx.tcx.opt_parent(def_id)),
|
||||||
ty::FnPtr(sig) => Some(ExprFnSig::Sig(sig, None)),
|
ty::FnPtr(sig) => Some(ExprFnSig::Sig(sig, None)),
|
||||||
ty::Dynamic(bounds, _, _) => {
|
ty::Dynamic(bounds, _, _) => {
|
||||||
let lang_items = cx.tcx.lang_items();
|
let lang_items = cx.tcx.lang_items();
|
||||||
|
@ -701,7 +701,7 @@ fn sig_from_bounds<'tcx>(
|
||||||
inputs.map(|ty| ExprFnSig::Trait(ty, output, predicates_id))
|
inputs.map(|ty| ExprFnSig::Trait(ty, output, predicates_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sig_for_projection<'tcx>(cx: &LateContext<'tcx>, ty: ProjectionTy<'tcx>) -> Option<ExprFnSig<'tcx>> {
|
fn sig_for_projection<'tcx>(cx: &LateContext<'tcx>, ty: AliasTy<'tcx>) -> Option<ExprFnSig<'tcx>> {
|
||||||
let mut inputs = None;
|
let mut inputs = None;
|
||||||
let mut output = None;
|
let mut output = None;
|
||||||
let lang_items = cx.tcx.lang_items();
|
let lang_items = cx.tcx.lang_items();
|
||||||
|
@ -980,13 +980,13 @@ pub fn make_projection<'tcx>(
|
||||||
container_id: DefId,
|
container_id: DefId,
|
||||||
assoc_ty: Symbol,
|
assoc_ty: Symbol,
|
||||||
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
|
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
|
||||||
) -> Option<ProjectionTy<'tcx>> {
|
) -> Option<AliasTy<'tcx>> {
|
||||||
fn helper<'tcx>(
|
fn helper<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
container_id: DefId,
|
container_id: DefId,
|
||||||
assoc_ty: Symbol,
|
assoc_ty: Symbol,
|
||||||
substs: SubstsRef<'tcx>,
|
substs: SubstsRef<'tcx>,
|
||||||
) -> Option<ProjectionTy<'tcx>> {
|
) -> Option<AliasTy<'tcx>> {
|
||||||
let Some(assoc_item) = tcx
|
let Some(assoc_item) = tcx
|
||||||
.associated_items(container_id)
|
.associated_items(container_id)
|
||||||
.find_by_name_and_kind(tcx, Ident::with_dummy_span(assoc_ty), AssocKind::Type, container_id)
|
.find_by_name_and_kind(tcx, Ident::with_dummy_span(assoc_ty), AssocKind::Type, container_id)
|
||||||
|
@ -1039,7 +1039,7 @@ pub fn make_projection<'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(ProjectionTy {
|
Some(AliasTy {
|
||||||
substs,
|
substs,
|
||||||
def_id: assoc_item.def_id,
|
def_id: assoc_item.def_id,
|
||||||
})
|
})
|
||||||
|
@ -1065,7 +1065,7 @@ pub fn make_normalized_projection<'tcx>(
|
||||||
assoc_ty: Symbol,
|
assoc_ty: Symbol,
|
||||||
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
|
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
|
||||||
) -> Option<Ty<'tcx>> {
|
) -> Option<Ty<'tcx>> {
|
||||||
fn helper<'tcx>(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: ProjectionTy<'tcx>) -> Option<Ty<'tcx>> {
|
fn helper<'tcx>(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: AliasTy<'tcx>) -> Option<Ty<'tcx>> {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
if let Some((i, subst)) = ty
|
if let Some((i, subst)) = ty
|
||||||
.substs
|
.substs
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue