Skip to content

Commit

Permalink
submodules: update clippy from be5d17f to 868f168
Browse files Browse the repository at this point in the history
Changes:
````
rustup rust-lang/rust#61836
fix suggestion for floating points inequality
````
  • Loading branch information
matthiaskrgr committed Jun 18, 2019
1 parent 1e916c4 commit 3ba9ac9
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn check_hash_peq<'a, 'tcx>(
cx, DERIVE_HASH_XOR_EQ, span,
mess,
|db| {
if let Some(node_id) = cx.tcx.hir().as_local_node_id(impl_id) {
if let Some(node_id) = cx.tcx.hir().as_local_hir_id(impl_id) {
db.span_note(
cx.tcx.hir().span(node_id),
"`PartialEq` implemented here"
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/enum_glob_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EnumGlobUse {
let map = cx.tcx.hir();
// only check top level `use` statements
for item in &m.item_ids {
self.lint_item(cx, map.expect_item(map.hir_to_node_id(item.id)));
self.lint_item(cx, map.expect_item(item.id));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxedLocal {
span_lint(
cx,
BOXED_LOCAL,
cx.tcx.hir().span_by_hir_id(node),
cx.tcx.hir().span(node),
"local variable doesn't need to be boxed here",
);
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
},
TyKind::Def(item, _) => {
let map = self.cx.tcx.hir();
if let ItemKind::Existential(ref exist_ty) = map.expect_item(map.hir_to_node_id(item.id)).node {
if let ItemKind::Existential(ref exist_ty) = map.expect_item(item.id).node {
for bound in &exist_ty.bounds {
if let GenericBound::Outlives(_) = *bound {
self.record(&None);
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods {
}
let name = implitem.ident.name.as_str();
let parent = cx.tcx.hir().get_parent_item(implitem.hir_id);
let item = cx.tcx.hir().expect_item_by_hir_id(parent);
let item = cx.tcx.hir().expect_item(parent);
let def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let ty = cx.tcx.type_of(def_id);
if_chain! {
Expand Down Expand Up @@ -1070,7 +1070,7 @@ fn lint_or_fun_call<'a, 'tcx: 'a>(

if call_found {
// don't lint for constant values
let owner_def = self.cx.tcx.hir().get_parent_did_by_hir_id(expr.hir_id);
let owner_def = self.cx.tcx.hir().get_parent_did(expr.hir_id);
let promotable = self
.cx
.tcx
Expand Down
8 changes: 6 additions & 2 deletions clippy_lints/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MiscLints {
db.span_suggestion(
expr.span,
"consider comparing them within some error",
format!("({}).abs() < error", lhs - rhs),
format!(
"({}).abs() {} error",
lhs - rhs,
if op == BinOpKind::Eq { '<' } else { '>' }
),
Applicability::MachineApplicable, // snippet
);
db.span_note(expr.span, "std::f32::EPSILON and std::f64::EPSILON are available.");
Expand Down Expand Up @@ -601,7 +605,7 @@ fn in_attributes_expansion(expr: &Expr) -> bool {
/// Tests whether `res` is a variable defined outside a macro.
fn non_macro_local(cx: &LateContext<'_, '_>, res: def::Res) -> bool {
if let def::Res::Local(id) = res {
!in_macro_or_desugar(cx.tcx.hir().span_by_hir_id(id))
!in_macro_or_desugar(cx.tcx.hir().span(id))
} else {
false
}
Expand Down
5 changes: 3 additions & 2 deletions clippy_lints/src/new_without_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
if let Some(self_def) = cx.tcx.type_of(self_did).ty_adt_def();
if self_def.did.is_local();
then {
let self_id = cx.tcx.hir().local_def_id_to_node_id(self_def.did.to_local());
if impling_types.contains(&self_id) {
let self_id = cx.tcx.hir().local_def_id_to_hir_id(self_def.did.to_local());
let node_id = cx.tcx.hir().hir_to_node_id(self_id);
if impling_types.contains(&node_id) {
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/non_copy_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst {
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx ImplItem) {
if let ImplItemKind::Const(hir_ty, ..) = &impl_item.node {
let item_hir_id = cx.tcx.hir().get_parent_node_by_hir_id(impl_item.hir_id);
let item = cx.tcx.hir().expect_item_by_hir_id(item_hir_id);
let item = cx.tcx.hir().expect_item(item_hir_id);
// Ensure the impl is an inherent impl.
if let ItemKind::Impl(_, _, _, _, None, _, _) = item.node {
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ pub fn any_parent_is_automatically_derived(tcx: TyCtxt<'_>, node: HirId) -> bool
let mut prev_enclosing_node = None;
let mut enclosing_node = node;
while Some(enclosing_node) != prev_enclosing_node {
if is_automatically_derived(map.attrs_by_hir_id(enclosing_node)) {
if is_automatically_derived(map.attrs(enclosing_node)) {
return true;
}
prev_enclosing_node = Some(enclosing_node);
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/float_cmp.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:60:5
|
LL | ONE as f64 != 2.0;
| ^^^^^^^^^^^^^^^^^ help: consider comparing them within some error: `(ONE as f64 - 2.0).abs() < error`
| ^^^^^^^^^^^^^^^^^ help: consider comparing them within some error: `(ONE as f64 - 2.0).abs() > error`
|
= note: `-D clippy::float-cmp` implied by `-D warnings`
note: std::f32::EPSILON and std::f64::EPSILON are available.
Expand All @@ -27,7 +27,7 @@ error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:68:5
|
LL | twice(x) != twice(ONE as f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some error: `(twice(x) - twice(ONE as f64)).abs() < error`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some error: `(twice(x) - twice(ONE as f64)).abs() > error`
|
note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp.rs:68:5
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/float_cmp_const.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ error: strict comparison of f32 or f64 constant
--> $DIR/float_cmp_const.rs:20:5
|
LL | TWO != ONE;
| ^^^^^^^^^^ help: consider comparing them within some error: `(TWO - ONE).abs() < error`
| ^^^^^^^^^^ help: consider comparing them within some error: `(TWO - ONE).abs() > error`
|
note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp_const.rs:20:5
Expand Down Expand Up @@ -75,7 +75,7 @@ error: strict comparison of f32 or f64 constant
--> $DIR/float_cmp_const.rs:27:5
|
LL | v != ONE;
| ^^^^^^^^ help: consider comparing them within some error: `(v - ONE).abs() < error`
| ^^^^^^^^ help: consider comparing them within some error: `(v - ONE).abs() > error`
|
note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp_const.rs:27:5
Expand Down

0 comments on commit 3ba9ac9

Please sign in to comment.