Skip to content

Commit 96746f9

Browse files
committed
---
yaml --- r: 276461 b: refs/heads/master c: b62e7ff h: refs/heads/master i: 276459: a1befd9
1 parent eed6ceb commit 96746f9

File tree

37 files changed

+1076
-1300
lines changed

37 files changed

+1076
-1300
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 3585321d1ed7665cf2c0d828ff0073844d27d831
2+
refs/heads/master: b62e7ff18d4030ef929226f9b92d83dbc5e67000
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
44
refs/heads/try: 49312a405e14a449b98fe0056b12a40ac128be4a
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

trunk/src/librustc/hir/lowering.rs

Lines changed: 70 additions & 91 deletions
Large diffs are not rendered by default.

trunk/src/librustc/hir/map/definitions.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,6 @@ impl Definitions {
195195
self.opt_def_index(node).map(DefId::local)
196196
}
197197

198-
pub fn local_def_id(&self, node: ast::NodeId) -> DefId {
199-
self.opt_local_def_id(node).unwrap()
200-
}
201-
202198
pub fn as_local_node_id(&self, def_id: DefId) -> Option<ast::NodeId> {
203199
if def_id.krate == LOCAL_CRATE {
204200
assert!(def_id.index.as_usize() < self.data.len());

trunk/src/librustc/hir/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,6 @@ pub type FreevarMap = NodeMap<Vec<Freevar>>;
16391639

16401640
pub type CaptureModeMap = NodeMap<CaptureClause>;
16411641

1642-
#[derive(Clone)]
16431642
pub struct TraitCandidate {
16441643
pub def_id: DefId,
16451644
pub import_id: Option<NodeId>,

trunk/src/librustc/ty/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ pub type Disr = ConstInt;
108108

109109
/// The complete set of all analyses described in this module. This is
110110
/// produced by the driver and fed to trans and later passes.
111-
#[derive(Clone)]
112111
pub struct CrateAnalysis<'a> {
113112
pub export_map: ExportMap,
114113
pub access_levels: middle::privacy::AccessLevels,

trunk/src/librustc_driver/driver.rs

Lines changed: 38 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
use rustc::dep_graph::DepGraph;
1212
use rustc::hir;
13-
use rustc::hir::{map as hir_map, FreevarMap, TraitMap};
14-
use rustc::hir::def::DefMap;
13+
use rustc::hir::map as hir_map;
1514
use rustc_mir as mir;
1615
use rustc::mir::mir_map::MirMap;
1716
use rustc::session::{Session, CompileResult, compile_result_from_err_count};
@@ -61,14 +60,6 @@ use syntax::visit;
6160
use syntax;
6261
use syntax_ext;
6362

64-
#[derive(Clone)]
65-
pub struct Resolutions {
66-
pub def_map: RefCell<DefMap>,
67-
pub freevars: FreevarMap,
68-
pub trait_map: TraitMap,
69-
pub maybe_unused_trait_imports: NodeSet,
70-
}
71-
7263
pub fn compile_input(sess: &Session,
7364
cstore: &CStore,
7465
cfg: ast::CrateConfig,
@@ -148,17 +139,15 @@ pub fn compile_input(sess: &Session,
148139

149140
time(sess.time_passes(),
150141
"external crate/lib resolution",
151-
|| LocalCrateReader::new(sess, &cstore, defs, &expanded_crate, &id)
142+
|| LocalCrateReader::new(sess, &cstore, &defs, &expanded_crate, &id)
152143
.read_crates(&dep_graph));
153144

154-
time(sess.time_passes(),
155-
"early lint checks",
156-
|| lint::check_ast_crate(sess, &expanded_crate));
157-
158-
let (analysis, resolutions, mut hir_forest) = {
159-
let defs = &mut *defs.borrow_mut();
160-
lower_and_resolve(sess, &id, defs, &expanded_crate, dep_graph, control.make_glob_map)
161-
};
145+
// Lower ast -> hir.
146+
let lcx = LoweringContext::new(sess, Some(&expanded_crate), defs);
147+
let hir_forest = &mut time(sess.time_passes(),
148+
"lowering ast -> hir",
149+
|| hir_map::Forest::new(lower_crate(&lcx, &expanded_crate),
150+
dep_graph));
162151

163152
// Discard MTWT tables that aren't required past lowering to HIR.
164153
if !keep_mtwt_tables(sess) {
@@ -168,7 +157,6 @@ pub fn compile_input(sess: &Session,
168157
let arenas = ty::CtxtArenas::new();
169158

170159
// Construct the HIR map
171-
let hir_forest = &mut hir_forest;
172160
let hir_map = time(sess.time_passes(),
173161
"indexing hir",
174162
move || hir_map::map_crate(hir_forest, defs));
@@ -187,8 +175,6 @@ pub fn compile_input(sess: &Session,
187175
&arenas,
188176
&cstore,
189177
&hir_map,
190-
&analysis,
191-
&resolutions,
192178
&expanded_crate,
193179
&hir_map.krate(),
194180
&id),
@@ -199,6 +185,10 @@ pub fn compile_input(sess: &Session,
199185
hir::check_attr::check_crate(sess, &expanded_crate);
200186
});
201187

188+
time(sess.time_passes(),
189+
"early lint checks",
190+
|| lint::check_ast_crate(sess, &expanded_crate));
191+
202192
let opt_crate = if keep_ast(sess) {
203193
Some(&expanded_crate)
204194
} else {
@@ -208,10 +198,9 @@ pub fn compile_input(sess: &Session,
208198

209199
phase_3_run_analysis_passes(sess,
210200
hir_map,
211-
analysis,
212-
resolutions,
213201
&arenas,
214202
&id,
203+
control.make_glob_map,
215204
|tcx, mir_map, analysis, result| {
216205
{
217206
// Eventually, we will want to track plugins.
@@ -364,7 +353,6 @@ pub struct CompileState<'a, 'b, 'ast: 'a, 'tcx: 'b> where 'ast: 'tcx {
364353
pub expanded_crate: Option<&'a ast::Crate>,
365354
pub hir_crate: Option<&'a hir::Crate>,
366355
pub ast_map: Option<&'a hir_map::Map<'ast>>,
367-
pub resolutions: Option<&'a Resolutions>,
368356
pub mir_map: Option<&'b MirMap<'tcx>>,
369357
pub analysis: Option<&'a ty::CrateAnalysis<'a>>,
370358
pub tcx: Option<&'b TyCtxt<'tcx>>,
@@ -389,7 +377,6 @@ impl<'a, 'b, 'ast, 'tcx> CompileState<'a, 'b, 'ast, 'tcx> {
389377
expanded_crate: None,
390378
hir_crate: None,
391379
ast_map: None,
392-
resolutions: None,
393380
analysis: None,
394381
mir_map: None,
395382
tcx: None,
@@ -436,8 +423,6 @@ impl<'a, 'b, 'ast, 'tcx> CompileState<'a, 'b, 'ast, 'tcx> {
436423
arenas: &'ast ty::CtxtArenas<'ast>,
437424
cstore: &'a CStore,
438425
hir_map: &'a hir_map::Map<'ast>,
439-
analysis: &'a ty::CrateAnalysis,
440-
resolutions: &'a Resolutions,
441426
krate: &'a ast::Crate,
442427
hir_crate: &'a hir::Crate,
443428
crate_name: &'a str)
@@ -447,8 +432,6 @@ impl<'a, 'b, 'ast, 'tcx> CompileState<'a, 'b, 'ast, 'tcx> {
447432
arenas: Some(arenas),
448433
cstore: Some(cstore),
449434
ast_map: Some(hir_map),
450-
analysis: Some(analysis),
451-
resolutions: Some(resolutions),
452435
expanded_crate: Some(krate),
453436
hir_crate: Some(hir_crate),
454437
out_file: out_file.as_ref().map(|s| &**s),
@@ -773,48 +756,14 @@ pub fn assign_node_ids(sess: &Session, krate: ast::Crate) -> ast::Crate {
773756
krate
774757
}
775758

776-
pub fn lower_and_resolve<'a>(sess: &Session,
777-
id: &'a str,
778-
defs: &mut hir_map::Definitions,
779-
krate: &ast::Crate,
780-
dep_graph: DepGraph,
781-
make_glob_map: resolve::MakeGlobMap)
782-
-> (ty::CrateAnalysis<'a>, Resolutions, hir_map::Forest) {
783-
resolve::with_resolver(sess, defs, make_glob_map, |mut resolver| {
784-
time(sess.time_passes(), "name resolution", || {
785-
resolve::resolve_crate(&mut resolver, krate);
786-
});
787-
788-
// Lower ast -> hir.
789-
let hir_forest = time(sess.time_passes(), "lowering ast -> hir", || {
790-
let lcx = LoweringContext::new(sess, Some(krate), &mut resolver);
791-
hir_map::Forest::new(lower_crate(&lcx, krate), dep_graph)
792-
});
793-
794-
(ty::CrateAnalysis {
795-
export_map: resolver.export_map,
796-
access_levels: AccessLevels::default(),
797-
reachable: NodeSet(),
798-
name: &id,
799-
glob_map: if resolver.make_glob_map { Some(resolver.glob_map) } else { None },
800-
}, Resolutions {
801-
def_map: RefCell::new(resolver.def_map),
802-
freevars: resolver.freevars,
803-
trait_map: resolver.trait_map,
804-
maybe_unused_trait_imports: resolver.maybe_unused_trait_imports,
805-
}, hir_forest)
806-
})
807-
}
808-
809759
/// Run the resolution, typechecking, region checking and other
810760
/// miscellaneous analysis passes on the crate. Return various
811761
/// structures carrying the results of the analysis.
812762
pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
813763
hir_map: hir_map::Map<'tcx>,
814-
mut analysis: ty::CrateAnalysis,
815-
resolutions: Resolutions,
816764
arenas: &'tcx ty::CtxtArenas<'tcx>,
817765
name: &str,
766+
make_glob_map: resolve::MakeGlobMap,
818767
f: F)
819768
-> Result<R, usize>
820769
where F: FnOnce(&TyCtxt<'tcx>, Option<MirMap<'tcx>>, ty::CrateAnalysis, CompileResult) -> R
@@ -839,11 +788,30 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
839788
})
840789
})?;
841790

791+
let resolve::CrateMap {
792+
def_map,
793+
freevars,
794+
maybe_unused_trait_imports,
795+
export_map,
796+
trait_map,
797+
glob_map,
798+
} = time(sess.time_passes(),
799+
"name resolution",
800+
|| resolve::resolve_crate(sess, &hir_map, make_glob_map));
801+
802+
let mut analysis = ty::CrateAnalysis {
803+
export_map: export_map,
804+
access_levels: AccessLevels::default(),
805+
reachable: NodeSet(),
806+
name: name,
807+
glob_map: glob_map,
808+
};
809+
842810
let named_region_map = time(time_passes,
843811
"lifetime resolution",
844812
|| middle::resolve_lifetime::krate(sess,
845813
&hir_map,
846-
&resolutions.def_map.borrow()))?;
814+
&def_map.borrow()))?;
847815

848816
time(time_passes,
849817
"looking for entry point",
@@ -863,18 +831,17 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
863831

864832
time(time_passes,
865833
"static item recursion checking",
866-
|| static_recursion::check_crate(sess, &resolutions.def_map.borrow(), &hir_map))?;
834+
|| static_recursion::check_crate(sess, &def_map.borrow(), &hir_map))?;
867835

868836
let index = stability::Index::new(&hir_map);
869837

870-
let trait_map = resolutions.trait_map;
871838
TyCtxt::create_and_enter(sess,
872839
arenas,
873-
resolutions.def_map,
840+
def_map,
874841
named_region_map,
875842
hir_map,
876-
resolutions.freevars,
877-
resolutions.maybe_unused_trait_imports,
843+
freevars,
844+
maybe_unused_trait_imports,
878845
region_map,
879846
lang_items,
880847
index,

trunk/src/librustc_driver/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,6 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
469469
control.after_write_deps.callback = box move |state| {
470470
pretty::print_after_write_deps(state.session,
471471
state.ast_map.unwrap(),
472-
state.analysis.unwrap(),
473-
state.resolutions.unwrap(),
474472
state.input,
475473
&state.expanded_crate.take().unwrap(),
476474
state.crate_name.unwrap(),

trunk/src/librustc_driver/pretty.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ pub use self::PpSourceMode::*;
1515
pub use self::PpMode::*;
1616
use self::NodesMatchingUII::*;
1717

18-
use abort_on_err;
19-
use driver::{self, Resolutions};
18+
use {driver, abort_on_err};
2019

2120
use rustc::dep_graph::DepGraph;
2221
use rustc::ty::{self, TyCtxt};
@@ -26,6 +25,7 @@ use rustc::session::Session;
2625
use rustc::session::config::Input;
2726
use rustc_borrowck as borrowck;
2827
use rustc_borrowck::graphviz as borrowck_dot;
28+
use rustc_resolve as resolve;
2929

3030
use rustc_mir::pretty::write_mir_pretty;
3131
use rustc_mir::graphviz::write_mir_graphviz;
@@ -202,8 +202,6 @@ impl PpSourceMode {
202202
fn call_with_pp_support_hir<'tcx, A, B, F>(&self,
203203
sess: &'tcx Session,
204204
ast_map: &hir_map::Map<'tcx>,
205-
analysis: &ty::CrateAnalysis,
206-
resolutions: &Resolutions,
207205
arenas: &'tcx ty::CtxtArenas<'tcx>,
208206
id: &str,
209207
payload: B,
@@ -230,10 +228,9 @@ impl PpSourceMode {
230228
PpmTyped => {
231229
abort_on_err(driver::phase_3_run_analysis_passes(sess,
232230
ast_map.clone(),
233-
analysis.clone(),
234-
resolutions.clone(),
235231
arenas,
236232
id,
233+
resolve::MakeGlobMap::No,
237234
|tcx, _, _, _| {
238235
let annotation = TypedAnnotation {
239236
tcx: tcx,
@@ -814,8 +811,6 @@ pub fn print_after_parsing(sess: &Session,
814811

815812
pub fn print_after_write_deps<'tcx, 'a: 'tcx>(sess: &'a Session,
816813
ast_map: &hir_map::Map<'tcx>,
817-
analysis: &ty::CrateAnalysis,
818-
resolutions: &Resolutions,
819814
input: &Input,
820815
krate: &ast::Crate,
821816
crate_name: &str,
@@ -827,8 +822,7 @@ pub fn print_after_write_deps<'tcx, 'a: 'tcx>(sess: &'a Session,
827822
let _ignore = dep_graph.in_ignore();
828823

829824
if ppm.needs_analysis() {
830-
print_with_analysis(sess, ast_map, analysis, resolutions,
831-
crate_name, arenas, ppm, opt_uii, ofile);
825+
print_with_analysis(sess, ast_map, crate_name, arenas, ppm, opt_uii, ofile);
832826
return;
833827
}
834828

@@ -859,8 +853,6 @@ pub fn print_after_write_deps<'tcx, 'a: 'tcx>(sess: &'a Session,
859853
let out: &mut Write = &mut out;
860854
s.call_with_pp_support_hir(sess,
861855
ast_map,
862-
analysis,
863-
resolutions,
864856
arenas,
865857
crate_name,
866858
box out,
@@ -882,8 +874,6 @@ pub fn print_after_write_deps<'tcx, 'a: 'tcx>(sess: &'a Session,
882874
let out: &mut Write = &mut out;
883875
s.call_with_pp_support_hir(sess,
884876
ast_map,
885-
analysis,
886-
resolutions,
887877
arenas,
888878
crate_name,
889879
(out,uii),
@@ -924,8 +914,6 @@ pub fn print_after_write_deps<'tcx, 'a: 'tcx>(sess: &'a Session,
924914
// Instead, we call that function ourselves.
925915
fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
926916
ast_map: &hir_map::Map<'tcx>,
927-
analysis: &ty::CrateAnalysis,
928-
resolutions: &Resolutions,
929917
crate_name: &str,
930918
arenas: &'tcx ty::CtxtArenas<'tcx>,
931919
ppm: PpMode,
@@ -943,10 +931,9 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
943931

944932
abort_on_err(driver::phase_3_run_analysis_passes(sess,
945933
ast_map.clone(),
946-
analysis.clone(),
947-
resolutions.clone(),
948934
arenas,
949935
crate_name,
936+
resolve::MakeGlobMap::No,
950937
|tcx, mir_map, _, _| {
951938
match ppm {
952939
PpmMir | PpmMirCFG => {

0 commit comments

Comments
 (0)