Skip to content

Commit a63b0f0

Browse files
committed
Auto merge of rust-lang#28866 - nikomatsakis:remove-hair-trait, r=nrc
As the subject says. This PR also removes the `Hair` trait, which was impeding the ability to build such a map, as described in this thread on internals: https://internals.rust-lang.org/t/removing-the-hair-trait-from-mir-construction/2732 r? @nrc
2 parents b2cc47f + 50c83a9 commit a63b0f0

31 files changed

+675
-740
lines changed

mk/main.mk

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,6 @@ ifdef CFG_DISABLE_STAGE0_LANDING_PADS
175175
RUSTFLAGS_STAGE0 += -Z no-landing-pads
176176
endif
177177

178-
# Enable MIR to "always build" for crates where this works. This is
179-
# just temporary while MIR is being actively built up -- it's just a
180-
# poor man's unit testing infrastructure. Anyway we only want this for
181-
# stage1/stage2.
182-
define ADD_MIR_FLAG
183-
RUSTFLAGS1_$(1) += -Z always-build-mir
184-
RUSTFLAGS2_$(1) += -Z always-build-mir
185-
endef
186-
$(foreach crate,$(TARGET_CRATES),$(eval $(call ADD_MIR_FLAG,$(crate))))
187-
$(foreach crate,$(RUSTC_CRATES),$(eval $(call ADD_MIR_FLAG,$(crate))))
188-
$(foreach crate,$(HOST_CRATES),$(eval $(call ADD_MIR_FLAG,$(crate))))
189-
190178
# platform-specific auto-configuration
191179
include $(CFG_SRC_DIR)mk/platform.mk
192180

src/librustc/session/config.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ pub struct Options {
101101
pub parse_only: bool,
102102
pub no_trans: bool,
103103
pub treat_err_as_bug: bool,
104-
pub always_build_mir: bool,
105104
pub no_analysis: bool,
106105
pub debugging_opts: DebuggingOptions,
107106
pub prints: Vec<PrintRequest>,
@@ -211,7 +210,6 @@ pub fn basic_options() -> Options {
211210
parse_only: false,
212211
no_trans: false,
213212
treat_err_as_bug: false,
214-
always_build_mir: false,
215213
no_analysis: false,
216214
debugging_opts: basic_debugging_options(),
217215
prints: Vec::new(),
@@ -578,8 +576,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
578576
"Run all passes except translation; no output"),
579577
treat_err_as_bug: bool = (false, parse_bool,
580578
"Treat all errors that occur as bugs"),
581-
always_build_mir: bool = (false, parse_bool,
582-
"Always build MIR for all fns, even without a #[rustc_mir] annotation"),
583579
no_analysis: bool = (false, parse_bool,
584580
"Parse and expand the source, but run no analysis"),
585581
extra_plugins: Vec<String> = (Vec::new(), parse_list,
@@ -895,7 +891,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
895891
let parse_only = debugging_opts.parse_only;
896892
let no_trans = debugging_opts.no_trans;
897893
let treat_err_as_bug = debugging_opts.treat_err_as_bug;
898-
let always_build_mir = debugging_opts.always_build_mir;
899894
let no_analysis = debugging_opts.no_analysis;
900895

901896
if debugging_opts.debug_llvm {
@@ -1049,7 +1044,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
10491044
parse_only: parse_only,
10501045
no_trans: no_trans,
10511046
treat_err_as_bug: treat_err_as_bug,
1052-
always_build_mir: always_build_mir,
10531047
no_analysis: no_analysis,
10541048
debugging_opts: debugging_opts,
10551049
prints: prints,

src/librustc_driver/driver.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,8 +738,9 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: Session,
738738
time(time_passes, "match checking", ||
739739
middle::check_match::check_crate(tcx));
740740

741-
time(time_passes, "MIR dump", ||
742-
mir::dump::dump_crate(tcx));
741+
let _mir_map =
742+
time(time_passes, "MIR dump", ||
743+
mir::mir_map::build_mir_for_crate(tcx));
743744

744745
time(time_passes, "liveness checking", ||
745746
middle::liveness::check_crate(tcx));

src/librustc_mir/build/block.rs

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

11+
use build::{BlockAnd, Builder};
1112
use hair::*;
1213
use repr::*;
13-
use build::{BlockAnd, Builder};
14+
use rustc_front::hir;
1415

15-
impl<H:Hair> Builder<H> {
16+
impl<'a,'tcx> Builder<'a,'tcx> {
1617
pub fn ast_block(&mut self,
17-
destination: &Lvalue<H>,
18+
destination: &Lvalue<'tcx>,
1819
mut block: BasicBlock,
19-
ast_block: H::Block)
20+
ast_block: &'tcx hir::Block)
2021
-> BlockAnd<()> {
2122
let this = self;
2223
let Block { extent, span: _, stmts, expr } = this.hir.mirror(ast_block);

src/librustc_mir/build/cfg.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
//! Routines for manipulating the control-flow graph.
1515
1616
use build::CFG;
17-
use hair::*;
1817
use repr::*;
18+
use syntax::codemap::Span;
1919

20-
impl<H:Hair> CFG<H> {
21-
pub fn block_data(&self, blk: BasicBlock) -> &BasicBlockData<H> {
20+
impl<'tcx> CFG<'tcx> {
21+
pub fn block_data(&self, blk: BasicBlock) -> &BasicBlockData<'tcx> {
2222
&self.basic_blocks[blk.index()]
2323
}
2424

25-
pub fn block_data_mut(&mut self, blk: BasicBlock) -> &mut BasicBlockData<H> {
25+
pub fn block_data_mut(&mut self, blk: BasicBlock) -> &mut BasicBlockData<'tcx> {
2626
&mut self.basic_blocks[blk.index()]
2727
}
2828

@@ -39,21 +39,21 @@ impl<H:Hair> CFG<H> {
3939
BasicBlock::new(node_index)
4040
}
4141

42-
pub fn push(&mut self, block: BasicBlock, statement: Statement<H>) {
42+
pub fn push(&mut self, block: BasicBlock, statement: Statement<'tcx>) {
4343
debug!("push({:?}, {:?})", block, statement);
4444
self.block_data_mut(block).statements.push(statement);
4545
}
4646

4747
pub fn push_assign_constant(&mut self,
4848
block: BasicBlock,
49-
span: H::Span,
50-
temp: &Lvalue<H>,
51-
constant: Constant<H>) {
49+
span: Span,
50+
temp: &Lvalue<'tcx>,
51+
constant: Constant<'tcx>) {
5252
self.push_assign(block, span, temp, Rvalue::Use(Operand::Constant(constant)));
5353
}
5454

55-
pub fn push_drop(&mut self, block: BasicBlock, span: H::Span,
56-
kind: DropKind, lvalue: &Lvalue<H>) {
55+
pub fn push_drop(&mut self, block: BasicBlock, span: Span,
56+
kind: DropKind, lvalue: &Lvalue<'tcx>) {
5757
self.push(block, Statement {
5858
span: span,
5959
kind: StatementKind::Drop(kind, lvalue.clone())
@@ -62,9 +62,9 @@ impl<H:Hair> CFG<H> {
6262

6363
pub fn push_assign(&mut self,
6464
block: BasicBlock,
65-
span: H::Span,
66-
lvalue: &Lvalue<H>,
67-
rvalue: Rvalue<H>) {
65+
span: Span,
66+
lvalue: &Lvalue<'tcx>,
67+
rvalue: Rvalue<'tcx>) {
6868
self.push(block, Statement {
6969
span: span,
7070
kind: StatementKind::Assign(lvalue.clone(), rvalue)
@@ -73,7 +73,7 @@ impl<H:Hair> CFG<H> {
7373

7474
pub fn terminate(&mut self,
7575
block: BasicBlock,
76-
terminator: Terminator<H>) {
76+
terminator: Terminator<'tcx>) {
7777
// Check whether this block has already been terminated. For
7878
// this, we rely on the fact that the initial state is to have
7979
// a Diverge terminator and an empty list of targets (which

src/librustc_mir/build/expr/as_constant.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ use build::{Builder};
1414
use hair::*;
1515
use repr::*;
1616

17-
impl<H:Hair> Builder<H> {
17+
impl<'a,'tcx> Builder<'a,'tcx> {
1818
/// Compile `expr`, yielding a compile-time constant. Assumes that
1919
/// `expr` is a valid compile-time constant!
20-
pub fn as_constant<M>(&mut self, expr: M) -> Constant<H>
21-
where M: Mirror<H, Output=Expr<H>>
20+
pub fn as_constant<M>(&mut self, expr: M) -> Constant<'tcx>
21+
where M: Mirror<'tcx, Output=Expr<'tcx>>
2222
{
2323
let expr = self.hir.mirror(expr);
2424
self.expr_as_constant(expr)
2525
}
2626

27-
fn expr_as_constant(&mut self, expr: Expr<H>) -> Constant<H> {
27+
fn expr_as_constant(&mut self, expr: Expr<'tcx>) -> Constant<'tcx> {
2828
let this = self;
2929
let Expr { ty, temp_lifetime: _, span, kind } = expr;
3030
match kind {

src/librustc_mir/build/expr/as_lvalue.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ use build::expr::category::Category;
1515
use hair::*;
1616
use repr::*;
1717

18-
impl<H:Hair> Builder<H> {
18+
impl<'a,'tcx> Builder<'a,'tcx> {
1919
/// Compile `expr`, yielding an lvalue that we can move from etc.
2020
pub fn as_lvalue<M>(&mut self,
2121
block: BasicBlock,
2222
expr: M)
23-
-> BlockAnd<Lvalue<H>>
24-
where M: Mirror<H, Output=Expr<H>>
23+
-> BlockAnd<Lvalue<'tcx>>
24+
where M: Mirror<'tcx, Output=Expr<'tcx>>
2525
{
2626
let expr = self.hir.mirror(expr);
2727
self.expr_as_lvalue(block, expr)
2828
}
2929

3030
fn expr_as_lvalue(&mut self,
3131
mut block: BasicBlock,
32-
expr: Expr<H>)
33-
-> BlockAnd<Lvalue<H>>
32+
expr: Expr<'tcx>)
33+
-> BlockAnd<Lvalue<'tcx>>
3434
{
3535
debug!("expr_as_lvalue(block={:?}, expr={:?})",
3636
block, expr);

src/librustc_mir/build/expr/as_operand.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ use build::expr::category::Category;
1515
use hair::*;
1616
use repr::*;
1717

18-
impl<H:Hair> Builder<H> {
18+
impl<'a,'tcx> Builder<'a,'tcx> {
1919
/// Compile `expr` into a value that can be used as an operand.
2020
/// If `expr` is an lvalue like `x`, this will introduce a
2121
/// temporary `tmp = x`, so that we capture the value of `x` at
2222
/// this time.
2323
pub fn as_operand<M>(&mut self,
2424
block: BasicBlock,
2525
expr: M)
26-
-> BlockAnd<Operand<H>>
27-
where M: Mirror<H, Output=Expr<H>>
26+
-> BlockAnd<Operand<'tcx>>
27+
where M: Mirror<'tcx, Output=Expr<'tcx>>
2828
{
2929
let expr = self.hir.mirror(expr);
3030
self.expr_as_operand(block, expr)
3131
}
3232

3333
fn expr_as_operand(&mut self,
3434
mut block: BasicBlock,
35-
expr: Expr<H>)
36-
-> BlockAnd<Operand<H>>
35+
expr: Expr<'tcx>)
36+
-> BlockAnd<Operand<'tcx>>
3737
{
3838
debug!("expr_as_operand(block={:?}, expr={:?})",
3939
block, expr);

src/librustc_mir/build/expr/as_rvalue.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@ use build::expr::category::{Category, RvalueFunc};
1717
use hair::*;
1818
use repr::*;
1919

20-
impl<H:Hair> Builder<H> {
20+
impl<'a,'tcx> Builder<'a,'tcx> {
2121
/// Compile `expr`, yielding an rvalue.
2222
pub fn as_rvalue<M>(&mut self,
2323
block: BasicBlock,
2424
expr: M)
25-
-> BlockAnd<Rvalue<H>>
26-
where M: Mirror<H, Output=Expr<H>>
25+
-> BlockAnd<Rvalue<'tcx>>
26+
where M: Mirror<'tcx, Output=Expr<'tcx>>
2727
{
2828
let expr = self.hir.mirror(expr);
2929
self.expr_as_rvalue(block, expr)
3030
}
3131

3232
fn expr_as_rvalue(&mut self,
3333
mut block: BasicBlock,
34-
expr: Expr<H>)
35-
-> BlockAnd<Rvalue<H>>
34+
expr: Expr<'tcx>)
35+
-> BlockAnd<Rvalue<'tcx>>
3636
{
3737
debug!("expr_as_rvalue(block={:?}, expr={:?})",
3838
block, expr);

src/librustc_mir/build/expr/as_temp.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ use build::expr::category::Category;
1515
use hair::*;
1616
use repr::*;
1717

18-
impl<H:Hair> Builder<H> {
18+
impl<'a,'tcx> Builder<'a,'tcx> {
1919
/// Compile `expr` into a fresh temporary. This is used when building
2020
/// up rvalues so as to freeze the value that will be consumed.
2121
pub fn as_temp<M>(&mut self,
2222
block: BasicBlock,
2323
expr: M)
24-
-> BlockAnd<Lvalue<H>>
25-
where M: Mirror<H, Output=Expr<H>>
24+
-> BlockAnd<Lvalue<'tcx>>
25+
where M: Mirror<'tcx, Output=Expr<'tcx>>
2626
{
2727
let expr = self.hir.mirror(expr);
2828
self.expr_as_temp(block, expr)
2929
}
3030

3131
fn expr_as_temp(&mut self,
3232
mut block: BasicBlock,
33-
expr: Expr<H>)
34-
-> BlockAnd<Lvalue<H>>
33+
expr: Expr<'tcx>)
34+
-> BlockAnd<Lvalue<'tcx>>
3535
{
3636
debug!("expr_as_temp(block={:?}, expr={:?})",
3737
block, expr);

src/librustc_mir/build/expr/category.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub enum RvalueFunc {
4141
/// Determines the category for a given expression. Note that scope
4242
/// and paren expressions have no category.
4343
impl Category {
44-
pub fn of<H:Hair>(ek: &ExprKind<H>) -> Option<Category> {
44+
pub fn of<'tcx>(ek: &ExprKind<'tcx>) -> Option<Category> {
4545
match *ek {
4646
ExprKind::Scope { .. } => None,
4747

src/librustc_mir/build/expr/into.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ use build::expr::category::{Category, RvalueFunc};
1515
use build::scope::LoopScope;
1616
use hair::*;
1717
use repr::*;
18+
use rustc::middle::region::CodeExtent;
19+
use syntax::codemap::Span;
1820

19-
impl<H:Hair> Builder<H> {
21+
impl<'a,'tcx> Builder<'a,'tcx> {
2022
/// Compile `expr`, storing the result into `destination`, which
2123
/// is assumed to be uninitialized.
2224
pub fn into_expr(&mut self,
23-
destination: &Lvalue<H>,
25+
destination: &Lvalue<'tcx>,
2426
mut block: BasicBlock,
25-
expr: Expr<H>)
27+
expr: Expr<'tcx>)
2628
-> BlockAnd<()>
2729
{
2830
debug!("into_expr(destination={:?}, block={:?}, expr={:?})",
@@ -266,12 +268,12 @@ impl<H:Hair> Builder<H> {
266268
}
267269

268270
fn break_or_continue<F>(&mut self,
269-
span: H::Span,
270-
label: Option<H::CodeExtent>,
271+
span: Span,
272+
label: Option<CodeExtent>,
271273
block: BasicBlock,
272274
exit_selector: F)
273275
-> BlockAnd<()>
274-
where F: FnOnce(&LoopScope<H>) -> BasicBlock
276+
where F: FnOnce(&LoopScope) -> BasicBlock
275277
{
276278
let loop_scope = self.find_loop_scope(span, label);
277279
let exit_block = exit_selector(&loop_scope);

0 commit comments

Comments
 (0)