mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 23:24:24 +00:00
Fix a couple warnings
This commit is contained in:
parent
cc8c1c0814
commit
7dd3679ac3
2 changed files with 13 additions and 12 deletions
|
@ -757,7 +757,6 @@ fn detect_absurd_comparison<'a>(cx: &LateContext, op: BinOp_, lhs: &'a Expr, rhs
|
|||
use types::ExtremeType::*;
|
||||
use types::AbsurdComparisonResult::*;
|
||||
use utils::comparisons::*;
|
||||
type Extr<'a> = ExtremeExpr<'a>;
|
||||
|
||||
let normalized = normalize_comparison(op, lhs, rhs);
|
||||
let (rel, normalized_lhs, normalized_rhs) = if let Some(val) = normalized {
|
||||
|
@ -772,17 +771,17 @@ fn detect_absurd_comparison<'a>(cx: &LateContext, op: BinOp_, lhs: &'a Expr, rhs
|
|||
Some(match rel {
|
||||
Rel::Lt => {
|
||||
match (lx, rx) {
|
||||
(Some(l @ Extr { which: Maximum, .. }), _) => (l, AlwaysFalse), // max < x
|
||||
(_, Some(r @ Extr { which: Minimum, .. })) => (r, AlwaysFalse), // x < min
|
||||
(Some(l @ ExtremeExpr { which: Maximum, .. }), _) => (l, AlwaysFalse), // max < x
|
||||
(_, Some(r @ ExtremeExpr { which: Minimum, .. })) => (r, AlwaysFalse), // x < min
|
||||
_ => return None,
|
||||
}
|
||||
}
|
||||
Rel::Le => {
|
||||
match (lx, rx) {
|
||||
(Some(l @ Extr { which: Minimum, .. }), _) => (l, AlwaysTrue), // min <= x
|
||||
(Some(l @ Extr { which: Maximum, .. }), _) => (l, InequalityImpossible), //max <= x
|
||||
(_, Some(r @ Extr { which: Minimum, .. })) => (r, InequalityImpossible), // x <= min
|
||||
(_, Some(r @ Extr { which: Maximum, .. })) => (r, AlwaysTrue), // x <= max
|
||||
(Some(l @ ExtremeExpr { which: Minimum, .. }), _) => (l, AlwaysTrue), // min <= x
|
||||
(Some(l @ ExtremeExpr { which: Maximum, .. }), _) => (l, InequalityImpossible), //max <= x
|
||||
(_, Some(r @ ExtremeExpr { which: Minimum, .. })) => (r, InequalityImpossible), // x <= min
|
||||
(_, Some(r @ ExtremeExpr { which: Maximum, .. })) => (r, AlwaysTrue), // x <= max
|
||||
_ => return None,
|
||||
}
|
||||
}
|
||||
|
|
12
src/lib.rs
12
src/lib.rs
|
@ -2,7 +2,6 @@
|
|||
#![feature(plugin_registrar)]
|
||||
#![feature(rustc_private)]
|
||||
#![allow(unknown_lints)]
|
||||
#![feature(borrow_state)]
|
||||
#![allow(missing_docs_in_private_items)]
|
||||
|
||||
extern crate rustc_plugin;
|
||||
|
@ -12,11 +11,14 @@ extern crate clippy_lints;
|
|||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(reg: &mut Registry) {
|
||||
if reg.sess.lint_store.borrow_state() == std::cell::BorrowState::Unused && reg.sess.lint_store.borrow().get_lint_groups().iter().any(|&(s, _, _)| s == "clippy") {
|
||||
reg.sess.struct_warn("running cargo clippy on a crate that also imports the clippy plugin").emit();
|
||||
} else {
|
||||
clippy_lints::register_plugins(reg);
|
||||
if let Ok(lint_store) = reg.sess.lint_store.try_borrow() {
|
||||
if lint_store.get_lint_groups().iter().any(|&(s, _, _)| s == "clippy") {
|
||||
reg.sess.struct_warn("running cargo clippy on a crate that also imports the clippy plugin").emit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
clippy_lints::register_plugins(reg);
|
||||
}
|
||||
|
||||
// only exists to let the dogfood integration test works.
|
||||
|
|
Loading…
Reference in a new issue