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

Unstable lints passed on command line can only be ungated from source code #113702

Closed
petrochenkov opened this issue Jul 14, 2023 · 2 comments · Fixed by #114959 or #115104
Closed

Unstable lints passed on command line can only be ungated from source code #113702

petrochenkov opened this issue Jul 14, 2023 · 2 comments · Fixed by #114959 or #115104
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lint 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

@petrochenkov
Copy link
Contributor

I tried this code:

rustc hello_world.rs -Wunnameable_types -Zunstable-options

I expected to see this happen:

Successful compilation, no warnings.

Instead, this happened:

$ rustc hello.rs -Wunnameable_types -Zunstable-options
warning: unknown lint: `unnameable_types`
  |
  = note: the `unnameable_types` lint is unstable
  = note: see issue #48054 <https://github.com/rust-lang/rust/issues/48054> for more information
  = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable
  = note: `#[warn(unknown_lints)]` on by default

The warnings can only be removed by

  • either additionally passing -Aunknown_lints, which is bad,
  • or adding #![feature(type_privacy_lints)] to source code of all crates in which we want to enable the lint, which may be dozens or hundreds crates like in case of Enable type privacy lints in rustc #113284, making this alternative even worse than the first one.

Warnings about unstable lints passed from command line should be silence-able from command line as well, with something like -Zunstable-options.

Meta

rustc --version --verbose:

rustc 1.73.0-nightly (7bd81ee19 2023-07-13)
binary: rustc
commit-hash: 7bd81ee1902c049691d0a1f03be5558bee51d100
commit-date: 2023-07-13
host: x86_64-pc-windows-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5
@petrochenkov petrochenkov added the C-bug Category: This is a bug. label Jul 14, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 14, 2023
@bjorn3
Copy link
Member

bjorn3 commented Jul 14, 2023

Does -Zcrate-attr=feature(type_privacy_lints) work?

@petrochenkov
Copy link
Contributor Author

Yep, it does.
And it's sort of better than -Zunstable-options as well.

The diagnostic should at least suggest it if the lint was passed from command line, so I'll keep the issue open.

@Noratrieb Noratrieb added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 29, 2023
compiler-errors added a commit to compiler-errors/rust that referenced this issue Aug 22, 2023
fix rust-lang#113702 emit a proper diagnostic message for unstable lints passed from CLI

Current output:
```bash
$ build/host/stage1/bin/rustc hello.rs -Wunnameable_types
warning: unknown lint: `unnameable_types`
  |
  = note: the `unnameable_types` lint is unstable
  = note: see issue rust-lang#48054 <rust-lang#48054> for more information
  = help: add `-Zcrate-attr="feature(type_privacy_lints)"` to the command-line options to enable
  = note: `#[warn(unknown_lints)]` on by default

warning: 1 warning emitted
```

Previously, the feature gate diagnostic message is like below, which is the same as the message for unstable lints from the root module.

```shell
= help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable
```

Fixes rust-lang#113702
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 22, 2023
…mpiler-errors

Rollup of 6 pull requests

Successful merges:

 - rust-lang#114959 (fix rust-lang#113702 emit a proper diagnostic message for unstable lints passed from CLI)
 - rust-lang#115011 (Warn on elided lifetimes in associated constants (`ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT`))
 - rust-lang#115077 (Do not emit invalid suggestion in E0191 when spans overlap)
 - rust-lang#115087 (Add disclaimer on size assertion macro)
 - rust-lang#115090 (Always use `os-release` rather than `/lib` to detect `NixOS` (bootstrap))
 - rust-lang#115101 (triagebot: add dependency licensing pings)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in d274417 Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lint 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
4 participants