Skip to content

Commit f3d96e9

Browse files
committed
fmt
1 parent 580ca93 commit f3d96e9

File tree

4 files changed

+42
-30
lines changed

4 files changed

+42
-30
lines changed

compiler/rustc_mir/src/transform/check_consts/check.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -826,21 +826,26 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
826826
);
827827

828828
let implsrc = tcx.infer_ctxt().enter(|infcx| {
829-
let mut selcx = SelectionContext::with_constness(&infcx, hir::Constness::Const);
829+
let mut selcx =
830+
SelectionContext::with_constness(&infcx, hir::Constness::Const);
830831
selcx.select(&obligation)
831832
});
832833

833834
match implsrc {
834835
Ok(Some(ImplSource::Param(_, ty::BoundConstness::ConstIfConst))) => {
835836
debug!(
836837
"const_trait_impl: provided {:?} via where-clause in {:?}",
837-
trait_ref, param_env
838+
trait_ref, param_env
838839
);
839840
return;
840841
}
841842
Ok(Some(ImplSource::UserDefined(data))) => {
842843
let callee_name = tcx.item_name(callee);
843-
if let Some(&did) = tcx.associated_item_def_ids(data.impl_def_id).iter().find(|did| tcx.item_name(**did) == callee_name) {
844+
if let Some(&did) = tcx
845+
.associated_item_def_ids(data.impl_def_id)
846+
.iter()
847+
.find(|did| tcx.item_name(**did) == callee_name)
848+
{
844849
callee = did;
845850
}
846851
}
@@ -909,7 +914,7 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
909914
// trait, but for it to still be non-const can be that the impl is
910915
// using default method bodies.
911916
nonconst_call_permission = true;
912-
}
917+
}
913918
}
914919

915920
if !nonconst_call_permission {

compiler/rustc_trait_selection/src/traits/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,10 @@ pub fn vtable_trait_upcasting_coercion_new_vptr_slot(
778778
let obligation = Obligation::new(
779779
ObligationCause::dummy(),
780780
ty::ParamEnv::reveal_all(),
781-
ty::Binder::dummy(ty::TraitPredicate { trait_ref, constness: ty::BoundConstness::NotConst }),
781+
ty::Binder::dummy(ty::TraitPredicate {
782+
trait_ref,
783+
constness: ty::BoundConstness::NotConst,
784+
}),
782785
);
783786

784787
let implsrc = tcx.infer_ctxt().enter(|infcx| {

compiler/rustc_trait_selection/src/traits/select/mod.rs

+26-24
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
319319
pub fn is_trait_predicate_const(&self, pred: ty::TraitPredicate<'_>) -> bool {
320320
match pred.constness {
321321
ty::BoundConstness::ConstIfConst if self.is_in_const_context => true,
322-
_ => false
322+
_ => false,
323323
}
324324
}
325325

@@ -1079,30 +1079,30 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10791079
let tcx = self.tcx();
10801080
// Respect const trait obligations
10811081
if self.is_trait_predicate_const(obligation.predicate.skip_binder()) {
1082-
if Some(obligation.predicate.skip_binder().trait_ref.def_id)
1083-
!= tcx.lang_items().sized_trait()
1084-
// const Sized bounds are skipped
1085-
{
1086-
match candidate {
1087-
// const impl
1088-
ImplCandidate(def_id)
1089-
if tcx.impl_constness(def_id) == hir::Constness::Const => {}
1090-
// const param
1091-
ParamCandidate(ty::ConstnessAnd {
1092-
constness: ty::BoundConstness::ConstIfConst,
1093-
..
1094-
}) => {}
1095-
// auto trait impl
1096-
AutoImplCandidate(..) => {}
1097-
// generator, this will raise error in other places
1098-
// or ignore error with const_async_blocks feature
1099-
GeneratorCandidate => {}
1100-
_ => {
1101-
// reject all other types of candidates
1102-
return Err(Unimplemented);
1103-
}
1082+
if Some(obligation.predicate.skip_binder().trait_ref.def_id)
1083+
!= tcx.lang_items().sized_trait()
1084+
// const Sized bounds are skipped
1085+
{
1086+
match candidate {
1087+
// const impl
1088+
ImplCandidate(def_id)
1089+
if tcx.impl_constness(def_id) == hir::Constness::Const => {}
1090+
// const param
1091+
ParamCandidate(ty::ConstnessAnd {
1092+
constness: ty::BoundConstness::ConstIfConst,
1093+
..
1094+
}) => {}
1095+
// auto trait impl
1096+
AutoImplCandidate(..) => {}
1097+
// generator, this will raise error in other places
1098+
// or ignore error with const_async_blocks feature
1099+
GeneratorCandidate => {}
1100+
_ => {
1101+
// reject all other types of candidates
1102+
return Err(Unimplemented);
11041103
}
11051104
}
1105+
}
11061106
}
11071107
// Treat negative impls as unimplemented, and reservation impls as ambiguity.
11081108
if let ImplCandidate(def_id) = candidate {
@@ -1497,7 +1497,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
14971497
// probably best characterized as a "hack", since we might prefer to just do our
14981498
// best to *not* create essentially duplicate candidates in the first place.
14991499
other.value.bound_vars().len() <= victim.value.bound_vars().len()
1500-
} else if other.value == victim.value && victim.constness == ty::BoundConstness::NotConst {
1500+
} else if other.value == victim.value
1501+
&& victim.constness == ty::BoundConstness::NotConst
1502+
{
15011503
// Drop otherwise equivalent non-const candidates in favor of const candidates.
15021504
true
15031505
} else {

compiler/rustc_typeck/src/collect.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2222,7 +2222,9 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
22222222
hir::GenericBound::Trait(poly_trait_ref, modifier) => {
22232223
let constness = match modifier {
22242224
hir::TraitBoundModifier::None => ty::BoundConstness::NotConst,
2225-
hir::TraitBoundModifier::MaybeConst => ty::BoundConstness::ConstIfConst,
2225+
hir::TraitBoundModifier::MaybeConst => {
2226+
ty::BoundConstness::ConstIfConst
2227+
}
22262228
// We ignore `where T: ?Sized`, it is already part of
22272229
// type parameter `T`.
22282230
hir::TraitBoundModifier::Maybe => continue,

0 commit comments

Comments
 (0)