Skip to content

Commit 500e5c1

Browse files
committed
Auto merge of #33758 - GuillaumeGomez:rollup, r=Manishearth
Rollup of 6 pull requests - Successful merges: #33668, #33676, #33683, #33734, #33739, #33745 - Failed merges: #33578
2 parents 179539f + 4a3ba87 commit 500e5c1

31 files changed

+415
-25
lines changed

Diff for: src/doc/book/casting-between-types.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ cast four bytes into a `u32`:
135135
```rust,ignore
136136
let a = [0u8, 0u8, 0u8, 0u8];
137137
138-
let b = a as u32; // four eights makes 32
138+
let b = a as u32; // four u8s makes a u32
139139
```
140140

141141
This errors with:
142142

143143
```text
144144
error: non-scalar cast: `[u8; 4]` as `u32`
145-
let b = a as u32; // four eights makes 32
145+
let b = a as u32; // four u8s makes a u32
146146
^~~~~~~~
147147
```
148148

Diff for: src/libcore/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ macro_rules! assert {
8686
#[stable(feature = "rust1", since = "1.0.0")]
8787
macro_rules! assert_eq {
8888
($left:expr , $right:expr) => ({
89-
match (&($left), &($right)) {
89+
match (&$left, &$right) {
9090
(left_val, right_val) => {
9191
if !(*left_val == *right_val) {
9292
panic!("assertion failed: `(left == right)` \

Diff for: src/libcore/sync/atomic.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
//! [1]: http://llvm.org/docs/LangRef.html#memory-model-for-concurrent-operations
2727
//!
2828
//! Atomic variables are safe to share between threads (they implement `Sync`)
29-
//! but they do not themselves provide the mechanism for sharing. The most
30-
//! common way to share an atomic variable is to put it into an `Arc` (an
29+
//! but they do not themselves provide the mechanism for sharing and follow the
30+
//! [threading model](../../../std/thread/index.html#the-threading-model) of rust.
31+
//! The most common way to share an atomic variable is to put it into an `Arc` (an
3132
//! atomically-reference-counted shared pointer).
3233
//!
3334
//! Most atomic types may be stored in static variables, initialized using
@@ -48,12 +49,16 @@
4849
//! let spinlock = Arc::new(AtomicUsize::new(1));
4950
//!
5051
//! let spinlock_clone = spinlock.clone();
51-
//! thread::spawn(move|| {
52+
//! let thread = thread::spawn(move|| {
5253
//! spinlock_clone.store(0, Ordering::SeqCst);
5354
//! });
5455
//!
5556
//! // Wait for the other thread to release the lock
5657
//! while spinlock.load(Ordering::SeqCst) != 0 {}
58+
//!
59+
//! if let Err(panic) = thread.join() {
60+
//! println!("Thread had an error: {:?}", panic);
61+
//! }
5762
//! }
5863
//! ```
5964
//!

Diff for: src/librustc/hir/lowering.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1286,8 +1286,12 @@ impl<'a> LoweringContext<'a> {
12861286
maybe_expr.as_ref().map(|x| self.lower_expr(x)))
12871287
}
12881288
ExprKind::Paren(ref ex) => {
1289-
// merge attributes into the inner expression.
12901289
return self.lower_expr(ex).map(|mut ex| {
1290+
// include parens in span, but only if it is a super-span.
1291+
if e.span.contains(ex.span) {
1292+
ex.span = e.span;
1293+
}
1294+
// merge attributes into the inner expression.
12911295
ex.attrs.update(|attrs| {
12921296
attrs.prepend(e.attrs.clone())
12931297
});

Diff for: src/librustc_borrowck/borrowck/gather_loans/move_error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
152152
ty::TyEnum(def, _) if def.has_dtor() => {
153153
let mut err = struct_span_err!(bccx, move_from.span, E0509,
154154
"cannot move out of type `{}`, \
155-
which defines the `Drop` trait",
155+
which implements the `Drop` trait",
156156
b.ty);
157157
err.span_label(move_from.span, &format!("cannot move out of here"));
158158
err

Diff for: src/librustc_trans/base.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,13 @@ pub fn coerce_unsized_into<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
617617
(&ty::TyRawPtr(..), &ty::TyRawPtr(..)) => {
618618
let (base, info) = if common::type_is_fat_ptr(bcx.tcx(), src_ty) {
619619
// fat-ptr to fat-ptr unsize preserves the vtable
620-
load_fat_ptr(bcx, src, src_ty)
620+
// i.e. &'a fmt::Debug+Send => &'a fmt::Debug
621+
// So we need to pointercast the base to ensure
622+
// the types match up.
623+
let (base, info) = load_fat_ptr(bcx, src, src_ty);
624+
let llcast_ty = type_of::fat_ptr_base_ty(bcx.ccx(), dst_ty);
625+
let base = PointerCast(bcx, base, llcast_ty);
626+
(base, info)
621627
} else {
622628
let base = load_ty(bcx, src, src_ty);
623629
unsize_thin_ptr(bcx, base, src_ty, dst_ty)

Diff for: src/librustc_trans/mir/rvalue.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,17 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
262262
assert!(common::type_is_fat_ptr(bcx.tcx(), cast_ty));
263263

264264
match operand.val {
265-
OperandValue::FatPtr(..) => {
265+
OperandValue::FatPtr(lldata, llextra) => {
266266
// unsize from a fat pointer - this is a
267267
// "trait-object-to-supertrait" coercion, for
268268
// example,
269269
// &'a fmt::Debug+Send => &'a fmt::Debug,
270-
// and is a no-op at the LLVM level
270+
// So we need to pointercast the base to ensure
271+
// the types match up.
271272
self.set_operand_dropped(&bcx, source);
272-
operand.val
273+
let llcast_ty = type_of::fat_ptr_base_ty(bcx.ccx(), cast_ty);
274+
let lldata = bcx.pointercast(lldata, llcast_ty);
275+
OperandValue::FatPtr(lldata, llextra)
273276
}
274277
OperandValue::Immediate(lldata) => {
275278
// "standard" unsize

Diff for: src/librustc_trans/type_of.rs

+11
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,17 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
157157
llsizingty
158158
}
159159

160+
pub fn fat_ptr_base_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> Type {
161+
match ty.sty {
162+
ty::TyBox(t) |
163+
ty::TyRef(_, ty::TypeAndMut { ty: t, .. }) |
164+
ty::TyRawPtr(ty::TypeAndMut { ty: t, .. }) if !type_is_sized(ccx.tcx(), t) => {
165+
in_memory_type_of(ccx, t).ptr_to()
166+
}
167+
_ => bug!("expected fat ptr ty but got {:?}", ty)
168+
}
169+
}
170+
160171
fn unsized_info_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> Type {
161172
let unsized_part = ccx.tcx().struct_tail(ty);
162173
match unsized_part.sty {

Diff for: src/test/compile-fail/E0036.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct Test;
12+
13+
impl Test {
14+
fn method<T>(&self, v: &[T]) -> usize {
15+
v.len()
16+
}
17+
}
18+
19+
fn main() {
20+
let x = Test;
21+
let v = &[0];
22+
x.method::<i32, i32>(v); //~ ERROR E0036
23+
}

Diff for: src/test/compile-fail/E0038.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait Trait {
12+
fn foo(&self) -> Self;
13+
}
14+
15+
fn call_foo(x: Box<Trait>) { //~ ERROR E0038
16+
let y = x.foo();
17+
}
18+
19+
fn main() {
20+
}

Diff for: src/test/compile-fail/E0040.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct Foo {
12+
x: i32,
13+
}
14+
15+
impl Drop for Foo {
16+
fn drop(&mut self) {
17+
println!("kaboom");
18+
}
19+
}
20+
21+
fn main() {
22+
let mut x = Foo { x: -7 };
23+
x.drop(); //~ ERROR E0040
24+
}

Diff for: src/test/compile-fail/E0044.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
extern { fn some_func<T>(x: T); } //~ ERROR E0044
12+
13+
fn main() {
14+
}

Diff for: src/test/compile-fail/E0045.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
extern "rust-call" { fn foo(x: u8, ...); } //~ ERROR E0045
12+
13+
fn main() {
14+
}

Diff for: src/test/compile-fail/E0046.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait Foo {
12+
fn foo();
13+
}
14+
15+
struct Bar;
16+
17+
impl Foo for Bar {} //~ ERROR E0046
18+
19+
fn main() {
20+
}

Diff for: src/test/compile-fail/E0049.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait Foo {
12+
fn foo<T: Default>(x: T) -> Self;
13+
}
14+
15+
struct Bar;
16+
17+
impl Foo for Bar {
18+
fn foo(x: bool) -> Self { Bar } //~ ERROR E0049
19+
}
20+
21+
fn main() {
22+
}

Diff for: src/test/compile-fail/E0050.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait Foo {
12+
fn foo(&self, x: u8) -> bool;
13+
}
14+
15+
struct Bar;
16+
17+
impl Foo for Bar {
18+
fn foo(&self) -> bool { true } //~ ERROR E0050
19+
}
20+
21+
fn main() {
22+
}

Diff for: src/test/compile-fail/E0053.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait Foo {
12+
fn foo(x: u16);
13+
fn bar(&self);
14+
}
15+
16+
struct Bar;
17+
18+
impl Foo for Bar {
19+
fn foo(x: i16) { } //~ ERROR E0053
20+
fn bar(&mut self) { } //~ ERROR E0053
21+
}
22+
23+
fn main() {
24+
}

Diff for: src/test/compile-fail/E0054.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
let x = 5;
13+
let x_is_nonzero = x as bool; //~ ERROR E0054
14+
}

Diff for: src/test/compile-fail/E0055.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![recursion_limit="2"]
12+
struct Foo;
13+
14+
impl Foo {
15+
fn foo(&self) {}
16+
}
17+
18+
fn main() {
19+
let foo = Foo;
20+
let ref_foo = &&Foo;
21+
ref_foo.foo(); //~ ERROR E0055
22+
//~^ ERROR E0275
23+
}

Diff for: src/test/compile-fail/E0057.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
let f = |x| x * 3;
13+
let a = f(); //~ ERROR E0057
14+
let b = f(4);
15+
let c = f(2, 3); //~ ERROR E0057
16+
}

Diff for: src/test/compile-fail/E0059.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(unboxed_closures)]
12+
13+
fn foo<F: Fn<i32>>(f: F) -> F::Output { f(3) } //~ ERROR E0059
14+
15+
fn main() {
16+
}

0 commit comments

Comments
 (0)