From a4b7ed7a42c716ab9f05e351f003d589124fd55d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:58 +0200 Subject: Adding upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/rfcs/rfc-1014-2.rs | 31 --- src/test/ui/rfcs/rfc-1014.rs | 34 --- src/test/ui/rfcs/rfc-1789-as-cell/from-mut.rs | 20 -- .../termination-trait-for-box-dyn-error.rs | 6 - .../termination-trait-for-empty.rs | 2 - .../termination-trait-for-exitcode.rs | 7 - .../termination-trait-for-impl-termination.rs | 3 - .../termination-trait-for-result-box-error_ok.rs | 6 - .../termination-trait-for-result.rs | 6 - .../termination-trait-for-str.rs | 4 - .../ui/rfcs/rfc-2005-default-binding-mode/box.rs | 18 -- .../rfcs/rfc-2005-default-binding-mode/constref.rs | 40 ---- .../ui/rfcs/rfc-2005-default-binding-mode/enum.rs | 45 ---- .../ui/rfcs/rfc-2005-default-binding-mode/for.rs | 20 -- .../rfcs/rfc-2005-default-binding-mode/general.rs | 249 --------------------- .../ui/rfcs/rfc-2005-default-binding-mode/lit.rs | 34 --- .../ui/rfcs/rfc-2005-default-binding-mode/range.rs | 9 - .../rfc-2005-default-binding-mode/ref-region.rs | 16 -- .../rfc-2005-default-binding-mode/reset-mode.rs | 14 -- .../ui/rfcs/rfc-2005-default-binding-mode/slice.rs | 25 --- .../rfcs/rfc-2005-default-binding-mode/struct.rs | 22 -- .../rfc-2005-default-binding-mode/tuple-struct.rs | 19 -- .../ui/rfcs/rfc-2005-default-binding-mode/tuple.rs | 12 - src/test/ui/rfcs/rfc-2151-raw-identifiers/attr.rs | 15 -- src/test/ui/rfcs/rfc-2151-raw-identifiers/basic.rs | 20 -- src/test/ui/rfcs/rfc-2151-raw-identifiers/items.rs | 32 --- .../ui/rfcs/rfc-2151-raw-identifiers/macros.rs | 38 ---- src/test/ui/rfcs/rfc-2175-or-if-while-let/basic.rs | 33 --- src/test/ui/rfcs/rfc-2302-self-struct-ctor.rs | 127 ----------- .../rfcs/rfc-2396-target_feature-11/check-pass.rs | 52 ----- .../closures-inherit-target_feature.rs | 20 -- .../feature-gate-target_feature_11.rs | 6 - .../feature-gate-target_feature_11.stderr | 14 -- .../rfc-2396-target_feature-11/fn-ptr.mir.stderr | 18 -- .../ui/rfcs/rfc-2396-target_feature-11/fn-ptr.rs | 12 - .../rfc-2396-target_feature-11/fn-ptr.thir.stderr | 18 -- .../rfcs/rfc-2396-target_feature-11/fn-traits.rs | 34 --- .../rfc-2396-target_feature-11/fn-traits.stderr | 105 --------- .../rfcs/rfc-2396-target_feature-11/issue-99876.rs | 9 - .../safe-calls.mir.stderr | 83 ------- .../rfcs/rfc-2396-target_feature-11/safe-calls.rs | 69 ------ .../safe-calls.thir.stderr | 83 ------- .../rfcs/rfc-2396-target_feature-11/trait-impl.rs | 21 -- .../rfc-2396-target_feature-11/trait-impl.stderr | 11 - ...-2421-unreserve-pure-offsetof-sizeof-alignof.rs | 15 -- .../coerce-in-base-expr.rs | 28 --- .../feature-gate.rs | 29 --- .../feature-gate.stderr | 22 -- .../issue-92010-trait-bound-not-satisfied.rs | 12 - .../issue-92010-trait-bound-not-satisfied.stderr | 12 - .../issue-96878.rs | 31 --- .../lifetime-update.rs | 43 ---- .../lifetime-update.stderr | 15 -- .../type-generic-update.rs | 56 ----- .../type-generic-update.stderr | 21 -- .../rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs | 23 -- src/test/ui/rfcs/rfc1445/eq-allows-match.rs | 17 -- src/test/ui/rfcs/rfc1623-2.rs | 99 -------- src/test/ui/rfcs/rfc1623-2.stderr | 39 ---- src/test/ui/rfcs/rfc1623-3.rs | 14 -- src/test/ui/rfcs/rfc1623-3.stderr | 35 --- src/test/ui/rfcs/rfc1623.rs | 75 ------- src/test/ui/rfcs/rfc1717/library-override.rs | 14 -- src/test/ui/rfcs/rfc1857-drop-order.rs | 224 ------------------ 64 files changed, 2286 deletions(-) delete mode 100644 src/test/ui/rfcs/rfc-1014-2.rs delete mode 100644 src/test/ui/rfcs/rfc-1014.rs delete mode 100644 src/test/ui/rfcs/rfc-1789-as-cell/from-mut.rs delete mode 100644 src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs delete mode 100644 src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-empty.rs delete mode 100644 src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-exitcode.rs delete mode 100644 src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-impl-termination.rs delete mode 100644 src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-result-box-error_ok.rs delete mode 100644 src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-result.rs delete mode 100644 src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-str.rs delete mode 100644 src/test/ui/rfcs/rfc-2005-default-binding-mode/box.rs delete mode 100644 src/test/ui/rfcs/rfc-2005-default-binding-mode/constref.rs delete mode 100644 src/test/ui/rfcs/rfc-2005-default-binding-mode/enum.rs delete mode 100644 src/test/ui/rfcs/rfc-2005-default-binding-mode/for.rs delete mode 100644 src/test/ui/rfcs/rfc-2005-default-binding-mode/general.rs delete mode 100644 src/test/ui/rfcs/rfc-2005-default-binding-mode/lit.rs delete mode 100644 src/test/ui/rfcs/rfc-2005-default-binding-mode/range.rs delete mode 100644 src/test/ui/rfcs/rfc-2005-default-binding-mode/ref-region.rs delete mode 100644 src/test/ui/rfcs/rfc-2005-default-binding-mode/reset-mode.rs delete mode 100644 src/test/ui/rfcs/rfc-2005-default-binding-mode/slice.rs delete mode 100644 src/test/ui/rfcs/rfc-2005-default-binding-mode/struct.rs delete mode 100644 src/test/ui/rfcs/rfc-2005-default-binding-mode/tuple-struct.rs delete mode 100644 src/test/ui/rfcs/rfc-2005-default-binding-mode/tuple.rs delete mode 100644 src/test/ui/rfcs/rfc-2151-raw-identifiers/attr.rs delete mode 100644 src/test/ui/rfcs/rfc-2151-raw-identifiers/basic.rs delete mode 100644 src/test/ui/rfcs/rfc-2151-raw-identifiers/items.rs delete mode 100644 src/test/ui/rfcs/rfc-2151-raw-identifiers/macros.rs delete mode 100644 src/test/ui/rfcs/rfc-2175-or-if-while-let/basic.rs delete mode 100644 src/test/ui/rfcs/rfc-2302-self-struct-ctor.rs delete mode 100644 src/test/ui/rfcs/rfc-2396-target_feature-11/check-pass.rs delete mode 100644 src/test/ui/rfcs/rfc-2396-target_feature-11/closures-inherit-target_feature.rs delete mode 100644 src/test/ui/rfcs/rfc-2396-target_feature-11/feature-gate-target_feature_11.rs delete mode 100644 src/test/ui/rfcs/rfc-2396-target_feature-11/feature-gate-target_feature_11.stderr delete mode 100644 src/test/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.mir.stderr delete mode 100644 src/test/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.rs delete mode 100644 src/test/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.thir.stderr delete mode 100644 src/test/ui/rfcs/rfc-2396-target_feature-11/fn-traits.rs delete mode 100644 src/test/ui/rfcs/rfc-2396-target_feature-11/fn-traits.stderr delete mode 100644 src/test/ui/rfcs/rfc-2396-target_feature-11/issue-99876.rs delete mode 100644 src/test/ui/rfcs/rfc-2396-target_feature-11/safe-calls.mir.stderr delete mode 100644 src/test/ui/rfcs/rfc-2396-target_feature-11/safe-calls.rs delete mode 100644 src/test/ui/rfcs/rfc-2396-target_feature-11/safe-calls.thir.stderr delete mode 100644 src/test/ui/rfcs/rfc-2396-target_feature-11/trait-impl.rs delete mode 100644 src/test/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr delete mode 100644 src/test/ui/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof.rs delete mode 100644 src/test/ui/rfcs/rfc-2528-type-changing-struct-update/coerce-in-base-expr.rs delete mode 100644 src/test/ui/rfcs/rfc-2528-type-changing-struct-update/feature-gate.rs delete mode 100644 src/test/ui/rfcs/rfc-2528-type-changing-struct-update/feature-gate.stderr delete mode 100644 src/test/ui/rfcs/rfc-2528-type-changing-struct-update/issue-92010-trait-bound-not-satisfied.rs delete mode 100644 src/test/ui/rfcs/rfc-2528-type-changing-struct-update/issue-92010-trait-bound-not-satisfied.stderr delete mode 100644 src/test/ui/rfcs/rfc-2528-type-changing-struct-update/issue-96878.rs delete mode 100644 src/test/ui/rfcs/rfc-2528-type-changing-struct-update/lifetime-update.rs delete mode 100644 src/test/ui/rfcs/rfc-2528-type-changing-struct-update/lifetime-update.stderr delete mode 100644 src/test/ui/rfcs/rfc-2528-type-changing-struct-update/type-generic-update.rs delete mode 100644 src/test/ui/rfcs/rfc-2528-type-changing-struct-update/type-generic-update.stderr delete mode 100644 src/test/ui/rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs delete mode 100644 src/test/ui/rfcs/rfc1445/eq-allows-match.rs delete mode 100644 src/test/ui/rfcs/rfc1623-2.rs delete mode 100644 src/test/ui/rfcs/rfc1623-2.stderr delete mode 100644 src/test/ui/rfcs/rfc1623-3.rs delete mode 100644 src/test/ui/rfcs/rfc1623-3.stderr delete mode 100644 src/test/ui/rfcs/rfc1623.rs delete mode 100644 src/test/ui/rfcs/rfc1717/library-override.rs delete mode 100644 src/test/ui/rfcs/rfc1857-drop-order.rs (limited to 'src/test/ui/rfcs') diff --git a/src/test/ui/rfcs/rfc-1014-2.rs b/src/test/ui/rfcs/rfc-1014-2.rs deleted file mode 100644 index 7dd65701f..000000000 --- a/src/test/ui/rfcs/rfc-1014-2.rs +++ /dev/null @@ -1,31 +0,0 @@ -// run-pass -#![allow(dead_code)] - -#![feature(rustc_private)] - -extern crate libc; - -type DWORD = u32; -type HANDLE = *mut u8; -type BOOL = i32; - -#[cfg(windows)] -extern "system" { - fn SetStdHandle(nStdHandle: DWORD, nHandle: HANDLE) -> BOOL; -} - -#[cfg(windows)] -fn close_stdout() { - const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD; - unsafe { SetStdHandle(STD_OUTPUT_HANDLE, 0 as HANDLE); } -} - -#[cfg(windows)] -fn main() { - close_stdout(); - println!("hello"); - println!("world"); -} - -#[cfg(not(windows))] -fn main() {} diff --git a/src/test/ui/rfcs/rfc-1014.rs b/src/test/ui/rfcs/rfc-1014.rs deleted file mode 100644 index c454dfa4e..000000000 --- a/src/test/ui/rfcs/rfc-1014.rs +++ /dev/null @@ -1,34 +0,0 @@ -// run-pass -#![allow(dead_code)] -// ignore-wasm32-bare no libc -// ignore-sgx no libc - -#![feature(rustc_private)] - -extern crate libc; - -type DWORD = u32; -type HANDLE = *mut u8; - -#[cfg(windows)] -extern "system" { - fn GetStdHandle(which: DWORD) -> HANDLE; - fn CloseHandle(handle: HANDLE) -> i32; -} - -#[cfg(windows)] -fn close_stdout() { - const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD; - unsafe { CloseHandle(GetStdHandle(STD_OUTPUT_HANDLE)); } -} - -#[cfg(not(windows))] -fn close_stdout() { - unsafe { libc::close(1); } -} - -fn main() { - close_stdout(); - println!("hello"); - println!("world"); -} diff --git a/src/test/ui/rfcs/rfc-1789-as-cell/from-mut.rs b/src/test/ui/rfcs/rfc-1789-as-cell/from-mut.rs deleted file mode 100644 index 329fadb15..000000000 --- a/src/test/ui/rfcs/rfc-1789-as-cell/from-mut.rs +++ /dev/null @@ -1,20 +0,0 @@ -// run-pass - -#![feature(as_array_of_cells)] - -use std::cell::Cell; - -fn main() { - let slice: &mut [i32] = &mut [1, 2, 3]; - let cell_slice: &Cell<[i32]> = Cell::from_mut(slice); - let slice_cell: &[Cell] = cell_slice.as_slice_of_cells(); - - assert_eq!(slice_cell.len(), 3); - - let mut array: [i32; 3] = [1, 2, 3]; - let cell_array: &Cell<[i32; 3]> = Cell::from_mut(&mut array); - let array_cell: &[Cell; 3] = cell_array.as_array_of_cells(); - - array_cell[0].set(99); - assert_eq!(array, [99, 2, 3]); -} diff --git a/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs b/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs deleted file mode 100644 index e98582cbc..000000000 --- a/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs +++ /dev/null @@ -1,6 +0,0 @@ -// run-pass -use std::error::Error; - -fn main() -> Result<(), Box> { - Ok(()) -} diff --git a/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-empty.rs b/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-empty.rs deleted file mode 100644 index bac695d4e..000000000 --- a/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-empty.rs +++ /dev/null @@ -1,2 +0,0 @@ -// run-pass -fn main() {} diff --git a/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-exitcode.rs b/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-exitcode.rs deleted file mode 100644 index 6d4c15620..000000000 --- a/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-exitcode.rs +++ /dev/null @@ -1,7 +0,0 @@ -// run-pass - -use std::process::ExitCode; - -fn main() -> ExitCode { - ExitCode::SUCCESS -} diff --git a/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-impl-termination.rs b/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-impl-termination.rs deleted file mode 100644 index c06a135dc..000000000 --- a/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-impl-termination.rs +++ /dev/null @@ -1,3 +0,0 @@ -// run-pass - -fn main() -> impl std::process::Termination { } diff --git a/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-result-box-error_ok.rs b/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-result-box-error_ok.rs deleted file mode 100644 index b0e932e1f..000000000 --- a/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-result-box-error_ok.rs +++ /dev/null @@ -1,6 +0,0 @@ -// run-pass -use std::io::Error; - -fn main() -> Result<(), Box> { - Ok(()) -} diff --git a/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-result.rs b/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-result.rs deleted file mode 100644 index 30f36c244..000000000 --- a/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-result.rs +++ /dev/null @@ -1,6 +0,0 @@ -// run-pass -use std::io::Error; - -fn main() -> Result<(), Error> { - Ok(()) -} diff --git a/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-str.rs b/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-str.rs deleted file mode 100644 index f0591c38c..000000000 --- a/src/test/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-str.rs +++ /dev/null @@ -1,4 +0,0 @@ -// run-pass -fn main() -> Result<(), &'static str> { - Ok(()) -} diff --git a/src/test/ui/rfcs/rfc-2005-default-binding-mode/box.rs b/src/test/ui/rfcs/rfc-2005-default-binding-mode/box.rs deleted file mode 100644 index 0d1cded36..000000000 --- a/src/test/ui/rfcs/rfc-2005-default-binding-mode/box.rs +++ /dev/null @@ -1,18 +0,0 @@ -// run-pass -#![allow(unreachable_patterns)] -#![feature(box_patterns)] - -struct Foo{} - -pub fn main() { - let b = Box::new(Foo{}); - let box f = &b; - let _: &Foo = f; - - match &&&b { - box f => { - let _: &Foo = f; - }, - _ => panic!(), - } -} diff --git a/src/test/ui/rfcs/rfc-2005-default-binding-mode/constref.rs b/src/test/ui/rfcs/rfc-2005-default-binding-mode/constref.rs deleted file mode 100644 index d5bca6a24..000000000 --- a/src/test/ui/rfcs/rfc-2005-default-binding-mode/constref.rs +++ /dev/null @@ -1,40 +0,0 @@ -// run-pass -const CONST_REF: &[u8; 3] = b"foo"; - -trait Foo { - const CONST_REF_DEFAULT: &'static [u8; 3] = b"bar"; - const CONST_REF: &'static [u8; 3]; -} - -impl Foo for i32 { - const CONST_REF: &'static [u8; 3] = b"jjj"; -} - -impl Foo for i64 { - const CONST_REF_DEFAULT: &'static [u8; 3] = b"ggg"; - const CONST_REF: &'static [u8; 3] = b"fff"; -} - -// Check that (associated and free) const references are not mistaken for a -// non-reference pattern (in which case they would be auto-dereferenced, making -// the types mismatched). - -fn const_ref() -> bool { - let f = b"foo"; - match f { - CONST_REF => true, - _ => false, - } -} - -fn associated_const_ref() -> bool { - match (b"bar", b"jjj", b"ggg", b"fff") { - (i32::CONST_REF_DEFAULT, i32::CONST_REF, i64::CONST_REF_DEFAULT, i64::CONST_REF) => true, - _ => false, - } -} - -pub fn main() { - assert!(const_ref()); - assert!(associated_const_ref()); -} diff --git a/src/test/ui/rfcs/rfc-2005-default-binding-mode/enum.rs b/src/test/ui/rfcs/rfc-2005-default-binding-mode/enum.rs deleted file mode 100644 index 52fbb90ed..000000000 --- a/src/test/ui/rfcs/rfc-2005-default-binding-mode/enum.rs +++ /dev/null @@ -1,45 +0,0 @@ -// run-pass -enum Wrapper { - Wrap(i32), -} - -use Wrapper::Wrap; - -pub fn main() { - let Wrap(x) = &Wrap(3); - println!("{}", *x); - - let Wrap(x) = &mut Wrap(3); - println!("{}", *x); - - if let Some(x) = &Some(3) { - println!("{}", *x); - } else { - panic!(); - } - - if let Some(x) = &mut Some(3) { - println!("{}", *x); - } else { - panic!(); - } - - if let Some(x) = &mut Some(3) { - *x += 1; - } else { - panic!(); - } - - while let Some(x) = &Some(3) { - println!("{}", *x); - break; - } - while let Some(x) = &mut Some(3) { - println!("{}", *x); - break; - } - while let Some(x) = &mut Some(3) { - *x += 1; - break; - } -} diff --git a/src/test/ui/rfcs/rfc-2005-default-binding-mode/for.rs b/src/test/ui/rfcs/rfc-2005-default-binding-mode/for.rs deleted file mode 100644 index a5a24a806..000000000 --- a/src/test/ui/rfcs/rfc-2005-default-binding-mode/for.rs +++ /dev/null @@ -1,20 +0,0 @@ -// run-pass -pub fn main() { - let mut tups = vec![(0u8, 1u8)]; - - for (n, m) in &tups { - let _: &u8 = n; - let _: &u8 = m; - } - - for (n, m) in &mut tups { - *n += 1; - *m += 2; - } - - assert_eq!(tups, vec![(1u8, 3u8)]); - - for (n, m) in tups { - println!("{} {}", m, n); - } -} diff --git a/src/test/ui/rfcs/rfc-2005-default-binding-mode/general.rs b/src/test/ui/rfcs/rfc-2005-default-binding-mode/general.rs deleted file mode 100644 index 0207f607b..000000000 --- a/src/test/ui/rfcs/rfc-2005-default-binding-mode/general.rs +++ /dev/null @@ -1,249 +0,0 @@ -// run-pass -#![allow(unused_variables)] -fn some_or_wildcard(r: &Option, b: &i32) { - let _: &i32 = match r { - Some(a) => a, - _ => b, - }; -} - -fn none_or_wildcard(r: &Option, b: &i32) { - let _: &i32 = match r { - None => b, - _ => b, - }; -} - -fn some_or_ref_none(r: &Option, b: &i32) { - let _: &i32 = match r { - Some(a) => a, - &None => b, - }; -} - -fn ref_some_or_none(r: &Option, b: &i32) { - let _: &i32 = match r { - &Some(ref a) => a, - None => b, - }; -} - -fn some_or_self(r: &Option) { - let _: &Option = match r { - Some(n) => { - let _: &i32 = n; - r - }, - x => x, - }; -} - -fn multiple_deref(r: &&&&&Option) { - let _: i32 = match r { - Some(a) => *a, - None => 5, - }; -} - -fn match_with_or() { - // FIXME(tschottdorf): #44912. - // - // let x = &Some((3, 3)); - // let _: &i32 = match x { - // Some((x, 3)) | &Some((ref x, 5)) => x, - // _ => &5i32, - // }; -} - -fn nested_mixed() { - match (&Some(5), &Some(6)) { - (Some(a), &Some(mut b)) => { - // Here, the `a` will be `&i32`, because in the first half of the tuple - // we hit a non-reference pattern and shift into `ref` mode. - // - // In the second half of the tuple there's no non-reference pattern, - // so `b` will be `i32` (bound with `move` mode). Moreover, `b` is - // mutable. - let _: &i32 = a; - b = 7; - let _: i32 = b; - }, - _ => {}, - }; -} - -fn nested_mixed_multiple_deref_1() { - let x = (1, &Some(5)); - let y = &Some(x); - match y { - Some((a, Some(b))) => { - let _: &i32 = a; - let _: &i32 = b; - }, - _ => {}, - }; -} - -fn nested_mixed_multiple_deref_2() { - let x = &Some(5); - let y = &x; - match y { - Some(z) => { - let _: &i32 = z; - }, - _ => {}, - } -} - -fn new_mutable_reference() { - let mut x = &mut Some(5); - match &mut x { - Some(y) => { - *y = 5; - }, - None => { }, - } - - match &mut x { - Some(y) => { - println!("{}", *y); - }, - None => {}, - } -} - -fn let_implicit_ref_binding() { - struct Foo(i32); - - // Note that these rules apply to any pattern matching - // whether it be in a `match` or a `let`. - // For example, `x` here is a `ref` binding: - let Foo(x) = &Foo(3); - let _: &i32 = x; -} - -fn explicit_mut_binding() { - match &Some(5i32) { - Some(mut n) => { - n += 1; - let _ = n; - } - None => {}, - }; - - match &mut Some(5i32) { - Some(n) => { - *n += 1; - let _ = n; - } - None => {}, - }; - - match &mut &mut Some(5i32) { - Some(n) => { - let _: &mut i32 = n; - } - None => {}, - }; -} - -fn tuple_mut_and_mut_mut() { - match (Some(5i32), &Some(5i32)) { - (Some(n), Some(m)) => { - // `n` and `m` are bound as immutable references. Make new references from them to - // assert that. - let r = n; - let _ = r; - let q = m; - let _ = q; - - // Assert the types. Note that we use `n` and `m` here which would fail had they been - // moved due to the assignments above. - let _: i32 = n; - let _: &i32 = m; - } - (_, _) => {}, - }; - - match (&Some(5i32), &&Some(5i32)) { - (Some(n), Some(m)) => { - let _: &i32 = n; - let _: &i32 = m; - } - (_, _) => {}, - }; - - match &mut &mut (Some(5i32), Some(5i32)) { - (Some(n), Some(m)) => { - // Dereferenced through &mut &mut, so a mutable binding results. - let _: &mut i32 = n; - let _: &mut i32 = m; - } - (_, _) => {}, - }; - - match (&mut Some(5i32), &mut &mut Some(5i32)) { - (Some(n), Some(m)) => { - let _: &mut i32 = n; - let _: &mut i32 = m; - } - (_, _) => {}, - }; -} - -fn min_mir_embedded_type() { - // The reduced invocation that an ICE was diagnosed with (was consuming - // adjustments in wrong order). - match (0u8, &&Some(5i32)) { - (_, Some(m)) => { - let _: &i32 = m; - } - (_, _) => {}, - }; -} - -fn no_autoderef() { - // Binding. - let x = &3; - println!("{}", *x); - - // Wildcard. - let _ = &3; - - // Constant of generic type (string) - const Y: &'static str = "foo"; - assert_eq!(0, match "foo" { - Y => 0, - _ => 1, - }); - - // Reference pattern. - let &x = &3; -} - -pub fn main() { - let r: &Option = &Some(3); - let b = &4i32; - - none_or_wildcard(r, b); - some_or_wildcard(r, b); - some_or_ref_none(r, b); - ref_some_or_none(r, b); - - some_or_self(r); - multiple_deref(&&&&r); - match_with_or(); - - nested_mixed(); - nested_mixed_multiple_deref_1(); - nested_mixed_multiple_deref_2(); - - new_mutable_reference(); - explicit_mut_binding(); - tuple_mut_and_mut_mut(); - min_mir_embedded_type(); - - let_implicit_ref_binding(); - - no_autoderef(); -} diff --git a/src/test/ui/rfcs/rfc-2005-default-binding-mode/lit.rs b/src/test/ui/rfcs/rfc-2005-default-binding-mode/lit.rs deleted file mode 100644 index 937975359..000000000 --- a/src/test/ui/rfcs/rfc-2005-default-binding-mode/lit.rs +++ /dev/null @@ -1,34 +0,0 @@ -// run-pass -#![allow(dead_code)] -fn with_u8() { - let s = 5u8; - let r = match &s { - 4 => false, - 5 => true, - _ => false, - }; - assert!(r); -} - -// A string literal isn't mistaken for a non-ref pattern (in which case we'd -// deref `s` and mess things up). -fn with_str() { - let s: &'static str = "abc"; - match s { - "abc" => true, - _ => panic!(), - }; -} - -// Ditto with byte strings. -fn with_bytes() { - let s: &'static [u8] = b"abc"; - match s { - b"abc" => true, - _ => panic!(), - }; -} - -pub fn main() { - with_str(); -} diff --git a/src/test/ui/rfcs/rfc-2005-default-binding-mode/range.rs b/src/test/ui/rfcs/rfc-2005-default-binding-mode/range.rs deleted file mode 100644 index f8abd1b96..000000000 --- a/src/test/ui/rfcs/rfc-2005-default-binding-mode/range.rs +++ /dev/null @@ -1,9 +0,0 @@ -// run-pass -pub fn main() { - let i = 5; - match &&&&i { - 1 ..= 3 => panic!(), - 4 ..= 8 => {}, - _ => panic!(), - } -} diff --git a/src/test/ui/rfcs/rfc-2005-default-binding-mode/ref-region.rs b/src/test/ui/rfcs/rfc-2005-default-binding-mode/ref-region.rs deleted file mode 100644 index b74e45c93..000000000 --- a/src/test/ui/rfcs/rfc-2005-default-binding-mode/ref-region.rs +++ /dev/null @@ -1,16 +0,0 @@ -// run-pass -fn foo<'a, 'b>(x: &'a &'b Option) -> &'a u32 { - let x: &'a &'a Option = x; - match x { - Some(r) => { - let _: &u32 = r; - r - }, - &None => panic!(), - } -} - -pub fn main() { - let x = Some(5); - foo(&&x); -} diff --git a/src/test/ui/rfcs/rfc-2005-default-binding-mode/reset-mode.rs b/src/test/ui/rfcs/rfc-2005-default-binding-mode/reset-mode.rs deleted file mode 100644 index 3b9d07610..000000000 --- a/src/test/ui/rfcs/rfc-2005-default-binding-mode/reset-mode.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-pass -// Test that we "reset" the mode as we pass through a `&` pattern. -// -// cc #46688 - -fn surprise(x: i32) { - assert_eq!(x, 2); -} - -fn main() { - let x = &(1, &2); - let (_, &b) = x; - surprise(b); -} diff --git a/src/test/ui/rfcs/rfc-2005-default-binding-mode/slice.rs b/src/test/ui/rfcs/rfc-2005-default-binding-mode/slice.rs deleted file mode 100644 index 33229a205..000000000 --- a/src/test/ui/rfcs/rfc-2005-default-binding-mode/slice.rs +++ /dev/null @@ -1,25 +0,0 @@ -// run-pass - -fn slice_pat() { - let sl: &[u8] = b"foo"; - - match sl { - [first, remainder @ ..] => { - let _: &u8 = first; - assert_eq!(first, &b'f'); - assert_eq!(remainder, b"oo"); - } - [] => panic!(), - } -} - -fn slice_pat_omission() { - match &[0, 1, 2] { - [..] => {} - }; -} - -fn main() { - slice_pat(); - slice_pat_omission(); -} diff --git a/src/test/ui/rfcs/rfc-2005-default-binding-mode/struct.rs b/src/test/ui/rfcs/rfc-2005-default-binding-mode/struct.rs deleted file mode 100644 index 5a00e5b68..000000000 --- a/src/test/ui/rfcs/rfc-2005-default-binding-mode/struct.rs +++ /dev/null @@ -1,22 +0,0 @@ -// run-pass -#[derive(Debug, PartialEq)] -struct Foo { - x: u8, -} - -pub fn main() { - let mut foo = Foo { - x: 1, - }; - - match &mut foo { - Foo{x: n} => { - *n += 1; - }, - }; - - assert_eq!(foo, Foo{x: 2}); - - let Foo{x: n} = &foo; - assert_eq!(*n, 2); -} diff --git a/src/test/ui/rfcs/rfc-2005-default-binding-mode/tuple-struct.rs b/src/test/ui/rfcs/rfc-2005-default-binding-mode/tuple-struct.rs deleted file mode 100644 index 0cf9ba1b4..000000000 --- a/src/test/ui/rfcs/rfc-2005-default-binding-mode/tuple-struct.rs +++ /dev/null @@ -1,19 +0,0 @@ -// run-pass -#![allow(dead_code)] -enum Foo { - Bar(Option, (), (), Vec), - Baz, -} - -pub fn main() { - let foo = Foo::Bar(Some(1), (), (), vec![2, 3]); - - match &foo { - Foo::Baz => panic!(), - Foo::Bar(None, ..) => panic!(), - Foo::Bar(Some(n), .., v) => { - assert_eq!((*v).len(), 2); - assert_eq!(*n, 1); - } - } -} diff --git a/src/test/ui/rfcs/rfc-2005-default-binding-mode/tuple.rs b/src/test/ui/rfcs/rfc-2005-default-binding-mode/tuple.rs deleted file mode 100644 index 4c22aa2d7..000000000 --- a/src/test/ui/rfcs/rfc-2005-default-binding-mode/tuple.rs +++ /dev/null @@ -1,12 +0,0 @@ -// run-pass -pub fn main() { - let foo = (Some(1), (), (), vec![2, 3]); - - match &foo { - (Some(n), .., v) => { - assert_eq!((*v).len(), 2); - assert_eq!(*n, 1); - } - (None, (), (), ..) => panic!(), - } -} diff --git a/src/test/ui/rfcs/rfc-2151-raw-identifiers/attr.rs b/src/test/ui/rfcs/rfc-2151-raw-identifiers/attr.rs deleted file mode 100644 index d359067f6..000000000 --- a/src/test/ui/rfcs/rfc-2151-raw-identifiers/attr.rs +++ /dev/null @@ -1,15 +0,0 @@ -// run-pass -use std::mem; - -#[r#repr(r#C, r#packed)] -struct Test { - a: bool, b: u64 -} - -#[r#derive(r#Debug)] -struct Test2(#[allow(unused_tuple_struct_fields)] u32); - -pub fn main() { - assert_eq!(mem::size_of::(), 9); - assert_eq!("Test2(123)", format!("{:?}", Test2(123))); -} diff --git a/src/test/ui/rfcs/rfc-2151-raw-identifiers/basic.rs b/src/test/ui/rfcs/rfc-2151-raw-identifiers/basic.rs deleted file mode 100644 index f2fe59668..000000000 --- a/src/test/ui/rfcs/rfc-2151-raw-identifiers/basic.rs +++ /dev/null @@ -1,20 +0,0 @@ -// run-pass -fn r#fn(r#match: u32) -> u32 { - r#match -} - -pub fn main() { - let r#struct = 1; - assert_eq!(1, r#struct); - - let foo = 2; - assert_eq!(2, r#foo); - - let r#bar = 3; - assert_eq!(3, bar); - - assert_eq!(4, r#fn(4)); - - let r#true = false; - assert_eq!(r#true, false); -} diff --git a/src/test/ui/rfcs/rfc-2151-raw-identifiers/items.rs b/src/test/ui/rfcs/rfc-2151-raw-identifiers/items.rs deleted file mode 100644 index 466522517..000000000 --- a/src/test/ui/rfcs/rfc-2151-raw-identifiers/items.rs +++ /dev/null @@ -1,32 +0,0 @@ -// run-pass -#[derive(Debug, PartialEq, Eq)] -struct IntWrapper(u32); - -#[derive(Debug, Ord, PartialOrd, PartialEq, Eq, Hash, Copy, Clone, Default)] -struct HasKeywordField { - r#struct: u32, -} - -struct Generic(T); - -trait Trait { - fn r#trait(&self) -> u32; -} -impl Trait for Generic { - fn r#trait(&self) -> u32 { - self.0 - } -} - -pub fn main() { - assert_eq!(IntWrapper(1), r#IntWrapper(1)); - - match IntWrapper(2) { - r#IntWrapper(r#struct) => assert_eq!(2, r#struct), - } - - assert_eq!("HasKeywordField { struct: 3 }", format!("{:?}", HasKeywordField { r#struct: 3 })); - - assert_eq!(4, Generic(4).0); - assert_eq!(5, Generic(5).r#trait()); -} diff --git a/src/test/ui/rfcs/rfc-2151-raw-identifiers/macros.rs b/src/test/ui/rfcs/rfc-2151-raw-identifiers/macros.rs deleted file mode 100644 index 0ab7e17f8..000000000 --- a/src/test/ui/rfcs/rfc-2151-raw-identifiers/macros.rs +++ /dev/null @@ -1,38 +0,0 @@ -// run-pass -#![feature(decl_macro)] - -macro_rules! r#struct { - ($r#struct:expr) => { $r#struct } -} - -macro_rules! old_macro { - ($a:expr) => {$a} -} - -macro r#decl_macro($r#fn:expr) { - $r#fn -} - -macro passthrough($id:ident) { - $id -} - -macro_rules! test_pat_match { - (a) => { 6 }; - (r#a) => { 7 }; -} - -pub fn main() { - r#println!("{struct}", r#struct = 1); - assert_eq!(2, r#struct!(2)); - assert_eq!(3, r#old_macro!(3)); - assert_eq!(4, decl_macro!(4)); - - let r#match = 5; - assert_eq!(5, passthrough!(r#match)); - - assert_eq!("r#struct", stringify!(r#struct)); - - assert_eq!(6, test_pat_match!(a)); - assert_eq!(7, test_pat_match!(r#a)); -} diff --git a/src/test/ui/rfcs/rfc-2175-or-if-while-let/basic.rs b/src/test/ui/rfcs/rfc-2175-or-if-while-let/basic.rs deleted file mode 100644 index 22f04c58f..000000000 --- a/src/test/ui/rfcs/rfc-2175-or-if-while-let/basic.rs +++ /dev/null @@ -1,33 +0,0 @@ -// run-pass -#![allow(dead_code)] - -enum E { - V(u8), - U(u8), - W, -} -use E::*; - -fn main() { - let mut e = V(10); - - if let V(x) | U(x) = e { - assert_eq!(x, 10); - } - while let V(x) | U(x) = e { - assert_eq!(x, 10); - e = W; - } - - // Accept leading `|`: - - let mut e = V(10); - - if let | V(x) | U(x) = e { - assert_eq!(x, 10); - } - while let | V(x) | U(x) = e { - assert_eq!(x, 10); - e = W; - } -} diff --git a/src/test/ui/rfcs/rfc-2302-self-struct-ctor.rs b/src/test/ui/rfcs/rfc-2302-self-struct-ctor.rs deleted file mode 100644 index 1ec20c500..000000000 --- a/src/test/ui/rfcs/rfc-2302-self-struct-ctor.rs +++ /dev/null @@ -1,127 +0,0 @@ -// run-pass - -#![allow(dead_code)] - -use std::fmt::Display; - -struct ST1(i32, i32); - -impl ST1 { - fn new() -> Self { - ST1(0, 1) - } - - fn ctor() -> Self { - Self(1,2) // Self as a constructor - } - - fn pattern(self) { - match self { - Self(x, y) => println!("{} {}", x, y), // Self as a pattern - } - } -} - -struct ST2(T); // With type parameter - -impl ST2 where T: Display { - - fn ctor(v: T) -> Self { - Self(v) - } - - fn pattern(&self) { - match self { - Self(ref v) => println!("{}", v), - } - } -} - -struct ST3<'a>(&'a i32); // With lifetime parameter - -impl<'a> ST3<'a> { - - fn ctor(v: &'a i32) -> Self { - Self(v) - } - - fn pattern(self) { - let Self(ref v) = self; - println!("{}", v); - } -} - -struct ST4(usize); - -impl ST4 { - fn map(opt: Option) -> Option { - opt.map(Self) // use `Self` as a function passed somewhere - } -} - -struct ST5; // unit struct - -impl ST5 { - fn ctor() -> Self { - Self // `Self` as a unit struct value - } - - fn pattern(self) -> Self { - match self { - Self => Self, // `Self` as a unit struct value for matching - } - } -} - -struct ST6(i32); -type T = ST6; -impl T { - fn ctor() -> Self { - ST6(1) - } - - fn type_alias(self) { - let Self(_x) = match self { Self(x) => Self(x) }; - let _opt: Option = Some(0).map(Self); - } -} - -struct ST7(T1, T2); - -impl ST7 { - - fn ctor() -> Self { - Self(1, 2) - } - - fn pattern(self) -> Self { - match self { - Self(x, y) => Self(x, y), - } - } -} - -fn main() { - let v1 = ST1::ctor(); - v1.pattern(); - - let v2 = ST2::ctor(10); - v2.pattern(); - - let local = 42; - let v3 = ST3::ctor(&local); - v3.pattern(); - - let v4 = Some(1usize); - let _ = ST4::map(v4); - - let v5 = ST5::ctor(); - v5.pattern(); - - let v6 = ST6::ctor(); - v6.type_alias(); - - let v7 = ST7::::ctor(); - let r = v7.pattern(); - println!("{} {}", r.0, r.1) -} diff --git a/src/test/ui/rfcs/rfc-2396-target_feature-11/check-pass.rs b/src/test/ui/rfcs/rfc-2396-target_feature-11/check-pass.rs deleted file mode 100644 index e0842bfa4..000000000 --- a/src/test/ui/rfcs/rfc-2396-target_feature-11/check-pass.rs +++ /dev/null @@ -1,52 +0,0 @@ -// Tests the new rules added by RFC 2396, including: -// - applying `#[target_feature]` to safe functions is allowed -// - calling functions with `#[target_feature]` is allowed in -// functions which have (at least) the same features -// - calling functions with `#[target_feature]` is allowed in -// unsafe contexts -// - functions with `#[target_feature]` can coerce to unsafe fn pointers - -// check-pass -// only-x86_64 -// revisions: mir thir -// [thir]compile-flags: -Z thir-unsafeck - -#![feature(target_feature_11)] - -#[target_feature(enable = "sse2")] -const fn sse2() {} - -#[cfg(target_feature = "sse2")] -const SSE2_ONLY: () = unsafe { - sse2(); -}; - -#[target_feature(enable = "sse2")] -fn also_sse2() { - sse2(); -} - -#[target_feature(enable = "sse2")] -#[target_feature(enable = "avx")] -fn sse2_and_avx() { - sse2(); -} - -struct Foo; - -impl Foo { - #[target_feature(enable = "sse2")] - fn sse2(&self) { - sse2(); - } -} - -fn main() { - if cfg!(target_feature = "sse2") { - unsafe { - sse2(); - Foo.sse2(); - } - } - let sse2_ptr: unsafe fn() = sse2; -} diff --git a/src/test/ui/rfcs/rfc-2396-target_feature-11/closures-inherit-target_feature.rs b/src/test/ui/rfcs/rfc-2396-target_feature-11/closures-inherit-target_feature.rs deleted file mode 100644 index a59d7c2d7..000000000 --- a/src/test/ui/rfcs/rfc-2396-target_feature-11/closures-inherit-target_feature.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Tests #73631: closures inherit `#[target_feature]` annotations - -// check-pass -// revisions: mir thir -// [thir]compile-flags: -Z thir-unsafeck -// only-x86_64 - -#![feature(target_feature_11)] - -#[target_feature(enable="avx")] -fn also_use_avx() { - println!("Hello from AVX") -} - -#[target_feature(enable="avx")] -fn use_avx() -> Box { - Box::new(|| also_use_avx()) -} - -fn main() {} diff --git a/src/test/ui/rfcs/rfc-2396-target_feature-11/feature-gate-target_feature_11.rs b/src/test/ui/rfcs/rfc-2396-target_feature-11/feature-gate-target_feature_11.rs deleted file mode 100644 index 975d7a1f6..000000000 --- a/src/test/ui/rfcs/rfc-2396-target_feature-11/feature-gate-target_feature_11.rs +++ /dev/null @@ -1,6 +0,0 @@ -// only-x86_64 - -#[target_feature(enable = "sse2")] //~ ERROR can only be applied to `unsafe` functions -fn foo() {} - -fn main() {} diff --git a/src/test/ui/rfcs/rfc-2396-target_feature-11/feature-gate-target_feature_11.stderr b/src/test/ui/rfcs/rfc-2396-target_feature-11/feature-gate-target_feature_11.stderr deleted file mode 100644 index 18917fd25..000000000 --- a/src/test/ui/rfcs/rfc-2396-target_feature-11/feature-gate-target_feature_11.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions - --> $DIR/feature-gate-target_feature_11.rs:3:1 - | -LL | #[target_feature(enable = "sse2")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | fn foo() {} - | -------- not an `unsafe` function - | - = note: see issue #69098 for more information - = help: add `#![feature(target_feature_11)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.mir.stderr b/src/test/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.mir.stderr deleted file mode 100644 index cf5815df5..000000000 --- a/src/test/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.mir.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/fn-ptr.rs:11:21 - | -LL | #[target_feature(enable = "sse2")] - | ---------------------------------- `#[target_feature]` added here -... -LL | let foo: fn() = foo; - | ---- ^^^ cannot coerce functions with `#[target_feature]` to safe function pointers - | | - | expected due to this - | - = note: expected fn pointer `fn()` - found fn item `fn() {foo}` - = note: functions with `#[target_feature]` can only be coerced to `unsafe` function pointers - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.rs b/src/test/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.rs deleted file mode 100644 index c95d4a08e..000000000 --- a/src/test/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.rs +++ /dev/null @@ -1,12 +0,0 @@ -// revisions: mir thir -// [thir]compile-flags: -Z thir-unsafeck -// only-x86_64 - -#![feature(target_feature_11)] - -#[target_feature(enable = "sse2")] -fn foo() {} - -fn main() { - let foo: fn() = foo; //~ ERROR mismatched types -} diff --git a/src/test/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.thir.stderr b/src/test/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.thir.stderr deleted file mode 100644 index cf5815df5..000000000 --- a/src/test/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.thir.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/fn-ptr.rs:11:21 - | -LL | #[target_feature(enable = "sse2")] - | ---------------------------------- `#[target_feature]` added here -... -LL | let foo: fn() = foo; - | ---- ^^^ cannot coerce functions with `#[target_feature]` to safe function pointers - | | - | expected due to this - | - = note: expected fn pointer `fn()` - found fn item `fn() {foo}` - = note: functions with `#[target_feature]` can only be coerced to `unsafe` function pointers - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/rfcs/rfc-2396-target_feature-11/fn-traits.rs b/src/test/ui/rfcs/rfc-2396-target_feature-11/fn-traits.rs deleted file mode 100644 index 43bda4962..000000000 --- a/src/test/ui/rfcs/rfc-2396-target_feature-11/fn-traits.rs +++ /dev/null @@ -1,34 +0,0 @@ -// only-x86_64 - -#![feature(target_feature_11)] - -#[target_feature(enable = "avx")] -fn foo() {} - -#[target_feature(enable = "avx")] -unsafe fn foo_unsafe() {} - -fn call(f: impl Fn()) { - f() -} - -fn call_mut(f: impl FnMut()) { - f() -} - -fn call_once(f: impl FnOnce()) { - f() -} - -fn main() { - call(foo); //~ ERROR expected a `Fn<()>` closure, found `fn() {foo}` - call_mut(foo); //~ ERROR expected a `FnMut<()>` closure, found `fn() {foo}` - call_once(foo); //~ ERROR expected a `FnOnce<()>` closure, found `fn() {foo}` - - call(foo_unsafe); - //~^ ERROR expected a `Fn<()>` closure, found `unsafe fn() {foo_unsafe}` - call_mut(foo_unsafe); - //~^ ERROR expected a `FnMut<()>` closure, found `unsafe fn() {foo_unsafe}` - call_once(foo_unsafe); - //~^ ERROR expected a `FnOnce<()>` closure, found `unsafe fn() {foo_unsafe}` -} diff --git a/src/test/ui/rfcs/rfc-2396-target_feature-11/fn-traits.stderr b/src/test/ui/rfcs/rfc-2396-target_feature-11/fn-traits.stderr deleted file mode 100644 index fc7bf2277..000000000 --- a/src/test/ui/rfcs/rfc-2396-target_feature-11/fn-traits.stderr +++ /dev/null @@ -1,105 +0,0 @@ -error[E0277]: expected a `Fn<()>` closure, found `fn() {foo}` - --> $DIR/fn-traits.rs:24:10 - | -LL | call(foo); - | ---- ^^^ expected an `Fn<()>` closure, found `fn() {foo}` - | | - | required by a bound introduced by this call - | - = help: the trait `Fn<()>` is not implemented for fn item `fn() {foo}` - = note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ }` - = note: `#[target_feature]` functions do not implement the `Fn` traits -note: required by a bound in `call` - --> $DIR/fn-traits.rs:11:17 - | -LL | fn call(f: impl Fn()) { - | ^^^^ required by this bound in `call` - -error[E0277]: expected a `FnMut<()>` closure, found `fn() {foo}` - --> $DIR/fn-traits.rs:25:14 - | -LL | call_mut(foo); - | -------- ^^^ expected an `FnMut<()>` closure, found `fn() {foo}` - | | - | required by a bound introduced by this call - | - = help: the trait `FnMut<()>` is not implemented for fn item `fn() {foo}` - = note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ }` - = note: `#[target_feature]` functions do not implement the `Fn` traits -note: required by a bound in `call_mut` - --> $DIR/fn-traits.rs:15:21 - | -LL | fn call_mut(f: impl FnMut()) { - | ^^^^^^^ required by this bound in `call_mut` - -error[E0277]: expected a `FnOnce<()>` closure, found `fn() {foo}` - --> $DIR/fn-traits.rs:26:15 - | -LL | call_once(foo); - | --------- ^^^ expected an `FnOnce<()>` closure, found `fn() {foo}` - | | - | required by a bound introduced by this call - | - = help: the trait `FnOnce<()>` is not implemented for fn item `fn() {foo}` - = note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ }` - = note: `#[target_feature]` functions do not implement the `Fn` traits -note: required by a bound in `call_once` - --> $DIR/fn-traits.rs:19:22 - | -LL | fn call_once(f: impl FnOnce()) { - | ^^^^^^^^ required by this bound in `call_once` - -error[E0277]: expected a `Fn<()>` closure, found `unsafe fn() {foo_unsafe}` - --> $DIR/fn-traits.rs:28:10 - | -LL | call(foo_unsafe); - | ---- ^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }` - | | - | required by a bound introduced by this call - | - = help: the trait `Fn<()>` is not implemented for fn item `unsafe fn() {foo_unsafe}` - = note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ }` - = note: `#[target_feature]` functions do not implement the `Fn` traits -note: required by a bound in `call` - --> $DIR/fn-traits.rs:11:17 - | -LL | fn call(f: impl Fn()) { - | ^^^^ required by this bound in `call` - -error[E0277]: expected a `FnMut<()>` closure, found `unsafe fn() {foo_unsafe}` - --> $DIR/fn-traits.rs:30:14 - | -LL | call_mut(foo_unsafe); - | -------- ^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }` - | | - | required by a bound introduced by this call - | - = help: the trait `FnMut<()>` is not implemented for fn item `unsafe fn() {foo_unsafe}` - = note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ }` - = note: `#[target_feature]` functions do not implement the `Fn` traits -note: required by a bound in `call_mut` - --> $DIR/fn-traits.rs:15:21 - | -LL | fn call_mut(f: impl FnMut()) { - | ^^^^^^^ required by this bound in `call_mut` - -error[E0277]: expected a `FnOnce<()>` closure, found `unsafe fn() {foo_unsafe}` - --> $DIR/fn-traits.rs:32:15 - | -LL | call_once(foo_unsafe); - | --------- ^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }` - | | - | required by a bound introduced by this call - | - = help: the trait `FnOnce<()>` is not implemented for fn item `unsafe fn() {foo_unsafe}` - = note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ }` - = note: `#[target_feature]` functions do not implement the `Fn` traits -note: required by a bound in `call_once` - --> $DIR/fn-traits.rs:19:22 - | -LL | fn call_once(f: impl FnOnce()) { - | ^^^^^^^^ required by this bound in `call_once` - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/rfcs/rfc-2396-target_feature-11/issue-99876.rs b/src/test/ui/rfcs/rfc-2396-target_feature-11/issue-99876.rs deleted file mode 100644 index 033dcdfc0..000000000 --- a/src/test/ui/rfcs/rfc-2396-target_feature-11/issue-99876.rs +++ /dev/null @@ -1,9 +0,0 @@ -// check-pass - -#![feature(target_feature_11)] - -struct S(T) -where - [T; (|| {}, 1).1]: Copy; - -fn main() {} diff --git a/src/test/ui/rfcs/rfc-2396-target_feature-11/safe-calls.mir.stderr b/src/test/ui/rfcs/rfc-2396-target_feature-11/safe-calls.mir.stderr deleted file mode 100644 index 0ef7b8b09..000000000 --- a/src/test/ui/rfcs/rfc-2396-target_feature-11/safe-calls.mir.stderr +++ /dev/null @@ -1,83 +0,0 @@ -error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:23:5 - | -LL | sse2(); - | ^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:26:5 - | -LL | avx_bmi2(); - | ^^^^^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:29:5 - | -LL | Quux.avx_bmi2(); - | ^^^^^^^^^^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:36:5 - | -LL | avx_bmi2(); - | ^^^^^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:39:5 - | -LL | Quux.avx_bmi2(); - | ^^^^^^^^^^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:46:5 - | -LL | sse2(); - | ^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:49:5 - | -LL | avx_bmi2(); - | ^^^^^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:52:5 - | -LL | Quux.avx_bmi2(); - | ^^^^^^^^^^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:60:5 - | -LL | sse2(); - | ^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:65:18 - | -LL | const name: () = sse2(); - | ^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error: aborting due to 10 previous errors - -For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/rfcs/rfc-2396-target_feature-11/safe-calls.rs b/src/test/ui/rfcs/rfc-2396-target_feature-11/safe-calls.rs deleted file mode 100644 index cebc6f947..000000000 --- a/src/test/ui/rfcs/rfc-2396-target_feature-11/safe-calls.rs +++ /dev/null @@ -1,69 +0,0 @@ -// revisions: mir thir -// [thir]compile-flags: -Z thir-unsafeck -// only-x86_64 - -#![feature(target_feature_11)] - -#[target_feature(enable = "sse2")] -const fn sse2() {} - -#[target_feature(enable = "avx")] -#[target_feature(enable = "bmi2")] -fn avx_bmi2() {} - -struct Quux; - -impl Quux { - #[target_feature(enable = "avx")] - #[target_feature(enable = "bmi2")] - fn avx_bmi2(&self) {} -} - -fn foo() { - sse2(); - //[mir]~^ ERROR call to function with `#[target_feature]` is unsafe - //[thir]~^^ ERROR call to function `sse2` with `#[target_feature]` is unsafe - avx_bmi2(); - //[mir]~^ ERROR call to function with `#[target_feature]` is unsafe - //[thir]~^^ ERROR call to function `avx_bmi2` with `#[target_feature]` is unsafe - Quux.avx_bmi2(); - //[mir]~^ ERROR call to function with `#[target_feature]` is unsafe - //[thir]~^^ ERROR call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe -} - -#[target_feature(enable = "sse2")] -fn bar() { - avx_bmi2(); - //[mir]~^ ERROR call to function with `#[target_feature]` is unsafe - //[thir]~^^ ERROR call to function `avx_bmi2` with `#[target_feature]` is unsafe - Quux.avx_bmi2(); - //[mir]~^ ERROR call to function with `#[target_feature]` is unsafe - //[thir]~^^ ERROR call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe -} - -#[target_feature(enable = "avx")] -fn baz() { - sse2(); - //[mir]~^ ERROR call to function with `#[target_feature]` is unsafe - //[thir]~^^ ERROR call to function `sse2` with `#[target_feature]` is unsafe - avx_bmi2(); - //[mir]~^ ERROR call to function with `#[target_feature]` is unsafe - //[thir]~^^ ERROR call to function `avx_bmi2` with `#[target_feature]` is unsafe - Quux.avx_bmi2(); - //[mir]~^ ERROR call to function with `#[target_feature]` is unsafe - //[thir]~^^ ERROR call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe -} - -#[target_feature(enable = "avx")] -#[target_feature(enable = "bmi2")] -fn qux() { - sse2(); - //[mir]~^ ERROR call to function with `#[target_feature]` is unsafe - //[thir]~^^ ERROR call to function `sse2` with `#[target_feature]` is unsafe -} - -const name: () = sse2(); -//[mir]~^ ERROR call to function with `#[target_feature]` is unsafe -//[thir]~^^ ERROR call to function `sse2` with `#[target_feature]` is unsafe - -fn main() {} diff --git a/src/test/ui/rfcs/rfc-2396-target_feature-11/safe-calls.thir.stderr b/src/test/ui/rfcs/rfc-2396-target_feature-11/safe-calls.thir.stderr deleted file mode 100644 index c75ac6e8b..000000000 --- a/src/test/ui/rfcs/rfc-2396-target_feature-11/safe-calls.thir.stderr +++ /dev/null @@ -1,83 +0,0 @@ -error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:23:5 - | -LL | sse2(); - | ^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:26:5 - | -LL | avx_bmi2(); - | ^^^^^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:29:5 - | -LL | Quux.avx_bmi2(); - | ^^^^^^^^^^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:36:5 - | -LL | avx_bmi2(); - | ^^^^^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:39:5 - | -LL | Quux.avx_bmi2(); - | ^^^^^^^^^^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:46:5 - | -LL | sse2(); - | ^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:49:5 - | -LL | avx_bmi2(); - | ^^^^^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:52:5 - | -LL | Quux.avx_bmi2(); - | ^^^^^^^^^^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:60:5 - | -LL | sse2(); - | ^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block - --> $DIR/safe-calls.rs:65:18 - | -LL | const name: () = sse2(); - | ^^^^^^ call to function with `#[target_feature]` - | - = note: can only be called if the required target features are available - -error: aborting due to 10 previous errors - -For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/rfcs/rfc-2396-target_feature-11/trait-impl.rs b/src/test/ui/rfcs/rfc-2396-target_feature-11/trait-impl.rs deleted file mode 100644 index 7314fa8cc..000000000 --- a/src/test/ui/rfcs/rfc-2396-target_feature-11/trait-impl.rs +++ /dev/null @@ -1,21 +0,0 @@ -// only-x86_64 - -#![feature(target_feature_11)] - -trait Foo { - fn foo(&self); - unsafe fn unsf_foo(&self); -} - -struct Bar; - -impl Foo for Bar { - #[target_feature(enable = "sse2")] - //~^ ERROR cannot be applied to safe trait method - fn foo(&self) {} - - #[target_feature(enable = "sse2")] - unsafe fn unsf_foo(&self) {} -} - -fn main() {} diff --git a/src/test/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr b/src/test/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr deleted file mode 100644 index 07d6e0900..000000000 --- a/src/test/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: `#[target_feature(..)]` cannot be applied to safe trait method - --> $DIR/trait-impl.rs:13:5 - | -LL | #[target_feature(enable = "sse2")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be applied to safe trait method -LL | -LL | fn foo(&self) {} - | ------------- not an `unsafe` function - -error: aborting due to previous error - diff --git a/src/test/ui/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof.rs b/src/test/ui/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof.rs deleted file mode 100644 index 6d7bca4da..000000000 --- a/src/test/ui/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof.rs +++ /dev/null @@ -1,15 +0,0 @@ -// run-pass -#![allow(dead_code)] -#![allow(unused_variables)] -// Test that removed keywords are allowed as identifiers. -fn main () { - let offsetof = (); - let alignof = (); - let sizeof = (); - let pure = (); -} - -fn offsetof() {} -fn alignof() {} -fn sizeof() {} -fn pure() {} diff --git a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/coerce-in-base-expr.rs b/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/coerce-in-base-expr.rs deleted file mode 100644 index 75e48bf4a..000000000 --- a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/coerce-in-base-expr.rs +++ /dev/null @@ -1,28 +0,0 @@ -// check-pass - -#![feature(type_changing_struct_update)] -#![allow(incomplete_features)] - -use std::any::Any; - -struct Foo { - a: A, - b: Box, - c: Box, -} - -struct B; -struct C; - -fn main() { - let y = Foo:: { - a: 0, - b: Box::new(B), - ..Foo { - a: 0, - b: Box::new(B), - // C needs to be told to coerce to `Box` - c: Box::new(C), - } - }; -} diff --git a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/feature-gate.rs b/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/feature-gate.rs deleted file mode 100644 index 1e8b99ba5..000000000 --- a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/feature-gate.rs +++ /dev/null @@ -1,29 +0,0 @@ -// gate-test-type_changing_struct_update - -#[derive(Debug)] -struct Machine { - state: S, - common_field1: &'static str, - common_field2: i32, -} -#[derive(Debug)] -struct State1; -#[derive(Debug, PartialEq)] -struct State2; - -fn update_to_state2() { - let m1: Machine = Machine { - state: State1, - common_field1: "hello", - common_field2: 2, - }; - let m2: Machine = Machine { - state: State2, - ..m1 - //~^ ERROR type changing struct updating is experimental [E0658] - //~| ERROR mismatched types [E0308] - }; - assert_eq!(State2, m2.state); -} - -fn main() {} diff --git a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/feature-gate.stderr b/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/feature-gate.stderr deleted file mode 100644 index 2217b8c04..000000000 --- a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/feature-gate.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0658]: type changing struct updating is experimental - --> $DIR/feature-gate.rs:22:11 - | -LL | ..m1 - | ^^ - | - = note: see issue #86555 for more information - = help: add `#![feature(type_changing_struct_update)]` to the crate attributes to enable - -error[E0308]: mismatched types - --> $DIR/feature-gate.rs:22:11 - | -LL | ..m1 - | ^^ expected struct `State2`, found struct `State1` - | - = note: expected struct `Machine` - found struct `Machine` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0308, E0658. -For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/issue-92010-trait-bound-not-satisfied.rs b/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/issue-92010-trait-bound-not-satisfied.rs deleted file mode 100644 index f1a54ee58..000000000 --- a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/issue-92010-trait-bound-not-satisfied.rs +++ /dev/null @@ -1,12 +0,0 @@ -#[derive(Clone)] -struct P { - x: T, - y: f64, -} - -impl P { - fn y(&self, y: f64) -> Self { P{y, .. self.clone() } } - //~^ mismatched types [E0308] -} - -fn main() {} diff --git a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/issue-92010-trait-bound-not-satisfied.stderr b/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/issue-92010-trait-bound-not-satisfied.stderr deleted file mode 100644 index 5957ea7c9..000000000 --- a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/issue-92010-trait-bound-not-satisfied.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-92010-trait-bound-not-satisfied.rs:8:43 - | -LL | fn y(&self, y: f64) -> Self { P{y, .. self.clone() } } - | ^^^^^^^^^^^^ expected struct `P`, found `&P` - | - = note: expected struct `P` - found reference `&P` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/issue-96878.rs b/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/issue-96878.rs deleted file mode 100644 index 3dfbef0ee..000000000 --- a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/issue-96878.rs +++ /dev/null @@ -1,31 +0,0 @@ -// check-pass - -#![feature(type_changing_struct_update)] -#![allow(incomplete_features)] - -use std::borrow::Cow; -use std::marker::PhantomData; - -#[derive(Default)] -struct NonGeneric { - field1: usize, -} - -#[derive(Default)] -struct Generic { - field1: T, - field2: U, -} - -#[derive(Default)] -struct MoreGeneric<'a, const N: usize> { - // If only `for [u32; N]: Default`... - field1: PhantomData<[u32; N]>, - field2: Cow<'a, str>, -} - -fn main() { - let default1 = NonGeneric { ..Default::default() }; - let default2: Generic = Generic { ..Default::default() }; - let default3: MoreGeneric<'static, 12> = MoreGeneric { ..Default::default() }; -} diff --git a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/lifetime-update.rs b/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/lifetime-update.rs deleted file mode 100644 index df2fef55d..000000000 --- a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/lifetime-update.rs +++ /dev/null @@ -1,43 +0,0 @@ -#![feature(type_changing_struct_update)] -#![allow(incomplete_features)] - -#[derive(Clone)] -struct Machine<'a, S> { - state: S, - lt_str: &'a str, - common_field: i32, -} - -#[derive(Clone)] -struct State1; -#[derive(Clone)] -struct State2; - -fn update_to_state2() { - let s = String::from("hello"); - let m1: Machine = Machine { - state: State1, - lt_str: &s, - //~^ ERROR `s` does not live long enough [E0597] - // FIXME: The error here actually comes from line 34. The - // span of the error message should be corrected to line 34 - common_field: 2, - }; - // update lifetime - let m3: Machine<'static, State1> = Machine { - lt_str: "hello, too", - ..m1.clone() - }; - // update lifetime and type - let m4: Machine<'static, State2> = Machine { - state: State2, - lt_str: "hello, again", - ..m1.clone() - }; - // updating to `static should fail. - let m2: Machine<'static, State1> = Machine { - ..m1 - }; -} - -fn main() {} diff --git a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/lifetime-update.stderr b/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/lifetime-update.stderr deleted file mode 100644 index 5f93ad6e0..000000000 --- a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/lifetime-update.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `s` does not live long enough - --> $DIR/lifetime-update.rs:20:17 - | -LL | lt_str: &s, - | ^^ borrowed value does not live long enough -... -LL | let m2: Machine<'static, State1> = Machine { - | ------------------------ type annotation requires that `s` is borrowed for `'static` -... -LL | } - | - `s` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/type-generic-update.rs b/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/type-generic-update.rs deleted file mode 100644 index dae1241d3..000000000 --- a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/type-generic-update.rs +++ /dev/null @@ -1,56 +0,0 @@ -#![feature(type_changing_struct_update)] -#![allow(incomplete_features)] - -struct Machine<'a, S, M> { - state: S, - message: M, - lt_str: &'a str, - common_field: i32, -} - -struct State1; -struct State2; - -struct Message1; -struct Message2; - -fn update() { - let m1: Machine = Machine { - state: State1, - message: Message1, - lt_str: "hello", - common_field: 2, - }; - // single type update - let m2: Machine = Machine { - state: State2, - ..m1 - }; - // multiple type update - let m3: Machine = Machine { - state: State2, - message: Message2, - ..m1 - }; -} - -fn fail_update() { - let m1: Machine = Machine { - state: 3.2, - message: 6.4, - lt_str: "hello", - common_field: 2, - }; - // single type update fail - let m2: Machine = Machine { - ..m1 - //~^ ERROR mismatched types [E0308] - }; - // multiple type update fail - let m3 = Machine:: { - ..m1 - //~^ ERROR mismatched types [E0308] - }; -} - -fn main() {} diff --git a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/type-generic-update.stderr b/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/type-generic-update.stderr deleted file mode 100644 index 6f31b1a96..000000000 --- a/src/test/ui/rfcs/rfc-2528-type-changing-struct-update/type-generic-update.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/type-generic-update.rs:46:11 - | -LL | ..m1 - | ^^ expected `i32`, found `f64` - | - = note: expected struct `Machine<'_, i32, _>` - found struct `Machine<'_, f64, _>` - -error[E0308]: mismatched types - --> $DIR/type-generic-update.rs:51:11 - | -LL | ..m1 - | ^^ expected `i32`, found `f64` - | - = note: expected struct `Machine<'_, i32, i32>` - found struct `Machine<'_, f64, f64>` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs b/src/test/ui/rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs deleted file mode 100644 index 17174e22c..000000000 --- a/src/test/ui/rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs +++ /dev/null @@ -1,23 +0,0 @@ -// run-pass -#![allow(dead_code)] - -macro_rules! foo { - (#[$attr:meta] $x:ident) => { - #[$attr] - struct $x { - x: u32 - } - } -} - -foo! { #[derive(PartialEq, Eq)] Foo } - -const FOO: Foo = Foo { x: 0 }; - -fn main() { - let y = Foo { x: 1 }; - match y { - FOO => { } - _ => { } - } -} diff --git a/src/test/ui/rfcs/rfc1445/eq-allows-match.rs b/src/test/ui/rfcs/rfc1445/eq-allows-match.rs deleted file mode 100644 index 405a69c94..000000000 --- a/src/test/ui/rfcs/rfc1445/eq-allows-match.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass -#![allow(dead_code)] - -#[derive(PartialEq, Eq)] -struct Foo { - x: u32 -} - -const FOO: Foo = Foo { x: 0 }; - -fn main() { - let y = Foo { x: 1 }; - match y { - FOO => { } - _ => { } - } -} diff --git a/src/test/ui/rfcs/rfc1623-2.rs b/src/test/ui/rfcs/rfc1623-2.rs deleted file mode 100644 index c0e13a5f5..000000000 --- a/src/test/ui/rfcs/rfc1623-2.rs +++ /dev/null @@ -1,99 +0,0 @@ -#![allow(dead_code)] - -fn non_elidable<'a, 'b>(a: &'a u8, b: &'b u8) -> &'a u8 { - a -} - -// The incorrect case without `for<'a>` is tested for in `rfc1623-2.rs` -static NON_ELIDABLE_FN: &for<'a> fn(&'a u8, &'a u8) -> &'a u8 = - &(non_elidable as for<'a> fn(&'a u8, &'a u8) -> &'a u8); - -struct SomeStruct<'x, 'y, 'z: 'x> { - foo: &'x Foo<'z>, - bar: &'x Bar<'z>, - f: &'y dyn for<'a, 'b> Fn(&'a Foo<'b>) -> &'a Foo<'b>, -} - -// Without this, the wf-check will fail early so we'll never see the -// error in SOME_STRUCT's body. -unsafe impl<'x, 'y, 'z: 'x> Sync for SomeStruct<'x, 'y, 'z> {} - -fn id(t: T) -> T { - t -} - -static SOME_STRUCT: &SomeStruct = &SomeStruct { - foo: &Foo { bools: &[false, true] }, - bar: &Bar { bools: &[true, true] }, - f: &id, - //~^ ERROR mismatched types - //~| ERROR mismatched types - //~| ERROR implementation of `FnOnce` is not general enough - //~| ERROR implementation of `FnOnce` is not general enough -}; - -// very simple test for a 'static static with default lifetime -static STATIC_STR: &'static str = "&'static str"; -const CONST_STR: &'static str = "&'static str"; - -// this should be the same as without default: -static EXPLICIT_STATIC_STR: &'static str = "&'static str"; -const EXPLICIT_CONST_STR: &'static str = "&'static str"; - -// a function that elides to an unbound lifetime for both in- and output -fn id_u8_slice(arg: &[u8]) -> &[u8] { - arg -} - -// one with a function, argument elided -static STATIC_SIMPLE_FN: &'static fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); -const CONST_SIMPLE_FN: &'static fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); - -// this should be the same as without elision -static STATIC_NON_ELIDED_fN: &'static for<'a> fn(&'a [u8]) -> &'a [u8] = - &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); -const CONST_NON_ELIDED_fN: &'static for<'a> fn(&'a [u8]) -> &'a [u8] = - &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); - -// another function that elides, each to a different unbound lifetime -fn multi_args(a: &u8, b: &u8, c: &u8) {} - -static STATIC_MULTI_FN: &'static fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); -const CONST_MULTI_FN: &'static fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); - -struct Foo<'a> { - bools: &'a [bool], -} - -static STATIC_FOO: Foo<'static> = Foo { bools: &[true, false] }; -const CONST_FOO: Foo<'static> = Foo { bools: &[true, false] }; - -type Bar<'a> = Foo<'a>; - -static STATIC_BAR: Bar<'static> = Bar { bools: &[true, false] }; -const CONST_BAR: Bar<'static> = Bar { bools: &[true, false] }; - -type Baz<'a> = fn(&'a [u8]) -> Option; - -fn baz(e: &[u8]) -> Option { - e.first().map(|x| *x) -} - -static STATIC_BAZ: &'static Baz<'static> = &(baz as Baz); -const CONST_BAZ: &'static Baz<'static> = &(baz as Baz); - -static BYTES: &'static [u8] = &[1, 2, 3]; - -fn main() { - let x = &[1u8, 2, 3]; - let y = x; - - // this works, so lifetime < `'static` is valid - assert_eq!(Some(1), STATIC_BAZ(y)); - assert_eq!(Some(1), CONST_BAZ(y)); - - let y = &[1u8, 2, 3]; - - STATIC_BAZ(BYTES); // BYTES has static lifetime - CONST_BAZ(y); // interestingly this does not get reported -} diff --git a/src/test/ui/rfcs/rfc1623-2.stderr b/src/test/ui/rfcs/rfc1623-2.stderr deleted file mode 100644 index d183eaaa6..000000000 --- a/src/test/ui/rfcs/rfc1623-2.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/rfc1623-2.rs:28:8 - | -LL | f: &id, - | ^^^ one type is more general than the other - | - = note: expected trait `for<'a, 'b> Fn<(&'a Foo<'b>,)>` - found trait `Fn<(&Foo<'_>,)>` - -error[E0308]: mismatched types - --> $DIR/rfc1623-2.rs:28:8 - | -LL | f: &id, - | ^^^ one type is more general than the other - | - = note: expected trait `for<'a, 'b> Fn<(&'a Foo<'b>,)>` - found trait `Fn<(&Foo<'_>,)>` - -error: implementation of `FnOnce` is not general enough - --> $DIR/rfc1623-2.rs:28:8 - | -LL | f: &id, - | ^^^ implementation of `FnOnce` is not general enough - | - = note: `fn(&'2 Foo<'_>) -> &'2 Foo<'_> {id::<&'2 Foo<'_>>}` must implement `FnOnce<(&'1 Foo<'b>,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 Foo<'_>,)>`, for some specific lifetime `'2` - -error: implementation of `FnOnce` is not general enough - --> $DIR/rfc1623-2.rs:28:8 - | -LL | f: &id, - | ^^^ implementation of `FnOnce` is not general enough - | - = note: `fn(&Foo<'2>) -> &Foo<'2> {id::<&Foo<'2>>}` must implement `FnOnce<(&'a Foo<'1>,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&Foo<'2>,)>`, for some specific lifetime `'2` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/rfcs/rfc1623-3.rs b/src/test/ui/rfcs/rfc1623-3.rs deleted file mode 100644 index 26fa6fdb5..000000000 --- a/src/test/ui/rfcs/rfc1623-3.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![allow(dead_code)] - -fn non_elidable<'a, 'b>(a: &'a u8, b: &'b u8) -> &'a u8 { - a -} - -// the boundaries of elision -static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = -//~^ ERROR missing lifetime specifier [E0106] - &(non_elidable as fn(&u8, &u8) -> &u8); - //~^ ERROR missing lifetime specifier [E0106] - //~| ERROR non-primitive cast - -fn main() {} diff --git a/src/test/ui/rfcs/rfc1623-3.stderr b/src/test/ui/rfcs/rfc1623-3.stderr deleted file mode 100644 index 77fc3f041..000000000 --- a/src/test/ui/rfcs/rfc1623-3.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/rfc1623-3.rs:8:42 - | -LL | static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = - | --- --- ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 - = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html -help: consider making the type lifetime-generic with a new `'a` lifetime - | -LL | static NON_ELIDABLE_FN: &for<'a> fn(&'a u8, &'a u8) -> &'a u8 = - | +++++++ ++ ++ ++ - -error[E0106]: missing lifetime specifier - --> $DIR/rfc1623-3.rs:10:39 - | -LL | &(non_elidable as fn(&u8, &u8) -> &u8); - | --- --- ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 -help: consider making the type lifetime-generic with a new `'a` lifetime - | -LL | &(non_elidable as for<'a> fn(&'a u8, &'a u8) -> &'a u8); - | +++++++ ++ ++ ++ - -error[E0605]: non-primitive cast: `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8 {non_elidable}` as `for<'a, 'b> fn(&'a u8, &'b u8) -> &u8` - --> $DIR/rfc1623-3.rs:10:6 - | -LL | &(non_elidable as fn(&u8, &u8) -> &u8); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid cast - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0106, E0605. -For more information about an error, try `rustc --explain E0106`. diff --git a/src/test/ui/rfcs/rfc1623.rs b/src/test/ui/rfcs/rfc1623.rs deleted file mode 100644 index adaf25c6b..000000000 --- a/src/test/ui/rfcs/rfc1623.rs +++ /dev/null @@ -1,75 +0,0 @@ -// run-pass -#![allow(unused_variables)] -#![allow(non_upper_case_globals)] - -#![allow(dead_code)] - -// very simple test for a 'static static with default lifetime -static STATIC_STR: &str = "&'static str"; -const CONST_STR: &str = "&'static str"; - -// this should be the same as without default: -static EXPLICIT_STATIC_STR: &'static str = "&'static str"; -const EXPLICIT_CONST_STR: &'static str = "&'static str"; - -// a function that elides to an unbound lifetime for both in- and output -fn id_u8_slice(arg: &[u8]) -> &[u8] { - arg -} - -// one with a function, argument elided -static STATIC_SIMPLE_FN: &fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); -const CONST_SIMPLE_FN: &fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); - -// this should be the same as without elision -static STATIC_NON_ELIDED_fN: &for<'a> fn(&'a [u8]) -> &'a [u8] = - &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); -const CONST_NON_ELIDED_fN: &for<'a> fn(&'a [u8]) -> &'a [u8] = - &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); - -// another function that elides, each to a different unbound lifetime -fn multi_args(a: &u8, b: &u8, c: &u8) {} - -static STATIC_MULTI_FN: &fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); -const CONST_MULTI_FN: &fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); - -struct Foo<'a> { - bools: &'a [bool], -} - -static STATIC_FOO: Foo = Foo { bools: &[true, false] }; -const CONST_FOO: Foo = Foo { bools: &[true, false] }; - -type Bar<'a> = Foo<'a>; - -static STATIC_BAR: Bar = Bar { bools: &[true, false] }; -const CONST_BAR: Bar = Bar { bools: &[true, false] }; - -type Baz<'a> = fn(&'a [u8]) -> Option; - -fn baz(e: &[u8]) -> Option { - e.first().map(|x| *x) -} - -static STATIC_BAZ: &Baz = &(baz as Baz); -const CONST_BAZ: &Baz = &(baz as Baz); - -static BYTES: &[u8] = &[1, 2, 3]; - -fn main() { - // make sure that the lifetime is actually elided (and not defaulted) - let x = &[1u8, 2, 3]; - STATIC_SIMPLE_FN(x); - CONST_SIMPLE_FN(x); - - STATIC_BAZ(BYTES); // neees static lifetime - CONST_BAZ(BYTES); - - // make sure this works with different lifetimes - let a = &1; - { - let b = &2; - let c = &3; - CONST_MULTI_FN(a, b, c); - } -} diff --git a/src/test/ui/rfcs/rfc1717/library-override.rs b/src/test/ui/rfcs/rfc1717/library-override.rs deleted file mode 100644 index 014ccac31..000000000 --- a/src/test/ui/rfcs/rfc1717/library-override.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-pass -// ignore-wasm32-bare no libc to test ffi with -// compile-flags: -lstatic=wronglibrary:rust_test_helpers - -#[link(name = "wronglibrary", kind = "dylib")] -extern "C" { - pub fn rust_dbg_extern_identity_u32(x: u32) -> u32; -} - -fn main() { - unsafe { - rust_dbg_extern_identity_u32(42); - } -} diff --git a/src/test/ui/rfcs/rfc1857-drop-order.rs b/src/test/ui/rfcs/rfc1857-drop-order.rs deleted file mode 100644 index 4c4816c2f..000000000 --- a/src/test/ui/rfcs/rfc1857-drop-order.rs +++ /dev/null @@ -1,224 +0,0 @@ -// run-pass -// needs-unwind - -#![allow(dead_code, unreachable_code)] - -use std::cell::RefCell; -use std::rc::Rc; -use std::panic::{self, AssertUnwindSafe, UnwindSafe}; - -// This struct is used to record the order in which elements are dropped -struct PushOnDrop { - vec: Rc>>, - val: u32 -} - -impl PushOnDrop { - fn new(val: u32, vec: Rc>>) -> PushOnDrop { - PushOnDrop { vec, val } - } -} - -impl Drop for PushOnDrop { - fn drop(&mut self) { - self.vec.borrow_mut().push(self.val) - } -} - -impl UnwindSafe for PushOnDrop { } - -// Structs -struct TestStruct { - x: PushOnDrop, - y: PushOnDrop, - z: PushOnDrop -} - -// Tuple structs -struct TestTupleStruct(PushOnDrop, PushOnDrop, PushOnDrop); - -// Enum variants -enum TestEnum { - Tuple(PushOnDrop, PushOnDrop, PushOnDrop), - Struct { x: PushOnDrop, y: PushOnDrop, z: PushOnDrop } -} - -fn test_drop_tuple() { - // Tuple fields are dropped in the same order they are declared - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let test_tuple = (PushOnDrop::new(1, dropped_fields.clone()), - PushOnDrop::new(2, dropped_fields.clone())); - drop(test_tuple); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // Panic during construction means that fields are treated as local variables - // Therefore they are dropped in reverse order of initialization - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - (PushOnDrop::new(2, cloned.clone()), - PushOnDrop::new(1, cloned.clone()), - panic!("this panic is caught :D")); - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); -} - -fn test_drop_struct() { - // Struct fields are dropped in the same order they are declared - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let test_struct = TestStruct { - x: PushOnDrop::new(1, dropped_fields.clone()), - y: PushOnDrop::new(2, dropped_fields.clone()), - z: PushOnDrop::new(3, dropped_fields.clone()), - }; - drop(test_struct); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // The same holds for tuple structs - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let test_tuple_struct = TestTupleStruct(PushOnDrop::new(1, dropped_fields.clone()), - PushOnDrop::new(2, dropped_fields.clone()), - PushOnDrop::new(3, dropped_fields.clone())); - drop(test_tuple_struct); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // Panic during struct construction means that fields are treated as local variables - // Therefore they are dropped in reverse order of initialization - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestStruct { - x: PushOnDrop::new(2, cloned.clone()), - y: PushOnDrop::new(1, cloned.clone()), - z: panic!("this panic is caught :D") - }; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // Test with different initialization order - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestStruct { - y: PushOnDrop::new(2, cloned.clone()), - x: PushOnDrop::new(1, cloned.clone()), - z: panic!("this panic is caught :D") - }; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // The same holds for tuple structs - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestTupleStruct(PushOnDrop::new(2, cloned.clone()), - PushOnDrop::new(1, cloned.clone()), - panic!("this panic is caught :D")); - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); -} - -fn test_drop_enum() { - // Enum variants are dropped in the same order they are declared - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let test_struct_enum = TestEnum::Struct { - x: PushOnDrop::new(1, dropped_fields.clone()), - y: PushOnDrop::new(2, dropped_fields.clone()), - z: PushOnDrop::new(3, dropped_fields.clone()) - }; - drop(test_struct_enum); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // The same holds for tuple enum variants - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let test_tuple_enum = TestEnum::Tuple(PushOnDrop::new(1, dropped_fields.clone()), - PushOnDrop::new(2, dropped_fields.clone()), - PushOnDrop::new(3, dropped_fields.clone())); - drop(test_tuple_enum); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // Panic during enum construction means that fields are treated as local variables - // Therefore they are dropped in reverse order of initialization - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestEnum::Struct { - x: PushOnDrop::new(2, cloned.clone()), - y: PushOnDrop::new(1, cloned.clone()), - z: panic!("this panic is caught :D") - }; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // Test with different initialization order - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestEnum::Struct { - y: PushOnDrop::new(2, cloned.clone()), - x: PushOnDrop::new(1, cloned.clone()), - z: panic!("this panic is caught :D") - }; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // The same holds for tuple enum variants - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestEnum::Tuple(PushOnDrop::new(2, cloned.clone()), - PushOnDrop::new(1, cloned.clone()), - panic!("this panic is caught :D")); - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); -} - -fn test_drop_list() { - // Elements in a Vec are dropped in the same order they are pushed - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let xs = vec![PushOnDrop::new(1, dropped_fields.clone()), - PushOnDrop::new(2, dropped_fields.clone()), - PushOnDrop::new(3, dropped_fields.clone())]; - drop(xs); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // The same holds for arrays - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let xs = [PushOnDrop::new(1, dropped_fields.clone()), - PushOnDrop::new(2, dropped_fields.clone()), - PushOnDrop::new(3, dropped_fields.clone())]; - drop(xs); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // Panic during vec construction means that fields are treated as local variables - // Therefore they are dropped in reverse order of initialization - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - vec![ - PushOnDrop::new(2, cloned.clone()), - PushOnDrop::new(1, cloned.clone()), - panic!("this panic is caught :D") - ]; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // The same holds for arrays - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - [ - PushOnDrop::new(2, cloned.clone()), - PushOnDrop::new(1, cloned.clone()), - panic!("this panic is caught :D") - ]; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); -} - -fn main() { - test_drop_tuple(); - test_drop_struct(); - test_drop_enum(); - test_drop_list(); -} -- cgit v1.2.3