Skip to content

Commit 5ed4eca

Browse files
committed
---
yaml --- r: 273111 b: refs/heads/beta c: 170f470 h: refs/heads/master i: 273109: b0eec00 273107: 2039554 273103: 0ce5b6e
1 parent 3614659 commit 5ed4eca

File tree

33 files changed

+386
-324
lines changed

33 files changed

+386
-324
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: a394d50490bc1f73afeed1d408f6153d267851b2
26+
refs/heads/beta: 170f4708bb48234a2f1a089342b31a424ac94fa9
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/doc/book/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ Cargo checks to see if any of your project’s files have been modified, and onl
501501
rebuilds your project if they’ve changed since the last time you built it.
502502

503503
With simple projects, Cargo doesn't bring a whole lot over just using `rustc`,
504-
but it will become useful in future. This is especially true when you start
504+
but it will become useful in the future. This is especially true when you start
505505
using crates; these are synonymous with a ‘library’ or ‘package’ in other
506506
programming languages. For complex projects composed of multiple crates, it’s
507507
much easier to let Cargo coordinate the build. Using Cargo, you can run `cargo

branches/beta/src/doc/book/if.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Rust’s take on `if` is not particularly complex, but it’s much more like the
44
`if` you’ll find in a dynamically typed language than in a more traditional
55
systems language. So let’s talk about it, to make sure you grasp the nuances.
66

7-
`if` is a specific form of a more general concept, the ‘branch’. The name comes
7+
`if` is a specific form of a more general concept, the ‘branch’, whose name comes
88
from a branch in a tree: a decision point, where depending on a choice,
99
multiple paths can be taken.
1010

branches/beta/src/doc/book/strings.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ let s = "foo\
4444
assert_eq!("foobar", s);
4545
```
4646

47-
Rust has more than only `&str`s though. A `String`, is a heap-allocated string.
47+
Rust has more than only `&str`s though. A `String` is a heap-allocated string.
4848
This string is growable, and is also guaranteed to be UTF-8. `String`s are
4949
commonly created by converting from a string slice using the `to_string`
5050
method.
@@ -89,7 +89,7 @@ Viewing a `String` as a `&str` is cheap, but converting the `&str` to a
8989

9090
## Indexing
9191

92-
Because strings are valid UTF-8, strings do not support indexing:
92+
Because strings are valid UTF-8, they do not support indexing:
9393

9494
```rust,ignore
9595
let s = "hello";

branches/beta/src/librustc/dep_graph/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use self::thread::{DepGraphThreadData, DepMessage};
1212
use middle::def_id::DefId;
13+
use syntax::ast::NodeId;
1314
use middle::ty::TyCtxt;
1415
use rustc_front::hir;
1516
use rustc_front::intravisit::Visitor;
@@ -71,6 +72,7 @@ pub enum DepNode {
7172
IntrinsicCheck(DefId),
7273
MatchCheck(DefId),
7374
MirMapConstruction(DefId),
75+
MirTypeck(NodeId),
7476
BorrowCheck(DefId),
7577
RvalueCheck(DefId),
7678
Reachability,

branches/beta/src/librustc/middle/infer/mod.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,11 +1120,15 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
11201120
.map(|method| resolve_ty(method.ty)))
11211121
}
11221122

1123+
pub fn errors_since_creation(&self) -> bool {
1124+
self.tcx.sess.err_count() - self.err_count_on_creation != 0
1125+
}
1126+
11231127
pub fn node_type(&self, id: ast::NodeId) -> Ty<'tcx> {
11241128
match self.tables.borrow().node_types.get(&id) {
11251129
Some(&t) => t,
11261130
// FIXME
1127-
None if self.tcx.sess.err_count() - self.err_count_on_creation != 0 =>
1131+
None if self.errors_since_creation() =>
11281132
self.tcx.types.err,
11291133
None => {
11301134
self.tcx.sess.bug(
@@ -1147,7 +1151,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
11471151
free_regions: &FreeRegionMap,
11481152
subject_node_id: ast::NodeId) {
11491153
let errors = self.region_vars.resolve_regions(free_regions, subject_node_id);
1150-
self.report_region_errors(&errors); // see error_reporting.rs
1154+
if !self.errors_since_creation() {
1155+
// As a heuristic, just skip reporting region errors
1156+
// altogether if other errors have been reported while
1157+
// this infcx was in use. This is totally hokey but
1158+
// otherwise we have a hard time separating legit region
1159+
// errors from silly ones.
1160+
self.report_region_errors(&errors); // see error_reporting.rs
1161+
}
11511162
}
11521163

11531164
pub fn ty_to_string(&self, t: Ty<'tcx>) -> String {

branches/beta/src/librustc/mir/mir_map.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use dep_graph::DepNode;
1211
use util::nodemap::NodeMap;
1312
use mir::repr::Mir;
14-
use mir::transform::MirPass;
15-
use middle::ty::{self, TyCtxt};
16-
use middle::infer;
1713

1814
pub struct MirMap<'tcx> {
1915
pub map: NodeMap<Mir<'tcx>>,
2016
}
21-
22-
impl<'tcx> MirMap<'tcx> {
23-
pub fn run_passes(&mut self, passes: &mut [Box<MirPass>], tcx: &TyCtxt<'tcx>) {
24-
if passes.is_empty() { return; }
25-
26-
for (&id, mir) in &mut self.map {
27-
let did = tcx.map.local_def_id(id);
28-
let _task = tcx.dep_graph.in_task(DepNode::MirMapConstruction(did));
29-
30-
let param_env = ty::ParameterEnvironment::for_item(tcx, id);
31-
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(param_env));
32-
33-
for pass in &mut *passes {
34-
pass.run_on_mir(mir, &infcx)
35-
}
36-
}
37-
}
38-
}

branches/beta/src/librustc/mir/repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl Debug for BasicBlock {
207207
}
208208

209209
///////////////////////////////////////////////////////////////////////////
210-
// BasicBlock and Terminator
210+
// BasicBlockData and Terminator
211211

212212
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
213213
pub struct BasicBlockData<'tcx> {

branches/beta/src/librustc/mir/transform.rs

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,68 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use mir::mir_map::MirMap;
1112
use mir::repr::Mir;
12-
use middle::infer::InferCtxt;
13+
use middle::ty::TyCtxt;
14+
use syntax::ast::NodeId;
1315

14-
pub trait MirPass {
15-
fn run_on_mir<'a, 'tcx>(&mut self, mir: &mut Mir<'tcx>, infcx: &InferCtxt<'a, 'tcx>);
16+
/// Various information about pass.
17+
pub trait Pass {
18+
// fn name() for printouts of various sorts?
19+
// fn should_run(Session) to check if pass should run?
20+
}
21+
22+
/// A pass which inspects the whole MirMap.
23+
pub trait MirMapPass<'tcx>: Pass {
24+
fn run_pass(&mut self, cx: &TyCtxt<'tcx>, map: &mut MirMap<'tcx>);
25+
}
26+
27+
/// A pass which inspects Mir of functions in isolation.
28+
pub trait MirPass<'tcx>: Pass {
29+
fn run_pass(&mut self, cx: &TyCtxt<'tcx>, id: NodeId, mir: &mut Mir<'tcx>);
30+
}
31+
32+
impl<'tcx, T: MirPass<'tcx>> MirMapPass<'tcx> for T {
33+
fn run_pass(&mut self, tcx: &TyCtxt<'tcx>, map: &mut MirMap<'tcx>) {
34+
for (&id, mir) in &mut map.map {
35+
MirPass::run_pass(self, tcx, id, mir);
36+
}
37+
}
38+
}
39+
40+
/// A manager for MIR passes.
41+
pub struct Passes {
42+
passes: Vec<Box<for<'tcx> MirMapPass<'tcx>>>,
43+
plugin_passes: Vec<Box<for<'tcx> MirMapPass<'tcx>>>
44+
}
45+
46+
impl Passes {
47+
pub fn new() -> Passes {
48+
let passes = Passes {
49+
passes: Vec::new(),
50+
plugin_passes: Vec::new()
51+
};
52+
passes
53+
}
54+
55+
pub fn run_passes<'tcx>(&mut self, pcx: &TyCtxt<'tcx>, map: &mut MirMap<'tcx>) {
56+
for pass in &mut self.plugin_passes {
57+
pass.run_pass(pcx, map);
58+
}
59+
for pass in &mut self.passes {
60+
pass.run_pass(pcx, map);
61+
}
62+
}
63+
64+
/// Pushes a built-in pass.
65+
pub fn push_pass(&mut self, pass: Box<for<'a> MirMapPass<'a>>) {
66+
self.passes.push(pass);
67+
}
68+
}
69+
70+
/// Copies the plugin passes.
71+
impl ::std::iter::Extend<Box<for<'a> MirMapPass<'a>>> for Passes {
72+
fn extend<I: IntoIterator<Item=Box<for <'a> MirMapPass<'a>>>>(&mut self, it: I) {
73+
self.plugin_passes.extend(it);
74+
}
1675
}

branches/beta/src/librustc/session/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
10951095
}
10961096
}
10971097

1098+
if cg.codegen_units < 1 {
1099+
early_error(error_format, "Value for codegen units must be a positive nonzero integer");
1100+
}
1101+
10981102
let cg = cg;
10991103

11001104
let sysroot_opt = matches.opt_str("sysroot").map(|m| PathBuf::from(&m));

branches/beta/src/librustc/session/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use middle::cstore::CrateStore;
1313
use middle::dependency_format;
1414
use session::search_paths::PathKind;
1515
use util::nodemap::{NodeMap, FnvHashMap};
16-
use mir::transform::MirPass;
16+
use mir::transform as mir_pass;
1717

1818
use syntax::ast::{NodeId, NodeIdAssigner, Name};
1919
use syntax::codemap::{Span, MultiSpan};
@@ -60,7 +60,7 @@ pub struct Session {
6060
pub lint_store: RefCell<lint::LintStore>,
6161
pub lints: RefCell<NodeMap<Vec<(lint::LintId, Span, String)>>>,
6262
pub plugin_llvm_passes: RefCell<Vec<String>>,
63-
pub plugin_mir_passes: RefCell<Vec<Box<MirPass>>>,
63+
pub mir_passes: RefCell<mir_pass::Passes>,
6464
pub plugin_attributes: RefCell<Vec<(String, AttributeType)>>,
6565
pub crate_types: RefCell<Vec<config::CrateType>>,
6666
pub dependency_formats: RefCell<dependency_format::Dependencies>,
@@ -477,7 +477,7 @@ pub fn build_session_(sopts: config::Options,
477477
lint_store: RefCell::new(lint::LintStore::new()),
478478
lints: RefCell::new(NodeMap()),
479479
plugin_llvm_passes: RefCell::new(Vec::new()),
480-
plugin_mir_passes: RefCell::new(Vec::new()),
480+
mir_passes: RefCell::new(mir_pass::Passes::new()),
481481
plugin_attributes: RefCell::new(Vec::new()),
482482
crate_types: RefCell::new(Vec::new()),
483483
dependency_formats: RefCell::new(FnvHashMap()),

branches/beta/src/librustc_driver/driver.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
568568
}
569569

570570
*sess.plugin_llvm_passes.borrow_mut() = llvm_passes;
571-
*sess.plugin_mir_passes.borrow_mut() = mir_passes;
571+
sess.mir_passes.borrow_mut().extend(mir_passes);
572572
*sess.plugin_attributes.borrow_mut() = attributes.clone();
573573
}));
574574

@@ -865,9 +865,19 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
865865
"MIR dump",
866866
|| mir::mir_map::build_mir_for_crate(tcx));
867867

868-
time(time_passes,
869-
"MIR passes",
870-
|| mir_map.run_passes(&mut sess.plugin_mir_passes.borrow_mut(), tcx));
868+
time(time_passes, "MIR passes", || {
869+
let mut passes = sess.mir_passes.borrow_mut();
870+
// Push all the built-in passes.
871+
passes.push_pass(box mir::transform::remove_dead_blocks::RemoveDeadBlocks);
872+
passes.push_pass(box mir::transform::type_check::TypeckMir);
873+
passes.push_pass(box mir::transform::simplify_cfg::SimplifyCfg);
874+
// Late passes
875+
passes.push_pass(box mir::transform::no_landing_pads::NoLandingPads);
876+
passes.push_pass(box mir::transform::remove_dead_blocks::RemoveDeadBlocks);
877+
passes.push_pass(box mir::transform::erase_regions::EraseRegions);
878+
// And run everything.
879+
passes.run_passes(tcx, &mut mir_map);
880+
});
871881

872882
time(time_passes,
873883
"borrow checking",
@@ -916,9 +926,8 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
916926
}
917927

918928
/// Run the translation phase to LLVM, after which the AST and analysis can
919-
/// be discarded.
920929
pub fn phase_4_translate_to_llvm<'tcx>(tcx: &TyCtxt<'tcx>,
921-
mut mir_map: MirMap<'tcx>,
930+
mir_map: MirMap<'tcx>,
922931
analysis: ty::CrateAnalysis)
923932
-> trans::CrateTranslation {
924933
let time_passes = tcx.sess.time_passes();
@@ -927,10 +936,6 @@ pub fn phase_4_translate_to_llvm<'tcx>(tcx: &TyCtxt<'tcx>,
927936
"resolving dependency formats",
928937
|| dependency_format::calculate(&tcx.sess));
929938

930-
time(time_passes,
931-
"erasing regions from MIR",
932-
|| mir::transform::erase_regions::erase_regions(tcx, &mut mir_map));
933-
934939
// Option dance to work around the lack of stack once closures.
935940
time(time_passes,
936941
"translation",

0 commit comments

Comments
 (0)