From 2ffb0de8cfda57cafdfd71a690f14c2e17216d85 Mon Sep 17 00:00:00 2001 From: jyn Date: Sun, 2 Apr 2023 18:09:11 -0400 Subject: Move most ui-fulldeps tests to ui They pass fine. Only tests that required `extern crate rustc_*` or were marked `ignore-stage1` have been keep in fulldeps. --- src/tools/tidy/src/ui_tests.rs | 2 +- tests/ui-fulldeps/auxiliary/issue-13560-1.rs | 3 - tests/ui-fulldeps/auxiliary/issue-13560-2.rs | 3 - tests/ui-fulldeps/auxiliary/issue-13560-3.rs | 6 -- tests/ui-fulldeps/auxiliary/issue-16822.rs | 20 ----- tests/ui-fulldeps/auxiliary/issue-18502.rs | 21 ----- tests/ui-fulldeps/auxiliary/issue-24106.rs | 13 ---- tests/ui-fulldeps/extern-mod-syntax.rs | 11 --- .../internal-lints/diagnostics_incorrect.rs | 15 ---- .../internal-lints/diagnostics_incorrect.stderr | 17 ---- .../internal-lints/existing_doc_keyword.rs | 11 --- .../internal-lints/existing_doc_keyword.stderr | 15 ---- .../internal-lints/query_stability_incorrect.rs | 15 ---- .../query_stability_incorrect.stderr | 17 ---- .../internal-lints/rustc_pass_by_value_self.rs | 54 ------------- .../internal-lints/rustc_pass_by_value_self.stderr | 38 --------- tests/ui-fulldeps/issue-11881.rs | 91 ---------------------- tests/ui-fulldeps/issue-13560.rs | 12 --- tests/ui-fulldeps/issue-15924.rs | 53 ------------- tests/ui-fulldeps/issue-16822.rs | 22 ------ tests/ui-fulldeps/issue-18502.rs | 8 -- tests/ui-fulldeps/issue-24106.rs | 8 -- tests/ui-fulldeps/issue-2804.rs | 81 ------------------- tests/ui-fulldeps/myriad-closures.rs | 39 ---------- tests/ui-fulldeps/std/issue-15149.rs | 57 -------------- .../std/issue-81357-unsound-file-methods.rs | 81 ------------------- tests/ui-fulldeps/std/stdio-from.rs | 69 ---------------- tests/ui-fulldeps/std/switch-stdout.rs | 51 ------------ tests/ui/auxiliary/issue-13560-1.rs | 3 + tests/ui/auxiliary/issue-13560-2.rs | 3 + tests/ui/auxiliary/issue-13560-3.rs | 6 ++ tests/ui/auxiliary/issue-16822.rs | 20 +++++ tests/ui/auxiliary/issue-18502.rs | 21 +++++ tests/ui/auxiliary/issue-24106.rs | 13 ++++ tests/ui/extern-mod-syntax.rs | 11 +++ tests/ui/internal-lints/diagnostics_incorrect.rs | 15 ++++ .../ui/internal-lints/diagnostics_incorrect.stderr | 17 ++++ tests/ui/internal-lints/existing_doc_keyword.rs | 11 +++ .../ui/internal-lints/existing_doc_keyword.stderr | 15 ++++ .../ui/internal-lints/query_stability_incorrect.rs | 15 ++++ .../query_stability_incorrect.stderr | 17 ++++ .../ui/internal-lints/rustc_pass_by_value_self.rs | 54 +++++++++++++ .../internal-lints/rustc_pass_by_value_self.stderr | 38 +++++++++ tests/ui/issue-11881.rs | 91 ++++++++++++++++++++++ tests/ui/issue-13560.rs | 12 +++ tests/ui/issue-15924.rs | 53 +++++++++++++ tests/ui/issue-16822.rs | 22 ++++++ tests/ui/issue-18502.rs | 8 ++ tests/ui/issue-24106.rs | 8 ++ tests/ui/issue-2804.rs | 81 +++++++++++++++++++ tests/ui/myriad-closures.rs | 39 ++++++++++ tests/ui/std/issue-15149.rs | 57 ++++++++++++++ tests/ui/std/issue-81357-unsound-file-methods.rs | 81 +++++++++++++++++++ tests/ui/std/stdio-from.rs | 69 ++++++++++++++++ tests/ui/std/switch-stdout.rs | 51 ++++++++++++ 55 files changed, 832 insertions(+), 832 deletions(-) delete mode 100644 tests/ui-fulldeps/auxiliary/issue-13560-1.rs delete mode 100644 tests/ui-fulldeps/auxiliary/issue-13560-2.rs delete mode 100644 tests/ui-fulldeps/auxiliary/issue-13560-3.rs delete mode 100644 tests/ui-fulldeps/auxiliary/issue-16822.rs delete mode 100644 tests/ui-fulldeps/auxiliary/issue-18502.rs delete mode 100644 tests/ui-fulldeps/auxiliary/issue-24106.rs delete mode 100644 tests/ui-fulldeps/extern-mod-syntax.rs delete mode 100644 tests/ui-fulldeps/internal-lints/diagnostics_incorrect.rs delete mode 100644 tests/ui-fulldeps/internal-lints/diagnostics_incorrect.stderr delete mode 100644 tests/ui-fulldeps/internal-lints/existing_doc_keyword.rs delete mode 100644 tests/ui-fulldeps/internal-lints/existing_doc_keyword.stderr delete mode 100644 tests/ui-fulldeps/internal-lints/query_stability_incorrect.rs delete mode 100644 tests/ui-fulldeps/internal-lints/query_stability_incorrect.stderr delete mode 100644 tests/ui-fulldeps/internal-lints/rustc_pass_by_value_self.rs delete mode 100644 tests/ui-fulldeps/internal-lints/rustc_pass_by_value_self.stderr delete mode 100644 tests/ui-fulldeps/issue-11881.rs delete mode 100644 tests/ui-fulldeps/issue-13560.rs delete mode 100644 tests/ui-fulldeps/issue-15924.rs delete mode 100644 tests/ui-fulldeps/issue-16822.rs delete mode 100644 tests/ui-fulldeps/issue-18502.rs delete mode 100644 tests/ui-fulldeps/issue-24106.rs delete mode 100644 tests/ui-fulldeps/issue-2804.rs delete mode 100644 tests/ui-fulldeps/myriad-closures.rs delete mode 100644 tests/ui-fulldeps/std/issue-15149.rs delete mode 100644 tests/ui-fulldeps/std/issue-81357-unsound-file-methods.rs delete mode 100644 tests/ui-fulldeps/std/stdio-from.rs delete mode 100644 tests/ui-fulldeps/std/switch-stdout.rs create mode 100644 tests/ui/auxiliary/issue-13560-1.rs create mode 100644 tests/ui/auxiliary/issue-13560-2.rs create mode 100644 tests/ui/auxiliary/issue-13560-3.rs create mode 100644 tests/ui/auxiliary/issue-16822.rs create mode 100644 tests/ui/auxiliary/issue-18502.rs create mode 100644 tests/ui/auxiliary/issue-24106.rs create mode 100644 tests/ui/extern-mod-syntax.rs create mode 100644 tests/ui/internal-lints/diagnostics_incorrect.rs create mode 100644 tests/ui/internal-lints/diagnostics_incorrect.stderr create mode 100644 tests/ui/internal-lints/existing_doc_keyword.rs create mode 100644 tests/ui/internal-lints/existing_doc_keyword.stderr create mode 100644 tests/ui/internal-lints/query_stability_incorrect.rs create mode 100644 tests/ui/internal-lints/query_stability_incorrect.stderr create mode 100644 tests/ui/internal-lints/rustc_pass_by_value_self.rs create mode 100644 tests/ui/internal-lints/rustc_pass_by_value_self.stderr create mode 100644 tests/ui/issue-11881.rs create mode 100644 tests/ui/issue-13560.rs create mode 100644 tests/ui/issue-15924.rs create mode 100644 tests/ui/issue-16822.rs create mode 100644 tests/ui/issue-18502.rs create mode 100644 tests/ui/issue-24106.rs create mode 100644 tests/ui/issue-2804.rs create mode 100644 tests/ui/myriad-closures.rs create mode 100644 tests/ui/std/issue-15149.rs create mode 100644 tests/ui/std/issue-81357-unsound-file-methods.rs create mode 100644 tests/ui/std/stdio-from.rs create mode 100644 tests/ui/std/switch-stdout.rs diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 7b7ee62a247..3d7f9828a7e 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -9,7 +9,7 @@ use std::path::{Path, PathBuf}; // FIXME: The following limits should be reduced eventually. const ENTRY_LIMIT: usize = 885; -const ROOT_ENTRY_LIMIT: usize = 880; +const ROOT_ENTRY_LIMIT: usize = 891; const ISSUES_ENTRY_LIMIT: usize = 1978; fn check_entries(tests_path: &Path, bad: &mut bool) { diff --git a/tests/ui-fulldeps/auxiliary/issue-13560-1.rs b/tests/ui-fulldeps/auxiliary/issue-13560-1.rs deleted file mode 100644 index c3a2ae679bf..00000000000 --- a/tests/ui-fulldeps/auxiliary/issue-13560-1.rs +++ /dev/null @@ -1,3 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "dylib"] diff --git a/tests/ui-fulldeps/auxiliary/issue-13560-2.rs b/tests/ui-fulldeps/auxiliary/issue-13560-2.rs deleted file mode 100644 index 39c261e1162..00000000000 --- a/tests/ui-fulldeps/auxiliary/issue-13560-2.rs +++ /dev/null @@ -1,3 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "rlib"] diff --git a/tests/ui-fulldeps/auxiliary/issue-13560-3.rs b/tests/ui-fulldeps/auxiliary/issue-13560-3.rs deleted file mode 100644 index e991bcc1a02..00000000000 --- a/tests/ui-fulldeps/auxiliary/issue-13560-3.rs +++ /dev/null @@ -1,6 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "rlib"] - -#[macro_use] #[no_link] extern crate issue_13560_1 as t1; -#[macro_use] extern crate issue_13560_2 as t2; diff --git a/tests/ui-fulldeps/auxiliary/issue-16822.rs b/tests/ui-fulldeps/auxiliary/issue-16822.rs deleted file mode 100644 index 9042dd39117..00000000000 --- a/tests/ui-fulldeps/auxiliary/issue-16822.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![crate_type="lib"] - -use std::cell::RefCell; - -pub struct Window{ - pub data: RefCell -} - -impl Window { - pub fn update(&self, e: i32) { - match e { - 1 => self.data.borrow_mut().update(), - _ => {} - } - } -} - -pub trait Update { - fn update(&mut self); -} diff --git a/tests/ui-fulldeps/auxiliary/issue-18502.rs b/tests/ui-fulldeps/auxiliary/issue-18502.rs deleted file mode 100644 index 4d4230607aa..00000000000 --- a/tests/ui-fulldeps/auxiliary/issue-18502.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![crate_type="lib"] - -struct Foo; -// This is the ICE trigger -struct Formatter; - -trait Show { - fn fmt(&self); -} - -impl Show for Foo { - fn fmt(&self) {} -} - -fn bar(f: extern "Rust" fn(&T), t: &T) { } - -// ICE requirement: this has to be marked as inline -#[inline] -pub fn baz() { - bar(Show::fmt, &Foo); -} diff --git a/tests/ui-fulldeps/auxiliary/issue-24106.rs b/tests/ui-fulldeps/auxiliary/issue-24106.rs deleted file mode 100644 index 2c6a6034806..00000000000 --- a/tests/ui-fulldeps/auxiliary/issue-24106.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![crate_type="lib"] - -enum E { E0 = 0, E1 = 1 } -const E0_U8: u8 = E::E0 as u8; -const E1_U8: u8 = E::E1 as u8; - -pub fn go() { - match 0 { - E0_U8 => (), - E1_U8 => (), - _ => (), - } -} diff --git a/tests/ui-fulldeps/extern-mod-syntax.rs b/tests/ui-fulldeps/extern-mod-syntax.rs deleted file mode 100644 index 230194c5377..00000000000 --- a/tests/ui-fulldeps/extern-mod-syntax.rs +++ /dev/null @@ -1,11 +0,0 @@ -// run-pass - -#![allow(unused_imports)] -#![feature(rustc_private)] - -extern crate libc; -use libc::c_void; - -pub fn main() { - println!("Hello world!"); -} diff --git a/tests/ui-fulldeps/internal-lints/diagnostics_incorrect.rs b/tests/ui-fulldeps/internal-lints/diagnostics_incorrect.rs deleted file mode 100644 index 99f99ffcd35..00000000000 --- a/tests/ui-fulldeps/internal-lints/diagnostics_incorrect.rs +++ /dev/null @@ -1,15 +0,0 @@ -// compile-flags: -Z unstable-options - -#![feature(rustc_attrs)] - -#[rustc_lint_diagnostics] -//~^ ERROR attribute should be applied to a function -struct Foo; - -impl Foo { - #[rustc_lint_diagnostics(a)] - //~^ ERROR malformed `rustc_lint_diagnostics` - fn bar() {} -} - -fn main() {} diff --git a/tests/ui-fulldeps/internal-lints/diagnostics_incorrect.stderr b/tests/ui-fulldeps/internal-lints/diagnostics_incorrect.stderr deleted file mode 100644 index e849ca2829e..00000000000 --- a/tests/ui-fulldeps/internal-lints/diagnostics_incorrect.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: malformed `rustc_lint_diagnostics` attribute input - --> $DIR/diagnostics_incorrect.rs:10:5 - | -LL | #[rustc_lint_diagnostics(a)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_lint_diagnostics]` - -error: attribute should be applied to a function definition - --> $DIR/diagnostics_incorrect.rs:5:1 - | -LL | #[rustc_lint_diagnostics] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | struct Foo; - | ----------- not a function definition - -error: aborting due to 2 previous errors - diff --git a/tests/ui-fulldeps/internal-lints/existing_doc_keyword.rs b/tests/ui-fulldeps/internal-lints/existing_doc_keyword.rs deleted file mode 100644 index 7783dc40fcf..00000000000 --- a/tests/ui-fulldeps/internal-lints/existing_doc_keyword.rs +++ /dev/null @@ -1,11 +0,0 @@ -// compile-flags: -Z unstable-options - -#![feature(rustc_private)] -#![feature(rustdoc_internals)] - -#![crate_type = "lib"] - -#![deny(rustc::existing_doc_keyword)] - -#[doc(keyword = "tadam")] //~ ERROR -mod tadam {} diff --git a/tests/ui-fulldeps/internal-lints/existing_doc_keyword.stderr b/tests/ui-fulldeps/internal-lints/existing_doc_keyword.stderr deleted file mode 100644 index 5110b9be08a..00000000000 --- a/tests/ui-fulldeps/internal-lints/existing_doc_keyword.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: found non-existing keyword `tadam` used in `#[doc(keyword = "...")]` - --> $DIR/existing_doc_keyword.rs:10:1 - | -LL | #[doc(keyword = "tadam")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: only existing keywords are allowed in core/std -note: the lint level is defined here - --> $DIR/existing_doc_keyword.rs:8:9 - | -LL | #![deny(rustc::existing_doc_keyword)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui-fulldeps/internal-lints/query_stability_incorrect.rs b/tests/ui-fulldeps/internal-lints/query_stability_incorrect.rs deleted file mode 100644 index f478b73329e..00000000000 --- a/tests/ui-fulldeps/internal-lints/query_stability_incorrect.rs +++ /dev/null @@ -1,15 +0,0 @@ -// compile-flags: -Z unstable-options - -#![feature(rustc_attrs)] - -#[rustc_lint_query_instability] -//~^ ERROR attribute should be applied to a function -struct Foo; - -impl Foo { - #[rustc_lint_query_instability(a)] - //~^ ERROR malformed `rustc_lint_query_instability` - fn bar() {} -} - -fn main() {} diff --git a/tests/ui-fulldeps/internal-lints/query_stability_incorrect.stderr b/tests/ui-fulldeps/internal-lints/query_stability_incorrect.stderr deleted file mode 100644 index 3f78b39edd9..00000000000 --- a/tests/ui-fulldeps/internal-lints/query_stability_incorrect.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: malformed `rustc_lint_query_instability` attribute input - --> $DIR/query_stability_incorrect.rs:10:5 - | -LL | #[rustc_lint_query_instability(a)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_lint_query_instability]` - -error: attribute should be applied to a function definition - --> $DIR/query_stability_incorrect.rs:5:1 - | -LL | #[rustc_lint_query_instability] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | struct Foo; - | ----------- not a function definition - -error: aborting due to 2 previous errors - diff --git a/tests/ui-fulldeps/internal-lints/rustc_pass_by_value_self.rs b/tests/ui-fulldeps/internal-lints/rustc_pass_by_value_self.rs deleted file mode 100644 index 6ce67dcaf1d..00000000000 --- a/tests/ui-fulldeps/internal-lints/rustc_pass_by_value_self.rs +++ /dev/null @@ -1,54 +0,0 @@ -// compile-flags: -Z unstable-options -// NOTE: This test doesn't actually require `fulldeps` -// so we could instead use it as a `ui` test. -// -// Considering that all other `internal-lints` are tested here -// this seems like the cleaner solution though. -#![feature(rustc_attrs)] -#![deny(rustc::pass_by_value)] -#![allow(unused)] - -#[rustc_pass_by_value] -struct TyCtxt<'tcx> { - inner: &'tcx (), -} - -impl<'tcx> TyCtxt<'tcx> { - fn by_value(self) {} // OK - fn by_ref(&self) {} //~ ERROR passing `TyCtxt<'tcx>` by reference -} - -struct TyS<'tcx> { - inner: &'tcx (), -} - -#[rustc_pass_by_value] -type Ty<'tcx> = &'tcx TyS<'tcx>; - -impl<'tcx> TyS<'tcx> { - fn by_value(self: Ty<'tcx>) {} - fn by_ref(self: &Ty<'tcx>) {} //~ ERROR passing `Ty<'tcx>` by reference -} - -#[rustc_pass_by_value] -struct Foo; - -impl Foo { - fn with_ref(&self) {} //~ ERROR passing `Foo` by reference -} - -#[rustc_pass_by_value] -struct WithParameters { - slice: [T; N], - m: M, -} - -impl WithParameters { - fn with_ref(&self) {} //~ ERROR passing `WithParameters` by reference -} - -impl WithParameters { - fn with_ref(&self) {} //~ ERROR passing `WithParameters` by reference -} - -fn main() {} diff --git a/tests/ui-fulldeps/internal-lints/rustc_pass_by_value_self.stderr b/tests/ui-fulldeps/internal-lints/rustc_pass_by_value_self.stderr deleted file mode 100644 index fb39ed60b82..00000000000 --- a/tests/ui-fulldeps/internal-lints/rustc_pass_by_value_self.stderr +++ /dev/null @@ -1,38 +0,0 @@ -error: passing `TyCtxt<'tcx>` by reference - --> $DIR/rustc_pass_by_value_self.rs:18:15 - | -LL | fn by_ref(&self) {} - | ^^^^^ help: try passing by value: `TyCtxt<'tcx>` - | -note: the lint level is defined here - --> $DIR/rustc_pass_by_value_self.rs:8:9 - | -LL | #![deny(rustc::pass_by_value)] - | ^^^^^^^^^^^^^^^^^^^^ - -error: passing `Ty<'tcx>` by reference - --> $DIR/rustc_pass_by_value_self.rs:30:21 - | -LL | fn by_ref(self: &Ty<'tcx>) {} - | ^^^^^^^^^ help: try passing by value: `Ty<'tcx>` - -error: passing `Foo` by reference - --> $DIR/rustc_pass_by_value_self.rs:37:17 - | -LL | fn with_ref(&self) {} - | ^^^^^ help: try passing by value: `Foo` - -error: passing `WithParameters` by reference - --> $DIR/rustc_pass_by_value_self.rs:47:17 - | -LL | fn with_ref(&self) {} - | ^^^^^ help: try passing by value: `WithParameters` - -error: passing `WithParameters` by reference - --> $DIR/rustc_pass_by_value_self.rs:51:17 - | -LL | fn with_ref(&self) {} - | ^^^^^ help: try passing by value: `WithParameters` - -error: aborting due to 5 previous errors - diff --git a/tests/ui-fulldeps/issue-11881.rs b/tests/ui-fulldeps/issue-11881.rs deleted file mode 100644 index f6360db9b5f..00000000000 --- a/tests/ui-fulldeps/issue-11881.rs +++ /dev/null @@ -1,91 +0,0 @@ -// run-pass - -#![allow(unused_must_use)] -#![allow(dead_code)] -#![allow(unused_imports)] - -use std::fmt; -use std::io::prelude::*; -use std::io::Cursor; -use std::slice; -use std::marker::PhantomData; - -trait Encoder { - type Error; -} - -trait Encodable { - fn encode(&self, s: &mut S) -> Result<(), S::Error>; -} - -struct JsonEncoder<'a>(PhantomData<&'a mut ()>); - -impl Encoder for JsonEncoder<'_> { - type Error = (); -} - -struct AsJson<'a, T> { - inner: &'a T, -} - -impl<'a, T: for<'r> Encodable>> fmt::Display for AsJson<'a, T> { - /// Encodes a json value into a string - fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - Ok(()) - } -} - -fn as_json(t: &T) -> AsJson<'_, T> { - AsJson { inner: t } -} - -struct OpaqueEncoder(Vec); - -impl Encoder for OpaqueEncoder { - type Error = (); -} - - -struct Foo { - baz: bool, -} - -impl Encodable for Foo { - fn encode(&self, _s: &mut S) -> Result<(), S::Error> { - Ok(()) - } -} - -struct Bar { - froboz: usize, -} - -impl Encodable for Bar { - fn encode(&self, _s: &mut S) -> Result<(), S::Error> { - Ok(()) - } -} - -enum WireProtocol { - JSON, - Opaque, - // ... -} - -fn encode_json Encodable>>(val: &T, wr: &mut Cursor>) { - write!(wr, "{}", as_json(val)); -} - -fn encode_opaque>(val: &T, wr: Vec) { - let mut encoder = OpaqueEncoder(wr); - val.encode(&mut encoder); -} - -pub fn main() { - let target = Foo { baz: false }; - let proto = WireProtocol::JSON; - match proto { - WireProtocol::JSON => encode_json(&target, &mut Cursor::new(Vec::new())), - WireProtocol::Opaque => encode_opaque(&target, Vec::new()), - } -} diff --git a/tests/ui-fulldeps/issue-13560.rs b/tests/ui-fulldeps/issue-13560.rs deleted file mode 100644 index 5f7d647e230..00000000000 --- a/tests/ui-fulldeps/issue-13560.rs +++ /dev/null @@ -1,12 +0,0 @@ -// run-pass -// aux-build:issue-13560-1.rs -// aux-build:issue-13560-2.rs -// aux-build:issue-13560-3.rs - -// Regression test for issue #13560, the test itself is all in the dependent -// libraries. The fail which previously failed to compile is the one numbered 3. - -extern crate issue_13560_2 as t2; -extern crate issue_13560_3 as t3; - -fn main() {} diff --git a/tests/ui-fulldeps/issue-15924.rs b/tests/ui-fulldeps/issue-15924.rs deleted file mode 100644 index d8b3914d0d4..00000000000 --- a/tests/ui-fulldeps/issue-15924.rs +++ /dev/null @@ -1,53 +0,0 @@ -// run-pass - -#![allow(unused_imports)] -#![allow(unused_must_use)] -// pretty-expanded FIXME #23616 - -use std::fmt; -use std::marker::PhantomData; - -trait Encoder { - type Error; -} - -trait Encodable { - fn encode(&self, s: &mut S) -> Result<(), S::Error>; -} - -impl Encodable for i32 { - fn encode(&self, _s: &mut S) -> Result<(), S::Error> { - Ok(()) - } -} - -struct JsonEncoder<'a>(PhantomData<&'a mut ()>); - -impl Encoder for JsonEncoder<'_> { - type Error = (); -} - -fn encode_json Encodable>>( - object: &T, -) -> Result { - let s = String::new(); - { - let mut encoder = JsonEncoder(PhantomData); - object.encode(&mut encoder)?; - } - Ok(s) -} - -struct Foo Encodable>> { - v: T, -} - -impl Encodable>> Drop for Foo { - fn drop(&mut self) { - encode_json(&self.v); - } -} - -fn main() { - let _ = Foo { v: 10 }; -} diff --git a/tests/ui-fulldeps/issue-16822.rs b/tests/ui-fulldeps/issue-16822.rs deleted file mode 100644 index c611c33affd..00000000000 --- a/tests/ui-fulldeps/issue-16822.rs +++ /dev/null @@ -1,22 +0,0 @@ -// run-pass -// aux-build:issue-16822.rs - -extern crate issue_16822 as lib; - -use std::cell::RefCell; - -struct App { - i: isize -} - -impl lib::Update for App { - fn update(&mut self) { - self.i += 1; - } -} - -fn main(){ - let app = App { i: 5 }; - let window = lib::Window { data: RefCell::new(app) }; - window.update(1); -} diff --git a/tests/ui-fulldeps/issue-18502.rs b/tests/ui-fulldeps/issue-18502.rs deleted file mode 100644 index 2082ae7a991..00000000000 --- a/tests/ui-fulldeps/issue-18502.rs +++ /dev/null @@ -1,8 +0,0 @@ -// run-pass -// aux-build:issue-18502.rs - -extern crate issue_18502 as fmt; - -fn main() { - ::fmt::baz(); -} diff --git a/tests/ui-fulldeps/issue-24106.rs b/tests/ui-fulldeps/issue-24106.rs deleted file mode 100644 index 45f0bd5b679..00000000000 --- a/tests/ui-fulldeps/issue-24106.rs +++ /dev/null @@ -1,8 +0,0 @@ -// run-pass -// aux-build:issue-24106.rs - -extern crate issue_24106; - -fn main() { - issue_24106::go::<()>(); -} diff --git a/tests/ui-fulldeps/issue-2804.rs b/tests/ui-fulldeps/issue-2804.rs deleted file mode 100644 index 571028c5e40..00000000000 --- a/tests/ui-fulldeps/issue-2804.rs +++ /dev/null @@ -1,81 +0,0 @@ -// run-pass - -#![allow(non_camel_case_types)] -#![allow(dead_code)] - -use std::collections::{BTreeMap, HashMap}; -use std::option; - -#[derive(Clone, Debug)] -enum Json { - I64(i64), - U64(u64), - F64(f64), - String(String), - Boolean(bool), - Array(Array), - Object(Object), - Null, -} - -type Array = Vec; -type Object = BTreeMap; - -enum object { - bool_value(bool), - int_value(i64), -} - -fn lookup(table: Object, key: String, default: String) -> String -{ - match table.get(&key) { - option::Option::Some(&Json::String(ref s)) => { - s.to_string() - } - option::Option::Some(value) => { - println!("{} was expected to be a string but is a {:?}", key, value); - default - } - option::Option::None => { - default - } - } -} - -fn add_interface(_store: isize, managed_ip: String, data: Json) -> (String, object) -{ - match &data { - &Json::Object(ref interface) => { - let name = lookup(interface.clone(), - "ifDescr".to_string(), - "".to_string()); - let label = format!("{}-{}", managed_ip, name); - - (label, object::bool_value(false)) - } - _ => { - println!("Expected dict for {} interfaces, found {:?}", managed_ip, data); - ("gnos:missing-interface".to_string(), object::bool_value(true)) - } - } -} - -fn add_interfaces(store: isize, managed_ip: String, device: HashMap) --> Vec<(String, object)> { - match device["interfaces"] { - Json::Array(ref interfaces) => - { - interfaces.iter().map(|interface| { - add_interface(store, managed_ip.clone(), (*interface).clone()) - }).collect() - } - _ => - { - println!("Expected list for {} interfaces, found {:?}", managed_ip, - device["interfaces"]); - Vec::new() - } - } -} - -pub fn main() {} diff --git a/tests/ui-fulldeps/myriad-closures.rs b/tests/ui-fulldeps/myriad-closures.rs deleted file mode 100644 index 310351f50cb..00000000000 --- a/tests/ui-fulldeps/myriad-closures.rs +++ /dev/null @@ -1,39 +0,0 @@ -// run-pass -// This test case tests whether we can handle code bases that contain a high -// number of closures, something that needs special handling in the MingGW -// toolchain. -// See https://github.com/rust-lang/rust/issues/34793 for more information. - -// Make sure we don't optimize anything away: -// compile-flags: -C no-prepopulate-passes -Cpasses=name-anon-globals - -// Expand something exponentially -macro_rules! go_bacterial { - ($mac:ident) => ($mac!()); - ($mac:ident 1 $($t:tt)*) => ( - go_bacterial!($mac $($t)*); - go_bacterial!($mac $($t)*); - ) -} - -macro_rules! mk_closure { - () => ((move || {})()) -} - -macro_rules! mk_fn { - () => { - { - fn function() { - // Make 16 closures - go_bacterial!(mk_closure 1 1 1 1); - } - let _ = function(); - } - } -} - -fn main() { - // Make 2^8 functions, each containing 16 closures, - // resulting in 2^12 closures overall. - go_bacterial!(mk_fn 1 1 1 1 1 1 1 1); -} diff --git a/tests/ui-fulldeps/std/issue-15149.rs b/tests/ui-fulldeps/std/issue-15149.rs deleted file mode 100644 index 064472f5785..00000000000 --- a/tests/ui-fulldeps/std/issue-15149.rs +++ /dev/null @@ -1,57 +0,0 @@ -// run-pass - -#![allow(unused_variables)] -// no-prefer-dynamic -// ignore-cross-compile - -use std::env; -use std::ffi::OsStr; -use std::fs; -use std::path::PathBuf; -use std::process; -use std::str; - -fn main() { - // If we're the child, make sure we were invoked correctly - let args: Vec = env::args().collect(); - if args.len() > 1 && args[1] == "child" { - // FIXME: This should check the whole `args[0]` instead of just - // checking that it ends_with the executable name. This - // is needed because of Windows, which has a different behavior. - // See #15149 for more info. - let my_path = env::current_exe().unwrap(); - return assert_eq!(my_path.file_stem(), Some(OsStr::new("mytest"))); - } - - test(); -} - -fn test() { - // If we're the parent, copy our own binary to a new directory. - let my_path = env::current_exe().unwrap(); - let my_dir = my_path.parent().unwrap(); - - let child_dir = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap()); - let child_dir = child_dir.join("issue-15140-child"); - fs::create_dir_all(&child_dir).unwrap(); - - let child_path = child_dir.join(&format!("mytest{}", env::consts::EXE_SUFFIX)); - fs::copy(&my_path, &child_path).unwrap(); - - // Append the new directory to our own PATH. - let path = { - let mut paths: Vec<_> = env::split_paths(&env::var_os("PATH").unwrap()).collect(); - paths.push(child_dir.to_path_buf()); - env::join_paths(paths).unwrap() - }; - - let child_output = - process::Command::new("mytest").env("PATH", &path).arg("child").output().unwrap(); - - assert!( - child_output.status.success(), - "child assertion failed\n child stdout:\n {}\n child stderr:\n {}", - str::from_utf8(&child_output.stdout).unwrap(), - str::from_utf8(&child_output.stderr).unwrap() - ); -} diff --git a/tests/ui-fulldeps/std/issue-81357-unsound-file-methods.rs b/tests/ui-fulldeps/std/issue-81357-unsound-file-methods.rs deleted file mode 100644 index fdf1150f8d2..00000000000 --- a/tests/ui-fulldeps/std/issue-81357-unsound-file-methods.rs +++ /dev/null @@ -1,81 +0,0 @@ -// run-fail -// only-windows - -fn main() { - use std::fs; - use std::io::prelude::*; - use std::os::windows::prelude::*; - use std::ptr; - use std::sync::Arc; - use std::thread; - use std::time::Duration; - - const FILE_FLAG_OVERLAPPED: u32 = 0x40000000; - - fn create_pipe_server(path: &str) -> fs::File { - let mut path0 = path.as_bytes().to_owned(); - path0.push(0); - extern "system" { - fn CreateNamedPipeA( - lpName: *const u8, - dwOpenMode: u32, - dwPipeMode: u32, - nMaxInstances: u32, - nOutBufferSize: u32, - nInBufferSize: u32, - nDefaultTimeOut: u32, - lpSecurityAttributes: *mut u8, - ) -> RawHandle; - } - - unsafe { - let h = CreateNamedPipeA(path0.as_ptr(), 3, 0, 1, 0, 0, 0, ptr::null_mut()); - assert_ne!(h as isize, -1); - fs::File::from_raw_handle(h) - } - } - - let path = "\\\\.\\pipe\\repro"; - let mut server = create_pipe_server(path); - - let client = Arc::new( - fs::OpenOptions::new().custom_flags(FILE_FLAG_OVERLAPPED).read(true).open(path).unwrap(), - ); - - let spawn_read = |is_first: bool| { - thread::spawn({ - let f = client.clone(); - move || { - let mut buf = [0xcc; 1]; - let mut f = f.as_ref(); - f.read(&mut buf).unwrap(); - if is_first { - assert_ne!(buf[0], 0xcc); - } else { - let b = buf[0]; // capture buf[0] - thread::sleep(Duration::from_millis(200)); - - // Check the buffer hasn't been written to after read. - dbg!(buf[0], b); - assert_eq!(buf[0], b); - } - } - }) - }; - - let t1 = spawn_read(true); - thread::sleep(Duration::from_millis(20)); - let t2 = spawn_read(false); - thread::sleep(Duration::from_millis(100)); - let _ = server.write(b"x"); - thread::sleep(Duration::from_millis(100)); - let _ = server.write(b"y"); - - // This is run fail because we need to test for the `abort`. - // That failing to run is the success case. - if t1.join().is_err() || t2.join().is_err() { - return; - } else { - panic!("success"); - } -} diff --git a/tests/ui-fulldeps/std/stdio-from.rs b/tests/ui-fulldeps/std/stdio-from.rs deleted file mode 100644 index fef9f27fcdf..00000000000 --- a/tests/ui-fulldeps/std/stdio-from.rs +++ /dev/null @@ -1,69 +0,0 @@ -// run-pass -// ignore-cross-compile - -use std::env; -use std::fs::File; -use std::io; -use std::io::{Read, Write}; -use std::process::{Command, Stdio}; -use std::path::PathBuf; - -fn main() { - if env::args().len() > 1 { - child().unwrap() - } else { - parent().unwrap() - } -} - -fn parent() -> io::Result<()> { - let td = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap()); - let input = td.join("stdio-from-input"); - let output = td.join("stdio-from-output"); - - File::create(&input)?.write_all(b"foo\n")?; - - // Set up this chain: - // $ me file - // ... to duplicate each line 8 times total. - - let mut child1 = Command::new(env::current_exe()?) - .arg("first") - .stdin(File::open(&input)?) // tests File::into() - .stdout(Stdio::piped()) - .spawn()?; - - let mut child3 = Command::new(env::current_exe()?) - .arg("third") - .stdin(Stdio::piped()) - .stdout(File::create(&output)?) // tests File::into() - .spawn()?; - - // Started out of order so we can test both `ChildStdin` and `ChildStdout`. - let mut child2 = Command::new(env::current_exe()?) - .arg("second") - .stdin(child1.stdout.take().unwrap()) // tests ChildStdout::into() - .stdout(child3.stdin.take().unwrap()) // tests ChildStdin::into() - .spawn()?; - - assert!(child1.wait()?.success()); - assert!(child2.wait()?.success()); - assert!(child3.wait()?.success()); - - let mut data = String::new(); - File::open(&output)?.read_to_string(&mut data)?; - for line in data.lines() { - assert_eq!(line, "foo"); - } - assert_eq!(data.lines().count(), 8); - Ok(()) -} - -fn child() -> io::Result<()> { - // double everything - let mut input = vec![]; - io::stdin().read_to_end(&mut input)?; - io::stdout().write_all(&input)?; - io::stdout().write_all(&input)?; - Ok(()) -} diff --git a/tests/ui-fulldeps/std/switch-stdout.rs b/tests/ui-fulldeps/std/switch-stdout.rs deleted file mode 100644 index e9501a80930..00000000000 --- a/tests/ui-fulldeps/std/switch-stdout.rs +++ /dev/null @@ -1,51 +0,0 @@ -// run-pass - -use std::env; -use std::fs::File; -use std::io::{Read, Write}; -use std::path::PathBuf; - -#[cfg(unix)] -fn switch_stdout_to(file: File) { - use std::os::unix::prelude::*; - - extern "C" { - fn dup2(old: i32, new: i32) -> i32; - } - - unsafe { - assert_eq!(dup2(file.as_raw_fd(), 1), 1); - } -} - -#[cfg(windows)] -fn switch_stdout_to(file: File) { - use std::os::windows::prelude::*; - - extern "system" { - fn SetStdHandle(nStdHandle: u32, handle: *mut u8) -> i32; - } - - const STD_OUTPUT_HANDLE: u32 = (-11i32) as u32; - - unsafe { - let rc = SetStdHandle(STD_OUTPUT_HANDLE, file.into_raw_handle() as *mut _); - assert!(rc != 0); - } -} - -fn main() { - let path = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap()); - let path = path.join("switch-stdout-output"); - let f = File::create(&path).unwrap(); - - println!("foo"); - std::io::stdout().flush().unwrap(); - switch_stdout_to(f); - println!("bar"); - std::io::stdout().flush().unwrap(); - - let mut contents = String::new(); - File::open(&path).unwrap().read_to_string(&mut contents).unwrap(); - assert_eq!(contents, "bar\n"); -} diff --git a/tests/ui/auxiliary/issue-13560-1.rs b/tests/ui/auxiliary/issue-13560-1.rs new file mode 100644 index 00000000000..c3a2ae679bf --- /dev/null +++ b/tests/ui/auxiliary/issue-13560-1.rs @@ -0,0 +1,3 @@ +// no-prefer-dynamic + +#![crate_type = "dylib"] diff --git a/tests/ui/auxiliary/issue-13560-2.rs b/tests/ui/auxiliary/issue-13560-2.rs new file mode 100644 index 00000000000..39c261e1162 --- /dev/null +++ b/tests/ui/auxiliary/issue-13560-2.rs @@ -0,0 +1,3 @@ +// no-prefer-dynamic + +#![crate_type = "rlib"] diff --git a/tests/ui/auxiliary/issue-13560-3.rs b/tests/ui/auxiliary/issue-13560-3.rs new file mode 100644 index 00000000000..e991bcc1a02 --- /dev/null +++ b/tests/ui/auxiliary/issue-13560-3.rs @@ -0,0 +1,6 @@ +// no-prefer-dynamic + +#![crate_type = "rlib"] + +#[macro_use] #[no_link] extern crate issue_13560_1 as t1; +#[macro_use] extern crate issue_13560_2 as t2; diff --git a/tests/ui/auxiliary/issue-16822.rs b/tests/ui/auxiliary/issue-16822.rs new file mode 100644 index 00000000000..9042dd39117 --- /dev/null +++ b/tests/ui/auxiliary/issue-16822.rs @@ -0,0 +1,20 @@ +#![crate_type="lib"] + +use std::cell::RefCell; + +pub struct Window{ + pub data: RefCell +} + +impl Window { + pub fn update(&self, e: i32) { + match e { + 1 => self.data.borrow_mut().update(), + _ => {} + } + } +} + +pub trait Update { + fn update(&mut self); +} diff --git a/tests/ui/auxiliary/issue-18502.rs b/tests/ui/auxiliary/issue-18502.rs new file mode 100644 index 00000000000..4d4230607aa --- /dev/null +++ b/tests/ui/auxiliary/issue-18502.rs @@ -0,0 +1,21 @@ +#![crate_type="lib"] + +struct Foo; +// This is the ICE trigger +struct Formatter; + +trait Show { + fn fmt(&self); +} + +impl Show for Foo { + fn fmt(&self) {} +} + +fn bar(f: extern "Rust" fn(&T), t: &T) { } + +// ICE requirement: this has to be marked as inline +#[inline] +pub fn baz() { + bar(Show::fmt, &Foo); +} diff --git a/tests/ui/auxiliary/issue-24106.rs b/tests/ui/auxiliary/issue-24106.rs new file mode 100644 index 00000000000..2c6a6034806 --- /dev/null +++ b/tests/ui/auxiliary/issue-24106.rs @@ -0,0 +1,13 @@ +#![crate_type="lib"] + +enum E { E0 = 0, E1 = 1 } +const E0_U8: u8 = E::E0 as u8; +const E1_U8: u8 = E::E1 as u8; + +pub fn go() { + match 0 { + E0_U8 => (), + E1_U8 => (), + _ => (), + } +} diff --git a/tests/ui/extern-mod-syntax.rs b/tests/ui/extern-mod-syntax.rs new file mode 100644 index 00000000000..230194c5377 --- /dev/null +++ b/tests/ui/extern-mod-syntax.rs @@ -0,0 +1,11 @@ +// run-pass + +#![allow(unused_imports)] +#![feature(rustc_private)] + +extern crate libc; +use libc::c_void; + +pub fn main() { + println!("Hello world!"); +} diff --git a/tests/ui/internal-lints/diagnostics_incorrect.rs b/tests/ui/internal-lints/diagnostics_incorrect.rs new file mode 100644 index 00000000000..99f99ffcd35 --- /dev/null +++ b/tests/ui/internal-lints/diagnostics_incorrect.rs @@ -0,0 +1,15 @@ +// compile-flags: -Z unstable-options + +#![feature(rustc_attrs)] + +#[rustc_lint_diagnostics] +//~^ ERROR attribute should be applied to a function +struct Foo; + +impl Foo { + #[rustc_lint_diagnostics(a)] + //~^ ERROR malformed `rustc_lint_diagnostics` + fn bar() {} +} + +fn main() {} diff --git a/tests/ui/internal-lints/diagnostics_incorrect.stderr b/tests/ui/internal-lints/diagnostics_incorrect.stderr new file mode 100644 index 00000000000..e849ca2829e --- /dev/null +++ b/tests/ui/internal-lints/diagnostics_incorrect.stderr @@ -0,0 +1,17 @@ +error: malformed `rustc_lint_diagnostics` attribute input + --> $DIR/diagnostics_incorrect.rs:10:5 + | +LL | #[rustc_lint_diagnostics(a)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_lint_diagnostics]` + +error: attribute should be applied to a function definition + --> $DIR/diagnostics_incorrect.rs:5:1 + | +LL | #[rustc_lint_diagnostics] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | struct Foo; + | ----------- not a function definition + +error: aborting due to 2 previous errors + diff --git a/tests/ui/internal-lints/existing_doc_keyword.rs b/tests/ui/internal-lints/existing_doc_keyword.rs new file mode 100644 index 00000000000..7783dc40fcf --- /dev/null +++ b/tests/ui/internal-lints/existing_doc_keyword.rs @@ -0,0 +1,11 @@ +// compile-flags: -Z unstable-options + +#![feature(rustc_private)] +#![feature(rustdoc_internals)] + +#![crate_type = "lib"] + +#![deny(rustc::existing_doc_keyword)] + +#[doc(keyword = "tadam")] //~ ERROR +mod tadam {} diff --git a/tests/ui/internal-lints/existing_doc_keyword.stderr b/tests/ui/internal-lints/existing_doc_keyword.stderr new file mode 100644 index 00000000000..5110b9be08a --- /dev/null +++ b/tests/ui/internal-lints/existing_doc_keyword.stderr @@ -0,0 +1,15 @@ +error: found non-existing keyword `tadam` used in `#[doc(keyword = "...")]` + --> $DIR/existing_doc_keyword.rs:10:1 + | +LL | #[doc(keyword = "tadam")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: only existing keywords are allowed in core/std +note: the lint level is defined here + --> $DIR/existing_doc_keyword.rs:8:9 + | +LL | #![deny(rustc::existing_doc_keyword)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/internal-lints/query_stability_incorrect.rs b/tests/ui/internal-lints/query_stability_incorrect.rs new file mode 100644 index 00000000000..f478b73329e --- /dev/null +++ b/tests/ui/internal-lints/query_stability_incorrect.rs @@ -0,0 +1,15 @@ +// compile-flags: -Z unstable-options + +#![feature(rustc_attrs)] + +#[rustc_lint_query_instability] +//~^ ERROR attribute should be applied to a function +struct Foo; + +impl Foo { + #[rustc_lint_query_instability(a)] + //~^ ERROR malformed `rustc_lint_query_instability` + fn bar() {} +} + +fn main() {} diff --git a/tests/ui/internal-lints/query_stability_incorrect.stderr b/tests/ui/internal-lints/query_stability_incorrect.stderr new file mode 100644 index 00000000000..3f78b39edd9 --- /dev/null +++ b/tests/ui/internal-lints/query_stability_incorrect.stderr @@ -0,0 +1,17 @@ +error: malformed `rustc_lint_query_instability` attribute input + --> $DIR/query_stability_incorrect.rs:10:5 + | +LL | #[rustc_lint_query_instability(a)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_lint_query_instability]` + +error: attribute should be applied to a function definition + --> $DIR/query_stability_incorrect.rs:5:1 + | +LL | #[rustc_lint_query_instability] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | struct Foo; + | ----------- not a function definition + +error: aborting due to 2 previous errors + diff --git a/tests/ui/internal-lints/rustc_pass_by_value_self.rs b/tests/ui/internal-lints/rustc_pass_by_value_self.rs new file mode 100644 index 00000000000..6ce67dcaf1d --- /dev/null +++ b/tests/ui/internal-lints/rustc_pass_by_value_self.rs @@ -0,0 +1,54 @@ +// compile-flags: -Z unstable-options +// NOTE: This test doesn't actually require `fulldeps` +// so we could instead use it as a `ui` test. +// +// Considering that all other `internal-lints` are tested here +// this seems like the cleaner solution though. +#![feature(rustc_attrs)] +#![deny(rustc::pass_by_value)] +#![allow(unused)] + +#[rustc_pass_by_value] +struct TyCtxt<'tcx> { + inner: &'tcx (), +} + +impl<'tcx> TyCtxt<'tcx> { + fn by_value(self) {} // OK + fn by_ref(&self) {} //~ ERROR passing `TyCtxt<'tcx>` by reference +} + +struct TyS<'tcx> { + inner: &'tcx (), +} + +#[rustc_pass_by_value] +type Ty<'tcx> = &'tcx TyS<'tcx>; + +impl<'tcx> TyS<'tcx> { + fn by_value(self: Ty<'tcx>) {} + fn by_ref(self: &Ty<'tcx>) {} //~ ERROR passing `Ty<'tcx>` by reference +} + +#[rustc_pass_by_value] +struct Foo; + +impl Foo { + fn with_ref(&self) {} //~ ERROR passing `Foo` by reference +} + +#[rustc_pass_by_value] +struct WithParameters { + slice: [T; N], + m: M, +} + +impl WithParameters { + fn with_ref(&self) {} //~ ERROR passing `WithParameters` by reference +} + +impl WithParameters { + fn with_ref(&self) {} //~ ERROR passing `WithParameters` by reference +} + +fn main() {} diff --git a/tests/ui/internal-lints/rustc_pass_by_value_self.stderr b/tests/ui/internal-lints/rustc_pass_by_value_self.stderr new file mode 100644 index 00000000000..fb39ed60b82 --- /dev/null +++ b/tests/ui/internal-lints/rustc_pass_by_value_self.stderr @@ -0,0 +1,38 @@ +error: passing `TyCtxt<'tcx>` by reference + --> $DIR/rustc_pass_by_value_self.rs:18:15 + | +LL | fn by_ref(&self) {} + | ^^^^^ help: try passing by value: `TyCtxt<'tcx>` + | +note: the lint level is defined here + --> $DIR/rustc_pass_by_value_self.rs:8:9 + | +LL | #![deny(rustc::pass_by_value)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: passing `Ty<'tcx>` by reference + --> $DIR/rustc_pass_by_value_self.rs:30:21 + | +LL | fn by_ref(self: &Ty<'tcx>) {} + | ^^^^^^^^^ help: try passing by value: `Ty<'tcx>` + +error: passing `Foo` by reference + --> $DIR/rustc_pass_by_value_self.rs:37:17 + | +LL | fn with_ref(&self) {} + | ^^^^^ help: try passing by value: `Foo` + +error: passing `WithParameters` by reference + --> $DIR/rustc_pass_by_value_self.rs:47:17 + | +LL | fn with_ref(&self) {} + | ^^^^^ help: try passing by value: `WithParameters` + +error: passing `WithParameters` by reference + --> $DIR/rustc_pass_by_value_self.rs:51:17 + | +LL | fn with_ref(&self) {} + | ^^^^^ help: try passing by value: `WithParameters` + +error: aborting due to 5 previous errors + diff --git a/tests/ui/issue-11881.rs b/tests/ui/issue-11881.rs new file mode 100644 index 00000000000..f6360db9b5f --- /dev/null +++ b/tests/ui/issue-11881.rs @@ -0,0 +1,91 @@ +// run-pass + +#![allow(unused_must_use)] +#![allow(dead_code)] +#![allow(unused_imports)] + +use std::fmt; +use std::io::prelude::*; +use std::io::Cursor; +use std::slice; +use std::marker::PhantomData; + +trait Encoder { + type Error; +} + +trait Encodable { + fn encode(&self, s: &mut S) -> Result<(), S::Error>; +} + +struct JsonEncoder<'a>(PhantomData<&'a mut ()>); + +impl Encoder for JsonEncoder<'_> { + type Error = (); +} + +struct AsJson<'a, T> { + inner: &'a T, +} + +impl<'a, T: for<'r> Encodable>> fmt::Display for AsJson<'a, T> { + /// Encodes a json value into a string + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { + Ok(()) + } +} + +fn as_json(t: &T) -> AsJson<'_, T> { + AsJson { inner: t } +} + +struct OpaqueEncoder(Vec); + +impl Encoder for OpaqueEncoder { + type Error = (); +} + + +struct Foo { + baz: bool, +} + +impl Encodable for Foo { + fn encode(&self, _s: &mut S) -> Result<(), S::Error> { + Ok(()) + } +} + +struct Bar { + froboz: usize, +} + +impl Encodable for Bar { + fn encode(&self, _s: &mut S) -> Result<(), S::Error> { + Ok(()) + } +} + +enum WireProtocol { + JSON, + Opaque, + // ... +} + +fn encode_json Encodable>>(val: &T, wr: &mut Cursor>) { + write!(wr, "{}", as_json(val)); +} + +fn encode_opaque>(val: &T, wr: Vec) { + let mut encoder = OpaqueEncoder(wr); + val.encode(&mut encoder); +} + +pub fn main() { + let target = Foo { baz: false }; + let proto = WireProtocol::JSON; + match proto { + WireProtocol::JSON => encode_json(&target, &mut Cursor::new(Vec::new())), + WireProtocol::Opaque => encode_opaque(&target, Vec::new()), + } +} diff --git a/tests/ui/issue-13560.rs b/tests/ui/issue-13560.rs new file mode 100644 index 00000000000..5f7d647e230 --- /dev/null +++ b/tests/ui/issue-13560.rs @@ -0,0 +1,12 @@ +// run-pass +// aux-build:issue-13560-1.rs +// aux-build:issue-13560-2.rs +// aux-build:issue-13560-3.rs + +// Regression test for issue #13560, the test itself is all in the dependent +// libraries. The fail which previously failed to compile is the one numbered 3. + +extern crate issue_13560_2 as t2; +extern crate issue_13560_3 as t3; + +fn main() {} diff --git a/tests/ui/issue-15924.rs b/tests/ui/issue-15924.rs new file mode 100644 index 00000000000..d8b3914d0d4 --- /dev/null +++ b/tests/ui/issue-15924.rs @@ -0,0 +1,53 @@ +// run-pass + +#![allow(unused_imports)] +#![allow(unused_must_use)] +// pretty-expanded FIXME #23616 + +use std::fmt; +use std::marker::PhantomData; + +trait Encoder { + type Error; +} + +trait Encodable { + fn encode(&self, s: &mut S) -> Result<(), S::Error>; +} + +impl Encodable for i32 { + fn encode(&self, _s: &mut S) -> Result<(), S::Error> { + Ok(()) + } +} + +struct JsonEncoder<'a>(PhantomData<&'a mut ()>); + +impl Encoder for JsonEncoder<'_> { + type Error = (); +} + +fn encode_json Encodable>>( + object: &T, +) -> Result { + let s = String::new(); + { + let mut encoder = JsonEncoder(PhantomData); + object.encode(&mut encoder)?; + } + Ok(s) +} + +struct Foo Encodable>> { + v: T, +} + +impl Encodable>> Drop for Foo { + fn drop(&mut self) { + encode_json(&self.v); + } +} + +fn main() { + let _ = Foo { v: 10 }; +} diff --git a/tests/ui/issue-16822.rs b/tests/ui/issue-16822.rs new file mode 100644 index 00000000000..c611c33affd --- /dev/null +++ b/tests/ui/issue-16822.rs @@ -0,0 +1,22 @@ +// run-pass +// aux-build:issue-16822.rs + +extern crate issue_16822 as lib; + +use std::cell::RefCell; + +struct App { + i: isize +} + +impl lib::Update for App { + fn update(&mut self) { + self.i += 1; + } +} + +fn main(){ + let app = App { i: 5 }; + let window = lib::Window { data: RefCell::new(app) }; + window.update(1); +} diff --git a/tests/ui/issue-18502.rs b/tests/ui/issue-18502.rs new file mode 100644 index 00000000000..2082ae7a991 --- /dev/null +++ b/tests/ui/issue-18502.rs @@ -0,0 +1,8 @@ +// run-pass +// aux-build:issue-18502.rs + +extern crate issue_18502 as fmt; + +fn main() { + ::fmt::baz(); +} diff --git a/tests/ui/issue-24106.rs b/tests/ui/issue-24106.rs new file mode 100644 index 00000000000..45f0bd5b679 --- /dev/null +++ b/tests/ui/issue-24106.rs @@ -0,0 +1,8 @@ +// run-pass +// aux-build:issue-24106.rs + +extern crate issue_24106; + +fn main() { + issue_24106::go::<()>(); +} diff --git a/tests/ui/issue-2804.rs b/tests/ui/issue-2804.rs new file mode 100644 index 00000000000..571028c5e40 --- /dev/null +++ b/tests/ui/issue-2804.rs @@ -0,0 +1,81 @@ +// run-pass + +#![allow(non_camel_case_types)] +#![allow(dead_code)] + +use std::collections::{BTreeMap, HashMap}; +use std::option; + +#[derive(Clone, Debug)] +enum Json { + I64(i64), + U64(u64), + F64(f64), + String(String), + Boolean(bool), + Array(Array), + Object(Object), + Null, +} + +type Array = Vec; +type Object = BTreeMap; + +enum object { + bool_value(bool), + int_value(i64), +} + +fn lookup(table: Object, key: String, default: String) -> String +{ + match table.get(&key) { + option::Option::Some(&Json::String(ref s)) => { + s.to_string() + } + option::Option::Some(value) => { + println!("{} was expected to be a string but is a {:?}", key, value); + default + } + option::Option::None => { + default + } + } +} + +fn add_interface(_store: isize, managed_ip: String, data: Json) -> (String, object) +{ + match &data { + &Json::Object(ref interface) => { + let name = lookup(interface.clone(), + "ifDescr".to_string(), + "".to_string()); + let label = format!("{}-{}", managed_ip, name); + + (label, object::bool_value(false)) + } + _ => { + println!("Expected dict for {} interfaces, found {:?}", managed_ip, data); + ("gnos:missing-interface".to_string(), object::bool_value(true)) + } + } +} + +fn add_interfaces(store: isize, managed_ip: String, device: HashMap) +-> Vec<(String, object)> { + match device["interfaces"] { + Json::Array(ref interfaces) => + { + interfaces.iter().map(|interface| { + add_interface(store, managed_ip.clone(), (*interface).clone()) + }).collect() + } + _ => + { + println!("Expected list for {} interfaces, found {:?}", managed_ip, + device["interfaces"]); + Vec::new() + } + } +} + +pub fn main() {} diff --git a/tests/ui/myriad-closures.rs b/tests/ui/myriad-closures.rs new file mode 100644 index 00000000000..310351f50cb --- /dev/null +++ b/tests/ui/myriad-closures.rs @@ -0,0 +1,39 @@ +// run-pass +// This test case tests whether we can handle code bases that contain a high +// number of closures, something that needs special handling in the MingGW +// toolchain. +// See https://github.com/rust-lang/rust/issues/34793 for more information. + +// Make sure we don't optimize anything away: +// compile-flags: -C no-prepopulate-passes -Cpasses=name-anon-globals + +// Expand something exponentially +macro_rules! go_bacterial { + ($mac:ident) => ($mac!()); + ($mac:ident 1 $($t:tt)*) => ( + go_bacterial!($mac $($t)*); + go_bacterial!($mac $($t)*); + ) +} + +macro_rules! mk_closure { + () => ((move || {})()) +} + +macro_rules! mk_fn { + () => { + { + fn function() { + // Make 16 closures + go_bacterial!(mk_closure 1 1 1 1); + } + let _ = function(); + } + } +} + +fn main() { + // Make 2^8 functions, each containing 16 closures, + // resulting in 2^12 closures overall. + go_bacterial!(mk_fn 1 1 1 1 1 1 1 1); +} diff --git a/tests/ui/std/issue-15149.rs b/tests/ui/std/issue-15149.rs new file mode 100644 index 00000000000..064472f5785 --- /dev/null +++ b/tests/ui/std/issue-15149.rs @@ -0,0 +1,57 @@ +// run-pass + +#![allow(unused_variables)] +// no-prefer-dynamic +// ignore-cross-compile + +use std::env; +use std::ffi::OsStr; +use std::fs; +use std::path::PathBuf; +use std::process; +use std::str; + +fn main() { + // If we're the child, make sure we were invoked correctly + let args: Vec = env::args().collect(); + if args.len() > 1 && args[1] == "child" { + // FIXME: This should check the whole `args[0]` instead of just + // checking that it ends_with the executable name. This + // is needed because of Windows, which has a different behavior. + // See #15149 for more info. + let my_path = env::current_exe().unwrap(); + return assert_eq!(my_path.file_stem(), Some(OsStr::new("mytest"))); + } + + test(); +} + +fn test() { + // If we're the parent, copy our own binary to a new directory. + let my_path = env::current_exe().unwrap(); + let my_dir = my_path.parent().unwrap(); + + let child_dir = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap()); + let child_dir = child_dir.join("issue-15140-child"); + fs::create_dir_all(&child_dir).unwrap(); + + let child_path = child_dir.join(&format!("mytest{}", env::consts::EXE_SUFFIX)); + fs::copy(&my_path, &child_path).unwrap(); + + // Append the new directory to our own PATH. + let path = { + let mut paths: Vec<_> = env::split_paths(&env::var_os("PATH").unwrap()).collect(); + paths.push(child_dir.to_path_buf()); + env::join_paths(paths).unwrap() + }; + + let child_output = + process::Command::new("mytest").env("PATH", &path).arg("child").output().unwrap(); + + assert!( + child_output.status.success(), + "child assertion failed\n child stdout:\n {}\n child stderr:\n {}", + str::from_utf8(&child_output.stdout).unwrap(), + str::from_utf8(&child_output.stderr).unwrap() + ); +} diff --git a/tests/ui/std/issue-81357-unsound-file-methods.rs b/tests/ui/std/issue-81357-unsound-file-methods.rs new file mode 100644 index 00000000000..fdf1150f8d2 --- /dev/null +++ b/tests/ui/std/issue-81357-unsound-file-methods.rs @@ -0,0 +1,81 @@ +// run-fail +// only-windows + +fn main() { + use std::fs; + use std::io::prelude::*; + use std::os::windows::prelude::*; + use std::ptr; + use std::sync::Arc; + use std::thread; + use std::time::Duration; + + const FILE_FLAG_OVERLAPPED: u32 = 0x40000000; + + fn create_pipe_server(path: &str) -> fs::File { + let mut path0 = path.as_bytes().to_owned(); + path0.push(0); + extern "system" { + fn CreateNamedPipeA( + lpName: *const u8, + dwOpenMode: u32, + dwPipeMode: u32, + nMaxInstances: u32, + nOutBufferSize: u32, + nInBufferSize: u32, + nDefaultTimeOut: u32, + lpSecurityAttributes: *mut u8, + ) -> RawHandle; + } + + unsafe { + let h = CreateNamedPipeA(path0.as_ptr(), 3, 0, 1, 0, 0, 0, ptr::null_mut()); + assert_ne!(h as isize, -1); + fs::File::from_raw_handle(h) + } + } + + let path = "\\\\.\\pipe\\repro"; + let mut server = create_pipe_server(path); + + let client = Arc::new( + fs::OpenOptions::new().custom_flags(FILE_FLAG_OVERLAPPED).read(true).open(path).unwrap(), + ); + + let spawn_read = |is_first: bool| { + thread::spawn({ + let f = client.clone(); + move || { + let mut buf = [0xcc; 1]; + let mut f = f.as_ref(); + f.read(&mut buf).unwrap(); + if is_first { + assert_ne!(buf[0], 0xcc); + } else { + let b = buf[0]; // capture buf[0] + thread::sleep(Duration::from_millis(200)); + + // Check the buffer hasn't been written to after read. + dbg!(buf[0], b); + assert_eq!(buf[0], b); + } + } + }) + }; + + let t1 = spawn_read(true); + thread::sleep(Duration::from_millis(20)); + let t2 = spawn_read(false); + thread::sleep(Duration::from_millis(100)); + let _ = server.write(b"x"); + thread::sleep(Duration::from_millis(100)); + let _ = server.write(b"y"); + + // This is run fail because we need to test for the `abort`. + // That failing to run is the success case. + if t1.join().is_err() || t2.join().is_err() { + return; + } else { + panic!("success"); + } +} diff --git a/tests/ui/std/stdio-from.rs b/tests/ui/std/stdio-from.rs new file mode 100644 index 00000000000..fef9f27fcdf --- /dev/null +++ b/tests/ui/std/stdio-from.rs @@ -0,0 +1,69 @@ +// run-pass +// ignore-cross-compile + +use std::env; +use std::fs::File; +use std::io; +use std::io::{Read, Write}; +use std::process::{Command, Stdio}; +use std::path::PathBuf; + +fn main() { + if env::args().len() > 1 { + child().unwrap() + } else { + parent().unwrap() + } +} + +fn parent() -> io::Result<()> { + let td = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap()); + let input = td.join("stdio-from-input"); + let output = td.join("stdio-from-output"); + + File::create(&input)?.write_all(b"foo\n")?; + + // Set up this chain: + // $ me file + // ... to duplicate each line 8 times total. + + let mut child1 = Command::new(env::current_exe()?) + .arg("first") + .stdin(File::open(&input)?) // tests File::into() + .stdout(Stdio::piped()) + .spawn()?; + + let mut child3 = Command::new(env::current_exe()?) + .arg("third") + .stdin(Stdio::piped()) + .stdout(File::create(&output)?) // tests File::into() + .spawn()?; + + // Started out of order so we can test both `ChildStdin` and `ChildStdout`. + let mut child2 = Command::new(env::current_exe()?) + .arg("second") + .stdin(child1.stdout.take().unwrap()) // tests ChildStdout::into() + .stdout(child3.stdin.take().unwrap()) // tests ChildStdin::into() + .spawn()?; + + assert!(child1.wait()?.success()); + assert!(child2.wait()?.success()); + assert!(child3.wait()?.success()); + + let mut data = String::new(); + File::open(&output)?.read_to_string(&mut data)?; + for line in data.lines() { + assert_eq!(line, "foo"); + } + assert_eq!(data.lines().count(), 8); + Ok(()) +} + +fn child() -> io::Result<()> { + // double everything + let mut input = vec![]; + io::stdin().read_to_end(&mut input)?; + io::stdout().write_all(&input)?; + io::stdout().write_all(&input)?; + Ok(()) +} diff --git a/tests/ui/std/switch-stdout.rs b/tests/ui/std/switch-stdout.rs new file mode 100644 index 00000000000..e9501a80930 --- /dev/null +++ b/tests/ui/std/switch-stdout.rs @@ -0,0 +1,51 @@ +// run-pass + +use std::env; +use std::fs::File; +use std::io::{Read, Write}; +use std::path::PathBuf; + +#[cfg(unix)] +fn switch_stdout_to(file: File) { + use std::os::unix::prelude::*; + + extern "C" { + fn dup2(old: i32, new: i32) -> i32; + } + + unsafe { + assert_eq!(dup2(file.as_raw_fd(), 1), 1); + } +} + +#[cfg(windows)] +fn switch_stdout_to(file: File) { + use std::os::windows::prelude::*; + + extern "system" { + fn SetStdHandle(nStdHandle: u32, handle: *mut u8) -> i32; + } + + const STD_OUTPUT_HANDLE: u32 = (-11i32) as u32; + + unsafe { + let rc = SetStdHandle(STD_OUTPUT_HANDLE, file.into_raw_handle() as *mut _); + assert!(rc != 0); + } +} + +fn main() { + let path = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap()); + let path = path.join("switch-stdout-output"); + let f = File::create(&path).unwrap(); + + println!("foo"); + std::io::stdout().flush().unwrap(); + switch_stdout_to(f); + println!("bar"); + std::io::stdout().flush().unwrap(); + + let mut contents = String::new(); + File::open(&path).unwrap().read_to_string(&mut contents).unwrap(); + assert_eq!(contents, "bar\n"); +} -- cgit 1.4.1-3-g733a5