Skip to content

Commit 8712dfb

Browse files
committed
---
yaml --- r: 128959 b: refs/heads/try c: 655600b h: refs/heads/master i: 128957: e4df134 128955: a747a69 128951: 8ec3b06 128943: 6fe31ab 128927: 7e009a5 128895: 877d138 v: v3
1 parent 8b7700f commit 8712dfb

File tree

25 files changed

+609
-185
lines changed

25 files changed

+609
-185
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 07d86b46a949a94223da714e35b343243e4ecce4
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a86d9ad15e339ab343a12513f9c90556f677b9ca
5-
refs/heads/try: 1f1620eed72f9b9c650576e3f6509c3267f0ab78
5+
refs/heads/try: 655600b01b88c2fb2f91965e2b505068db7d808f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/doc/guide-pointers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ let z = &x;
332332
Mutable ones, however, are not:
333333

334334
```{rust,ignore}
335-
let x = 5i;
335+
let mut x = 5i;
336336
let y = &mut x;
337337
let z = &mut x; // error: cannot borrow `x` as mutable more than once at a time
338338
```

branches/try/src/doc/guide-tasks.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,9 @@ closure in the new task.
8989
fn print_message() { println!("I am running in a different task!"); }
9090
spawn(print_message);
9191
92-
// Print something profound in a different task using a `proc` expression
92+
// Alternatively, use a `proc` expression instead of a named function.
9393
// The `proc` expression evaluates to an (unnamed) owned closure.
9494
// That closure will call `println!(...)` when the spawned task runs.
95-
9695
spawn(proc() println!("I am also running in a different task!") );
9796
~~~~
9897

@@ -352,14 +351,14 @@ fn main() {
352351

353352
The function `pnorm` performs a simple computation on the vector (it computes the sum of its items
354353
at the power given as argument and takes the inverse power of this value). The Arc on the vector is
355-
created by the line
354+
created by the line:
356355

357356
~~~
358357
# use std::rand;
359358
# use std::sync::Arc;
360359
# fn main() {
361360
# let numbers = Vec::from_fn(1000000, |_| rand::random::<f64>());
362-
let numbers_arc=Arc::new(numbers);
361+
let numbers_arc = Arc::new(numbers);
363362
# }
364363
~~~
365364

branches/try/src/libcore/str.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,13 +1094,25 @@ pub trait StrSlice<'a> {
10941094
/// # Arguments
10951095
///
10961096
/// - needle - The string to look for
1097+
///
1098+
/// # Example
1099+
///
1100+
/// ```rust
1101+
/// assert!("bananas".contains("nana"));
1102+
/// ```
10971103
fn contains<'a>(&self, needle: &'a str) -> bool;
10981104

10991105
/// Returns true if a string contains a char.
11001106
///
11011107
/// # Arguments
11021108
///
11031109
/// - needle - The char to look for
1110+
///
1111+
/// # Example
1112+
///
1113+
/// ```rust
1114+
/// assert!("hello".contains_char('e'));
1115+
/// ```
11041116
fn contains_char(&self, needle: char) -> bool;
11051117

11061118
/// An iterator over the characters of `self`. Note, this iterates
@@ -1115,6 +1127,13 @@ pub trait StrSlice<'a> {
11151127
fn chars(&self) -> Chars<'a>;
11161128

11171129
/// An iterator over the bytes of `self`
1130+
///
1131+
/// # Example
1132+
///
1133+
/// ```rust
1134+
/// let v: Vec<u8> = "bors".bytes().collect();
1135+
/// assert_eq!(v, b"bors".to_vec());
1136+
/// ```
11181137
fn bytes(&self) -> Bytes<'a>;
11191138

11201139
/// An iterator over the characters of `self` and their byte offsets.
@@ -1381,9 +1400,21 @@ pub trait StrSlice<'a> {
13811400
fn slice_chars(&self, begin: uint, end: uint) -> &'a str;
13821401

13831402
/// Returns true if `needle` is a prefix of the string.
1403+
///
1404+
/// # Example
1405+
///
1406+
/// ```rust
1407+
/// assert!("banana".starts_with("ba"));
1408+
/// ```
13841409
fn starts_with(&self, needle: &str) -> bool;
13851410

