Skip to content

Commit e7d153a

Browse files
committed
Auto merge of #4306 - mikerite:fix-breakage-20190730, r=flip1995
Fix breakage due to rust-lang/rust#61856 changelog: none
2 parents dc69a5c + 2f5c1d0 commit e7d153a

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

clippy_lints/src/escape.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc::hir::intravisit as visit;
2-
use rustc::hir::*;
2+
use rustc::hir::{self, *};
33
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
44
use rustc::middle::expr_use_visitor::*;
55
use rustc::middle::mem_categorization::{cmt_, Categorization};
@@ -101,6 +101,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxedLocal {
101101
}
102102
}
103103

104+
// TODO: Replace with Map::is_argument(..) when it's fixed
105+
fn is_argument(map: &hir::map::Map<'_>, id: HirId) -> bool {
106+
match map.find(id) {
107+
Some(Node::Binding(_)) => (),
108+
_ => return false,
109+
}
110+
111+
match map.find(map.get_parent_node(id)) {
112+
Some(Node::Arg(_)) => true,
113+
_ => false,
114+
}
115+
}
116+
104117
impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
105118
fn consume(&mut self, _: HirId, _: Span, cmt: &cmt_<'tcx>, mode: ConsumeMode) {
106119
if let Categorization::Local(lid) = cmt.cat {
@@ -113,11 +126,13 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
113126
fn matched_pat(&mut self, _: &Pat, _: &cmt_<'tcx>, _: MatchMode) {}
114127
fn consume_pat(&mut self, consume_pat: &Pat, cmt: &cmt_<'tcx>, _: ConsumeMode) {
115128
let map = &self.cx.tcx.hir();
116-
if map.is_argument(consume_pat.hir_id) {
129+
if is_argument(map, consume_pat.hir_id) {
117130
// Skip closure arguments
118-
if let Some(Node::Expr(..)) = map.find(map.get_parent_node(consume_pat.hir_id)) {
131+
let parent_id = map.get_parent_node(consume_pat.hir_id);
132+
if let Some(Node::Expr(..)) = map.find(map.get_parent_node(parent_id)) {
119133
return;
120134
}
135+
121136
if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) {
122137
self.set.insert(consume_pat.hir_id);
123138
}

0 commit comments

Comments
 (0)