Skip to content

Commit 720234a

Browse files
committed
---
yaml --- r: 129014 b: refs/heads/master c: 70ea0bb h: refs/heads/master v: v3
1 parent fe1fde2 commit 720234a

25 files changed

+97
-360
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: d0104d04fdf5126bdc3f76eac93906f25a201ad3
2+
refs/heads/master: 70ea0bb5f5323ff6174488cad6b7f3541bb347d6
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a86d9ad15e339ab343a12513f9c90556f677b9ca
55
refs/heads/try: 961753763fb87ddcbbccaec4ea87648608d19a58

trunk/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ then
635635
LLVM_VERSION=$($LLVM_CONFIG --version)
636636

637637
case $LLVM_VERSION in
638-
(3.[2-5]*)
638+
(3.[2-6]*)
639639
msg "found ok version of LLVM: $LLVM_VERSION"
640640
;;
641641
(*)

trunk/src/doc/guide.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,8 +1073,8 @@ destructuring `let`.
10731073
## Enums
10741074

10751075
Finally, Rust has a "sum type", an **enum**. Enums are an incredibly useful
1076-
feature of Rust, and are used throughout the standard library. This is an enum
1077-
that is provided by the Rust standard library:
1076+
feature of Rust, and are used throughout the standard library. Enums look
1077+
like this:
10781078

10791079
```{rust}
10801080
enum Ordering {
@@ -1084,8 +1084,9 @@ enum Ordering {
10841084
}
10851085
```
10861086

1087-
An `Ordering` can only be _one_ of `Less`, `Equal`, or `Greater` at any given
1088-
time. Here's an example:
1087+
This is an enum that is provided by the Rust standard library. An `Ordering`
1088+
can only be _one_ of `Less`, `Equal`, or `Greater` at any given time. Here's
1089+
an example:
10891090

10901091
```{rust}
10911092
fn cmp(a: int, b: int) -> Ordering {
@@ -2896,11 +2897,9 @@ pub fn print_hello() {
28962897
}
28972898
```
28982899

2899-
When we include a module like this, we don't need to make the `mod` declaration
2900-
in `hello.rs`, because it's already been declared in `lib.rs`. `hello.rs` just
2901-
contains the body of the module which is defined (by the `pub mod hello`) in
2902-
`lib.rs`. This helps prevent 'rightward drift': when you end up indenting so
2903-
many times that your code is hard to read.
2900+
When we include a module like this, we don't need to make the `mod` declaration,
2901+
it's just understood. This helps prevent 'rightward drift': when you end up
2902+
indenting so many times that your code is hard to read.
29042903

29052904
Finally, make a new directory, `src/goodbye`, and make a new file in it,
29062905
`src/goodbye/mod.rs`:

