Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions compiler/rustc_interface/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ pub(crate) fn parse_cfg(dcx: DiagCtxtHandle<'_>, cfgs: Vec<String>) -> Cfg {
cfgs.into_iter()
.map(|s| {
let psess = ParseSess::emitter_with_note(
vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE],
vec![
crate::DEFAULT_LOCALE_RESOURCE,
rustc_parse::DEFAULT_LOCALE_RESOURCE,
rustc_session::DEFAULT_LOCALE_RESOURCE,
],
format!("this occurred on the command line: `--cfg={s}`"),
);
let filename = FileName::cfg_spec_source_code(&s);
Expand Down Expand Up @@ -129,7 +133,11 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch

for s in specs {
let psess = ParseSess::emitter_with_note(
vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE],
vec![
crate::DEFAULT_LOCALE_RESOURCE,
rustc_parse::DEFAULT_LOCALE_RESOURCE,
rustc_session::DEFAULT_LOCALE_RESOURCE,
],
format!("this occurred on the command line: `--check-cfg={s}`"),
);
let filename = FileName::cfg_spec_source_code(&s);
Expand Down
5 changes: 5 additions & 0 deletions tests/ui/cfg/invalid-cli-cfg-pred.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//@ compile-flags: --cfg foo=1x

fn main() {}

//~? ERROR invalid `--cfg` argument
7 changes: 7 additions & 0 deletions tests/ui/cfg/invalid-cli-cfg-pred.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
error: invalid suffix `x` for number literal
|
= help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)
= note: this occurred on the command line: `--cfg=foo=1x`

error: invalid `--cfg` argument: `foo=1x` (expected `key` or `key="value"`, ensure escaping is appropriate for your shell, try 'key="value"' or key=\"value\")

5 changes: 5 additions & 0 deletions tests/ui/cfg/invalid-cli-check-cfg-pred.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//@ compile-flags: --check-cfg 'foo=1x'

fn main() {}

//~? ERROR invalid `--check-cfg` argument
10 changes: 10 additions & 0 deletions tests/ui/cfg/invalid-cli-check-cfg-pred.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: invalid suffix `x` for number literal
|
= help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)
= note: this occurred on the command line: `--check-cfg=foo=1x`

error: invalid `--check-cfg` argument: `foo=1x`
|
= note: expected `cfg(name, values("value1", "value2", ... "valueN"))`
= note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details

Loading