Skip to content

Commit 431362a

Browse files
committed
Fix diag for generic parameters from outer function
1 parent 7f0fa48 commit 431362a

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -554,14 +554,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
554554
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
555555
match resolution_error {
556556
ResolutionError::GenericParamsFromOuterFunction(outer_res, has_generic_params) => {
557-
let mut err = struct_span_err!(
558-
self.tcx.sess,
559-
span,
560-
E0401,
561-
"can't use generic parameters from outer function",
562-
);
563-
err.span_label(span, "use of generic parameter from outer function");
564-
557+
let mut err =
558+
self.tcx.sess.create_err(errs::GenericParamsFromOuterFunction { span });
565559
let sm = self.tcx.sess.source_map();
566560
let def_id = match outer_res {
567561
Res::SelfTyParam { .. } => {

compiler/rustc_resolve/src/errors.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,14 @@ pub(crate) struct ForwardDeclaredGenericParam {
319319
pub(crate) span: Span,
320320
}
321321

322+
#[derive(Diagnostic)]
323+
#[diag(resolve_generic_params_from_outer_function, code = "E0401")]
324+
pub(crate) struct GenericParamsFromOuterFunction {
325+
#[primary_span]
326+
#[label]
327+
pub(crate) span: Span,
328+
}
329+
322330
#[derive(Diagnostic)]
323331
#[diag(resolve_param_in_ty_of_const_param, code = "E0770")]
324332
pub(crate) struct ParamInTyOfConstParam {

0 commit comments

Comments
 (0)