diff options
| author | David Wood <david.wood@huawei.com> | 2022-05-07 06:05:01 +0100 |
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2022-05-12 07:21:51 +0100 |
| commit | 5685abc96b4e2fa1be05ed4beefb72708c233739 (patch) | |
| tree | 39a7752b19bce13503ec27247a3f64351b667b9c | |
| parent | 7b7061dd898b5a9c06477941e2d0840e27b9c67b (diff) | |
| download | rust-5685abc96b4e2fa1be05ed4beefb72708c233739.tar.gz rust-5685abc96b4e2fa1be05ed4beefb72708c233739.zip | |
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>
| -rw-r--r-- | compiler/rustc_error_messages/locales/en-US/typeck.ftl | 4 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/astconv/generics.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/errors.rs | 6 |
3 files changed, 8 insertions, 16 deletions
diff --git a/compiler/rustc_error_messages/locales/en-US/typeck.ftl b/compiler/rustc_error_messages/locales/en-US/typeck.ftl index 9195d7a2b8f..be1a45fd872 100644 --- a/compiler/rustc_error_messages/locales/en-US/typeck.ftl +++ b/compiler/rustc_error_messages/locales/en-US/typeck.ftl @@ -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 diff --git a/compiler/rustc_typeck/src/astconv/generics.rs b/compiler/rustc_typeck/src/astconv/generics.rs index 38c29d3874c..dc4bc8fb55a 100644 --- a/compiler/rustc_typeck/src/astconv/generics.rs +++ b/compiler/rustc_typeck/src/astconv/generics.rs @@ -3,10 +3,7 @@ use crate::astconv::{ 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 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { }) .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 diff --git a/compiler/rustc_typeck/src/errors.rs b/compiler/rustc_typeck/src/errors.rs index 81d4c9135ef..540fd63e137 100644 --- a/compiler/rustc_typeck/src/errors.rs +++ b/compiler/rustc_typeck/src/errors.rs @@ -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; |
