Add new path_attribute lint - #17798
Closed
GauravPawar101 wants to merge 1 commit into
Closed
GauravPawar101 wants to merge 1 commit into
GauravPawar101 wants to merge 1 commit into
Conversation
Detects use of the built-in `#[path = "..."]` attribute to override the source file of an out-of-line module. With the conventional module layout, a module's source file is predictable from its name, which keeps the module tree navigable for readers and for tooling. `#[path]` breaks that correspondence, and rustc additionally resolves nested `mod` declarations in a `#[path]`-included file relative to that file's directory rather than to a directory named after the module, so the relationship is not just unconventional but easy to get wrong. `#[path]` remains the only way to express a non-standard module layout and is legitimately needed for generated code, platform-specific implementations and tests, so the lint is in the `restriction` group and allow-by-default. Unlike `self_named_module_files`, `mod_module_files` and `inline_modules`, none of which prohibit overriding a module's source path, this lint specifically targets the attribute itself. The lint does not fire for `#[path]` on an inline module, which only changes the directory that nested `mod` declarations resolve against.
Collaborator
|
Thanks for the pull request, and welcome! You should hear from one of our reviewers after this PR gets at least 2 reviews from the community. Please see the contribution instructions for more information. |
|
Lintcheck changes for f4c011d
This comment will be updated if you push new changes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Detects use of the built-in
#[path = "..."]attribute to override the source file of an out-of-line module.With the conventional module layout, a module's source file is predictable from its name, which keeps the module tree navigable for readers and for tooling.
#[path]breaks that correspondence, and rustc additionally resolves nestedmoddeclarations in a#[path]-included file relative to that file's directory rather than to a directory named after the module, so the relationship is not just unconventional but easy to get wrong.#[path]remains the only way to express a non-standard module layout and is legitimately needed for generated code, platform-specific implementations and tests, so the lint is in therestrictiongroup and allow-by-default.Unlike
self_named_module_files,mod_module_filesandinline_modules, none of which prohibit overriding a module's source path, this lint specifically targets the attribute itself.The lint does not fire for
#[path]on an inline module, which only changes the directory that nestedmoddeclarations resolve against.Replaces the closed #17788, whose branch also carried the
useless_attributefixes. This branch now contains only the new lint.