Skip to content

fix: address lint false positives, UI test diffs, and panic detection edge cases#1

Merged
maximedrn merged 5 commits intomasterfrom
dev
Feb 16, 2026
Merged

fix: address lint false positives, UI test diffs, and panic detection edge cases#1
maximedrn merged 5 commits intomasterfrom
dev

Conversation

@maximedrn
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings February 16, 2026 15:55
@maximedrn maximedrn merged commit 8d34340 into master Feb 16, 2026
3 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request addresses multiple issues related to lint false positives and test compatibility: (1) updates UI test configuration to use Rust edition 2024, (2) refactors panic detection logic to use diagnostic items instead of string matching, (3) adds filtering for macro-expanded and desugared code in the missing_type lint, and (4) updates expected test outputs.

Changes:

  • Updated all UI test configurations to include --edition=2024 flag for compatibility
  • Refactored panic_usage lint to use is_diagnostic_item with rustc symbols instead of the PanicKind enum
  • Added macro expansion and desugaring checks to missing_type lint to avoid false positives from async/await and other compiler-generated code
  • Updated UI test expectations to match new panic backend detection messages

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
rules/unsafe_usage/src/lib.rs Added --edition=2024 flag to UI test configuration
rules/panic_usage/ui/main.stderr Updated expected output messages for panic detection (Unwrap/Expect -> unwrap/expect, BeginPanic -> PanicFmt)
rules/panic_usage/src/lib.rs Refactored to use diagnostic items, removed PanicKind enum, added rustc_span::sym import, updated test flags
rules/missing_type/ui/main.rs Added async function test cases to verify lint doesn't trigger on async constructs
rules/missing_type/src/lib.rs Added macro expansion and desugaring filtering, added coroutine detection, updated test flags
rules/indexing_usage/src/lib.rs Added --edition=2024 flag to UI test configuration
.vscode/settings.json Added technical terms (desugared, krate, typeck) to spell-check dictionary

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return;
if context.tcx.is_diagnostic_item(sym::unwrap, def_id)
|| context.tcx.is_diagnostic_item(sym::option_unwrap, def_id)
|| context.tcx.is_diagnostic_item(sym::except, def_id)
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in diagnostic item symbol: sym::except should be sym::expect. This typo prevents the lint from correctly detecting calls to the expect method on Result types. The correct diagnostic item name for the expect method is expect, not except.

Suggested change
|| context.tcx.is_diagnostic_item(sym::except, def_id)
|| context.tcx.is_diagnostic_item(sym::expect, def_id)

Copilot uses AI. Check for mistakes.
Comment on lines +71 to +73
// This checks for method calls where the method name is `unwrap` or
// `expect`, and the method is defined in the local crate (to avoid
// false positives from external crates).
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states "the method is defined in the local crate (to avoid false positives from external crates)" but the code actually checks if the method matches standard library diagnostic items (unwrap, option_unwrap, etc.), which are from external crates. The comment should be updated to accurately reflect that this code detects calls to standard library unwrap/expect methods using diagnostic items.

Copilot uses AI. Check for mistakes.
Comment on lines +81 to +82
|| context.tcx.is_diagnostic_item(sym::except, def_id)
|| context.tcx.is_diagnostic_item(sym::option_expect, def_id)
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code only checks for sym::unwrap and sym::option_unwrap but may be missing Result::unwrap. The standard library provides diagnostic items for both Option and Result versions of these methods. Consider adding checks for sym::result_unwrap and sym::result_expect (if they exist) to ensure complete coverage of panic-inducing methods on both Option and Result types.

Suggested change
|| context.tcx.is_diagnostic_item(sym::except, def_id)
|| context.tcx.is_diagnostic_item(sym::option_expect, def_id)
|| context.tcx.is_diagnostic_item(sym::expect, def_id)
|| context.tcx.is_diagnostic_item(sym::option_expect, def_id)
|| context.tcx.is_diagnostic_item(sym::result_unwrap, def_id)
|| context.tcx.is_diagnostic_item(sym::result_expect, def_id)

Copilot uses AI. Check for mistakes.
Comment on lines +109 to +110
// Skip if the expression is from a macro expansion, as it may not be
// possible to determine the type annotation in that case.
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment "Skip if the expression is from a macro expansion" is inaccurate here. The check from_expansion() was already performed at lines 99-101. This check is actually filtering out coroutines (async blocks, generators), not macro expansions. The comment should be updated to say something like "Skip coroutines (async blocks, generators) as they have compiler-generated state machines with implicit type annotations."

Suggested change
// Skip if the expression is from a macro expansion, as it may not be
// possible to determine the type annotation in that case.
// Skip coroutines (async blocks, generators) as they have
// compiler-generated state machines with implicit type annotations.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants