rust-lang / rust-lang/rust

Should `#[expect(warnings)]` at some point warn that there are no warnings in the annotated code?

Open
#130,609 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics A-lints C-bug F-lint_reasons T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
#[expect(warnings)]
pub fn foo() {}
Current output

rustc is happy with an expect annotation on code, that does not trigger a warning

Desired output

probably this should ask to remove the expect annotation?

Rationale and extra context

expect(warnings) is probably not the most idiomatic thing to do, but I found it in my code. And I would think that this behaves like other expect annotations.

Other cases

No response

Rust Version
rustc 1.83.0-nightly (f79a912d9 2024-09-18)
binary: rustc
commit-hash: f79a912d9edc3ad4db910c0e93672ed5c65133fa
commit-date: 2024-09-18
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0
Anything else?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the annotated foo example with the reported nightly rustc version and compare its behavior with other #[expect(...)] annotations. Determine the intended handling for an expectation covering no warnings, then verify the chosen behavior with compiler tests; done means the behavior is specified and consistently tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.