use syntax::ast::*;
use syntax::codemap::Span;
use syntax::visit::FnKind;
-use utils::{constants, in_external_macro, snippet, snippet_opt, span_help_and_lint, span_lint, span_lint_and_then};
+use crate::utils::{constants, in_external_macro, snippet, snippet_opt, span_help_and_lint, span_lint, span_lint_and_then};
/// **What it does:** Checks for structure field patterns bound to wildcards.
///
impl EarlyLintPass for MiscEarly {
fn check_generics(&mut self, cx: &EarlyContext, gen: &Generics) {
for param in &gen.params {
- if let GenericParam::Type(ref ty) = *param {
- let name = ty.ident.name.as_str();
+ if let GenericParamKind::Type { .. } = param.kind {
+ let name = param.ident.name.as_str();
if constants::BUILTIN_TYPES.contains(&&*name) {
span_lint(
cx,
BUILTIN_TYPE_SHADOW,
- ty.span,
+ param.ident.span,
&format!("This generic shadows the built-in type `{}`", name),
);
}
let type_name = npat.segments
.last()
.expect("A path must have at least one segment")
- .identifier
+ .ident
.name;
for field in pfields {
let mut registered_names: HashMap<String, Span> = HashMap::new();
for arg in &decl.inputs {
- if let PatKind::Ident(_, sp_ident, None) = arg.pat.node {
- let arg_name = sp_ident.node.to_string();
+ if let PatKind::Ident(_, ident, None) = arg.pat.node {
+ let arg_name = ident.name.to_string();
if arg_name.starts_with('_') {
if let Some(correspondence) = registered_names.get(&arg_name[1..]) {
}
match expr.node {
ExprKind::Call(ref paren, _) => if let ExprKind::Paren(ref closure) = paren.node {
- if let ExprKind::Closure(_, _, ref decl, ref block, _) = closure.node {
+ if let ExprKind::Closure(_, _, _, ref decl, ref block, _) = closure.node {
span_lint_and_then(
cx,
REDUNDANT_CLOSURE_CALL,
if_chain! {
if let StmtKind::Local(ref local) = w[0].node;
if let Option::Some(ref t) = local.init;
- if let ExprKind::Closure(_, _, _, _, _) = t.node;
- if let PatKind::Ident(_, sp_ident, _) = local.pat.node;
+ if let ExprKind::Closure(..) = t.node;
+ if let PatKind::Ident(_, ident, _) = local.pat.node;
if let StmtKind::Semi(ref second) = w[1].node;
if let ExprKind::Assign(_, ref call) = second.node;
if let ExprKind::Call(ref closure, _) = call.node;
if let ExprKind::Path(_, ref path) = closure.node;
then {
- if sp_ident.node == (&path.segments[0]).identifier {
+ if ident == path.segments[0].ident {
span_lint(
cx,
REDUNDANT_CLOSURE_CALL,
}
impl MiscEarly {
- fn check_lit(&self, cx: &EarlyContext, lit: &Lit) {
+ fn check_lit(self, cx: &EarlyContext, lit: &Lit) {
if_chain! {
if let LitKind::Int(value, ..) = lit.node;
if let Some(src) = snippet_opt(cx, lit.span);
let mut seen = (false, false);
for ch in src.chars() {
match ch {
- 'a' ... 'f' => seen.0 = true,
- 'A' ... 'F' => seen.1 = true,
+ 'a' ..= 'f' => seen.0 = true,
+ 'A' ..= 'F' => seen.1 = true,
'i' | 'u' => break, // start of suffix already
_ => ()
}