Skip to content

Commit 1f9d059

Browse files
committed
Convert RUST_FLAGS and RUSTDOC_FLAGS warnings
1 parent 5e6929f commit 1f9d059

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

src/cargo/ops/cargo_compile/mod.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ use crate::util::interning::InternedString;
5858
use crate::util::{CargoResult, StableHasher};
5959

6060
mod compile_filter;
61+
use annotate_snippets::Level;
6162
pub use compile_filter::{CompileFilter, FilterRule, LibRule};
6263

6364
pub(super) mod unit_generator;
@@ -230,17 +231,24 @@ pub fn create_bcx<'a, 'gctx>(
230231
match build_config.intent {
231232
UserIntent::Test | UserIntent::Build | UserIntent::Check { .. } | UserIntent::Bench => {
232233
if ws.gctx().get_env("RUST_FLAGS").is_ok() {
233-
gctx.shell()
234-
.warn("ignoring environment variable `RUST_FLAGS`")?;
235-
gctx.shell().note("rust flags are passed via `RUSTFLAGS`")?;
234+
gctx.shell().print_report(
235+
&[Level::WARNING
236+
.secondary_title("ignoring environment variable `RUST_FLAGS`")
237+
.element(Level::HELP.message("rust flags are passed via `RUSTFLAGS`"))],
238+
false,
239+
)?;
236240
}
237241
}
238242
UserIntent::Doc { .. } | UserIntent::Doctest => {
239243
if ws.gctx().get_env("RUSTDOC_FLAGS").is_ok() {
240-
gctx.shell()
241-
.warn("ignoring environment variable `RUSTDOC_FLAGS`")?;
242-
gctx.shell()
243-
.note("rustdoc flags are passed via `RUSTDOCFLAGS`")?;
244+
gctx.shell().print_report(
245+
&[Level::WARNING
246+
.secondary_title("ignoring environment variable `RUSTDOC_FLAGS`")
247+
.element(
248+
Level::HELP.message("rustdoc flags are passed via `RUSTDOCFLAGS`"),
249+
)],
250+
false,
251+
)?;
244252
}
245253
}
246254
}

tests/testsuite/rustdocflags.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ fn rustdocflags_misspelled() {
116116
.env("RUSTDOC_FLAGS", "foo")
117117
.with_stderr_data(str![[r#"
118118
[WARNING] ignoring environment variable `RUSTDOC_FLAGS`
119-
[NOTE] rustdoc flags are passed via `RUSTDOCFLAGS`
119+
|
120+
= [HELP] rustdoc flags are passed via `RUSTDOCFLAGS`
120121
...
121122
"#]])
122123
.run();

tests/testsuite/rustflags.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,13 +1441,12 @@ fn env_rustflags_misspelled() {
14411441
for cmd in &["check", "build", "run", "test", "bench"] {
14421442
p.cargo(cmd)
14431443
.env("RUST_FLAGS", "foo")
1444-
.with_stderr_data(
1445-
"\
1444+
.with_stderr_data(str![[r#"
14461445
[WARNING] ignoring environment variable `RUST_FLAGS`
1447-
[NOTE] rust flags are passed via `RUSTFLAGS`
1446+
|
1447+
= [HELP] rust flags are passed via `RUSTFLAGS`
14481448
...
1449-
",
1450-
)
1449+
"#]])
14511450
.run();
14521451
}
14531452
}
@@ -1473,7 +1472,8 @@ fn env_rustflags_misspelled_build_script() {
14731472
.env("RUST_FLAGS", "foo")
14741473
.with_stderr_data(str![[r#"
14751474
[WARNING] ignoring environment variable `RUST_FLAGS`
1476-
[NOTE] rust flags are passed via `RUSTFLAGS`
1475+
|
1476+
= [HELP] rust flags are passed via `RUSTFLAGS`
14771477
[COMPILING] foo v0.0.1 ([ROOT]/foo)
14781478
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
14791479

0 commit comments

Comments
 (0)