Skip to content

Commit 0e497a7

Browse files
committed
translations(rustc_session): migrates two diagnostics in session.rs
1 parent 24de943 commit 0e497a7

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

compiler/rustc_error_messages/locales/en-US/session.ftl

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ session_feature_diagnostic_for_issue =
1515
session_feature_diagnostic_help =
1616
add `#![feature({$feature})]` to the crate attributes to enable
1717
18-
session_target_data_layout_parse_error = {$err}
19-
2018
session_not_circumvent_feature = `-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature gates, except when testing error paths in the CTFE engine
2119
2220
session_profile_use_file_does_not_exist = file `{$path}` passed to `-C profile-use` does not exist.
@@ -54,3 +52,7 @@ session_target_inconsistent_architecture = inconsistent target specification: "d
5452
session_target_inconsistent_pointer_width = inconsistent target specification: "data-layout" claims pointers are {$pointer_size}-bit, while "target-pointer-width" is `{$target}`
5553
5654
session_target_invalid_bits_size = {$err}
55+
56+
session_target_stack_protector_not_supported = `-Z stack-protector={$stack_protector}` is not supported for target {$target_triple} and will be ignored
57+
58+
session_split_debuginfo_unstable_platform = `-Csplit-debuginfo={$debuginfo}` is unstable on this platform

compiler/rustc_errors/src/diagnostic.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_lint_defs::{Applicability, LintExpectationId};
1010
use rustc_span::edition::LATEST_STABLE_EDITION;
1111
use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, Symbol};
1212
use rustc_span::{edition::Edition, Span, DUMMY_SP};
13-
use rustc_target::spec::PanicStrategy;
13+
use rustc_target::spec::{PanicStrategy, SplitDebuginfo, StackProtector, TargetTriple};
1414
use std::borrow::Cow;
1515
use std::fmt;
1616
use std::hash::{Hash, Hasher};
@@ -93,6 +93,9 @@ into_diagnostic_arg_using_display!(
9393
Ident,
9494
MacroRulesNormalizedIdent,
9595
ParseIntError,
96+
StackProtector,
97+
&TargetTriple,
98+
SplitDebuginfo
9699
);
97100

98101
impl IntoDiagnosticArg for bool {

compiler/rustc_session/src/errors.rs

+14
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_errors::{fluent, DiagnosticBuilder, Handler, MultiSpan};
66
use rustc_macros::SessionDiagnostic;
77
use rustc_span::{Span, Symbol};
88
use rustc_target::abi::TargetDataLayoutErrors;
9+
use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTriple};
910

1011
#[derive(SessionDiagnostic)]
1112
#[diag(session::incorrect_cgu_reuse_type)]
@@ -156,3 +157,16 @@ pub struct UnstableVirtualFunctionElimination;
156157
pub struct UnsupportedDwarfVersion {
157158
pub dwarf_version: u32,
158159
}
160+
161+
#[derive(SessionDiagnostic)]
162+
#[diag(session::target_stack_protector_not_supported)]
163+
pub struct StackProtectorNotSupportedForTarget<'a> {
164+
pub stack_protector: StackProtector,
165+
pub target_triple: &'a TargetTriple,
166+
}
167+
168+
#[derive(SessionDiagnostic)]
169+
#[diag(session::split_debuginfo_unstable_platform)]
170+
pub struct SplitDebugInfoUnstablePlatform {
171+
pub debuginfo: SplitDebuginfo,
172+
}

compiler/rustc_session/src/session.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ use crate::config::{self, CrateType, InstrumentCoverage, OptLevel, OutputType, S
55
use crate::errors::{
66
CannotEnableCrtStaticLinux, CannotMixAndMatchSanitizers, LinkerPluginToWindowsNotSupported,
77
NotCircumventFeature, ProfileSampleUseFileDoesNotExist, ProfileUseFileDoesNotExist,
8-
SanitizerCfiEnabled, SanitizerNotSupported, SanitizersNotSupported, TargetRequiresUnwindTables,
9-
UnstableVirtualFunctionElimination, UnsupportedDwarfVersion,
8+
SanitizerCfiEnabled, SanitizerNotSupported, SanitizersNotSupported,
9+
SplitDebugInfoUnstablePlatform, StackProtectorNotSupportedForTarget,
10+
TargetRequiresUnwindTables, UnstableVirtualFunctionElimination, UnsupportedDwarfVersion,
1011
};
1112
use crate::parse::{add_feature_diagnostics, ParseSess};
1213
use crate::search_paths::{PathKind, SearchPath};
@@ -1544,10 +1545,10 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
15441545

15451546
if sess.opts.unstable_opts.stack_protector != StackProtector::None {
15461547
if !sess.target.options.supports_stack_protector {
1547-
sess.warn(&format!(
1548-
"`-Z stack-protector={}` is not supported for target {} and will be ignored",
1549-
sess.opts.unstable_opts.stack_protector, sess.opts.target_triple
1550-
))
1548+
sess.emit_warning(StackProtectorNotSupportedForTarget {
1549+
stack_protector: sess.opts.unstable_opts.stack_protector,
1550+
target_triple: &sess.opts.target_triple,
1551+
});
15511552
}
15521553
}
15531554

@@ -1560,10 +1561,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
15601561
if !sess.target.options.supported_split_debuginfo.contains(&sess.split_debuginfo())
15611562
&& !sess.opts.unstable_opts.unstable_options
15621563
{
1563-
sess.err(&format!(
1564-
"`-Csplit-debuginfo={}` is unstable on this platform",
1565-
sess.split_debuginfo()
1566-
));
1564+
sess.emit_err(SplitDebugInfoUnstablePlatform { debuginfo: sess.split_debuginfo() });
15671565
}
15681566
}
15691567

0 commit comments

Comments
 (0)