Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 5685abc

Browse files
committed
typeck: simplify error type using () field
Using new support for spanless subdiagnostics from `()` fields in the diagnostic derive, simplify the "explicit generic args with impl trait" diagnostic's struct. Signed-off-by: David Wood <[email protected]>
1 parent 7b7061d commit 5685abc

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,4 @@ typeck-explicit-generic-args-with-impl-trait =
9999
cannot provide explicit generic arguments when `impl Trait` is used in argument position
100100
.label = explicit generic argument not allowed
101101
.note = see issue #83701 <https://github.com/rust-lang/rust/issues/83701> for more information
102-
103-
typeck-explicit-generic-args-with-impl-trait-feature =
104-
add `#![feature(explicit_generic_args_with_impl_trait)]` to the crate attributes to enable
102+
.help = add `#![feature(explicit_generic_args_with_impl_trait)]` to the crate attributes to enable

compiler/rustc_typeck/src/astconv/generics.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ use crate::astconv::{
33
AstConv, CreateSubstsForGenericArgsCtxt, ExplicitLateBound, GenericArgCountMismatch,
44
GenericArgCountResult, GenericArgPosition,
55
};
6-
use crate::errors::{
7-
AssocTypeBindingNotAllowed, ExplicitGenericArgsWithImplTrait,
8-
ExplicitGenericArgsWithImplTraitFeature,
9-
};
6+
use crate::errors::{AssocTypeBindingNotAllowed, ExplicitGenericArgsWithImplTrait};
107
use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs};
118
use rustc_ast::ast::ParamKindOrd;
129
use rustc_errors::{struct_span_err, Applicability, Diagnostic, MultiSpan};
@@ -639,11 +636,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
639636
})
640637
.collect::<Vec<_>>();
641638

642-
let mut err = tcx.sess.create_err(ExplicitGenericArgsWithImplTrait { spans });
643-
if tcx.sess.is_nightly_build() {
644-
err.subdiagnostic(ExplicitGenericArgsWithImplTraitFeature);
645-
}
646-
err.emit();
639+
tcx.sess.emit_err(ExplicitGenericArgsWithImplTrait {
640+
spans,
641+
is_nightly_build: tcx.sess.is_nightly_build().then_some(()),
642+
});
647643
}
648644

649645
impl_trait

compiler/rustc_typeck/src/errors.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,6 @@ pub struct ExplicitGenericArgsWithImplTrait {
247247
#[primary_span]
248248
#[label]
249249
pub spans: Vec<Span>,
250+
#[help]
251+
pub is_nightly_build: Option<()>,
250252
}
251-
252-
#[derive(SessionSubdiagnostic)]
253-
#[help(slug = "typeck-explicit-generic-args-with-impl-trait-feature")]
254-
pub struct ExplicitGenericArgsWithImplTraitFeature;

0 commit comments

Comments
 (0)