Remove ToPolyTraitRef impl for TraitRef
This commit is contained in:
parent
be76bdf905
commit
c065f57111
9 changed files with 33 additions and 45 deletions
|
@ -21,7 +21,7 @@ use rustc_infer::infer::{self, InferOk};
|
|||
use rustc_middle::ty::subst::Subst;
|
||||
use rustc_middle::ty::subst::{InternalSubsts, SubstsRef};
|
||||
use rustc_middle::ty::GenericParamDefKind;
|
||||
use rustc_middle::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TypeFoldable, WithConstness};
|
||||
use rustc_middle::ty::{self, ToPredicate, Ty, TypeFoldable, WithConstness};
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::Span;
|
||||
use rustc_trait_selection::traits;
|
||||
|
@ -330,7 +330,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let trait_ref = ty::TraitRef::new(trait_def_id, substs);
|
||||
|
||||
// Construct an obligation
|
||||
let poly_trait_ref = trait_ref.to_poly_trait_ref();
|
||||
let poly_trait_ref = ty::Binder::dummy(trait_ref);
|
||||
let obligation = traits::Obligation::misc(
|
||||
span,
|
||||
self.body_id,
|
||||
|
|
|
@ -21,9 +21,7 @@ use rustc_infer::infer::{self, InferOk, TyCtxtInferExt};
|
|||
use rustc_middle::middle::stability;
|
||||
use rustc_middle::ty::subst::{InternalSubsts, Subst, SubstsRef};
|
||||
use rustc_middle::ty::GenericParamDefKind;
|
||||
use rustc_middle::ty::{
|
||||
self, ParamEnvAnd, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness,
|
||||
};
|
||||
use rustc_middle::ty::{self, ParamEnvAnd, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness};
|
||||
use rustc_session::lint;
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
use rustc_span::lev_distance::{find_best_match_for_name, lev_distance};
|
||||
|
@ -967,7 +965,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
|||
|
||||
if self.tcx.is_trait_alias(trait_def_id) {
|
||||
// For trait aliases, assume all super-traits are relevant.
|
||||
let bounds = iter::once(trait_ref.to_poly_trait_ref());
|
||||
let bounds = iter::once(ty::Binder::dummy(trait_ref));
|
||||
self.elaborate_bounds(bounds, |this, new_trait_ref, item| {
|
||||
let new_trait_ref = this.erase_late_bound_regions(new_trait_ref);
|
||||
|
||||
|
@ -1372,7 +1370,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
|||
trait_ref: ty::TraitRef<'tcx>,
|
||||
) -> traits::SelectionResult<'tcx, traits::Selection<'tcx>> {
|
||||
let cause = traits::ObligationCause::misc(self.span, self.body_id);
|
||||
let predicate = trait_ref.to_poly_trait_ref().to_poly_trait_predicate();
|
||||
let predicate = ty::Binder::dummy(trait_ref).to_poly_trait_predicate();
|
||||
let obligation = traits::Obligation::new(cause, self.param_env, predicate);
|
||||
traits::SelectionContext::new(self).select(&obligation)
|
||||
}
|
||||
|
|
|
@ -12,9 +12,7 @@ use rustc_hir::{ExprKind, Node, QPath};
|
|||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||
use rustc_middle::ty::fast_reject::simplify_type;
|
||||
use rustc_middle::ty::print::with_crate_prefix;
|
||||
use rustc_middle::ty::{
|
||||
self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness,
|
||||
};
|
||||
use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness};
|
||||
use rustc_span::lev_distance;
|
||||
use rustc_span::symbol::{kw, sym, Ident};
|
||||
use rustc_span::{source_map, FileName, Span};
|
||||
|
@ -53,7 +51,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
.into()],
|
||||
);
|
||||
let trait_ref = ty::TraitRef::new(fn_once, fn_once_substs);
|
||||
let poly_trait_ref = trait_ref.to_poly_trait_ref();
|
||||
let poly_trait_ref = ty::Binder::dummy(trait_ref);
|
||||
let obligation = Obligation::misc(
|
||||
span,
|
||||
self.body_id,
|
||||
|
|
|
@ -40,7 +40,7 @@ use rustc_middle::ty::query::Providers;
|
|||
use rustc_middle::ty::subst::InternalSubsts;
|
||||
use rustc_middle::ty::util::Discr;
|
||||
use rustc_middle::ty::util::IntTypeExt;
|
||||
use rustc_middle::ty::{self, AdtKind, Const, DefIdTree, ToPolyTraitRef, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{self, AdtKind, Const, DefIdTree, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{ReprOptions, ToPredicate, WithConstness};
|
||||
use rustc_session::lint;
|
||||
use rustc_session::parse::feature_err;
|
||||
|
@ -607,8 +607,7 @@ fn type_param_predicates(
|
|||
ItemKind::Trait(_, _, ref generics, ..) => {
|
||||
// Implied `Self: Trait` and supertrait bounds.
|
||||
if param_id == item_hir_id {
|
||||
let identity_trait_ref =
|
||||
ty::Binder::dummy(ty::TraitRef::identity(tcx, item_def_id));
|
||||
let identity_trait_ref = ty::TraitRef::identity(tcx, item_def_id);
|
||||
extend =
|
||||
Some((identity_trait_ref.without_const().to_predicate(tcx), item.span));
|
||||
}
|
||||
|
@ -2003,14 +2002,11 @@ fn predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicates<'_> {
|
|||
// *current* state of an external file.
|
||||
span = tcx.sess.source_map().guess_head_span(span);
|
||||
}
|
||||
result.predicates = tcx.arena.alloc_from_iter(
|
||||
result.predicates.iter().copied().chain(std::iter::once((
|
||||
ty::Binder::dummy(ty::TraitRef::identity(tcx, def_id))
|
||||
.without_const()
|
||||
.to_predicate(tcx),
|
||||
result.predicates =
|
||||
tcx.arena.alloc_from_iter(result.predicates.iter().copied().chain(std::iter::once((
|
||||
ty::TraitRef::identity(tcx, def_id).without_const().to_predicate(tcx),
|
||||
span,
|
||||
))),
|
||||
);
|
||||
))));
|
||||
}
|
||||
debug!("predicates_of(def_id={:?}) = {:?}", def_id, result);
|
||||
result
|
||||
|
@ -2046,7 +2042,9 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
|
|||
match item.kind {
|
||||
ItemKind::Impl(ref impl_) => {
|
||||
if impl_.defaultness.is_default() {
|
||||
is_default_impl_trait = tcx.impl_trait_ref(def_id);
|
||||
is_default_impl_trait = tcx
|
||||
.impl_trait_ref(def_id)
|
||||
.map(|trait_ref| ty::Binder::dummy(trait_ref));
|
||||
}
|
||||
&impl_.generics
|
||||
}
|
||||
|
@ -2126,10 +2124,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
|
|||
// (see below). Recall that a default impl is not itself an impl, but rather a
|
||||
// set of defaults that can be incorporated into another impl.
|
||||
if let Some(trait_ref) = is_default_impl_trait {
|
||||
predicates.insert((
|
||||
trait_ref.to_poly_trait_ref().without_const().to_predicate(tcx),
|
||||
tcx.def_span(def_id),
|
||||
));
|
||||
predicates.insert((trait_ref.without_const().to_predicate(tcx), tcx.def_span(def_id)));
|
||||
}
|
||||
|
||||
// Collect the region predicates that were declared inline as
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue