This commit is contained in:
Oliver Schneider
2016-06-10 16:17:20 +02:00
parent 7253ce73bb
commit 4701f13551
21 changed files with 98 additions and 98 deletions

View File

@@ -37,15 +37,15 @@ const KNOWN_CONSTS: &'static [(f64, &'static str, usize)] = &[(f64::E, "E", 4),
(f64::SQRT_2, "SQRT_2", 5)];
#[derive(Copy,Clone)]
pub struct ApproxConstant;
pub struct Pass;
impl LintPass for ApproxConstant {
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(APPROX_CONSTANT)
}
}
impl LateLintPass for ApproxConstant {
impl LateLintPass for Pass {
fn check_expr(&mut self, cx: &LateContext, e: &Expr) {
if let ExprLit(ref lit) = e.node {
check_lit(cx, lit, e);

View File

@@ -80,7 +80,7 @@ pub fn check_attrs<'a>(cx: &EarlyContext, valid_idents: &[String], attrs: &'a [a
}
#[allow(while_let_loop)] // #362
pub fn check_doc(cx: &EarlyContext, valid_idents: &[String], docs: &[(&str, Span)]) -> Result<(), ()> {
fn check_doc(cx: &EarlyContext, valid_idents: &[String], docs: &[(&str, Span)]) -> Result<(), ()> {
// In markdown, `_` can be used to emphasize something, or, is a raw `_` depending on context.
// There really is no markdown specification that would disambiguate this properly. This is
// what GitHub and Rustdoc do:

View File

@@ -23,15 +23,15 @@ declare_lint! {
}
#[allow(missing_copy_implementations)]
pub struct DropRefPass;
pub struct Pass;
impl LintPass for DropRefPass {
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(DROP_REF)
}
}
impl LateLintPass for DropRefPass {
impl LateLintPass for Pass {
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
if let ExprCall(ref path, ref args) = expr.node {
if let ExprPath(None, _) = path.node {

View File

@@ -18,15 +18,15 @@ declare_lint! {
"finds C-like enums that are `repr(isize/usize)` and have values that don't fit into an `i32`"
}
pub struct EnumClikeUnportableVariant;
pub struct UnportableVariant;
impl LintPass for EnumClikeUnportableVariant {
impl LintPass for UnportableVariant {
fn get_lints(&self) -> LintArray {
lint_array!(ENUM_CLIKE_UNPORTABLE_VARIANT)
}
}
impl LateLintPass for EnumClikeUnportableVariant {
impl LateLintPass for UnportableVariant {
#[allow(cast_possible_truncation, cast_sign_loss)]
fn check_item(&mut self, cx: &LateContext, item: &Item) {
if let ItemEnum(ref def, _) = item.node {

View File

@@ -11,7 +11,7 @@ use syntax::ast::NodeId;
use syntax::codemap::Span;
use utils::span_lint;
pub struct EscapePass;
pub struct Pass;
/// **What it does:** This lint checks for usage of `Box<T>` where an unboxed `T` would work fine.
///
@@ -44,13 +44,13 @@ struct EscapeDelegate<'a, 'tcx: 'a> {
set: NodeSet,
}
impl LintPass for EscapePass {
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(BOXED_LOCAL)
}
}
impl LateLintPass for EscapePass {
impl LateLintPass for Pass {
fn check_fn(&mut self, cx: &LateContext, _: visit::FnKind, decl: &FnDecl, body: &Block, _: Span, id: NodeId) {
let param_env = ty::ParameterEnvironment::for_item(cx.tcx, id);

View File

@@ -23,15 +23,15 @@ declare_lint! {
}
#[derive(Copy, Clone, Debug)]
pub struct FormatMacLint;
pub struct Pass;
impl LintPass for FormatMacLint {
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array![USELESS_FORMAT]
}
}
impl LateLintPass for FormatMacLint {
impl LateLintPass for Pass {
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
if let Some(span) = is_expn_of(cx, expr.span, "format") {
match expr.node {

View File

@@ -132,7 +132,7 @@ mod reexport {
#[cfg_attr(rustfmt, rustfmt_skip)]
pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
let conf = match utils::conf::conf_file(reg.args()) {
let conf = match utils::conf::file(reg.args()) {
Ok(file_name) => {
// if the user specified a file, it must exist, otherwise default to `clippy.toml` but
// do not require the file to exist
@@ -142,7 +142,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
("clippy.toml", false)
};
let (conf, errors) = utils::conf::read_conf(file_name, must_exist);
let (conf, errors) = utils::conf::read(file_name, must_exist);
// all conf errors are non-fatal, we just use the default conf in case of error
for error in errors {
@@ -171,14 +171,14 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
reg.register_late_lint_pass(box misc::TopLevelRefPass);
reg.register_late_lint_pass(box misc::CmpNan);
reg.register_late_lint_pass(box eq_op::EqOp);
reg.register_early_lint_pass(box enum_variants::EnumVariantNames);
reg.register_early_lint_pass(box enum_variants::EnumVariantNames::default());
reg.register_late_lint_pass(box enum_glob_use::EnumGlobUse);
reg.register_late_lint_pass(box enum_clike::EnumClikeUnportableVariant);
reg.register_late_lint_pass(box enum_clike::UnportableVariant);
reg.register_late_lint_pass(box bit_mask::BitMask);
reg.register_late_lint_pass(box ptr_arg::PtrArg);
reg.register_late_lint_pass(box needless_bool::NeedlessBool);
reg.register_late_lint_pass(box needless_bool::BoolComparison);
reg.register_late_lint_pass(box approx_const::ApproxConstant);
reg.register_late_lint_pass(box approx_const::Pass);
reg.register_late_lint_pass(box misc::FloatCmp);
reg.register_early_lint_pass(box precedence::Precedence);
reg.register_late_lint_pass(box eta_reduction::EtaPass);
@@ -195,11 +195,11 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
reg.register_late_lint_pass(box unicode::Unicode);
reg.register_late_lint_pass(box strings::StringAdd);
reg.register_early_lint_pass(box returns::ReturnPass);
reg.register_late_lint_pass(box methods::MethodsPass);
reg.register_late_lint_pass(box shadow::ShadowPass);
reg.register_late_lint_pass(box methods::Pass);
reg.register_late_lint_pass(box shadow::Pass);
reg.register_late_lint_pass(box types::LetPass);
reg.register_late_lint_pass(box types::UnitCmp);
reg.register_late_lint_pass(box loops::LoopsPass);
reg.register_late_lint_pass(box loops::Pass);
reg.register_late_lint_pass(box lifetimes::LifetimePass);
reg.register_late_lint_pass(box entry::HashMapLint);
reg.register_late_lint_pass(box ranges::StepByZero);
@@ -208,35 +208,35 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
reg.register_late_lint_pass(box matches::MatchPass);
reg.register_late_lint_pass(box misc::PatternPass);
reg.register_late_lint_pass(box minmax::MinMaxPass);
reg.register_late_lint_pass(box open_options::NonSensicalOpenOptions);
reg.register_late_lint_pass(box zero_div_zero::ZeroDivZeroPass);
reg.register_late_lint_pass(box open_options::NonSensical);
reg.register_late_lint_pass(box zero_div_zero::Pass);
reg.register_late_lint_pass(box mutex_atomic::MutexAtomic);
reg.register_late_lint_pass(box needless_update::NeedlessUpdatePass);
reg.register_late_lint_pass(box needless_update::Pass);
reg.register_late_lint_pass(box needless_borrow::NeedlessBorrow);
reg.register_late_lint_pass(box no_effect::NoEffectPass);
reg.register_late_lint_pass(box map_clone::MapClonePass);
reg.register_late_lint_pass(box temporary_assignment::TemporaryAssignmentPass);
reg.register_late_lint_pass(box no_effect::Pass);
reg.register_late_lint_pass(box map_clone::Pass);
reg.register_late_lint_pass(box temporary_assignment::Pass);
reg.register_late_lint_pass(box transmute::Transmute);
reg.register_late_lint_pass(box cyclomatic_complexity::CyclomaticComplexity::new(conf.cyclomatic_complexity_threshold));
reg.register_late_lint_pass(box escape::EscapePass);
reg.register_late_lint_pass(box escape::Pass);
reg.register_early_lint_pass(box misc_early::MiscEarly);
reg.register_late_lint_pass(box misc::UsedUnderscoreBinding);
reg.register_late_lint_pass(box array_indexing::ArrayIndexing);
reg.register_late_lint_pass(box panic::PanicPass);
reg.register_late_lint_pass(box panic::Pass);
reg.register_late_lint_pass(box strings::StringLitAsBytes);
reg.register_late_lint_pass(box derive::Derive);
reg.register_late_lint_pass(box types::CharLitAsU8);
reg.register_late_lint_pass(box print::PrintLint);
reg.register_late_lint_pass(box vec::UselessVec);
reg.register_late_lint_pass(box print::Pass);
reg.register_late_lint_pass(box vec::Pass);
reg.register_early_lint_pass(box non_expressive_names::NonExpressiveNames {
max_single_char_names: conf.max_single_char_names,
});
reg.register_late_lint_pass(box drop_ref::DropRefPass);
reg.register_late_lint_pass(box drop_ref::Pass);
reg.register_late_lint_pass(box types::AbsurdExtremeComparisons);
reg.register_late_lint_pass(box types::InvalidUpcastComparisons);
reg.register_late_lint_pass(box regex::RegexPass::default());
reg.register_late_lint_pass(box regex::Pass::default());
reg.register_late_lint_pass(box copies::CopyAndPaste);
reg.register_late_lint_pass(box format::FormatMacLint);
reg.register_late_lint_pass(box format::Pass);
reg.register_early_lint_pass(box formatting::Formatting);
reg.register_late_lint_pass(box swap::Swap);
reg.register_early_lint_pass(box if_not_else::IfNotElse);

View File

@@ -205,9 +205,9 @@ declare_lint! {
}
#[derive(Copy, Clone)]
pub struct LoopsPass;
pub struct Pass;
impl LintPass for LoopsPass {
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(NEEDLESS_RANGE_LOOP,
EXPLICIT_ITER_LOOP,
@@ -222,7 +222,7 @@ impl LintPass for LoopsPass {
}
}
impl LateLintPass for LoopsPass {
impl LateLintPass for Pass {
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
if let Some((pat, arg, body)) = recover_for_loop(expr) {
check_for_loop(cx, pat, arg, body, expr);

View File

@@ -18,9 +18,9 @@ declare_lint! {
}
#[derive(Copy, Clone)]
pub struct MapClonePass;
pub struct Pass;
impl LateLintPass for MapClonePass {
impl LateLintPass for Pass {
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
// call to .map()
if let ExprMethodCall(name, _, ref args) = expr.node {
@@ -119,7 +119,7 @@ fn only_derefs(cx: &LateContext, expr: &Expr, id: ast::Name) -> bool {
}
}
impl LintPass for MapClonePass {
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(MAP_CLONE)
}

View File

@@ -17,7 +17,7 @@ use utils::MethodArgs;
use utils::paths;
#[derive(Clone)]
pub struct MethodsPass;
pub struct Pass;
/// **What it does:** This lint checks for `.unwrap()` calls on `Option`s.
///
@@ -336,7 +336,7 @@ declare_lint! {
"using `.iter().nth()` on a slice or Vec"
}
impl LintPass for MethodsPass {
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(EXTEND_FROM_SLICE,
OPTION_UNWRAP_USED,
@@ -359,7 +359,7 @@ impl LintPass for MethodsPass {
}
}
impl LateLintPass for MethodsPass {
impl LateLintPass for Pass {
fn check_expr(&mut self, cx: &LateContext, expr: &hir::Expr) {
if in_macro(cx, expr.span) {
return;

View File

@@ -17,15 +17,15 @@ declare_lint! {
}
#[derive(Copy, Clone)]
pub struct NeedlessUpdatePass;
pub struct Pass;
impl LintPass for NeedlessUpdatePass {
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(NEEDLESS_UPDATE)
}
}
impl LateLintPass for NeedlessUpdatePass {
impl LateLintPass for Pass {
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
if let ExprStruct(_, ref fields, Some(ref base)) = expr.node {
let ty = cx.tcx.expr_ty(expr);

View File

@@ -78,15 +78,15 @@ fn has_no_effect(cx: &LateContext, expr: &Expr) -> bool {
}
#[derive(Copy, Clone)]
pub struct NoEffectPass;
pub struct Pass;
impl LintPass for NoEffectPass {
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(NO_EFFECT, UNNECESSARY_OPERATION)
}
}
impl LateLintPass for NoEffectPass {
impl LateLintPass for Pass {
fn check_stmt(&mut self, cx: &LateContext, stmt: &Stmt) {
if let StmtSemi(ref expr, _) = stmt.node {
if has_no_effect(cx, expr) {

View File

@@ -19,15 +19,15 @@ declare_lint! {
#[derive(Copy,Clone)]
pub struct NonSensicalOpenOptions;
pub struct NonSensical;
impl LintPass for NonSensicalOpenOptions {
impl LintPass for NonSensical {
fn get_lints(&self) -> LintArray {
lint_array!(NONSENSICAL_OPEN_OPTIONS)
}
}
impl LateLintPass for NonSensicalOpenOptions {
impl LateLintPass for NonSensical {
fn check_expr(&mut self, cx: &LateContext, e: &Expr) {
if let ExprMethodCall(ref name, _, ref arguments) = e.node {
let (obj_ty, _) = walk_ptrs_ty_depth(cx.tcx.expr_ty(&arguments[0]));

View File

@@ -17,15 +17,15 @@ declare_lint! {
}
#[allow(missing_copy_implementations)]
pub struct PanicPass;
pub struct Pass;
impl LintPass for PanicPass {
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(PANIC_PARAMS)
}
}
impl LateLintPass for PanicPass {
impl LateLintPass for Pass {
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
if_let_chain! {[
let ExprBlock(ref block) = expr.node,

View File

@@ -31,15 +31,15 @@ declare_lint! {
}
#[derive(Copy, Clone, Debug)]
pub struct PrintLint;
pub struct Pass;
impl LintPass for PrintLint {
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(PRINT_STDOUT, USE_DEBUG)
}
}
impl LateLintPass for PrintLint {
impl LateLintPass for Pass {
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
if let ExprCall(ref fun, ref args) = expr.node {
if let ExprPath(_, ref path) = fun.node {

View File

@@ -56,18 +56,18 @@ declare_lint! {
}
#[derive(Clone, Default)]
pub struct RegexPass {
pub struct Pass {
spans: HashSet<Span>,
last: Option<NodeId>,
}
impl LintPass for RegexPass {
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(INVALID_REGEX, REGEX_MACRO, TRIVIAL_REGEX)
}
}
impl LateLintPass for RegexPass {
impl LateLintPass for Pass {
fn check_crate(&mut self, _: &LateContext, _: &Crate) {
self.spans.clear();
}

View File

@@ -45,15 +45,15 @@ declare_lint! {
}
#[derive(Copy, Clone)]
pub struct ShadowPass;
pub struct Pass;
impl LintPass for ShadowPass {
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(SHADOW_SAME, SHADOW_REUSE, SHADOW_UNRELATED)
}
}
impl LateLintPass for ShadowPass {
impl LateLintPass for Pass {
fn check_fn(&mut self, cx: &LateContext, _: FnKind, decl: &FnDecl, block: &Block, _: Span, _: NodeId) {
if in_external_macro(cx, block.span) {
return;

View File

@@ -24,15 +24,15 @@ fn is_temporary(expr: &Expr) -> bool {
}
#[derive(Copy, Clone)]
pub struct TemporaryAssignmentPass;
pub struct Pass;
impl LintPass for TemporaryAssignmentPass {
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(TEMPORARY_ASSIGNMENT)
}
}
impl LateLintPass for TemporaryAssignmentPass {
impl LateLintPass for Pass {
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
if let ExprAssign(ref target, _) = expr.node {
match target.node {

View File

@@ -5,7 +5,7 @@ use syntax::parse::token;
use toml;
/// Get the configuration file from arguments.
pub fn conf_file(args: &[ptr::P<ast::MetaItem>]) -> Result<Option<token::InternedString>, (&'static str, codemap::Span)> {
pub fn file(args: &[ptr::P<ast::MetaItem>]) -> Result<Option<token::InternedString>, (&'static str, codemap::Span)> {
for arg in args {
match arg.node {
ast::MetaItemKind::Word(ref name) |
@@ -31,18 +31,18 @@ pub fn conf_file(args: &[ptr::P<ast::MetaItem>]) -> Result<Option<token::Interne
/// Error from reading a configuration file.
#[derive(Debug)]
pub enum ConfError {
pub enum Error {
IoError(io::Error),
TomlError(Vec<toml::ParserError>),
TypeError(&'static str, &'static str, &'static str),
UnknownKey(String),
}
impl fmt::Display for ConfError {
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
ConfError::IoError(ref err) => err.fmt(f),
ConfError::TomlError(ref errs) => {
Error::IoError(ref err) => err.fmt(f),
Error::TomlError(ref errs) => {
let mut first = true;
for err in errs {
if !first {
@@ -55,17 +55,17 @@ impl fmt::Display for ConfError {
Ok(())
}
ConfError::TypeError(ref key, ref expected, ref got) => {
Error::TypeError(ref key, ref expected, ref got) => {
write!(f, "`{}` is expected to be a `{}` but is a `{}`", key, expected, got)
}
ConfError::UnknownKey(ref key) => write!(f, "unknown key `{}`", key),
Error::UnknownKey(ref key) => write!(f, "unknown key `{}`", key),
}
}
}
impl From<io::Error> for ConfError {
impl From<io::Error> for Error {
fn from(e: io::Error) -> Self {
ConfError::IoError(e)
Error::IoError(e)
}
}
@@ -87,7 +87,7 @@ macro_rules! define_Conf {
impl Conf {
/// Set the property `name` (which must be the `toml` name) to the given value
#[allow(cast_sign_loss)]
fn set(&mut self, name: String, value: toml::Value) -> Result<(), ConfError> {
fn set(&mut self, name: String, value: toml::Value) -> Result<(), Error> {
match name.as_str() {
$(
define_Conf!(PAT $toml_name) => {
@@ -95,7 +95,7 @@ macro_rules! define_Conf {
self.$rust_name = value;
}
else {
return Err(ConfError::TypeError(define_Conf!(EXPR $toml_name),
return Err(Error::TypeError(define_Conf!(EXPR $toml_name),
stringify!($($ty)+),
value.type_str()));
}
@@ -106,7 +106,7 @@ macro_rules! define_Conf {
return Ok(());
}
_ => {
return Err(ConfError::UnknownKey(name));
return Err(Error::UnknownKey(name));
}
}
@@ -163,7 +163,7 @@ define_Conf! {
/// Read the `toml` configuration file. The function will ignore “File not found” errors iif
/// `!must_exist`, in which case, it will return the default configuration.
/// In case of error, the function tries to continue as much as possible.
pub fn read_conf(path: &str, must_exist: bool) -> (Conf, Vec<ConfError>) {
pub fn read(path: &str, must_exist: bool) -> (Conf, Vec<Error>) {
let mut conf = Conf::default();
let mut errors = Vec::new();
@@ -191,7 +191,7 @@ pub fn read_conf(path: &str, must_exist: bool) -> (Conf, Vec<ConfError>) {
let toml = if let Some(toml) = parser.parse() {
toml
} else {
errors.push(ConfError::TomlError(parser.errors));
errors.push(Error::TomlError(parser.errors));
return (conf, errors);
};

View File

@@ -22,15 +22,15 @@ declare_lint! {
}
#[derive(Copy, Clone, Debug)]
pub struct UselessVec;
pub struct Pass;
impl LintPass for UselessVec {
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(USELESS_VEC)
}
}
impl LateLintPass for UselessVec {
impl LateLintPass for Pass {
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
// search for `&vec![_]` expressions where the adjusted type is `&[_]`
if_let_chain!{[
@@ -51,12 +51,12 @@ impl LateLintPass for UselessVec {
}
fn check_vec_macro(cx: &LateContext, vec: &Expr, span: Span) {
if let Some(vec_args) = unexpand_vec(cx, vec) {
if let Some(vec_args) = unexpand(cx, vec) {
let snippet = match vec_args {
VecArgs::Repeat(elem, len) => {
Args::Repeat(elem, len) => {
format!("&[{}; {}]", snippet(cx, elem.span, "elem"), snippet(cx, len.span, "len")).into()
}
VecArgs::Vec(args) => {
Args::Vec(args) => {
if let Some(last) = args.iter().last() {
let span = Span {
lo: args[0].span.lo,
@@ -78,7 +78,7 @@ fn check_vec_macro(cx: &LateContext, vec: &Expr, span: Span) {
}
/// Represent the pre-expansion arguments of a `vec!` invocation.
pub enum VecArgs<'a> {
pub enum Args<'a> {
/// `vec![elem; len]`
Repeat(&'a P<Expr>, &'a P<Expr>),
/// `vec![a, b, c]`
@@ -86,7 +86,7 @@ pub enum VecArgs<'a> {
}
/// Returns the arguments of the `vec!` macro if this expression was expanded from `vec!`.
pub fn unexpand_vec<'e>(cx: &LateContext, expr: &'e Expr) -> Option<VecArgs<'e>> {
pub fn unexpand<'e>(cx: &LateContext, expr: &'e Expr) -> Option<Args<'e>> {
if_let_chain!{[
let ExprCall(ref fun, ref args) = expr.node,
let ExprPath(_, ref path) = fun.node,
@@ -94,7 +94,7 @@ pub fn unexpand_vec<'e>(cx: &LateContext, expr: &'e Expr) -> Option<VecArgs<'e>>
], {
return if match_path(path, &paths::VEC_FROM_ELEM) && args.len() == 2 {
// `vec![elem; size]` case
Some(VecArgs::Repeat(&args[0], &args[1]))
Some(Args::Repeat(&args[0], &args[1]))
}
else if match_path(path, &["into_vec"]) && args.len() == 1 {
// `vec![a, b, c]` case
@@ -102,7 +102,7 @@ pub fn unexpand_vec<'e>(cx: &LateContext, expr: &'e Expr) -> Option<VecArgs<'e>>
let ExprBox(ref boxed) = args[0].node,
let ExprVec(ref args) = boxed.node
], {
return Some(VecArgs::Vec(&*args));
return Some(Args::Vec(&*args));
}}
None

View File

@@ -3,10 +3,10 @@ use rustc::lint::*;
use rustc::hir::*;
use utils::span_help_and_lint;
/// `ZeroDivZeroPass` is a pass that checks for a binary expression that consists
/// `Pass` is a pass that checks for a binary expression that consists
/// `of 0.0/0.0`, which is always `NaN`. It is more clear to replace instances of
/// `0.0/0.0` with `std::f32::NaN` or `std::f64::NaN`, depending on the precision.
pub struct ZeroDivZeroPass;
pub struct Pass;
/// **What it does:** This lint checks for `0.0 / 0.0`.
///
@@ -21,13 +21,13 @@ declare_lint! {
"usage of `0.0 / 0.0` to obtain NaN instead of std::f32::NaN or std::f64::NaN"
}
impl LintPass for ZeroDivZeroPass {
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(ZERO_DIVIDED_BY_ZERO)
}
}
impl LateLintPass for ZeroDivZeroPass {
impl LateLintPass for Pass {
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
// check for instances of 0.0/0.0
if_let_chain! {[