Simplify a bunch of trait ref obligation creations
This commit is contained in:
parent
08afabddac
commit
42cc8e8f4e
10 changed files with 17 additions and 40 deletions
|
@ -10,7 +10,7 @@ use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceC
|
|||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::subst::{GenericArgKind, InternalSubsts};
|
||||
use rustc_middle::ty::{self, adjustment::PointerCast, Instance, InstanceDef, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{Binder, TraitPredicate, TraitRef, TypeVisitable};
|
||||
use rustc_middle::ty::{Binder, TraitRef, TypeVisitable};
|
||||
use rustc_mir_dataflow::{self, Analysis};
|
||||
use rustc_span::{sym, Span, Symbol};
|
||||
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt as _;
|
||||
|
@ -735,11 +735,8 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
|
|||
}
|
||||
|
||||
let trait_ref = TraitRef::from_method(tcx, trait_id, substs);
|
||||
let poly_trait_pred = Binder::dummy(TraitPredicate {
|
||||
trait_ref,
|
||||
constness: ty::BoundConstness::ConstIfConst,
|
||||
polarity: ty::ImplPolarity::Positive,
|
||||
});
|
||||
let poly_trait_pred =
|
||||
Binder::dummy(trait_ref).with_constness(ty::BoundConstness::ConstIfConst);
|
||||
let obligation =
|
||||
Obligation::new(tcx, ObligationCause::dummy(), param_env, poly_trait_pred);
|
||||
|
||||
|
@ -828,9 +825,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
|
|||
tcx,
|
||||
ObligationCause::dummy_with_span(*fn_span),
|
||||
param_env,
|
||||
tcx.mk_predicate(
|
||||
poly_trait_pred.map_bound(ty::PredicateKind::Trait),
|
||||
),
|
||||
poly_trait_pred,
|
||||
);
|
||||
|
||||
// improve diagnostics by showing what failed. Our requirements are stricter this time
|
||||
|
|
|
@ -13,10 +13,9 @@ use rustc_middle::mir;
|
|||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
|
||||
use rustc_middle::ty::{
|
||||
suggest_constraining_type_param, Adt, Closure, DefIdTree, FnDef, FnPtr, Param, TraitPredicate,
|
||||
Ty,
|
||||
suggest_constraining_type_param, Adt, Closure, DefIdTree, FnDef, FnPtr, Param, Ty,
|
||||
};
|
||||
use rustc_middle::ty::{Binder, BoundConstness, ImplPolarity, TraitRef};
|
||||
use rustc_middle::ty::{Binder, TraitRef};
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::{BytePos, Pos, Span, Symbol};
|
||||
|
@ -150,11 +149,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
|
|||
tcx,
|
||||
ObligationCause::dummy(),
|
||||
param_env,
|
||||
Binder::dummy(TraitPredicate {
|
||||
trait_ref,
|
||||
constness: BoundConstness::NotConst,
|
||||
polarity: ImplPolarity::Positive,
|
||||
}),
|
||||
Binder::dummy(trait_ref),
|
||||
);
|
||||
|
||||
let infcx = tcx.infer_ctxt().build();
|
||||
|
|
|
@ -157,11 +157,8 @@ impl Qualif for NeedsNonConstDrop {
|
|||
cx.tcx,
|
||||
ObligationCause::dummy_with_span(cx.body.span),
|
||||
cx.param_env,
|
||||
ty::Binder::dummy(ty::TraitPredicate {
|
||||
trait_ref: cx.tcx.at(cx.body.span).mk_trait_ref(LangItem::Destruct, [ty]),
|
||||
constness: ty::BoundConstness::ConstIfConst,
|
||||
polarity: ty::ImplPolarity::Positive,
|
||||
}),
|
||||
ty::Binder::dummy(cx.tcx.at(cx.body.span).mk_trait_ref(LangItem::Destruct, [ty]))
|
||||
.with_constness(ty::BoundConstness::ConstIfConst),
|
||||
);
|
||||
|
||||
let infcx = cx.tcx.infer_ctxt().build();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue