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
15 changes: 11 additions & 4 deletions src/bin/cargo/commands/tree.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::cli;
use crate::command_prelude::*;
use annotate_snippets::Level;
use anyhow::{bail, format_err};
use cargo::core::dependency::DepKind;
use cargo::ops::Packages;
Expand Down Expand Up @@ -141,10 +142,16 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {

let no_dedupe = args.flag("no-dedupe") || args.flag("all");
if args.flag("all") {
gctx.shell().warn(
"The `cargo tree` --all flag has been changed to --no-dedupe, \
and may be removed in a future version.\n\
If you are looking to display all workspace members, use the --workspace flag.",
gctx.shell().print_report(
&[Level::WARNING
.secondary_title(
"the `cargo tree` --all flag has been changed to --no-dedupe, \
and may be removed in a future version",
)
.element(Level::HELP.message(
"if you are looking to display all workspace members, use the --workspace flag",
))],
false,
)?;
}

Expand Down
22 changes: 15 additions & 7 deletions src/cargo/ops/cargo_compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ use crate::util::interning::InternedString;
use crate::util::{CargoResult, StableHasher};

mod compile_filter;
use annotate_snippets::Level;
pub use compile_filter::{CompileFilter, FilterRule, LibRule};

pub(super) mod unit_generator;
Expand Down Expand Up @@ -230,17 +231,24 @@ pub fn create_bcx<'a, 'gctx>(
match build_config.intent {
UserIntent::Test | UserIntent::Build | UserIntent::Check { .. } | UserIntent::Bench => {
if ws.gctx().get_env("RUST_FLAGS").is_ok() {
gctx.shell()
.warn("ignoring environment variable `RUST_FLAGS`")?;
gctx.shell().note("rust flags are passed via `RUSTFLAGS`")?;
gctx.shell().print_report(
&[Level::WARNING
.secondary_title("ignoring environment variable `RUST_FLAGS`")
.element(Level::HELP.message("rust flags are passed via `RUSTFLAGS`"))],
false,
)?;
}
}
UserIntent::Doc { .. } | UserIntent::Doctest => {
if ws.gctx().get_env("RUSTDOC_FLAGS").is_ok() {
gctx.shell()
.warn("ignoring environment variable `RUSTDOC_FLAGS`")?;
gctx.shell()
.note("rustdoc flags are passed via `RUSTDOCFLAGS`")?;
gctx.shell().print_report(
&[Level::WARNING
.secondary_title("ignoring environment variable `RUSTDOC_FLAGS`")
.element(
Level::HELP.message("rustdoc flags are passed via `RUSTDOCFLAGS`"),
)],
false,
)?;
}
}
}
Expand Down
32 changes: 32 additions & 0 deletions tests/testsuite/cargo_tree/dupe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::prelude::*;
use cargo_test_support::file;
use cargo_test_support::project;
use cargo_test_support::registry::Package;
use cargo_test_support::str;

#[cargo_test]
fn case() {
Expand Down Expand Up @@ -34,3 +35,34 @@ fn case() {
.stdout_eq(file!["stdout.term.svg"])
.stderr_eq(file!["stderr.term.svg"]);
}

#[cargo_test]
fn all_flag() {
Package::new("a", "1.0.0").dep("b", "1.0").publish();
Package::new("b", "1.0.0").dep("c", "1.0").publish();
Package::new("c", "1.0.0").publish();

let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"

[dependencies]
a = "1.0"
b = "1.0"
"#,
)
.file("src/lib.rs", "")
.file("build.rs", "fn main() {}")
.build();

p.cargo("tree --all").with_stderr_data(str![[r#"
[WARNING] the `cargo tree` --all flag has been changed to --no-dedupe, and may be removed in a future version
|
= [HELP] if you are looking to display all workspace members, use the --workspace flag
...
"#]]).run();
}
3 changes: 2 additions & 1 deletion tests/testsuite/rustdocflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ fn rustdocflags_misspelled() {
.env("RUSTDOC_FLAGS", "foo")
.with_stderr_data(str![[r#"
[WARNING] ignoring environment variable `RUSTDOC_FLAGS`
[NOTE] rustdoc flags are passed via `RUSTDOCFLAGS`
|
= [HELP] rustdoc flags are passed via `RUSTDOCFLAGS`
...
"#]])
.run();
Expand Down
12 changes: 6 additions & 6 deletions tests/testsuite/rustflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1441,13 +1441,12 @@ fn env_rustflags_misspelled() {
for cmd in &["check", "build", "run", "test", "bench"] {
p.cargo(cmd)
.env("RUST_FLAGS", "foo")
.with_stderr_data(
"\
.with_stderr_data(str![[r#"
[WARNING] ignoring environment variable `RUST_FLAGS`
[NOTE] rust flags are passed via `RUSTFLAGS`
|
= [HELP] rust flags are passed via `RUSTFLAGS`
...
",
)
"#]])
.run();
}
}
Expand All @@ -1473,7 +1472,8 @@ fn env_rustflags_misspelled_build_script() {
.env("RUST_FLAGS", "foo")
.with_stderr_data(str![[r#"
[WARNING] ignoring environment variable `RUST_FLAGS`
[NOTE] rust flags are passed via `RUSTFLAGS`
|
= [HELP] rust flags are passed via `RUSTFLAGS`
[COMPILING] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

Expand Down