Skip to content

Commit 8bc646d

Browse files
committed
---
yaml --- r: 227646 b: refs/heads/try c: 2e997ef h: refs/heads/master v: v3
1 parent 87b29ca commit 8bc646d

File tree

17 files changed

+169
-432
lines changed

17 files changed

+169
-432
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 89485b2b6b643019c1748d456898c8774e2331de
4+
refs/heads/try: 2e997ef2d487525ea41e78ba793cb6e7c61cb204
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/librustc/diagnostics.rs

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -256,21 +256,6 @@ See [RFC 911] for more details on the design of `const fn`s.
256256
[RFC 911]: https://github.com/rust-lang/rfcs/blob/master/text/0911-const-fn.md
257257
"##,
258258

259-
E0016: r##"
260-
Blocks in constants may only contain items (such as constant, function
261-
definition, etc...) and a tail expression. Example:
262-
263-
```
264-
const FOO: i32 = { let x = 0; x }; // 'x' isn't an item!
265-
```
266-
267-
To avoid it, you have to replace the non-item object:
268-
269-
```
270-
const FOO: i32 = { const X : i32 = 0; X };
271-
```
272-
"##,
273-
274259
E0018: r##"
275260
The value of static and const variables must be known at compile time. You
276261
can't cast a pointer as an integer because we can't know what value the
@@ -294,42 +279,6 @@ println!("{}", Y);
294279
```
295280
"##,
296281

297-
E0019: r##"
298-
A function call isn't allowed in the const's initialization expression
299-
because the expression's value must be known at compile-time. Example of
300-
erroneous code:
301-
302-
```
303-
enum Test {
304-
V1
305-
}
306-
307-
impl Test {
308-
fn test(&self) -> i32 {
309-
12
310-
}
311-
}
312-
313-
fn main() {
314-
const FOO: Test = Test::V1;
315-
316-
const A: i32 = FOO.test(); // You can't call Test::func() here !
317-
}
318-
```
319-
320-
Remember: you can't use a function call inside a const's initialization
321-
expression! However, you can totally use it elsewhere you want:
322-
323-
```
324-
fn main() {
325-
const FOO: Test = Test::V1;
326-
327-
FOO.func(); // here is good
328-
let x = FOO.func(); // or even here!
329-
}
330-
```
331-
"##,
332-
333282
E0020: r##"
334283
This error indicates that an attempt was made to divide by zero (or take the
335284
remainder of a zero divisor) in a static or constant expression.
@@ -1001,7 +950,9 @@ static mut BAR: Option<Vec<i32>> = None;
1001950

1002951

1003952
register_diagnostics! {
953+
E0016,
1004954
E0017,
955+
E0019,
1005956
E0022,
1006957
E0038,
1007958
E0109,

branches/try/src/librustc/middle/ty.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,10 @@ pub const INITIAL_DISCRIMINANT_VALUE: Disr = 0;
101101

102102
/// The complete set of all analyses described in this module. This is
103103
/// produced by the driver and fed to trans and later passes.
104-
pub struct CrateAnalysis<'tcx> {
104+
pub struct CrateAnalysis {
105105
pub export_map: ExportMap,
106106
pub exported_items: middle::privacy::ExportedItems,
107107
pub public_items: middle::privacy::PublicItems,
108-
pub ty_cx: ty::ctxt<'tcx>,
109108
pub reachable: NodeSet,
110109
pub name: String,
111110
pub glob_map: Option<GlobMap>,

branches/try/src/librustc_driver/driver.rs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -119,26 +119,26 @@ pub fn compile_input(sess: Session,
119119
&ast_map.krate(),
120120
&id[..]));
121121

122-
let analysis = phase_3_run_analysis_passes(sess,
123-
ast_map,
124-
&arenas,
125-
id,
126-
control.make_glob_map);
122+
let (tcx, analysis) = phase_3_run_analysis_passes(sess,
123+
ast_map,
124+
&arenas,
125+
id,
126+
control.make_glob_map);
127127

128128
controller_entry_point!(after_analysis,
129-
analysis.ty_cx.sess,
129+
tcx.sess,
130130
CompileState::state_after_analysis(input,
131-
&analysis.ty_cx.sess,
131+
&tcx.sess,
132132
outdir,
133-
analysis.ty_cx.map.krate(),
133+
tcx.map.krate(),
134134
&analysis,
135-
&analysis.ty_cx));
135+
&tcx));
136136

137137
if log_enabled!(::log::INFO) {
138138
println!("Pre-trans");
139-
analysis.ty_cx.print_debug_stats();
139+
tcx.print_debug_stats();
140140
}
141-
let (tcx, trans) = phase_4_translate_to_llvm(analysis);
141+
let trans = phase_4_translate_to_llvm(&tcx, analysis);
142142

143143
if log_enabled!(::log::INFO) {
144144
println!("Post-trans");
@@ -240,7 +240,7 @@ pub struct CompileState<'a, 'ast: 'a, 'tcx: 'a> {
240240
pub out_dir: Option<&'a Path>,
241241
pub expanded_crate: Option<&'a ast::Crate>,
242242
pub ast_map: Option<&'a ast_map::Map<'ast>>,
243-
pub analysis: Option<&'a ty::CrateAnalysis<'tcx>>,
243+
pub analysis: Option<&'a ty::CrateAnalysis>,
244244
pub tcx: Option<&'a ty::ctxt<'tcx>>,
245245
pub trans: Option<&'a trans::CrateTranslation>,
246246
}
@@ -309,7 +309,7 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
309309
session: &'a Session,
310310
out_dir: &'a Option<PathBuf>,
311311
expanded_crate: &'a ast::Crate,
312-
analysis: &'a ty::CrateAnalysis<'tcx>,
312+
analysis: &'a ty::CrateAnalysis,
313313
tcx: &'a ty::ctxt<'tcx>)
314314
-> CompileState<'a, 'ast, 'tcx> {
315315
CompileState {
@@ -583,7 +583,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
583583
arenas: &'tcx ty::CtxtArenas<'tcx>,
584584
name: String,
585585
make_glob_map: resolve::MakeGlobMap)
586-
-> ty::CrateAnalysis<'tcx> {
586+
-> (ty::ctxt<'tcx>, ty::CrateAnalysis) {
587587
let time_passes = sess.time_passes();
588588
let krate = ast_map.krate();
589589

@@ -704,29 +704,28 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
704704
// The above three passes generate errors w/o aborting
705705
ty_cx.sess.abort_if_errors();
706706

707-
ty::CrateAnalysis {
707+
(ty_cx, ty::CrateAnalysis {
708708
export_map: export_map,
709-
ty_cx: ty_cx,
710709
exported_items: exported_items,
711710
public_items: public_items,
712711
reachable: reachable_map,
713712
name: name,
714713
glob_map: glob_map,
715-
}
714+
})
716715
}
717716

718717
/// Run the translation phase to LLVM, after which the AST and analysis can
719718
/// be discarded.
720-
pub fn phase_4_translate_to_llvm<'tcx>(analysis: ty::CrateAnalysis<'tcx>)
721-
-> (ty::ctxt<'tcx>, trans::CrateTranslation) {
722-
let time_passes = analysis.ty_cx.sess.time_passes();
719+
pub fn phase_4_translate_to_llvm(tcx: &ty::ctxt, analysis: ty::CrateAnalysis)
720+
-> trans::CrateTranslation {
721+
let time_passes = tcx.sess.time_passes();
723722

724723
time(time_passes, "resolving dependency formats", (), |_|
725-
dependency_format::calculate(&analysis.ty_cx));
724+
dependency_format::calculate(tcx));
726725

727726
// Option dance to work around the lack of stack once closures.
728727
time(time_passes, "translation", analysis, |analysis|
729-
trans::trans_crate(analysis))
728+
trans::trans_crate(tcx, analysis))
730729
}
731730

732731
/// Run LLVM itself, producing a bitcode file, assembly file or object file

branches/try/src/librustc_driver/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,10 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
377377
if sess.opts.debugging_opts.save_analysis {
378378
control.after_analysis.callback = box |state| {
379379
time(state.session.time_passes(),
380-
"save analysis",
381-
state.expanded_crate.unwrap(),
382-
|krate| save::process_crate(state.session,
383-
krate,
384-
state.analysis.unwrap(),
385-
state.out_dir));
380+
"save analysis", (),
381+
|_| save::process_crate(state.tcx.unwrap(),
382+
state.analysis.unwrap(),
383+
state.out_dir));
386384
};
387385
control.make_glob_map = resolve::MakeGlobMap::Yes;
388386
}

branches/try/src/librustc_driver/pretty.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ impl PpSourceMode {
148148
}
149149
PpmTyped => {
150150
let ast_map = ast_map.expect("--pretty=typed missing ast_map");
151-
let analysis = driver::phase_3_run_analysis_passes(sess,
151+
let (tcx, _) = driver::phase_3_run_analysis_passes(sess,
152152
ast_map,
153153
arenas,
154154
id,
155155
resolve::MakeGlobMap::No);
156-
let annotation = TypedAnnotation { analysis: analysis };
156+
let annotation = TypedAnnotation { tcx: tcx };
157157
f(&annotation, payload)
158158
}
159159
}
@@ -285,14 +285,14 @@ impl<'ast> pprust::PpAnn for HygieneAnnotation<'ast> {
285285

286286

287287
struct TypedAnnotation<'tcx> {
288-
analysis: ty::CrateAnalysis<'tcx>,
288+
tcx: ty::ctxt<'tcx>,
289289
}
290290

291291
impl<'tcx> PrinterSupport<'tcx> for TypedAnnotation<'tcx> {
292-
fn sess<'a>(&'a self) -> &'a Session { &self.analysis.ty_cx.sess }
292+
fn sess<'a>(&'a self) -> &'a Session { &self.tcx.sess }
293293

294294
fn ast_map<'a>(&'a self) -> Option<&'a ast_map::Map<'tcx>> {
295-
Some(&self.analysis.ty_cx.map)
295+
Some(&self.tcx.map)
296296
}
297297

298298
fn pp_ann<'a>(&'a self) -> &'a pprust::PpAnn { self }
@@ -310,16 +310,15 @@ impl<'tcx> pprust::PpAnn for TypedAnnotation<'tcx> {
310310
fn post(&self,
311311
s: &mut pprust::State,
312312
node: pprust::AnnNode) -> io::Result<()> {
313-
let tcx = &self.analysis.ty_cx;
314313
match node {
315314
pprust::NodeExpr(expr) => {
316315
try!(pp::space(&mut s.s));
317316
try!(pp::word(&mut s.s, "as"));
318317
try!(pp::space(&mut s.s));
319318
try!(pp::word(&mut s.s,
320319
&ppaux::ty_to_string(
321-
tcx,
322-
ty::expr_ty(tcx, expr))));
320+
&self.tcx,
321+
ty::expr_ty(&self.tcx, expr))));
323322
s.pclose()
324323
}
325324
_ => Ok(())
@@ -646,12 +645,12 @@ pub fn pretty_print_input(sess: Session,
646645
match code {
647646
Some(code) => {
648647
let variants = gather_flowgraph_variants(&sess);
649-
let analysis = driver::phase_3_run_analysis_passes(sess,
648+
let (tcx, _) = driver::phase_3_run_analysis_passes(sess,
650649
ast_map,
651650
&arenas,
652651
id,
653652
resolve::MakeGlobMap::No);
654-
print_flowgraph(variants, analysis, code, mode, out)
653+
print_flowgraph(variants, &tcx, code, mode, out)
655654
}
656655
None => {
657656
let message = format!("--pretty=flowgraph needs \
@@ -682,18 +681,17 @@ pub fn pretty_print_input(sess: Session,
682681
}
683682

684683
fn print_flowgraph<W: Write>(variants: Vec<borrowck_dot::Variant>,
685-
analysis: ty::CrateAnalysis,
684+
tcx: &ty::ctxt,
686685
code: blocks::Code,
687686
mode: PpFlowGraphMode,
688687
mut out: W) -> io::Result<()> {
689-
let ty_cx = &analysis.ty_cx;
690688
let cfg = match code {
691-
blocks::BlockCode(block) => cfg::CFG::new(ty_cx, &*block),
692-
blocks::FnLikeCode(fn_like) => cfg::CFG::new(ty_cx, &*fn_like.body()),
689+
blocks::BlockCode(block) => cfg::CFG::new(tcx, &*block),
690+
blocks::FnLikeCode(fn_like) => cfg::CFG::new(tcx, &*fn_like.body()),
693691
};
694692
let labelled_edges = mode != PpFlowGraphMode::UnlabelledEdges;
695693
let lcfg = LabelledCFG {
696-
ast_map: &ty_cx.map,
694+
ast_map: &tcx.map,
697695
cfg: &cfg,
698696
name: format!("node_{}", code.id()),
699697
labelled_edges: labelled_edges,
@@ -705,14 +703,14 @@ fn print_flowgraph<W: Write>(variants: Vec<borrowck_dot::Variant>,
705703
return expand_err_details(r);
706704
}
707705
blocks::BlockCode(_) => {
708-
ty_cx.sess.err("--pretty flowgraph with -Z flowgraph-print \
709-
annotations requires fn-like node id.");
706+
tcx.sess.err("--pretty flowgraph with -Z flowgraph-print \
707+
annotations requires fn-like node id.");
710708
return Ok(())
711709
}
712710
blocks::FnLikeCode(fn_like) => {
713711
let fn_parts = borrowck::FnPartsWithCFG::from_fn_like(&fn_like, &cfg);
714712
let (bccx, analysis_data) =
715-
borrowck::build_borrowck_dataflow_data_for_fn(ty_cx, fn_parts);
713+
borrowck::build_borrowck_dataflow_data_for_fn(tcx, fn_parts);
716714

717715
let lcfg = borrowck_dot::DataflowLabeller {
718716
inner: lcfg,

0 commit comments

Comments
 (0)