diff --git a/compiler/rustc_hir_analysis/src/coherence/mod.rs b/compiler/rustc_hir_analysis/src/coherence/mod.rs index fc8fab0eabc83..1f73950765ed0 100644 --- a/compiler/rustc_hir_analysis/src/coherence/mod.rs +++ b/compiler/rustc_hir_analysis/src/coherence/mod.rs @@ -43,7 +43,7 @@ fn enforce_trait_manually_implementable( let impl_header_span = tcx.def_span(impl_def_id); // Disallow *all* explicit impls of traits marked `#[rustc_deny_explicit_impl]` - if tcx.trait_def(trait_def_id).deny_explicit_impl { + if tcx.trait_def(trait_def_id).deny_explicit_impl && !tcx.hir().rustc_coherence_is_core() { let trait_name = tcx.item_name(trait_def_id); let mut err = struct_span_err!( tcx.sess, diff --git a/library/core/src/any.rs b/library/core/src/any.rs index 8f5404d9713dd..5e4346c16c9c0 100644 --- a/library/core/src/any.rs +++ b/library/core/src/any.rs @@ -112,6 +112,7 @@ use crate::intrinsics; // but we would likely want to indicate as such in documentation). #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "Any")] +#[cfg_attr(not(bootstrap), rustc_deny_explicit_impl(implement_via_object = true))] pub trait Any: 'static { /// Gets the `TypeId` of `self`. /// @@ -132,7 +133,7 @@ pub trait Any: 'static { } #[stable(feature = "rust1", since = "1.0.0")] -impl Any for T { +impl Any for T { fn type_id(&self) -> TypeId { TypeId::of::() }