span_lint_and_then,
};
use if_chain::if_chain;
+use rustc::declare_lint_pass;
use rustc::lint::{in_external_macro, EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
-use rustc::{declare_lint_pass, declare_tool_lint};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::Applicability;
+use rustc_session::declare_tool_lint;
use syntax::ast::*;
use syntax::source_map::Span;
use syntax::visit::{walk_expr, FnKind, Visitor};
}
impl ReturnVisitor {
+ #[must_use]
fn new() -> Self {
Self { found_return: false }
}
);
}
},
- ExprKind::Lit(ref lit) => self.check_lit(cx, lit),
+ ExprKind::Lit(ref lit) => Self::check_lit(cx, lit),
_ => (),
}
}
}
impl MiscEarlyLints {
- fn check_lit(self, cx: &EarlyContext<'_>, lit: &Lit) {
+ fn check_lit(cx: &EarlyContext<'_>, lit: &Lit) {
// We test if first character in snippet is a number, because the snippet could be an expansion
// from a built-in macro like `line!()` or a proc-macro like `#[wasm_bindgen]`.
// Note that this check also covers special case that `line!()` is eagerly expanded by compiler.
if let LitKind::Int(value, lit_int_type) = lit.kind {
let suffix = match lit_int_type {
- LitIntType::Signed(ty) => ty.ty_to_string(),
- LitIntType::Unsigned(ty) => ty.ty_to_string(),
+ LitIntType::Signed(ty) => ty.name_str(),
+ LitIntType::Unsigned(ty) => ty.name_str(),
LitIntType::Unsuffixed => "",
};
},
);
}
- } else if let LitKind::Float(_, float_ty) = lit.kind {
- let suffix = float_ty.ty_to_string();
+ } else if let LitKind::Float(_, LitFloatType::Suffixed(float_ty)) = lit.kind {
+ let suffix = float_ty.name_str();
let maybe_last_sep_idx = lit_snip.len() - suffix.len() - 1;
if lit_snip.as_bytes()[maybe_last_sep_idx] != b'_' {
span_lint_and_sugg(