Skip to content

New lint: empty_expect#16765

Open
konard wants to merge 1 commit intorust-lang:masterfrom
konard:empty-expect-lint
Open

New lint: empty_expect#16765
konard wants to merge 1 commit intorust-lang:masterfrom
konard:empty-expect-lint

Conversation

@konard
Copy link
Copy Markdown

@konard konard commented Mar 26, 2026

Summary

  • Adds new empty_expect lint (category: suspicious)
  • Detects .expect("") calls with empty string message
  • These provide no more context than .unwrap() and are sometimes used to bypass unwrap_used

Test plan

  • Added UI tests for Option::expect("") and Result::expect("")
  • Verified non-empty .expect("msg") does not trigger

Closes #16764

🤖 Generated with Claude Code

Detects `.expect("")` with empty message, which provides no more
context than `.unwrap()` and is sometimes used to bypass
`unwrap_used` lint.

Closes rust-lang#16764

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rustbot rustbot added needs-fcp PRs that add, remove, or rename lints and need an FCP S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Mar 26, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 26, 2026

r? @llogiq

rustbot has assigned @llogiq.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 7 candidates
  • 7 candidates expanded to 7 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 26, 2026

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

@github-actions
Copy link
Copy Markdown

Lintcheck changes for 6373de8

Lint Added Removed Changed
clippy::empty_expect 1 0 0

This comment will be updated if you push new changes

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 28, 2026

☔ The latest upstream changes (possibly #16687) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-fcp PRs that add, remove, or rename lints and need an FCP S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New lint: empty_expect - detect .expect("") with empty message

3 participants