Skip to content

Commit 7dd3679

Browse files
committed
Fix a couple warnings
1 parent cc8c1c0 commit 7dd3679

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

clippy_lints/src/types.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,6 @@ fn detect_absurd_comparison<'a>(cx: &LateContext, op: BinOp_, lhs: &'a Expr, rhs
757757
use types::ExtremeType::*;
758758
use types::AbsurdComparisonResult::*;
759759
use utils::comparisons::*;
760-
type Extr<'a> = ExtremeExpr<'a>;
761760

762761
let normalized = normalize_comparison(op, lhs, rhs);
763762
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
772771
Some(match rel {
773772
Rel::Lt => {
774773
match (lx, rx) {
775-
(Some(l @ Extr { which: Maximum, .. }), _) => (l, AlwaysFalse), // max < x
776-
(_, Some(r @ Extr { which: Minimum, .. })) => (r, AlwaysFalse), // x < min
774+
(Some(l @ ExtremeExpr { which: Maximum, .. }), _) => (l, AlwaysFalse), // max < x
775+
(_, Some(r @ ExtremeExpr { which: Minimum, .. })) => (r, AlwaysFalse), // x < min
777776
_ => return None,
778777
}
779778
}
780779
Rel::Le => {
781780
match (lx, rx) {
782-
(Some(l @ Extr { which: Minimum, .. }), _) => (l, AlwaysTrue), // min <= x
783-
(Some(l @ Extr { which: Maximum, .. }), _) => (l, InequalityImpossible), //max <= x
784-
(_, Some(r @ Extr { which: Minimum, .. })) => (r, InequalityImpossible), // x <= min
785-
(_, Some(r @ Extr { which: Maximum, .. })) => (r, AlwaysTrue), // x <= max
781+
(Some(l @ ExtremeExpr { which: Minimum, .. }), _) => (l, AlwaysTrue), // min <= x
782+
(Some(l @ ExtremeExpr { which: Maximum, .. }), _) => (l, InequalityImpossible), //max <= x
783+
(_, Some(r @ ExtremeExpr { which: Minimum, .. })) => (r, InequalityImpossible), // x <= min
784+
(_, Some(r @ ExtremeExpr { which: Maximum, .. })) => (r, AlwaysTrue), // x <= max
786785
_ => return None,
787786
}
788787
}

src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#![feature(plugin_registrar)]
33
#![feature(rustc_private)]
44
#![allow(unknown_lints)]
5-
#![feature(borrow_state)]
65
#![allow(missing_docs_in_private_items)]
76

87
extern crate rustc_plugin;
@@ -12,11 +11,14 @@ extern crate clippy_lints;
1211

1312
#[plugin_registrar]
1413
pub fn plugin_registrar(reg: &mut Registry) {
15-
if reg.sess.lint_store.borrow_state() == std::cell::BorrowState::Unused && reg.sess.lint_store.borrow().get_lint_groups().iter().any(|&(s, _, _)| s == "clippy") {
16-
reg.sess.struct_warn("running cargo clippy on a crate that also imports the clippy plugin").emit();
17-
} else {
18-
clippy_lints::register_plugins(reg);
14+
if let Ok(lint_store) = reg.sess.lint_store.try_borrow() {
15+
if lint_store.get_lint_groups().iter().any(|&(s, _, _)| s == "clippy") {
16+
reg.sess.struct_warn("running cargo clippy on a crate that also imports the clippy plugin").emit();
17+
return;
18+
}
1919
}
20+
21+
clippy_lints::register_plugins(reg);
2022
}
2123

2224
// only exists to let the dogfood integration test works.

0 commit comments

Comments
 (0)