about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src/coherence
diff options
context:
space:
mode:
authorMaybe Waffle <waffle.lapkin@gmail.com>2023-04-17 17:16:49 +0000
committerMaybe Waffle <waffle.lapkin@gmail.com>2023-04-17 18:00:27 +0000
commit9534541dd48ec52bcd9a60094155dffaa8f0a87f (patch)
treec29312654e3f9e9a11201fcf82f5f3a884566c35 /compiler/rustc_hir_analysis/src/coherence
parente49122fb1ca87a6c3e3c22abb315fc75cfe8daed (diff)
downloadrust-9534541dd48ec52bcd9a60094155dffaa8f0a87f.tar.gz
rust-9534541dd48ec52bcd9a60094155dffaa8f0a87f.zip
Use `Item::expect_*` and `ImplItem::expect_*` more
Diffstat (limited to 'compiler/rustc_hir_analysis/src/coherence')
-rw-r--r--compiler/rustc_hir_analysis/src/coherence/builtin.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/rustc_hir_analysis/src/coherence/builtin.rs b/compiler/rustc_hir_analysis/src/coherence/builtin.rs
index 0f40cca9427..c2dc2a0f058 100644
--- a/compiler/rustc_hir_analysis/src/coherence/builtin.rs
+++ b/compiler/rustc_hir_analysis/src/coherence/builtin.rs
@@ -74,10 +74,9 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
 
     debug!("visit_implementation_of_copy: self_type={:?} (free)", self_type);
 
-    let span = match tcx.hir().expect_item(impl_did).kind {
-        ItemKind::Impl(hir::Impl { polarity: hir::ImplPolarity::Negative(_), .. }) => return,
-        ItemKind::Impl(impl_) => impl_.self_ty.span,
-        _ => bug!("expected Copy impl item"),
+    let span = match tcx.hir().expect_item(impl_did).expect_impl() {
+        hir::Impl { polarity: hir::ImplPolarity::Negative(_), .. } => return,
+        hir::Impl { self_ty, .. } => self_ty.span,
     };
 
     let cause = traits::ObligationCause::misc(span, impl_did);