diff options
| author | David Wood <david.wood@huawei.com> | 2022-05-07 07:50:01 +0100 |
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2022-05-12 07:21:51 +0100 |
| commit | 664733efd50eb4e2233d083abd159ca71f3844ff (patch) | |
| tree | e9c8dd39600a66e80e0b6050f2ead74f79a81574 | |
| parent | 78cc331bd71e918cef3d33a6557b1be9ae84eb26 (diff) | |
| download | rust-664733efd50eb4e2233d083abd159ca71f3844ff.tar.gz rust-664733efd50eb4e2233d083abd159ca71f3844ff.zip | |
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>
| -rw-r--r-- | compiler/rustc_error_messages/locales/en-US/typeck.ftl | 5 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/astconv/errors.rs | 16 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/errors.rs | 10 |
3 files changed, 17 insertions, 14 deletions
diff --git a/compiler/rustc_error_messages/locales/en-US/typeck.ftl b/compiler/rustc_error_messages/locales/en-US/typeck.ftl index a6b2b1dbd6a..4122464a4a2 100644 --- a/compiler/rustc_error_messages/locales/en-US/typeck.ftl +++ b/compiler/rustc_error_messages/locales/en-US/typeck.ftl @@ -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 diff --git a/compiler/rustc_typeck/src/astconv/errors.rs b/compiler/rustc_typeck/src/astconv/errors.rs index 5cfed81017f..8fe89c66389 100644 --- a/compiler/rustc_typeck/src/astconv/errors.rs +++ b/compiler/rustc_typeck/src/astconv/errors.rs @@ -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 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { 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 }); } } diff --git a/compiler/rustc_typeck/src/errors.rs b/compiler/rustc_typeck/src/errors.rs index 93900ae24bb..1cb112e68ce 100644 --- a/compiler/rustc_typeck/src/errors.rs +++ b/compiler/rustc_typeck/src/errors.rs @@ -313,3 +313,13 @@ impl<'a> SessionDiagnostic<'a> for MissingTypeParams { err } } + +#[derive(SessionDiagnostic)] +#[error(code = "E0183", slug = "typeck-manual-implementation")] +#[help] +pub struct ManualImplementation { + #[primary_span] + #[label] + pub span: Span, + pub trait_name: String, +} |
