Skip to content

fix(missing_type): ignore macro-generated bodies in missing let type lint#2

Merged
maximedrn merged 6 commits intomasterfrom
dev
Feb 20, 2026
Merged

fix(missing_type): ignore macro-generated bodies in missing let type lint#2
maximedrn merged 6 commits intomasterfrom
dev

Conversation

@maximedrn
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings February 20, 2026 17:17
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 PR fixes the missing_type lint to properly ignore let statements within macro-generated function bodies. Previously, the lint only checked if individual let statements were from macro expansions, but it didn't check if the enclosing function body itself was macro-generated. The PR also includes housekeeping improvements to the .gitignore file.

Changes:

  • Added check to skip linting let statements when the enclosing function body is from a macro expansion
  • Added extern crate rustc_span declaration to support the new check
  • Updated .gitignore to exclude OS-generated files (.DS_Store and Thumbs.db)

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 2 comments.

File Description
rules/missing_type/src/lib.rs Added check for macro-generated enclosing bodies and declared rustc_span extern crate
.gitignore Added entries for OS-generated files (.DS_Store, Thumbs.db)

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

Comment on lines +64 to +65
// Skip if the let statement is from a macro expansion, as it may not
// be possible to determine the type annotation in that case.
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The comment on lines 64-65 is nearly identical to the comment on lines 70-72, but they describe different checks. The first check (lines 60-68) verifies if the enclosing function body is from a macro expansion, while the second check (line 74) verifies if the let statement itself is from a macro expansion. The comment should be updated to clarify this distinction. Consider updating the comment to: "Skip if the enclosing function body is from a macro expansion, as the let statement may be generated by macro code."

Suggested change
// Skip if the let statement is from a macro expansion, as it may not
// be possible to determine the type annotation in that case.
// Skip if the enclosing function body is from a macro expansion, as the
// let statement may be generated by macro code.

Copilot uses AI. Check for mistakes.
Comment on lines +60 to +68
let Some(body_id) = context.enclosing_body else {
return;
};

// Skip if the let statement is from a macro expansion, as it may not
// be possible to determine the type annotation in that case.
if context.tcx.hir_body(body_id).value.span.from_expansion() {
return;
}
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The new check for macro-generated bodies (lines 60-68) lacks test coverage. The UI test file (ui/main.rs) doesn't include any test cases with macro-generated code that would exercise this new logic. Consider adding a test case with a macro that generates a function body containing let statements to ensure this check works as intended and doesn't regress in the future.

Copilot uses AI. Check for mistakes.
@maximedrn maximedrn merged commit b7adf87 into master Feb 20, 2026
1 check passed
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