Remove some empty subdiagnostics

This commit is contained in:
Jonathan Brouwer 2026-02-11 19:23:46 +01:00
parent d00ba92259
commit 635dcd819a
No known key found for this signature in database
GPG key ID: 13619B051B673C52
9 changed files with 22 additions and 54 deletions

View file

@ -68,8 +68,7 @@ use crate::creader::CStore;
use crate::errors::{
BadPanicStrategy, CrateDepMultiple, IncompatiblePanicInDropStrategy,
IncompatibleWithImmediateAbort, IncompatibleWithImmediateAbortCore, LibRequired,
NonStaticCrateDep, RequiredPanicStrategy, RlibRequired, RustcDriverHelp, RustcLibRequired,
TwoPanicRuntimes,
NonStaticCrateDep, RequiredPanicStrategy, RlibRequired, RustcLibRequired, TwoPanicRuntimes,
};
pub(crate) fn calculate(tcx: TyCtxt<'_>) -> Dependencies {
@ -318,7 +317,7 @@ fn add_library(
.drain(..)
.map(|cnum| NonStaticCrateDep { crate_name_: tcx.crate_name(cnum) })
.collect(),
rustc_driver_help: linking_to_rustc_driver.then_some(RustcDriverHelp),
rustc_driver_help: linking_to_rustc_driver,
});
}
}

View file

@ -43,8 +43,8 @@ pub struct CrateDepMultiple {
pub crate_name: Symbol,
#[subdiagnostic]
pub non_static_deps: Vec<NonStaticCrateDep>,
#[subdiagnostic]
pub rustc_driver_help: Option<RustcDriverHelp>,
#[help("`feature(rustc_private)` is needed to link to the compiler's `rustc_driver` library")]
pub rustc_driver_help: bool,
}
#[derive(Subdiagnostic)]
@ -54,10 +54,6 @@ pub struct NonStaticCrateDep {
pub crate_name_: Symbol,
}
#[derive(Subdiagnostic)]
#[help("`feature(rustc_private)` is needed to link to the compiler's `rustc_driver` library")]
pub struct RustcDriverHelp;
#[derive(Diagnostic)]
#[diag("cannot link together two panic runtimes: {$prev_name} and {$cur_name}")]
pub struct TwoPanicRuntimes {

View file

@ -2786,12 +2786,14 @@ pub(crate) struct UnknownTokenStart {
pub escaped: String,
#[subdiagnostic]
pub sugg: Option<TokenSubstitution>,
#[subdiagnostic]
pub null: Option<UnknownTokenNull>,
#[help(
"source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used"
)]
pub null: bool,
#[subdiagnostic]
pub repeat: Option<UnknownTokenRepeat>,
#[subdiagnostic]
pub invisible: Option<InvisibleCharacter>,
#[help("invisible characters like '{$escaped}' are not usually visible in text editors")]
pub invisible: bool,
}
#[derive(Subdiagnostic)]
@ -2837,16 +2839,6 @@ pub(crate) struct UnknownTokenRepeat {
pub repeats: usize,
}
#[derive(Subdiagnostic)]
#[help("invisible characters like '{$escaped}' are not usually visible in text editors")]
pub(crate) struct InvisibleCharacter;
#[derive(Subdiagnostic)]
#[help(
"source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used"
)]
pub(crate) struct UnknownTokenNull;
#[derive(Diagnostic)]
pub(crate) enum UnescapeError {
#[diag("invalid unicode character escape")]

View file

@ -459,8 +459,8 @@ impl<'psess, 'src> Lexer<'psess, 'src> {
span: self.mk_sp(start, self.pos + Pos::from_usize(repeats * c.len_utf8())),
escaped: escaped_char(c),
sugg,
null: if c == '\x00' { Some(errors::UnknownTokenNull) } else { None },
invisible: if INVISIBLE_CHARACTERS.contains(&c) { Some(errors::InvisibleCharacter) } else { None },
null: c == '\x00',
invisible: INVISIBLE_CHARACTERS.contains(&c),
repeat: if repeats > 0 {
swallow_next_invalid = repeats;
Some(errors::UnknownTokenRepeat { repeats })

View file

@ -1015,11 +1015,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
span,
name,
param_kind: is_type,
help: self
.tcx
.sess
.is_nightly_build()
.then_some(errs::ParamInNonTrivialAnonConstHelp),
help: self.tcx.sess.is_nightly_build(),
})
}
ResolutionError::ParamInEnumDiscriminant { name, param_kind: is_type } => self

View file

@ -429,14 +429,10 @@ pub(crate) struct ParamInNonTrivialAnonConst {
pub(crate) name: Symbol,
#[subdiagnostic]
pub(crate) param_kind: ParamKindInNonTrivialAnonConst,
#[subdiagnostic]
pub(crate) help: Option<ParamInNonTrivialAnonConstHelp>,
#[help("add `#![feature(generic_const_exprs)]` to allow generic const expressions")]
pub(crate) help: bool,
}
#[derive(Subdiagnostic)]
#[help("add `#![feature(generic_const_exprs)]` to allow generic const expressions")]
pub(crate) struct ParamInNonTrivialAnonConstHelp;
#[derive(Debug)]
#[derive(Subdiagnostic)]
pub(crate) enum ParamKindInNonTrivialAnonConst {

View file

@ -3510,12 +3510,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
span: lifetime_ref.ident.span,
name: lifetime_ref.ident.name,
param_kind: errors::ParamKindInNonTrivialAnonConst::Lifetime,
help: self
.r
.tcx
.sess
.is_nightly_build()
.then_some(errors::ParamInNonTrivialAnonConstHelp),
help: self.r.tcx.sess.is_nightly_build(),
})
.emit();
}

View file

@ -16,7 +16,7 @@ use tracing::debug;
use crate::error_reporting::infer::nice_region_error::NiceRegionError;
use crate::error_reporting::infer::nice_region_error::placeholder_error::Highlighted;
use crate::errors::{ConsiderBorrowingParamHelp, RelationshipHelp, TraitImplDiff};
use crate::errors::{ConsiderBorrowingParamHelp, TraitImplDiff};
use crate::infer::{RegionResolutionError, ValuePairs};
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
@ -117,7 +117,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
trait_sp,
note: (),
param_help: ConsiderBorrowingParamHelp { spans: visitor.types.to_vec() },
rel_help: visitor.types.is_empty().then_some(RelationshipHelp),
rel_help: visitor.types.is_empty(),
expected,
found,
};

View file

@ -1230,12 +1230,6 @@ impl Subdiagnostic for ConsiderBorrowingParamHelp {
}
}
#[derive(Subdiagnostic)]
#[help(
"verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output"
)]
pub struct RelationshipHelp;
#[derive(Diagnostic)]
#[diag("`impl` item signature doesn't match `trait` item signature")]
pub struct TraitImplDiff {
@ -1251,10 +1245,10 @@ pub struct TraitImplDiff {
pub note: (),
#[subdiagnostic]
pub param_help: ConsiderBorrowingParamHelp,
#[subdiagnostic]
// Seems like subdiagnostics are always pushed to the end, so this one
// also has to be a subdiagnostic to maintain order.
pub rel_help: Option<RelationshipHelp>,
#[help(
"verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output"
)]
pub rel_help: bool,
pub expected: String,
pub found: String,
}