From 1b0186e9ecdaa6fd00f1beea7d877b5a4fbd762d Mon Sep 17 00:00:00 2001 From: Caio Date: Wed, 15 Sep 2021 14:03:27 -0300 Subject: Move some tests to more reasonable directories --- src/test/ui/associated-types/issue-19883.rs | 16 ++ src/test/ui/associated-types/issue-19883.stderr | 15 ++ src/test/ui/associated-types/issue-21363.rs | 15 ++ .../ui/async-await/auxiliary/issue-72470-lib.rs | 175 +++++++++++++++++++++ .../ui/async-await/issue-72470-llvm-dominate.rs | 66 ++++++++ src/test/ui/auxiliary/define-macro.rs | 6 - src/test/ui/auxiliary/issue-72470-lib.rs | 175 --------------------- src/test/ui/bug-7183-generics.rs | 36 ----- src/test/ui/closures/issue-78720.rs | 19 +++ src/test/ui/closures/issue-78720.stderr | 55 +++++++ src/test/ui/consts/issue-23833.rs | 15 ++ src/test/ui/consts/issue-34784.rs | 21 +++ src/test/ui/deriving/issue-3935.rs | 13 ++ src/test/ui/enable-unstable-lib-feature.rs | 13 -- src/test/ui/enable-unstable-lib-feature.stderr | 14 -- src/test/ui/expr-empty-ret.rs | 15 -- src/test/ui/generics/mid-path-type-params.rs | 37 +++++ src/test/ui/guards.rs | 20 --- .../type-arg-mismatch-due-to-impl-trait.rs | 16 ++ .../type-arg-mismatch-due-to-impl-trait.stderr | 15 ++ src/test/ui/issue-72470-llvm-dominate.rs | 66 -------- src/test/ui/issues/issue-19883.rs | 16 -- src/test/ui/issues/issue-19883.stderr | 15 -- src/test/ui/issues/issue-20692.rs | 11 -- src/test/ui/issues/issue-20692.stderr | 35 ----- src/test/ui/issues/issue-21363.rs | 15 -- src/test/ui/issues/issue-23825.rs | 21 --- src/test/ui/issues/issue-23833.rs | 15 -- src/test/ui/issues/issue-33498.rs | 11 -- src/test/ui/issues/issue-34194.rs | 11 -- src/test/ui/issues/issue-34784.rs | 21 --- src/test/ui/issues/issue-35376.rs | 43 ----- src/test/ui/issues/issue-35376.stderr | 12 -- src/test/ui/issues/issue-36768.rs | 9 -- src/test/ui/issues/issue-37433.rs | 12 -- src/test/ui/issues/issue-37433.stderr | 9 -- src/test/ui/issues/issue-38002.rs | 35 ----- src/test/ui/issues/issue-3935.rs | 13 -- src/test/ui/issues/issue-41255.rs | 51 ------ src/test/ui/issues/issue-41255.stderr | 115 -------------- src/test/ui/issues/issue-42944.rs | 21 --- src/test/ui/issues/issue-42944.stderr | 27 ---- ...-45107-unnecessary-unsafe-in-closure.mir.stderr | 35 ----- .../issue-45107-unnecessary-unsafe-in-closure.rs | 28 ---- ...45107-unnecessary-unsafe-in-closure.thir.stderr | 35 ----- src/test/ui/issues/issue-53912.rs | 37 ----- src/test/ui/issues/issue-56685.rs | 44 ------ src/test/ui/issues/issue-56685.stderr | 63 -------- src/test/ui/issues/issue-57410.rs | 17 -- src/test/ui/issues/issue-5791.rs | 14 -- src/test/ui/issues/issue-5791.stderr | 21 --- src/test/ui/issues/issue-74614.rs | 18 --- src/test/ui/issues/issue-78720.rs | 19 --- src/test/ui/issues/issue-78720.stderr | 55 ------- src/test/ui/issues/issue-79593.rs | 29 ---- src/test/ui/issues/issue-79593.stderr | 33 ---- src/test/ui/issues/issue-79744.rs | 13 -- src/test/ui/issues/issue-79744.stderr | 12 -- .../issues/type-arg-mismatch-due-to-impl-trait.rs | 16 -- .../type-arg-mismatch-due-to-impl-trait.stderr | 15 -- src/test/ui/lint/enable-unstable-lib-feature.rs | 13 ++ .../ui/lint/enable-unstable-lib-feature.stderr | 14 ++ src/test/ui/lint/issue-57410.rs | 17 ++ src/test/ui/lint/issue-79744.rs | 13 ++ src/test/ui/lint/issue-79744.stderr | 12 ++ src/test/ui/llvm-asm/issue-37433.rs | 12 ++ src/test/ui/llvm-asm/issue-37433.stderr | 9 ++ src/test/ui/macros/auxiliary/define-macro.rs | 6 + src/test/ui/macros/out-of-order-shadowing.rs | 10 ++ src/test/ui/macros/out-of-order-shadowing.stderr | 21 +++ src/test/ui/match/guards.rs | 20 +++ src/test/ui/match/issue-33498.rs | 11 ++ src/test/ui/match/issue-41255.rs | 51 ++++++ src/test/ui/match/issue-41255.stderr | 115 ++++++++++++++ src/test/ui/match/issue-56685.rs | 44 ++++++ src/test/ui/match/issue-56685.stderr | 63 ++++++++ src/test/ui/mid-path-type-params.rs | 37 ----- src/test/ui/never_type/expr-empty-ret.rs | 15 ++ src/test/ui/out-of-order-shadowing.rs | 10 -- src/test/ui/out-of-order-shadowing.stderr | 21 --- src/test/ui/polymorphization/issue-74614.rs | 18 +++ src/test/ui/privacy/issue-79593.rs | 29 ++++ src/test/ui/privacy/issue-79593.stderr | 33 ++++ src/test/ui/resolve/issue-42944.rs | 21 +++ src/test/ui/resolve/issue-42944.stderr | 27 ++++ src/test/ui/resolve/use-self-in-inner-fn.rs | 14 ++ src/test/ui/resolve/use-self-in-inner-fn.stderr | 15 ++ src/test/ui/specialization/issue-35376.rs | 43 +++++ src/test/ui/specialization/issue-35376.stderr | 12 ++ src/test/ui/static/issue-34194.rs | 11 ++ src/test/ui/structs-enums/issue-38002.rs | 35 +++++ src/test/ui/symbol-names/issue-53912.rs | 37 +++++ src/test/ui/test-attrs/issue-36768.rs | 9 ++ src/test/ui/thread-local/tls.rs | 14 ++ src/test/ui/tls.rs | 14 -- src/test/ui/traits/bug-7183-generics.rs | 36 +++++ src/test/ui/traits/issue-20692.rs | 11 ++ src/test/ui/traits/issue-20692.stderr | 35 +++++ src/test/ui/traits/issue-23825.rs | 21 +++ ...-45107-unnecessary-unsafe-in-closure.mir.stderr | 35 +++++ .../issue-45107-unnecessary-unsafe-in-closure.rs | 28 ++++ ...45107-unnecessary-unsafe-in-closure.thir.stderr | 35 +++++ src/test/ui/use-self-in-inner-fn.rs | 14 -- src/test/ui/use-self-in-inner-fn.stderr | 15 -- src/tools/tidy/src/ui_tests.rs | 4 +- 105 files changed, 1445 insertions(+), 1480 deletions(-) create mode 100644 src/test/ui/associated-types/issue-19883.rs create mode 100644 src/test/ui/associated-types/issue-19883.stderr create mode 100644 src/test/ui/associated-types/issue-21363.rs create mode 100644 src/test/ui/async-await/auxiliary/issue-72470-lib.rs create mode 100644 src/test/ui/async-await/issue-72470-llvm-dominate.rs delete mode 100644 src/test/ui/auxiliary/define-macro.rs delete mode 100644 src/test/ui/auxiliary/issue-72470-lib.rs delete mode 100644 src/test/ui/bug-7183-generics.rs create mode 100644 src/test/ui/closures/issue-78720.rs create mode 100644 src/test/ui/closures/issue-78720.stderr create mode 100644 src/test/ui/consts/issue-23833.rs create mode 100644 src/test/ui/consts/issue-34784.rs create mode 100644 src/test/ui/deriving/issue-3935.rs delete mode 100644 src/test/ui/enable-unstable-lib-feature.rs delete mode 100644 src/test/ui/enable-unstable-lib-feature.stderr delete mode 100644 src/test/ui/expr-empty-ret.rs create mode 100644 src/test/ui/generics/mid-path-type-params.rs delete mode 100644 src/test/ui/guards.rs create mode 100644 src/test/ui/impl-trait/type-arg-mismatch-due-to-impl-trait.rs create mode 100644 src/test/ui/impl-trait/type-arg-mismatch-due-to-impl-trait.stderr delete mode 100644 src/test/ui/issue-72470-llvm-dominate.rs delete mode 100644 src/test/ui/issues/issue-19883.rs delete mode 100644 src/test/ui/issues/issue-19883.stderr delete mode 100644 src/test/ui/issues/issue-20692.rs delete mode 100644 src/test/ui/issues/issue-20692.stderr delete mode 100644 src/test/ui/issues/issue-21363.rs delete mode 100644 src/test/ui/issues/issue-23825.rs delete mode 100644 src/test/ui/issues/issue-23833.rs delete mode 100644 src/test/ui/issues/issue-33498.rs delete mode 100644 src/test/ui/issues/issue-34194.rs delete mode 100644 src/test/ui/issues/issue-34784.rs delete mode 100644 src/test/ui/issues/issue-35376.rs delete mode 100644 src/test/ui/issues/issue-35376.stderr delete mode 100644 src/test/ui/issues/issue-36768.rs delete mode 100644 src/test/ui/issues/issue-37433.rs delete mode 100644 src/test/ui/issues/issue-37433.stderr delete mode 100644 src/test/ui/issues/issue-38002.rs delete mode 100644 src/test/ui/issues/issue-3935.rs delete mode 100644 src/test/ui/issues/issue-41255.rs delete mode 100644 src/test/ui/issues/issue-41255.stderr delete mode 100644 src/test/ui/issues/issue-42944.rs delete mode 100644 src/test/ui/issues/issue-42944.stderr delete mode 100644 src/test/ui/issues/issue-45107-unnecessary-unsafe-in-closure.mir.stderr delete mode 100644 src/test/ui/issues/issue-45107-unnecessary-unsafe-in-closure.rs delete mode 100644 src/test/ui/issues/issue-45107-unnecessary-unsafe-in-closure.thir.stderr delete mode 100644 src/test/ui/issues/issue-53912.rs delete mode 100644 src/test/ui/issues/issue-56685.rs delete mode 100644 src/test/ui/issues/issue-56685.stderr delete mode 100644 src/test/ui/issues/issue-57410.rs delete mode 100644 src/test/ui/issues/issue-5791.rs delete mode 100644 src/test/ui/issues/issue-5791.stderr delete mode 100644 src/test/ui/issues/issue-74614.rs delete mode 100644 src/test/ui/issues/issue-78720.rs delete mode 100644 src/test/ui/issues/issue-78720.stderr delete mode 100644 src/test/ui/issues/issue-79593.rs delete mode 100644 src/test/ui/issues/issue-79593.stderr delete mode 100644 src/test/ui/issues/issue-79744.rs delete mode 100644 src/test/ui/issues/issue-79744.stderr delete mode 100644 src/test/ui/issues/type-arg-mismatch-due-to-impl-trait.rs delete mode 100644 src/test/ui/issues/type-arg-mismatch-due-to-impl-trait.stderr create mode 100644 src/test/ui/lint/enable-unstable-lib-feature.rs create mode 100644 src/test/ui/lint/enable-unstable-lib-feature.stderr create mode 100644 src/test/ui/lint/issue-57410.rs create mode 100644 src/test/ui/lint/issue-79744.rs create mode 100644 src/test/ui/lint/issue-79744.stderr create mode 100644 src/test/ui/llvm-asm/issue-37433.rs create mode 100644 src/test/ui/llvm-asm/issue-37433.stderr create mode 100644 src/test/ui/macros/auxiliary/define-macro.rs create mode 100644 src/test/ui/macros/out-of-order-shadowing.rs create mode 100644 src/test/ui/macros/out-of-order-shadowing.stderr create mode 100644 src/test/ui/match/guards.rs create mode 100644 src/test/ui/match/issue-33498.rs create mode 100644 src/test/ui/match/issue-41255.rs create mode 100644 src/test/ui/match/issue-41255.stderr create mode 100644 src/test/ui/match/issue-56685.rs create mode 100644 src/test/ui/match/issue-56685.stderr delete mode 100644 src/test/ui/mid-path-type-params.rs create mode 100644 src/test/ui/never_type/expr-empty-ret.rs delete mode 100644 src/test/ui/out-of-order-shadowing.rs delete mode 100644 src/test/ui/out-of-order-shadowing.stderr create mode 100644 src/test/ui/polymorphization/issue-74614.rs create mode 100644 src/test/ui/privacy/issue-79593.rs create mode 100644 src/test/ui/privacy/issue-79593.stderr create mode 100644 src/test/ui/resolve/issue-42944.rs create mode 100644 src/test/ui/resolve/issue-42944.stderr create mode 100644 src/test/ui/resolve/use-self-in-inner-fn.rs create mode 100644 src/test/ui/resolve/use-self-in-inner-fn.stderr create mode 100644 src/test/ui/specialization/issue-35376.rs create mode 100644 src/test/ui/specialization/issue-35376.stderr create mode 100644 src/test/ui/static/issue-34194.rs create mode 100644 src/test/ui/structs-enums/issue-38002.rs create mode 100644 src/test/ui/symbol-names/issue-53912.rs create mode 100644 src/test/ui/test-attrs/issue-36768.rs create mode 100644 src/test/ui/thread-local/tls.rs delete mode 100644 src/test/ui/tls.rs create mode 100644 src/test/ui/traits/bug-7183-generics.rs create mode 100644 src/test/ui/traits/issue-20692.rs create mode 100644 src/test/ui/traits/issue-20692.stderr create mode 100644 src/test/ui/traits/issue-23825.rs create mode 100644 src/test/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.mir.stderr create mode 100644 src/test/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.rs create mode 100644 src/test/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.thir.stderr delete mode 100644 src/test/ui/use-self-in-inner-fn.rs delete mode 100644 src/test/ui/use-self-in-inner-fn.stderr (limited to 'src') diff --git a/src/test/ui/associated-types/issue-19883.rs b/src/test/ui/associated-types/issue-19883.rs new file mode 100644 index 00000000000..5cf422043a5 --- /dev/null +++ b/src/test/ui/associated-types/issue-19883.rs @@ -0,0 +1,16 @@ +trait From { + type Output; + + fn from(src: Src) -> >::Output; +} + +trait To: Sized { + fn to>(self) -> + >::Dst + //~^ ERROR cannot find associated type `Dst` in trait `From` + { + From::from(self) + } +} + +fn main() {} diff --git a/src/test/ui/associated-types/issue-19883.stderr b/src/test/ui/associated-types/issue-19883.stderr new file mode 100644 index 00000000000..bd6a86b7420 --- /dev/null +++ b/src/test/ui/associated-types/issue-19883.stderr @@ -0,0 +1,15 @@ +error[E0576]: cannot find associated type `Dst` in trait `From` + --> $DIR/issue-19883.rs:9:30 + | +LL | type Output; + | ------------ associated type `Output` defined here +... +LL | >::Dst + | ^^^ + | | + | not found in `From` + | help: maybe you meant this associated type: `Output` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0576`. diff --git a/src/test/ui/associated-types/issue-21363.rs b/src/test/ui/associated-types/issue-21363.rs new file mode 100644 index 00000000000..acc28cb430b --- /dev/null +++ b/src/test/ui/associated-types/issue-21363.rs @@ -0,0 +1,15 @@ +// check-pass +// pretty-expanded FIXME #23616 + +#![no_implicit_prelude] + +trait Iterator { + type Item; + fn dummy(&self) { } +} + +impl<'a, T> Iterator for &'a mut (dyn Iterator + 'a) { + type Item = T; +} + +fn main() {} diff --git a/src/test/ui/async-await/auxiliary/issue-72470-lib.rs b/src/test/ui/async-await/auxiliary/issue-72470-lib.rs new file mode 100644 index 00000000000..8383eba8912 --- /dev/null +++ b/src/test/ui/async-await/auxiliary/issue-72470-lib.rs @@ -0,0 +1,175 @@ +// compile-flags: -C opt-level=3 +// edition:2018 + +use std::future::Future; +use std::marker::PhantomData; +use std::pin::Pin; +use std::sync::atomic::AtomicUsize; +use std::sync::Arc; +use std::task::Poll::{Pending, Ready}; +use std::task::Waker; +use std::task::{Context, Poll}; +use std::{ + ptr, + task::{RawWaker, RawWakerVTable}, +}; + +/// Future for the [`poll_fn`] function. +pub struct PollFn { + f: F, +} + +impl Unpin for PollFn {} + +/// Creates a new future wrapping around a function returning [`Poll`]. +pub fn poll_fn(f: F) -> PollFn +where + F: FnMut(&mut Context<'_>) -> Poll, +{ + PollFn { f } +} + +impl Future for PollFn +where + F: FnMut(&mut Context<'_>) -> Poll, +{ + type Output = T; + + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + (&mut self.f)(cx) + } +} +pub fn run(future: F) -> F::Output { + BasicScheduler.block_on(future) +} + +pub(crate) struct BasicScheduler; + +impl BasicScheduler { + pub(crate) fn block_on(&mut self, mut future: F) -> F::Output + where + F: Future, + { + let waker = unsafe { Waker::from_raw(raw_waker()) }; + let mut cx = std::task::Context::from_waker(&waker); + + let mut future = unsafe { Pin::new_unchecked(&mut future) }; + + loop { + if let Ready(v) = future.as_mut().poll(&mut cx) { + return v; + } + } + } +} + +// ===== impl Spawner ===== + +fn raw_waker() -> RawWaker { + RawWaker::new(ptr::null(), waker_vtable()) +} + +fn waker_vtable() -> &'static RawWakerVTable { + &RawWakerVTable::new( + clone_arc_raw, + wake_arc_raw, + wake_by_ref_arc_raw, + drop_arc_raw, + ) +} + +unsafe fn clone_arc_raw(_: *const ()) -> RawWaker { + raw_waker() +} + +unsafe fn wake_arc_raw(_: *const ()) {} + +unsafe fn wake_by_ref_arc_raw(_: *const ()) {} + +unsafe fn drop_arc_raw(_: *const ()) {} + +struct AtomicWaker {} + +impl AtomicWaker { + /// Create an `AtomicWaker` + fn new() -> AtomicWaker { + AtomicWaker {} + } + + fn register_by_ref(&self, _waker: &Waker) {} +} + +#[allow(dead_code)] +struct Tx { + inner: Arc>, +} + +struct Rx { + inner: Arc>, +} + +#[allow(dead_code)] +struct Chan { + tx: PhantomData, + semaphore: Sema, + rx_waker: AtomicWaker, + rx_closed: bool, +} + +fn channel() -> (Tx, Rx) { + let chan = Arc::new(Chan { + tx: PhantomData, + semaphore: Sema(AtomicUsize::new(0)), + rx_waker: AtomicWaker::new(), + rx_closed: false, + }); + + ( + Tx { + inner: chan.clone(), + }, + Rx { inner: chan }, + ) +} + +// ===== impl Rx ===== + +impl Rx { + /// Receive the next value + fn recv(&mut self, cx: &mut Context<'_>) -> Poll> { + self.inner.rx_waker.register_by_ref(cx.waker()); + + if self.inner.rx_closed && self.inner.semaphore.is_idle() { + Ready(None) + } else { + Pending + } + } +} + +struct Sema(AtomicUsize); + +impl Sema { + fn is_idle(&self) -> bool { + false + } +} + +pub struct UnboundedReceiver { + chan: Rx, +} + +pub fn unbounded_channel() -> UnboundedReceiver { + let (tx, rx) = channel(); + + drop(tx); + let rx = UnboundedReceiver { chan: rx }; + + rx +} + +impl UnboundedReceiver { + pub async fn recv(&mut self) -> Option { + poll_fn(|cx| self.chan.recv(cx)).await + } +} diff --git a/src/test/ui/async-await/issue-72470-llvm-dominate.rs b/src/test/ui/async-await/issue-72470-llvm-dominate.rs new file mode 100644 index 00000000000..5bb69a07305 --- /dev/null +++ b/src/test/ui/async-await/issue-72470-llvm-dominate.rs @@ -0,0 +1,66 @@ +// compile-flags: -C opt-level=3 +// aux-build: issue-72470-lib.rs +// edition:2018 +// build-pass + +// Regression test for issue #72470, using the minimization +// in https://github.com/jonas-schievink/llvm-error + +extern crate issue_72470_lib; + +use std::future::Future; +use std::pin::Pin; +use std::sync::Mutex; +use std::task::Poll::{Pending, Ready}; + +#[allow(dead_code)] +enum Msg { + A(Vec<()>), + B, +} + +#[allow(dead_code)] +enum Out { + _0(Option), + Disabled, +} + +#[allow(unused_must_use)] +fn main() { + let mut rx = issue_72470_lib::unbounded_channel::(); + let entity = Mutex::new(()); + issue_72470_lib::run(async move { + { + let output = { + let mut fut = rx.recv(); + issue_72470_lib::poll_fn(|cx| { + loop { + let fut = unsafe { Pin::new_unchecked(&mut fut) }; + let out = match fut.poll(cx) { + Ready(out) => out, + Pending => { + break; + } + }; + #[allow(unused_variables)] + match &out { + Some(_msg) => {} + _ => break, + } + return Ready(Out::_0(out)); + } + Ready(Out::_0(None)) + }) + .await + }; + match output { + Out::_0(Some(_msg)) => { + entity.lock(); + } + Out::_0(None) => unreachable!(), + _ => unreachable!(), + } + } + entity.lock(); + }); +} diff --git a/src/test/ui/auxiliary/define-macro.rs b/src/test/ui/auxiliary/define-macro.rs deleted file mode 100644 index 4956907c55e..00000000000 --- a/src/test/ui/auxiliary/define-macro.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[macro_export] -macro_rules! define_macro { - ($i:ident) => { - macro_rules! $i { () => {} } - } -} diff --git a/src/test/ui/auxiliary/issue-72470-lib.rs b/src/test/ui/auxiliary/issue-72470-lib.rs deleted file mode 100644 index 8383eba8912..00000000000 --- a/src/test/ui/auxiliary/issue-72470-lib.rs +++ /dev/null @@ -1,175 +0,0 @@ -// compile-flags: -C opt-level=3 -// edition:2018 - -use std::future::Future; -use std::marker::PhantomData; -use std::pin::Pin; -use std::sync::atomic::AtomicUsize; -use std::sync::Arc; -use std::task::Poll::{Pending, Ready}; -use std::task::Waker; -use std::task::{Context, Poll}; -use std::{ - ptr, - task::{RawWaker, RawWakerVTable}, -}; - -/// Future for the [`poll_fn`] function. -pub struct PollFn { - f: F, -} - -impl Unpin for PollFn {} - -/// Creates a new future wrapping around a function returning [`Poll`]. -pub fn poll_fn(f: F) -> PollFn -where - F: FnMut(&mut Context<'_>) -> Poll, -{ - PollFn { f } -} - -impl Future for PollFn -where - F: FnMut(&mut Context<'_>) -> Poll, -{ - type Output = T; - - fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - (&mut self.f)(cx) - } -} -pub fn run(future: F) -> F::Output { - BasicScheduler.block_on(future) -} - -pub(crate) struct BasicScheduler; - -impl BasicScheduler { - pub(crate) fn block_on(&mut self, mut future: F) -> F::Output - where - F: Future, - { - let waker = unsafe { Waker::from_raw(raw_waker()) }; - let mut cx = std::task::Context::from_waker(&waker); - - let mut future = unsafe { Pin::new_unchecked(&mut future) }; - - loop { - if let Ready(v) = future.as_mut().poll(&mut cx) { - return v; - } - } - } -} - -// ===== impl Spawner ===== - -fn raw_waker() -> RawWaker { - RawWaker::new(ptr::null(), waker_vtable()) -} - -fn waker_vtable() -> &'static RawWakerVTable { - &RawWakerVTable::new( - clone_arc_raw, - wake_arc_raw, - wake_by_ref_arc_raw, - drop_arc_raw, - ) -} - -unsafe fn clone_arc_raw(_: *const ()) -> RawWaker { - raw_waker() -} - -unsafe fn wake_arc_raw(_: *const ()) {} - -unsafe fn wake_by_ref_arc_raw(_: *const ()) {} - -unsafe fn drop_arc_raw(_: *const ()) {} - -struct AtomicWaker {} - -impl AtomicWaker { - /// Create an `AtomicWaker` - fn new() -> AtomicWaker { - AtomicWaker {} - } - - fn register_by_ref(&self, _waker: &Waker) {} -} - -#[allow(dead_code)] -struct Tx { - inner: Arc>, -} - -struct Rx { - inner: Arc>, -} - -#[allow(dead_code)] -struct Chan { - tx: PhantomData, - semaphore: Sema, - rx_waker: AtomicWaker, - rx_closed: bool, -} - -fn channel() -> (Tx, Rx) { - let chan = Arc::new(Chan { - tx: PhantomData, - semaphore: Sema(AtomicUsize::new(0)), - rx_waker: AtomicWaker::new(), - rx_closed: false, - }); - - ( - Tx { - inner: chan.clone(), - }, - Rx { inner: chan }, - ) -} - -// ===== impl Rx ===== - -impl Rx { - /// Receive the next value - fn recv(&mut self, cx: &mut Context<'_>) -> Poll> { - self.inner.rx_waker.register_by_ref(cx.waker()); - - if self.inner.rx_closed && self.inner.semaphore.is_idle() { - Ready(None) - } else { - Pending - } - } -} - -struct Sema(AtomicUsize); - -impl Sema { - fn is_idle(&self) -> bool { - false - } -} - -pub struct UnboundedReceiver { - chan: Rx, -} - -pub fn unbounded_channel() -> UnboundedReceiver { - let (tx, rx) = channel(); - - drop(tx); - let rx = UnboundedReceiver { chan: rx }; - - rx -} - -impl UnboundedReceiver { - pub async fn recv(&mut self) -> Option { - poll_fn(|cx| self.chan.recv(cx)).await - } -} diff --git a/src/test/ui/bug-7183-generics.rs b/src/test/ui/bug-7183-generics.rs deleted file mode 100644 index f53a1736127..00000000000 --- a/src/test/ui/bug-7183-generics.rs +++ /dev/null @@ -1,36 +0,0 @@ -// run-pass - -trait Speak : Sized { - fn say(&self, s:&str) -> String; - fn hi(&self) -> String { hello(self) } -} - -fn hello(s:&S) -> String{ - s.say("hello") -} - -impl Speak for isize { - fn say(&self, s:&str) -> String { - format!("{}: {}", s, *self) - } -} - -impl Speak for Option { - fn say(&self, s:&str) -> String { - match *self { - None => format!("{} - none", s), - Some(ref x) => { format!("something!{}", x.say(s)) } - } - } -} - - -pub fn main() { - assert_eq!(3.hi(), "hello: 3".to_string()); - assert_eq!(Some(Some(3)).hi(), - "something!something!hello: 3".to_string()); - assert_eq!(None::.hi(), "hello - none".to_string()); - - assert_eq!(Some(None::).hi(), "something!hello - none".to_string()); - assert_eq!(Some(3).hi(), "something!hello: 3".to_string()); -} diff --git a/src/test/ui/closures/issue-78720.rs b/src/test/ui/closures/issue-78720.rs new file mode 100644 index 00000000000..4cdb9f49113 --- /dev/null +++ b/src/test/ui/closures/issue-78720.rs @@ -0,0 +1,19 @@ +fn server() -> impl { +//~^ ERROR at least one trait must be specified + ().map2(|| "") +} + +trait FilterBase2 { + fn map2(self, f: F) -> Map2 {} + //~^ ERROR mismatched types + //~^^ ERROR the size for values of type `Self` cannot be known at compilation time +} + +struct Map2 { + _func: F, + //~^ ERROR cannot find type `F` in this scope +} + +impl FilterBase2 for F {} + +fn main() {} diff --git a/src/test/ui/closures/issue-78720.stderr b/src/test/ui/closures/issue-78720.stderr new file mode 100644 index 00000000000..3dd13877298 --- /dev/null +++ b/src/test/ui/closures/issue-78720.stderr @@ -0,0 +1,55 @@ +error: at least one trait must be specified + --> $DIR/issue-78720.rs:1:16 + | +LL | fn server() -> impl { + | ^^^^ + +error[E0412]: cannot find type `F` in this scope + --> $DIR/issue-78720.rs:13:12 + | +LL | _func: F, + | ^ + | + ::: $SRC_DIR/core/src/ops/function.rs:LL:COL + | +LL | pub trait Fn: FnMut { + | ------------------------------- similarly named trait `Fn` defined here + | +help: a trait with a similar name exists + | +LL | _func: Fn, + | ~~ +help: you might be missing a type parameter + | +LL | struct Map2 { + | +++ + +error[E0308]: mismatched types + --> $DIR/issue-78720.rs:7:39 + | +LL | fn map2(self, f: F) -> Map2 {} + | ^^ expected struct `Map2`, found `()` + | + = note: expected struct `Map2` + found unit type `()` + +error[E0277]: the size for values of type `Self` cannot be known at compilation time + --> $DIR/issue-78720.rs:7:16 + | +LL | fn map2(self, f: F) -> Map2 {} + | ^^^^ doesn't have a size known at compile-time + | + = help: unsized fn params are gated as an unstable feature +help: consider further restricting `Self` + | +LL | fn map2(self, f: F) -> Map2 where Self: Sized {} + | +++++++++++++++++ +help: function arguments must have a statically known size, borrowed types always have a known size + | +LL | fn map2(&self, f: F) -> Map2 {} + | + + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0277, E0308, E0412. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/consts/issue-23833.rs b/src/test/ui/consts/issue-23833.rs new file mode 100644 index 00000000000..d4128fa54e3 --- /dev/null +++ b/src/test/ui/consts/issue-23833.rs @@ -0,0 +1,15 @@ +// run-pass +#![allow(unused_imports)] +use std::fmt; + +const A_I8_T + : [u32; (i8::MAX as i8 - 1i8) as usize] + = [0; (i8::MAX as usize) - 1]; + +fn main() { + foo(&A_I8_T[..]); +} + +fn foo(x: T) { + println!("{:?}", x); +} diff --git a/src/test/ui/consts/issue-34784.rs b/src/test/ui/consts/issue-34784.rs new file mode 100644 index 00000000000..98d943470a7 --- /dev/null +++ b/src/test/ui/consts/issue-34784.rs @@ -0,0 +1,21 @@ +// run-pass + +#![warn(pointer_structural_match)] +#![allow(dead_code)] +const C: *const u8 = &0; + +fn foo(x: *const u8) { + match x { + C => {} + _ => {} + } +} + +const D: *const [u8; 4] = b"abcd"; + +fn main() { + match D { + D => {} + _ => {} + } +} diff --git a/src/test/ui/deriving/issue-3935.rs b/src/test/ui/deriving/issue-3935.rs new file mode 100644 index 00000000000..e98d68e0eb2 --- /dev/null +++ b/src/test/ui/deriving/issue-3935.rs @@ -0,0 +1,13 @@ +// run-pass + +#[derive(PartialEq)] +struct Bike { + name: String, +} + +pub fn main() { + let town_bike = Bike { name: "schwinn".to_string() }; + let my_bike = Bike { name: "surly".to_string() }; + + assert!(town_bike != my_bike); +} diff --git a/src/test/ui/enable-unstable-lib-feature.rs b/src/test/ui/enable-unstable-lib-feature.rs deleted file mode 100644 index aa6a973d7bd..00000000000 --- a/src/test/ui/enable-unstable-lib-feature.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Test that enabling an unstable feature disables warnings - -// aux-build:stability-cfg2.rs - -#![feature(unstable_test_feature)] -#![deny(non_snake_case)] // To trigger a hard error - -// Shouldn't generate a warning about unstable features -extern crate stability_cfg2; - -pub fn BOGUS() { } //~ ERROR - -pub fn main() { } diff --git a/src/test/ui/enable-unstable-lib-feature.stderr b/src/test/ui/enable-unstable-lib-feature.stderr deleted file mode 100644 index bb4e928ad15..00000000000 --- a/src/test/ui/enable-unstable-lib-feature.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: function `BOGUS` should have a snake case name - --> $DIR/enable-unstable-lib-feature.rs:11:8 - | -LL | pub fn BOGUS() { } - | ^^^^^ help: convert the identifier to snake case: `bogus` - | -note: the lint level is defined here - --> $DIR/enable-unstable-lib-feature.rs:6:9 - | -LL | #![deny(non_snake_case)] // To trigger a hard error - | ^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/expr-empty-ret.rs b/src/test/ui/expr-empty-ret.rs deleted file mode 100644 index ce8ffaf94d0..00000000000 --- a/src/test/ui/expr-empty-ret.rs +++ /dev/null @@ -1,15 +0,0 @@ -// run-pass - -#![allow(dead_code)] -// Issue #521 - -// pretty-expanded FIXME #23616 - -fn f() { - let _x = match true { - true => { 10 } - false => { return } - }; -} - -pub fn main() { } diff --git a/src/test/ui/generics/mid-path-type-params.rs b/src/test/ui/generics/mid-path-type-params.rs new file mode 100644 index 00000000000..a8128207c80 --- /dev/null +++ b/src/test/ui/generics/mid-path-type-params.rs @@ -0,0 +1,37 @@ +// run-pass + +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +struct S { + contents: T, +} + +impl S { + fn new(x: T, _: U) -> S { + S { + contents: x, + } + } +} + +trait Trait { + fn new(x: T, y: U) -> Self; +} + +struct S2 { + contents: isize, +} + +impl Trait for S2 { + fn new(x: isize, _: U) -> S2 { + S2 { + contents: x, + } + } +} + +pub fn main() { + let _ = S::::new::(1, 1.0); + let _: S2 = Trait::::new::(1, 1.0); +} diff --git a/src/test/ui/guards.rs b/src/test/ui/guards.rs deleted file mode 100644 index 10a4bb67387..00000000000 --- a/src/test/ui/guards.rs +++ /dev/null @@ -1,20 +0,0 @@ -// run-pass - -#![allow(non_shorthand_field_patterns)] - -#[derive(Copy, Clone)] -struct Pair { x: isize, y: isize } - -pub fn main() { - let a: isize = - match 10 { x if x < 7 => { 1 } x if x < 11 => { 2 } 10 => { 3 } _ => { 4 } }; - assert_eq!(a, 2); - - let b: isize = - match (Pair {x: 10, y: 20}) { - x if x.x < 5 && x.y < 5 => { 1 } - Pair {x: x, y: y} if x == 10 && y == 20 => { 2 } - Pair {x: _x, y: _y} => { 3 } - }; - assert_eq!(b, 2); -} diff --git a/src/test/ui/impl-trait/type-arg-mismatch-due-to-impl-trait.rs b/src/test/ui/impl-trait/type-arg-mismatch-due-to-impl-trait.rs new file mode 100644 index 00000000000..ecfa5c69e2f --- /dev/null +++ b/src/test/ui/impl-trait/type-arg-mismatch-due-to-impl-trait.rs @@ -0,0 +1,16 @@ +trait Foo { + type T; + fn foo(&self, t: Self::T); +//~^ NOTE expected 0 type parameters +} + +impl Foo for u32 { + type T = (); + + fn foo(&self, t: impl Clone) {} +//~^ ERROR method `foo` has 1 type parameter but its trait declaration has 0 type parameters +//~| NOTE found 1 type parameter +//~| NOTE `impl Trait` introduces an implicit type parameter +} + +fn main() {} diff --git a/src/test/ui/impl-trait/type-arg-mismatch-due-to-impl-trait.stderr b/src/test/ui/impl-trait/type-arg-mismatch-due-to-impl-trait.stderr new file mode 100644 index 00000000000..30322f88cca --- /dev/null +++ b/src/test/ui/impl-trait/type-arg-mismatch-due-to-impl-trait.stderr @@ -0,0 +1,15 @@ +error[E0049]: method `foo` has 1 type parameter but its trait declaration has 0 type parameters + --> $DIR/type-arg-mismatch-due-to-impl-trait.rs:10:22 + | +LL | fn foo(&self, t: Self::T); + | - expected 0 type parameters +... +LL | fn foo(&self, t: impl Clone) {} + | ^^^^^^^^^^ + | | + | found 1 type parameter + | `impl Trait` introduces an implicit type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0049`. diff --git a/src/test/ui/issue-72470-llvm-dominate.rs b/src/test/ui/issue-72470-llvm-dominate.rs deleted file mode 100644 index 5bb69a07305..00000000000 --- a/src/test/ui/issue-72470-llvm-dominate.rs +++ /dev/null @@ -1,66 +0,0 @@ -// compile-flags: -C opt-level=3 -// aux-build: issue-72470-lib.rs -// edition:2018 -// build-pass - -// Regression test for issue #72470, using the minimization -// in https://github.com/jonas-schievink/llvm-error - -extern crate issue_72470_lib; - -use std::future::Future; -use std::pin::Pin; -use std::sync::Mutex; -use std::task::Poll::{Pending, Ready}; - -#[allow(dead_code)] -enum Msg { - A(Vec<()>), - B, -} - -#[allow(dead_code)] -enum Out { - _0(Option), - Disabled, -} - -#[allow(unused_must_use)] -fn main() { - let mut rx = issue_72470_lib::unbounded_channel::(); - let entity = Mutex::new(()); - issue_72470_lib::run(async move { - { - let output = { - let mut fut = rx.recv(); - issue_72470_lib::poll_fn(|cx| { - loop { - let fut = unsafe { Pin::new_unchecked(&mut fut) }; - let out = match fut.poll(cx) { - Ready(out) => out, - Pending => { - break; - } - }; - #[allow(unused_variables)] - match &out { - Some(_msg) => {} - _ => break, - } - return Ready(Out::_0(out)); - } - Ready(Out::_0(None)) - }) - .await - }; - match output { - Out::_0(Some(_msg)) => { - entity.lock(); - } - Out::_0(None) => unreachable!(), - _ => unreachable!(), - } - } - entity.lock(); - }); -} diff --git a/src/test/ui/issues/issue-19883.rs b/src/test/ui/issues/issue-19883.rs deleted file mode 100644 index 5cf422043a5..00000000000 --- a/src/test/ui/issues/issue-19883.rs +++ /dev/null @@ -1,16 +0,0 @@ -trait From { - type Output; - - fn from(src: Src) -> >::Output; -} - -trait To: Sized { - fn to>(self) -> - >::Dst - //~^ ERROR cannot find associated type `Dst` in trait `From` - { - From::from(self) - } -} - -fn main() {} diff --git a/src/test/ui/issues/issue-19883.stderr b/src/test/ui/issues/issue-19883.stderr deleted file mode 100644 index bd6a86b7420..00000000000 --- a/src/test/ui/issues/issue-19883.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0576]: cannot find associated type `Dst` in trait `From` - --> $DIR/issue-19883.rs:9:30 - | -LL | type Output; - | ------------ associated type `Output` defined here -... -LL | >::Dst - | ^^^ - | | - | not found in `From` - | help: maybe you meant this associated type: `Output` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0576`. diff --git a/src/test/ui/issues/issue-20692.rs b/src/test/ui/issues/issue-20692.rs deleted file mode 100644 index 1cb2d8c7302..00000000000 --- a/src/test/ui/issues/issue-20692.rs +++ /dev/null @@ -1,11 +0,0 @@ -trait Array: Sized + Copy {} - -fn f(x: &T) { - let _ = x - //~^ ERROR `Array` cannot be made into an object - as - &dyn Array; - //~^ ERROR `Array` cannot be made into an object -} - -fn main() {} diff --git a/src/test/ui/issues/issue-20692.stderr b/src/test/ui/issues/issue-20692.stderr deleted file mode 100644 index 1d7f252e556..00000000000 --- a/src/test/ui/issues/issue-20692.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0038]: the trait `Array` cannot be made into an object - --> $DIR/issue-20692.rs:7:5 - | -LL | &dyn Array; - | ^^^^^^^^^^ `Array` cannot be made into an object - | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/issue-20692.rs:1:14 - | -LL | trait Array: Sized + Copy {} - | ----- ^^^^^ ^^^^ ...because it requires `Self: Sized` - | | | - | | ...because it requires `Self: Sized` - | this trait cannot be made into an object... - -error[E0038]: the trait `Array` cannot be made into an object - --> $DIR/issue-20692.rs:4:13 - | -LL | let _ = x - | ^ `Array` cannot be made into an object - | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/issue-20692.rs:1:14 - | -LL | trait Array: Sized + Copy {} - | ----- ^^^^^ ^^^^ ...because it requires `Self: Sized` - | | | - | | ...because it requires `Self: Sized` - | this trait cannot be made into an object... - = note: required because of the requirements on the impl of `CoerceUnsized<&dyn Array>` for `&T` - = note: required by cast to type `&dyn Array` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/issues/issue-21363.rs b/src/test/ui/issues/issue-21363.rs deleted file mode 100644 index acc28cb430b..00000000000 --- a/src/test/ui/issues/issue-21363.rs +++ /dev/null @@ -1,15 +0,0 @@ -// check-pass -// pretty-expanded FIXME #23616 - -#![no_implicit_prelude] - -trait Iterator { - type Item; - fn dummy(&self) { } -} - -impl<'a, T> Iterator for &'a mut (dyn Iterator + 'a) { - type Item = T; -} - -fn main() {} diff --git a/src/test/ui/issues/issue-23825.rs b/src/test/ui/issues/issue-23825.rs deleted file mode 100644 index a9f0095d2e2..00000000000 --- a/src/test/ui/issues/issue-23825.rs +++ /dev/null @@ -1,21 +0,0 @@ -// run-pass -trait Stringify { - fn to_string(&self) -> String; -} - -impl Stringify for u32 { - fn to_string(&self) -> String { format!("u32: {}", *self) } -} - -impl Stringify for f32 { - fn to_string(&self) -> String { format!("f32: {}", *self) } -} - -fn print(x: T) -> String { - x.to_string() -} - -fn main() { - assert_eq!(&print(5), "u32: 5"); - assert_eq!(&print(5.0), "f32: 5"); -} diff --git a/src/test/ui/issues/issue-23833.rs b/src/test/ui/issues/issue-23833.rs deleted file mode 100644 index d4128fa54e3..00000000000 --- a/src/test/ui/issues/issue-23833.rs +++ /dev/null @@ -1,15 +0,0 @@ -// run-pass -#![allow(unused_imports)] -use std::fmt; - -const A_I8_T - : [u32; (i8::MAX as i8 - 1i8) as usize] - = [0; (i8::MAX as usize) - 1]; - -fn main() { - foo(&A_I8_T[..]); -} - -fn foo(x: T) { - println!("{:?}", x); -} diff --git a/src/test/ui/issues/issue-33498.rs b/src/test/ui/issues/issue-33498.rs deleted file mode 100644 index 9c8a97e7e6b..00000000000 --- a/src/test/ui/issues/issue-33498.rs +++ /dev/null @@ -1,11 +0,0 @@ -// run-pass -#![allow(unused_variables)] -pub fn main() { - let x = (0, 2); - - match x { - (0, ref y) => {} - (y, 0) => {} - _ => (), - } -} diff --git a/src/test/ui/issues/issue-34194.rs b/src/test/ui/issues/issue-34194.rs deleted file mode 100644 index 6dce556e9e3..00000000000 --- a/src/test/ui/issues/issue-34194.rs +++ /dev/null @@ -1,11 +0,0 @@ -// build-pass -#![allow(dead_code)] - -struct A { - a: &'static (), -} - -static B: &'static A = &A { a: &() }; -static C: &'static A = &B; - -fn main() {} diff --git a/src/test/ui/issues/issue-34784.rs b/src/test/ui/issues/issue-34784.rs deleted file mode 100644 index 98d943470a7..00000000000 --- a/src/test/ui/issues/issue-34784.rs +++ /dev/null @@ -1,21 +0,0 @@ -// run-pass - -#![warn(pointer_structural_match)] -#![allow(dead_code)] -const C: *const u8 = &0; - -fn foo(x: *const u8) { - match x { - C => {} - _ => {} - } -} - -const D: *const [u8; 4] = b"abcd"; - -fn main() { - match D { - D => {} - _ => {} - } -} diff --git a/src/test/ui/issues/issue-35376.rs b/src/test/ui/issues/issue-35376.rs deleted file mode 100644 index cc35213b93d..00000000000 --- a/src/test/ui/issues/issue-35376.rs +++ /dev/null @@ -1,43 +0,0 @@ -// check-pass -#![feature(specialization)] -//~^ WARN the feature `specialization` is incomplete - -fn main() {} - -pub trait Alpha { } - -pub trait Beta { - type Event; -} - -pub trait Delta { - type Handle; - fn process(&self); -} - -pub struct Parent(A, T); - -impl Delta for Parent -where A: Alpha, - T: Delta, - T::Handle: Beta::Event> { - type Handle = Handle; - default fn process(&self) { - unimplemented!() - } -} - -impl Delta for Parent -where A: Alpha + Alpha, - T: Delta, - T::Handle: Beta::Event> { - fn process(&self) { - unimplemented!() - } -} - -pub struct Handle; - -impl Beta for Handle { - type Event = (); -} diff --git a/src/test/ui/issues/issue-35376.stderr b/src/test/ui/issues/issue-35376.stderr deleted file mode 100644 index 835277d408e..00000000000 --- a/src/test/ui/issues/issue-35376.stderr +++ /dev/null @@ -1,12 +0,0 @@ -warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-35376.rs:2:12 - | -LL | #![feature(specialization)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #31844 for more information - = help: consider using `min_specialization` instead, which is more stable and complete - -warning: 1 warning emitted - diff --git a/src/test/ui/issues/issue-36768.rs b/src/test/ui/issues/issue-36768.rs deleted file mode 100644 index f671cbc8205..00000000000 --- a/src/test/ui/issues/issue-36768.rs +++ /dev/null @@ -1,9 +0,0 @@ -// run-pass -// compile-flags:--test -#![deny(private_in_public)] - -#[test] fn foo() {} -mod foo {} - -#[test] fn core() {} -extern crate core; diff --git a/src/test/ui/issues/issue-37433.rs b/src/test/ui/issues/issue-37433.rs deleted file mode 100644 index 1c362e8aba0..00000000000 --- a/src/test/ui/issues/issue-37433.rs +++ /dev/null @@ -1,12 +0,0 @@ -// build-fail -// ignore-emscripten no llvm_asm! support - -#![feature(llvm_asm)] -#![allow(deprecated)] // llvm_asm! - -fn main() { - unsafe { - llvm_asm!("" :: "r"("")); - //~^ ERROR: invalid value for constraint in inline assembly - } -} diff --git a/src/test/ui/issues/issue-37433.stderr b/src/test/ui/issues/issue-37433.stderr deleted file mode 100644 index 44a8eb32b7c..00000000000 --- a/src/test/ui/issues/issue-37433.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0669]: invalid value for constraint in inline assembly - --> $DIR/issue-37433.rs:9:29 - | -LL | llvm_asm!("" :: "r"("")); - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0669`. diff --git a/src/test/ui/issues/issue-38002.rs b/src/test/ui/issues/issue-38002.rs deleted file mode 100644 index fdb31fc44a1..00000000000 --- a/src/test/ui/issues/issue-38002.rs +++ /dev/null @@ -1,35 +0,0 @@ -// run-pass -#![allow(dead_code)] -// Check that constant ADTs are codegened OK, part k of N. - -enum Bar { - C -} - -enum Foo { - A {}, - B { - y: usize, - z: Bar - }, -} - -const LIST: [(usize, Foo); 2] = [ - (51, Foo::B { y: 42, z: Bar::C }), - (52, Foo::B { y: 45, z: Bar::C }), -]; - -pub fn main() { - match LIST { - [ - (51, Foo::B { y: 42, z: Bar::C }), - (52, Foo::B { y: 45, z: Bar::C }) - ] => {} - _ => { - // I would want to print the enum here, but if - // the discriminant is garbage this causes an - // `unreachable` and silent process exit. - panic!("trivial match failed") - } - } -} diff --git a/src/test/ui/issues/issue-3935.rs b/src/test/ui/issues/issue-3935.rs deleted file mode 100644 index e98d68e0eb2..00000000000 --- a/src/test/ui/issues/issue-3935.rs +++ /dev/null @@ -1,13 +0,0 @@ -// run-pass - -#[derive(PartialEq)] -struct Bike { - name: String, -} - -pub fn main() { - let town_bike = Bike { name: "schwinn".to_string() }; - let my_bike = Bike { name: "surly".to_string() }; - - assert!(town_bike != my_bike); -} diff --git a/src/test/ui/issues/issue-41255.rs b/src/test/ui/issues/issue-41255.rs deleted file mode 100644 index 9d7072f1665..00000000000 --- a/src/test/ui/issues/issue-41255.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Matching against float literals should result in a linter error - -#![feature(exclusive_range_pattern)] -#![feature(half_open_range_patterns)] -#![allow(unused)] -#![forbid(illegal_floating_point_literal_pattern)] - -fn main() { - let x = 42.0; - match x { - 5.0 => {}, //~ ERROR floating-point types cannot be used in patterns - //~| WARNING hard error - 5.0f32 => {}, //~ ERROR floating-point types cannot be used in patterns - //~| WARNING hard error - -5.0 => {}, //~ ERROR floating-point types cannot be used in patterns - //~| WARNING hard error - 1.0 .. 33.0 => {}, //~ ERROR floating-point types cannot be used in patterns - //~| WARNING hard error - //~| ERROR floating-point types cannot be used in patterns - //~| WARNING hard error - 39.0 ..= 70.0 => {}, //~ ERROR floating-point types cannot be used in patterns - //~| ERROR floating-point types cannot be used in patterns - //~| WARNING hard error - //~| WARNING hard error - - ..71.0 => {} - //~^ ERROR floating-point types cannot be used in patterns - //~| WARNING this was previously accepted by the compiler - ..=72.0 => {} - //~^ ERROR floating-point types cannot be used in patterns - //~| WARNING this was previously accepted by the compiler - 71.0.. => {} - //~^ ERROR floating-point types cannot be used in patterns - //~| WARNING this was previously accepted by the compiler - _ => {}, - }; - let y = 5.0; - // Same for tuples - match (x, 5) { - (3.14, 1) => {}, //~ ERROR floating-point types cannot be used - //~| WARNING hard error - _ => {}, - } - // Or structs - struct Foo { x: f32 }; - match (Foo { x }) { - Foo { x: 2.0 } => {}, //~ ERROR floating-point types cannot be used - //~| WARNING hard error - _ => {}, - } -} diff --git a/src/test/ui/issues/issue-41255.stderr b/src/test/ui/issues/issue-41255.stderr deleted file mode 100644 index bf81c8d371c..00000000000 --- a/src/test/ui/issues/issue-41255.stderr +++ /dev/null @@ -1,115 +0,0 @@ -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:11:9 - | -LL | 5.0 => {}, - | ^^^ - | -note: the lint level is defined here - --> $DIR/issue-41255.rs:6:11 - | -LL | #![forbid(illegal_floating_point_literal_pattern)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:13:9 - | -LL | 5.0f32 => {}, - | ^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:15:10 - | -LL | -5.0 => {}, - | ^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:17:9 - | -LL | 1.0 .. 33.0 => {}, - | ^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:17:16 - | -LL | 1.0 .. 33.0 => {}, - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:21:9 - | -LL | 39.0 ..= 70.0 => {}, - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:21:18 - | -LL | 39.0 ..= 70.0 => {}, - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:26:11 - | -LL | ..71.0 => {} - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:29:12 - | -LL | ..=72.0 => {} - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:32:9 - | -LL | 71.0.. => {} - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:40:10 - | -LL | (3.14, 1) => {}, - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 - -error: floating-point types cannot be used in patterns - --> $DIR/issue-41255.rs:47:18 - | -LL | Foo { x: 2.0 } => {}, - | ^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #41620 - -error: aborting due to 12 previous errors - diff --git a/src/test/ui/issues/issue-42944.rs b/src/test/ui/issues/issue-42944.rs deleted file mode 100644 index a4404857a56..00000000000 --- a/src/test/ui/issues/issue-42944.rs +++ /dev/null @@ -1,21 +0,0 @@ -mod foo { - pub struct Bx(()); -} - -mod bar { - use foo::Bx; - - fn foo() { - Bx(()); - //~^ ERROR cannot initialize a tuple struct which contains private fields [E0423] - } -} - -mod baz { - fn foo() { - Bx(()); - //~^ ERROR cannot find function, tuple struct or tuple variant `Bx` in this scope [E0425] - } -} - -fn main() {} diff --git a/src/test/ui/issues/issue-42944.stderr b/src/test/ui/issues/issue-42944.stderr deleted file mode 100644 index 008492529d1..00000000000 --- a/src/test/ui/issues/issue-42944.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0423]: cannot initialize a tuple struct which contains private fields - --> $DIR/issue-42944.rs:9:9 - | -LL | Bx(()); - | ^^ - | -note: constructor is not visible here due to private fields - --> $DIR/issue-42944.rs:2:19 - | -LL | pub struct Bx(()); - | ^^ private field - -error[E0425]: cannot find function, tuple struct or tuple variant `Bx` in this scope - --> $DIR/issue-42944.rs:16:9 - | -LL | Bx(()); - | ^^ not found in this scope - | -help: consider importing this tuple struct - | -LL | use foo::Bx; - | - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0423, E0425. -For more information about an error, try `rustc --explain E0423`. diff --git a/src/test/ui/issues/issue-45107-unnecessary-unsafe-in-closure.mir.stderr b/src/test/ui/issues/issue-45107-unnecessary-unsafe-in-closure.mir.stderr deleted file mode 100644 index 9e9cbcf33ae..00000000000 --- a/src/test/ui/issues/issue-45107-unnecessary-unsafe-in-closure.mir.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error: unnecessary `unsafe` block - --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:10:13 - | -LL | unsafe { - | ------ because it's nested under this `unsafe` block -LL | let f = |v: &mut Vec<_>| { -LL | unsafe { - | ^^^^^^ unnecessary `unsafe` block - | -note: the lint level is defined here - --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:4:8 - | -LL | #[deny(unused_unsafe)] - | ^^^^^^^^^^^^^ - -error: unnecessary `unsafe` block - --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:12:38 - | -LL | unsafe { - | ------ because it's nested under this `unsafe` block -... -LL | |w: &mut Vec| { unsafe { - | ^^^^^^ unnecessary `unsafe` block - -error: unnecessary `unsafe` block - --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:16:34 - | -LL | unsafe { - | ------ because it's nested under this `unsafe` block -... -LL | |x: &mut Vec| { unsafe { - | ^^^^^^ unnecessary `unsafe` block - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/issues/issue-45107-unnecessary-unsafe-in-closure.rs b/src/test/ui/issues/issue-45107-unnecessary-unsafe-in-closure.rs deleted file mode 100644 index ac1cfd62a05..00000000000 --- a/src/test/ui/issues/issue-45107-unnecessary-unsafe-in-closure.rs +++ /dev/null @@ -1,28 +0,0 @@ -// revisions: mir thir -// [thir]compile-flags: -Zthir-unsafeck - -#[deny(unused_unsafe)] -fn main() { - let mut v = Vec::::with_capacity(24); - - unsafe { - let f = |v: &mut Vec<_>| { - unsafe { //~ ERROR unnecessary `unsafe` - v.set_len(24); - |w: &mut Vec| { unsafe { //~ ERROR unnecessary `unsafe` - w.set_len(32); - } }; - } - |x: &mut Vec| { unsafe { //~ ERROR unnecessary `unsafe` - x.set_len(40); - } }; - }; - - v.set_len(0); - f(&mut v); - } - - |y: &mut Vec| { unsafe { - y.set_len(48); - } }; -} diff --git a/src/test/ui/issues/issue-45107-unnecessary-unsafe-in-closure.thir.stderr b/src/test/ui/issues/issue-45107-unnecessary-unsafe-in-closure.thir.stderr deleted file mode 100644 index 9e9cbcf33ae..00000000000 --- a/src/test/ui/issues/issue-45107-unnecessary-unsafe-in-closure.thir.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error: unnecessary `unsafe` block - --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:10:13 - | -LL | unsafe { - | ------ because it's nested under this `unsafe` block -LL | let f = |v: &mut Vec<_>| { -LL | unsafe { - | ^^^^^^ unnecessary `unsafe` block - | -note: the lint level is defined here - --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:4:8 - | -LL | #[deny(unused_unsafe)] - | ^^^^^^^^^^^^^ - -error: unnecessary `unsafe` block - --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:12:38 - | -LL | unsafe { - | ------ because it's nested under this `unsafe` block -... -LL | |w: &mut Vec| { unsafe { - | ^^^^^^ unnecessary `unsafe` block - -error: unnecessary `unsafe` block - --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:16:34 - | -LL | unsafe { - | ------ because it's nested under this `unsafe` block -... -LL | |x: &mut Vec| { unsafe { - | ^^^^^^ unnecessary `unsafe` block - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/issues/issue-53912.rs b/src/test/ui/issues/issue-53912.rs deleted file mode 100644 index 65b6825a832..00000000000 --- a/src/test/ui/issues/issue-53912.rs +++ /dev/null @@ -1,37 +0,0 @@ -// build-pass - -// This test is the same code as in ui/symbol-names/issue-60925.rs but this checks that the -// reproduction compiles successfully and doesn't segfault, whereas that test just checks that the -// symbol mangling fix produces the correct result. - -fn dummy() {} - -mod llvm { - pub(crate) struct Foo; -} -mod foo { - pub(crate) struct Foo(T); - - impl Foo<::llvm::Foo> { - pub(crate) fn foo() { - for _ in 0..0 { - for _ in &[::dummy()] { - ::dummy(); - ::dummy(); - ::dummy(); - } - } - } - } - - pub(crate) fn foo() { - Foo::foo(); - Foo::foo(); - } -} - -pub fn foo() { - foo::foo(); -} - -fn main() {} diff --git a/src/test/ui/issues/issue-56685.rs b/src/test/ui/issues/issue-56685.rs deleted file mode 100644 index f320c99ed15..00000000000 --- a/src/test/ui/issues/issue-56685.rs +++ /dev/null @@ -1,44 +0,0 @@ -#![allow(dead_code)] -#![deny(unused_variables)] - -// This test aims to check that unused variable suggestions update bindings in all -// match arms. - -fn main() { - enum E { - A(i32,), - B(i32,), - } - - match E::A(1) { - E::A(x) | E::B(x) => {} - //~^ ERROR unused variable: `x` - } - - enum F { - A(i32, i32,), - B(i32, i32,), - C(i32, i32,), - } - - let _ = match F::A(1, 2) { - F::A(x, y) | F::B(x, y) => { y }, - //~^ ERROR unused variable: `x` - F::C(a, b) => { 3 } - //~^ ERROR unused variable: `a` - //~^^ ERROR unused variable: `b` - }; - - let _ = if let F::A(x, y) | F::B(x, y) = F::A(1, 2) { - //~^ ERROR unused variable: `x` - y - } else { - 3 - }; - - while let F::A(x, y) | F::B(x, y) = F::A(1, 2) { - //~^ ERROR unused variable: `x` - let _ = y; - break; - } -} diff --git a/src/test/ui/issues/issue-56685.stderr b/src/test/ui/issues/issue-56685.stderr deleted file mode 100644 index ccf357d4aa0..00000000000 --- a/src/test/ui/issues/issue-56685.stderr +++ /dev/null @@ -1,63 +0,0 @@ -error: unused variable: `x` - --> $DIR/issue-56685.rs:14:14 - | -LL | E::A(x) | E::B(x) => {} - | ^ ^ - | -note: the lint level is defined here - --> $DIR/issue-56685.rs:2:9 - | -LL | #![deny(unused_variables)] - | ^^^^^^^^^^^^^^^^ -help: if this is intentional, prefix it with an underscore - | -LL | E::A(_x) | E::B(_x) => {} - | ~~ ~~ - -error: unused variable: `x` - --> $DIR/issue-56685.rs:25:14 - | -LL | F::A(x, y) | F::B(x, y) => { y }, - | ^ ^ - | -help: if this is intentional, prefix it with an underscore - | -LL | F::A(_x, y) | F::B(_x, y) => { y }, - | ~~ ~~ - -error: unused variable: `a` - --> $DIR/issue-56685.rs:27:14 - | -LL | F::C(a, b) => { 3 } - | ^ help: if this is intentional, prefix it with an underscore: `_a` - -error: unused variable: `b` - --> $DIR/issue-56685.rs:27:17 - | -LL | F::C(a, b) => { 3 } - | ^ help: if this is intentional, prefix it with an underscore: `_b` - -error: unused variable: `x` - --> $DIR/issue-56685.rs:32:25 - | -LL | let _ = if let F::A(x, y) | F::B(x, y) = F::A(1, 2) { - | ^ ^ - | -help: if this is intentional, prefix it with an underscore - | -LL | let _ = if let F::A(_x, y) | F::B(_x, y) = F::A(1, 2) { - | ~~ ~~ - -error: unused variable: `x` - --> $DIR/issue-56685.rs:39:20 - | -LL | while let F::A(x, y) | F::B(x, y) = F::A(1, 2) { - | ^ ^ - | -help: if this is intentional, prefix it with an underscore - | -LL | while let F::A(_x, y) | F::B(_x, y) = F::A(1, 2) { - | ~~ ~~ - -error: aborting due to 6 previous errors - diff --git a/src/test/ui/issues/issue-57410.rs b/src/test/ui/issues/issue-57410.rs deleted file mode 100644 index 0cf4b8068e4..00000000000 --- a/src/test/ui/issues/issue-57410.rs +++ /dev/null @@ -1,17 +0,0 @@ -// check-pass - -// Tests that the `unreachable_pub` lint doesn't fire for `pub self::imp::f`. - -#![deny(unreachable_pub)] - -mod m { - mod imp { - pub fn f() {} - } - - pub use self::imp::f; -} - -pub use self::m::f; - -fn main() {} diff --git a/src/test/ui/issues/issue-5791.rs b/src/test/ui/issues/issue-5791.rs deleted file mode 100644 index 3544160f094..00000000000 --- a/src/test/ui/issues/issue-5791.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-pass -#![allow(dead_code)] -#![warn(clashing_extern_declarations)] -// pretty-expanded FIXME #23616 - -extern "C" { - #[link_name = "malloc"] - fn malloc1(len: i32) -> *const u8; - #[link_name = "malloc"] - //~^ WARN `malloc2` redeclares `malloc` with a different signature - fn malloc2(len: i32, foo: i32) -> *const u8; -} - -pub fn main() {} diff --git a/src/test/ui/issues/issue-5791.stderr b/src/test/ui/issues/issue-5791.stderr deleted file mode 100644 index cf60e609deb..00000000000 --- a/src/test/ui/issues/issue-5791.stderr +++ /dev/null @@ -1,21 +0,0 @@ -warning: `malloc2` redeclares `malloc` with a different signature - --> $DIR/issue-5791.rs:9:5 - | -LL | / #[link_name = "malloc"] -LL | | fn malloc1(len: i32) -> *const u8; - | |______________________________________- `malloc` previously declared here -LL | / #[link_name = "malloc"] -LL | | -LL | | fn malloc2(len: i32, foo: i32) -> *const u8; - | |________________________________________________^ this signature doesn't match the previous declaration - | -note: the lint level is defined here - --> $DIR/issue-5791.rs:3:9 - | -LL | #![warn(clashing_extern_declarations)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: expected `unsafe extern "C" fn(i32) -> *const u8` - found `unsafe extern "C" fn(i32, i32) -> *const u8` - -warning: 1 warning emitted - diff --git a/src/test/ui/issues/issue-74614.rs b/src/test/ui/issues/issue-74614.rs deleted file mode 100644 index 8b0c00b1355..00000000000 --- a/src/test/ui/issues/issue-74614.rs +++ /dev/null @@ -1,18 +0,0 @@ -// compile-flags:-Zpolymorphize=on -// build-pass - -fn test() { - std::mem::size_of::(); -} - -pub fn foo(_: T) -> &'static fn() { - &(test:: as fn()) -} - -fn outer() { - foo(|| ()); -} - -fn main() { - outer::(); -} diff --git a/src/test/ui/issues/issue-78720.rs b/src/test/ui/issues/issue-78720.rs deleted file mode 100644 index 4cdb9f49113..00000000000 --- a/src/test/ui/issues/issue-78720.rs +++ /dev/null @@ -1,19 +0,0 @@ -fn server() -> impl { -//~^ ERROR at least one trait must be specified - ().map2(|| "") -} - -trait FilterBase2 { - fn map2(self, f: F) -> Map2 {} - //~^ ERROR mismatched types - //~^^ ERROR the size for values of type `Self` cannot be known at compilation time -} - -struct Map2 { - _func: F, - //~^ ERROR cannot find type `F` in this scope -} - -impl FilterBase2 for F {} - -fn main() {} diff --git a/src/test/ui/issues/issue-78720.stderr b/src/test/ui/issues/issue-78720.stderr deleted file mode 100644 index 3dd13877298..00000000000 --- a/src/test/ui/issues/issue-78720.stderr +++ /dev/null @@ -1,55 +0,0 @@ -error: at least one trait must be specified - --> $DIR/issue-78720.rs:1:16 - | -LL | fn server() -> impl { - | ^^^^ - -error[E0412]: cannot find type `F` in this scope - --> $DIR/issue-78720.rs:13:12 - | -LL | _func: F, - | ^ - | - ::: $SRC_DIR/core/src/ops/function.rs:LL:COL - | -LL | pub trait Fn: FnMut { - | ------------------------------- similarly named trait `Fn` defined here - | -help: a trait with a similar name exists - | -LL | _func: Fn, - | ~~ -help: you might be missing a type parameter - | -LL | struct Map2 { - | +++ - -error[E0308]: mismatched types - --> $DIR/issue-78720.rs:7:39 - | -LL | fn map2(self, f: F) -> Map2 {} - | ^^ expected struct `Map2`, found `()` - | - = note: expected struct `Map2` - found unit type `()` - -error[E0277]: the size for values of type `Self` cannot be known at compilation time - --> $DIR/issue-78720.rs:7:16 - | -LL | fn map2(self, f: F) -> Map2 {} - | ^^^^ doesn't have a size known at compile-time - | - = help: unsized fn params are gated as an unstable feature -help: consider further restricting `Self` - | -LL | fn map2(self, f: F) -> Map2 where Self: Sized {} - | +++++++++++++++++ -help: function arguments must have a statically known size, borrowed types always have a known size - | -LL | fn map2(&self, f: F) -> Map2 {} - | + - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0277, E0308, E0412. -For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/issues/issue-79593.rs b/src/test/ui/issues/issue-79593.rs deleted file mode 100644 index b94278bfdd2..00000000000 --- a/src/test/ui/issues/issue-79593.rs +++ /dev/null @@ -1,29 +0,0 @@ -mod foo { - pub struct Pub { private: () } - - pub enum Enum { - Variant { x: (), y: () }, - Other - } - - fn correct() { - Pub {}; - //~^ ERROR missing field `private` in initializer of `Pub` - Enum::Variant { x: () }; - //~^ ERROR missing field `y` in initializer of `Enum` - } -} - -fn correct() { - foo::Pub {}; - //~^ ERROR cannot construct `Pub` with struct literal syntax due to inaccessible fields -} - -fn wrong() { - foo::Enum::Variant { x: () }; - //~^ ERROR missing field `y` in initializer of `Enum` - foo::Enum::Variant { }; - //~^ ERROR missing fields `x` and `y` in initializer of `Enum` -} - -fn main() {} diff --git a/src/test/ui/issues/issue-79593.stderr b/src/test/ui/issues/issue-79593.stderr deleted file mode 100644 index b8c7d4f23a2..00000000000 --- a/src/test/ui/issues/issue-79593.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0063]: missing field `private` in initializer of `Pub` - --> $DIR/issue-79593.rs:10:9 - | -LL | Pub {}; - | ^^^ missing `private` - -error[E0063]: missing field `y` in initializer of `Enum` - --> $DIR/issue-79593.rs:12:9 - | -LL | Enum::Variant { x: () }; - | ^^^^^^^^^^^^^ missing `y` - -error: cannot construct `Pub` with struct literal syntax due to inaccessible fields - --> $DIR/issue-79593.rs:18:5 - | -LL | foo::Pub {}; - | ^^^^^^^^ - -error[E0063]: missing field `y` in initializer of `Enum` - --> $DIR/issue-79593.rs:23:5 - | -LL | foo::Enum::Variant { x: () }; - | ^^^^^^^^^^^^^^^^^^ missing `y` - -error[E0063]: missing fields `x` and `y` in initializer of `Enum` - --> $DIR/issue-79593.rs:25:5 - | -LL | foo::Enum::Variant { }; - | ^^^^^^^^^^^^^^^^^^ missing `x` and `y` - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0063`. diff --git a/src/test/ui/issues/issue-79744.rs b/src/test/ui/issues/issue-79744.rs deleted file mode 100644 index e9725a027d3..00000000000 --- a/src/test/ui/issues/issue-79744.rs +++ /dev/null @@ -1,13 +0,0 @@ -fn main() { - let elem = 6i8; - let e2 = 230; - //~^ ERROR literal out of range for `i8` - //~| HELP consider using the type `u8` instead - - let mut vec = Vec::new(); - - vec.push(e2); - vec.push(elem); - - println!("{:?}", vec); -} diff --git a/src/test/ui/issues/issue-79744.stderr b/src/test/ui/issues/issue-79744.stderr deleted file mode 100644 index 6f6dd44d236..00000000000 --- a/src/test/ui/issues/issue-79744.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: literal out of range for `i8` - --> $DIR/issue-79744.rs:3:14 - | -LL | let e2 = 230; - | ^^^ - | - = note: `#[deny(overflowing_literals)]` on by default - = note: the literal `230` does not fit into the type `i8` whose range is `-128..=127` - = help: consider using the type `u8` instead - -error: aborting due to previous error - diff --git a/src/test/ui/issues/type-arg-mismatch-due-to-impl-trait.rs b/src/test/ui/issues/type-arg-mismatch-due-to-impl-trait.rs deleted file mode 100644 index ecfa5c69e2f..00000000000 --- a/src/test/ui/issues/type-arg-mismatch-due-to-impl-trait.rs +++ /dev/null @@ -1,16 +0,0 @@ -trait Foo { - type T; - fn foo(&self, t: Self::T); -//~^ NOTE expected 0 type parameters -} - -impl Foo for u32 { - type T = (); - - fn foo(&self, t: impl Clone) {} -//~^ ERROR method `foo` has 1 type parameter but its trait declaration has 0 type parameters -//~| NOTE found 1 type parameter -//~| NOTE `impl Trait` introduces an implicit type parameter -} - -fn main() {} diff --git a/src/test/ui/issues/type-arg-mismatch-due-to-impl-trait.stderr b/src/test/ui/issues/type-arg-mismatch-due-to-impl-trait.stderr deleted file mode 100644 index 30322f88cca..00000000000 --- a/src/test/ui/issues/type-arg-mismatch-due-to-impl-trait.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0049]: method `foo` has 1 type parameter but its trait declaration has 0 type parameters - --> $DIR/type-arg-mismatch-due-to-impl-trait.rs:10:22 - | -LL | fn foo(&self, t: Self::T); - | - expected 0 type parameters -... -LL | fn foo(&self, t: impl Clone) {} - | ^^^^^^^^^^ - | | - | found 1 type parameter - | `impl Trait` introduces an implicit type parameter - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0049`. diff --git a/src/test/ui/lint/enable-unstable-lib-feature.rs b/src/test/ui/lint/enable-unstable-lib-feature.rs new file mode 100644 index 00000000000..aa6a973d7bd --- /dev/null +++ b/src/test/ui/lint/enable-unstable-lib-feature.rs @@ -0,0 +1,13 @@ +// Test that enabling an unstable feature disables warnings + +// aux-build:stability-cfg2.rs + +#![feature(unstable_test_feature)] +#![deny(non_snake_case)] // To trigger a hard error + +// Shouldn't generate a warning about unstable features +extern crate stability_cfg2; + +pub fn BOGUS() { } //~ ERROR + +pub fn main() { } diff --git a/src/test/ui/lint/enable-unstable-lib-feature.stderr b/src/test/ui/lint/enable-unstable-lib-feature.stderr new file mode 100644 index 00000000000..bb4e928ad15 --- /dev/null +++ b/src/test/ui/lint/enable-unstable-lib-feature.stderr @@ -0,0 +1,14 @@ +error: function `BOGUS` should have a snake case name + --> $DIR/enable-unstable-lib-feature.rs:11:8 + | +LL | pub fn BOGUS() { } + | ^^^^^ help: convert the identifier to snake case: `bogus` + | +note: the lint level is defined here + --> $DIR/enable-unstable-lib-feature.rs:6:9 + | +LL | #![deny(non_snake_case)] // To trigger a hard error + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/lint/issue-57410.rs b/src/test/ui/lint/issue-57410.rs new file mode 100644 index 00000000000..0cf4b8068e4 --- /dev/null +++ b/src/test/ui/lint/issue-57410.rs @@ -0,0 +1,17 @@ +// check-pass + +// Tests that the `unreachable_pub` lint doesn't fire for `pub self::imp::f`. + +#![deny(unreachable_pub)] + +mod m { + mod imp { + pub fn f() {} + } + + pub use self::imp::f; +} + +pub use self::m::f; + +fn main() {} diff --git a/src/test/ui/lint/issue-79744.rs b/src/test/ui/lint/issue-79744.rs new file mode 100644 index 00000000000..e9725a027d3 --- /dev/null +++ b/src/test/ui/lint/issue-79744.rs @@ -0,0 +1,13 @@ +fn main() { + let elem = 6i8; + let e2 = 230; + //~^ ERROR literal out of range for `i8` + //~| HELP consider using the type `u8` instead + + let mut vec = Vec::new(); + + vec.push(e2); + vec.push(elem); + + println!("{:?}", vec); +} diff --git a/src/test/ui/lint/issue-79744.stderr b/src/test/ui/lint/issue-79744.stderr new file mode 100644 index 00000000000..6f6dd44d236 --- /dev/null +++ b/src/test/ui/lint/issue-79744.stderr @@ -0,0 +1,12 @@ +error: literal out of range for `i8` + --> $DIR/issue-79744.rs:3:14 + | +LL | let e2 = 230; + | ^^^ + | + = note: `#[deny(overflowing_literals)]` on by default + = note: the literal `230` does not fit into the type `i8` whose range is `-128..=127` + = help: consider using the type `u8` instead + +error: aborting due to previous error + diff --git a/src/test/ui/llvm-asm/issue-37433.rs b/src/test/ui/llvm-asm/issue-37433.rs new file mode 100644 index 00000000000..1c362e8aba0 --- /dev/null +++ b/src/test/ui/llvm-asm/issue-37433.rs @@ -0,0 +1,12 @@ +// build-fail +// ignore-emscripten no llvm_asm! support + +#![feature(llvm_asm)] +#![allow(deprecated)] // llvm_asm! + +fn main() { + unsafe { + llvm_asm!("" :: "r"("")); + //~^ ERROR: invalid value for constraint in inline assembly + } +} diff --git a/src/test/ui/llvm-asm/issue-37433.stderr b/src/test/ui/llvm-asm/issue-37433.stderr new file mode 100644 index 00000000000..44a8eb32b7c --- /dev/null +++ b/src/test/ui/llvm-asm/issue-37433.stderr @@ -0,0 +1,9 @@ +error[E0669]: invalid value for constraint in inline assembly + --> $DIR/issue-37433.rs:9:29 + | +LL | llvm_asm!("" :: "r"("")); + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0669`. diff --git a/src/test/ui/macros/auxiliary/define-macro.rs b/src/test/ui/macros/auxiliary/define-macro.rs new file mode 100644 index 00000000000..4956907c55e --- /dev/null +++ b/src/test/ui/macros/auxiliary/define-macro.rs @@ -0,0 +1,6 @@ +#[macro_export] +macro_rules! define_macro { + ($i:ident) => { + macro_rules! $i { () => {} } + } +} diff --git a/src/test/ui/macros/out-of-order-shadowing.rs b/src/test/ui/macros/out-of-order-shadowing.rs new file mode 100644 index 00000000000..a0d1a973764 --- /dev/null +++ b/src/test/ui/macros/out-of-order-shadowing.rs @@ -0,0 +1,10 @@ +// aux-build:define-macro.rs + +macro_rules! bar { () => {} } +define_macro!(bar); +bar!(); //~ ERROR `bar` is ambiguous + +macro_rules! m { () => { #[macro_use] extern crate define_macro; } } +m!(); + +fn main() {} diff --git a/src/test/ui/macros/out-of-order-shadowing.stderr b/src/test/ui/macros/out-of-order-shadowing.stderr new file mode 100644 index 00000000000..1db31e0272c --- /dev/null +++ b/src/test/ui/macros/out-of-order-shadowing.stderr @@ -0,0 +1,21 @@ +error[E0659]: `bar` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) + --> $DIR/out-of-order-shadowing.rs:5:1 + | +LL | bar!(); + | ^^^ ambiguous name + | +note: `bar` could refer to the macro defined here + --> $DIR/out-of-order-shadowing.rs:4:1 + | +LL | define_macro!(bar); + | ^^^^^^^^^^^^^^^^^^^ +note: `bar` could also refer to the macro defined here + --> $DIR/out-of-order-shadowing.rs:3:1 + | +LL | macro_rules! bar { () => {} } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `define_macro` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0659`. diff --git a/src/test/ui/match/guards.rs b/src/test/ui/match/guards.rs new file mode 100644 index 00000000000..10a4bb67387 --- /dev/null +++ b/src/test/ui/match/guards.rs @@ -0,0 +1,20 @@ +// run-pass + +#![allow(non_shorthand_field_patterns)] + +#[derive(Copy, Clone)] +struct Pair { x: isize, y: isize } + +pub fn main() { + let a: isize = + match 10 { x if x < 7 => { 1 } x if x < 11 => { 2 } 10 => { 3 } _ => { 4 } }; + assert_eq!(a, 2); + + let b: isize = + match (Pair {x: 10, y: 20}) { + x if x.x < 5 && x.y < 5 => { 1 } + Pair {x: x, y: y} if x == 10 && y == 20 => { 2 } + Pair {x: _x, y: _y} => { 3 } + }; + assert_eq!(b, 2); +} diff --git a/src/test/ui/match/issue-33498.rs b/src/test/ui/match/issue-33498.rs new file mode 100644 index 00000000000..9c8a97e7e6b --- /dev/null +++ b/src/test/ui/match/issue-33498.rs @@ -0,0 +1,11 @@ +// run-pass +#![allow(unused_variables)] +pub fn main() { + let x = (0, 2); + + match x { + (0, ref y) => {} + (y, 0) => {} + _ => (), + } +} diff --git a/src/test/ui/match/issue-41255.rs b/src/test/ui/match/issue-41255.rs new file mode 100644 index 00000000000..9d7072f1665 --- /dev/null +++ b/src/test/ui/match/issue-41255.rs @@ -0,0 +1,51 @@ +// Matching against float literals should result in a linter error + +#![feature(exclusive_range_pattern)] +#![feature(half_open_range_patterns)] +#![allow(unused)] +#![forbid(illegal_floating_point_literal_pattern)] + +fn main() { + let x = 42.0; + match x { + 5.0 => {}, //~ ERROR floating-point types cannot be used in patterns + //~| WARNING hard error + 5.0f32 => {}, //~ ERROR floating-point types cannot be used in patterns + //~| WARNING hard error + -5.0 => {}, //~ ERROR floating-point types cannot be used in patterns + //~| WARNING hard error + 1.0 .. 33.0 => {}, //~ ERROR floating-point types cannot be used in patterns + //~| WARNING hard error + //~| ERROR floating-point types cannot be used in patterns + //~| WARNING hard error + 39.0 ..= 70.0 => {}, //~ ERROR floating-point types cannot be used in patterns + //~| ERROR floating-point types cannot be used in patterns + //~| WARNING hard error + //~| WARNING hard error + + ..71.0 => {} + //~^ ERROR floating-point types cannot be used in patterns + //~| WARNING this was previously accepted by the compiler + ..=72.0 => {} + //~^ ERROR floating-point types cannot be used in patterns + //~| WARNING this was previously accepted by the compiler + 71.0.. => {} + //~^ ERROR floating-point types cannot be used in patterns + //~| WARNING this was previously accepted by the compiler + _ => {}, + }; + let y = 5.0; + // Same for tuples + match (x, 5) { + (3.14, 1) => {}, //~ ERROR floating-point types cannot be used + //~| WARNING hard error + _ => {}, + } + // Or structs + struct Foo { x: f32 }; + match (Foo { x }) { + Foo { x: 2.0 } => {}, //~ ERROR floating-point types cannot be used + //~| WARNING hard error + _ => {}, + } +} diff --git a/src/test/ui/match/issue-41255.stderr b/src/test/ui/match/issue-41255.stderr new file mode 100644 index 00000000000..bf81c8d371c --- /dev/null +++ b/src/test/ui/match/issue-41255.stderr @@ -0,0 +1,115 @@ +error: floating-point types cannot be used in patterns + --> $DIR/issue-41255.rs:11:9 + | +LL | 5.0 => {}, + | ^^^ + | +note: the lint level is defined here + --> $DIR/issue-41255.rs:6:11 + | +LL | #![forbid(illegal_floating_point_literal_pattern)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41620 + +error: floating-point types cannot be used in patterns + --> $DIR/issue-41255.rs:13:9 + | +LL | 5.0f32 => {}, + | ^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41620 + +error: floating-point types cannot be used in patterns + --> $DIR/issue-41255.rs:15:10 + | +LL | -5.0 => {}, + | ^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41620 + +error: floating-point types cannot be used in patterns + --> $DIR/issue-41255.rs:17:9 + | +LL | 1.0 .. 33.0 => {}, + | ^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41620 + +error: floating-point types cannot be used in patterns + --> $DIR/issue-41255.rs:17:16 + | +LL | 1.0 .. 33.0 => {}, + | ^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41620 + +error: floating-point types cannot be used in patterns + --> $DIR/issue-41255.rs:21:9 + | +LL | 39.0 ..= 70.0 => {}, + | ^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41620 + +error: floating-point types cannot be used in patterns + --> $DIR/issue-41255.rs:21:18 + | +LL | 39.0 ..= 70.0 => {}, + | ^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41620 + +error: floating-point types cannot be used in patterns + --> $DIR/issue-41255.rs:26:11 + | +LL | ..71.0 => {} + | ^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41620 + +error: floating-point types cannot be used in patterns + --> $DIR/issue-41255.rs:29:12 + | +LL | ..=72.0 => {} + | ^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41620 + +error: floating-point types cannot be used in patterns + --> $DIR/issue-41255.rs:32:9 + | +LL | 71.0.. => {} + | ^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41620 + +error: floating-point types cannot be used in patterns + --> $DIR/issue-41255.rs:40:10 + | +LL | (3.14, 1) => {}, + | ^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41620 + +error: floating-point types cannot be used in patterns + --> $DIR/issue-41255.rs:47:18 + | +LL | Foo { x: 2.0 } => {}, + | ^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41620 + +error: aborting due to 12 previous errors + diff --git a/src/test/ui/match/issue-56685.rs b/src/test/ui/match/issue-56685.rs new file mode 100644 index 00000000000..f320c99ed15 --- /dev/null +++ b/src/test/ui/match/issue-56685.rs @@ -0,0 +1,44 @@ +#![allow(dead_code)] +#![deny(unused_variables)] + +// This test aims to check that unused variable suggestions update bindings in all +// match arms. + +fn main() { + enum E { + A(i32,), + B(i32,), + } + + match E::A(1) { + E::A(x) | E::B(x) => {} + //~^ ERROR unused variable: `x` + } + + enum F { + A(i32, i32,), + B(i32, i32,), + C(i32, i32,), + } + + let _ = match F::A(1, 2) { + F::A(x, y) | F::B(x, y) => { y }, + //~^ ERROR unused variable: `x` + F::C(a, b) => { 3 } + //~^ ERROR unused variable: `a` + //~^^ ERROR unused variable: `b` + }; + + let _ = if let F::A(x, y) | F::B(x, y) = F::A(1, 2) { + //~^ ERROR unused variable: `x` + y + } else { + 3 + }; + + while let F::A(x, y) | F::B(x, y) = F::A(1, 2) { + //~^ ERROR unused variable: `x` + let _ = y; + break; + } +} diff --git a/src/test/ui/match/issue-56685.stderr b/src/test/ui/match/issue-56685.stderr new file mode 100644 index 00000000000..ccf357d4aa0 --- /dev/null +++ b/src/test/ui/match/issue-56685.stderr @@ -0,0 +1,63 @@ +error: unused variable: `x` + --> $DIR/issue-56685.rs:14:14 + | +LL | E::A(x) | E::B(x) => {} + | ^ ^ + | +note: the lint level is defined here + --> $DIR/issue-56685.rs:2:9 + | +LL | #![deny(unused_variables)] + | ^^^^^^^^^^^^^^^^ +help: if this is intentional, prefix it with an underscore + | +LL | E::A(_x) | E::B(_x) => {} + | ~~ ~~ + +error: unused variable: `x` + --> $DIR/issue-56685.rs:25:14 + | +LL | F::A(x, y) | F::B(x, y) => { y }, + | ^ ^ + | +help: if this is intentional, prefix it with an underscore + | +LL | F::A(_x, y) | F::B(_x, y) => { y }, + | ~~ ~~ + +error: unused variable: `a` + --> $DIR/issue-56685.rs:27:14 + | +LL | F::C(a, b) => { 3 } + | ^ help: if this is intentional, prefix it with an underscore: `_a` + +error: unused variable: `b` + --> $DIR/issue-56685.rs:27:17 + | +LL | F::C(a, b) => { 3 } + | ^ help: if this is intentional, prefix it with an underscore: `_b` + +error: unused variable: `x` + --> $DIR/issue-56685.rs:32:25 + | +LL | let _ = if let F::A(x, y) | F::B(x, y) = F::A(1, 2) { + | ^ ^ + | +help: if this is intentional, prefix it with an underscore + | +LL | let _ = if let F::A(_x, y) | F::B(_x, y) = F::A(1, 2) { + | ~~ ~~ + +error: unused variable: `x` + --> $DIR/issue-56685.rs:39:20 + | +LL | while let F::A(x, y) | F::B(x, y) = F::A(1, 2) { + | ^ ^ + | +help: if this is intentional, prefix it with an underscore + | +LL | while let F::A(_x, y) | F::B(_x, y) = F::A(1, 2) { + | ~~ ~~ + +error: aborting due to 6 previous errors + diff --git a/src/test/ui/mid-path-type-params.rs b/src/test/ui/mid-path-type-params.rs deleted file mode 100644 index a8128207c80..00000000000 --- a/src/test/ui/mid-path-type-params.rs +++ /dev/null @@ -1,37 +0,0 @@ -// run-pass - -#![allow(dead_code)] -// pretty-expanded FIXME #23616 - -struct S { - contents: T, -} - -impl S { - fn new(x: T, _: U) -> S { - S { - contents: x, - } - } -} - -trait Trait { - fn new(x: T, y: U) -> Self; -} - -struct S2 { - contents: isize, -} - -impl Trait for S2 { - fn new(x: isize, _: U) -> S2 { - S2 { - contents: x, - } - } -} - -pub fn main() { - let _ = S::::new::(1, 1.0); - let _: S2 = Trait::::new::(1, 1.0); -} diff --git a/src/test/ui/never_type/expr-empty-ret.rs b/src/test/ui/never_type/expr-empty-ret.rs new file mode 100644 index 00000000000..ce8ffaf94d0 --- /dev/null +++ b/src/test/ui/never_type/expr-empty-ret.rs @@ -0,0 +1,15 @@ +// run-pass + +#![allow(dead_code)] +// Issue #521 + +// pretty-expanded FIXME #23616 + +fn f() { + let _x = match true { + true => { 10 } + false => { return } + }; +} + +pub fn main() { } diff --git a/src/test/ui/out-of-order-shadowing.rs b/src/test/ui/out-of-order-shadowing.rs deleted file mode 100644 index a0d1a973764..00000000000 --- a/src/test/ui/out-of-order-shadowing.rs +++ /dev/null @@ -1,10 +0,0 @@ -// aux-build:define-macro.rs - -macro_rules! bar { () => {} } -define_macro!(bar); -bar!(); //~ ERROR `bar` is ambiguous - -macro_rules! m { () => { #[macro_use] extern crate define_macro; } } -m!(); - -fn main() {} diff --git a/src/test/ui/out-of-order-shadowing.stderr b/src/test/ui/out-of-order-shadowing.stderr deleted file mode 100644 index 1db31e0272c..00000000000 --- a/src/test/ui/out-of-order-shadowing.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0659]: `bar` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) - --> $DIR/out-of-order-shadowing.rs:5:1 - | -LL | bar!(); - | ^^^ ambiguous name - | -note: `bar` could refer to the macro defined here - --> $DIR/out-of-order-shadowing.rs:4:1 - | -LL | define_macro!(bar); - | ^^^^^^^^^^^^^^^^^^^ -note: `bar` could also refer to the macro defined here - --> $DIR/out-of-order-shadowing.rs:3:1 - | -LL | macro_rules! bar { () => {} } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `define_macro` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0659`. diff --git a/src/test/ui/polymorphization/issue-74614.rs b/src/test/ui/polymorphization/issue-74614.rs new file mode 100644 index 00000000000..8b0c00b1355 --- /dev/null +++ b/src/test/ui/polymorphization/issue-74614.rs @@ -0,0 +1,18 @@ +// compile-flags:-Zpolymorphize=on +// build-pass + +fn test() { + std::mem::size_of::(); +} + +pub fn foo(_: T) -> &'static fn() { + &(test:: as fn()) +} + +fn outer() { + foo(|| ()); +} + +fn main() { + outer::(); +} diff --git a/src/test/ui/privacy/issue-79593.rs b/src/test/ui/privacy/issue-79593.rs new file mode 100644 index 00000000000..b94278bfdd2 --- /dev/null +++ b/src/test/ui/privacy/issue-79593.rs @@ -0,0 +1,29 @@ +mod foo { + pub struct Pub { private: () } + + pub enum Enum { + Variant { x: (), y: () }, + Other + } + + fn correct() { + Pub {}; + //~^ ERROR missing field `private` in initializer of `Pub` + Enum::Variant { x: () }; + //~^ ERROR missing field `y` in initializer of `Enum` + } +} + +fn correct() { + foo::Pub {}; + //~^ ERROR cannot construct `Pub` with struct literal syntax due to inaccessible fields +} + +fn wrong() { + foo::Enum::Variant { x: () }; + //~^ ERROR missing field `y` in initializer of `Enum` + foo::Enum::Variant { }; + //~^ ERROR missing fields `x` and `y` in initializer of `Enum` +} + +fn main() {} diff --git a/src/test/ui/privacy/issue-79593.stderr b/src/test/ui/privacy/issue-79593.stderr new file mode 100644 index 00000000000..b8c7d4f23a2 --- /dev/null +++ b/src/test/ui/privacy/issue-79593.stderr @@ -0,0 +1,33 @@ +error[E0063]: missing field `private` in initializer of `Pub` + --> $DIR/issue-79593.rs:10:9 + | +LL | Pub {}; + | ^^^ missing `private` + +error[E0063]: missing field `y` in initializer of `Enum` + --> $DIR/issue-79593.rs:12:9 + | +LL | Enum::Variant { x: () }; + | ^^^^^^^^^^^^^ missing `y` + +error: cannot construct `Pub` with struct literal syntax due to inaccessible fields + --> $DIR/issue-79593.rs:18:5 + | +LL | foo::Pub {}; + | ^^^^^^^^ + +error[E0063]: missing field `y` in initializer of `Enum` + --> $DIR/issue-79593.rs:23:5 + | +LL | foo::Enum::Variant { x: () }; + | ^^^^^^^^^^^^^^^^^^ missing `y` + +error[E0063]: missing fields `x` and `y` in initializer of `Enum` + --> $DIR/issue-79593.rs:25:5 + | +LL | foo::Enum::Variant { }; + | ^^^^^^^^^^^^^^^^^^ missing `x` and `y` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0063`. diff --git a/src/test/ui/resolve/issue-42944.rs b/src/test/ui/resolve/issue-42944.rs new file mode 100644 index 00000000000..a4404857a56 --- /dev/null +++ b/src/test/ui/resolve/issue-42944.rs @@ -0,0 +1,21 @@ +mod foo { + pub struct Bx(()); +} + +mod bar { + use foo::Bx; + + fn foo() { + Bx(()); + //~^ ERROR cannot initialize a tuple struct which contains private fields [E0423] + } +} + +mod baz { + fn foo() { + Bx(()); + //~^ ERROR cannot find function, tuple struct or tuple variant `Bx` in this scope [E0425] + } +} + +fn main() {} diff --git a/src/test/ui/resolve/issue-42944.stderr b/src/test/ui/resolve/issue-42944.stderr new file mode 100644 index 00000000000..008492529d1 --- /dev/null +++ b/src/test/ui/resolve/issue-42944.stderr @@ -0,0 +1,27 @@ +error[E0423]: cannot initialize a tuple struct which contains private fields + --> $DIR/issue-42944.rs:9:9 + | +LL | Bx(()); + | ^^ + | +note: constructor is not visible here due to private fields + --> $DIR/issue-42944.rs:2:19 + | +LL | pub struct Bx(()); + | ^^ private field + +error[E0425]: cannot find function, tuple struct or tuple variant `Bx` in this scope + --> $DIR/issue-42944.rs:16:9 + | +LL | Bx(()); + | ^^ not found in this scope + | +help: consider importing this tuple struct + | +LL | use foo::Bx; + | + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0423, E0425. +For more information about an error, try `rustc --explain E0423`. diff --git a/src/test/ui/resolve/use-self-in-inner-fn.rs b/src/test/ui/resolve/use-self-in-inner-fn.rs new file mode 100644 index 00000000000..eccb315feb1 --- /dev/null +++ b/src/test/ui/resolve/use-self-in-inner-fn.rs @@ -0,0 +1,14 @@ +struct A; + +impl A { +//~^ NOTE `Self` type implicitly declared here, by this `impl` + fn banana(&mut self) { + fn peach(this: &Self) { + //~^ ERROR can't use generic parameters from outer function + //~| NOTE use of generic parameter from outer function + //~| NOTE use a type here instead + } + } +} + +fn main() {} diff --git a/src/test/ui/resolve/use-self-in-inner-fn.stderr b/src/test/ui/resolve/use-self-in-inner-fn.stderr new file mode 100644 index 00000000000..96609349924 --- /dev/null +++ b/src/test/ui/resolve/use-self-in-inner-fn.stderr @@ -0,0 +1,15 @@ +error[E0401]: can't use generic parameters from outer function + --> $DIR/use-self-in-inner-fn.rs:6:25 + | +LL | impl A { + | ---- `Self` type implicitly declared here, by this `impl` +... +LL | fn peach(this: &Self) { + | ^^^^ + | | + | use of generic parameter from outer function + | use a type here instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0401`. diff --git a/src/test/ui/specialization/issue-35376.rs b/src/test/ui/specialization/issue-35376.rs new file mode 100644 index 00000000000..cc35213b93d --- /dev/null +++ b/src/test/ui/specialization/issue-35376.rs @@ -0,0 +1,43 @@ +// check-pass +#![feature(specialization)] +//~^ WARN the feature `specialization` is incomplete + +fn main() {} + +pub trait Alpha { } + +pub trait Beta { + type Event; +} + +pub trait Delta { + type Handle; + fn process(&self); +} + +pub struct Parent(A, T); + +impl Delta for Parent +where A: Alpha, + T: Delta, + T::Handle: Beta::Event> { + type Handle = Handle; + default fn process(&self) { + unimplemented!() + } +} + +impl Delta for Parent +where A: Alpha + Alpha, + T: Delta, + T::Handle: Beta::Event> { + fn process(&self) { + unimplemented!() + } +} + +pub struct Handle; + +impl Beta for Handle { + type Event = (); +} diff --git a/src/test/ui/specialization/issue-35376.stderr b/src/test/ui/specialization/issue-35376.stderr new file mode 100644 index 00000000000..835277d408e --- /dev/null +++ b/src/test/ui/specialization/issue-35376.stderr @@ -0,0 +1,12 @@ +warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/issue-35376.rs:2:12 + | +LL | #![feature(specialization)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #31844 for more information + = help: consider using `min_specialization` instead, which is more stable and complete + +warning: 1 warning emitted + diff --git a/src/test/ui/static/issue-34194.rs b/src/test/ui/static/issue-34194.rs new file mode 100644 index 00000000000..6dce556e9e3 --- /dev/null +++ b/src/test/ui/static/issue-34194.rs @@ -0,0 +1,11 @@ +// build-pass +#![allow(dead_code)] + +struct A { + a: &'static (), +} + +static B: &'static A = &A { a: &() }; +static C: &'static A = &B; + +fn main() {} diff --git a/src/test/ui/structs-enums/issue-38002.rs b/src/test/ui/structs-enums/issue-38002.rs new file mode 100644 index 00000000000..fdb31fc44a1 --- /dev/null +++ b/src/test/ui/structs-enums/issue-38002.rs @@ -0,0 +1,35 @@ +// run-pass +#![allow(dead_code)] +// Check that constant ADTs are codegened OK, part k of N. + +enum Bar { + C +} + +enum Foo { + A {}, + B { + y: usize, + z: Bar + }, +} + +const LIST: [(usize, Foo); 2] = [ + (51, Foo::B { y: 42, z: Bar::C }), + (52, Foo::B { y: 45, z: Bar::C }), +]; + +pub fn main() { + match LIST { + [ + (51, Foo::B { y: 42, z: Bar::C }), + (52, Foo::B { y: 45, z: Bar::C }) + ] => {} + _ => { + // I would want to print the enum here, but if + // the discriminant is garbage this causes an + // `unreachable` and silent process exit. + panic!("trivial match failed") + } + } +} diff --git a/src/test/ui/symbol-names/issue-53912.rs b/src/test/ui/symbol-names/issue-53912.rs new file mode 100644 index 00000000000..65b6825a832 --- /dev/null +++ b/src/test/ui/symbol-names/issue-53912.rs @@ -0,0 +1,37 @@ +// build-pass + +// This test is the same code as in ui/symbol-names/issue-60925.rs but this checks that the +// reproduction compiles successfully and doesn't segfault, whereas that test just checks that the +// symbol mangling fix produces the correct result. + +fn dummy() {} + +mod llvm { + pub(crate) struct Foo; +} +mod foo { + pub(crate) struct Foo(T); + + impl Foo<::llvm::Foo> { + pub(crate) fn foo() { + for _ in 0..0 { + for _ in &[::dummy()] { + ::dummy(); + ::dummy(); + ::dummy(); + } + } + } + } + + pub(crate) fn foo() { + Foo::foo(); + Foo::foo(); + } +} + +pub fn foo() { + foo::foo(); +} + +fn main() {} diff --git a/src/test/ui/test-attrs/issue-36768.rs b/src/test/ui/test-attrs/issue-36768.rs new file mode 100644 index 00000000000..f671cbc8205 --- /dev/null +++ b/src/test/ui/test-attrs/issue-36768.rs @@ -0,0 +1,9 @@ +// run-pass +// compile-flags:--test +#![deny(private_in_public)] + +#[test] fn foo() {} +mod foo {} + +#[test] fn core() {} +extern crate core; diff --git a/src/test/ui/thread-local/tls.rs b/src/test/ui/thread-local/tls.rs new file mode 100644 index 00000000000..fbd3413885f --- /dev/null +++ b/src/test/ui/thread-local/tls.rs @@ -0,0 +1,14 @@ +// run-pass +// ignore-emscripten no threads support +// compile-flags: -O + +#![feature(thread_local)] + +#[thread_local] +static S: u32 = 222; + +fn main() { + let local = &S as *const u32 as usize; + let foreign = std::thread::spawn(|| &S as *const u32 as usize).join().unwrap(); + assert_ne!(local, foreign); +} diff --git a/src/test/ui/tls.rs b/src/test/ui/tls.rs deleted file mode 100644 index fbd3413885f..00000000000 --- a/src/test/ui/tls.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-pass -// ignore-emscripten no threads support -// compile-flags: -O - -#![feature(thread_local)] - -#[thread_local] -static S: u32 = 222; - -fn main() { - let local = &S as *const u32 as usize; - let foreign = std::thread::spawn(|| &S as *const u32 as usize).join().unwrap(); - assert_ne!(local, foreign); -} diff --git a/src/test/ui/traits/bug-7183-generics.rs b/src/test/ui/traits/bug-7183-generics.rs new file mode 100644 index 00000000000..f53a1736127 --- /dev/null +++ b/src/test/ui/traits/bug-7183-generics.rs @@ -0,0 +1,36 @@ +// run-pass + +trait Speak : Sized { + fn say(&self, s:&str) -> String; + fn hi(&self) -> String { hello(self) } +} + +fn hello(s:&S) -> String{ + s.say("hello") +} + +impl Speak for isize { + fn say(&self, s:&str) -> String { + format!("{}: {}", s, *self) + } +} + +impl Speak for Option { + fn say(&self, s:&str) -> String { + match *self { + None => format!("{} - none", s), + Some(ref x) => { format!("something!{}", x.say(s)) } + } + } +} + + +pub fn main() { + assert_eq!(3.hi(), "hello: 3".to_string()); + assert_eq!(Some(Some(3)).hi(), + "something!something!hello: 3".to_string()); + assert_eq!(None::.hi(), "hello - none".to_string()); + + assert_eq!(Some(None::).hi(), "something!hello - none".to_string()); + assert_eq!(Some(3).hi(), "something!hello: 3".to_string()); +} diff --git a/src/test/ui/traits/issue-20692.rs b/src/test/ui/traits/issue-20692.rs new file mode 100644 index 00000000000..1cb2d8c7302 --- /dev/null +++ b/src/test/ui/traits/issue-20692.rs @@ -0,0 +1,11 @@ +trait Array: Sized + Copy {} + +fn f(x: &T) { + let _ = x + //~^ ERROR `Array` cannot be made into an object + as + &dyn Array; + //~^ ERROR `Array` cannot be made into an object +} + +fn main() {} diff --git a/src/test/ui/traits/issue-20692.stderr b/src/test/ui/traits/issue-20692.stderr new file mode 100644 index 00000000000..1d7f252e556 --- /dev/null +++ b/src/test/ui/traits/issue-20692.stderr @@ -0,0 +1,35 @@ +error[E0038]: the trait `Array` cannot be made into an object + --> $DIR/issue-20692.rs:7:5 + | +LL | &dyn Array; + | ^^^^^^^^^^ `Array` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + --> $DIR/issue-20692.rs:1:14 + | +LL | trait Array: Sized + Copy {} + | ----- ^^^^^ ^^^^ ...because it requires `Self: Sized` + | | | + | | ...because it requires `Self: Sized` + | this trait cannot be made into an object... + +error[E0038]: the trait `Array` cannot be made into an object + --> $DIR/issue-20692.rs:4:13 + | +LL | let _ = x + | ^ `Array` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + --> $DIR/issue-20692.rs:1:14 + | +LL | trait Array: Sized + Copy {} + | ----- ^^^^^ ^^^^ ...because it requires `Self: Sized` + | | | + | | ...because it requires `Self: Sized` + | this trait cannot be made into an object... + = note: required because of the requirements on the impl of `CoerceUnsized<&dyn Array>` for `&T` + = note: required by cast to type `&dyn Array` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/traits/issue-23825.rs b/src/test/ui/traits/issue-23825.rs new file mode 100644 index 00000000000..a9f0095d2e2 --- /dev/null +++ b/src/test/ui/traits/issue-23825.rs @@ -0,0 +1,21 @@ +// run-pass +trait Stringify { + fn to_string(&self) -> String; +} + +impl Stringify for u32 { + fn to_string(&self) -> String { format!("u32: {}", *self) } +} + +impl Stringify for f32 { + fn to_string(&self) -> String { format!("f32: {}", *self) } +} + +fn print(x: T) -> String { + x.to_string() +} + +fn main() { + assert_eq!(&print(5), "u32: 5"); + assert_eq!(&print(5.0), "f32: 5"); +} diff --git a/src/test/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.mir.stderr b/src/test/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.mir.stderr new file mode 100644 index 00000000000..9e9cbcf33ae --- /dev/null +++ b/src/test/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.mir.stderr @@ -0,0 +1,35 @@ +error: unnecessary `unsafe` block + --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:10:13 + | +LL | unsafe { + | ------ because it's nested under this `unsafe` block +LL | let f = |v: &mut Vec<_>| { +LL | unsafe { + | ^^^^^^ unnecessary `unsafe` block + | +note: the lint level is defined here + --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:4:8 + | +LL | #[deny(unused_unsafe)] + | ^^^^^^^^^^^^^ + +error: unnecessary `unsafe` block + --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:12:38 + | +LL | unsafe { + | ------ because it's nested under this `unsafe` block +... +LL | |w: &mut Vec| { unsafe { + | ^^^^^^ unnecessary `unsafe` block + +error: unnecessary `unsafe` block + --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:16:34 + | +LL | unsafe { + | ------ because it's nested under this `unsafe` block +... +LL | |x: &mut Vec| { unsafe { + | ^^^^^^ unnecessary `unsafe` block + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.rs b/src/test/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.rs new file mode 100644 index 00000000000..ac1cfd62a05 --- /dev/null +++ b/src/test/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.rs @@ -0,0 +1,28 @@ +// revisions: mir thir +// [thir]compile-flags: -Zthir-unsafeck + +#[deny(unused_unsafe)] +fn main() { + let mut v = Vec::::with_capacity(24); + + unsafe { + let f = |v: &mut Vec<_>| { + unsafe { //~ ERROR unnecessary `unsafe` + v.set_len(24); + |w: &mut Vec| { unsafe { //~ ERROR unnecessary `unsafe` + w.set_len(32); + } }; + } + |x: &mut Vec| { unsafe { //~ ERROR unnecessary `unsafe` + x.set_len(40); + } }; + }; + + v.set_len(0); + f(&mut v); + } + + |y: &mut Vec| { unsafe { + y.set_len(48); + } }; +} diff --git a/src/test/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.thir.stderr b/src/test/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.thir.stderr new file mode 100644 index 00000000000..9e9cbcf33ae --- /dev/null +++ b/src/test/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.thir.stderr @@ -0,0 +1,35 @@ +error: unnecessary `unsafe` block + --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:10:13 + | +LL | unsafe { + | ------ because it's nested under this `unsafe` block +LL | let f = |v: &mut Vec<_>| { +LL | unsafe { + | ^^^^^^ unnecessary `unsafe` block + | +note: the lint level is defined here + --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:4:8 + | +LL | #[deny(unused_unsafe)] + | ^^^^^^^^^^^^^ + +error: unnecessary `unsafe` block + --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:12:38 + | +LL | unsafe { + | ------ because it's nested under this `unsafe` block +... +LL | |w: &mut Vec| { unsafe { + | ^^^^^^ unnecessary `unsafe` block + +error: unnecessary `unsafe` block + --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:16:34 + | +LL | unsafe { + | ------ because it's nested under this `unsafe` block +... +LL | |x: &mut Vec| { unsafe { + | ^^^^^^ unnecessary `unsafe` block + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/use-self-in-inner-fn.rs b/src/test/ui/use-self-in-inner-fn.rs deleted file mode 100644 index eccb315feb1..00000000000 --- a/src/test/ui/use-self-in-inner-fn.rs +++ /dev/null @@ -1,14 +0,0 @@ -struct A; - -impl A { -//~^ NOTE `Self` type implicitly declared here, by this `impl` - fn banana(&mut self) { - fn peach(this: &Self) { - //~^ ERROR can't use generic parameters from outer function - //~| NOTE use of generic parameter from outer function - //~| NOTE use a type here instead - } - } -} - -fn main() {} diff --git a/src/test/ui/use-self-in-inner-fn.stderr b/src/test/ui/use-self-in-inner-fn.stderr deleted file mode 100644 index 96609349924..00000000000 --- a/src/test/ui/use-self-in-inner-fn.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0401]: can't use generic parameters from outer function - --> $DIR/use-self-in-inner-fn.rs:6:25 - | -LL | impl A { - | ---- `Self` type implicitly declared here, by this `impl` -... -LL | fn peach(this: &Self) { - | ^^^^ - | | - | use of generic parameter from outer function - | use a type here instead - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0401`. diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 46b5b877b4c..a341527c84c 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -7,8 +7,8 @@ use std::path::Path; const ENTRY_LIMIT: usize = 1000; // FIXME: The following limits should be reduced eventually. -const ROOT_ENTRY_LIMIT: usize = 1345; -const ISSUES_ENTRY_LIMIT: usize = 2525; +const ROOT_ENTRY_LIMIT: usize = 1330; +const ISSUES_ENTRY_LIMIT: usize = 2488; fn check_entries(path: &Path, bad: &mut bool) { let dirs = walkdir::WalkDir::new(&path.join("test/ui")) -- cgit 1.4.1-3-g733a5