Auto merge of #33758 - GuillaumeGomez:rollup, r=Manishearth
Rollup of 6 pull requests - Successful merges: #33668, #33676, #33683, #33734, #33739, #33745 - Failed merges: #33578
This commit is contained in:
commit
500e5c15cb
@ -135,14 +135,14 @@ cast four bytes into a `u32`:
|
||||
```rust,ignore
|
||||
let a = [0u8, 0u8, 0u8, 0u8];
|
||||
|
||||
let b = a as u32; // four eights makes 32
|
||||
let b = a as u32; // four u8s makes a u32
|
||||
```
|
||||
|
||||
This errors with:
|
||||
|
||||
```text
|
||||
error: non-scalar cast: `[u8; 4]` as `u32`
|
||||
let b = a as u32; // four eights makes 32
|
||||
let b = a as u32; // four u8s makes a u32
|
||||
^~~~~~~~
|
||||
```
|
||||
|
||||
|
@ -86,7 +86,7 @@ macro_rules! assert {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
macro_rules! assert_eq {
|
||||
($left:expr , $right:expr) => ({
|
||||
match (&($left), &($right)) {
|
||||
match (&$left, &$right) {
|
||||
(left_val, right_val) => {
|
||||
if !(*left_val == *right_val) {
|
||||
panic!("assertion failed: `(left == right)` \
|
||||
|
@ -26,8 +26,9 @@
|
||||
//! [1]: http://llvm.org/docs/LangRef.html#memory-model-for-concurrent-operations
|
||||
//!
|
||||
//! Atomic variables are safe to share between threads (they implement `Sync`)
|
||||
//! but they do not themselves provide the mechanism for sharing. The most
|
||||
//! common way to share an atomic variable is to put it into an `Arc` (an
|
||||
//! but they do not themselves provide the mechanism for sharing and follow the
|
||||
//! [threading model](../../../std/thread/index.html#the-threading-model) of rust.
|
||||
//! The most common way to share an atomic variable is to put it into an `Arc` (an
|
||||
//! atomically-reference-counted shared pointer).
|
||||
//!
|
||||
//! Most atomic types may be stored in static variables, initialized using
|
||||
@ -48,12 +49,16 @@
|
||||
//! let spinlock = Arc::new(AtomicUsize::new(1));
|
||||
//!
|
||||
//! let spinlock_clone = spinlock.clone();
|
||||
//! thread::spawn(move|| {
|
||||
//! let thread = thread::spawn(move|| {
|
||||
//! spinlock_clone.store(0, Ordering::SeqCst);
|
||||
//! });
|
||||
//!
|
||||
//! // Wait for the other thread to release the lock
|
||||
//! while spinlock.load(Ordering::SeqCst) != 0 {}
|
||||
//!
|
||||
//! if let Err(panic) = thread.join() {
|
||||
//! println!("Thread had an error: {:?}", panic);
|
||||
//! }
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
|
@ -1286,8 +1286,12 @@ impl<'a> LoweringContext<'a> {
|
||||
maybe_expr.as_ref().map(|x| self.lower_expr(x)))
|
||||
}
|
||||
ExprKind::Paren(ref ex) => {
|
||||
// merge attributes into the inner expression.
|
||||
return self.lower_expr(ex).map(|mut ex| {
|
||||
// include parens in span, but only if it is a super-span.
|
||||
if e.span.contains(ex.span) {
|
||||
ex.span = e.span;
|
||||
}
|
||||
// merge attributes into the inner expression.
|
||||
ex.attrs.update(|attrs| {
|
||||
attrs.prepend(e.attrs.clone())
|
||||
});
|
||||
|
@ -152,7 +152,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
ty::TyEnum(def, _) if def.has_dtor() => {
|
||||
let mut err = struct_span_err!(bccx, move_from.span, E0509,
|
||||
"cannot move out of type `{}`, \
|
||||
which defines the `Drop` trait",
|
||||
which implements the `Drop` trait",
|
||||
b.ty);
|
||||
err.span_label(move_from.span, &format!("cannot move out of here"));
|
||||
err
|
||||
|
@ -617,7 +617,13 @@ pub fn coerce_unsized_into<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
(&ty::TyRawPtr(..), &ty::TyRawPtr(..)) => {
|
||||
let (base, info) = if common::type_is_fat_ptr(bcx.tcx(), src_ty) {
|
||||
// fat-ptr to fat-ptr unsize preserves the vtable
|
||||
load_fat_ptr(bcx, src, src_ty)
|
||||
// i.e. &'a fmt::Debug+Send => &'a fmt::Debug
|
||||
// So we need to pointercast the base to ensure
|
||||
// the types match up.
|
||||
let (base, info) = load_fat_ptr(bcx, src, src_ty);
|
||||
let llcast_ty = type_of::fat_ptr_base_ty(bcx.ccx(), dst_ty);
|
||||
let base = PointerCast(bcx, base, llcast_ty);
|
||||
(base, info)
|
||||
} else {
|
||||
let base = load_ty(bcx, src, src_ty);
|
||||
unsize_thin_ptr(bcx, base, src_ty, dst_ty)
|
||||
|
@ -262,14 +262,17 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
assert!(common::type_is_fat_ptr(bcx.tcx(), cast_ty));
|
||||
|
||||
match operand.val {
|
||||
OperandValue::FatPtr(..) => {
|
||||
OperandValue::FatPtr(lldata, llextra) => {
|
||||
// unsize from a fat pointer - this is a
|
||||
// "trait-object-to-supertrait" coercion, for
|
||||
// example,
|
||||
// &'a fmt::Debug+Send => &'a fmt::Debug,
|
||||
// and is a no-op at the LLVM level
|
||||
// So we need to pointercast the base to ensure
|
||||
// the types match up.
|
||||
self.set_operand_dropped(&bcx, source);
|
||||
operand.val
|
||||
let llcast_ty = type_of::fat_ptr_base_ty(bcx.ccx(), cast_ty);
|
||||
let lldata = bcx.pointercast(lldata, llcast_ty);
|
||||
OperandValue::FatPtr(lldata, llextra)
|
||||
}
|
||||
OperandValue::Immediate(lldata) => {
|
||||
// "standard" unsize
|
||||
|
@ -157,6 +157,17 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
|
||||
llsizingty
|
||||
}
|
||||
|
||||
pub fn fat_ptr_base_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> Type {
|
||||
match ty.sty {
|
||||
ty::TyBox(t) |
|
||||
ty::TyRef(_, ty::TypeAndMut { ty: t, .. }) |
|
||||
ty::TyRawPtr(ty::TypeAndMut { ty: t, .. }) if !type_is_sized(ccx.tcx(), t) => {
|
||||
in_memory_type_of(ccx, t).ptr_to()
|
||||
}
|
||||
_ => bug!("expected fat ptr ty but got {:?}", ty)
|
||||
}
|
||||
}
|
||||
|
||||
fn unsized_info_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> Type {
|
||||
let unsized_part = ccx.tcx().struct_tail(ty);
|
||||
match unsized_part.sty {
|
||||
|
23
src/test/compile-fail/E0036.rs
Normal file
23
src/test/compile-fail/E0036.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct Test;
|
||||
|
||||
impl Test {
|
||||
fn method<T>(&self, v: &[T]) -> usize {
|
||||
v.len()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = Test;
|
||||
let v = &[0];
|
||||
x.method::<i32, i32>(v); //~ ERROR E0036
|
||||
}
|
20
src/test/compile-fail/E0038.rs
Normal file
20
src/test/compile-fail/E0038.rs
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
trait Trait {
|
||||
fn foo(&self) -> Self;
|
||||
}
|
||||
|
||||
fn call_foo(x: Box<Trait>) { //~ ERROR E0038
|
||||
let y = x.foo();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
24
src/test/compile-fail/E0040.rs
Normal file
24
src/test/compile-fail/E0040.rs
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct Foo {
|
||||
x: i32,
|
||||
}
|
||||
|
||||
impl Drop for Foo {
|
||||
fn drop(&mut self) {
|
||||
println!("kaboom");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut x = Foo { x: -7 };
|
||||
x.drop(); //~ ERROR E0040
|
||||
}
|
14
src/test/compile-fail/E0044.rs
Normal file
14
src/test/compile-fail/E0044.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
extern { fn some_func<T>(x: T); } //~ ERROR E0044
|
||||
|
||||
fn main() {
|
||||
}
|
14
src/test/compile-fail/E0045.rs
Normal file
14
src/test/compile-fail/E0045.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
extern "rust-call" { fn foo(x: u8, ...); } //~ ERROR E0045
|
||||
|
||||
fn main() {
|
||||
}
|
20
src/test/compile-fail/E0046.rs
Normal file
20
src/test/compile-fail/E0046.rs
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
trait Foo {
|
||||
fn foo();
|
||||
}
|
||||
|
||||
struct Bar;
|
||||
|
||||
impl Foo for Bar {} //~ ERROR E0046
|
||||
|
||||
fn main() {
|
||||
}
|
22
src/test/compile-fail/E0049.rs
Normal file
22
src/test/compile-fail/E0049.rs
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
trait Foo {
|
||||
fn foo<T: Default>(x: T) -> Self;
|
||||
}
|
||||
|
||||
struct Bar;
|
||||
|
||||
impl Foo for Bar {
|
||||
fn foo(x: bool) -> Self { Bar } //~ ERROR E0049
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
22
src/test/compile-fail/E0050.rs
Normal file
22
src/test/compile-fail/E0050.rs
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
trait Foo {
|
||||
fn foo(&self, x: u8) -> bool;
|
||||
}
|
||||
|
||||
struct Bar;
|
||||
|
||||
impl Foo for Bar {
|
||||
fn foo(&self) -> bool { true } //~ ERROR E0050
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
24
src/test/compile-fail/E0053.rs
Normal file
24
src/test/compile-fail/E0053.rs
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
trait Foo {
|
||||
fn foo(x: u16);
|
||||
fn bar(&self);
|
||||
}
|
||||
|
||||
struct Bar;
|
||||
|
||||
impl Foo for Bar {
|
||||
fn foo(x: i16) { } //~ ERROR E0053
|
||||
fn bar(&mut self) { } //~ ERROR E0053
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
14
src/test/compile-fail/E0054.rs
Normal file
14
src/test/compile-fail/E0054.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let x = 5;
|
||||
let x_is_nonzero = x as bool; //~ ERROR E0054
|
||||
}
|
23
src/test/compile-fail/E0055.rs
Normal file
23
src/test/compile-fail/E0055.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![recursion_limit="2"]
|
||||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
fn foo(&self) {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let foo = Foo;
|
||||
let ref_foo = &&Foo;
|
||||
ref_foo.foo(); //~ ERROR E0055
|
||||
//~^ ERROR E0275
|
||||
}
|
16
src/test/compile-fail/E0057.rs
Normal file
16
src/test/compile-fail/E0057.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let f = |x| x * 3;
|
||||
let a = f(); //~ ERROR E0057
|
||||
let b = f(4);
|
||||
let c = f(2, 3); //~ ERROR E0057
|
||||
}
|
16
src/test/compile-fail/E0059.rs
Normal file
16
src/test/compile-fail/E0059.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(unboxed_closures)]
|
||||
|
||||
fn foo<F: Fn<i32>>(f: F) -> F::Output { f(3) } //~ ERROR E0059
|
||||
|
||||
fn main() {
|
||||
}
|
17
src/test/compile-fail/E0060.rs
Normal file
17
src/test/compile-fail/E0060.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
extern "C" {
|
||||
fn printf(_: *const u8, ...) -> u32;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
unsafe { printf(); } //~ ERROR E0060
|
||||
}
|
15
src/test/compile-fail/E0061.rs
Normal file
15
src/test/compile-fail/E0061.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn f(a: u16, b: &str) {}
|
||||
|
||||
fn main() {
|
||||
f(0); //~ ERROR E0061
|
||||
}
|
@ -37,7 +37,7 @@ impl Drop for S {
|
||||
|
||||
fn move_in_match() {
|
||||
match (S {f: "foo".to_string(), g: "bar".to_string()}) {
|
||||
S { //~ ERROR cannot move out of type `S`, which defines the `Drop` trait
|
||||
S { //~ ERROR cannot move out of type `S`, which implements the `Drop` trait
|
||||
//~| cannot move out of here
|
||||
f: _s, //~ NOTE to prevent move
|
||||
g: _t //~ NOTE and here
|
||||
|
@ -16,17 +16,17 @@ impl Drop for S {
|
||||
fn move_in_match() {
|
||||
match (S {f:"foo".to_string()}) {
|
||||
S {f:_s} => {}
|
||||
//~^ ERROR cannot move out of type `S`, which defines the `Drop` trait
|
||||
//~^ ERROR cannot move out of type `S`, which implements the `Drop` trait
|
||||
}
|
||||
}
|
||||
|
||||
fn move_in_let() {
|
||||
let S {f:_s} = S {f:"foo".to_string()};
|
||||
//~^ ERROR cannot move out of type `S`, which defines the `Drop` trait
|
||||
//~^ ERROR cannot move out of type `S`, which implements the `Drop` trait
|
||||
}
|
||||
|
||||
fn move_in_fn_arg(S {f:_s}: S) {
|
||||
//~^ ERROR cannot move out of type `S`, which defines the `Drop` trait
|
||||
//~^ ERROR cannot move out of type `S`, which implements the `Drop` trait
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -16,17 +16,17 @@ impl Drop for S {
|
||||
fn move_in_match() {
|
||||
match S("foo".to_string()) {
|
||||
S(_s) => {}
|
||||
//~^ ERROR cannot move out of type `S`, which defines the `Drop` trait
|
||||
//~^ ERROR cannot move out of type `S`, which implements the `Drop` trait
|
||||
}
|
||||
}
|
||||
|
||||
fn move_in_let() {
|
||||
let S(_s) = S("foo".to_string());
|
||||
//~^ ERROR cannot move out of type `S`, which defines the `Drop` trait
|
||||
//~^ ERROR cannot move out of type `S`, which implements the `Drop` trait
|
||||
}
|
||||
|
||||
fn move_in_fn_arg(S(_s): S) {
|
||||
//~^ ERROR cannot move out of type `S`, which defines the `Drop` trait
|
||||
//~^ ERROR cannot move out of type `S`, which implements the `Drop` trait
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -19,11 +19,13 @@ struct T { a: isize, mv: Box<isize> }
|
||||
impl Drop for T { fn drop(&mut self) { } }
|
||||
|
||||
fn f(s0:S) {
|
||||
let _s2 = S{a: 2, ..s0}; //~error: cannot move out of type `S`, which defines the `Drop` trait
|
||||
let _s2 = S{a: 2, ..s0};
|
||||
//~^ error: cannot move out of type `S`, which implements the `Drop` trait
|
||||
}
|
||||
|
||||
fn g(s0:T) {
|
||||
let _s2 = T{a: 2, ..s0}; //~error: cannot move out of type `T`, which defines the `Drop` trait
|
||||
let _s2 = T{a: 2, ..s0};
|
||||
//~^ error: cannot move out of type `T`, which implements the `Drop` trait
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -23,6 +23,6 @@ fn main() {
|
||||
|
||||
match x {
|
||||
X { x: y } => println!("contents: {}", y)
|
||||
//~^ ERROR cannot move out of type `X`, which defines the `Drop` trait
|
||||
//~^ ERROR cannot move out of type `X`, which implements the `Drop` trait
|
||||
}
|
||||
}
|
||||
|
@ -81,11 +81,11 @@ impl FuncContainerOuter {
|
||||
fn run(&self) {
|
||||
unsafe {
|
||||
(*self.container).f1(1); //~ ERROR no method named `f1` found
|
||||
//~^ NOTE use `(*self.container.f1)(...)`
|
||||
//~^ NOTE use `((*self.container).f1)(...)`
|
||||
(*self.container).f2(1); //~ ERROR no method named `f2` found
|
||||
//~^ NOTE use `(*self.container.f2)(...)`
|
||||
//~^ NOTE use `((*self.container).f2)(...)`
|
||||
(*self.container).f3(1); //~ ERROR no method named `f3` found
|
||||
//~^ NOTE use `(*self.container.f3)(...)`
|
||||
//~^ NOTE use `((*self.container).f3)(...)`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
31
src/test/compile-fail/paren-span.rs
Normal file
31
src/test/compile-fail/paren-span.rs
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Be smart about span of parenthesized expression in macro.
|
||||
|
||||
macro_rules! paren {
|
||||
($e:expr) => (($e))
|
||||
// ^^^^ do not highlight here
|
||||
}
|
||||
|
||||
mod m {
|
||||
pub struct S {
|
||||
x: i32
|
||||
}
|
||||
pub fn make() -> S {
|
||||
S { x: 0 }
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let s = m::make();
|
||||
paren!(s.x); //~ ERROR field `x` of struct `m::S` is private
|
||||
// ^^^ highlight here
|
||||
}
|
44
src/test/run-pass/issue-33387.rs
Normal file
44
src/test/run-pass/issue-33387.rs
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
trait Foo {
|
||||
fn get(&self) -> [u8; 2];
|
||||
}
|
||||
|
||||
impl Foo for [u8; 2] {
|
||||
fn get(&self) -> [u8; 2] {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
struct Bar<T: ?Sized>(T);
|
||||
|
||||
#[rustc_mir]
|
||||
fn unsize_fat_ptr<'a>(x: &'a Bar<Foo + Send + 'a>) -> &'a Bar<Foo + 'a> {
|
||||
x
|
||||
}
|
||||
|
||||
#[rustc_mir]
|
||||
fn unsize_nested_fat_ptr(x: Arc<Foo + Send>) -> Arc<Foo> {
|
||||
x
|
||||
}
|
||||
|
||||
#[rustc_mir]
|
||||
fn main() {
|
||||
let x: Box<Bar<Foo + Send>> = Box::new(Bar([1,2]));
|
||||
assert_eq!(unsize_fat_ptr(&*x).0.get(), [1, 2]);
|
||||
|
||||
let x: Arc<Foo + Send> = Arc::new([3, 4]);
|
||||
assert_eq!(unsize_nested_fat_ptr(x).get(), [3, 4]);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user