Skip to content

Commit db8c92d

Browse files
committed
---
yaml --- r: 162044 b: refs/heads/auto c: f33d879 h: refs/heads/master v: v3
1 parent 216eea7 commit db8c92d

File tree

7 files changed

+101
-66
lines changed

7 files changed

+101
-66
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 8c07db5aac1bf87bce734d34b2c63a0890e02bd4
13+
refs/heads/auto: f33d879a7094bce7e16345dcc2efa85da6f05261
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc_trans/trans/closure.rs

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,21 +272,24 @@ fn load_environment<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
272272
let mut i = 0u;
273273
for freevar in freevars.iter() {
274274
let mut upvarptr = GEPi(bcx, llcdata, &[0u, i]);
275-
match store {
276-
ty::RegionTraitStore(..) => { upvarptr = Load(bcx, upvarptr); }
277-
ty::UniqTraitStore => {}
278-
}
275+
let captured_by_ref = match store {
276+
ty::RegionTraitStore(..) => {
277+
upvarptr = Load(bcx, upvarptr);
278+
true
279+
}
280+
ty::UniqTraitStore => false
281+
};
279282
let def_id = freevar.def.def_id();
280283

281284
bcx.fcx.llupvars.borrow_mut().insert(def_id.node, upvarptr);
282-
for &env_pointer_alloca in env_pointer_alloca.iter() {
285+
if let Some(env_pointer_alloca) = env_pointer_alloca {
283286
debuginfo::create_captured_var_metadata(
284287
bcx,
285288
def_id.node,
286289
cdata_ty,
287290
env_pointer_alloca,
288291
i,
289-
store,
292+
captured_by_ref,
290293
freevar.span);
291294
}
292295

@@ -320,11 +323,25 @@ fn load_unboxed_closure_environment<'blk, 'tcx>(
320323
bcx.fcx.llenv.unwrap()
321324
};
322325

326+
// Store the pointer to closure data in an alloca for debug info because that's what the
327+
// llvm.dbg.declare intrinsic expects
328+
let env_pointer_alloca = if bcx.sess().opts.debuginfo == FullDebugInfo {
329+
let alloc = alloc_ty(bcx, ty::mk_mut_ptr(bcx.tcx(), self_type), "__debuginfo_env_ptr");
330+
Store(bcx, llenv, alloc);
331+
Some(alloc)
332+
} else {
333+
None
334+
};
335+
323336
for (i, freevar) in freevars.iter().enumerate() {
324337
let mut upvar_ptr = GEPi(bcx, llenv, &[0, i]);
325-
if freevar_mode == ast::CaptureByRef {
326-
upvar_ptr = Load(bcx, upvar_ptr);
327-
}
338+
let captured_by_ref = match freevar_mode {
339+
ast::CaptureByRef => {
340+
upvar_ptr = Load(bcx, upvar_ptr);
341+
true
342+
}
343+
ast::CaptureByValue => false
344+
};
328345
let def_id = freevar.def.def_id();
329346
bcx.fcx.llupvars.borrow_mut().insert(def_id.node, upvar_ptr);
330347

@@ -333,6 +350,17 @@ fn load_unboxed_closure_environment<'blk, 'tcx>(
333350
upvar_ptr,
334351
node_id_type(bcx, def_id.node))
335352
}
353+
354+
if let Some(env_pointer_alloca) = env_pointer_alloca {
355+
debuginfo::create_captured_var_metadata(
356+
bcx,
357+
def_id.node,
358+
self_type,
359+
env_pointer_alloca,
360+
i,
361+
captured_by_ref,
362+
freevar.span);
363+
}
336364
}
337365

338366
bcx

branches/auto/src/librustc_trans/trans/debuginfo.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
885885
env_data_type: Ty<'tcx>,
886886
env_pointer: ValueRef,
887887
env_index: uint,
888-
closure_store: ty::TraitStore,
888+
captured_by_ref: bool,
889889
span: Span) {
890890
if fn_should_be_ignored(bcx.fcx) {
891891
return;
@@ -940,13 +940,10 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
940940
llvm::LLVMDIBuilderCreateOpDeref(Type::i64(cx).to_ref())]
941941
};
942942

