Skip to content

Only first cap-lints argument is used #54282

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

Open
Mark-Simulacrum opened this issue Sep 17, 2018 · 6 comments
Open

Only first cap-lints argument is used #54282

Mark-Simulacrum opened this issue Sep 17, 2018 · 6 comments
Labels
A-CLI Area: Command-line interface (CLI) to the compiler A-frontend Area: Compiler frontend (errors, parsing and HIR) A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Mark-Simulacrum
Copy link
Member

rustc --cap-lints=warn --cap-lints=foo should give an error on the invalid "foo" passed, but currently this does nothing.

It is not completely clear what exact behavior we want on --cap-lints=allow --cap-lints=forbid for example, though.

Currently this means that there's no way to override Cargo's default behavior on dependencies via RUSTFLAGS, for example.

@Mark-Simulacrum Mark-Simulacrum added A-frontend Area: Compiler frontend (errors, parsing and HIR) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 17, 2018
@GuillaumeGomez
Copy link
Member

Shouldn't only the last cap-lints instance be considered instead of just the first one?

@Mark-Simulacrum
Copy link
Member Author

I believe the behavior we determined is that the first one is -- using the last one feels like 'the right thing' but I'm not sure it's feasible to make that change very well.

@GuillaumeGomez
Copy link
Member

We can't know unless we try.

@steveklabnik
Copy link
Member

Triage: given this code:

fn main() {
    100u8 << 10;
}

produces this:

~\tmp> rustc --cap-lints=allow --cap-lints=deny foo.rs
~\tmp> rustc --cap-lints=deny --cap-lints=allow foo.rs
warning: unused bitwise operation that must be used
 --> foo.rs:2:5
  |
2 |     100u8 << 10;
  |     ^^^^^^^^^^^
  |
  = note: `#[warn(unused_must_use)]` on by default

error: attempt to shift left with overflow
 --> foo.rs:2:5
  |
2 |     100u8 << 10;
  |     ^^^^^^^^^^^
  |
  = note: `#[deny(exceeding_bitshifts)]` on by default

That is, nothing has changed, the first parameter wins.

@weihanglo
Copy link
Member

weihanglo commented Jan 12, 2025

Do we ever want to change the behavior?

Cargo probes rustc information with extra rustc calls. If user provides RUSTFLAGS=--cap-lints=allow then some errors will be supressed and Cargo will fail (#116626 (comment)). If we are not able and not going to change, I think we can have a workaround in Cargo by passing an extra --cap-lints to override the user provided one.

Granted, Cargo should communicate with rustc through a better interface :)

@jieyouxu jieyouxu added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-CLI Area: Command-line interface (CLI) to the compiler labels Jan 23, 2025
@jieyouxu
Copy link
Member

jieyouxu commented Jan 23, 2025

This is behavior of a stable compiler flag interacting with each other. If we do change it so last instance takes precedence, can that break users who rely on the first-instance wins behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: Command-line interface (CLI) to the compiler A-frontend Area: Compiler frontend (errors, parsing and HIR) A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants