mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-24 13:43:04 +00:00
Clippy dogfood
This commit is contained in:
parent
8612346de1
commit
af80c53450
@ -50,7 +50,7 @@ pub struct Range<'a> {
|
|||||||
pub fn range<'a, 'b, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'b hir::Expr) -> Option<Range<'b>> {
|
pub fn range<'a, 'b, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'b hir::Expr) -> Option<Range<'b>> {
|
||||||
/// Finds the field named `name` in the field. Always return `Some` for
|
/// Finds the field named `name` in the field. Always return `Some` for
|
||||||
/// convenience.
|
/// convenience.
|
||||||
fn get_field<'a>(name: Symbol, fields: &'a [hir::Field]) -> Option<&'a hir::Expr> {
|
fn get_field(name: Symbol, fields: &[hir::Field]) -> Option<&hir::Expr> {
|
||||||
let expr = &fields.iter().find(|field| field.ident.name == name)?.expr;
|
let expr = &fields.iter().find(|field| field.ident.name == name)?.expr;
|
||||||
|
|
||||||
Some(expr)
|
Some(expr)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use crate::utils::{match_type, match_def_path, paths, span_help_and_lint, span_lint, walk_ptrs_ty};
|
use crate::utils::{match_type, match_def_path, paths, span_help_and_lint, span_lint, walk_ptrs_ty};
|
||||||
use crate::utils::sym;
|
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use rustc::hir::def::{DefKind, Res};
|
use rustc::hir::def::{DefKind, Res};
|
||||||
@ -8,9 +7,8 @@ use rustc::hir::*;
|
|||||||
use rustc::lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintArray, LintPass};
|
use rustc::lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintArray, LintPass};
|
||||||
use rustc::{declare_lint_pass, declare_tool_lint, impl_lint_pass};
|
use rustc::{declare_lint_pass, declare_tool_lint, impl_lint_pass};
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use syntax::ast::{Crate as AstCrate, ItemKind, Name};
|
use syntax::ast::{Crate as AstCrate, Name};
|
||||||
use syntax::source_map::Span;
|
use syntax::source_map::Span;
|
||||||
use syntax::symbol::LocalInternedString;
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// **What it does:** Checks for various things we like to keep tidy in clippy.
|
/// **What it does:** Checks for various things we like to keep tidy in clippy.
|
||||||
@ -76,7 +74,9 @@ declare_clippy_lint! {
|
|||||||
declare_lint_pass!(ClippyLintsInternal => [CLIPPY_LINTS_INTERNAL]);
|
declare_lint_pass!(ClippyLintsInternal => [CLIPPY_LINTS_INTERNAL]);
|
||||||
|
|
||||||
impl EarlyLintPass for ClippyLintsInternal {
|
impl EarlyLintPass for ClippyLintsInternal {
|
||||||
fn check_crate(&mut self, cx: &EarlyContext<'_>, krate: &AstCrate) {
|
fn check_crate(&mut self, _cx: &EarlyContext<'_>, _krate: &AstCrate) {
|
||||||
|
/*
|
||||||
|
FIXME: turn back on when we get rid of all the lazy_statics
|
||||||
if let Some(utils) = krate.module.items.iter().find(|item| item.ident.name == *sym::utils) {
|
if let Some(utils) = krate.module.items.iter().find(|item| item.ident.name == *sym::utils) {
|
||||||
if let ItemKind::Mod(ref utils_mod) = utils.node {
|
if let ItemKind::Mod(ref utils_mod) = utils.node {
|
||||||
if let Some(paths) = utils_mod.items.iter().find(|item| item.ident.name == *sym::paths) {
|
if let Some(paths) = utils_mod.items.iter().find(|item| item.ident.name == *sym::paths) {
|
||||||
@ -101,6 +101,7 @@ impl EarlyLintPass for ClippyLintsInternal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1028,7 +1028,7 @@ pub fn has_iter_method(cx: &LateContext<'_, '_>, probably_ref_ty: Ty<'_>) -> Opt
|
|||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
for path in into_iter_collections.iter() {
|
for path in &into_iter_collections {
|
||||||
if match_def_path(cx, def_id, path) {
|
if match_def_path(cx, def_id, path) {
|
||||||
return Some(*path.last().unwrap());
|
return Some(*path.last().unwrap());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user