diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-02-10 13:12:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-10 13:12:31 +0100 |
| commit | 55913368c53b2846bd96fd017abc34a0af07ccc8 (patch) | |
| tree | 5c3cfc67941b0bf40c4ad3dec50f529e473ff23e /compiler/rustc_hir_analysis | |
| parent | ed3b049a8b234180f2e156dac358af4effb35f09 (diff) | |
| parent | a2479a4ae75884953eb9eaad083105174549c2ed (diff) | |
| download | rust-55913368c53b2846bd96fd017abc34a0af07ccc8.tar.gz rust-55913368c53b2846bd96fd017abc34a0af07ccc8.zip | |
Rollup merge of #120870 - Zalathar:allow-min-spec, r=oli-obk
Allow restricted trait impls under `#[allow_internal_unstable(min_specialization)]` This is a follow-up to #119963 and a companion to #120866, though it can land independently from the latter. --- We have several compiler crates that only enable `#[feature(min_specialization)]` because it is required by their expansions of `newtype_index!`, in order to implement traits marked with `#[rustc_specialization_trait]`. This PR allows those traits to be implemented internally by macros with `#[allow_internal_unstable(min_specialization)]`, without needing specialization to be enabled in the enclosing crate.
Diffstat (limited to 'compiler/rustc_hir_analysis')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/coherence/mod.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/lib.rs | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_hir_analysis/src/coherence/mod.rs b/compiler/rustc_hir_analysis/src/coherence/mod.rs index 8cf1f2c9407..817dab993a3 100644 --- a/compiler/rustc_hir_analysis/src/coherence/mod.rs +++ b/compiler/rustc_hir_analysis/src/coherence/mod.rs @@ -10,7 +10,7 @@ use rustc_errors::{codes::*, struct_span_code_err}; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_middle::query::Providers; use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt}; -use rustc_span::ErrorGuaranteed; +use rustc_span::{sym, ErrorGuaranteed}; use rustc_trait_selection::traits; mod builtin; @@ -70,7 +70,11 @@ fn enforce_trait_manually_implementable( if let ty::trait_def::TraitSpecializationKind::AlwaysApplicable = tcx.trait_def(trait_def_id).specialization_kind { - if !tcx.features().specialization && !tcx.features().min_specialization { + if !tcx.features().specialization + && !tcx.features().min_specialization + && !impl_header_span.allows_unstable(sym::specialization) + && !impl_header_span.allows_unstable(sym::min_specialization) + { return Err(tcx.dcx().emit_err(errors::SpecializationTrait { span: impl_header_span })); } } diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 883d416ecd1..1aaefc5b520 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -67,7 +67,7 @@ This API is completely unstable and subject to change. #![feature(is_sorted)] #![feature(iter_intersperse)] #![feature(let_chains)] -#![feature(min_specialization)] +#![cfg_attr(bootstrap, feature(min_specialization))] #![feature(never_type)] #![feature(lazy_cell)] #![feature(slice_partition_dedup)] |
