Forbid implementing Freeze
even if the trait is stabilized
This commit is contained in:
parent
f030d49536
commit
7849230740
10 changed files with 62 additions and 5 deletions
|
@ -10,6 +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_session::parse::feature_err;
|
||||
use rustc_span::{sym, ErrorGuaranteed};
|
||||
use rustc_trait_selection::traits;
|
||||
|
||||
|
@ -49,6 +50,19 @@ fn enforce_trait_manually_implementable(
|
|||
) -> Result<(), ErrorGuaranteed> {
|
||||
let impl_header_span = tcx.def_span(impl_def_id);
|
||||
|
||||
if tcx.lang_items().freeze_trait() == Some(trait_def_id) {
|
||||
if !tcx.features().freeze_impls {
|
||||
feature_err(
|
||||
&tcx.sess,
|
||||
sym::freeze_impls,
|
||||
impl_header_span,
|
||||
"explicit impls for the `Freeze` trait are not permitted",
|
||||
)
|
||||
.with_span_label(impl_header_span, format!("impl of `Freeze` not allowed"))
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
||||
// Disallow *all* explicit impls of traits marked `#[rustc_deny_explicit_impl]`
|
||||
if trait_def.deny_explicit_impl {
|
||||
let trait_name = tcx.item_name(trait_def_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue