From e7e93717ce8e6f5cec217ebfcda2d8c8b76f6b49 Mon Sep 17 00:00:00 2001 From: Caio Date: Tue, 16 Feb 2021 21:22:21 -0300 Subject: Move some tests to more reasonable directories --- src/test/ui/associated-types/issue-21726.rs | 38 +++++ src/test/ui/associated-types/issue-22560.rs | 15 ++ src/test/ui/associated-types/issue-22560.stderr | 60 +++++++ src/test/ui/associated-types/issue-23595-2.rs | 10 ++ src/test/ui/associated-types/issue-23595-2.stderr | 9 ++ src/test/ui/associated-types/issue-24204.rs | 25 +++ .../issue-43784-associated-type.rs | 17 ++ .../issue-43784-associated-type.stderr | 17 ++ .../associated-types/project-defer-unification.rs | 104 +++++++++++++ src/test/ui/async-await/issue-77993-2.rs | 9 ++ src/test/ui/async-await/issue-77993-2.stderr | 8 + .../async-await/repeat_count_const_in_async_fn.rs | 10 ++ src/test/ui/cleanup-rvalue-during-if-and-while.rs | 43 ----- src/test/ui/consts/issue-13837.rs | 13 ++ src/test/ui/consts/issue-17718-references.rs | 24 +++ src/test/ui/consts/issue-17718-references.stderr | 27 ++++ src/test/ui/consts/issue-32829.rs | 6 + src/test/ui/consts/issue-32829.stderr | 13 ++ src/test/ui/consts/issue-33537.rs | 14 ++ src/test/ui/consts/rvalue-static-promotion.rs | 19 +++ .../ui/consts/write-to-static-mut-in-static.rs | 10 ++ .../ui/consts/write-to-static-mut-in-static.stderr | 24 +++ src/test/ui/dotdotdot-expr.rs | 4 - src/test/ui/dotdotdot-expr.stderr | 17 -- src/test/ui/emit-artifact-notifications.nll.stderr | 1 - .../ui/emit-artifact-notifications.polonius.stderr | 1 - src/test/ui/emit-artifact-notifications.rs | 8 - src/test/ui/emit-artifact-notifications.stderr | 1 - src/test/ui/emit-metadata-obj.rs | 7 - src/test/ui/expr-if-panic.rs | 18 --- src/test/ui/expr/if/expr-if-panic-pass.rs | 18 +++ src/test/ui/expr/if/issue-4201.rs | 9 ++ src/test/ui/expr/if/issue-4201.stderr | 18 +++ .../cleanup-rvalue-during-if-and-while.rs | 43 +++++ src/test/ui/html-literals.rs | 94 ----------- src/test/ui/hygiene/issue-40847.rs | 17 ++ src/test/ui/issue-6157.rs | 23 +++ src/test/ui/issues/issue-13837.rs | 13 -- src/test/ui/issues/issue-17718-references.rs | 24 --- src/test/ui/issues/issue-17718-references.stderr | 27 ---- src/test/ui/issues/issue-20616-3.rs | 35 ----- src/test/ui/issues/issue-20616-3.stderr | 8 - src/test/ui/issues/issue-21726.rs | 38 ----- src/test/ui/issues/issue-22560.rs | 15 -- src/test/ui/issues/issue-22560.stderr | 60 ------- src/test/ui/issues/issue-23595-2.rs | 10 -- src/test/ui/issues/issue-23595-2.stderr | 9 -- src/test/ui/issues/issue-24204.rs | 25 --- src/test/ui/issues/issue-31924-non-snake-ffi.rs | 8 - src/test/ui/issues/issue-32829.rs | 6 - src/test/ui/issues/issue-32829.stderr | 13 -- src/test/ui/issues/issue-33537.rs | 14 -- src/test/ui/issues/issue-40847.rs | 17 -- src/test/ui/issues/issue-4201.rs | 9 -- src/test/ui/issues/issue-4201.stderr | 18 --- src/test/ui/issues/issue-43784-associated-type.rs | 17 -- .../ui/issues/issue-43784-associated-type.stderr | 17 -- src/test/ui/issues/issue-44406.rs | 10 -- src/test/ui/issues/issue-44406.stderr | 25 --- src/test/ui/issues/issue-6157.rs | 23 --- src/test/ui/issues/issue-77993-2.rs | 9 -- src/test/ui/issues/issue-77993-2.stderr | 8 - src/test/ui/lint/issue-31924-non-snake-ffi.rs | 8 + src/test/ui/macros/html-literals.rs | 94 +++++++++++ src/test/ui/old-suffixes-are-really-forbidden.rs | 4 - .../ui/old-suffixes-are-really-forbidden.stderr | 18 --- src/test/ui/one-tuple.rs | 15 -- src/test/ui/parser/dotdotdot-expr.rs | 4 + src/test/ui/parser/dotdotdot-expr.stderr | 17 ++ src/test/ui/parser/issue-20616-3.rs | 35 +++++ src/test/ui/parser/issue-20616-3.stderr | 8 + src/test/ui/parser/issue-44406.rs | 10 ++ src/test/ui/parser/issue-44406.stderr | 25 +++ .../ui/parser/old-suffixes-are-really-forbidden.rs | 4 + .../old-suffixes-are-really-forbidden.stderr | 18 +++ src/test/ui/parser/struct-literal-variant-in-if.rs | 25 +++ .../ui/parser/struct-literal-variant-in-if.stderr | 76 +++++++++ src/test/ui/project-defer-unification.rs | 104 ------------- src/test/ui/range_inclusive_gate.rs | 14 -- ...ions-fn-subtyping-return-static-fail.nll.stderr | 8 - .../ui/regions-fn-subtyping-return-static-fail.rs | 51 ------ .../regions-fn-subtyping-return-static-fail.stderr | 12 -- ...ions-fn-subtyping-return-static-fail.nll.stderr | 8 + .../regions-fn-subtyping-return-static-fail.rs | 51 ++++++ .../regions-fn-subtyping-return-static-fail.stderr | 12 ++ src/test/ui/repeat_count_const_in_async_fn.rs | 10 -- .../rmeta/emit-artifact-notifications.nll.stderr | 1 + .../emit-artifact-notifications.polonius.stderr | 1 + src/test/ui/rmeta/emit-artifact-notifications.rs | 8 + .../ui/rmeta/emit-artifact-notifications.stderr | 1 + src/test/ui/rmeta/emit-metadata-obj.rs | 7 + src/test/ui/rvalue-static-promotion.rs | 19 --- src/test/ui/struct-literal-variant-in-if.rs | 25 --- src/test/ui/struct-literal-variant-in-if.stderr | 76 --------- src/test/ui/structs-enums/type-sizes.rs | 173 +++++++++++++++++++++ src/test/ui/tuple/one-tuple.rs | 15 ++ src/test/ui/type-id-higher-rank.rs | 72 --------- src/test/ui/type-sizes.rs | 173 --------------------- .../ui/unboxed-closures/type-id-higher-rank.rs | 72 +++++++++ src/test/ui/write-to-static-mut-in-static.rs | 10 -- src/test/ui/write-to-static-mut-in-static.stderr | 24 --- src/tools/tidy/src/ui_tests.rs | 4 +- 102 files changed, 1275 insertions(+), 1289 deletions(-) create mode 100644 src/test/ui/associated-types/issue-21726.rs create mode 100644 src/test/ui/associated-types/issue-22560.rs create mode 100644 src/test/ui/associated-types/issue-22560.stderr create mode 100644 src/test/ui/associated-types/issue-23595-2.rs create mode 100644 src/test/ui/associated-types/issue-23595-2.stderr create mode 100644 src/test/ui/associated-types/issue-24204.rs create mode 100644 src/test/ui/associated-types/issue-43784-associated-type.rs create mode 100644 src/test/ui/associated-types/issue-43784-associated-type.stderr create mode 100644 src/test/ui/associated-types/project-defer-unification.rs create mode 100644 src/test/ui/async-await/issue-77993-2.rs create mode 100644 src/test/ui/async-await/issue-77993-2.stderr create mode 100644 src/test/ui/async-await/repeat_count_const_in_async_fn.rs delete mode 100644 src/test/ui/cleanup-rvalue-during-if-and-while.rs create mode 100644 src/test/ui/consts/issue-13837.rs create mode 100644 src/test/ui/consts/issue-17718-references.rs create mode 100644 src/test/ui/consts/issue-17718-references.stderr create mode 100644 src/test/ui/consts/issue-32829.rs create mode 100644 src/test/ui/consts/issue-32829.stderr create mode 100644 src/test/ui/consts/issue-33537.rs create mode 100644 src/test/ui/consts/rvalue-static-promotion.rs create mode 100644 src/test/ui/consts/write-to-static-mut-in-static.rs create mode 100644 src/test/ui/consts/write-to-static-mut-in-static.stderr delete mode 100644 src/test/ui/dotdotdot-expr.rs delete mode 100644 src/test/ui/dotdotdot-expr.stderr delete mode 100644 src/test/ui/emit-artifact-notifications.nll.stderr delete mode 100644 src/test/ui/emit-artifact-notifications.polonius.stderr delete mode 100644 src/test/ui/emit-artifact-notifications.rs delete mode 100644 src/test/ui/emit-artifact-notifications.stderr delete mode 100644 src/test/ui/emit-metadata-obj.rs delete mode 100644 src/test/ui/expr-if-panic.rs create mode 100644 src/test/ui/expr/if/expr-if-panic-pass.rs create mode 100644 src/test/ui/expr/if/issue-4201.rs create mode 100644 src/test/ui/expr/if/issue-4201.stderr create mode 100644 src/test/ui/for-loop-while/cleanup-rvalue-during-if-and-while.rs delete mode 100644 src/test/ui/html-literals.rs create mode 100644 src/test/ui/hygiene/issue-40847.rs create mode 100644 src/test/ui/issue-6157.rs delete mode 100644 src/test/ui/issues/issue-13837.rs delete mode 100644 src/test/ui/issues/issue-17718-references.rs delete mode 100644 src/test/ui/issues/issue-17718-references.stderr delete mode 100644 src/test/ui/issues/issue-20616-3.rs delete mode 100644 src/test/ui/issues/issue-20616-3.stderr delete mode 100644 src/test/ui/issues/issue-21726.rs delete mode 100644 src/test/ui/issues/issue-22560.rs delete mode 100644 src/test/ui/issues/issue-22560.stderr delete mode 100644 src/test/ui/issues/issue-23595-2.rs delete mode 100644 src/test/ui/issues/issue-23595-2.stderr delete mode 100644 src/test/ui/issues/issue-24204.rs delete mode 100644 src/test/ui/issues/issue-31924-non-snake-ffi.rs delete mode 100644 src/test/ui/issues/issue-32829.rs delete mode 100644 src/test/ui/issues/issue-32829.stderr delete mode 100644 src/test/ui/issues/issue-33537.rs delete mode 100644 src/test/ui/issues/issue-40847.rs delete mode 100644 src/test/ui/issues/issue-4201.rs delete mode 100644 src/test/ui/issues/issue-4201.stderr delete mode 100644 src/test/ui/issues/issue-43784-associated-type.rs delete mode 100644 src/test/ui/issues/issue-43784-associated-type.stderr delete mode 100644 src/test/ui/issues/issue-44406.rs delete mode 100644 src/test/ui/issues/issue-44406.stderr delete mode 100644 src/test/ui/issues/issue-6157.rs delete mode 100644 src/test/ui/issues/issue-77993-2.rs delete mode 100644 src/test/ui/issues/issue-77993-2.stderr create mode 100644 src/test/ui/lint/issue-31924-non-snake-ffi.rs create mode 100644 src/test/ui/macros/html-literals.rs delete mode 100644 src/test/ui/old-suffixes-are-really-forbidden.rs delete mode 100644 src/test/ui/old-suffixes-are-really-forbidden.stderr delete mode 100644 src/test/ui/one-tuple.rs create mode 100644 src/test/ui/parser/dotdotdot-expr.rs create mode 100644 src/test/ui/parser/dotdotdot-expr.stderr create mode 100644 src/test/ui/parser/issue-20616-3.rs create mode 100644 src/test/ui/parser/issue-20616-3.stderr create mode 100644 src/test/ui/parser/issue-44406.rs create mode 100644 src/test/ui/parser/issue-44406.stderr create mode 100644 src/test/ui/parser/old-suffixes-are-really-forbidden.rs create mode 100644 src/test/ui/parser/old-suffixes-are-really-forbidden.stderr create mode 100644 src/test/ui/parser/struct-literal-variant-in-if.rs create mode 100644 src/test/ui/parser/struct-literal-variant-in-if.stderr delete mode 100644 src/test/ui/project-defer-unification.rs delete mode 100644 src/test/ui/range_inclusive_gate.rs delete mode 100644 src/test/ui/regions-fn-subtyping-return-static-fail.nll.stderr delete mode 100644 src/test/ui/regions-fn-subtyping-return-static-fail.rs delete mode 100644 src/test/ui/regions-fn-subtyping-return-static-fail.stderr create mode 100644 src/test/ui/regions/regions-fn-subtyping-return-static-fail.nll.stderr create mode 100644 src/test/ui/regions/regions-fn-subtyping-return-static-fail.rs create mode 100644 src/test/ui/regions/regions-fn-subtyping-return-static-fail.stderr delete mode 100644 src/test/ui/repeat_count_const_in_async_fn.rs create mode 100644 src/test/ui/rmeta/emit-artifact-notifications.nll.stderr create mode 100644 src/test/ui/rmeta/emit-artifact-notifications.polonius.stderr create mode 100644 src/test/ui/rmeta/emit-artifact-notifications.rs create mode 100644 src/test/ui/rmeta/emit-artifact-notifications.stderr create mode 100644 src/test/ui/rmeta/emit-metadata-obj.rs delete mode 100644 src/test/ui/rvalue-static-promotion.rs delete mode 100644 src/test/ui/struct-literal-variant-in-if.rs delete mode 100644 src/test/ui/struct-literal-variant-in-if.stderr create mode 100644 src/test/ui/structs-enums/type-sizes.rs create mode 100644 src/test/ui/tuple/one-tuple.rs delete mode 100644 src/test/ui/type-id-higher-rank.rs delete mode 100644 src/test/ui/type-sizes.rs create mode 100644 src/test/ui/unboxed-closures/type-id-higher-rank.rs delete mode 100644 src/test/ui/write-to-static-mut-in-static.rs delete mode 100644 src/test/ui/write-to-static-mut-in-static.stderr diff --git a/src/test/ui/associated-types/issue-21726.rs b/src/test/ui/associated-types/issue-21726.rs new file mode 100644 index 00000000000..b98cf216695 --- /dev/null +++ b/src/test/ui/associated-types/issue-21726.rs @@ -0,0 +1,38 @@ +// check-pass +#![allow(dead_code)] +// Regression test for #21726: an issue arose around the rules for +// subtyping of projection types that resulted in an unconstrained +// region, yielding region inference failures. + +// pretty-expanded FIXME #23616 + +fn main() { } + +fn foo<'a>(s: &'a str) { + let b: B<()> = B::new(s, ()); + b.get_short(); +} + +trait IntoRef<'a> { + type T: Clone; + fn into_ref(self, _: &'a str) -> Self::T; +} + +impl<'a> IntoRef<'a> for () { + type T = &'a str; + fn into_ref(self, s: &'a str) -> &'a str { + s + } +} + +struct B<'a, P: IntoRef<'a>>(P::T); + +impl<'a, P: IntoRef<'a>> B<'a, P> { + fn new(s: &'a str, i: P) -> B<'a, P> { + B(i.into_ref(s)) + } + + fn get_short(&self) -> P::T { + self.0.clone() + } +} diff --git a/src/test/ui/associated-types/issue-22560.rs b/src/test/ui/associated-types/issue-22560.rs new file mode 100644 index 00000000000..44be8817b08 --- /dev/null +++ b/src/test/ui/associated-types/issue-22560.rs @@ -0,0 +1,15 @@ +trait Add { + type Output; +} + +trait Sub { + type Output; +} + +type Test = dyn Add + Sub; +//~^ ERROR E0393 +//~| ERROR E0191 +//~| ERROR E0393 +//~| ERROR E0225 + +fn main() { } diff --git a/src/test/ui/associated-types/issue-22560.stderr b/src/test/ui/associated-types/issue-22560.stderr new file mode 100644 index 00000000000..9dda99109fa --- /dev/null +++ b/src/test/ui/associated-types/issue-22560.stderr @@ -0,0 +1,60 @@ +error[E0393]: the type parameter `Rhs` must be explicitly specified + --> $DIR/issue-22560.rs:9:23 + | +LL | / trait Sub { +LL | | type Output; +LL | | } + | |_- type parameter `Rhs` must be specified for this +LL | +LL | type Test = dyn Add + Sub; + | ^^^ help: set the type parameter to the desired type: `Sub` + | + = note: because of the default `Self` reference, type parameters must be specified on object types + +error[E0393]: the type parameter `Rhs` must be explicitly specified + --> $DIR/issue-22560.rs:9:17 + | +LL | / trait Add { +LL | | type Output; +LL | | } + | |_- type parameter `Rhs` must be specified for this +... +LL | type Test = dyn Add + Sub; + | ^^^ help: set the type parameter to the desired type: `Add` + | + = note: because of the default `Self` reference, type parameters must be specified on object types + +error[E0225]: only auto traits can be used as additional traits in a trait object + --> $DIR/issue-22560.rs:9:23 + | +LL | type Test = dyn Add + Sub; + | --- ^^^ additional non-auto trait + | | + | first non-auto trait + | + = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Add<[type error]> + Sub<[type error]> {}` + = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit + +error[E0191]: the value of the associated types `Output` (from trait `Add`), `Output` (from trait `Sub`) must be specified + --> $DIR/issue-22560.rs:9:17 + | +LL | type Output; + | ------------ `Output` defined here +... +LL | type Output; + | ------------ `Output` defined here +... +LL | type Test = dyn Add + Sub; + | ^^^ ^^^ associated type `Output` must be specified + | | + | associated type `Output` must be specified + | +help: specify the associated types + | +LL | type Test = dyn Add + Sub; + | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0191, E0225, E0393. +For more information about an error, try `rustc --explain E0191`. diff --git a/src/test/ui/associated-types/issue-23595-2.rs b/src/test/ui/associated-types/issue-23595-2.rs new file mode 100644 index 00000000000..2bfee7a35fa --- /dev/null +++ b/src/test/ui/associated-types/issue-23595-2.rs @@ -0,0 +1,10 @@ +#![feature(associated_type_defaults)] + +pub struct C {a:AType} + +pub trait A { + type B = C; + //~^ ERROR: associated type `anything_here_kills_it` not found for `Self` +} + +fn main() {} diff --git a/src/test/ui/associated-types/issue-23595-2.stderr b/src/test/ui/associated-types/issue-23595-2.stderr new file mode 100644 index 00000000000..dded673f6ee --- /dev/null +++ b/src/test/ui/associated-types/issue-23595-2.stderr @@ -0,0 +1,9 @@ +error[E0220]: associated type `anything_here_kills_it` not found for `Self` + --> $DIR/issue-23595-2.rs:6:22 + | +LL | type B = C; + | ^^^^^^^^^^^^^^^^^^^^^^ associated type `anything_here_kills_it` not found + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0220`. diff --git a/src/test/ui/associated-types/issue-24204.rs b/src/test/ui/associated-types/issue-24204.rs new file mode 100644 index 00000000000..5a7b3459589 --- /dev/null +++ b/src/test/ui/associated-types/issue-24204.rs @@ -0,0 +1,25 @@ +// check-pass + +#![allow(dead_code)] + +trait MultiDispatch { + type O; +} + +trait Trait: Sized { + type A: MultiDispatch; + type B; + + fn new(u: U) -> >::O + where + Self::A: MultiDispatch; +} + +fn test>(b: i32) -> T +where + T::A: MultiDispatch, +{ + T::new(b) +} + +fn main() {} diff --git a/src/test/ui/associated-types/issue-43784-associated-type.rs b/src/test/ui/associated-types/issue-43784-associated-type.rs new file mode 100644 index 00000000000..78815d8d3fa --- /dev/null +++ b/src/test/ui/associated-types/issue-43784-associated-type.rs @@ -0,0 +1,17 @@ +pub trait Partial: Copy { +} + +pub trait Complete { + type Assoc: Partial; +} + +impl Partial for T::Assoc where + T: Complete +{ +} + +impl Complete for T { + type Assoc = T; //~ ERROR the trait bound `T: Copy` is not satisfied +} + +fn main() {} diff --git a/src/test/ui/associated-types/issue-43784-associated-type.stderr b/src/test/ui/associated-types/issue-43784-associated-type.stderr new file mode 100644 index 00000000000..d5105ae3b58 --- /dev/null +++ b/src/test/ui/associated-types/issue-43784-associated-type.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `T: Copy` is not satisfied + --> $DIR/issue-43784-associated-type.rs:14:5 + | +LL | type Assoc: Partial; + | ------------- required by this bound in `Complete::Assoc` +... +LL | type Assoc = T; + | ^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` + | +help: consider restricting type parameter `T` + | +LL | impl Complete for T { + | ^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/project-defer-unification.rs b/src/test/ui/associated-types/project-defer-unification.rs new file mode 100644 index 00000000000..547ff45c229 --- /dev/null +++ b/src/test/ui/associated-types/project-defer-unification.rs @@ -0,0 +1,104 @@ +// run-pass + +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unreachable_code)] +// A regression test extracted from image-0.3.11. The point of +// failure was in `index_colors` below. + +use std::ops::{Deref, DerefMut}; + +#[derive(Copy, Clone)] +pub struct Luma { pub data: [T; 1] } + +impl Pixel for Luma { + type Subpixel = T; +} + +pub struct ImageBuffer { + pixels: P, + c: Container, +} + +pub trait GenericImage: Sized { + type Pixel: Pixel; +} + +pub trait Pixel: Copy + Clone { + type Subpixel: Primitive; +} + +pub trait Primitive: Copy + PartialOrd + Clone { +} + +impl GenericImage for ImageBuffer +where P: Pixel + 'static, + Container: Deref + DerefMut, + P::Subpixel: 'static { + + type Pixel = P; +} + +impl Primitive for u8 { } + +impl ImageBuffer +where P: Pixel + 'static, + P::Subpixel: 'static, + Container: Deref +{ + pub fn pixels<'a>(&'a self) -> Pixels<'a, Self> { + loop { } + } + + pub fn pixels_mut(&mut self) -> PixelsMut