13861411
/// Returns true if `needle` is a suffix of the string.
1412+
///
1413+
/// # Example
1414+
///
1415+
/// ```rust
1416+
/// assert!("banana".ends_with("nana"));
1417+
/// ```
13871418
fn ends_with(&self, needle: &str) -> bool;
13881419

13891420
/// Returns a string with characters that match `to_trim` removed.
@@ -1525,6 +1556,15 @@ pub trait StrSlice<'a> {
15251556

15261557
/// Plucks the character starting at the `i`th byte of a string.
15271558
///
1559+
/// # Example
1560+
///
1561+
/// ```rust
1562+
/// let s = "abπc";
1563+
/// assert_eq!(s.char_at(1), 'b');
1564+
/// assert_eq!(s.char_at(2), 'π');
1565+
/// assert_eq!(s.char_at(4), 'c');
1566+
/// ```
1567+
///
15281568
/// # Failure
15291569
///
15301570
/// If `i` is greater than or equal to the length of the string.
@@ -1540,6 +1580,12 @@ pub trait StrSlice<'a> {
15401580
fn char_at_reverse(&self, i: uint) -> char;
15411581

15421582
/// Work with the byte buffer of a string as a byte slice.
1583+
///
1584+
/// # Example
1585+
///
1586+
/// ```rust
1587+
/// assert_eq!("bors".as_bytes(), b"bors");
1588+
/// ```
15431589
fn as_bytes(&self) -> &'a [u8];
15441590

15451591
/// Returns the byte index of the first character of `self` that

branches/try/src/liblibc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ extern {}
304304
// If/when libprim happens, this can be removed in favor of that
305305
pub enum Nullable<T> {
306306
Null,
307-
Some(T)
307+
NotNull(T)
308308
}
309309

310310
pub mod types {

branches/try/src/librustc/middle/cfg/construct.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,14 +473,15 @@ impl<'a> CFGBuilder<'a> {
473473
ast::ExprInlineAsm(ref inline_asm) => {
474474
let inputs = inline_asm.inputs.iter();
475475
let outputs = inline_asm.outputs.iter();
476-
fn extract_expr<A>(&(_, expr): &(A, Gc<ast::Expr>)) -> Gc<ast::Expr> { expr }
477476
let post_inputs = self.exprs(inputs.map(|a| {
478477
debug!("cfg::construct InlineAsm id:{} input:{:?}", expr.id, a);
479-
extract_expr(a)
478+
let &(_, expr) = a;
479+
expr
480480
}), pred);
481481
let post_outputs = self.exprs(outputs.map(|a| {
482482
debug!("cfg::construct InlineAsm id:{} output:{:?}", expr.id, a);
483-
extract_expr(a)
483+
let &(_, expr, _) = a;
484+
expr
484485
}), post_inputs);
485486
self.add_node(expr.id, [post_outputs])
486487
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,9 @@ impl<'d,'t,TYPER:mc::Typer> ExprUseVisitor<'d,'t,TYPER> {
380380
self.consume_expr(&**input);
381381
}
382382

383-
for &(_, ref output) in ia.outputs.iter() {
384-
self.mutate_expr(expr, &**output, JustWrite);
383+
for &(_, ref output, is_rw) in ia.outputs.iter() {
384+
self.mutate_expr(expr, &**output,
385+
if is_rw { WriteAndRead } else { JustWrite });
385386
}
386387
}
387388

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,9 +1192,10 @@ impl<'a> Liveness<'a> {
11921192
}
11931193

11941194
ExprInlineAsm(ref ia) => {
1195-
let succ = ia.outputs.iter().rev().fold(succ, |succ, &(_, ref expr)| {
1196-
// see comment on lvalues in
1197-
// propagate_through_lvalue_components()
1195+
1196+
let succ = ia.outputs.iter().rev().fold(succ, |succ, &(_, ref expr, _)| {
1197+
// see comment on lvalues
1198+
// in propagate_through_lvalue_components()
11981199
let succ = self.write_lvalue(&**expr, succ, ACC_WRITE);
11991200
self.propagate_through_lvalue_components(&**expr, succ)
12001201
});
@@ -1437,7 +1438,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
14371438
}
14381439

14391440
// Output operands must be lvalues
1440-
for &(_, ref out) in ia.outputs.iter() {
1441+
for &(_, ref out, _) in ia.outputs.iter() {
14411442
this.check_lvalue(&**out);
14421443
this.visit_expr(&**out, ());
14431444
}

branches/try/src/librustc/middle/trans/asm.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,27 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)
3636

3737
let temp_scope = fcx.push_custom_cleanup_scope();
3838

39+
let mut ext_inputs = Vec::new();
40+
let mut ext_constraints = Vec::new();
41+
3942
// Prepare the output operands
40-
let outputs = ia.outputs.iter().map(|&(ref c, ref out)| {
43+
let outputs = ia.outputs.iter().enumerate().map(|(i, &(ref c, ref out, is_rw))| {
4144
constraints.push((*c).clone());
4245

4346
let out_datum = unpack_datum!(bcx, expr::trans(bcx, &**out));
4447
output_types.push(type_of::type_of(bcx.ccx(), out_datum.ty));
45-
out_datum.val
48+
let val = out_datum.val;
49+
if is_rw {
50+
ext_inputs.push(unpack_result!(bcx, {
51+
callee::trans_arg_datum(bcx,
52+
expr_ty(bcx, &**out),
53+
out_datum,
54+
cleanup::CustomScope(temp_scope),
55+
callee::DontAutorefArg)
56+
}));
57+
ext_constraints.push(i.to_string());
58+
}
59+
val
4660

4761
}).collect::<Vec<_>>();
4862

@@ -58,14 +72,15 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)
5872
cleanup::CustomScope(temp_scope),
5973
callee::DontAutorefArg)
6074
})
61-
}).collect::<Vec<_>>();
75+
}).collect::<Vec<_>>().append(ext_inputs.as_slice());
6276