943-
let address_op_count = match closure_store {
944-
ty::RegionTraitStore(..) => {
945-
address_operations.len()
946-
}
947-
ty::UniqTraitStore => {
948-
address_operations.len() - 1
949-
}
943+
let address_op_count = if captured_by_ref {
944+
address_operations.len()
945+
} else {
946+
address_operations.len() - 1
950947
};
951948

952949
let variable_access = IndirectVariable {

branches/auto/src/libstd/macros.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,11 @@ macro_rules! debug_assert_eq(
217217
/// Iterators:
218218
///
219219
/// ```rust
220-
/// fn divide_by_three(x: i32) -> i32 { // one of the poorest implementations of x/3
221-
/// for i in std::iter::count(0_i32, 1) {
222-
/// if i < 0 { panic!("i32 overflow"); }
223-
/// if x < 3*i { return i; }
220+
/// fn divide_by_three(x: u32) -> u32 { // one of the poorest implementations of x/3
221+
/// for i in std::iter::count(0_u32, 1) {
222+
/// if 3*i < i { panic!("u32 overflow"); }
223+
/// if x < 3*i { return i-1; }
224224
/// }
225-
///
226225
/// unreachable!();
227226
/// }
228227
/// ```

branches/auto/src/libstd/num/strconv.rs

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,6 @@ pub enum SignFormat {
8383
/// - `f` - a callback which will be invoked for each ascii character
8484
/// which composes the string representation of this integer
8585
///
86-
/// # Return value
87-
///
88-
/// A tuple containing the byte vector, and a boolean flag indicating
89-
/// whether it represents a special value like `inf`, `-inf`, `NaN` or not.
90-
/// It returns a tuple because there can be ambiguity between a special value
91-
/// and a number representation at higher bases.
92-
///
9386
/// # Panics
9487
///
9588
/// - Panics if `radix` < 2 or `radix` > 36.
@@ -147,40 +140,41 @@ fn int_to_str_bytes_common<T: Int>(num: T, radix: uint, sign: SignFormat, f: |u8
147140
}
148141
}
149142

150-
/**
151-
* Converts a number to its string representation as a byte vector.
152-
* This is meant to be a common base implementation for all numeric string
153-
* conversion functions like `to_string()` or `to_str_radix()`.
154-
*
155-
* # Arguments
156-
* - `num` - The number to convert. Accepts any number that
157-
* implements the numeric traits.
158-
* - `radix` - Base to use. Accepts only the values 2-36. If the exponential notation
159-
* is used, then this base is only used for the significand. The exponent
160-
* itself always printed using a base of 10.
161-
* - `negative_zero` - Whether to treat the special value `-0` as
162-
* `-0` or as `+0`.
163-
* - `sign` - How to emit the sign. See `SignFormat`.
164-
* - `digits` - The amount of digits to use for emitting the fractional
165-
* part, if any. See `SignificantDigits`.
166-
* - `exp_format` - Whether or not to use the exponential (scientific) notation.
167-
* See `ExponentFormat`.
168-
* - `exp_capital` - Whether or not to use a capital letter for the exponent sign, if
169-
* exponential notation is desired.
170-
*
171-
* # Return value
172-
* A tuple containing the byte vector, and a boolean flag indicating
173-
* whether it represents a special value like `inf`, `-inf`, `NaN` or not.
174-
* It returns a tuple because there can be ambiguity between a special value
175-
* and a number representation at higher bases.
176-
*
177-
* # Panics
178-
* - Panics if `radix` < 2 or `radix` > 36.
179-
* - Panics if `radix` > 14 and `exp_format` is `ExpDec` due to conflict
180-
* between digit and exponent sign `'e'`.
181-
* - Panics if `radix` > 25 and `exp_format` is `ExpBin` due to conflict
182-
* between digit and exponent sign `'p'`.
183-
*/
143+
/// Converts a number to its string representation as a byte vector.
144+
/// This is meant to be a common base implementation for all numeric string
145+
/// conversion functions like `to_string()` or `to_str_radix()`.
146+
///
147+
/// # Arguments
148+
///
149+
/// - `num` - The number to convert. Accepts any number that
150+
/// implements the numeric traits.
151+
/// - `radix` - Base to use. Accepts only the values 2-36. If the exponential notation
152+
/// is used, then this base is only used for the significand. The exponent
153+
/// itself always printed using a base of 10.
154+
/// - `negative_zero` - Whether to treat the special value `-0` as
155+
/// `-0` or as `+0`.
156+
/// - `sign` - How to emit the sign. See `SignFormat`.
157+
/// - `digits` - The amount of digits to use for emitting the fractional
158+
/// part, if any. See `SignificantDigits`.
159+
/// - `exp_format` - Whether or not to use the exponential (scientific) notation.
160+
/// See `ExponentFormat`.
161+
/// - `exp_capital` - Whether or not to use a capital letter for the exponent sign, if
162+
/// exponential notation is desired.
163+
///
164+
/// # Return value
165+
///
166+
/// A tuple containing the byte vector, and a boolean flag indicating
167+
/// whether it represents a special value like `inf`, `-inf`, `NaN` or not.
168+
/// It returns a tuple because there can be ambiguity between a special value
169+
/// and a number representation at higher bases.
170+
///
171+
/// # Panics
172+
///
173+
/// - Panics if `radix` < 2 or `radix` > 36.
174+
/// - Panics if `radix` > 14 and `exp_format` is `ExpDec` due to conflict
175+
/// between digit and exponent sign `'e'`.
176+
/// - Panics if `radix` > 25 and `exp_format` is `ExpBin` due to conflict
177+
/// between digit and exponent sign `'p'`.
184178
pub fn float_to_str_bytes_common<T: Float>(
185179
num: T, radix: uint, negative_zero: bool,
186180
sign: SignFormat, digits: SignificantDigits, exp_format: ExponentFormat, exp_upper: bool

branches/auto/src/libstd/rt/backtrace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ mod imp {
252252
#[cfg(all(target_os = "ios", target_arch = "arm"))]
253253
#[inline(never)]
254254
pub fn write(w: &mut Writer) -> IoResult<()> {
255-
use iter::{Iterator, range};
255+
use iter::{IteratorExt, range};
256256
use result;
257257
use slice::{SlicePrelude};
258258

branches/auto/src/test/debuginfo/var-captured-in-sendable-closure.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
// gdb-check:$2 = {a = -2, b = 3.5, c = 4}
2424
// gdb-command:print *owned
2525
// gdb-check:$3 = 5
26+
// gdb-command:continue
2627

28+
// gdb-command:print constant2
29+
// gdb-check:$4 = 6
30+
// gdb-command:continue
2731

2832
// === LLDB TESTS ==================================================================================
2933

@@ -37,6 +41,7 @@
3741
// lldb-check:[...]$2 = 5
3842

3943
#![allow(unused_variables)]
44+
#![feature(unboxed_closures)]
4045

4146
struct Struct {
4247
a: int,
@@ -55,12 +60,24 @@ fn main() {
5560

5661
let owned = box 5;
5762

58-
let closure: proc() = proc() {
63+
let closure = move |:| {
5964
zzz(); // #break
6065
do_something(&constant, &a_struct.a, &*owned);
6166
};
6267

6368
closure();
69+
70+
let constant2 = 6u;
71+
72+
// The `self` argument of the following closure should be passed by value
73+
// to FnOnce::call_once(self, args), which gets translated a bit differently
74+
// than the regular case. Let's make sure this is supported too.
75+
let immedate_env = move |:| {
76+
zzz(); // #break
77+
return constant2;
78+
};
79+
80+
immedate_env();
6481
}
6582

6683
fn do_something(_: &int, _:&int, _:&int) {

0 commit comments

Comments
 (0)