Skip to content

Commit c673fe4

Browse files
committed
---
yaml --- r: 274669 b: refs/heads/stable c: a1ffe6b h: refs/heads/master i: 274667: 6a198cd
1 parent 0eec02f commit c673fe4

File tree

7 files changed

+198
-72
lines changed

7 files changed

+198
-72
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: c0221c8897db309a79990367476177b1230bb264
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: f8fa6140fa6a85ea21ef4d2d56764862f7b3728b
32+
refs/heads/stable: a1ffe6b6bbfec7374f91dbbfb2e51a3fa5fadb1e
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/liballoc/arc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,9 @@ impl<T: ?Sized> Deref for Arc<T> {
380380
}
381381

382382
impl<T: Clone> Arc<T> {
383-
/// Make a mutable reference into the given `Arc<T>`.
384-
/// If the `Arc<T>` has more than one strong reference, or any weak
385-
/// references, the inner data is cloned.
383+
/// Make a mutable reference into the given `Arc<T>` by cloning the inner
384+
/// data if the `Arc<T>` doesn't have one strong reference and no weak
385+
/// references.
386386
///
387387
/// This is also referred to as a copy-on-write.
388388
///

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ pub enum PrintRequest {
163163
FileNames,
164164
Sysroot,
165165
CrateName,
166+
Cfg,
166167
}
167168

168169
pub enum Input {
@@ -1105,6 +1106,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
11051106
"crate-name" => PrintRequest::CrateName,
11061107
"file-names" => PrintRequest::FileNames,
11071108
"sysroot" => PrintRequest::Sysroot,
1109+
"cfg" => PrintRequest::Cfg,
11081110
req => {
11091111
early_error(error_format, &format!("unknown print request `{}`", req))
11101112
}

branches/stable/src/librustc_driver/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,25 @@ impl RustcDefaultCalls {
518518
.to_string_lossy());
519519
}
520520
}
521+
PrintRequest::Cfg => {
522+
for cfg in config::build_configuration(sess) {
523+
match cfg.node {
524+
ast::MetaWord(ref word) => println!("{}", word),
525+
ast::MetaNameValue(ref name, ref value) => {
526+
println!("{}=\"{}\"", name, match value.node {
527+
ast::LitStr(ref s, _) => s,
528+
_ => continue,
529+
});
530+
}
531+
// Right now there are not and should not be any
532+
// MetaList items in the configuration returned by
533+
// `build_configuration`.
534+
ast::MetaList(..) => {
535+
panic!("MetaList encountered in default cfg")
536+
}
537+
}
538+
}
539+
}
521540
}
522541
}
523542
return Compilation::Stop;

branches/stable/src/librustc_mir/mir_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extern crate rustc_front;
2323
use build;
2424
use graphviz;
2525
use pretty;
26-
use transform::{simplify_cfg, MirPass};
26+
use transform::*;
2727
use rustc::dep_graph::DepNode;
2828
use rustc::mir::repr::Mir;
2929
use hair::cx::Cx;

branches/stable/src/librustc_mir/transform/erase_regions.rs

Lines changed: 157 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
1515
use rustc::middle::ty;
1616
use rustc::mir::repr::*;
17-
use rustc::mir::visit::MutVisitor;
18-
use mir_map::MirMap;
1917
use transform::MirPass;
18+
use mir_map::MirMap;
2019

2120
pub fn erase_regions<'tcx>(tcx: &ty::ctxt<'tcx>, mir_map: &mut MirMap<'tcx>) {
2221
let mut eraser = EraseRegions::new(tcx);
@@ -30,105 +29,196 @@ pub struct EraseRegions<'a, 'tcx: 'a> {
3029
tcx: &'a ty::ctxt<'tcx>,
3130
}
3231

