Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--message-format doesn't work on "no-op" builds #13384

Closed
glandium opened this issue Feb 1, 2024 · 1 comment
Closed

--message-format doesn't work on "no-op" builds #13384

glandium opened this issue Feb 1, 2024 · 1 comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.

Comments

@glandium
Copy link
Contributor

glandium commented Feb 1, 2024

Problem

When rebuilding with no change, cargo build shows its output in the original format, not the requested one

Steps

$ cargo new foo; cd foo
$ cat <<EOF > src/main.rs
fn main() {
    let a = 1;
}
EOF
$ cargo build
   Compiling foo v0.1.0 (/tmp/testcase/foo)
warning: unused variable: `a`
 --> foo/src/main.rs:2:9
  |
2 |     let a = 1;
  |         ^ help: if this is intentional, prefix it with an underscore: `_a`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: `foo` (bin "foo") generated 1 warning (run `cargo fix --bin "foo"` to apply 1 suggestion)
    Finished dev [optimized + debuginfo] target(s) in 0.16s
$ cargo build --message-format=short
warning: unused variable: `a`
 --> foo/src/main.rs:2:9
  |
2 |     let a = 1;
  |         ^ help: if this is intentional, prefix it with an underscore: `_a`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: `foo` (bin "foo") generated 1 warning (run `cargo fix --bin "foo"` to apply 1 suggestion)
    Finished dev [optimized + debuginfo] target(s) in 0.00s
$ rm -rf target
$ cargo build --message-format=short
   Compiling foo v0.1.0 (/tmp/testcase/foo)
foo/src/main.rs:2:9: warning: unused variable: `a`
warning: `foo` (bin "foo") generated 1 warning (run `cargo fix --bin "foo"` to apply 1 suggestion)
    Finished dev [optimized + debuginfo] target(s) in 0.16s
$ cargo build
foo/src/main.rs:2:9: warning: unused variable: `a`
warning: `foo` (bin "foo") generated 1 warning (run `cargo fix --bin "foo"` to apply 1 suggestion)
    Finished dev [optimized + debuginfo] target(s) in 0.04s

Possible Solution(s)

in a similar manner that altering RUSTFLAGS makes cargo rebuild, a different value of --message-format should probably do so too.

Notes

No response

Version

cargo 1.77.0-nightly (7bb7b5395 2024-01-20)
release: 1.77.0-nightly
commit-hash: 7bb7b539558dc88bea44cee4168b6269bf8177b0
commit-date: 2024-01-20
host: x86_64-unknown-linux-gnu
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 8.5.0-DEV (sys:0.4.70+curl-8.5.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Debian 12 (bookworm) [64-bit]
@glandium glandium added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Feb 1, 2024
@ehuss
Copy link
Contributor

ehuss commented Feb 1, 2024

Thanks for the report! I believe this is a duplicate of #9003, so closing in favor of that.

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants