diff options
| author | Xiretza <xiretza@xiretza.xyz> | 2022-12-28 23:21:04 +0100 |
|---|---|---|
| committer | Xiretza <xiretza@xiretza.xyz> | 2023-02-01 21:56:28 +0100 |
| commit | 0d0d36991599d230d4781432391608f9821765fa (patch) | |
| tree | 9c43880852c0a5bf7654766a9994d83a122d7fb9 /compiler/rustc_errors/src | |
| parent | a476683c8478f548adee406e036328412a0f9d19 (diff) | |
| download | rust-0d0d36991599d230d4781432391608f9821765fa.tar.gz rust-0d0d36991599d230d4781432391608f9821765fa.zip | |
Make "use latest edition" subdiagnostic translatable
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic.rs | 37 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 2 |
2 files changed, 1 insertions, 38 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 632f819e584..9ed8ab67431 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -7,7 +7,6 @@ use rustc_data_structures::fx::FxHashMap; use rustc_error_messages::fluent_value_from_str_list_sep_by_and; use rustc_error_messages::FluentValue; use rustc_lint_defs::{Applicability, LintExpectationId}; -use rustc_span::edition::LATEST_STABLE_EDITION; use rustc_span::symbol::Symbol; use rustc_span::{Span, DUMMY_SP}; use std::borrow::Cow; @@ -1071,39 +1070,3 @@ impl PartialEq for Diagnostic { self.keys() == other.keys() } } - -pub enum HelpUseLatestEdition { - Cargo, - Standalone, -} - -impl HelpUseLatestEdition { - pub fn new() -> Self { - if std::env::var_os("CARGO").is_some() { Self::Cargo } else { Self::Standalone } - } -} - -impl AddToDiagnostic for HelpUseLatestEdition { - fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, f: F) - where - F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage, - { - let msg = f( - diag, - match self { - Self::Cargo => { - format!("set `edition = \"{}\"` in `Cargo.toml`", LATEST_STABLE_EDITION) - } - Self::Standalone => { - format!("pass `--edition {}` to `rustc`", LATEST_STABLE_EDITION) - } - } - .into(), - ); - diag.help(msg); - - let msg = - f(diag, "for more on editions, read https://doc.rust-lang.org/edition-guide".into()); - diag.note(msg); - } -} diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 05cfebbfe8a..ec04e865d53 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -378,7 +378,7 @@ pub struct DelayedBugPanic; pub use diagnostic::{ AddToDiagnostic, DecorateLint, Diagnostic, DiagnosticArg, DiagnosticArgValue, DiagnosticId, - DiagnosticStyledString, HelpUseLatestEdition, IntoDiagnosticArg, SubDiagnostic, + DiagnosticStyledString, IntoDiagnosticArg, SubDiagnostic, }; pub use diagnostic_builder::{DiagnosticBuilder, EmissionGuarantee, Noted}; pub use diagnostic_impls::{DiagnosticArgFromDisplay, DiagnosticSymbolList}; |
