From 0d0d36991599d230d4781432391608f9821765fa Mon Sep 17 00:00:00 2001 From: Xiretza Date: Wed, 28 Dec 2022 23:21:04 +0100 Subject: Make "use latest edition" subdiagnostic translatable --- compiler/rustc_errors/src/diagnostic.rs | 37 --------------------------------- compiler/rustc_errors/src/lib.rs | 2 +- 2 files changed, 1 insertion(+), 38 deletions(-) (limited to 'compiler/rustc_errors/src') 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(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}; -- cgit 1.4.1-3-g733a5