{ + loop { } + } +} + +pub struct Pixels<'a, I: 'a> { + image: &'a I, + x: u32, + y: u32, + width: u32, + height: u32 +} + +impl<'a, I: GenericImage> Iterator for Pixels<'a, I> { + type Item = (u32, u32, I::Pixel); + + fn next(&mut self) -> Option<(u32, u32, I::Pixel)> { + loop { } + } +} + +pub struct PixelsMut<'a, P: Pixel + 'a> where P::Subpixel: 'a { + chunks: &'a mut P::Subpixel +} + +impl<'a, P: Pixel + 'a> Iterator for PixelsMut<'a, P> where P::Subpixel: 'a { + type Item = &'a mut P; + + fn next(&mut self) -> Option<&'a mut P> { + loop { } + } +} + +pub fn index_colors(image: &ImageBuffer>) + -> ImageBuffer, Vec> +where Pix: Pixel + 'static, +{ + // When NLL-enabled, `let mut` below is deemed unnecessary (due to + // the remaining code being unreachable); so ignore that lint. + #![allow(unused_mut)] + + let mut indices: ImageBuffer<_,Vec<_>> = loop { }; + for (pixel, idx) in image.pixels().zip(indices.pixels_mut()) { + // failured occurred here ^^ because we were requiring that we + // could project Pixel or Subpixel from `T_indices` (type of + // `indices`), but the type is insufficiently constrained + // until we reach the return below. + } + indices +} + +fn main() { } diff --git a/src/test/ui/async-await/issue-77993-2.rs b/src/test/ui/async-await/issue-77993-2.rs new file mode 100644 index 00000000000..4d554a0a1d0 --- /dev/null +++ b/src/test/ui/async-await/issue-77993-2.rs @@ -0,0 +1,9 @@ +// edition:2018 + +async fn test() -> Result<(), Box> { + macro!(); + //~^ ERROR expected identifier, found `!` + Ok(()) +} + +fn main() {} diff --git a/src/test/ui/async-await/issue-77993-2.stderr b/src/test/ui/async-await/issue-77993-2.stderr new file mode 100644 index 00000000000..64b378f83fc --- /dev/null +++ b/src/test/ui/async-await/issue-77993-2.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `!` + --> $DIR/issue-77993-2.rs:4:10 + | +LL | macro!(); + | ^ expected identifier + +error: aborting due to previous error + diff --git a/src/test/ui/async-await/repeat_count_const_in_async_fn.rs b/src/test/ui/async-await/repeat_count_const_in_async_fn.rs new file mode 100644 index 00000000000..ebabc3fbf10 --- /dev/null +++ b/src/test/ui/async-await/repeat_count_const_in_async_fn.rs @@ -0,0 +1,10 @@ +// check-pass +// edition:2018 +// compile-flags: --crate-type=lib + +pub async fn test() { + const C: usize = 4; + foo(&mut [0u8; C]).await; +} + +async fn foo(_: &mut [u8]) {} diff --git a/src/test/ui/cleanup-rvalue-during-if-and-while.rs b/src/test/ui/cleanup-rvalue-during-if-and-while.rs deleted file mode 100644 index 6fecb4e76da..00000000000 --- a/src/test/ui/cleanup-rvalue-during-if-and-while.rs +++ /dev/null @@ -1,43 +0,0 @@ -// run-pass -// This test verifies that temporaries created for `while`'s and `if` -// conditions are dropped after the condition is evaluated. - -#![feature(box_syntax)] - -struct Temporary; - -static mut DROPPED: isize = 0; - -impl Drop for Temporary { - fn drop(&mut self) { - unsafe { DROPPED += 1; } - } -} - -impl Temporary { - fn do_stuff(&self) -> bool {true} -} - -fn borrow() -> Box { box Temporary } - - -pub fn main() { - let mut i = 0; - - // This loop's condition - // should call `Temporary`'s - // `drop` 6 times. - while borrow().do_stuff() { - i += 1; - unsafe { assert_eq!(DROPPED, i) } - if i > 5 { - break; - } - } - - // This if condition should - // call it 1 time - if borrow().do_stuff() { - unsafe { assert_eq!(DROPPED, i + 1) } - } -} diff --git a/src/test/ui/consts/issue-13837.rs b/src/test/ui/consts/issue-13837.rs new file mode 100644 index 00000000000..645b1c0eb87 --- /dev/null +++ b/src/test/ui/consts/issue-13837.rs @@ -0,0 +1,13 @@ +// check-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +struct TestStruct { + x: *const [isize; 2] +} + +unsafe impl Sync for TestStruct {} + +static TEST_VALUE : TestStruct = TestStruct{x: 0x1234 as *const [isize; 2]}; + +fn main() {} diff --git a/src/test/ui/consts/issue-17718-references.rs b/src/test/ui/consts/issue-17718-references.rs new file mode 100644 index 00000000000..03d5f8bb3f1 --- /dev/null +++ b/src/test/ui/consts/issue-17718-references.rs @@ -0,0 +1,24 @@ +#![allow(warnings)] + +struct Struct { a: usize } + +const C: usize = 1; +static S: usize = 1; + +const T1: &'static usize = &C; +const T2: &'static usize = &S; //~ ERROR: constants cannot refer to statics +static T3: &'static usize = &C; +static T4: &'static usize = &S; + +const T5: usize = C; +const T6: usize = S; //~ ERROR: constants cannot refer to statics +static T7: usize = C; +static T8: usize = S; + +const T9: Struct = Struct { a: C }; +const T10: Struct = Struct { a: S }; +//~^ ERROR: constants cannot refer to statics +static T11: Struct = Struct { a: C }; +static T12: Struct = Struct { a: S }; + +fn main() {} diff --git a/src/test/ui/consts/issue-17718-references.stderr b/src/test/ui/consts/issue-17718-references.stderr new file mode 100644 index 00000000000..e3c3b369ffb --- /dev/null +++ b/src/test/ui/consts/issue-17718-references.stderr @@ -0,0 +1,27 @@ +error[E0013]: constants cannot refer to statics + --> $DIR/issue-17718-references.rs:9:29 + | +LL | const T2: &'static usize = &S; + | ^ + | + = help: consider extracting the value of the `static` to a `const`, and referring to that + +error[E0013]: constants cannot refer to statics + --> $DIR/issue-17718-references.rs:14:19 + | +LL | const T6: usize = S; + | ^ + | + = help: consider extracting the value of the `static` to a `const`, and referring to that + +error[E0013]: constants cannot refer to statics + --> $DIR/issue-17718-references.rs:19:33 + | +LL | const T10: Struct = Struct { a: S }; + | ^ + | + = help: consider extracting the value of the `static` to a `const`, and referring to that + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0013`. diff --git a/src/test/ui/consts/issue-32829.rs b/src/test/ui/consts/issue-32829.rs new file mode 100644 index 00000000000..adfee7b925c --- /dev/null +++ b/src/test/ui/consts/issue-32829.rs @@ -0,0 +1,6 @@ +static S : u64 = { { panic!("foo"); 0 } }; +//~^ ERROR panicking in statics is unstable + +fn main() { + println!("{:?}", S); +} diff --git a/src/test/ui/consts/issue-32829.stderr b/src/test/ui/consts/issue-32829.stderr new file mode 100644 index 00000000000..48e0880d5ed --- /dev/null +++ b/src/test/ui/consts/issue-32829.stderr @@ -0,0 +1,13 @@ +error[E0658]: panicking in statics is unstable + --> $DIR/issue-32829.rs:1:22 + | +LL | static S : u64 = { { panic!("foo"); 0 } }; + | ^^^^^^^^^^^^^^ + | + = note: see issue #51999 for more information + = help: add `#![feature(const_panic)]` to the crate attributes to enable + = note: this error originates in a 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 E0658`. diff --git a/src/test/ui/consts/issue-33537.rs b/src/test/ui/consts/issue-33537.rs new file mode 100644 index 00000000000..3539aa64776 --- /dev/null +++ b/src/test/ui/consts/issue-33537.rs @@ -0,0 +1,14 @@ +// run-pass + +const fn foo() -> *const i8 { + b"foo" as *const _ as *const i8 +} + +const fn bar() -> i32 { + *&{(1, 2, 3).1} +} + +fn main() { + assert_eq!(foo(), b"foo" as *const _ as *const i8); + assert_eq!(bar(), 2); +} diff --git a/src/test/ui/consts/rvalue-static-promotion.rs b/src/test/ui/consts/rvalue-static-promotion.rs new file mode 100644 index 00000000000..2d7e4ab3989 --- /dev/null +++ b/src/test/ui/consts/rvalue-static-promotion.rs @@ -0,0 +1,19 @@ +// run-pass + +use std::cell::Cell; + +const NONE_CELL_STRING: Option> = None; + +struct Foo(T); +impl Foo { + const FOO: Option> = None; +} + +fn main() { + let _: &'static u32 = &42; + let _: &'static Option = &None; + + // We should be able to peek at consts and see they're None. + let _: &'static Option> = &NONE_CELL_STRING; + let _: &'static Option> = &Foo::FOO; +} diff --git a/src/test/ui/consts/write-to-static-mut-in-static.rs b/src/test/ui/consts/write-to-static-mut-in-static.rs new file mode 100644 index 00000000000..43c63fed8ce --- /dev/null +++ b/src/test/ui/consts/write-to-static-mut-in-static.rs @@ -0,0 +1,10 @@ +pub static mut A: u32 = 0; +pub static mut B: () = unsafe { A = 1; }; +//~^ ERROR could not evaluate static initializer + +pub static mut C: u32 = unsafe { C = 1; 0 }; +//~^ ERROR cycle detected + +pub static D: u32 = D; + +fn main() {} diff --git a/src/test/ui/consts/write-to-static-mut-in-static.stderr b/src/test/ui/consts/write-to-static-mut-in-static.stderr new file mode 100644 index 00000000000..789919bd166 --- /dev/null +++ b/src/test/ui/consts/write-to-static-mut-in-static.stderr @@ -0,0 +1,24 @@ +error[E0080]: could not evaluate static initializer + --> $DIR/write-to-static-mut-in-static.rs:2:33 + | +LL | pub static mut B: () = unsafe { A = 1; }; + | ^^^^^ modifying a static's initial value from another static's initializer + +error[E0391]: cycle detected when const-evaluating + checking `C` + --> $DIR/write-to-static-mut-in-static.rs:5:1 + | +LL | pub static mut C: u32 = unsafe { C = 1; 0 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...which requires const-evaluating + checking `C`... + --> $DIR/write-to-static-mut-in-static.rs:5:1 + | +LL | pub static mut C: u32 = unsafe { C = 1; 0 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires const-evaluating + checking `C`, completing the cycle + = note: cycle used when running analysis passes on this crate + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0080, E0391. +For more information about an error, try `rustc --explain E0080`. diff --git a/src/test/ui/dotdotdot-expr.rs b/src/test/ui/dotdotdot-expr.rs deleted file mode 100644 index d842fb6e030..00000000000 --- a/src/test/ui/dotdotdot-expr.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() { - let _redemptive = 1...21; - //~^ ERROR unexpected token -} diff --git a/src/test/ui/dotdotdot-expr.stderr b/src/test/ui/dotdotdot-expr.stderr deleted file mode 100644 index ec1335cfdb0..00000000000 --- a/src/test/ui/dotdotdot-expr.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: unexpected token: `...` - --> $DIR/dotdotdot-expr.rs:2:24 - | -LL | let _redemptive = 1...21; - | ^^^ - | -help: use `..` for an exclusive range - | -LL | let _redemptive = 1..21; - | ^^ -help: or `..=` for an inclusive range - | -LL | let _redemptive = 1..=21; - | ^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/emit-artifact-notifications.nll.stderr b/src/test/ui/emit-artifact-notifications.nll.stderr deleted file mode 100644 index 5547631a4b0..00000000000 --- a/src/test/ui/emit-artifact-notifications.nll.stderr +++ /dev/null @@ -1 +0,0 @@ -{"artifact":"$TEST_BUILD_DIR/emit-artifact-notifications.nll/libemit_artifact_notifications.rmeta","emit":"metadata"} diff --git a/src/test/ui/emit-artifact-notifications.polonius.stderr b/src/test/ui/emit-artifact-notifications.polonius.stderr deleted file mode 100644 index 47b48b399c2..00000000000 --- a/src/test/ui/emit-artifact-notifications.polonius.stderr +++ /dev/null @@ -1 +0,0 @@ -{"artifact":"$TEST_BUILD_DIR/emit-artifact-notifications.polonius/libemit_artifact_notifications.rmeta","emit":"metadata"} diff --git a/src/test/ui/emit-artifact-notifications.rs b/src/test/ui/emit-artifact-notifications.rs deleted file mode 100644 index 984a7fabb66..00000000000 --- a/src/test/ui/emit-artifact-notifications.rs +++ /dev/null @@ -1,8 +0,0 @@ -// compile-flags:--emit=metadata --error-format=json --json artifacts -// build-pass -// ignore-pass -// ^-- needed because `--pass check` does not emit the output needed. - -// A very basic test for the emission of artifact notifications in JSON output. - -fn main() {} diff --git a/src/test/ui/emit-artifact-notifications.stderr b/src/test/ui/emit-artifact-notifications.stderr deleted file mode 100644 index 260d41b8f15..00000000000 --- a/src/test/ui/emit-artifact-notifications.stderr +++ /dev/null @@ -1 +0,0 @@ -{"artifact":"$TEST_BUILD_DIR/emit-artifact-notifications/libemit_artifact_notifications.rmeta","emit":"metadata"} diff --git a/src/test/ui/emit-metadata-obj.rs b/src/test/ui/emit-metadata-obj.rs deleted file mode 100644 index 334c7cc5b81..00000000000 --- a/src/test/ui/emit-metadata-obj.rs +++ /dev/null @@ -1,7 +0,0 @@ -// compile-flags:--emit=metadata,obj -// build-pass - -// A test for the emission of metadata + obj and other metadata + non-link -// combinations. See issue #81117. - -fn main() {} diff --git a/src/test/ui/expr-if-panic.rs b/src/test/ui/expr-if-panic.rs deleted file mode 100644 index 6069cd835e1..00000000000 --- a/src/test/ui/expr-if-panic.rs +++ /dev/null @@ -1,18 +0,0 @@ -// run-pass - -fn test_if_panic() { - let x = if false { panic!() } else { 10 }; - assert_eq!(x, 10); -} - -fn test_else_panic() { - let x = if true { 10 } else { panic!() }; - assert_eq!(x, 10); -} - -fn test_elseif_panic() { - let x = if false { 0 } else if false { panic!() } else { 10 }; - assert_eq!(x, 10); -} - -pub fn main() { test_if_panic(); test_else_panic(); test_elseif_panic(); } diff --git a/src/test/ui/expr/if/expr-if-panic-pass.rs b/src/test/ui/expr/if/expr-if-panic-pass.rs new file mode 100644 index 00000000000..6069cd835e1 --- /dev/null +++ b/src/test/ui/expr/if/expr-if-panic-pass.rs @@ -0,0 +1,18 @@ +// run-pass + +fn test_if_panic() { + let x = if false { panic!() } else { 10 }; + assert_eq!(x, 10); +} + +fn test_else_panic() { + let x = if true { 10 } else { panic!() }; + assert_eq!(x, 10); +} + +fn test_elseif_panic() { + let x = if false { 0 } else if false { panic!() } else { 10 }; + assert_eq!(x, 10); +} + +pub fn main() { test_if_panic(); test_else_panic(); test_elseif_panic(); } diff --git a/src/test/ui/expr/if/issue-4201.rs b/src/test/ui/expr/if/issue-4201.rs new file mode 100644 index 00000000000..1f292229fd6 --- /dev/null +++ b/src/test/ui/expr/if/issue-4201.rs @@ -0,0 +1,9 @@ +fn main() { + let a = if true { + 0 + } else if false { +//~^ ERROR `if` may be missing an `else` clause +//~| expected `()`, found integer + 1 + }; +} diff --git a/src/test/ui/expr/if/issue-4201.stderr b/src/test/ui/expr/if/issue-4201.stderr new file mode 100644 index 00000000000..bc638ddf55b --- /dev/null +++ b/src/test/ui/expr/if/issue-4201.stderr @@ -0,0 +1,18 @@ +error[E0317]: `if` may be missing an `else` clause + --> $DIR/issue-4201.rs:4:12 + | +LL | } else if false { + | ____________^ +LL | | +LL | | +LL | | 1 + | | - found here +LL | | }; + | |_____^ expected `()`, found integer + | + = note: `if` expressions without `else` evaluate to `()` + = help: consider adding an `else` block that evaluates to the expected type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0317`. diff --git a/src/test/ui/for-loop-while/cleanup-rvalue-during-if-and-while.rs b/src/test/ui/for-loop-while/cleanup-rvalue-during-if-and-while.rs new file mode 100644 index 00000000000..6fecb4e76da --- /dev/null +++ b/src/test/ui/for-loop-while/cleanup-rvalue-during-if-and-while.rs @@ -0,0 +1,43 @@ +// run-pass +// This test verifies that temporaries created for `while`'s and `if` +// conditions are dropped after the condition is evaluated. + +#![feature(box_syntax)] + +struct Temporary; + +static mut DROPPED: isize = 0; + +impl Drop for Temporary { + fn drop(&mut self) { + unsafe { DROPPED += 1; } + } +} + +impl Temporary { + fn do_stuff(&self) -> bool {true} +} + +fn borrow() -> Box { box Temporary } + + +pub fn main() { + let mut i = 0; + + // This loop's condition + // should call `Temporary`'s + // `drop` 6 times. + while borrow().do_stuff() { + i += 1; + unsafe { assert_eq!(DROPPED, i) } + if i > 5 { + break; + } + } + + // This if condition should + // call it 1 time + if borrow().do_stuff() { + unsafe { assert_eq!(DROPPED, i + 1) } + } +} diff --git a/src/test/ui/html-literals.rs b/src/test/ui/html-literals.rs deleted file mode 100644 index ae45e97c8b0..00000000000 --- a/src/test/ui/html-literals.rs +++ /dev/null @@ -1,94 +0,0 @@ -// run-pass - -#![allow(non_camel_case_types)] -// A test of the macro system. Can we do HTML literals? - -/* - -This is an HTML parser written as a macro. It's all CPS, and we have -to carry around a bunch of state. The arguments to macros all look like this: - -{ tag_stack* # expr* # tokens } - -The stack keeps track of where we are in the tree. The expr is a list -of children of the current node. The tokens are everything that's -left. - -*/ -use HTMLFragment::{tag, text}; - -macro_rules! html { - ( $($body:tt)* ) => ( - parse_node!( []; []; $($body)* ) - ) -} - -macro_rules! parse_node { - ( - [:$head:ident ($(:$head_nodes:expr),*) - $(:$tags:ident ($(:$tag_nodes:expr),*))*]; - [$(:$nodes:expr),*]; - $($rest:tt)* - ) => ( - parse_node!( - [$(: $tags ($(:$tag_nodes),*))*]; - [$(:$head_nodes,)* :tag(stringify!($head).to_string(), - vec![$($nodes),*])]; - $($rest)* - ) - ); - - ( - [$(:$tags:ident ($(:$tag_nodes:expr),*) )*]; - [$(:$nodes:expr),*]; - <$tag:ident> $($rest:tt)* - ) => ( - parse_node!( - [:$tag ($(:$nodes)*) $(: $tags ($(:$tag_nodes),*) )*]; - []; - $($rest)* - ) - ); - - ( - [$(:$tags:ident ($(:$tag_nodes:expr),*) )*]; - [$(:$nodes:expr),*]; - . $($rest:tt)* - ) => ( - parse_node!( - [$(: $tags ($(:$tag_nodes),*))*]; - [$(:$nodes,)* :text(".".to_string())]; - $($rest)* - ) - ); - - ( - [$(:$tags:ident ($(:$tag_nodes:expr),*) )*]; - [$(:$nodes:expr),*]; - $word:ident $($rest:tt)* - ) => ( - parse_node!( - [$(: $tags ($(:$tag_nodes),*))*]; - [$(:$nodes,)* :text(stringify!($word).to_string())]; - $($rest)* - ) - ); - - ( []; [:$e:expr]; ) => ( $e ); -} - -pub fn main() { - let _page = html! ( - - This is the title. - -

This is some text

- - - ); -} - -enum HTMLFragment { - tag(String, Vec ), - text(String), -} diff --git a/src/test/ui/hygiene/issue-40847.rs b/src/test/ui/hygiene/issue-40847.rs new file mode 100644 index 00000000000..087b40ad6cd --- /dev/null +++ b/src/test/ui/hygiene/issue-40847.rs @@ -0,0 +1,17 @@ +// run-pass +macro_rules! gen { + ($name:ident ( $($dol:tt $var:ident)* ) $($body:tt)*) => { + macro_rules! $name { + ($($dol $var:ident)*) => { + $($body)* + } + } + } +} + +gen!(m($var) $var); + +fn main() { + let x = 1; + assert_eq!(m!(x), 1); +} diff --git a/src/test/ui/issue-6157.rs b/src/test/ui/issue-6157.rs new file mode 100644 index 00000000000..b7a44ed8623 --- /dev/null +++ b/src/test/ui/issue-6157.rs @@ -0,0 +1,23 @@ +// run-pass +// pretty-expanded FIXME #23616 + +pub trait OpInt { fn call(&mut self, _: isize, _: isize) -> isize; } + +impl OpInt for F where F: FnMut(isize, isize) -> isize { + fn call(&mut self, a:isize, b:isize) -> isize { + (*self)(a, b) + } +} + +fn squarei<'a>(x: isize, op: &'a mut dyn OpInt) -> isize { op.call(x, x) } + +fn muli(x:isize, y:isize) -> isize { x * y } + +pub fn main() { + let mut f = |x, y| muli(x, y); + { + let g = &mut f; + let h = g as &mut dyn OpInt; + squarei(3, h); + } +} diff --git a/src/test/ui/issues/issue-13837.rs b/src/test/ui/issues/issue-13837.rs deleted file mode 100644 index 645b1c0eb87..00000000000 --- a/src/test/ui/issues/issue-13837.rs +++ /dev/null @@ -1,13 +0,0 @@ -// check-pass -#![allow(dead_code)] -// pretty-expanded FIXME #23616 - -struct TestStruct { - x: *const [isize; 2] -} - -unsafe impl Sync for TestStruct {} - -static TEST_VALUE : TestStruct = TestStruct{x: 0x1234 as *const [isize; 2]}; - -fn main() {} diff --git a/src/test/ui/issues/issue-17718-references.rs b/src/test/ui/issues/issue-17718-references.rs deleted file mode 100644 index 03d5f8bb3f1..00000000000 --- a/src/test/ui/issues/issue-17718-references.rs +++ /dev/null @@ -1,24 +0,0 @@ -#![allow(warnings)] - -struct Struct { a: usize } - -const C: usize = 1; -static S: usize = 1; - -const T1: &'static usize = &C; -const T2: &'static usize = &S; //~ ERROR: constants cannot refer to statics -static T3: &'static usize = &C; -static T4: &'static usize = &S; - -const T5: usize = C; -const T6: usize = S; //~ ERROR: constants cannot refer to statics -static T7: usize = C; -static T8: usize = S; - -const T9: Struct = Struct { a: C }; -const T10: Struct = Struct { a: S }; -//~^ ERROR: constants cannot refer to statics -static T11: Struct = Struct { a: C }; -static T12: Struct = Struct { a: S }; - -fn main() {} diff --git a/src/test/ui/issues/issue-17718-references.stderr b/src/test/ui/issues/issue-17718-references.stderr deleted file mode 100644 index e3c3b369ffb..00000000000 --- a/src/test/ui/issues/issue-17718-references.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0013]: constants cannot refer to statics - --> $DIR/issue-17718-references.rs:9:29 - | -LL | const T2: &'static usize = &S; - | ^ - | - = help: consider extracting the value of the `static` to a `const`, and referring to that - -error[E0013]: constants cannot refer to statics - --> $DIR/issue-17718-references.rs:14:19 - | -LL | const T6: usize = S; - | ^ - | - = help: consider extracting the value of the `static` to a `const`, and referring to that - -error[E0013]: constants cannot refer to statics - --> $DIR/issue-17718-references.rs:19:33 - | -LL | const T10: Struct = Struct { a: S }; - | ^ - | - = help: consider extracting the value of the `static` to a `const`, and referring to that - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0013`. diff --git a/src/test/ui/issues/issue-20616-3.rs b/src/test/ui/issues/issue-20616-3.rs deleted file mode 100644 index b2371051c78..00000000000 --- a/src/test/ui/issues/issue-20616-3.rs +++ /dev/null @@ -1,35 +0,0 @@ -// We need all these 9 issue-20616-N.rs files -// because we can only catch one parsing error at a time - -type Type_1_<'a, T> = &'a T; - - -//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` - - -//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` - - -type Type_3 = Box; -//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,` - - -//type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` - - -type Type_5_<'a> = Type_1_<'a, ()>; - - -//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` - - -//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` - - -//type Type_7 = Box<(),,>; // error: expected type, found `,` - - -//type Type_8<'a,,> = &'a (); // error: expected ident, found `,` - - -//type Type_9 = Box; // error: expected ident, found `,` diff --git a/src/test/ui/issues/issue-20616-3.stderr b/src/test/ui/issues/issue-20616-3.stderr deleted file mode 100644 index b535c7a3267..00000000000 --- a/src/test/ui/issues/issue-20616-3.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: expected one of `>`, a const expression, lifetime, or type, found `,` - --> $DIR/issue-20616-3.rs:13:24 - | -LL | type Type_3 = Box; - | ^ expected one of `>`, a const expression, lifetime, or type - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-21726.rs b/src/test/ui/issues/issue-21726.rs deleted file mode 100644 index b98cf216695..00000000000 --- a/src/test/ui/issues/issue-21726.rs +++ /dev/null @@ -1,38 +0,0 @@ -// check-pass -#![allow(dead_code)] -// Regression test for #21726: an issue arose around the rules for -// subtyping of projection types that resulted in an unconstrained -// region, yielding region inference failures. - -// pretty-expanded FIXME #23616 - -fn main() { } - -fn foo<'a>(s: &'a str) { - let b: B<()> = B::new(s, ()); - b.get_short(); -} - -trait IntoRef<'a> { - type T: Clone; - fn into_ref(self, _: &'a str) -> Self::T; -} - -impl<'a> IntoRef<'a> for () { - type T = &'a str; - fn into_ref(self, s: &'a str) -> &'a str { - s - } -} - -struct B<'a, P: IntoRef<'a>>(P::T); - -impl<'a, P: IntoRef<'a>> B<'a, P> { - fn new(s: &'a str, i: P) -> B<'a, P> { - B(i.into_ref(s)) - } - - fn get_short(&self) -> P::T { - self.0.clone() - } -} diff --git a/src/test/ui/issues/issue-22560.rs b/src/test/ui/issues/issue-22560.rs deleted file mode 100644 index 44be8817b08..00000000000 --- a/src/test/ui/issues/issue-22560.rs +++ /dev/null @@ -1,15 +0,0 @@ -trait Add { - type Output; -} - -trait Sub { - type Output; -} - -type Test = dyn Add + Sub; -//~^ ERROR E0393 -//~| ERROR E0191 -//~| ERROR E0393 -//~| ERROR E0225 - -fn main() { } diff --git a/src/test/ui/issues/issue-22560.stderr b/src/test/ui/issues/issue-22560.stderr deleted file mode 100644 index 9dda99109fa..00000000000 --- a/src/test/ui/issues/issue-22560.stderr +++ /dev/null @@ -1,60 +0,0 @@ -error[E0393]: the type parameter `Rhs` must be explicitly specified - --> $DIR/issue-22560.rs:9:23 - | -LL | / trait Sub { -LL | | type Output; -LL | | } - | |_- type parameter `Rhs` must be specified for this -LL | -LL | type Test = dyn Add + Sub; - | ^^^ help: set the type parameter to the desired type: `Sub` - | - = note: because of the default `Self` reference, type parameters must be specified on object types - -error[E0393]: the type parameter `Rhs` must be explicitly specified - --> $DIR/issue-22560.rs:9:17 - | -LL | / trait Add { -LL | | type Output; -LL | | } - | |_- type parameter `Rhs` must be specified for this -... -LL | type Test = dyn Add + Sub; - | ^^^ help: set the type parameter to the desired type: `Add` - | - = note: because of the default `Self` reference, type parameters must be specified on object types - -error[E0225]: only auto traits can be used as additional traits in a trait object - --> $DIR/issue-22560.rs:9:23 - | -LL | type Test = dyn Add + Sub; - | --- ^^^ additional non-auto trait - | | - | first non-auto trait - | - = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Add<[type error]> + Sub<[type error]> {}` - = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit - -error[E0191]: the value of the associated types `Output` (from trait `Add`), `Output` (from trait `Sub`) must be specified - --> $DIR/issue-22560.rs:9:17 - | -LL | type Output; - | ------------ `Output` defined here -... -LL | type Output; - | ------------ `Output` defined here -... -LL | type Test = dyn Add + Sub; - | ^^^ ^^^ associated type `Output` must be specified - | | - | associated type `Output` must be specified - | -help: specify the associated types - | -LL | type Test = dyn Add + Sub; - | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0191, E0225, E0393. -For more information about an error, try `rustc --explain E0191`. diff --git a/src/test/ui/issues/issue-23595-2.rs b/src/test/ui/issues/issue-23595-2.rs deleted file mode 100644 index 2bfee7a35fa..00000000000 --- a/src/test/ui/issues/issue-23595-2.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(associated_type_defaults)] - -pub struct C {a:AType} - -pub trait A { - type B = C; - //~^ ERROR: associated type `anything_here_kills_it` not found for `Self` -} - -fn main() {} diff --git a/src/test/ui/issues/issue-23595-2.stderr b/src/test/ui/issues/issue-23595-2.stderr deleted file mode 100644 index dded673f6ee..00000000000 --- a/src/test/ui/issues/issue-23595-2.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0220]: associated type `anything_here_kills_it` not found for `Self` - --> $DIR/issue-23595-2.rs:6:22 - | -LL | type B = C; - | ^^^^^^^^^^^^^^^^^^^^^^ associated type `anything_here_kills_it` not found - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0220`. diff --git a/src/test/ui/issues/issue-24204.rs b/src/test/ui/issues/issue-24204.rs deleted file mode 100644 index 5a7b3459589..00000000000 --- a/src/test/ui/issues/issue-24204.rs +++ /dev/null @@ -1,25 +0,0 @@ -// check-pass - -#![allow(dead_code)] - -trait MultiDispatch { - type O; -} - -trait Trait: Sized { - type A: MultiDispatch; - type B; - - fn new(u: U) -> >::O - where - Self::A: MultiDispatch; -} - -fn test>(b: i32) -> T -where - T::A: MultiDispatch, -{ - T::new(b) -} - -fn main() {} diff --git a/src/test/ui/issues/issue-31924-non-snake-ffi.rs b/src/test/ui/issues/issue-31924-non-snake-ffi.rs deleted file mode 100644 index 63e42b48442..00000000000 --- a/src/test/ui/issues/issue-31924-non-snake-ffi.rs +++ /dev/null @@ -1,8 +0,0 @@ -// check-pass - -#![deny(non_snake_case)] - -#[no_mangle] -pub extern "C" fn SparklingGenerationForeignFunctionInterface() {} // OK - -fn main() {} diff --git a/src/test/ui/issues/issue-32829.rs b/src/test/ui/issues/issue-32829.rs deleted file mode 100644 index adfee7b925c..00000000000 --- a/src/test/ui/issues/issue-32829.rs +++ /dev/null @@ -1,6 +0,0 @@ -static S : u64 = { { panic!("foo"); 0 } }; -//~^ ERROR panicking in statics is unstable - -fn main() { - println!("{:?}", S); -} diff --git a/src/test/ui/issues/issue-32829.stderr b/src/test/ui/issues/issue-32829.stderr deleted file mode 100644 index 48e0880d5ed..00000000000 --- a/src/test/ui/issues/issue-32829.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: panicking in statics is unstable - --> $DIR/issue-32829.rs:1:22 - | -LL | static S : u64 = { { panic!("foo"); 0 } }; - | ^^^^^^^^^^^^^^ - | - = note: see issue #51999 for more information - = help: add `#![feature(const_panic)]` to the crate attributes to enable - = note: this error originates in a 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 E0658`. diff --git a/src/test/ui/issues/issue-33537.rs b/src/test/ui/issues/issue-33537.rs deleted file mode 100644 index 3539aa64776..00000000000 --- a/src/test/ui/issues/issue-33537.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-pass - -const fn foo() -> *const i8 { - b"foo" as *const _ as *const i8 -} - -const fn bar() -> i32 { - *&{(1, 2, 3).1} -} - -fn main() { - assert_eq!(foo(), b"foo" as *const _ as *const i8); - assert_eq!(bar(), 2); -} diff --git a/src/test/ui/issues/issue-40847.rs b/src/test/ui/issues/issue-40847.rs deleted file mode 100644 index 087b40ad6cd..00000000000 --- a/src/test/ui/issues/issue-40847.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass -macro_rules! gen { - ($name:ident ( $($dol:tt $var:ident)* ) $($body:tt)*) => { - macro_rules! $name { - ($($dol $var:ident)*) => { - $($body)* - } - } - } -} - -gen!(m($var) $var); - -fn main() { - let x = 1; - assert_eq!(m!(x), 1); -} diff --git a/src/test/ui/issues/issue-4201.rs b/src/test/ui/issues/issue-4201.rs deleted file mode 100644 index 1f292229fd6..00000000000 --- a/src/test/ui/issues/issue-4201.rs +++ /dev/null @@ -1,9 +0,0 @@ -fn main() { - let a = if true { - 0 - } else if false { -//~^ ERROR `if` may be missing an `else` clause -//~| expected `()`, found integer - 1 - }; -} diff --git a/src/test/ui/issues/issue-4201.stderr b/src/test/ui/issues/issue-4201.stderr deleted file mode 100644 index bc638ddf55b..00000000000 --- a/src/test/ui/issues/issue-4201.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0317]: `if` may be missing an `else` clause - --> $DIR/issue-4201.rs:4:12 - | -LL | } else if false { - | ____________^ -LL | | -LL | | -LL | | 1 - | | - found here -LL | | }; - | |_____^ expected `()`, found integer - | - = note: `if` expressions without `else` evaluate to `()` - = help: consider adding an `else` block that evaluates to the expected type - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0317`. diff --git a/src/test/ui/issues/issue-43784-associated-type.rs b/src/test/ui/issues/issue-43784-associated-type.rs deleted file mode 100644 index 78815d8d3fa..00000000000 --- a/src/test/ui/issues/issue-43784-associated-type.rs +++ /dev/null @@ -1,17 +0,0 @@ -pub trait Partial: Copy { -} - -pub trait Complete { - type Assoc: Partial; -} - -impl Partial for T::Assoc where - T: Complete -{ -} - -impl Complete for T { - type Assoc = T; //~ ERROR the trait bound `T: Copy` is not satisfied -} - -fn main() {} diff --git a/src/test/ui/issues/issue-43784-associated-type.stderr b/src/test/ui/issues/issue-43784-associated-type.stderr deleted file mode 100644 index d5105ae3b58..00000000000 --- a/src/test/ui/issues/issue-43784-associated-type.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/issue-43784-associated-type.rs:14:5 - | -LL | type Assoc: Partial; - | ------------- required by this bound in `Complete::Assoc` -... -LL | type Assoc = T; - | ^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` - | -help: consider restricting type parameter `T` - | -LL | impl Complete for T { - | ^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/issues/issue-44406.rs b/src/test/ui/issues/issue-44406.rs deleted file mode 100644 index 83bbf884a4f..00000000000 --- a/src/test/ui/issues/issue-44406.rs +++ /dev/null @@ -1,10 +0,0 @@ -macro_rules! foo { - ($rest: tt) => { - bar(baz: $rest) - } -} - -fn main() { - foo!(true); //~ ERROR expected type, found keyword - //~^ ERROR expected identifier, found keyword -} diff --git a/src/test/ui/issues/issue-44406.stderr b/src/test/ui/issues/issue-44406.stderr deleted file mode 100644 index 701c32d6236..00000000000 --- a/src/test/ui/issues/issue-44406.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error: expected identifier, found keyword `true` - --> $DIR/issue-44406.rs:8:10 - | -LL | foo!(true); - | ^^^^ expected identifier, found keyword - | -help: you can escape reserved keywords to use them as identifiers - | -LL | foo!(r#true); - | ^^^^^^ - -error: expected type, found keyword `true` - --> $DIR/issue-44406.rs:8:10 - | -LL | bar(baz: $rest) - | - help: try using a semicolon: `;` -... -LL | foo!(true); - | ^^^^ expected type - | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` - = note: see issue #23416 for more information - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/issues/issue-6157.rs b/src/test/ui/issues/issue-6157.rs deleted file mode 100644 index b7a44ed8623..00000000000 --- a/src/test/ui/issues/issue-6157.rs +++ /dev/null @@ -1,23 +0,0 @@ -// run-pass -// pretty-expanded FIXME #23616 - -pub trait OpInt { fn call(&mut self, _: isize, _: isize) -> isize; } - -impl OpInt for F where F: FnMut(isize, isize) -> isize { - fn call(&mut self, a:isize, b:isize) -> isize { - (*self)(a, b) - } -} - -fn squarei<'a>(x: isize, op: &'a mut dyn OpInt) -> isize { op.call(x, x) } - -fn muli(x:isize, y:isize) -> isize { x * y } - -pub fn main() { - let mut f = |x, y| muli(x, y); - { - let g = &mut f; - let h = g as &mut dyn OpInt; - squarei(3, h); - } -} diff --git a/src/test/ui/issues/issue-77993-2.rs b/src/test/ui/issues/issue-77993-2.rs deleted file mode 100644 index 4d554a0a1d0..00000000000 --- a/src/test/ui/issues/issue-77993-2.rs +++ /dev/null @@ -1,9 +0,0 @@ -// edition:2018 - -async fn test() -> Result<(), Box> { - macro!(); - //~^ ERROR expected identifier, found `!` - Ok(()) -} - -fn main() {} diff --git a/src/test/ui/issues/issue-77993-2.stderr b/src/test/ui/issues/issue-77993-2.stderr deleted file mode 100644 index 64b378f83fc..00000000000 --- a/src/test/ui/issues/issue-77993-2.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: expected identifier, found `!` - --> $DIR/issue-77993-2.rs:4:10 - | -LL | macro!(); - | ^ expected identifier - -error: aborting due to previous error - diff --git a/src/test/ui/lint/issue-31924-non-snake-ffi.rs b/src/test/ui/lint/issue-31924-non-snake-ffi.rs new file mode 100644 index 00000000000..63e42b48442 --- /dev/null +++ b/src/test/ui/lint/issue-31924-non-snake-ffi.rs @@ -0,0 +1,8 @@ +// check-pass + +#![deny(non_snake_case)] + +#[no_mangle] +pub extern "C" fn SparklingGenerationForeignFunctionInterface() {} // OK + +fn main() {} diff --git a/src/test/ui/macros/html-literals.rs b/src/test/ui/macros/html-literals.rs new file mode 100644 index 00000000000..ae45e97c8b0 --- /dev/null +++ b/src/test/ui/macros/html-literals.rs @@ -0,0 +1,94 @@ +// run-pass + +#![allow(non_camel_case_types)] +// A test of the macro system. Can we do HTML literals? + +/* + +This is an HTML parser written as a macro. It's all CPS, and we have +to carry around a bunch of state. The arguments to macros all look like this: + +{ tag_stack* # expr* # tokens } + +The stack keeps track of where we are in the tree. The expr is a list +of children of the current node. The tokens are everything that's +left. + +*/ +use HTMLFragment::{tag, text}; + +macro_rules! html { + ( $($body:tt)* ) => ( + parse_node!( []; []; $($body)* ) + ) +} + +macro_rules! parse_node { + ( + [:$head:ident ($(:$head_nodes:expr),*) + $(:$tags:ident ($(:$tag_nodes:expr),*))*]; + [$(:$nodes:expr),*]; + $($rest:tt)* + ) => ( + parse_node!( + [$(: $tags ($(:$tag_nodes),*))*]; + [$(:$head_nodes,)* :tag(stringify!($head).to_string(), + vec![$($nodes),*])]; + $($rest)* + ) + ); + + ( + [$(:$tags:ident ($(:$tag_nodes:expr),*) )*]; + [$(:$nodes:expr),*]; + <$tag:ident> $($rest:tt)* + ) => ( + parse_node!( + [:$tag ($(:$nodes)*) $(: $tags ($(:$tag_nodes),*) )*]; + []; + $($rest)* + ) + ); + + ( + [$(:$tags:ident ($(:$tag_nodes:expr),*) )*]; + [$(:$nodes:expr),*]; + . $($rest:tt)* + ) => ( + parse_node!( + [$(: $tags ($(:$tag_nodes),*))*]; + [$(:$nodes,)* :text(".".to_string())]; + $($rest)* + ) + ); + + ( + [$(:$tags:ident ($(:$tag_nodes:expr),*) )*]; + [$(:$nodes:expr),*]; + $word:ident $($rest:tt)* + ) => ( + parse_node!( + [$(: $tags ($(:$tag_nodes),*))*]; + [$(:$nodes,)* :text(stringify!($word).to_string())]; + $($rest)* + ) + ); + + ( []; [:$e:expr]; ) => ( $e ); +} + +pub fn main() { + let _page = html! ( + + This is the title. + +

This is some text

+ + + ); +} + +enum HTMLFragment { + tag(String, Vec ), + text(String), +} diff --git a/src/test/ui/old-suffixes-are-really-forbidden.rs b/src/test/ui/old-suffixes-are-really-forbidden.rs deleted file mode 100644 index eea95b7d626..00000000000 --- a/src/test/ui/old-suffixes-are-really-forbidden.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() { - let a = 1_is; //~ ERROR invalid suffix - let b = 2_us; //~ ERROR invalid suffix -} diff --git a/src/test/ui/old-suffixes-are-really-forbidden.stderr b/src/test/ui/old-suffixes-are-really-forbidden.stderr deleted file mode 100644 index fb309793b34..00000000000 --- a/src/test/ui/old-suffixes-are-really-forbidden.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: invalid suffix `is` for number literal - --> $DIR/old-suffixes-are-really-forbidden.rs:2:13 - | -LL | let a = 1_is; - | ^^^^ invalid suffix `is` - | - = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) - -error: invalid suffix `us` for number literal - --> $DIR/old-suffixes-are-really-forbidden.rs:3:13 - | -LL | let b = 2_us; - | ^^^^ invalid suffix `us` - | - = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/one-tuple.rs b/src/test/ui/one-tuple.rs deleted file mode 100644 index 00fbadce1ac..00000000000 --- a/src/test/ui/one-tuple.rs +++ /dev/null @@ -1,15 +0,0 @@ -// run-pass -// Why one-tuples? Because macros. - - -pub fn main() { - match ('c',) { - (x,) => { - assert_eq!(x, 'c'); - } - } - // test the 1-tuple type too - let x: (char,) = ('d',); - let (y,) = x; - assert_eq!(y, 'd'); -} diff --git a/src/test/ui/parser/dotdotdot-expr.rs b/src/test/ui/parser/dotdotdot-expr.rs new file mode 100644 index 00000000000..d842fb6e030 --- /dev/null +++ b/src/test/ui/parser/dotdotdot-expr.rs @@ -0,0 +1,4 @@ +fn main() { + let _redemptive = 1...21; + //~^ ERROR unexpected token +} diff --git a/src/test/ui/parser/dotdotdot-expr.stderr b/src/test/ui/parser/dotdotdot-expr.stderr new file mode 100644 index 00000000000..ec1335cfdb0 --- /dev/null +++ b/src/test/ui/parser/dotdotdot-expr.stderr @@ -0,0 +1,17 @@ +error: unexpected token: `...` + --> $DIR/dotdotdot-expr.rs:2:24 + | +LL | let _redemptive = 1...21; + | ^^^ + | +help: use `..` for an exclusive range + | +LL | let _redemptive = 1..21; + | ^^ +help: or `..=` for an inclusive range + | +LL | let _redemptive = 1..=21; + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-20616-3.rs b/src/test/ui/parser/issue-20616-3.rs new file mode 100644 index 00000000000..b2371051c78 --- /dev/null +++ b/src/test/ui/parser/issue-20616-3.rs @@ -0,0 +1,35 @@ +// We need all these 9 issue-20616-N.rs files +// because we can only catch one parsing error at a time + +type Type_1_<'a, T> = &'a T; + + +//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` + + +//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` + + +type Type_3 = Box; +//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,` + + +//type Type_4 = Type_1_<'static,, T>; // error: expected type, found `,` + + +type Type_5_<'a> = Type_1_<'a, ()>; + + +//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` + + +//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` + + +//type Type_7 = Box<(),,>; // error: expected type, found `,` + + +//type Type_8<'a,,> = &'a (); // error: expected ident, found `,` + + +//type Type_9 = Box; // error: expected ident, found `,` diff --git a/src/test/ui/parser/issue-20616-3.stderr b/src/test/ui/parser/issue-20616-3.stderr new file mode 100644 index 00000000000..b535c7a3267 --- /dev/null +++ b/src/test/ui/parser/issue-20616-3.stderr @@ -0,0 +1,8 @@ +error: expected one of `>`, a const expression, lifetime, or type, found `,` + --> $DIR/issue-20616-3.rs:13:24 + | +LL | type Type_3 = Box; + | ^ expected one of `>`, a const expression, lifetime, or type + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-44406.rs b/src/test/ui/parser/issue-44406.rs new file mode 100644 index 00000000000..83bbf884a4f --- /dev/null +++ b/src/test/ui/parser/issue-44406.rs @@ -0,0 +1,10 @@ +macro_rules! foo { + ($rest: tt) => { + bar(baz: $rest) + } +} + +fn main() { + foo!(true); //~ ERROR expected type, found keyword + //~^ ERROR expected identifier, found keyword +} diff --git a/src/test/ui/parser/issue-44406.stderr b/src/test/ui/parser/issue-44406.stderr new file mode 100644 index 00000000000..701c32d6236 --- /dev/null +++ b/src/test/ui/parser/issue-44406.stderr @@ -0,0 +1,25 @@ +error: expected identifier, found keyword `true` + --> $DIR/issue-44406.rs:8:10 + | +LL | foo!(true); + | ^^^^ expected identifier, found keyword + | +help: you can escape reserved keywords to use them as identifiers + | +LL | foo!(r#true); + | ^^^^^^ + +error: expected type, found keyword `true` + --> $DIR/issue-44406.rs:8:10 + | +LL | bar(baz: $rest) + | - help: try using a semicolon: `;` +... +LL | foo!(true); + | ^^^^ expected type + | + = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` + = note: see issue #23416 for more information + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/old-suffixes-are-really-forbidden.rs b/src/test/ui/parser/old-suffixes-are-really-forbidden.rs new file mode 100644 index 00000000000..eea95b7d626 --- /dev/null +++ b/src/test/ui/parser/old-suffixes-are-really-forbidden.rs @@ -0,0 +1,4 @@ +fn main() { + let a = 1_is; //~ ERROR invalid suffix + let b = 2_us; //~ ERROR invalid suffix +} diff --git a/src/test/ui/parser/old-suffixes-are-really-forbidden.stderr b/src/test/ui/parser/old-suffixes-are-really-forbidden.stderr new file mode 100644 index 00000000000..fb309793b34 --- /dev/null +++ b/src/test/ui/parser/old-suffixes-are-really-forbidden.stderr @@ -0,0 +1,18 @@ +error: invalid suffix `is` for number literal + --> $DIR/old-suffixes-are-really-forbidden.rs:2:13 + | +LL | let a = 1_is; + | ^^^^ invalid suffix `is` + | + = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) + +error: invalid suffix `us` for number literal + --> $DIR/old-suffixes-are-really-forbidden.rs:3:13 + | +LL | let b = 2_us; + | ^^^^ invalid suffix `us` + | + = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/parser/struct-literal-variant-in-if.rs b/src/test/ui/parser/struct-literal-variant-in-if.rs new file mode 100644 index 00000000000..4ef8effaf1f --- /dev/null +++ b/src/test/ui/parser/struct-literal-variant-in-if.rs @@ -0,0 +1,25 @@ +#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] +enum E { + V { field: bool }, + I { field1: bool, field2: usize }, + J { field: isize }, + K { field: &'static str}, +} +fn test_E(x: E) { + let field = true; + if x == E::V { field } {} + //~^ ERROR expected value, found struct variant `E::V` + //~| ERROR mismatched types + if x == E::I { field1: true, field2: 42 } {} + //~^ ERROR struct literals are not allowed here + if x == E::V { field: false } {} + //~^ ERROR struct literals are not allowed here + if x == E::J { field: -42 } {} + //~^ ERROR struct literals are not allowed here + if x == E::K { field: "" } {} + //~^ ERROR struct literals are not allowed here + let y: usize = (); + //~^ ERROR mismatched types +} + +fn main() {} diff --git a/src/test/ui/parser/struct-literal-variant-in-if.stderr b/src/test/ui/parser/struct-literal-variant-in-if.stderr new file mode 100644 index 00000000000..a2252d4e4d2 --- /dev/null +++ b/src/test/ui/parser/struct-literal-variant-in-if.stderr @@ -0,0 +1,76 @@ +error: struct literals are not allowed here + --> $DIR/struct-literal-variant-in-if.rs:13:13 + | +LL | if x == E::I { field1: true, field2: 42 } {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: surround the struct literal with parentheses + | +LL | if x == (E::I { field1: true, field2: 42 }) {} + | ^ ^ + +error: struct literals are not allowed here + --> $DIR/struct-literal-variant-in-if.rs:15:13 + | +LL | if x == E::V { field: false } {} + | ^^^^^^^^^^^^^^^^^^^^^ + | +help: surround the struct literal with parentheses + | +LL | if x == (E::V { field: false }) {} + | ^ ^ + +error: struct literals are not allowed here + --> $DIR/struct-literal-variant-in-if.rs:17:13 + | +LL | if x == E::J { field: -42 } {} + | ^^^^^^^^^^^^^^^^^^^ + | +help: surround the struct literal with parentheses + | +LL | if x == (E::J { field: -42 }) {} + | ^ ^ + +error: struct literals are not allowed here + --> $DIR/struct-literal-variant-in-if.rs:19:13 + | +LL | if x == E::K { field: "" } {} + | ^^^^^^^^^^^^^^^^^^ + | +help: surround the struct literal with parentheses + | +LL | if x == (E::K { field: "" }) {} + | ^ ^ + +error[E0423]: expected value, found struct variant `E::V` + --> $DIR/struct-literal-variant-in-if.rs:10:13 + | +LL | if x == E::V { field } {} + | ^^^^ not a value + | +help: surround the struct literal with parentheses + | +LL | if x == (E::V { field }) {} + | ^ ^ + +error[E0308]: mismatched types + --> $DIR/struct-literal-variant-in-if.rs:10:20 + | +LL | if x == E::V { field } {} + | ---------------^^^^^--- help: consider using a semicolon here + | | | + | | expected `()`, found `bool` + | expected this to be `()` + +error[E0308]: mismatched types + --> $DIR/struct-literal-variant-in-if.rs:21:20 + | +LL | let y: usize = (); + | ----- ^^ expected `usize`, found `()` + | | + | expected due to this + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0308, E0423. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/project-defer-unification.rs b/src/test/ui/project-defer-unification.rs deleted file mode 100644 index 547ff45c229..00000000000 --- a/src/test/ui/project-defer-unification.rs +++ /dev/null @@ -1,104 +0,0 @@ -// run-pass - -#![allow(dead_code)] -#![allow(unused_variables)] -#![allow(unreachable_code)] -// A regression test extracted from image-0.3.11. The point of -// failure was in `index_colors` below. - -use std::ops::{Deref, DerefMut}; - -#[derive(Copy, Clone)] -pub struct Luma { pub data: [T; 1] } - -impl Pixel for Luma { - type Subpixel = T; -} - -pub struct ImageBuffer { - pixels: P, - c: Container, -} - -pub trait GenericImage: Sized { - type Pixel: Pixel; -} - -pub trait Pixel: Copy + Clone { - type Subpixel: Primitive; -} - -pub trait Primitive: Copy + PartialOrd + Clone { -} - -impl GenericImage for ImageBuffer -where P: Pixel + 'static, - Container: Deref + DerefMut, - P::Subpixel: 'static { - - type Pixel = P; -} - -impl Primitive for u8 { } - -impl ImageBuffer -where P: Pixel + 'static, - P::Subpixel: 'static, - Container: Deref -{ - pub fn pixels<'a>(&'a self) -> Pixels<'a, Self> { - loop { } - } - - pub fn pixels_mut(&mut self) -> PixelsMut

{ - loop { } - } -} - -pub struct Pixels<'a, I: 'a> { - image: &'a I, - x: u32, - y: u32, - width: u32, - height: u32 -} - -impl<'a, I: GenericImage> Iterator for Pixels<'a, I> { - type Item = (u32, u32, I::Pixel); - - fn next(&mut self) -> Option<(u32, u32, I::Pixel)> { - loop { } - } -} - -pub struct PixelsMut<'a, P: Pixel + 'a> where P::Subpixel: 'a { - chunks: &'a mut P::Subpixel -} - -impl<'a, P: Pixel + 'a> Iterator for PixelsMut<'a, P> where P::Subpixel: 'a { - type Item = &'a mut P; - - fn next(&mut self) -> Option<&'a mut P> { - loop { } - } -} - -pub fn index_colors(image: &ImageBuffer>) - -> ImageBuffer, Vec> -where Pix: Pixel + 'static, -{ - // When NLL-enabled, `let mut` below is deemed unnecessary (due to - // the remaining code being unreachable); so ignore that lint. - #![allow(unused_mut)] - - let mut indices: ImageBuffer<_,Vec<_>> = loop { }; - for (pixel, idx) in image.pixels().zip(indices.pixels_mut()) { - // failured occurred here ^^ because we were requiring that we - // could project Pixel or Subpixel from `T_indices` (type of - // `indices`), but the type is insufficiently constrained - // until we reach the return below. - } - indices -} - -fn main() { } diff --git a/src/test/ui/range_inclusive_gate.rs b/src/test/ui/range_inclusive_gate.rs deleted file mode 100644 index e26e31b44a0..00000000000 --- a/src/test/ui/range_inclusive_gate.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-pass - -#![allow(unused_comparisons)] -// Test that you only need the syntax gate if you don't mention the structs. -// (Obsoleted since both features are stabilized) - -fn main() { - let mut count = 0; - for i in 0_usize..=10 { - assert!(i >= 0 && i <= 10); - count += i; - } - assert_eq!(count, 55); -} diff --git a/src/test/ui/regions-fn-subtyping-return-static-fail.nll.stderr b/src/test/ui/regions-fn-subtyping-return-static-fail.nll.stderr deleted file mode 100644 index d762f55f9d5..00000000000 --- a/src/test/ui/regions-fn-subtyping-return-static-fail.nll.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: higher-ranked subtype error - --> $DIR/regions-fn-subtyping-return-static-fail.rs:48:5 - | -LL | want_G(baz); - | ^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/regions-fn-subtyping-return-static-fail.rs b/src/test/ui/regions-fn-subtyping-return-static-fail.rs deleted file mode 100644 index 539221b5a04..00000000000 --- a/src/test/ui/regions-fn-subtyping-return-static-fail.rs +++ /dev/null @@ -1,51 +0,0 @@ -// In this fn, the type `F` is a function that takes a reference to a -// struct and returns another reference with the same lifetime. -// -// Meanwhile, the bare fn `foo` takes a reference to a struct with -// *ANY* lifetime and returns a reference with the 'static lifetime. -// This can safely be considered to be an instance of `F` because all -// lifetimes are sublifetimes of 'static. - -#![allow(dead_code)] -#![allow(unused_variables)] - -struct S; - -// Given 'cx, return 'cx -type F = for<'cx> fn(&'cx S) -> &'cx S; -fn want_F(f: F) {} - -// Given anything, return 'static -type G = for<'cx> fn(&'cx S) -> &'static S; -fn want_G(f: G) {} - -// Should meet both. -fn foo(x: &S) -> &'static S { - panic!() -} - -// Should meet both. -fn bar<'a, 'b>(x: &'a S) -> &'b S { - panic!() -} - -// Meets F, but not G. -fn baz(x: &S) -> &S { - panic!() -} - -fn supply_F() { - want_F(foo); - - want_F(bar); - - want_F(baz); -} - -fn supply_G() { - want_G(foo); - want_G(bar); - want_G(baz); //~ ERROR mismatched types -} - -pub fn main() {} diff --git a/src/test/ui/regions-fn-subtyping-return-static-fail.stderr b/src/test/ui/regions-fn-subtyping-return-static-fail.stderr deleted file mode 100644 index c9ce936c7d4..00000000000 --- a/src/test/ui/regions-fn-subtyping-return-static-fail.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/regions-fn-subtyping-return-static-fail.rs:48:12 - | -LL | want_G(baz); - | ^^^ one type is more general than the other - | - = note: expected fn pointer `for<'cx> fn(&'cx S) -> &'static S` - found fn pointer `for<'r> fn(&'r S) -> &'r S` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-fn-subtyping-return-static-fail.nll.stderr b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.nll.stderr new file mode 100644 index 00000000000..d762f55f9d5 --- /dev/null +++ b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.nll.stderr @@ -0,0 +1,8 @@ +error: higher-ranked subtype error + --> $DIR/regions-fn-subtyping-return-static-fail.rs:48:5 + | +LL | want_G(baz); + | ^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/regions/regions-fn-subtyping-return-static-fail.rs b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.rs new file mode 100644 index 00000000000..539221b5a04 --- /dev/null +++ b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.rs @@ -0,0 +1,51 @@ +// In this fn, the type `F` is a function that takes a reference to a +// struct and returns another reference with the same lifetime. +// +// Meanwhile, the bare fn `foo` takes a reference to a struct with +// *ANY* lifetime and returns a reference with the 'static lifetime. +// This can safely be considered to be an instance of `F` because all +// lifetimes are sublifetimes of 'static. + +#![allow(dead_code)] +#![allow(unused_variables)] + +struct S; + +// Given 'cx, return 'cx +type F = for<'cx> fn(&'cx S) -> &'cx S; +fn want_F(f: F) {} + +// Given anything, return 'static +type G = for<'cx> fn(&'cx S) -> &'static S; +fn want_G(f: G) {} + +// Should meet both. +fn foo(x: &S) -> &'static S { + panic!() +} + +// Should meet both. +fn bar<'a, 'b>(x: &'a S) -> &'b S { + panic!() +} + +// Meets F, but not G. +fn baz(x: &S) -> &S { + panic!() +} + +fn supply_F() { + want_F(foo); + + want_F(bar); + + want_F(baz); +} + +fn supply_G() { + want_G(foo); + want_G(bar); + want_G(baz); //~ ERROR mismatched types +} + +pub fn main() {} diff --git a/src/test/ui/regions/regions-fn-subtyping-return-static-fail.stderr b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.stderr new file mode 100644 index 00000000000..c9ce936c7d4 --- /dev/null +++ b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/regions-fn-subtyping-return-static-fail.rs:48:12 + | +LL | want_G(baz); + | ^^^ one type is more general than the other + | + = note: expected fn pointer `for<'cx> fn(&'cx S) -> &'static S` + found fn pointer `for<'r> fn(&'r S) -> &'r S` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/repeat_count_const_in_async_fn.rs b/src/test/ui/repeat_count_const_in_async_fn.rs deleted file mode 100644 index ebabc3fbf10..00000000000 --- a/src/test/ui/repeat_count_const_in_async_fn.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass -// edition:2018 -// compile-flags: --crate-type=lib - -pub async fn test() { - const C: usize = 4; - foo(&mut [0u8; C]).await; -} - -async fn foo(_: &mut [u8]) {} diff --git a/src/test/ui/rmeta/emit-artifact-notifications.nll.stderr b/src/test/ui/rmeta/emit-artifact-notifications.nll.stderr new file mode 100644 index 00000000000..ed62f300284 --- /dev/null +++ b/src/test/ui/rmeta/emit-artifact-notifications.nll.stderr @@ -0,0 +1 @@ +{"artifact":"$TEST_BUILD_DIR/rmeta/emit-artifact-notifications.nll/libemit_artifact_notifications.rmeta","emit":"metadata"} diff --git a/src/test/ui/rmeta/emit-artifact-notifications.polonius.stderr b/src/test/ui/rmeta/emit-artifact-notifications.polonius.stderr new file mode 100644 index 00000000000..255c7b370f9 --- /dev/null +++ b/src/test/ui/rmeta/emit-artifact-notifications.polonius.stderr @@ -0,0 +1 @@ +{"artifact":"$TEST_BUILD_DIR/rmeta/emit-artifact-notifications.polonius/libemit_artifact_notifications.rmeta","emit":"metadata"} diff --git a/src/test/ui/rmeta/emit-artifact-notifications.rs b/src/test/ui/rmeta/emit-artifact-notifications.rs new file mode 100644 index 00000000000..984a7fabb66 --- /dev/null +++ b/src/test/ui/rmeta/emit-artifact-notifications.rs @@ -0,0 +1,8 @@ +// compile-flags:--emit=metadata --error-format=json --json artifacts +// build-pass +// ignore-pass +// ^-- needed because `--pass check` does not emit the output needed. + +// A very basic test for the emission of artifact notifications in JSON output. + +fn main() {} diff --git a/src/test/ui/rmeta/emit-artifact-notifications.stderr b/src/test/ui/rmeta/emit-artifact-notifications.stderr new file mode 100644 index 00000000000..b2f0aa7575c --- /dev/null +++ b/src/test/ui/rmeta/emit-artifact-notifications.stderr @@ -0,0 +1 @@ +{"artifact":"$TEST_BUILD_DIR/rmeta/emit-artifact-notifications/libemit_artifact_notifications.rmeta","emit":"metadata"} diff --git a/src/test/ui/rmeta/emit-metadata-obj.rs b/src/test/ui/rmeta/emit-metadata-obj.rs new file mode 100644 index 00000000000..334c7cc5b81 --- /dev/null +++ b/src/test/ui/rmeta/emit-metadata-obj.rs @@ -0,0 +1,7 @@ +// compile-flags:--emit=metadata,obj +// build-pass + +// A test for the emission of metadata + obj and other metadata + non-link +// combinations. See issue #81117. + +fn main() {} diff --git a/src/test/ui/rvalue-static-promotion.rs b/src/test/ui/rvalue-static-promotion.rs deleted file mode 100644 index 2d7e4ab3989..00000000000 --- a/src/test/ui/rvalue-static-promotion.rs +++ /dev/null @@ -1,19 +0,0 @@ -// run-pass - -use std::cell::Cell; - -const NONE_CELL_STRING: Option> = None; - -struct Foo(T); -impl Foo { - const FOO: Option> = None; -} - -fn main() { - let _: &'static u32 = &42; - let _: &'static Option = &None; - - // We should be able to peek at consts and see they're None. - let _: &'static Option> = &NONE_CELL_STRING; - let _: &'static Option> = &Foo::FOO; -} diff --git a/src/test/ui/struct-literal-variant-in-if.rs b/src/test/ui/struct-literal-variant-in-if.rs deleted file mode 100644 index 4ef8effaf1f..00000000000 --- a/src/test/ui/struct-literal-variant-in-if.rs +++ /dev/null @@ -1,25 +0,0 @@ -#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] -enum E { - V { field: bool }, - I { field1: bool, field2: usize }, - J { field: isize }, - K { field: &'static str}, -} -fn test_E(x: E) { - let field = true; - if x == E::V { field } {} - //~^ ERROR expected value, found struct variant `E::V` - //~| ERROR mismatched types - if x == E::I { field1: true, field2: 42 } {} - //~^ ERROR struct literals are not allowed here - if x == E::V { field: false } {} - //~^ ERROR struct literals are not allowed here - if x == E::J { field: -42 } {} - //~^ ERROR struct literals are not allowed here - if x == E::K { field: "" } {} - //~^ ERROR struct literals are not allowed here - let y: usize = (); - //~^ ERROR mismatched types -} - -fn main() {} diff --git a/src/test/ui/struct-literal-variant-in-if.stderr b/src/test/ui/struct-literal-variant-in-if.stderr deleted file mode 100644 index a2252d4e4d2..00000000000 --- a/src/test/ui/struct-literal-variant-in-if.stderr +++ /dev/null @@ -1,76 +0,0 @@ -error: struct literals are not allowed here - --> $DIR/struct-literal-variant-in-if.rs:13:13 - | -LL | if x == E::I { field1: true, field2: 42 } {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: surround the struct literal with parentheses - | -LL | if x == (E::I { field1: true, field2: 42 }) {} - | ^ ^ - -error: struct literals are not allowed here - --> $DIR/struct-literal-variant-in-if.rs:15:13 - | -LL | if x == E::V { field: false } {} - | ^^^^^^^^^^^^^^^^^^^^^ - | -help: surround the struct literal with parentheses - | -LL | if x == (E::V { field: false }) {} - | ^ ^ - -error: struct literals are not allowed here - --> $DIR/struct-literal-variant-in-if.rs:17:13 - | -LL | if x == E::J { field: -42 } {} - | ^^^^^^^^^^^^^^^^^^^ - | -help: surround the struct literal with parentheses - | -LL | if x == (E::J { field: -42 }) {} - | ^ ^ - -error: struct literals are not allowed here - --> $DIR/struct-literal-variant-in-if.rs:19:13 - | -LL | if x == E::K { field: "" } {} - | ^^^^^^^^^^^^^^^^^^ - | -help: surround the struct literal with parentheses - | -LL | if x == (E::K { field: "" }) {} - | ^ ^ - -error[E0423]: expected value, found struct variant `E::V` - --> $DIR/struct-literal-variant-in-if.rs:10:13 - | -LL | if x == E::V { field } {} - | ^^^^ not a value - | -help: surround the struct literal with parentheses - | -LL | if x == (E::V { field }) {} - | ^ ^ - -error[E0308]: mismatched types - --> $DIR/struct-literal-variant-in-if.rs:10:20 - | -LL | if x == E::V { field } {} - | ---------------^^^^^--- help: consider using a semicolon here - | | | - | | expected `()`, found `bool` - | expected this to be `()` - -error[E0308]: mismatched types - --> $DIR/struct-literal-variant-in-if.rs:21:20 - | -LL | let y: usize = (); - | ----- ^^ expected `usize`, found `()` - | | - | expected due to this - -error: aborting due to 7 previous errors - -Some errors have detailed explanations: E0308, E0423. -For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/structs-enums/type-sizes.rs b/src/test/ui/structs-enums/type-sizes.rs new file mode 100644 index 00000000000..73a11a5e743 --- /dev/null +++ b/src/test/ui/structs-enums/type-sizes.rs @@ -0,0 +1,173 @@ +// run-pass + +#![allow(non_camel_case_types)] +#![allow(dead_code)] +#![feature(never_type)] + +use std::mem::size_of; +use std::num::NonZeroU8; + +struct t {a: u8, b: i8} +struct u {a: u8, b: i8, c: u8} +struct v {a: u8, b: i8, c: v2, d: u32} +struct v2 {u: char, v: u8} +struct w {a: isize, b: ()} +struct x {a: isize, b: (), c: ()} +struct y {x: isize} + +enum e1 { + a(u8, u32), b(u32), c +} +enum e2 { + a(u32), b +} + +#[repr(C, u8)] +enum e3 { + a([u16; 0], u8), b +} + +struct ReorderedStruct { + a: u8, + b: u16, + c: u8 +} + +enum ReorderedEnum { + A(u8, u16, u8), + B(u8, u16, u8), +} + +enum ReorderedEnum2 { + A(u8, u32, u8), + B(u16, u8, u16, u8), + + // 0x100 niche variants. + _00, _01, _02, _03, _04, _05, _06, _07, _08, _09, _0A, _0B, _0C, _0D, _0E, _0F, + _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _1A, _1B, _1C, _1D, _1E, _1F, + _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _2A, _2B, _2C, _2D, _2E, _2F, + _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _3A, _3B, _3C, _3D, _3E, _3F, + _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _4A, _4B, _4C, _4D, _4E, _4F, + _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _5A, _5B, _5C, _5D, _5E, _5F, + _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _6A, _6B, _6C, _6D, _6E, _6F, + _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _7A, _7B, _7C, _7D, _7E, _7F, + _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, _8A, _8B, _8C, _8D, _8E, _8F, + _90, _91, _92, _93, _94, _95, _96, _97, _98, _99, _9A, _9B, _9C, _9D, _9E, _9F, + _A0, _A1, _A2, _A3, _A4, _A5, _A6, _A7, _A8, _A9, _AA, _AB, _AC, _AD, _AE, _AF, + _B0, _B1, _B2, _B3, _B4, _B5, _B6, _B7, _B8, _B9, _BA, _BB, _BC, _BD, _BE, _BF, + _C0, _C1, _C2, _C3, _C4, _C5, _C6, _C7, _C8, _C9, _CA, _CB, _CC, _CD, _CE, _CF, + _D0, _D1, _D2, _D3, _D4, _D5, _D6, _D7, _D8, _D9, _DA, _DB, _DC, _DD, _DE, _DF, + _E0, _E1, _E2, _E3, _E4, _E5, _E6, _E7, _E8, _E9, _EA, _EB, _EC, _ED, _EE, _EF, + _F0, _F1, _F2, _F3, _F4, _F5, _F6, _F7, _F8, _F9, _FA, _FB, _FC, _FD, _FE, _FF, +} + +enum EnumEmpty {} + +enum EnumSingle1 { + A, +} + +enum EnumSingle2 { + A = 42 as isize, +} + +enum EnumSingle3 { + A, + B(!), +} + +#[repr(u8)] +enum EnumSingle4 { + A, +} + +#[repr(u8)] +enum EnumSingle5 { + A = 42 as u8, +} + +enum EnumWithMaybeUninhabitedVariant { + A(&'static ()), + B(&'static (), T), + C, +} + +enum NicheFilledEnumWithAbsentVariant { + A(&'static ()), + B((), !), + C, +} + +enum Option2 { + Some(A, B), + None +} + +// Two layouts are considered for `CanBeNicheFilledButShouldnt`: +// Niche-filling: +// { u32 (4 bytes), NonZeroU8 + tag in niche (1 byte), padding (3 bytes) } +// Tagged: +// { tag (1 byte), NonZeroU8 (1 byte), padding (2 bytes), u32 (4 bytes) } +// Both are the same size (due to padding), +// but the tagged layout is better as the tag creates a niche with 254 invalid values, +// allowing types like `Option>` to fit into 8 bytes. +pub enum CanBeNicheFilledButShouldnt { + A(NonZeroU8, u32), + B +} +pub enum AlwaysTaggedBecauseItHasNoNiche { + A(u8, u32), + B +} + +pub fn main() { + assert_eq!(size_of::(), 1 as usize); + assert_eq!(size_of::(), 4 as usize); + assert_eq!(size_of::(), 4 as usize); + assert_eq!(size_of::(), 1 as usize); + assert_eq!(size_of::(), 4 as usize); + assert_eq!(size_of::(), 2 as usize); + assert_eq!(size_of::(), 3 as usize); + // Alignment causes padding before the char and the u32. + + assert_eq!(size_of::(), + 16 as usize); + assert_eq!(size_of::(), size_of::()); + assert_eq!(size_of::(), size_of::()); + assert_eq!(size_of::(), size_of::()); + assert_eq!(size_of::(), size_of::()); + + // Make sure enum types are the appropriate size, mostly + // around ensuring alignment is handled properly + + assert_eq!(size_of::(), 8 as usize); + assert_eq!(size_of::(), 8 as usize); + assert_eq!(size_of::(), 4 as usize); + assert_eq!(size_of::(), 4); + assert_eq!(size_of::(), 6); + assert_eq!(size_of::(), 8); + + + assert_eq!(size_of::(), 0); + assert_eq!(size_of::(), 0); + assert_eq!(size_of::(), 0); + assert_eq!(size_of::(), 0); + assert_eq!(size_of::(), 1); + assert_eq!(size_of::(), 1); + + assert_eq!(size_of::>(), + size_of::>()); + assert_eq!(size_of::(), size_of::<&'static ()>()); + + assert_eq!(size_of::>>(), size_of::<(bool, &())>()); + assert_eq!(size_of::>>(), size_of::<(bool, &())>()); + assert_eq!(size_of::>>(), size_of::<(bool, &())>()); + assert_eq!(size_of::>>(), size_of::<(bool, &())>()); + + assert_eq!(size_of::(), 8); + assert_eq!(size_of::>(), 8); + assert_eq!(size_of::>>(), 8); + assert_eq!(size_of::(), 8); + assert_eq!(size_of::>(), 8); + assert_eq!(size_of::>>(), 8); +} diff --git a/src/test/ui/tuple/one-tuple.rs b/src/test/ui/tuple/one-tuple.rs new file mode 100644 index 00000000000..00fbadce1ac --- /dev/null +++ b/src/test/ui/tuple/one-tuple.rs @@ -0,0 +1,15 @@ +// run-pass +// Why one-tuples? Because macros. + + +pub fn main() { + match ('c',) { + (x,) => { + assert_eq!(x, 'c'); + } + } + // test the 1-tuple type too + let x: (char,) = ('d',); + let (y,) = x; + assert_eq!(y, 'd'); +} diff --git a/src/test/ui/type-id-higher-rank.rs b/src/test/ui/type-id-higher-rank.rs deleted file mode 100644 index 355d1109941..00000000000 --- a/src/test/ui/type-id-higher-rank.rs +++ /dev/null @@ -1,72 +0,0 @@ -// run-pass -// Test that type IDs correctly account for higher-rank lifetimes -// Also acts as a regression test for an ICE (issue #19791) - -use std::any::{Any, TypeId}; - -struct Struct<'a>(&'a ()); -trait Trait<'a> {} - -fn main() { - // Bare fns - { - let a = TypeId::of::(); - let b = TypeId::of:: fn(&'static isize, &'a isize)>(); - let c = TypeId::of:: fn(&'a isize, &'b isize)>(); - let d = TypeId::of:: fn(&'b isize, &'a isize)>(); - assert!(a != b); - assert!(a != c); - assert!(a != d); - assert!(b != c); - assert!(b != d); - assert_eq!(c, d); - - // Make sure De Bruijn indices are handled correctly - let e = TypeId::of:: fn(fn(&'a isize) -> &'a isize)>(); - let f = TypeId::of:: fn(&'a isize) -> &'a isize)>(); - assert!(e != f); - - // Make sure lifetime parameters of items are not ignored. - let g = TypeId::of:: fn(&'a dyn Trait<'a>) -> Struct<'a>>(); - let h = TypeId::of:: fn(&'a dyn Trait<'a>) -> Struct<'static>>(); - let i = TypeId::of:: fn(&'a dyn Trait<'b>) -> Struct<'b>>(); - assert!(g != h); - assert!(g != i); - assert!(h != i); - - // Make sure lifetime anonymization handles nesting correctly - let j = TypeId::of:: fn(&'a isize) -> &'a usize)>(); - let k = TypeId::of:: fn(&'b isize) -> &'b usize)>(); - assert_eq!(j, k); - } - // Boxed unboxed closures - { - let a = TypeId::of::>(); - let b = TypeId::of:: Fn(&'static isize, &'a isize)>>(); - let c = TypeId::of:: Fn(&'a isize, &'b isize)>>(); - let d = TypeId::of:: Fn(&'b isize, &'a isize)>>(); - assert!(a != b); - assert!(a != c); - assert!(a != d); - assert!(b != c); - assert!(b != d); - assert_eq!(c, d); - - // Make sure De Bruijn indices are handled correctly - let e = TypeId::of:: Fn(Box &'a isize>)>>(); - let f = TypeId::of:: Fn(&'a isize) -> &'a isize>)>>(); - assert!(e != f); - } - // Raw unboxed closures - // Note that every unboxed closure has its own anonymous type, - // so no two IDs should equal each other, even when compatible - { - let a = id(|_: &isize, _: &isize| {}); - let b = id(|_: &isize, _: &isize| {}); - assert!(a != b); - } - - fn id(_: T) -> TypeId { - TypeId::of::() - } -} diff --git a/src/test/ui/type-sizes.rs b/src/test/ui/type-sizes.rs deleted file mode 100644 index 73a11a5e743..00000000000 --- a/src/test/ui/type-sizes.rs +++ /dev/null @@ -1,173 +0,0 @@ -// run-pass - -#![allow(non_camel_case_types)] -#![allow(dead_code)] -#![feature(never_type)] - -use std::mem::size_of; -use std::num::NonZeroU8; - -struct t {a: u8, b: i8} -struct u {a: u8, b: i8, c: u8} -struct v {a: u8, b: i8, c: v2, d: u32} -struct v2 {u: char, v: u8} -struct w {a: isize, b: ()} -struct x {a: isize, b: (), c: ()} -struct y {x: isize} - -enum e1 { - a(u8, u32), b(u32), c -} -enum e2 { - a(u32), b -} - -#[repr(C, u8)] -enum e3 { - a([u16; 0], u8), b -} - -struct ReorderedStruct { - a: u8, - b: u16, - c: u8 -} - -enum ReorderedEnum { - A(u8, u16, u8), - B(u8, u16, u8), -} - -enum ReorderedEnum2 { - A(u8, u32, u8), - B(u16, u8, u16, u8), - - // 0x100 niche variants. - _00, _01, _02, _03, _04, _05, _06, _07, _08, _09, _0A, _0B, _0C, _0D, _0E, _0F, - _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _1A, _1B, _1C, _1D, _1E, _1F, - _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _2A, _2B, _2C, _2D, _2E, _2F, - _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _3A, _3B, _3C, _3D, _3E, _3F, - _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _4A, _4B, _4C, _4D, _4E, _4F, - _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _5A, _5B, _5C, _5D, _5E, _5F, - _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _6A, _6B, _6C, _6D, _6E, _6F, - _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _7A, _7B, _7C, _7D, _7E, _7F, - _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, _8A, _8B, _8C, _8D, _8E, _8F, - _90, _91, _92, _93, _94, _95, _96, _97, _98, _99, _9A, _9B, _9C, _9D, _9E, _9F, - _A0, _A1, _A2, _A3, _A4, _A5, _A6, _A7, _A8, _A9, _AA, _AB, _AC, _AD, _AE, _AF, - _B0, _B1, _B2, _B3, _B4, _B5, _B6, _B7, _B8, _B9, _BA, _BB, _BC, _BD, _BE, _BF, - _C0, _C1, _C2, _C3, _C4, _C5, _C6, _C7, _C8, _C9, _CA, _CB, _CC, _CD, _CE, _CF, - _D0, _D1, _D2, _D3, _D4, _D5, _D6, _D7, _D8, _D9, _DA, _DB, _DC, _DD, _DE, _DF, - _E0, _E1, _E2, _E3, _E4, _E5, _E6, _E7, _E8, _E9, _EA, _EB, _EC, _ED, _EE, _EF, - _F0, _F1, _F2, _F3, _F4, _F5, _F6, _F7, _F8, _F9, _FA, _FB, _FC, _FD, _FE, _FF, -} - -enum EnumEmpty {} - -enum EnumSingle1 { - A, -} - -enum EnumSingle2 { - A = 42 as isize, -} - -enum EnumSingle3 { - A, - B(!), -} - -#[repr(u8)] -enum EnumSingle4 { - A, -} - -#[repr(u8)] -enum EnumSingle5 { - A = 42 as u8, -} - -enum EnumWithMaybeUninhabitedVariant { - A(&'static ()), - B(&'static (), T), - C, -} - -enum NicheFilledEnumWithAbsentVariant { - A(&'static ()), - B((), !), - C, -} - -enum Option2 { - Some(A, B), - None -} - -// Two layouts are considered for `CanBeNicheFilledButShouldnt`: -// Niche-filling: -// { u32 (4 bytes), NonZeroU8 + tag in niche (1 byte), padding (3 bytes) } -// Tagged: -// { tag (1 byte), NonZeroU8 (1 byte), padding (2 bytes), u32 (4 bytes) } -// Both are the same size (due to padding), -// but the tagged layout is better as the tag creates a niche with 254 invalid values, -// allowing types like `Option>` to fit into 8 bytes. -pub enum CanBeNicheFilledButShouldnt { - A(NonZeroU8, u32), - B -} -pub enum AlwaysTaggedBecauseItHasNoNiche { - A(u8, u32), - B -} - -pub fn main() { - assert_eq!(size_of::(), 1 as usize); - assert_eq!(size_of::(), 4 as usize); - assert_eq!(size_of::(), 4 as usize); - assert_eq!(size_of::(), 1 as usize); - assert_eq!(size_of::(), 4 as usize); - assert_eq!(size_of::(), 2 as usize); - assert_eq!(size_of::(), 3 as usize); - // Alignment causes padding before the char and the u32. - - assert_eq!(size_of::(), - 16 as usize); - assert_eq!(size_of::(), size_of::()); - assert_eq!(size_of::(), size_of::()); - assert_eq!(size_of::(), size_of::()); - assert_eq!(size_of::(), size_of::()); - - // Make sure enum types are the appropriate size, mostly - // around ensuring alignment is handled properly - - assert_eq!(size_of::(), 8 as usize); - assert_eq!(size_of::(), 8 as usize); - assert_eq!(size_of::(), 4 as usize); - assert_eq!(size_of::(), 4); - assert_eq!(size_of::(), 6); - assert_eq!(size_of::(), 8); - - - assert_eq!(size_of::(), 0); - assert_eq!(size_of::(), 0); - assert_eq!(size_of::(), 0); - assert_eq!(size_of::(), 0); - assert_eq!(size_of::(), 1); - assert_eq!(size_of::(), 1); - - assert_eq!(size_of::>(), - size_of::>()); - assert_eq!(size_of::(), size_of::<&'static ()>()); - - assert_eq!(size_of::>>(), size_of::<(bool, &())>()); - assert_eq!(size_of::>>(), size_of::<(bool, &())>()); - assert_eq!(size_of::>>(), size_of::<(bool, &())>()); - assert_eq!(size_of::>>(), size_of::<(bool, &())>()); - - assert_eq!(size_of::(), 8); - assert_eq!(size_of::>(), 8); - assert_eq!(size_of::>>(), 8); - assert_eq!(size_of::(), 8); - assert_eq!(size_of::>(), 8); - assert_eq!(size_of::>>(), 8); -} diff --git a/src/test/ui/unboxed-closures/type-id-higher-rank.rs b/src/test/ui/unboxed-closures/type-id-higher-rank.rs new file mode 100644 index 00000000000..355d1109941 --- /dev/null +++ b/src/test/ui/unboxed-closures/type-id-higher-rank.rs @@ -0,0 +1,72 @@ +// run-pass +// Test that type IDs correctly account for higher-rank lifetimes +// Also acts as a regression test for an ICE (issue #19791) + +use std::any::{Any, TypeId}; + +struct Struct<'a>(&'a ()); +trait Trait<'a> {} + +fn main() { + // Bare fns + { + let a = TypeId::of::(); + let b = TypeId::of:: fn(&'static isize, &'a isize)>(); + let c = TypeId::of:: fn(&'a isize, &'b isize)>(); + let d = TypeId::of:: fn(&'b isize, &'a isize)>(); + assert!(a != b); + assert!(a != c); + assert!(a != d); + assert!(b != c); + assert!(b != d); + assert_eq!(c, d); + + // Make sure De Bruijn indices are handled correctly + let e = TypeId::of:: fn(fn(&'a isize) -> &'a isize)>(); + let f = TypeId::of:: fn(&'a isize) -> &'a isize)>(); + assert!(e != f); + + // Make sure lifetime parameters of items are not ignored. + let g = TypeId::of:: fn(&'a dyn Trait<'a>) -> Struct<'a>>(); + let h = TypeId::of:: fn(&'a dyn Trait<'a>) -> Struct<'static>>(); + let i = TypeId::of:: fn(&'a dyn Trait<'b>) -> Struct<'b>>(); + assert!(g != h); + assert!(g != i); + assert!(h != i); + + // Make sure lifetime anonymization handles nesting correctly + let j = TypeId::of:: fn(&'a isize) -> &'a usize)>(); + let k = TypeId::of:: fn(&'b isize) -> &'b usize)>(); + assert_eq!(j, k); + } + // Boxed unboxed closures + { + let a = TypeId::of::>(); + let b = TypeId::of:: Fn(&'static isize, &'a isize)>>(); + let c = TypeId::of:: Fn(&'a isize, &'b isize)>>(); + let d = TypeId::of:: Fn(&'b isize, &'a isize)>>(); + assert!(a != b); + assert!(a != c); + assert!(a != d); + assert!(b != c); + assert!(b != d); + assert_eq!(c, d); + + // Make sure De Bruijn indices are handled correctly + let e = TypeId::of:: Fn(Box &'a isize>)>>(); + let f = TypeId::of:: Fn(&'a isize) -> &'a isize>)>>(); + assert!(e != f); + } + // Raw unboxed closures + // Note that every unboxed closure has its own anonymous type, + // so no two IDs should equal each other, even when compatible + { + let a = id(|_: &isize, _: &isize| {}); + let b = id(|_: &isize, _: &isize| {}); + assert!(a != b); + } + + fn id(_: T) -> TypeId { + TypeId::of::() + } +} diff --git a/src/test/ui/write-to-static-mut-in-static.rs b/src/test/ui/write-to-static-mut-in-static.rs deleted file mode 100644 index 43c63fed8ce..00000000000 --- a/src/test/ui/write-to-static-mut-in-static.rs +++ /dev/null @@ -1,10 +0,0 @@ -pub static mut A: u32 = 0; -pub static mut B: () = unsafe { A = 1; }; -//~^ ERROR could not evaluate static initializer - -pub static mut C: u32 = unsafe { C = 1; 0 }; -//~^ ERROR cycle detected - -pub static D: u32 = D; - -fn main() {} diff --git a/src/test/ui/write-to-static-mut-in-static.stderr b/src/test/ui/write-to-static-mut-in-static.stderr deleted file mode 100644 index 789919bd166..00000000000 --- a/src/test/ui/write-to-static-mut-in-static.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0080]: could not evaluate static initializer - --> $DIR/write-to-static-mut-in-static.rs:2:33 - | -LL | pub static mut B: () = unsafe { A = 1; }; - | ^^^^^ modifying a static's initial value from another static's initializer - -error[E0391]: cycle detected when const-evaluating + checking `C` - --> $DIR/write-to-static-mut-in-static.rs:5:1 - | -LL | pub static mut C: u32 = unsafe { C = 1; 0 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: ...which requires const-evaluating + checking `C`... - --> $DIR/write-to-static-mut-in-static.rs:5:1 - | -LL | pub static mut C: u32 = unsafe { C = 1; 0 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which again requires const-evaluating + checking `C`, completing the cycle - = note: cycle used when running analysis passes on this crate - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0080, E0391. -For more information about an error, try `rustc --explain E0080`. diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 74ed2366752..659d5ae03c9 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 = 1459; -const ISSUES_ENTRY_LIMIT: usize = 2615; +const ROOT_ENTRY_LIMIT: usize = 1418; +const ISSUES_ENTRY_LIMIT: usize = 2582; fn check_entries(path: &Path, bad: &mut bool) { let dirs = walkdir::WalkDir::new(&path.join("test/ui")) -- cgit 1.4.1-3-g733a5