diff options
| author | bors <bors@rust-lang.org> | 2015-02-10 19:52:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-02-10 19:52:04 +0000 |
| commit | bc87efef2cceaec99d30e809cac2b8d22b9e25fc (patch) | |
| tree | 1f59e50bc58a426615cc15594cade8b69f24bdbf /src/test/compile-fail | |
| parent | 88d8ba5ab3b1d22288b021708c3d87464e43b880 (diff) | |
| parent | 3e10785e21b731d536cf9ad9b911e8261862bde7 (diff) | |
| download | rust-bc87efef2cceaec99d30e809cac2b8d22b9e25fc.tar.gz rust-bc87efef2cceaec99d30e809cac2b8d22b9e25fc.zip | |
Auto merge of #22153 - alexcrichton:rollup, r=alexcrichton
Diffstat (limited to 'src/test/compile-fail')
| -rw-r--r-- | src/test/compile-fail/cfg-attr-cfg-2.rs | 18 | ||||
| -rw-r--r-- | src/test/compile-fail/cfg-attr-crate-2.rs | 17 | ||||
| -rw-r--r-- | src/test/compile-fail/functional-struct-update-respects-privacy.rs | 42 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-17551.rs | 4 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-17999.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-20801.rs | 47 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-2150.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/liveness-unused.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/reserved-become.rs | 14 |
9 files changed, 140 insertions, 5 deletions
diff --git a/src/test/compile-fail/cfg-attr-cfg-2.rs b/src/test/compile-fail/cfg-attr-cfg-2.rs new file mode 100644 index 00000000000..b71a3be5dce --- /dev/null +++ b/src/test/compile-fail/cfg-attr-cfg-2.rs @@ -0,0 +1,18 @@ +// Copyright 2015 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. +// +// error-pattern: main function not found +// compile-flags: --cfg foo + +// main is conditionally compiled, but the conditional compilation +// is conditional too! + +#[cfg_attr(foo, cfg(bar))] +fn main() { } diff --git a/src/test/compile-fail/cfg-attr-crate-2.rs b/src/test/compile-fail/cfg-attr-crate-2.rs new file mode 100644 index 00000000000..4867dd8d0b4 --- /dev/null +++ b/src/test/compile-fail/cfg-attr-crate-2.rs @@ -0,0 +1,17 @@ +// Copyright 2015 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. +// +// compile-flags: --cfg broken + +// https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044 + +#![cfg_attr(broken, no_std)] //~ ERROR no_std is experimental + +fn main() { } diff --git a/src/test/compile-fail/functional-struct-update-respects-privacy.rs b/src/test/compile-fail/functional-struct-update-respects-privacy.rs new file mode 100644 index 00000000000..51e23a689a1 --- /dev/null +++ b/src/test/compile-fail/functional-struct-update-respects-privacy.rs @@ -0,0 +1,42 @@ +// Copyright 2015 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. + +// RFC 736 (and Issue 21407): functional struct update should respect privacy. + +// The `foo` module attempts to maintains an invariant that each `S` +// has a unique `u64` id. +use self::foo::S; +mod foo { + use std::cell::{UnsafeCell}; + + static mut count : UnsafeCell<u64> = UnsafeCell { value: 1 }; + + pub struct S { pub a: u8, pub b: String, secret_uid: u64 } + + pub fn make_secrets(a: u8, b: String) -> S { + let val = unsafe { let p = count.get(); let val = *p; *p = val + 1; val }; + println!("creating {}, uid {}", b, val); + S { a: a, b: b, secret_uid: val } + } + + impl Drop for S { + fn drop(&mut self) { + println!("dropping {}, uid {}", self.b, self.secret_uid); + } + } +} + +fn main() { + let s_1 = foo::make_secrets(3, format!("ess one")); + let s_2 = foo::S { b: format!("ess two"), ..s_1 }; // FRU ... + //~^ ERROR field `secret_uid` of struct `foo::S` is private + println!("main forged an S named: {}", s_2.b); + // at end of scope, ... both s_1 *and* s_2 get dropped. Boom! +} diff --git a/src/test/compile-fail/issue-17551.rs b/src/test/compile-fail/issue-17551.rs index b19a7703b85..e037ba92b4a 100644 --- a/src/test/compile-fail/issue-17551.rs +++ b/src/test/compile-fail/issue-17551.rs @@ -13,6 +13,6 @@ struct B<T>; fn main() { - let foo = B; - let closure = || foo; //~ ERROR unable to infer enough type information + let foo = B; //~ ERROR: unable to infer enough type information + let closure = || foo; } diff --git a/src/test/compile-fail/issue-17999.rs b/src/test/compile-fail/issue-17999.rs index f4c0a9c38c3..88945f80eae 100644 --- a/src/test/compile-fail/issue-17999.rs +++ b/src/test/compile-fail/issue-17999.rs @@ -9,7 +9,6 @@ // except according to those terms. #![deny(unused_variables)] -#![feature(core)] fn main() { for _ in 1..101 { diff --git a/src/test/compile-fail/issue-20801.rs b/src/test/compile-fail/issue-20801.rs new file mode 100644 index 00000000000..929c8ec0fd6 --- /dev/null +++ b/src/test/compile-fail/issue-20801.rs @@ -0,0 +1,47 @@ +// Copyright 2015 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. + +// We used to ICE when moving out of a `*mut T` or `*const T`. + +struct T(u8); + +static mut GLOBAL_MUT_T: T = T(0); + +static GLOBAL_T: T = T(0); + +fn imm_ref() -> &'static T { + unsafe { &GLOBAL_T } +} + +fn mut_ref() -> &'static mut T { + unsafe { &mut GLOBAL_MUT_T } +} + +fn mut_ptr() -> *mut T { + unsafe { 0u8 as *mut T } +} + +fn const_ptr() -> *const T { + unsafe { 0u8 as *const T } +} + +pub fn main() { + let a = unsafe { *mut_ref() }; + //~^ ERROR cannot move out of borrowed content + + let b = unsafe { *imm_ref() }; + //~^ ERROR cannot move out of borrowed content + + let c = unsafe { *mut_ptr() }; + //~^ ERROR cannot move out of dereference of unsafe pointer + + let d = unsafe { *const_ptr() }; + //~^ ERROR cannot move out of dereference of unsafe pointer +} diff --git a/src/test/compile-fail/issue-2150.rs b/src/test/compile-fail/issue-2150.rs index a2711d532d2..79df16c8979 100644 --- a/src/test/compile-fail/issue-2150.rs +++ b/src/test/compile-fail/issue-2150.rs @@ -11,7 +11,6 @@ #![deny(unreachable_code)] #![allow(unused_variables)] #![allow(dead_code)] -#![feature(core)] fn fail_len(v: Vec<isize> ) -> usize { let mut i = 3; diff --git a/src/test/compile-fail/liveness-unused.rs b/src/test/compile-fail/liveness-unused.rs index d4238120d06..ac4b8a5f309 100644 --- a/src/test/compile-fail/liveness-unused.rs +++ b/src/test/compile-fail/liveness-unused.rs @@ -11,7 +11,6 @@ #![deny(unused_variables)] #![deny(unused_assignments)] #![allow(dead_code, non_camel_case_types)] -#![feature(core)] fn f1(x: isize) { //~^ ERROR unused variable: `x` diff --git a/src/test/compile-fail/reserved-become.rs b/src/test/compile-fail/reserved-become.rs new file mode 100644 index 00000000000..82e9ebc10d1 --- /dev/null +++ b/src/test/compile-fail/reserved-become.rs @@ -0,0 +1,14 @@ +// Copyright 2012-2015 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 become = 0; + //~^ ERROR `become` is a reserved keyword +} |
