typeck: port "manual implementations"

Port the "manual implementations of `X` are experimental" diagnostic to
use the diagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
David Wood
2022-05-07 07:50:01 +01:00
parent 78cc331bd7
commit 664733efd5
3 changed files with 17 additions and 14 deletions
@@ -122,3 +122,8 @@ typeck-missing-type-params =
*[other] references
} to {$parameters}
.note = because of the default `Self` reference, type parameters must be specified on object types
typeck-manual-implementation =
manual implementations of `{$trait_name}` are experimental
.label = manual implementations of `{$trait_name}` are experimental
.help = add `#![feature(unboxed_closures)]` to the crate attributes to enable
+2 -14
View File
@@ -1,5 +1,5 @@
use crate::astconv::AstConv;
use crate::errors::MissingTypeParams;
use crate::errors::{ManualImplementation, MissingTypeParams};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{pluralize, struct_span_err, Applicability, ErrorGuaranteed};
use rustc_hir as hir;
@@ -121,19 +121,7 @@ pub(crate) fn complain_about_internal_fn_trait(
if is_impl {
let trait_name = self.tcx().def_path_str(trait_def_id);
struct_span_err!(
self.tcx().sess,
span,
E0183,
"manual implementations of `{}` are experimental",
trait_name,
)
.span_label(
span,
format!("manual implementations of `{}` are experimental", trait_name),
)
.help("add `#![feature(unboxed_closures)]` to the crate attributes to enable")
.emit();
self.tcx().sess.emit_err(ManualImplementation { span, trait_name });
}
}
+10
View File
@@ -313,3 +313,13 @@ fn into_diagnostic(self, sess: &'a ParseSess) -> DiagnosticBuilder<'a, ErrorGuar
err
}
}
#[derive(SessionDiagnostic)]
#[error(code = "E0183", slug = "typeck-manual-implementation")]
#[help]
pub struct ManualImplementation {
#[primary_span]
#[label]
pub span: Span,
pub trait_name: String,
}