about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKyle Matsuda <kyle.yoshio.matsuda@gmail.com>2023-04-13 16:43:34 -0600
committerKyle Matsuda <kyle.yoshio.matsuda@gmail.com>2023-04-13 16:43:34 -0600
commit8d5ee1a0729b91545e856dbf14fd75687dc9e2b8 (patch)
tree5b321e0ff7bbe673cb64e5245f9217b484d2a843
parente2f5a5a71fa2a55e976484b9e72f5aa425ebab62 (diff)
downloadrust-8d5ee1a0729b91545e856dbf14fd75687dc9e2b8.tar.gz
rust-8d5ee1a0729b91545e856dbf14fd75687dc9e2b8.zip
make impl_subject more readable
-rw-r--r--compiler/rustc_middle/src/hir/mod.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs
index 50a3067c559..7770a5e4764 100644
--- a/compiler/rustc_middle/src/hir/mod.rs
+++ b/compiler/rustc_middle/src/hir/mod.rs
@@ -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),
+        }
     }
 }