Skip to content

Commit db41a15

Browse files
authored
Rollup merge of #150659 - mu001999-contrib:fix/150654, r=Urgau
Add missing translator resources for interface parse_cfg and parse_check_cfg Missing resources leads to the failure of `translate_message`. Fixes #150654
2 parents 0d7f1e1 + 759857c commit db41a15

5 files changed

Lines changed: 37 additions & 2 deletions

File tree

compiler/rustc_interface/src/interface.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ pub(crate) fn parse_cfg(dcx: DiagCtxtHandle<'_>, cfgs: Vec<String>) -> Cfg {
5555
cfgs.into_iter()
5656
.map(|s| {
5757
let psess = ParseSess::emitter_with_note(
58-
vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE],
58+
vec![
59+
crate::DEFAULT_LOCALE_RESOURCE,
60+
rustc_parse::DEFAULT_LOCALE_RESOURCE,
61+
rustc_session::DEFAULT_LOCALE_RESOURCE,
62+
],
5963
format!("this occurred on the command line: `--cfg={s}`"),
6064
);
6165
let filename = FileName::cfg_spec_source_code(&s);
@@ -129,7 +133,11 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch
129133

130134
for s in specs {
131135
let psess = ParseSess::emitter_with_note(
132-
vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE],
136+
vec![
137+
crate::DEFAULT_LOCALE_RESOURCE,
138+
rustc_parse::DEFAULT_LOCALE_RESOURCE,
139+
rustc_session::DEFAULT_LOCALE_RESOURCE,
140+
],
133141
format!("this occurred on the command line: `--check-cfg={s}`"),
134142
);
135143
let filename = FileName::cfg_spec_source_code(&s);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//@ compile-flags: --cfg foo=1x
2+
3+
fn main() {}
4+
5+
//~? ERROR invalid `--cfg` argument
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
error: invalid suffix `x` for number literal
2+
|
3+
= help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)
4+
= note: this occurred on the command line: `--cfg=foo=1x`
5+
6+
error: invalid `--cfg` argument: `foo=1x` (expected `key` or `key="value"`, ensure escaping is appropriate for your shell, try 'key="value"' or key=\"value\")
7+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//@ compile-flags: --check-cfg 'foo=1x'
2+
3+
fn main() {}
4+
5+
//~? ERROR invalid `--check-cfg` argument
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: invalid suffix `x` for number literal
2+
|
3+
= help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)
4+
= note: this occurred on the command line: `--check-cfg=foo=1x`
5+
6+
error: invalid `--check-cfg` argument: `foo=1x`
7+
|
8+
= note: expected `cfg(name, values("value1", "value2", ... "valueN"))`
9+
= note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details
10+

0 commit comments

Comments
 (0)