diff --git a/compiler/rustc_session/messages.ftl b/compiler/rustc_session/messages.ftl index d9e1082eb4157..ce9777860df13 100644 --- a/compiler/rustc_session/messages.ftl +++ b/compiler/rustc_session/messages.ftl @@ -25,7 +25,7 @@ session_feature_diagnostic_help = add `#![feature({$feature})]` to the crate attributes to enable session_feature_suggest_upgrade_compiler = - this compiler is version {$version} built on {$date}, consider upgrading? + this compiler was built on {$date}; consider upgrading if it is out of date session_file_is_not_writeable = output file {$file} is not writeable -- check its permissions diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs index c094c88ba8627..47140218279f2 100644 --- a/compiler/rustc_session/src/errors.rs +++ b/compiler/rustc_session/src/errors.rs @@ -34,16 +34,14 @@ pub struct FeatureDiagnosticForIssue { #[derive(Subdiagnostic)] #[note(session_feature_suggest_upgrade_compiler)] pub struct SuggestUpgradeCompiler { - version: &'static str, date: &'static str, } impl SuggestUpgradeCompiler { - pub fn new() -> Self { - let version = option_env!("CFG_VERSION").unwrap_or("unknown"); - let date = option_env!("CFG_VER_DATE").unwrap_or("unknown"); + pub fn new() -> Option { + let date = option_env!("CFG_VER_DATE")?; - Self { version, date } + Some(Self { date }) } } diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index d249df415198c..9d6918ee8760c 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -185,7 +185,9 @@ pub fn add_feature_diagnostics_for_issue( err.subdiagnostic(FeatureDiagnosticHelp { feature }); } - err.subdiagnostic(SuggestUpgradeCompiler::new()); + if let Some(suggestion) = SuggestUpgradeCompiler::new() { + err.subdiagnostic(suggestion); + } } }