-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix internal lint checking
match_type
uses
* Check for `is_item` instead * Check consts and statics from external crates * Check for lang items * Check for inherent functions which have the same name as a field
- Loading branch information
Showing
6 changed files
with
289 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub static OPTION: [&str; 3] = ["core", "option", "Option"]; | ||
pub const RESULT: &[&str] = &["core", "result", "Result"]; |
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,43 @@ | ||
// run-rustfix | ||
// aux-build:paths.rs | ||
#![deny(clippy::internal)] | ||
#![feature(rustc_private)] | ||
|
||
extern crate clippy_utils; | ||
extern crate paths; | ||
extern crate rustc_hir; | ||
extern crate rustc_lint; | ||
extern crate rustc_middle; | ||
extern crate rustc_span; | ||
|
||
use clippy_utils::is_item; | ||
use rustc_lint::LateContext; | ||
use rustc_middle::ty::Ty; | ||
|
||
#[allow(unused)] | ||
use rustc_hir::LangItem; | ||
#[allow(unused)] | ||
use rustc_span::sym; | ||
|
||
#[allow(unused)] | ||
static OPTION: [&str; 3] = ["core", "option", "Option"]; | ||
#[allow(unused)] | ||
const RESULT: &[&str] = &["core", "result", "Result"]; | ||
|
||
fn _f<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) { | ||
let _ = is_item(cx, ty, sym::option_type); | ||
let _ = is_item(cx, ty, sym::result_type); | ||
let _ = is_item(cx, ty, sym::result_type); | ||
|
||
#[allow(unused)] | ||
let rc_path = &["alloc", "rc", "Rc"]; | ||
let _ = clippy_utils::is_item(cx, ty, sym::Rc); | ||
|
||
let _ = is_item(cx, ty, sym::option_type); | ||
let _ = is_item(cx, ty, sym::result_type); | ||
|
||
let _ = is_item(cx, ty, LangItem::OwnedBox); | ||
let _ = is_item(cx, ty, sym::maybe_uninit_uninit); | ||
} | ||
|
||
fn main() {} |
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,43 @@ | ||
// run-rustfix | ||
// aux-build:paths.rs | ||
#![deny(clippy::internal)] | ||
#![feature(rustc_private)] | ||
|
||
extern crate clippy_utils; | ||
extern crate paths; | ||
extern crate rustc_hir; | ||
extern crate rustc_lint; | ||
extern crate rustc_middle; | ||
extern crate rustc_span; | ||
|
||
use clippy_utils::is_item; | ||
use rustc_lint::LateContext; | ||
use rustc_middle::ty::Ty; | ||
|
||
#[allow(unused)] | ||
use rustc_hir::LangItem; | ||
#[allow(unused)] | ||
use rustc_span::sym; | ||
|
||
#[allow(unused)] | ||
static OPTION: [&str; 3] = ["core", "option", "Option"]; | ||
#[allow(unused)] | ||
const RESULT: &[&str] = &["core", "result", "Result"]; | ||
|
||
fn _f<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) { | ||
let _ = is_item(cx, ty, &OPTION); | ||
let _ = is_item(cx, ty, RESULT); | ||
let _ = is_item(cx, ty, &["core", "result", "Result"]); | ||
|
||
#[allow(unused)] | ||
let rc_path = &["alloc", "rc", "Rc"]; | ||
let _ = clippy_utils::is_item(cx, ty, rc_path); | ||
|
||
let _ = is_item(cx, ty, &paths::OPTION); | ||
let _ = is_item(cx, ty, paths::RESULT); | ||
|
||
let _ = is_item(cx, ty, &["alloc", "boxed", "Box"]); | ||
let _ = is_item(cx, ty, &["core", "mem", "maybe_uninit", "MaybeUninit", "uninit"]); | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.