Skip to content

Commit 664733e

Browse files
committed
typeck: port "manual implementations"
Port the "manual implementations of `X` are experimental" diagnostic to use the diagnostic derive. Signed-off-by: David Wood <[email protected]>
1 parent 78cc331 commit 664733e

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

compiler/rustc_error_messages/locales/en-US/typeck.ftl

+5
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,8 @@ typeck-missing-type-params =
122122
*[other] references
123123
} to {$parameters}
124124
.note = because of the default `Self` reference, type parameters must be specified on object types
125+
126+
typeck-manual-implementation =
127+
manual implementations of `{$trait_name}` are experimental
128+
.label = manual implementations of `{$trait_name}` are experimental
129+
.help = add `#![feature(unboxed_closures)]` to the crate attributes to enable

compiler/rustc_typeck/src/astconv/errors.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::astconv::AstConv;
2-
use crate::errors::MissingTypeParams;
2+
use crate::errors::{ManualImplementation, MissingTypeParams};
33
use rustc_data_structures::fx::FxHashMap;
44
use rustc_errors::{pluralize, struct_span_err, Applicability, ErrorGuaranteed};
55
use rustc_hir as hir;
@@ -121,19 +121,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
121121

122122
if is_impl {
123123
let trait_name = self.tcx().def_path_str(trait_def_id);
124-
struct_span_err!(
125-
self.tcx().sess,
126-
span,
127-
E0183,
128-
"manual implementations of `{}` are experimental",
129-
trait_name,
130-
)
131-
.span_label(
132-
span,
133-
format!("manual implementations of `{}` are experimental", trait_name),
134-
)
135-
.help("add `#![feature(unboxed_closures)]` to the crate attributes to enable")
136-
.emit();
124+
self.tcx().sess.emit_err(ManualImplementation { span, trait_name });
137125
}
138126
}
139127

compiler/rustc_typeck/src/errors.rs

+10
Original file line numberDiff line numberDiff line change
@@ -313,3 +313,13 @@ impl<'a> SessionDiagnostic<'a> for MissingTypeParams {
313313
err
314314
}
315315
}
316+
317+
#[derive(SessionDiagnostic)]
318+
#[error(code = "E0183", slug = "typeck-manual-implementation")]
319+
#[help]
320+
pub struct ManualImplementation {
321+
#[primary_span]
322+
#[label]
323+
pub span: Span,
324+
pub trait_name: String,
325+
}

0 commit comments

Comments
 (0)