Conversation
There was a problem hiding this comment.
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_spandeclaration 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.
| // Skip if the let statement is from a macro expansion, as it may not | ||
| // be possible to determine the type annotation in that case. |
There was a problem hiding this comment.
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."
| // 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. |
rules/missing_type/src/lib.rs
Outdated
| 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; | ||
| } |
There was a problem hiding this comment.
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.
No description provided.