Skip to content

Commit

Permalink
make impl_subject more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
kylematsuda committed Apr 13, 2023
1 parent e2f5a5a commit 8d5ee1a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions compiler/rustc_middle/src/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,10 @@ impl<'tcx> TyCtxt<'tcx> {
}

pub fn impl_subject(self, def_id: DefId) -> EarlyBinder<ImplSubject<'tcx>> {
EarlyBinder(
self.impl_trait_ref(def_id)
.map(|t| t.subst_identity())
.map(ImplSubject::Trait)
.unwrap_or_else(|| ImplSubject::Inherent(self.type_of(def_id).subst_identity())),
)
match self.impl_trait_ref(def_id) {
Some(t) => t.map_bound(ImplSubject::Trait),
None => self.type_of(def_id).map_bound(ImplSubject::Inherent),
}
}
}

Expand Down

0 comments on commit 8d5ee1a

Please sign in to comment.