Skip to content

Commit 1c2689b

Browse files
[don't merge pls] estimate fallout of changing Any blanket impl
1 parent 6ef7d16 commit 1c2689b

File tree

2 files changed

+3
-2
lines changed
  • compiler/rustc_hir_analysis/src/coherence
  • library/core/src

2 files changed

+3
-2
lines changed

compiler/rustc_hir_analysis/src/coherence/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn enforce_trait_manually_implementable(
4343
let impl_header_span = tcx.def_span(impl_def_id);
4444

4545
// Disallow *all* explicit impls of traits marked `#[rustc_deny_explicit_impl]`
46-
if tcx.trait_def(trait_def_id).deny_explicit_impl {
46+
if tcx.trait_def(trait_def_id).deny_explicit_impl && !tcx.hir().rustc_coherence_is_core() {
4747
let trait_name = tcx.item_name(trait_def_id);
4848
let mut err = struct_span_err!(
4949
tcx.sess,

library/core/src/any.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ use crate::intrinsics;
112112
// but we would likely want to indicate as such in documentation).
113113
#[stable(feature = "rust1", since = "1.0.0")]
114114
#[cfg_attr(not(test), rustc_diagnostic_item = "Any")]
115+
#[cfg_attr(not(bootstrap), rustc_deny_explicit_impl(implement_via_object = true))]
115116
pub trait Any: 'static {
116117
/// Gets the `TypeId` of `self`.
117118
///
@@ -132,7 +133,7 @@ pub trait Any: 'static {
132133
}
133134

134135
#[stable(feature = "rust1", since = "1.0.0")]
135-
impl<T: 'static + ?Sized> Any for T {
136+
impl<T: 'static> Any for T {
136137
fn type_id(&self) -> TypeId {
137138
TypeId::of::<T>()
138139
}

0 commit comments

Comments
 (0)