mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Move is_argument check into mutate
This commit is contained in:
parent
3aa531c194
commit
3d39379f9c
@ -113,18 +113,6 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
let map = &self.cx.tcx.hir();
|
||||
if is_argument(map, cmt.hir_id) {
|
||||
// Skip closure arguments
|
||||
let parent_id = map.get_parent_node(cmt.hir_id);
|
||||
if let Some(Node::Expr(..)) = map.find(map.get_parent_node(parent_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) {
|
||||
self.set.insert(cmt.hir_id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if let Categorization::Local(lid) = cmt.cat {
|
||||
if let Some(Node::Binding(_)) = map.find(cmt.hir_id) {
|
||||
if self.set.contains(&lid) {
|
||||
@ -143,7 +131,21 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn mutate(&mut self, _: &cmt_<'tcx>) {}
|
||||
fn mutate(&mut self, cmt: &cmt_<'tcx>) {
|
||||
let map = &self.cx.tcx.hir();
|
||||
if is_argument(map, cmt.hir_id) {
|
||||
// Skip closure arguments
|
||||
let parent_id = map.get_parent_node(cmt.hir_id);
|
||||
if let Some(Node::Expr(..)) = map.find(map.get_parent_node(parent_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) {
|
||||
self.set.insert(cmt.hir_id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> EscapeDelegate<'a, 'tcx> {
|
||||
|
@ -0,0 +1,16 @@
|
||||
error: local variable doesn't need to be boxed here
|
||||
--> $DIR/escape_analysis.rs:39:13
|
||||
|
|
||||
LL | fn warn_arg(x: Box<A>) {
|
||||
| ^
|
||||
|
|
||||
= note: `-D clippy::boxed-local` implied by `-D warnings`
|
||||
|
||||
error: local variable doesn't need to be boxed here
|
||||
--> $DIR/escape_analysis.rs:130:12
|
||||
|
|
||||
LL | pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {}
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
Loading…
Reference in New Issue
Block a user