6377
// no failure occurred preparing operands, no need to cleanup
6478
fcx.pop_custom_cleanup_scope(temp_scope);
6579

6680
let mut constraints =
6781
String::from_str(constraints.iter()
6882
.map(|s| s.get().to_string())
83+
.chain(ext_constraints.move_iter())
6984
.collect::<Vec<String>>()
7085
.connect(",")
7186
.as_slice());

branches/try/src/librustc/middle/trans/cabi_x86_64.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,15 @@ fn classify_ty(ty: Type) -> Vec<RegClass> {
176176
}
177177

178178
fn classify_struct(tys: &[Type],
179-
cls: &mut [RegClass], i: uint,
180-
off: uint) {
179+
cls: &mut [RegClass],
180+
i: uint,
181+
off: uint,
182+
packed: bool) {
181183
let mut field_off = off;
182184
for ty in tys.iter() {
183-
field_off = align(field_off, *ty);
185+
if !packed {
186+
field_off = align(field_off, *ty);
187+
}
184188
classify(*ty, cls, i, field_off);
185189
field_off += ty_size(*ty);
186190
}
@@ -219,7 +223,7 @@ fn classify_ty(ty: Type) -> Vec<RegClass> {
219223
unify(cls, ix + off / 8u, SSEDs);
220224
}
221225
Struct => {
222-
classify_struct(ty.field_types().as_slice(), cls, ix, off);
226+
classify_struct(ty.field_types().as_slice(), cls, ix, off, ty.is_packed());
223227
}
224228
Array => {
225229
let len = ty.array_length();

branches/try/src/librustc/middle/trans/debuginfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3729,7 +3729,7 @@ fn populate_scope_map(cx: &CrateContext,
37293729
walk_expr(cx, &**exp, scope_stack, scope_map);
37303730
}
37313731

3732-
for &(_, ref exp) in outputs.iter() {
3732+
for &(_, ref exp, _) in outputs.iter() {
37333733
walk_expr(cx, &**exp, scope_stack, scope_map);
37343734
}
37353735
}

branches/try/src/librustc/middle/typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3332,7 +3332,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
33323332
for &(_, ref input) in ia.inputs.iter() {
33333333
check_expr(fcx, &**input);
33343334
}
3335-
for &(_, ref out) in ia.outputs.iter() {
3335+
for &(_, ref out, _) in ia.outputs.iter() {
33363336
check_expr(fcx, &**out);
33373337
}
33383338
fcx.write_nil(id);

0 commit comments

Comments
 (0)