Skip to content

Commit 43d6830

Browse files
committed
---
yaml --- r: 206335 b: refs/heads/beta c: df18642 h: refs/heads/master i: 206333: 892f0c9 206331: f3f7711 206327: 4764851 206319: d6723ee 206303: d7e422b 206271: f4a6f51 206207: 78dedd1 206079: b4c5da1 205823: 0ec64e0 v: v3
1 parent 1973b1f commit 43d6830

File tree

8 files changed

+47
-32
lines changed

8 files changed

+47
-32
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2929
refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3030
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3131
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
32-
refs/heads/beta: 5574029b68e4a66864c4eaff8553cc8086117d56
32+
refs/heads/beta: df18642b1ad80369cefc0cbe626e5b0096654938
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3535
refs/heads/tmp: 579e31929feff51dcaf8d444648eff8de735f91a

branches/beta/src/doc/trpl/concurrency.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ use std::thread;
116116
fn main() {
117117
let mut data = vec![1u32, 2, 3];
118118
119-
for i in 0..3 {
119+
for i in 0..2 {
120120
thread::spawn(move || {
121121
data[i] += 1;
122122
});
@@ -154,7 +154,7 @@ use std::sync::Mutex;
154154
fn main() {
155155
let mut data = Mutex::new(vec![1u32, 2, 3]);
156156
157-
for i in 0..3 {
157+
for i in 0..2 {
158158
let data = data.lock().unwrap();
159159
thread::spawn(move || {
160160
data[i] += 1;
@@ -196,7 +196,7 @@ use std::thread;
196196
fn main() {
197197
let data = Arc::new(Mutex::new(vec![1u32, 2, 3]));
198198
199-
for i in 0..3 {
199+
for i in 0..2 {
200200
let data = data.clone();
201201
thread::spawn(move || {
202202
let mut data = data.lock().unwrap();
@@ -217,7 +217,7 @@ thread more closely:
217217
# use std::thread;
218218
# fn main() {
219219
# let data = Arc::new(Mutex::new(vec![1u32, 2, 3]));
220-
# for i in 0..3 {
220+
# for i in 0..2 {
221221
# let data = data.clone();
222222
thread::spawn(move || {
223223
let mut data = data.lock().unwrap();

branches/beta/src/doc/trpl/patterns.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ This prints `something else`
7070

7171
# Bindings
7272

73-
If you’re matching multiple things, via a `|` or a `...`, you can bind
74-
the value to a name with `@`:
73+
You can bind values to names with `@`:
7574

7675
```rust
7776
let x = 1;
@@ -82,7 +81,36 @@ match x {
8281
}
8382
```
8483

85-
This prints `got a range element 1`.
84+
This prints `got a range element 1`. This is useful when you want to
85+
do a complicated match of part of a data structure:
86+
87+
```rust
88+
#[derive(Debug)]
89+
struct Person {
90+
name: Option<String>,
91+
}
92+
93+
let name = "Steve".to_string();
94+
let mut x: Option<Person> = Some(Person { name: Some(name) });
95+
match x {
96+
Some(Person { name: ref a @ Some(_), .. }) => println!("{:?}", a),
97+
_ => {}
98+
}
99+
```
100+
101+
This prints `Some("Steve")`: We’ve bound the inner `name` to `a`.
102+
103+
If you use `@` with `|`, you need to make sure the name is bound in each part
104+
of the pattern:
105+
106+
```rust
107+
let x = 5;
108+
109+
match x {
110+
e @ 1 ... 5 | e @ 8 ... 10 => println!("got a range element {}", e),
111+
_ => println!("anything"),
112+
}
113+
```
86114

87115
# Ignoring variants
88116

branches/beta/src/liblog/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ macro_rules! info {
136136
}
137137

138138
/// A convenience macro for logging at the debug log level. This macro can also
139-
/// be omitted at compile time by passing `-C debug-assertions` to the compiler. If
139+
/// be omitted at compile time by passing `--cfg ndebug` to the compiler. If
140140
/// this option is not passed, then debug statements will be compiled.
141141
///
142142
/// # Examples

branches/beta/src/librustc_typeck/check/cast.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,9 @@ pub fn check_cast<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, cast: &CastCheck<'tcx>) {
170170
demand::coerce(fcx, e.span, t_1, &e);
171171
}
172172
}
173-
} else if fcx.type_is_fat_ptr(t_e, span) != fcx.type_is_fat_ptr(t_1, span) {
173+
} else if fcx.type_is_fat_ptr(t_e, span) && !fcx.type_is_fat_ptr(t_1, span) {
174174
fcx.type_error_message(span, |actual| {
175-
format!("illegal cast; cast to or from fat pointer: `{}` as `{}` \
176-
involving incompatible type.",
175+
format!("illegal cast; cast from fat pointer: `{}` as `{}`",
177176
actual, fcx.infcx().ty_to_string(t_1))
178177
}, t_e, None);
179178
} else if !(t_e_is_scalar && t_1_is_trivial) {

branches/beta/src/test/compile-fail/fat-ptr-cast.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,12 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// Make sure casts between thin pointer <-> fat pointer are illegal.
12-
13-
pub trait Trait {}
14-
1511
fn main() {
1612
let a: &[i32] = &[1, 2, 3];
1713
let b: Box<[i32]> = Box::new([1, 2, 3]);
1814
let p = a as *const [i32];
19-
let q = a.as_ptr();
20-
21-
a as usize; //~ ERROR illegal cast
22-
b as usize; //~ ERROR illegal cast
23-
p as usize; //~ ERROR illegal cast
24-
25-
// #22955
26-
q as *const [i32]; //~ ERROR illegal cast
2715

28-
// #21397
29-
let t: *mut (Trait + 'static) = 0 as *mut _; //~ ERROR illegal cast
30-
let mut fail: *const str = 0 as *const str; //~ ERROR illegal cast
16+
a as usize; //~ ERROR cast from fat pointer
17+
b as usize; //~ ERROR cast from fat pointer
18+
p as usize; //~ ERROR cast from fat pointer
3119
}

branches/beta/src/test/compile-fail/issue-22034.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
extern crate libc;
1212

1313
fn main() {
14-
let ptr: *mut () = 0 as *mut _;
15-
let _: &mut Fn() = unsafe {
16-
&mut *(ptr as *mut Fn())
17-
//~^ ERROR illegal cast
14+
let foo: *mut libc::c_void;
15+
let cb: &mut Fn() = unsafe {
16+
&mut *(foo as *mut Fn())
17+
//~^ ERROR use of possibly uninitialized variable: `foo`
1818
};
1919
}

branches/beta/src/test/compile-fail/issue-22289.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
// except according to those terms.
1010

1111
fn main() {
12-
0 as &std::any::Any; //~ ERROR illegal cast
12+
0 as &std::any::Any; //~ ERROR non-scalar cast: `i32` as `&core::any::Any`
1313
}

0 commit comments

Comments
 (0)