trunk/src/libarena/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ mod tests {
563563

564564
struct Noncopy {
565565
string: String,
566-
array: Vec<int>,
566+
array: Vec<int> ,
567567
}
568568

569569
#[test]

trunk/src/libcollections/bitv.rs

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,9 +2566,7 @@ mod tests {
25662566
let mut r = rng();
25672567
let mut bitv = 0 as uint;
25682568
b.iter(|| {
2569-
for _ in range(0u, 100) {
2570-
bitv |= 1 << ((r.next_u32() as uint) % uint::BITS);
2571-
}
2569+
bitv |= 1 << ((r.next_u32() as uint) % uint::BITS);
25722570
&bitv
25732571
})
25742572
}
@@ -2578,9 +2576,7 @@ mod tests {
25782576
let mut r = rng();
25792577
let mut bitv = Bitv::with_capacity(BENCH_BITS, false);
25802578
b.iter(|| {
2581-
for _ in range(0u, 100) {
2582-
bitv.set((r.next_u32() as uint) % BENCH_BITS, true);
2583-
}
2579+
bitv.set((r.next_u32() as uint) % BENCH_BITS, true);
25842580
&bitv
25852581
})
25862582
}
@@ -2590,9 +2586,7 @@ mod tests {
25902586
let mut r = rng();
25912587
let mut bitv = Bitv::with_capacity(uint::BITS, false);
25922588
b.iter(|| {
2593-
for _ in range(0u, 100) {
2594-
bitv.set((r.next_u32() as uint) % uint::BITS, true);
2595-
}
2589+
bitv.set((r.next_u32() as uint) % uint::BITS, true);
25962590
&bitv
25972591
})
25982592
}
@@ -2602,9 +2596,7 @@ mod tests {
26022596
let mut r = rng();
26032597
let mut bitv = BitvSet::new();
26042598
b.iter(|| {
2605-
for _ in range(0u, 100) {
2606-
bitv.insert((r.next_u32() as uint) % uint::BITS);
2607-
}
2599+
bitv.insert((r.next_u32() as uint) % uint::BITS);
26082600
&bitv
26092601
})
26102602
}
@@ -2614,9 +2606,7 @@ mod tests {
26142606
let mut r = rng();
26152607
let mut bitv = BitvSet::new();
26162608
b.iter(|| {
2617-
for _ in range(0u, 100) {
2618-
bitv.insert((r.next_u32() as uint) % BENCH_BITS);
2619-
}
2609+
bitv.insert((r.next_u32() as uint) % BENCH_BITS);
26202610
&bitv
26212611
})
26222612
}
@@ -2626,33 +2616,29 @@ mod tests {
26262616
let mut b1 = Bitv::with_capacity(BENCH_BITS, false);
26272617
let b2 = Bitv::with_capacity(BENCH_BITS, false);
26282618
b.iter(|| {
2629-
b1.union(&b2)
2619+
b1.union(&b2);
26302620
})
26312621
}
26322622

26332623
#[bench]
2634-
fn bench_bitv_small_iter(b: &mut Bencher) {
2624+
fn bench_btv_small_iter(b: &mut Bencher) {
26352625
let bitv = Bitv::with_capacity(uint::BITS, false);
26362626
b.iter(|| {
2637-
let mut sum = 0;
2638-
for _ in range(0u, 10) {
2639-
for pres in bitv.iter() {
2640-
sum += pres as uint;
2641-
}
2627+
let mut _sum = 0;
2628+
for pres in bitv.iter() {
2629+
_sum += pres as uint;
26422630
}
2643-
sum
26442631
})
26452632
}
26462633

26472634
#[bench]
26482635
fn bench_bitv_big_iter(b: &mut Bencher) {
26492636
let bitv = Bitv::with_capacity(BENCH_BITS, false);
26502637
b.iter(|| {
2651-
let mut sum = 0;
2638+
let mut _sum = 0;
26522639
for pres in bitv.iter() {
2653-
sum += pres as uint;
2640+
_sum += pres as uint;
26542641
}
2655-
sum
26562642
})
26572643
}
26582644

@@ -2661,11 +2647,10 @@ mod tests {
26612647
let bitv = BitvSet::from_bitv(from_fn(BENCH_BITS,
26622648
|idx| {idx % 3 == 0}));
26632649
b.iter(|| {
2664-
let mut sum = 0;
2650+
let mut _sum = 0;
26652651
for idx in bitv.iter() {
2666-
sum += idx;
2652+
_sum += idx;
26672653
}
2668-
sum
26692654
})
26702655
}
26712656
}

trunk/src/libcore/mem.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,6 @@ use ptr;
1919

2020
pub use intrinsics::transmute;
2121

22-
/// Moves a thing into the void.
23-
///
24-
/// The forget function will take ownership of the provided value but neglect
25-
/// to run any required cleanup or memory management operations on it.
26-
///
27-
/// This function is the unsafe version of the `drop` function because it does
28-
/// not run any destructors.
29-
#[stable]
30-
pub use intrinsics::forget;
31-
3222
/// Returns the size of a type in bytes.
3323
#[inline]
3424
#[stable]
@@ -347,6 +337,17 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
347337
#[stable]
348338
pub fn drop<T>(_x: T) { }
349339

340+
/// Moves a thing into the void.
341+
///
342+
/// The forget function will take ownership of the provided value but neglect
343+
/// to run any required cleanup or memory management operations on it.
344+
///
345+
/// This function is the unsafe version of the `drop` function because it does
346+
/// not run any destructors.
347+
#[inline]
348+
#[stable]
349+
pub unsafe fn forget<T>(thing: T) { intrinsics::forget(thing) }
350+
350351
/// Interprets `src` as `&U`, and then reads `src` without moving the contained
351352
/// value.
352353
///

trunk/src/libgetopts/lib.rs

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
571571
}
572572
} else {
573573
let mut j = 1;
574+
let mut last_valid_opt_id = None;
574575
names = Vec::new();
575576
while j < curlen {
576577
let range = cur.as_slice().char_range_at(j);
@@ -583,24 +584,27 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
583584
interpreted correctly
584585
*/
585586

586-
let opt_id = match find_opt(opts.as_slice(), opt.clone()) {
587-
Some(id) => id,
588-
None => return Err(UnrecognizedOption(opt.to_string()))
589-
};
590-
591-
names.push(opt);
592-
593-
let arg_follows = match opts[opt_id].hasarg {
594-
Yes | Maybe => true,
595-
No => false
596-
};
597-
598-
if arg_follows && range.next < curlen {
599-
i_arg = Some(cur.as_slice()
600-
.slice(range.next, curlen).to_string());
601-
break;
587+
match find_opt(opts.as_slice(), opt.clone()) {
588+
Some(id) => last_valid_opt_id = Some(id),
589+
None => {
590+
let arg_follows =
591+
last_valid_opt_id.is_some() &&
592+
match opts[last_valid_opt_id.unwrap()]
593+
.hasarg {
594+
595+
Yes | Maybe => true,
596+
No => false
597+
};
598+
if arg_follows && j < curlen {
599+
i_arg = Some(cur.as_slice()
600+
.slice(j, curlen).to_string());
601+
break;
602+
} else {
603+
last_valid_opt_id = None;
604+
}
605+
}
602606
}
603-
607+
names.push(opt);
604608
j = range.next;
605609
}
606610
}
@@ -613,7 +617,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
613617
};
614618
match opts[optid].hasarg {
615619
No => {
616-
if name_pos == names.len() && !i_arg.is_none() {
620+
if !i_arg.is_none() {
617621
return Err(UnexpectedArgument(nm.to_string()));
618622
}
619623
vals.get_mut(optid).push(Given);
@@ -1437,21 +1441,6 @@ mod tests {
14371441

14381442
}
14391443

1440-
#[test]
1441-
fn test_nospace_conflict() {
1442-
let args = vec!("-vvLverbose".to_string(), "-v".to_string() );
1443-
let opts = vec!(optmulti("L", "", "library directory", "LIB"),
1444-
optflagmulti("v", "verbose", "Verbose"));
1445-
let matches = &match getopts(args.as_slice(), opts.as_slice()) {
1446-
result::Ok(m) => m,
1447-
result::Err(e) => fail!( "{}", e )
1448-
};
1449-
assert!(matches.opts_present(["L".to_string()]));
1450-
assert_eq!(matches.opts_str(["L".to_string()]).unwrap(), "verbose".to_string());
1451-
assert!(matches.opts_present(["v".to_string()]));
1452-
assert_eq!(3, matches.opt_count("v"));
1453-
}
1454-
14551444
#[test]
14561445
fn test_long_to_short() {
14571446
let mut short = Opt {

trunk/src/librustc/middle/resolve_lifetime.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ impl<'a> LifetimeContext<'a> {
206206

207207
self.check_lifetime_names(&generics.lifetimes);
208208

209-
let referenced_idents = free_lifetimes(&generics.ty_params,
210-
&generics.where_clause);
209+
let referenced_idents = free_lifetimes(&generics.ty_params);
211210
debug!("pushing fn scope id={} due to fn item/method\
212211
referenced_idents={:?}",
213212
n,
@@ -404,8 +403,7 @@ fn search_lifetimes(lifetimes: &Vec<ast::LifetimeDef>,
404403
///////////////////////////////////////////////////////////////////////////
405404

406405
pub fn early_bound_lifetimes<'a>(generics: &'a ast::Generics) -> Vec<ast::LifetimeDef> {
407-
let referenced_idents = free_lifetimes(&generics.ty_params,
408-
&generics.where_clause);
406+
let referenced_idents = free_lifetimes(&generics.ty_params);
409407
if referenced_idents.is_empty() {
410408
return Vec::new();
411409
}
@@ -416,9 +414,7 @@ pub fn early_bound_lifetimes<'a>(generics: &'a ast::Generics) -> Vec<ast::Lifeti
416414
.collect()
417415
}
418416

419-
pub fn free_lifetimes(ty_params: &OwnedSlice<ast::TyParam>,
420-
where_clause: &ast::WhereClause)
421-
-> Vec<ast::Name> {
417+
pub fn free_lifetimes(ty_params: &OwnedSlice<ast::TyParam>) -> Vec<ast::Name> {
422418
/*!
423419
* Gathers up and returns the names of any lifetimes that appear
424420
* free in `ty_params`. Of course, right now, all lifetimes appear
@@ -430,9 +426,6 @@ pub fn free_lifetimes(ty_params: &OwnedSlice<ast::TyParam>,
430426
for ty_param in ty_params.iter() {
431427
visit::walk_ty_param_bounds(&mut collector, &ty_param.bounds, ());
432428
}
433-
for predicate in where_clause.predicates.iter() {
434-
visit::walk_ty_param_bounds(&mut collector, &predicate.bounds, ());
435-
}
436429
return collector.names;
437430

438431
struct FreeLifetimeCollector {

trunk/src/librustc/middle/trans/base.rs

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,44 +2240,26 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t)
22402240
ty::ty_bare_fn(ref f) => (f.sig.clone(), f.abi, false),
22412241
ty::ty_unboxed_closure(closure_did, _) => {
22422242
let unboxed_closures = ccx.tcx.unboxed_closures.borrow();
2243-
let ref function_type = unboxed_closures.get(&closure_did)
2244-
.closure_type;
2245-
2243+
let function_type = unboxed_closures.get(&closure_did)
2244+
.closure_type
2245+
.clone();
22462246
(function_type.sig.clone(), RustCall, true)
22472247
}
2248-
_ => ccx.sess().bug("expected closure or function.")
2248+
_ => fail!("expected closure or function.")
22492249
};
22502250

2251-
22522251
// Since index 0 is the return value of the llvm func, we start
22532252
// at either 1 or 2 depending on whether there's an env slot or not
22542253
let mut first_arg_offset = if has_env { 2 } else { 1 };
22552254
let mut attrs = llvm::AttrBuilder::new();
22562255
let ret_ty = fn_sig.output;
22572256

2258-
// These have an odd calling convention, so we need to manually
2259-
// unpack the input ty's
2260-
let input_tys = match ty::get(fn_ty).sty {
2261-
ty::ty_unboxed_closure(_, _) => {
2262-
assert!(abi == RustCall);
2263-
2264-
match ty::get(fn_sig.inputs[0]).sty {
2265-
ty::ty_nil => Vec::new(),
2266-
ty::ty_tup(ref inputs) => inputs.clone(),
2267-
_ => ccx.sess().bug("expected tuple'd inputs")
2268-
}
2269-
},
2270-
ty::ty_bare_fn(_) if abi == RustCall => {
2271-
let inputs = vec![fn_sig.inputs[0]];
2272-
2273-
match ty::get(fn_sig.inputs[1]).sty {
2274-
ty::ty_nil => inputs,
2275-
ty::ty_tup(ref t_in) => inputs.append(t_in.as_slice()),
2276-
_ => ccx.sess().bug("expected tuple'd inputs")
2277-
}
2278-
}
2279-
_ => fn_sig.inputs.clone()
2280-
};
2257+
// These have an odd calling convention, so we skip them for now.
2258+
//
2259+
// FIXME(pcwalton): We don't have to skip them; just untuple the result.
2260+
if abi == RustCall {
2261+
return attrs;
2262+
}
22812263

22822264
// A function pointer is called without the declaration
22832265
// available, so we have to apply any attributes with ABI
@@ -2333,7 +2315,7 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t)
23332315
}
23342316
}
23352317

2336-
for (idx, &t) in input_tys.iter().enumerate().map(|(i, v)| (i + first_arg_offset, v)) {
2318+
for (idx, &t) in fn_sig.inputs.iter().enumerate().map(|(i, v)| (i + first_arg_offset, v)) {
23372319
match ty::get(t).sty {
23382320
// this needs to be first to prevent fat pointers from falling through
23392321
_ if !type_is_immediate(ccx, t) => {

0 commit comments

Comments
 (0)