Skip to content

Commit

Permalink
Auto merge of #31321 - jseyfried:cleanup, r=nrc
Browse files Browse the repository at this point in the history
The first commit improves detection of unused imports -- it should have been part of #30325. Right now, the unused import in the changed test would not be reported.

The rest of the commits are miscellaneous, independent clean-ups in resolve that I didn't think warranted individual PRs.

r? @nrc
  • Loading branch information
bors committed Feb 5, 2016
2 parents 7bcced7 + 9c166cb commit dcf8ef2
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 290 deletions.
2 changes: 1 addition & 1 deletion src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use front::map as ast_map;
use session::Session;
use util::nodemap::{FnvHashMap, NodeMap, NodeSet};
use middle::cstore::InlinedItem;
use middle::ty::{self, Ty};
use middle::ty;

use std::cell::RefCell;
use std::collections::hash_map::Entry;
Expand Down
1 change: 0 additions & 1 deletion src/librustc_lint/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};
use syntax::{abi, ast};
use syntax::attr::{self, AttrMetaMethods};
use syntax::codemap::{self, Span};
use syntax::ast::{TyIs, TyUs, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};

use rustc_front::hir;
use rustc_front::intravisit::{self, Visitor};
Expand Down
32 changes: 10 additions & 22 deletions src/librustc_resolve/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,29 +142,17 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
}

fn block_needs_anonymous_module(&mut self, block: &Block) -> bool {
// Check each statement.
for statement in &block.stmts {
match statement.node {
StmtDecl(ref declaration, _) => {
match declaration.node {
DeclItem(_) => {
return true;
}
_ => {
// Keep searching.
}
}
}
_ => {
// Keep searching.
fn is_item(statement: &hir::Stmt) -> bool {
if let StmtDecl(ref declaration, _) = statement.node {
if let DeclItem(_) = declaration.node {
return true;
}
}
false
}

// If we found no items, we don't need to create
// an anonymous module.

return false;
// If any statements are items, we need to create an anonymous module
block.stmts.iter().any(is_item)
}

/// Constructs the reduced graph for one item.
Expand Down Expand Up @@ -309,7 +297,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
let external_module = self.new_extern_crate_module(parent_link, def);
self.define(parent, name, TypeNS, (external_module, sp));

self.build_reduced_graph_for_external_crate(&external_module);
self.build_reduced_graph_for_external_crate(external_module);
}
parent
}
Expand Down Expand Up @@ -365,7 +353,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
for variant in &(*enum_definition).variants {
let item_def_id = self.ast_map.local_def_id(item.id);
self.build_reduced_graph_for_variant(variant, item_def_id,
&module, variant_modifiers);
module, variant_modifiers);
}
parent
}
Expand Down Expand Up @@ -421,7 +409,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
};

let modifiers = DefModifiers::PUBLIC; // NB: not DefModifiers::IMPORTABLE
self.define(&module_parent, item.name, ns, (def, item.span, modifiers));
self.define(module_parent, item.name, ns, (def, item.span, modifiers));

self.trait_item_map.insert((item.name, def_id), item_def_id);
}
Expand Down
Loading

0 comments on commit dcf8ef2

Please sign in to comment.