mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-04 01:42:54 +03:00
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 <david.wood@huawei.com>
This commit is contained in:
@@ -99,6 +99,4 @@ typeck-explicit-generic-args-with-impl-trait =
|
||||
cannot provide explicit generic arguments when `impl Trait` is used in argument position
|
||||
.label = explicit generic argument not allowed
|
||||
.note = see issue #83701 <https://github.com/rust-lang/rust/issues/83701> for more information
|
||||
|
||||
typeck-explicit-generic-args-with-impl-trait-feature =
|
||||
add `#![feature(explicit_generic_args_with_impl_trait)]` to the crate attributes to enable
|
||||
.help = add `#![feature(explicit_generic_args_with_impl_trait)]` to the crate attributes to enable
|
||||
|
||||
@@ -3,10 +3,7 @@
|
||||
AstConv, CreateSubstsForGenericArgsCtxt, ExplicitLateBound, GenericArgCountMismatch,
|
||||
GenericArgCountResult, GenericArgPosition,
|
||||
};
|
||||
use crate::errors::{
|
||||
AssocTypeBindingNotAllowed, ExplicitGenericArgsWithImplTrait,
|
||||
ExplicitGenericArgsWithImplTraitFeature,
|
||||
};
|
||||
use crate::errors::{AssocTypeBindingNotAllowed, ExplicitGenericArgsWithImplTrait};
|
||||
use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs};
|
||||
use rustc_ast::ast::ParamKindOrd;
|
||||
use rustc_errors::{struct_span_err, Applicability, Diagnostic, MultiSpan};
|
||||
@@ -639,11 +636,10 @@ pub(crate) fn check_impl_trait(
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let mut err = tcx.sess.create_err(ExplicitGenericArgsWithImplTrait { spans });
|
||||
if tcx.sess.is_nightly_build() {
|
||||
err.subdiagnostic(ExplicitGenericArgsWithImplTraitFeature);
|
||||
}
|
||||
err.emit();
|
||||
tcx.sess.emit_err(ExplicitGenericArgsWithImplTrait {
|
||||
spans,
|
||||
is_nightly_build: tcx.sess.is_nightly_build().then_some(()),
|
||||
});
|
||||
}
|
||||
|
||||
impl_trait
|
||||
|
||||
@@ -247,8 +247,6 @@ pub struct ExplicitGenericArgsWithImplTrait {
|
||||
#[primary_span]
|
||||
#[label]
|
||||
pub spans: Vec<Span>,
|
||||
#[help]
|
||||
pub is_nightly_build: Option<()>,
|
||||
}
|
||||
|
||||
#[derive(SessionSubdiagnostic)]
|
||||
#[help(slug = "typeck-explicit-generic-args-with-impl-trait-feature")]
|
||||
pub struct ExplicitGenericArgsWithImplTraitFeature;
|
||||
|
||||
Reference in New Issue
Block a user