Skip to content

Commit

Permalink
Tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Mar 21, 2022
1 parent 1f3ee7f commit fe5b813
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 8 additions & 4 deletions compiler/rustc_trait_selection/src/traits/select/confirmation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,8 +1051,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
#[cfg(bootstrap)]
{}

if obligation.predicate.skip_binder().def_id() == drop_trait
{
if obligation.predicate.skip_binder().def_id() == drop_trait {
return Ok(ImplSourceConstDestructData { nested: vec![] });
}

Expand All @@ -1068,7 +1067,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
if let Some(impl_def_id) = impl_def_id {
let obligations = self.infcx.commit_unconditionally(|_| {
let mut new_obligation = obligation.clone();
new_obligation.predicate = new_obligation.predicate.map_bound(|mut trait_pred| { trait_pred.trait_ref.def_id = drop_trait; trait_pred });
new_obligation.predicate = new_obligation.predicate.map_bound(|mut trait_pred| {
trait_pred.trait_ref.def_id = drop_trait;
trait_pred
});
let substs = self.rematch_impl(impl_def_id, &new_obligation);
debug!(?substs, "impl substs");
let cause = obligation.derived_cause(ImplDerivedObligation);
Expand Down Expand Up @@ -1140,7 +1142,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
self_ty
.rebind(ty::TraitPredicate {
trait_ref: ty::TraitRef {
def_id: self.tcx().require_lang_item(LangItem::Destruct, None),
def_id: self
.tcx()
.require_lang_item(LangItem::Destruct, None),
substs: self.tcx().mk_substs_trait(nested_ty, &[]),
},
constness: ty::BoundConstness::ConstIfConst,
Expand Down
6 changes: 5 additions & 1 deletion src/test/ui/rfc-2632-const-trait-impl/const-drop-bound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ const fn foo<T, E>(res: Result<T, E>) -> Option<T> where E: ~const Destruct {

pub struct Foo<T>(T);

const fn baz<T: ~const Destruct, E: ~const Destruct>(res: Result<Foo<T>, Foo<E>>) -> Option<Foo<T>> {
const fn baz<T, E>(res: Result<Foo<T>, Foo<E>>) -> Option<Foo<T>>
where
T: ~const Destruct,
E: ~const Destruct,
{
foo(res)
}

Expand Down

0 comments on commit fe5b813

Please sign in to comment.