32+
impl<'a, 'tcx> MirPass<'tcx> for EraseRegions<'a, 'tcx> {
33+
34+
fn run_on_mir(&mut self, mir: &mut Mir<'tcx>) {
35+
36+
for basic_block in &mut mir.basic_blocks {
37+
self.erase_regions_basic_block(basic_block);
38+
}
39+
40+
self.erase_regions_return_ty(&mut mir.return_ty);
41+
42+
self.erase_regions_tys(mir.var_decls.iter_mut().map(|d| &mut d.ty));
43+
self.erase_regions_tys(mir.arg_decls.iter_mut().map(|d| &mut d.ty));
44+
self.erase_regions_tys(mir.temp_decls.iter_mut().map(|d| &mut d.ty));
45+
}
46+
}
47+
3348
impl<'a, 'tcx> EraseRegions<'a, 'tcx> {
49+
3450
pub fn new(tcx: &'a ty::ctxt<'tcx>) -> EraseRegions<'a, 'tcx> {
3551
EraseRegions {
3652
tcx: tcx
3753
}
3854
}
3955

40-
fn erase_regions_return_ty(&mut self, fn_output: &mut ty::FnOutput<'tcx>) {
41-
match *fn_output {
42-
ty::FnConverging(ref mut ty) => {
43-
*ty = self.tcx.erase_regions(ty);
44-
},
45-
ty::FnDiverging => {}
56+
fn erase_regions_basic_block(&mut self,
57+
basic_block: &mut BasicBlockData<'tcx>) {
58+
for statement in &mut basic_block.statements {
59+
self.erase_regions_statement(statement);
4660
}
47-
}
48-
49-
fn erase_regions_tys<'b, T>(&mut self, tys: T)
50-
where T: Iterator<Item = &'b mut ty::Ty<'tcx>>,
51-
'tcx: 'b
52-
{
53-
for ty in tys {
54-
*ty = self.tcx.erase_regions(ty);
55-
}
56-
}
57-
}
5861

59-
impl<'a, 'tcx> MirPass<'tcx> for EraseRegions<'a, 'tcx> {
60-
fn run_on_mir(&mut self, mir: &mut Mir<'tcx>) {
61-
self.visit_mir(mir);
62+
self.erase_regions_terminator(basic_block.terminator_mut());
6263
}
63-
}
6464

65-
impl<'a, 'tcx> MutVisitor<'tcx> for EraseRegions<'a, 'tcx> {
66-
fn visit_mir(&mut self, mir: &mut Mir<'tcx>) {
67-
self.erase_regions_return_ty(&mut mir.return_ty);
68-
self.erase_regions_tys(mir.var_decls.iter_mut().map(|d| &mut d.ty));
69-
self.erase_regions_tys(mir.arg_decls.iter_mut().map(|d| &mut d.ty));
70-
self.erase_regions_tys(mir.temp_decls.iter_mut().map(|d| &mut d.ty));
71-
self.super_mir(mir);
65+
fn erase_regions_statement(&mut self,
66+
statement: &mut Statement<'tcx>) {
67+
match statement.kind {
68+
StatementKind::Assign(ref mut lvalue, ref mut rvalue) => {
69+
self.erase_regions_lvalue(lvalue);
70+
self.erase_regions_rvalue(rvalue);
71+
}
72+
}
7273
}
7374

74-
fn visit_terminator(&mut self, bb: BasicBlock, terminator: &mut Terminator<'tcx>) {
75+
fn erase_regions_terminator(&mut self,
76+
terminator: &mut Terminator<'tcx>) {
7577
match *terminator {
7678
Terminator::Goto { .. } |
7779
Terminator::Resume |
78-
Terminator::Return |
79-
Terminator::If { .. } |
80-
Terminator::Switch { .. } |
81-
Terminator::Drop { .. } |
82-
Terminator::Call { .. } => {
80+
Terminator::Return => {
8381
/* nothing to do */
84-
},
85-
Terminator::SwitchInt { ref mut switch_ty, .. } => {
82+
}
83+
Terminator::If { ref mut cond, .. } => {
84+
self.erase_regions_operand(cond);
85+
}
86+
Terminator::Switch { ref mut discr, .. } => {
87+
self.erase_regions_lvalue(discr);
88+
}
89+
Terminator::SwitchInt { ref mut discr, ref mut switch_ty, .. } => {
90+
self.erase_regions_lvalue(discr);
8691
*switch_ty = self.tcx.erase_regions(switch_ty);
8792
},
93+
Terminator::Drop { ref mut value, .. } => {
94+
self.erase_regions_lvalue(value);
95+
}
96+
Terminator::Call { ref mut func, ref mut args, ref mut destination, .. } => {
97+
if let Some((ref mut destination, _)) = *destination {
98+
self.erase_regions_lvalue(destination);
99+
}
100+
self.erase_regions_operand(func);
101+
for arg in &mut *args {
102+
self.erase_regions_operand(arg);
103+
}
104+
}
88105
}
89-
self.super_terminator(bb, terminator);
90106
}
91107

92-
fn visit_rvalue(&mut self, rvalue: &mut Rvalue<'tcx>) {
93-
match *rvalue {
94-
Rvalue::Use(_) |
95-
Rvalue::Len(_) |
96-
Rvalue::BinaryOp(_, _, _) |
97-
Rvalue::UnaryOp(_, _) |
98-
Rvalue::Slice { input: _, from_start: _, from_end: _ } |
99-
Rvalue::InlineAsm(_) => {},
100-
101-
Rvalue::Repeat(_, ref mut value) => value.ty = self.tcx.erase_regions(&value.ty),
102-
Rvalue::Ref(ref mut region, _, _) => *region = ty::ReStatic,
103-
Rvalue::Cast(_, _, ref mut ty) => *ty = self.tcx.erase_regions(ty),
104-
Rvalue::Box(ref mut ty) => *ty = self.tcx.erase_regions(ty),
108+
fn erase_regions_operand(&mut self, operand: &mut Operand<'tcx>) {
109+
match *operand {
110+
Operand::Consume(ref mut lvalue) => {
111+
self.erase_regions_lvalue(lvalue);
112+
}
113+
Operand::Constant(ref mut constant) => {
114+
self.erase_regions_constant(constant);
115+
}
116+
}
117+
}
105118

119+
fn erase_regions_lvalue(&mut self, lvalue: &mut Lvalue<'tcx>) {
120+
match *lvalue {
121+
Lvalue::Var(_) |
122+
Lvalue::Temp(_) |
123+
Lvalue::Arg(_) |
124+
Lvalue::Static(_) |
125+
Lvalue::ReturnPointer => {}
126+
Lvalue::Projection(ref mut lvalue_projection) => {
127+
self.erase_regions_lvalue(&mut lvalue_projection.base);
128+
match lvalue_projection.elem {
129+
ProjectionElem::Deref |
130+
ProjectionElem::Field(_) |
131+
ProjectionElem::Downcast(..) |
132+
ProjectionElem::ConstantIndex {..} => { /* nothing to do */ }
133+
ProjectionElem::Index(ref mut index) => {
134+
self.erase_regions_operand(index);
135+
}
136+
}
137+
}
138+
}
139+
}
106140

107-
Rvalue::Aggregate(AggregateKind::Vec, _) |
108-
Rvalue::Aggregate(AggregateKind::Tuple, _) => {},
109-
Rvalue::Aggregate(AggregateKind::Adt(_, _, ref mut substs), _) =>
110-
*substs = self.tcx.mk_substs(self.tcx.erase_regions(*substs)),
111-
Rvalue::Aggregate(AggregateKind::Closure(def_id, ref mut closure_substs), _) => {
112-
let cloned = Box::new(closure_substs.clone());
113-
let ty = self.tcx.mk_closure_from_closure_substs(def_id, cloned);
114-
let erased = self.tcx.erase_regions(&ty);
115-
*closure_substs = match erased.sty {
116-
ty::TyClosure(_, ref closure_substs) => &*closure_substs,
117-
_ => unreachable!()
118-
};
141+
fn erase_regions_rvalue(&mut self, rvalue: &mut Rvalue<'tcx>) {
142+
match *rvalue {
143+
Rvalue::Use(ref mut operand) => {
144+
self.erase_regions_operand(operand)
145+
}
146+
Rvalue::Repeat(ref mut operand, ref mut value) => {
147+
self.erase_regions_operand(operand);
148+
value.ty = self.tcx.erase_regions(&value.ty);
149+
}
150+
Rvalue::Ref(ref mut region, _, ref mut lvalue) => {
151+
*region = ty::ReStatic;
152+
self.erase_regions_lvalue(lvalue);
153+
}
154+
Rvalue::Len(ref mut lvalue) => self.erase_regions_lvalue(lvalue),
155+
Rvalue::Cast(_, ref mut operand, ref mut ty) => {
156+
self.erase_regions_operand(operand);
157+
*ty = self.tcx.erase_regions(ty);
158+
}
159+
Rvalue::BinaryOp(_, ref mut operand1, ref mut operand2) => {
160+
self.erase_regions_operand(operand1);
161+
self.erase_regions_operand(operand2);
162+
}
163+
Rvalue::UnaryOp(_, ref mut operand) => {
164+
self.erase_regions_operand(operand);
119165
}
166+
Rvalue::Box(ref mut ty) => *ty = self.tcx.erase_regions(ty),
167+
Rvalue::Aggregate(ref mut aggregate_kind, ref mut operands) => {
168+
match *aggregate_kind {
169+
AggregateKind::Vec |
170+
AggregateKind::Tuple => {},
171+
AggregateKind::Adt(_, _, ref mut substs) => {
172+
let erased = self.tcx.erase_regions(*substs);
173+
*substs = self.tcx.mk_substs(erased);
174+
}
175+
AggregateKind::Closure(def_id, ref mut closure_substs) => {
176+
let cloned = Box::new(closure_substs.clone());
177+
let ty = self.tcx.mk_closure_from_closure_substs(def_id,
178+
cloned);
179+
let erased = self.tcx.erase_regions(&ty);
180+
*closure_substs = match erased.sty {
181+
ty::TyClosure(_, ref closure_substs) => &*closure_substs,
182+
_ => unreachable!()
183+
};
184+
}
185+
}
186+
for operand in &mut *operands {
187+
self.erase_regions_operand(operand);
188+
}
189+
}
190+
Rvalue::Slice { ref mut input, .. } => {
191+
self.erase_regions_lvalue(input);
192+
}
193+
Rvalue::InlineAsm(_) => {},
120194
}
121-
self.super_rvalue(rvalue);
122195
}
123196

124-
fn visit_constant(&mut self, constant: &mut Constant<'tcx>) {
197+
fn erase_regions_constant(&mut self, constant: &mut Constant<'tcx>) {
125198
constant.ty = self.tcx.erase_regions(&constant.ty);
126199
match constant.literal {
127200
Literal::Item { ref mut substs, .. } => {
128201
*substs = self.tcx.mk_substs(self.tcx.erase_regions(substs));
129202
}
130203
Literal::Value { .. } => { /* nothing to do */ }
131204
}
132-
self.super_constant(constant);
205+
}
206+
207+
fn erase_regions_return_ty(&mut self, fn_output: &mut ty::FnOutput<'tcx>) {
208+
match *fn_output {
209+
ty::FnConverging(ref mut ty) => {
210+
*ty = self.tcx.erase_regions(ty);
211+
},
212+
ty::FnDiverging => {}
213+
}
214+
}
215+
216+
fn erase_regions_tys<'b, T>(&mut self, tys: T)
217+
where T: Iterator<Item = &'b mut ty::Ty<'tcx>>,
218+
'tcx: 'b
219+
{
220+
for ty in tys {
221+
*ty = self.tcx.erase_regions(ty);
222+
}
133223
}
134224
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-include ../tools.mk
2+
3+
all: default
4+
$(RUSTC) --target x86_64-pc-windows-gnu --print cfg | grep windows
5+
$(RUSTC) --target x86_64-pc-windows-gnu --print cfg | grep x86_64
6+
$(RUSTC) --target i686-pc-windows-msvc --print cfg | grep msvc
7+
$(RUSTC) --target i686-apple-darwin --print cfg | grep macos
8+
9+
ifdef IS_WINDOWS
10+
default:
11+
$(RUSTC) --print cfg | grep windows
12+
else
13+
default:
14+
$(RUSTC) --print cfg | grep unix
15+
endif

0 commit comments

Comments
 (0)