fmt
This commit is contained in:
parent
580ca930ac
commit
f3d96e9391
4 changed files with 42 additions and 30 deletions
|
@ -826,7 +826,8 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
|
||||||
);
|
);
|
||||||
|
|
||||||
let implsrc = tcx.infer_ctxt().enter(|infcx| {
|
let implsrc = tcx.infer_ctxt().enter(|infcx| {
|
||||||
let mut selcx = SelectionContext::with_constness(&infcx, hir::Constness::Const);
|
let mut selcx =
|
||||||
|
SelectionContext::with_constness(&infcx, hir::Constness::Const);
|
||||||
selcx.select(&obligation)
|
selcx.select(&obligation)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -840,7 +841,11 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
|
||||||
}
|
}
|
||||||
Ok(Some(ImplSource::UserDefined(data))) => {
|
Ok(Some(ImplSource::UserDefined(data))) => {
|
||||||
let callee_name = tcx.item_name(callee);
|
let callee_name = tcx.item_name(callee);
|
||||||
if let Some(&did) = tcx.associated_item_def_ids(data.impl_def_id).iter().find(|did| tcx.item_name(**did) == callee_name) {
|
if let Some(&did) = tcx
|
||||||
|
.associated_item_def_ids(data.impl_def_id)
|
||||||
|
.iter()
|
||||||
|
.find(|did| tcx.item_name(**did) == callee_name)
|
||||||
|
{
|
||||||
callee = did;
|
callee = did;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -778,7 +778,10 @@ pub fn vtable_trait_upcasting_coercion_new_vptr_slot(
|
||||||
let obligation = Obligation::new(
|
let obligation = Obligation::new(
|
||||||
ObligationCause::dummy(),
|
ObligationCause::dummy(),
|
||||||
ty::ParamEnv::reveal_all(),
|
ty::ParamEnv::reveal_all(),
|
||||||
ty::Binder::dummy(ty::TraitPredicate { trait_ref, constness: ty::BoundConstness::NotConst }),
|
ty::Binder::dummy(ty::TraitPredicate {
|
||||||
|
trait_ref,
|
||||||
|
constness: ty::BoundConstness::NotConst,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
let implsrc = tcx.infer_ctxt().enter(|infcx| {
|
let implsrc = tcx.infer_ctxt().enter(|infcx| {
|
||||||
|
|
|
@ -319,7 +319,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
pub fn is_trait_predicate_const(&self, pred: ty::TraitPredicate<'_>) -> bool {
|
pub fn is_trait_predicate_const(&self, pred: ty::TraitPredicate<'_>) -> bool {
|
||||||
match pred.constness {
|
match pred.constness {
|
||||||
ty::BoundConstness::ConstIfConst if self.is_in_const_context => true,
|
ty::BoundConstness::ConstIfConst if self.is_in_const_context => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1497,7 +1497,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
// probably best characterized as a "hack", since we might prefer to just do our
|
// probably best characterized as a "hack", since we might prefer to just do our
|
||||||
// best to *not* create essentially duplicate candidates in the first place.
|
// best to *not* create essentially duplicate candidates in the first place.
|
||||||
other.value.bound_vars().len() <= victim.value.bound_vars().len()
|
other.value.bound_vars().len() <= victim.value.bound_vars().len()
|
||||||
} else if other.value == victim.value && victim.constness == ty::BoundConstness::NotConst {
|
} else if other.value == victim.value
|
||||||
|
&& victim.constness == ty::BoundConstness::NotConst
|
||||||
|
{
|
||||||
// Drop otherwise equivalent non-const candidates in favor of const candidates.
|
// Drop otherwise equivalent non-const candidates in favor of const candidates.
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2222,7 +2222,9 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
|
||||||
hir::GenericBound::Trait(poly_trait_ref, modifier) => {
|
hir::GenericBound::Trait(poly_trait_ref, modifier) => {
|
||||||
let constness = match modifier {
|
let constness = match modifier {
|
||||||
hir::TraitBoundModifier::None => ty::BoundConstness::NotConst,
|
hir::TraitBoundModifier::None => ty::BoundConstness::NotConst,
|
||||||
hir::TraitBoundModifier::MaybeConst => ty::BoundConstness::ConstIfConst,
|
hir::TraitBoundModifier::MaybeConst => {
|
||||||
|
ty::BoundConstness::ConstIfConst
|
||||||
|
}
|
||||||
// We ignore `where T: ?Sized`, it is already part of
|
// We ignore `where T: ?Sized`, it is already part of
|
||||||
// type parameter `T`.
|
// type parameter `T`.
|
||||||
hir::TraitBoundModifier::Maybe => continue,
|
hir::TraitBoundModifier::Maybe => continue,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue