Skip to content

Commit 9d54ebe

Browse files
committed
Auto merge of #43271 - Nashenas88:nll, r=nikomatsakis
Add empty MIR pass for non-lexical lifetimes This is the first step for #43234.
2 parents 1edbc3d + 7a966b4 commit 9d54ebe

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

src/librustc/session/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
10601060
"insert profiling code"),
10611061
relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
10621062
"choose which RELRO level to use"),
1063+
nll: bool = (false, parse_bool, [UNTRACKED],
1064+
"run the non-lexical lifetimes MIR pass"),
10631065
}
10641066

10651067
pub fn default_lib_output() -> CrateType {

src/librustc_driver/driver.rs

+1
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
938938
passes.push_pass(MIR_VALIDATED,
939939
mir::transform::simplify_branches::SimplifyBranches::new("initial"));
940940
passes.push_pass(MIR_VALIDATED, mir::transform::simplify::SimplifyCfg::new("qualify-consts"));
941+
passes.push_pass(MIR_VALIDATED, mir::transform::nll::NLL);
941942

942943
// Optimizations begin.
943944
passes.push_pass(MIR_OPTIMIZED, mir::transform::no_landing_pads::NoLandingPads);

src/librustc_mir/transform/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub mod deaggregator;
4040
pub mod instcombine;
4141
pub mod copy_prop;
4242
pub mod inline;
43+
pub mod nll;
4344

4445
pub(crate) fn provide(providers: &mut Providers) {
4546
self::qualify_consts::provide(providers);

src/librustc_mir/transform/nll.rs

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use rustc::ty::TyCtxt;
12+
use rustc::mir::Mir;
13+
use rustc::mir::visit::MutVisitor;
14+
use rustc::mir::transform::{MirPass, MirSource};
15+
16+
#[allow(dead_code)]
17+
struct NLLVisitor<'a, 'tcx: 'a> {
18+
tcx: TyCtxt<'a, 'tcx, 'tcx>,
19+
}
20+
21+
impl<'a, 'tcx> NLLVisitor<'a, 'tcx> {
22+
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Self {
23+
NLLVisitor {
24+
tcx: tcx
25+
}
26+
}
27+
}
28+
29+
impl<'a, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'tcx> {
30+
// FIXME: Nashenas88: implement me!
31+
}
32+
33+
// MIR Pass for non-lexical lifetimes
34+
pub struct NLL;
35+
36+
impl MirPass for NLL {
37+
fn run_pass<'a, 'tcx>(&self,
38+
tcx: TyCtxt<'a, 'tcx, 'tcx>,
39+
_: MirSource,
40+
mir: &mut Mir<'tcx>) {
41+
if tcx.sess.opts.debugging_opts.nll {
42+
// Clone mir so we can mutate it without disturbing the rest
43+
// of the compiler
44+
NLLVisitor::new(tcx).visit_mir(&mut mir.clone());
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)