ImplTraitPlaceholder -> is_impl_trait_in_trait
This commit is contained in:
parent
39d19ca9f2
commit
e41491fe05
10 changed files with 41 additions and 34 deletions
|
@ -359,10 +359,12 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
pub fn get_impl_future_output_ty(&self, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
|
||||
let (def_id, substs) = match *ty.kind() {
|
||||
ty::Alias(_, ty::AliasTy { def_id, substs, .. })
|
||||
if matches!(
|
||||
self.tcx.def_kind(def_id),
|
||||
DefKind::OpaqueTy | DefKind::ImplTraitPlaceholder
|
||||
) =>
|
||||
if matches!(self.tcx.def_kind(def_id), DefKind::OpaqueTy) =>
|
||||
{
|
||||
(def_id, substs)
|
||||
}
|
||||
ty::Alias(_, ty::AliasTy { def_id, substs, .. })
|
||||
if self.tcx.is_impl_trait_in_trait(def_id) =>
|
||||
{
|
||||
(def_id, substs)
|
||||
}
|
||||
|
@ -1754,8 +1756,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
)
|
||||
}
|
||||
(true, ty::Alias(ty::Projection, proj))
|
||||
if self.tcx.def_kind(proj.def_id)
|
||||
== DefKind::ImplTraitPlaceholder =>
|
||||
if self.tcx.is_impl_trait_in_trait(proj.def_id) =>
|
||||
{
|
||||
let sm = self.tcx.sess.source_map();
|
||||
let pos = sm.lookup_char_pos(self.tcx.def_span(proj.def_id).lo());
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::TypeErrCtxt;
|
||||
use rustc_errors::Applicability::{MachineApplicable, MaybeIncorrect};
|
||||
use rustc_errors::{pluralize, Diagnostic, MultiSpan};
|
||||
use rustc_hir::{self as hir, def::DefKind};
|
||||
use rustc_hir as hir;
|
||||
use rustc_middle::traits::ObligationCauseCode;
|
||||
use rustc_middle::ty::error::ExpectedFound;
|
||||
use rustc_middle::ty::print::Printer;
|
||||
|
@ -75,7 +75,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
diag.note("an associated type was expected, but a different one was found");
|
||||
}
|
||||
(ty::Param(p), ty::Alias(ty::Projection, proj)) | (ty::Alias(ty::Projection, proj), ty::Param(p))
|
||||
if tcx.def_kind(proj.def_id) != DefKind::ImplTraitPlaceholder =>
|
||||
if !tcx.is_impl_trait_in_trait(proj.def_id) =>
|
||||
{
|
||||
let p_def_id = tcx
|
||||
.generics_of(body_owner_def_id)
|
||||
|
@ -222,7 +222,7 @@ impl<T> Trait<T> for X {
|
|||
diag.span_label(p_span, "this type parameter");
|
||||
}
|
||||
}
|
||||
(ty::Alias(ty::Projection, proj_ty), _) if tcx.def_kind(proj_ty.def_id) != DefKind::ImplTraitPlaceholder => {
|
||||
(ty::Alias(ty::Projection, proj_ty), _) if !tcx.is_impl_trait_in_trait(proj_ty.def_id) => {
|
||||
self.expected_projection(
|
||||
diag,
|
||||
proj_ty,
|
||||
|
@ -231,7 +231,7 @@ impl<T> Trait<T> for X {
|
|||
cause.code(),
|
||||
);
|
||||
}
|
||||
(_, ty::Alias(ty::Projection, proj_ty)) if tcx.def_kind(proj_ty.def_id) != DefKind::ImplTraitPlaceholder => {
|
||||
(_, ty::Alias(ty::Projection, proj_ty)) if !tcx.is_impl_trait_in_trait(proj_ty.def_id) => {
|
||||
let msg = format!(
|
||||
"consider constraining the associated type `{}` to `{}`",
|
||||
values.found, values.expected,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::errors::OpaqueHiddenTypeDiag;
|
||||
use crate::infer::{DefiningAnchor, InferCtxt, InferOk};
|
||||
use crate::traits;
|
||||
use hir::def::DefKind;
|
||||
use hir::def_id::{DefId, LocalDefId};
|
||||
use hir::OpaqueTyOrigin;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
|
@ -481,9 +480,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
ty::Alias(ty::Projection, proj)
|
||||
if self.tcx.def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder =>
|
||||
{
|
||||
ty::Alias(ty::Projection, proj) if self.tcx.is_impl_trait_in_trait(proj.def_id) => {
|
||||
// Skip lifetime parameters that are not captures.
|
||||
let variances = self.tcx.variances_of(proj.def_id);
|
||||
|
||||
|
@ -563,8 +560,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
// FIXME(RPITIT): Don't replace RPITITs with inference vars.
|
||||
ty::Alias(ty::Projection, projection_ty)
|
||||
if !projection_ty.has_escaping_bound_vars()
|
||||
&& tcx.def_kind(projection_ty.def_id)
|
||||
!= DefKind::ImplTraitPlaceholder =>
|
||||
&& !tcx.is_impl_trait_in_trait(projection_ty.def_id) =>
|
||||
{
|
||||
self.infer_projection(
|
||||
param_env,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue