diff options
| author | bors <bors@rust-lang.org> | 2024-02-20 12:05:09 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-20 12:05:09 +0000 |
| commit | 29f87ade9d78d233e85ef6ca2d6153d0d4fd38d6 (patch) | |
| tree | 6224d184fc8bb6bb02ef7ef2838d4114169ddb60 /compiler/rustc_session | |
| parent | cce6a6e22e715bd74455f2560a956ab920c3a914 (diff) | |
| parent | f6f87798439e2ce7861da761b444fe0978335ed9 (diff) | |
Auto merge of #120576 - nnethercote:merge-Diagnostic-DiagnosticBuilder, r=davidtwco
Overhaul `Diagnostic` and `DiagnosticBuilder` Implements the first part of https://github.com/rust-lang/compiler-team/issues/722, which moves functionality and use away from `Diagnostic`, onto `DiagnosticBuilder`. Likely follow-ups: - Move things around, because this PR was written to minimize diff size, so some things end up in sub-optimal places. E.g. `DiagnosticBuilder` has impls in both `diagnostic.rs` and `diagnostic_builder.rs`. - Rename `Diagnostic` as `DiagInner` and `DiagnosticBuilder` as `Diag`. r? `@davidtwco`
Diffstat (limited to 'compiler/rustc_session')
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_session/src/parse.rs | 13 |
2 files changed, 12 insertions, 4 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index ef0512bf686..0a330da87b0 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -2468,6 +2468,9 @@ pub fn parse_externs( )); let adjusted_name = name.replace('-', "_"); if is_ascii_ident(&adjusted_name) { + // FIXME: make this translatable + #[allow(rustc::diagnostic_outside_of_impl)] + #[allow(rustc::untranslatable_diagnostic)] error.help(format!( "consider replacing the dashes with underscores: `{adjusted_name}`" )); diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 701c5bf375f..b011ca4dd50 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -15,7 +15,8 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc}; use rustc_errors::{emitter::SilentEmitter, DiagCtxt}; use rustc_errors::{ - fallback_fluent_bundle, Diagnostic, DiagnosticBuilder, DiagnosticMessage, MultiSpan, StashKey, + fallback_fluent_bundle, DiagnosticBuilder, DiagnosticMessage, EmissionGuarantee, MultiSpan, + StashKey, }; use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures}; use rustc_span::edition::Edition; @@ -156,7 +157,11 @@ pub fn feature_warn_issue( } /// Adds the diagnostics for a feature to an existing error. -pub fn add_feature_diagnostics(err: &mut Diagnostic, sess: &Session, feature: Symbol) { +pub fn add_feature_diagnostics<G: EmissionGuarantee>( + err: &mut DiagnosticBuilder<'_, G>, + sess: &Session, + feature: Symbol, +) { add_feature_diagnostics_for_issue(err, sess, feature, GateIssue::Language, false); } @@ -165,8 +170,8 @@ pub fn add_feature_diagnostics(err: &mut Diagnostic, sess: &Session, feature: Sy /// This variant allows you to control whether it is a library or language feature. /// Almost always, you want to use this for a language feature. If so, prefer /// `add_feature_diagnostics`. -pub fn add_feature_diagnostics_for_issue( - err: &mut Diagnostic, +pub fn add_feature_diagnostics_for_issue<G: EmissionGuarantee>( + err: &mut DiagnosticBuilder<'_, G>, sess: &Session, feature: Symbol, issue: GateIssue, |
