Skip to content

Commit ae664f0

Browse files
author
George-lewis
committed
Update diagnostic message
1 parent 6fbe98c commit ae664f0

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

compiler/rustc_session/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ session_feature_diagnostic_help =
2525
add `#![feature({$feature})]` to the crate attributes to enable
2626
2727
session_feature_suggest_upgrade_compiler =
28-
this compiler is version {$version} built on {$date}, consider upgrading?
28+
this compiler was built on {$date}; consider upgrading if it is out of date
2929
3030
session_file_is_not_writeable = output file {$file} is not writeable -- check its permissions
3131

compiler/rustc_session/src/errors.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,14 @@ pub struct FeatureDiagnosticForIssue {
3535
#[derive(Subdiagnostic)]
3636
#[note(session_feature_suggest_upgrade_compiler)]
3737
pub struct SuggestUpgradeCompiler {
38-
version: &'static str,
3938
date: &'static str,
4039
}
4140

4241
impl SuggestUpgradeCompiler {
43-
pub fn new() -> Self {
44-
let version = option_env!("CFG_VERSION").unwrap_or("unknown");
45-
let date = option_env!("CFG_VER_DATE").unwrap_or("unknown");
42+
pub fn new() -> Option<Self> {
43+
let date = option_env!("CFG_VER_DATE")?;
4644

47-
Self { version, date }
45+
Some(Self { date })
4846
}
4947
}
5048

compiler/rustc_session/src/parse.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ pub fn add_feature_diagnostics_for_issue(
186186
err.subdiagnostic(FeatureDiagnosticHelp { feature });
187187
}
188188

189-
err.subdiagnostic(SuggestUpgradeCompiler::new());
189+
if let Some(suggestion) = SuggestUpgradeCompiler::new() {
190+
err.subdiagnostic(suggestion);
191+
}
190192
}
191193
}
192194

0 commit comments

Comments
 (0)