Rollup merge of #94467 - ibraheemdev:master, r=pnkfelix
Add `special_module_name` lint Declaring `lib` as a module is one of the most common beginner mistakes when trying to setup a binary and library target in the same crate. `special_module_name` lints against it, as well as `mod main;` ``` warning: found module declaration for main.rs --> $DIR/special_module_name.rs:4:1 | LL | mod main; | ^^^^^^^^^ | = note: a binary crate cannot be used as library warning: found module declaration for lib.rs --> $DIR/special_module_name.rs:1:1 | LL | mod lib; | ^^^^^^^^ | = note: `#[warn(special_module_name)]` on by default = note: lib.rs is the root of this crate's library target = help: to refer to it from other targets, use the library's name as the path ``` Note that the help message is not the best in that it doesn't provide an example of an import path (`the_actual_crate_name::`), and doesn't check whether the current file is part of a library/binary target to provide more specific error messages. I'm not sure where this lint would have to be run to access that information.
This commit is contained in:
commit
da1d738601
6 changed files with 135 additions and 0 deletions
|
@ -133,6 +133,7 @@ macro_rules! early_lint_passes {
|
|||
UnusedBraces: UnusedBraces,
|
||||
UnusedImportBraces: UnusedImportBraces,
|
||||
UnsafeCode: UnsafeCode,
|
||||
SpecialModuleName: SpecialModuleName,
|
||||
AnonymousParameters: AnonymousParameters,
|
||||
EllipsisInclusiveRangePatterns: EllipsisInclusiveRangePatterns::default(),
|
||||
NonCamelCaseTypes: NonCamelCaseTypes,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue