-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #13294 - WeiTheShinobi:new_lint_used_underscore_items, …
…r=llogiq Add new lint: `used_underscore_items` Closes #13260 --- changelog: new [`used_underscore_items`] lint against using items with a single leading underscore
- Loading branch information
Showing
7 changed files
with
333 additions
and
55 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pub struct _ExternalStruct {} | ||
|
||
impl _ExternalStruct { | ||
pub fn _foo(self) {} | ||
} | ||
|
||
pub fn _exernal_foo() {} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
//@aux-build:external_item.rs | ||
#![allow(unused)] | ||
#![warn(clippy::used_underscore_items)] | ||
|
||
extern crate external_item; | ||
|
||
// should not lint macro | ||
macro_rules! macro_wrap_func { | ||
() => { | ||
fn _marco_foo() {} | ||
}; | ||
} | ||
|
||
macro_wrap_func!(); | ||
|
||
struct _FooStruct {} | ||
|
||
impl _FooStruct { | ||
fn _method_call(self) {} | ||
} | ||
|
||
fn _foo1() {} | ||
|
||
fn _foo2() -> i32 { | ||
0 | ||
} | ||
|
||
mod a { | ||
pub mod b { | ||
pub mod c { | ||
pub fn _foo3() {} | ||
|
||
pub struct _FooStruct2 {} | ||
|
||
impl _FooStruct2 { | ||
pub fn _method_call(self) {} | ||
} | ||
} | ||
} | ||
} | ||
|
||
fn main() { | ||
_foo1(); | ||
let _ = _foo2(); | ||
a::b::c::_foo3(); | ||
let _ = &_FooStruct {}; | ||
let _ = _FooStruct {}; | ||
|
||
let foo_struct = _FooStruct {}; | ||
foo_struct._method_call(); | ||
|
||
let foo_struct2 = a::b::c::_FooStruct2 {}; | ||
foo_struct2._method_call(); | ||
} | ||
|
||
// should not lint exteranl crate. | ||
// user cannot control how others name their items | ||
fn external_item_call() { | ||
let foo_struct3 = external_item::_ExternalStruct {}; | ||
foo_struct3._foo(); | ||
|
||
external_item::_exernal_foo(); | ||
} |
Oops, something went wrong.