diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index 9027d330a90f6..8a84fca143809 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -367,10 +367,11 @@ pub(super) fn specialization_graph_provider( } let access_levels = tcx.privacy_access_levels(impl_def_id.krate); - let id = tcx.hir().as_local_hir_id(impl_def_id).unwrap(); - if access_levels.is_exported(id) || access_levels.is_public(id) { - for cause in &overlap.intercrate_ambiguity_causes { - cause.add_intercrate_ambiguity_hint(&mut err); + if let Some(id) = tcx.hir().as_local_hir_id(impl_def_id) { + if access_levels.is_exported(id) || access_levels.is_public(id) { + for cause in &overlap.intercrate_ambiguity_causes { + cause.add_intercrate_ambiguity_hint(&mut err); + } } }