From 7ffcedf6659d30c4a076d89b2586b385ad2f2d16 Mon Sep 17 00:00:00 2001 From: Caio Date: Wed, 4 Jan 2023 16:44:30 -0300 Subject: Move tests --- src/test/ui/associated-consts/issue-105330.rs | 21 ++++ src/test/ui/associated-consts/issue-105330.stderr | 113 +++++++++++++++++++++ src/test/ui/associated-types/issue-25700-1.rs | 13 +++ src/test/ui/associated-types/issue-25700-2.rs | 23 +++++ src/test/ui/associated-types/issue-25700.rs | 14 +++ src/test/ui/associated-types/issue-25700.stderr | 13 +++ .../ui/codegen/issue-82859-slice-miscompile.rs | 19 ++++ src/test/ui/command/issue-10626.rs | 26 +++++ src/test/ui/drop/issue-2734.rs | 22 ++++ src/test/ui/dropck/issue-34053.rs | 30 ++++++ src/test/ui/enum-discriminant/issue-72554.rs | 22 ++++ src/test/ui/enum-discriminant/issue-72554.stderr | 17 ++++ src/test/ui/extern/issue-13655.rs | 32 ++++++ src/test/ui/issues/issue-105330.rs | 21 ---- src/test/ui/issues/issue-105330.stderr | 113 --------------------- src/test/ui/issues/issue-10536.rs | 19 ---- src/test/ui/issues/issue-10536.stderr | 14 --- src/test/ui/issues/issue-10626.rs | 26 ----- src/test/ui/issues/issue-13655.rs | 32 ------ src/test/ui/issues/issue-18937-1.rs | 21 ---- src/test/ui/issues/issue-18937.rs | 40 -------- src/test/ui/issues/issue-18937.stderr | 14 --- src/test/ui/issues/issue-25700-1.rs | 13 --- src/test/ui/issues/issue-25700-2.rs | 23 ----- src/test/ui/issues/issue-25700.rs | 14 --- src/test/ui/issues/issue-25700.stderr | 13 --- src/test/ui/issues/issue-2734.rs | 22 ---- src/test/ui/issues/issue-31173.rs | 15 --- src/test/ui/issues/issue-31173.stderr | 45 -------- src/test/ui/issues/issue-34053.rs | 30 ------ src/test/ui/issues/issue-54189.rs | 6 -- src/test/ui/issues/issue-54189.stderr | 9 -- src/test/ui/issues/issue-72554.rs | 22 ---- src/test/ui/issues/issue-72554.stderr | 17 ---- src/test/ui/issues/issue-82859-slice-miscompile.rs | 19 ---- src/test/ui/issues/issue-99875.rs | 16 --- src/test/ui/issues/issue-99875.stderr | 33 ------ src/test/ui/macros/issue-10536.rs | 19 ++++ src/test/ui/macros/issue-10536.stderr | 14 +++ src/test/ui/nll/issue-54189.rs | 6 ++ src/test/ui/nll/issue-54189.stderr | 9 ++ src/test/ui/traits/issue-99875.rs | 16 +++ src/test/ui/traits/issue-99875.stderr | 33 ++++++ src/test/ui/typeck/issue-18937-1.rs | 21 ++++ src/test/ui/typeck/issue-18937.rs | 40 ++++++++ src/test/ui/typeck/issue-18937.stderr | 14 +++ src/test/ui/typeck/issue-31173.rs | 15 +++ src/test/ui/typeck/issue-31173.stderr | 45 ++++++++ src/tools/tidy/src/ui_tests.rs | 2 +- 49 files changed, 598 insertions(+), 598 deletions(-) create mode 100644 src/test/ui/associated-consts/issue-105330.rs create mode 100644 src/test/ui/associated-consts/issue-105330.stderr create mode 100644 src/test/ui/associated-types/issue-25700-1.rs create mode 100644 src/test/ui/associated-types/issue-25700-2.rs create mode 100644 src/test/ui/associated-types/issue-25700.rs create mode 100644 src/test/ui/associated-types/issue-25700.stderr create mode 100644 src/test/ui/codegen/issue-82859-slice-miscompile.rs create mode 100644 src/test/ui/command/issue-10626.rs create mode 100644 src/test/ui/drop/issue-2734.rs create mode 100644 src/test/ui/dropck/issue-34053.rs create mode 100644 src/test/ui/enum-discriminant/issue-72554.rs create mode 100644 src/test/ui/enum-discriminant/issue-72554.stderr create mode 100644 src/test/ui/extern/issue-13655.rs delete mode 100644 src/test/ui/issues/issue-105330.rs delete mode 100644 src/test/ui/issues/issue-105330.stderr delete mode 100644 src/test/ui/issues/issue-10536.rs delete mode 100644 src/test/ui/issues/issue-10536.stderr delete mode 100644 src/test/ui/issues/issue-10626.rs delete mode 100644 src/test/ui/issues/issue-13655.rs delete mode 100644 src/test/ui/issues/issue-18937-1.rs delete mode 100644 src/test/ui/issues/issue-18937.rs delete mode 100644 src/test/ui/issues/issue-18937.stderr delete mode 100644 src/test/ui/issues/issue-25700-1.rs delete mode 100644 src/test/ui/issues/issue-25700-2.rs delete mode 100644 src/test/ui/issues/issue-25700.rs delete mode 100644 src/test/ui/issues/issue-25700.stderr delete mode 100644 src/test/ui/issues/issue-2734.rs delete mode 100644 src/test/ui/issues/issue-31173.rs delete mode 100644 src/test/ui/issues/issue-31173.stderr delete mode 100644 src/test/ui/issues/issue-34053.rs delete mode 100644 src/test/ui/issues/issue-54189.rs delete mode 100644 src/test/ui/issues/issue-54189.stderr delete mode 100644 src/test/ui/issues/issue-72554.rs delete mode 100644 src/test/ui/issues/issue-72554.stderr delete mode 100644 src/test/ui/issues/issue-82859-slice-miscompile.rs delete mode 100644 src/test/ui/issues/issue-99875.rs delete mode 100644 src/test/ui/issues/issue-99875.stderr create mode 100644 src/test/ui/macros/issue-10536.rs create mode 100644 src/test/ui/macros/issue-10536.stderr create mode 100644 src/test/ui/nll/issue-54189.rs create mode 100644 src/test/ui/nll/issue-54189.stderr create mode 100644 src/test/ui/traits/issue-99875.rs create mode 100644 src/test/ui/traits/issue-99875.stderr create mode 100644 src/test/ui/typeck/issue-18937-1.rs create mode 100644 src/test/ui/typeck/issue-18937.rs create mode 100644 src/test/ui/typeck/issue-18937.stderr create mode 100644 src/test/ui/typeck/issue-31173.rs create mode 100644 src/test/ui/typeck/issue-31173.stderr (limited to 'src') diff --git a/src/test/ui/associated-consts/issue-105330.rs b/src/test/ui/associated-consts/issue-105330.rs new file mode 100644 index 00000000000..86e45f10b0e --- /dev/null +++ b/src/test/ui/associated-consts/issue-105330.rs @@ -0,0 +1,21 @@ +pub trait TraitWAssocConst { + const A: usize; +} +pub struct Demo {} + +impl TraitWAssocConst for impl Demo { //~ ERROR E0404 + //~^ ERROR E0562 + pubconst A: str = 32; //~ ERROR expected one of +} + +fn foo>() { //~ ERROR E0658 + foo::()(); //~ ERROR E0271 + //~^ ERROR E0618 + //~| ERROR E0277 +} + +fn main>() { //~ ERROR E0131 + //~^ ERROR E0658 + foo::(); //~ ERROR E0277 + //~^ ERROR E0271 +} diff --git a/src/test/ui/associated-consts/issue-105330.stderr b/src/test/ui/associated-consts/issue-105330.stderr new file mode 100644 index 00000000000..30c380152a5 --- /dev/null +++ b/src/test/ui/associated-consts/issue-105330.stderr @@ -0,0 +1,113 @@ +error: expected one of `!` or `::`, found `A` + --> $DIR/issue-105330.rs:8:14 + | +LL | impl TraitWAssocConst for impl Demo { + | - while parsing this item list starting here +LL | +LL | pubconst A: str = 32; + | ^ expected one of `!` or `::` +LL | } + | - the item list ends here + +error[E0404]: expected trait, found struct `Demo` + --> $DIR/issue-105330.rs:6:32 + | +LL | impl TraitWAssocConst for impl Demo { + | ^^^^ not a trait + +error[E0658]: associated const equality is incomplete + --> $DIR/issue-105330.rs:11:28 + | +LL | fn foo>() { + | ^^^^ + | + = note: see issue #92827 for more information + = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable + +error[E0658]: associated const equality is incomplete + --> $DIR/issue-105330.rs:17:29 + | +LL | fn main>() { + | ^^^^ + | + = note: see issue #92827 for more information + = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable + +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type + --> $DIR/issue-105330.rs:6:27 + | +LL | impl TraitWAssocConst for impl Demo { + | ^^^^^^^^^ + +error[E0277]: the trait bound `Demo: TraitWAssocConst` is not satisfied + --> $DIR/issue-105330.rs:12:11 + | +LL | foo::()(); + | ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo` + | +note: required by a bound in `foo` + --> $DIR/issue-105330.rs:11:11 + | +LL | fn foo>() { + | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo` + +error[E0271]: type mismatch resolving `::A == 32` + --> $DIR/issue-105330.rs:12:11 + | +LL | foo::()(); + | ^^^^ expected `32`, found `::A` + | + = note: expected constant `32` + found constant `::A` +note: required by a bound in `foo` + --> $DIR/issue-105330.rs:11:28 + | +LL | fn foo>() { + | ^^^^ required by this bound in `foo` + +error[E0618]: expected function, found `()` + --> $DIR/issue-105330.rs:12:5 + | +LL | fn foo>() { + | ----------------------------------- `foo::` defined here returns `()` +LL | foo::()(); + | ^^^^^^^^^^^^^-- + | | + | call expression requires function + +error[E0277]: the trait bound `Demo: TraitWAssocConst` is not satisfied + --> $DIR/issue-105330.rs:19:11 + | +LL | foo::(); + | ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo` + | +note: required by a bound in `foo` + --> $DIR/issue-105330.rs:11:11 + | +LL | fn foo>() { + | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo` + +error[E0271]: type mismatch resolving `::A == 32` + --> $DIR/issue-105330.rs:19:11 + | +LL | foo::(); + | ^^^^ expected `32`, found `::A` + | + = note: expected constant `32` + found constant `::A` +note: required by a bound in `foo` + --> $DIR/issue-105330.rs:11:28 + | +LL | fn foo>() { + | ^^^^ required by this bound in `foo` + +error[E0131]: `main` function is not allowed to have generic parameters + --> $DIR/issue-105330.rs:17:8 + | +LL | fn main>() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` cannot have generic parameters + +error: aborting due to 11 previous errors + +Some errors have detailed explanations: E0131, E0271, E0277, E0404, E0562, E0618, E0658. +For more information about an error, try `rustc --explain E0131`. diff --git a/src/test/ui/associated-types/issue-25700-1.rs b/src/test/ui/associated-types/issue-25700-1.rs new file mode 100644 index 00000000000..5e71a52ba4e --- /dev/null +++ b/src/test/ui/associated-types/issue-25700-1.rs @@ -0,0 +1,13 @@ +// run-pass +struct S(#[allow(unused_tuple_struct_fields)] Option<&'static T>); + +trait Tr { type Out; } +impl Tr for T { type Out = T; } + +impl Copy for S where S: Tr {} +impl Clone for S where S: Tr { + fn clone(&self) -> Self { *self } +} +fn main() { + S::<()>(None); +} diff --git a/src/test/ui/associated-types/issue-25700-2.rs b/src/test/ui/associated-types/issue-25700-2.rs new file mode 100644 index 00000000000..89b1db496f9 --- /dev/null +++ b/src/test/ui/associated-types/issue-25700-2.rs @@ -0,0 +1,23 @@ +// run-pass +pub trait Parser { + type Input; +} + +pub struct Iter(#[allow(unused_tuple_struct_fields)] P, P::Input); + +#[allow(unused_tuple_struct_fields)] +pub struct Map(P, F); +impl Parser for Map where F: FnMut(P) { + type Input = u8; +} + +trait AstId { type Untyped; } +impl AstId for u32 { type Untyped = u32; } + +fn record_type(i: Id::Untyped) -> u8 { + Iter(Map(i, |_: Id::Untyped| {}), 42).1 +} + +pub fn main() { + assert_eq!(record_type::(3), 42); +} diff --git a/src/test/ui/associated-types/issue-25700.rs b/src/test/ui/associated-types/issue-25700.rs new file mode 100644 index 00000000000..e5b9a97523d --- /dev/null +++ b/src/test/ui/associated-types/issue-25700.rs @@ -0,0 +1,14 @@ +struct S(#[allow(unused_tuple_struct_fields)] Option<&'static T>); + +trait Tr { type Out; } +impl Tr for T { type Out = T; } + +impl Copy for S where S: Tr {} +impl Clone for S where S: Tr { + fn clone(&self) -> Self { *self } +} +fn main() { + let t = S::<()>(None); + drop(t); + drop(t); //~ ERROR use of moved value +} diff --git a/src/test/ui/associated-types/issue-25700.stderr b/src/test/ui/associated-types/issue-25700.stderr new file mode 100644 index 00000000000..fa309a55c3c --- /dev/null +++ b/src/test/ui/associated-types/issue-25700.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `t` + --> $DIR/issue-25700.rs:13:10 + | +LL | let t = S::<()>(None); + | - move occurs because `t` has type `S<()>`, which does not implement the `Copy` trait +LL | drop(t); + | - value moved here +LL | drop(t); + | ^ value used here after move + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/codegen/issue-82859-slice-miscompile.rs b/src/test/ui/codegen/issue-82859-slice-miscompile.rs new file mode 100644 index 00000000000..b64eb499071 --- /dev/null +++ b/src/test/ui/codegen/issue-82859-slice-miscompile.rs @@ -0,0 +1,19 @@ +// run-pass +// compile-flags: -Copt-level=0 -Cdebuginfo=2 + +// Make sure LLVM does not miscompile this. + +fn indirect_get_slice() -> &'static [usize] { + &[] +} + +#[inline(always)] +fn get_slice() -> &'static [usize] { + let ret = indirect_get_slice(); + ret +} + +fn main() { + let output = get_slice().len(); + assert_eq!(output, 0); +} diff --git a/src/test/ui/command/issue-10626.rs b/src/test/ui/command/issue-10626.rs new file mode 100644 index 00000000000..696a2dd1657 --- /dev/null +++ b/src/test/ui/command/issue-10626.rs @@ -0,0 +1,26 @@ +// run-pass +// ignore-emscripten no processes +// ignore-sgx no processes + +// Make sure that if a process doesn't have its stdio/stderr descriptors set up +// that we don't die in a large ball of fire + +use std::env; +use std::process::{Command, Stdio}; + +pub fn main () { + let args: Vec = env::args().collect(); + if args.len() > 1 && args[1] == "child" { + for _ in 0..1000 { + println!("hello?"); + } + for _ in 0..1000 { + println!("hello?"); + } + return; + } + + let mut p = Command::new(&args[0]); + p.arg("child").stdout(Stdio::null()).stderr(Stdio::null()); + println!("{:?}", p.spawn().unwrap().wait()); +} diff --git a/src/test/ui/drop/issue-2734.rs b/src/test/ui/drop/issue-2734.rs new file mode 100644 index 00000000000..df4f394dc37 --- /dev/null +++ b/src/test/ui/drop/issue-2734.rs @@ -0,0 +1,22 @@ +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +trait hax { + fn dummy(&self) { } +} +impl hax for A { } + +fn perform_hax(x: Box) -> Box { + Box::new(x) as Box +} + +fn deadcode() { + perform_hax(Box::new("deadcode".to_string())); +} + +pub fn main() { + let _ = perform_hax(Box::new(42)); +} diff --git a/src/test/ui/dropck/issue-34053.rs b/src/test/ui/dropck/issue-34053.rs new file mode 100644 index 00000000000..fa23ae8f95b --- /dev/null +++ b/src/test/ui/dropck/issue-34053.rs @@ -0,0 +1,30 @@ +// run-pass +use std::sync::atomic::{AtomicUsize, Ordering}; + +static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0); + +struct A(i32); + +impl Drop for A { + fn drop(&mut self) { + // update global drop count + DROP_COUNTER.fetch_add(1, Ordering::SeqCst); + } +} + +static FOO: A = A(123); +const BAR: A = A(456); + +impl A { + const BAZ: A = A(789); +} + +fn main() { + assert_eq!(DROP_COUNTER.load(Ordering::SeqCst), 0); + assert_eq!(&FOO.0, &123); + assert_eq!(DROP_COUNTER.load(Ordering::SeqCst), 0); + assert_eq!(BAR.0, 456); + assert_eq!(DROP_COUNTER.load(Ordering::SeqCst), 1); + assert_eq!(A::BAZ.0, 789); + assert_eq!(DROP_COUNTER.load(Ordering::SeqCst), 2); +} diff --git a/src/test/ui/enum-discriminant/issue-72554.rs b/src/test/ui/enum-discriminant/issue-72554.rs new file mode 100644 index 00000000000..54f7e9ac592 --- /dev/null +++ b/src/test/ui/enum-discriminant/issue-72554.rs @@ -0,0 +1,22 @@ +use std::collections::BTreeSet; + +#[derive(Hash)] +pub enum ElemDerived { + //~^ ERROR recursive type `ElemDerived` has infinite size + A(ElemDerived) +} + + +pub enum Elem { + Derived(ElemDerived) +} + +pub struct Set(BTreeSet); + +impl Set { + pub fn into_iter(self) -> impl Iterator { + self.0.into_iter() + } +} + +fn main() {} diff --git a/src/test/ui/enum-discriminant/issue-72554.stderr b/src/test/ui/enum-discriminant/issue-72554.stderr new file mode 100644 index 00000000000..d12be539f7c --- /dev/null +++ b/src/test/ui/enum-discriminant/issue-72554.stderr @@ -0,0 +1,17 @@ +error[E0072]: recursive type `ElemDerived` has infinite size + --> $DIR/issue-72554.rs:4:1 + | +LL | pub enum ElemDerived { + | ^^^^^^^^^^^^^^^^^^^^ +LL | +LL | A(ElemDerived) + | ----------- recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle + | +LL | A(Box) + | ++++ + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0072`. diff --git a/src/test/ui/extern/issue-13655.rs b/src/test/ui/extern/issue-13655.rs new file mode 100644 index 00000000000..6dd1847995f --- /dev/null +++ b/src/test/ui/extern/issue-13655.rs @@ -0,0 +1,32 @@ +// run-pass +#![feature(fn_traits, unboxed_closures)] +use std::ops::Fn; + +struct Foo(T); + +impl Fn<()> for Foo { + extern "rust-call" fn call(&self, _: ()) -> T { + match *self { + Foo(t) => t + } + } +} + +impl FnMut<()> for Foo { + extern "rust-call" fn call_mut(&mut self, _: ()) -> T { + self.call(()) + } +} + +impl FnOnce<()> for Foo { + type Output = T; + + extern "rust-call" fn call_once(self, _: ()) -> T { + self.call(()) + } +} + +fn main() { + let t: u8 = 1; + println!("{}", Foo(t)()); +} diff --git a/src/test/ui/issues/issue-105330.rs b/src/test/ui/issues/issue-105330.rs deleted file mode 100644 index 86e45f10b0e..00000000000 --- a/src/test/ui/issues/issue-105330.rs +++ /dev/null @@ -1,21 +0,0 @@ -pub trait TraitWAssocConst { - const A: usize; -} -pub struct Demo {} - -impl TraitWAssocConst for impl Demo { //~ ERROR E0404 - //~^ ERROR E0562 - pubconst A: str = 32; //~ ERROR expected one of -} - -fn foo>() { //~ ERROR E0658 - foo::()(); //~ ERROR E0271 - //~^ ERROR E0618 - //~| ERROR E0277 -} - -fn main>() { //~ ERROR E0131 - //~^ ERROR E0658 - foo::(); //~ ERROR E0277 - //~^ ERROR E0271 -} diff --git a/src/test/ui/issues/issue-105330.stderr b/src/test/ui/issues/issue-105330.stderr deleted file mode 100644 index 30c380152a5..00000000000 --- a/src/test/ui/issues/issue-105330.stderr +++ /dev/null @@ -1,113 +0,0 @@ -error: expected one of `!` or `::`, found `A` - --> $DIR/issue-105330.rs:8:14 - | -LL | impl TraitWAssocConst for impl Demo { - | - while parsing this item list starting here -LL | -LL | pubconst A: str = 32; - | ^ expected one of `!` or `::` -LL | } - | - the item list ends here - -error[E0404]: expected trait, found struct `Demo` - --> $DIR/issue-105330.rs:6:32 - | -LL | impl TraitWAssocConst for impl Demo { - | ^^^^ not a trait - -error[E0658]: associated const equality is incomplete - --> $DIR/issue-105330.rs:11:28 - | -LL | fn foo>() { - | ^^^^ - | - = note: see issue #92827 for more information - = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable - -error[E0658]: associated const equality is incomplete - --> $DIR/issue-105330.rs:17:29 - | -LL | fn main>() { - | ^^^^ - | - = note: see issue #92827 for more information - = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable - -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/issue-105330.rs:6:27 - | -LL | impl TraitWAssocConst for impl Demo { - | ^^^^^^^^^ - -error[E0277]: the trait bound `Demo: TraitWAssocConst` is not satisfied - --> $DIR/issue-105330.rs:12:11 - | -LL | foo::()(); - | ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo` - | -note: required by a bound in `foo` - --> $DIR/issue-105330.rs:11:11 - | -LL | fn foo>() { - | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo` - -error[E0271]: type mismatch resolving `::A == 32` - --> $DIR/issue-105330.rs:12:11 - | -LL | foo::()(); - | ^^^^ expected `32`, found `::A` - | - = note: expected constant `32` - found constant `::A` -note: required by a bound in `foo` - --> $DIR/issue-105330.rs:11:28 - | -LL | fn foo>() { - | ^^^^ required by this bound in `foo` - -error[E0618]: expected function, found `()` - --> $DIR/issue-105330.rs:12:5 - | -LL | fn foo>() { - | ----------------------------------- `foo::` defined here returns `()` -LL | foo::()(); - | ^^^^^^^^^^^^^-- - | | - | call expression requires function - -error[E0277]: the trait bound `Demo: TraitWAssocConst` is not satisfied - --> $DIR/issue-105330.rs:19:11 - | -LL | foo::(); - | ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo` - | -note: required by a bound in `foo` - --> $DIR/issue-105330.rs:11:11 - | -LL | fn foo>() { - | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo` - -error[E0271]: type mismatch resolving `::A == 32` - --> $DIR/issue-105330.rs:19:11 - | -LL | foo::(); - | ^^^^ expected `32`, found `::A` - | - = note: expected constant `32` - found constant `::A` -note: required by a bound in `foo` - --> $DIR/issue-105330.rs:11:28 - | -LL | fn foo>() { - | ^^^^ required by this bound in `foo` - -error[E0131]: `main` function is not allowed to have generic parameters - --> $DIR/issue-105330.rs:17:8 - | -LL | fn main>() { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` cannot have generic parameters - -error: aborting due to 11 previous errors - -Some errors have detailed explanations: E0131, E0271, E0277, E0404, E0562, E0618, E0658. -For more information about an error, try `rustc --explain E0131`. diff --git a/src/test/ui/issues/issue-10536.rs b/src/test/ui/issues/issue-10536.rs deleted file mode 100644 index f536d8f940a..00000000000 --- a/src/test/ui/issues/issue-10536.rs +++ /dev/null @@ -1,19 +0,0 @@ -// We only want to assert that this doesn't ICE, we don't particularly care -// about whether it nor it fails to compile. - -macro_rules! foo{ - () => {{ - macro_rules! bar{() => (())} - 1 - }} -} - -pub fn main() { - foo!(); - - assert!({one! two()}); //~ ERROR expected one of `(`, `[`, or `{`, found `two` - - // regardless of whether nested macro_rules works, the following should at - // least throw a conventional error. - assert!({one! two}); //~ ERROR expected one of `(`, `[`, or `{`, found `two` -} diff --git a/src/test/ui/issues/issue-10536.stderr b/src/test/ui/issues/issue-10536.stderr deleted file mode 100644 index cc048445871..00000000000 --- a/src/test/ui/issues/issue-10536.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: expected one of `(`, `[`, or `{`, found `two` - --> $DIR/issue-10536.rs:14:19 - | -LL | assert!({one! two()}); - | ^^^ expected one of `(`, `[`, or `{` - -error: expected one of `(`, `[`, or `{`, found `two` - --> $DIR/issue-10536.rs:18:19 - | -LL | assert!({one! two}); - | ^^^ expected one of `(`, `[`, or `{` - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/issues/issue-10626.rs b/src/test/ui/issues/issue-10626.rs deleted file mode 100644 index 696a2dd1657..00000000000 --- a/src/test/ui/issues/issue-10626.rs +++ /dev/null @@ -1,26 +0,0 @@ -// run-pass -// ignore-emscripten no processes -// ignore-sgx no processes - -// Make sure that if a process doesn't have its stdio/stderr descriptors set up -// that we don't die in a large ball of fire - -use std::env; -use std::process::{Command, Stdio}; - -pub fn main () { - let args: Vec = env::args().collect(); - if args.len() > 1 && args[1] == "child" { - for _ in 0..1000 { - println!("hello?"); - } - for _ in 0..1000 { - println!("hello?"); - } - return; - } - - let mut p = Command::new(&args[0]); - p.arg("child").stdout(Stdio::null()).stderr(Stdio::null()); - println!("{:?}", p.spawn().unwrap().wait()); -} diff --git a/src/test/ui/issues/issue-13655.rs b/src/test/ui/issues/issue-13655.rs deleted file mode 100644 index 6dd1847995f..00000000000 --- a/src/test/ui/issues/issue-13655.rs +++ /dev/null @@ -1,32 +0,0 @@ -// run-pass -#![feature(fn_traits, unboxed_closures)] -use std::ops::Fn; - -struct Foo(T); - -impl Fn<()> for Foo { - extern "rust-call" fn call(&self, _: ()) -> T { - match *self { - Foo(t) => t - } - } -} - -impl FnMut<()> for Foo { - extern "rust-call" fn call_mut(&mut self, _: ()) -> T { - self.call(()) - } -} - -impl FnOnce<()> for Foo { - type Output = T; - - extern "rust-call" fn call_once(self, _: ()) -> T { - self.call(()) - } -} - -fn main() { - let t: u8 = 1; - println!("{}", Foo(t)()); -} diff --git a/src/test/ui/issues/issue-18937-1.rs b/src/test/ui/issues/issue-18937-1.rs deleted file mode 100644 index 57e56d832c6..00000000000 --- a/src/test/ui/issues/issue-18937-1.rs +++ /dev/null @@ -1,21 +0,0 @@ -// run-pass -// Test that we are able to type-check this example. In particular, -// knowing that `T: 'a` allows us to deduce that `[U]: 'a` (because -// when `T=[U]` it implies that `U: 'a`). -// -// Regr. test for live code we found in the wild when fixing #18937. - -pub trait Leak { - fn leak<'a>(self) -> &'a T where T: 'a; -} - -impl Leak<[U]> for Vec { - fn leak<'a>(mut self) -> &'a [U] where [U]: 'a { - let r: *mut [U] = &mut self[..]; - std::mem::forget(self); - unsafe { &mut *r } - } -} -fn main() { - println!("Hello, world!"); -} diff --git a/src/test/ui/issues/issue-18937.rs b/src/test/ui/issues/issue-18937.rs deleted file mode 100644 index af85e5b2b02..00000000000 --- a/src/test/ui/issues/issue-18937.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Regression test for #18937. - -use std::fmt; - -#[derive(Debug)] -struct MyString<'a>(&'a String); - -struct B { - list: Vec>, -} - -trait A<'a> { - fn foo(&mut self, f: F) - where F: fmt::Debug + 'a, - Self: Sized; -} - -impl<'a> A<'a> for B { - fn foo(&mut self, f: F) - where F: fmt::Debug + 'static, //~ ERROR impl has stricter - { - self.list.push(Box::new(f)); - } -} - -fn main() { - let mut b = B { list: Vec::new() }; - - // Create a borrowed pointer, put it in `b`, then drop what's borrowing it - let a = "hello".to_string(); - b.foo(MyString(&a)); - - // Drop the data which `b` has a reference to - drop(a); - - // Use the data, probably segfaulting - for b in b.list.iter() { - println!("{:?}", b); - } -} diff --git a/src/test/ui/issues/issue-18937.stderr b/src/test/ui/issues/issue-18937.stderr deleted file mode 100644 index 5e2ba0ef4fc..00000000000 --- a/src/test/ui/issues/issue-18937.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0276]: impl has stricter requirements than trait - --> $DIR/issue-18937.rs:20:31 - | -LL | / fn foo(&mut self, f: F) -LL | | where F: fmt::Debug + 'a, -LL | | Self: Sized; - | |__________________________- definition of `foo` from trait -... -LL | where F: fmt::Debug + 'static, - | ^^^^^^^ impl has extra requirement `F: 'static` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0276`. diff --git a/src/test/ui/issues/issue-25700-1.rs b/src/test/ui/issues/issue-25700-1.rs deleted file mode 100644 index 5e71a52ba4e..00000000000 --- a/src/test/ui/issues/issue-25700-1.rs +++ /dev/null @@ -1,13 +0,0 @@ -// run-pass -struct S(#[allow(unused_tuple_struct_fields)] Option<&'static T>); - -trait Tr { type Out; } -impl Tr for T { type Out = T; } - -impl Copy for S where S: Tr {} -impl Clone for S where S: Tr { - fn clone(&self) -> Self { *self } -} -fn main() { - S::<()>(None); -} diff --git a/src/test/ui/issues/issue-25700-2.rs b/src/test/ui/issues/issue-25700-2.rs deleted file mode 100644 index 89b1db496f9..00000000000 --- a/src/test/ui/issues/issue-25700-2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// run-pass -pub trait Parser { - type Input; -} - -pub struct Iter(#[allow(unused_tuple_struct_fields)] P, P::Input); - -#[allow(unused_tuple_struct_fields)] -pub struct Map(P, F); -impl Parser for Map where F: FnMut(P) { - type Input = u8; -} - -trait AstId { type Untyped; } -impl AstId for u32 { type Untyped = u32; } - -fn record_type(i: Id::Untyped) -> u8 { - Iter(Map(i, |_: Id::Untyped| {}), 42).1 -} - -pub fn main() { - assert_eq!(record_type::(3), 42); -} diff --git a/src/test/ui/issues/issue-25700.rs b/src/test/ui/issues/issue-25700.rs deleted file mode 100644 index e5b9a97523d..00000000000 --- a/src/test/ui/issues/issue-25700.rs +++ /dev/null @@ -1,14 +0,0 @@ -struct S(#[allow(unused_tuple_struct_fields)] Option<&'static T>); - -trait Tr { type Out; } -impl Tr for T { type Out = T; } - -impl Copy for S where S: Tr {} -impl Clone for S where S: Tr { - fn clone(&self) -> Self { *self } -} -fn main() { - let t = S::<()>(None); - drop(t); - drop(t); //~ ERROR use of moved value -} diff --git a/src/test/ui/issues/issue-25700.stderr b/src/test/ui/issues/issue-25700.stderr deleted file mode 100644 index fa309a55c3c..00000000000 --- a/src/test/ui/issues/issue-25700.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `t` - --> $DIR/issue-25700.rs:13:10 - | -LL | let t = S::<()>(None); - | - move occurs because `t` has type `S<()>`, which does not implement the `Copy` trait -LL | drop(t); - | - value moved here -LL | drop(t); - | ^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/issues/issue-2734.rs b/src/test/ui/issues/issue-2734.rs deleted file mode 100644 index df4f394dc37..00000000000 --- a/src/test/ui/issues/issue-2734.rs +++ /dev/null @@ -1,22 +0,0 @@ -// run-pass -#![allow(dead_code)] -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -trait hax { - fn dummy(&self) { } -} -impl hax for A { } - -fn perform_hax(x: Box) -> Box { - Box::new(x) as Box -} - -fn deadcode() { - perform_hax(Box::new("deadcode".to_string())); -} - -pub fn main() { - let _ = perform_hax(Box::new(42)); -} diff --git a/src/test/ui/issues/issue-31173.rs b/src/test/ui/issues/issue-31173.rs deleted file mode 100644 index f678df5b42b..00000000000 --- a/src/test/ui/issues/issue-31173.rs +++ /dev/null @@ -1,15 +0,0 @@ -use std::vec::IntoIter; - -pub fn get_tok(it: &mut IntoIter) { - let mut found_e = false; - - let temp: Vec = it - .take_while(|&x| { - found_e = true; - false - }) - .cloned() //~ ERROR to be an iterator that yields `&_`, but it yields `u8` - .collect(); //~ ERROR the method -} - -fn main() {} diff --git a/src/test/ui/issues/issue-31173.stderr b/src/test/ui/issues/issue-31173.stderr deleted file mode 100644 index f3be99f9bcb..00000000000 --- a/src/test/ui/issues/issue-31173.stderr +++ /dev/null @@ -1,45 +0,0 @@ -error[E0271]: expected `TakeWhile<&mut IntoIter, [closure@issue-31173.rs:7:21]>` to be an iterator that yields `&_`, but it yields `u8` - --> $DIR/issue-31173.rs:11:10 - | -LL | .cloned() - | ^^^^^^ expected reference, found `u8` - | - = note: expected reference `&_` - found type `u8` -note: the method call chain might not have had the expected associated types - --> $DIR/issue-31173.rs:3:20 - | -LL | pub fn get_tok(it: &mut IntoIter) { - | ^^^^^^^^^^^^^^^^^ `Iterator::Item` is `u8` here -... -LL | .take_while(|&x| { - | __________- -LL | | found_e = true; -LL | | false -LL | | }) - | |__________- `Iterator::Item` remains `u8` here -note: required by a bound in `cloned` - --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL - -error[E0599]: the method `collect` exists for struct `Cloned, [closure@issue-31173.rs:7:21]>>`, but its trait bounds were not satisfied - --> $DIR/issue-31173.rs:12:10 - | -LL | .collect(); - | ^^^^^^^ method cannot be called due to unsatisfied trait bounds - --> $SRC_DIR/core/src/iter/adapters/take_while.rs:LL:COL - | - = note: doesn't satisfy `<_ as Iterator>::Item = &_` - --> $SRC_DIR/core/src/iter/adapters/cloned.rs:LL:COL - | - = note: doesn't satisfy `_: Iterator` - | - = note: the following trait bounds were not satisfied: - `, [closure@$DIR/issue-31173.rs:7:21: 7:25]> as Iterator>::Item = &_` - which is required by `Cloned, [closure@$DIR/issue-31173.rs:7:21: 7:25]>>: Iterator` - `Cloned, [closure@$DIR/issue-31173.rs:7:21: 7:25]>>: Iterator` - which is required by `&mut Cloned, [closure@$DIR/issue-31173.rs:7:21: 7:25]>>: Iterator` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0271, E0599. -For more information about an error, try `rustc --explain E0271`. diff --git a/src/test/ui/issues/issue-34053.rs b/src/test/ui/issues/issue-34053.rs deleted file mode 100644 index fa23ae8f95b..00000000000 --- a/src/test/ui/issues/issue-34053.rs +++ /dev/null @@ -1,30 +0,0 @@ -// run-pass -use std::sync::atomic::{AtomicUsize, Ordering}; - -static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0); - -struct A(i32); - -impl Drop for A { - fn drop(&mut self) { - // update global drop count - DROP_COUNTER.fetch_add(1, Ordering::SeqCst); - } -} - -static FOO: A = A(123); -const BAR: A = A(456); - -impl A { - const BAZ: A = A(789); -} - -fn main() { - assert_eq!(DROP_COUNTER.load(Ordering::SeqCst), 0); - assert_eq!(&FOO.0, &123); - assert_eq!(DROP_COUNTER.load(Ordering::SeqCst), 0); - assert_eq!(BAR.0, 456); - assert_eq!(DROP_COUNTER.load(Ordering::SeqCst), 1); - assert_eq!(A::BAZ.0, 789); - assert_eq!(DROP_COUNTER.load(Ordering::SeqCst), 2); -} diff --git a/src/test/ui/issues/issue-54189.rs b/src/test/ui/issues/issue-54189.rs deleted file mode 100644 index 70aecc384ef..00000000000 --- a/src/test/ui/issues/issue-54189.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn bug() -> impl for <'r> Fn() -> &'r () { || { &() } } -//~^ ERROR binding for associated type `Output` references lifetime `'r` - -fn main() { - let f = bug(); -} diff --git a/src/test/ui/issues/issue-54189.stderr b/src/test/ui/issues/issue-54189.stderr deleted file mode 100644 index 4787abd49d1..00000000000 --- a/src/test/ui/issues/issue-54189.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0582]: binding for associated type `Output` references lifetime `'r`, which does not appear in the trait input types - --> $DIR/issue-54189.rs:1:35 - | -LL | fn bug() -> impl for <'r> Fn() -> &'r () { || { &() } } - | ^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0582`. diff --git a/src/test/ui/issues/issue-72554.rs b/src/test/ui/issues/issue-72554.rs deleted file mode 100644 index 54f7e9ac592..00000000000 --- a/src/test/ui/issues/issue-72554.rs +++ /dev/null @@ -1,22 +0,0 @@ -use std::collections::BTreeSet; - -#[derive(Hash)] -pub enum ElemDerived { - //~^ ERROR recursive type `ElemDerived` has infinite size - A(ElemDerived) -} - - -pub enum Elem { - Derived(ElemDerived) -} - -pub struct Set(BTreeSet); - -impl Set { - pub fn into_iter(self) -> impl Iterator { - self.0.into_iter() - } -} - -fn main() {} diff --git a/src/test/ui/issues/issue-72554.stderr b/src/test/ui/issues/issue-72554.stderr deleted file mode 100644 index d12be539f7c..00000000000 --- a/src/test/ui/issues/issue-72554.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0072]: recursive type `ElemDerived` has infinite size - --> $DIR/issue-72554.rs:4:1 - | -LL | pub enum ElemDerived { - | ^^^^^^^^^^^^^^^^^^^^ -LL | -LL | A(ElemDerived) - | ----------- recursive without indirection - | -help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle - | -LL | A(Box) - | ++++ + - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0072`. diff --git a/src/test/ui/issues/issue-82859-slice-miscompile.rs b/src/test/ui/issues/issue-82859-slice-miscompile.rs deleted file mode 100644 index b64eb499071..00000000000 --- a/src/test/ui/issues/issue-82859-slice-miscompile.rs +++ /dev/null @@ -1,19 +0,0 @@ -// run-pass -// compile-flags: -Copt-level=0 -Cdebuginfo=2 - -// Make sure LLVM does not miscompile this. - -fn indirect_get_slice() -> &'static [usize] { - &[] -} - -#[inline(always)] -fn get_slice() -> &'static [usize] { - let ret = indirect_get_slice(); - ret -} - -fn main() { - let output = get_slice().len(); - assert_eq!(output, 0); -} diff --git a/src/test/ui/issues/issue-99875.rs b/src/test/ui/issues/issue-99875.rs deleted file mode 100644 index cf73fd8d31f..00000000000 --- a/src/test/ui/issues/issue-99875.rs +++ /dev/null @@ -1,16 +0,0 @@ -struct Argument; -struct Return; - -fn function(_: Argument) -> Return { todo!() } - -trait Trait {} -impl Trait for fn(Argument) -> Return {} - -fn takes(_: impl Trait) {} - -fn main() { - takes(function); - //~^ ERROR the trait bound - takes(|_: Argument| -> Return { todo!() }); - //~^ ERROR the trait bound -} diff --git a/src/test/ui/issues/issue-99875.stderr b/src/test/ui/issues/issue-99875.stderr deleted file mode 100644 index 3ff8f12f1b8..00000000000 --- a/src/test/ui/issues/issue-99875.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0277]: the trait bound `fn(Argument) -> Return {function}: Trait` is not satisfied - --> $DIR/issue-99875.rs:12:11 - | -LL | takes(function); - | ----- ^^^^^^^^ the trait `Trait` is not implemented for fn item `fn(Argument) -> Return {function}` - | | - | required by a bound introduced by this call - | - = help: the trait `Trait` is implemented for fn pointer `fn(Argument) -> Return` -note: required by a bound in `takes` - --> $DIR/issue-99875.rs:9:18 - | -LL | fn takes(_: impl Trait) {} - | ^^^^^ required by this bound in `takes` - -error[E0277]: the trait bound `[closure@$DIR/issue-99875.rs:14:11: 14:34]: Trait` is not satisfied - --> $DIR/issue-99875.rs:14:11 - | -LL | takes(|_: Argument| -> Return { todo!() }); - | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for closure `[closure@$DIR/issue-99875.rs:14:11: 14:34]` - | | - | required by a bound introduced by this call - | - = help: the trait `Trait` is implemented for fn pointer `fn(Argument) -> Return` -note: required by a bound in `takes` - --> $DIR/issue-99875.rs:9:18 - | -LL | fn takes(_: impl Trait) {} - | ^^^^^ required by this bound in `takes` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/macros/issue-10536.rs b/src/test/ui/macros/issue-10536.rs new file mode 100644 index 00000000000..f536d8f940a --- /dev/null +++ b/src/test/ui/macros/issue-10536.rs @@ -0,0 +1,19 @@ +// We only want to assert that this doesn't ICE, we don't particularly care +// about whether it nor it fails to compile. + +macro_rules! foo{ + () => {{ + macro_rules! bar{() => (())} + 1 + }} +} + +pub fn main() { + foo!(); + + assert!({one! two()}); //~ ERROR expected one of `(`, `[`, or `{`, found `two` + + // regardless of whether nested macro_rules works, the following should at + // least throw a conventional error. + assert!({one! two}); //~ ERROR expected one of `(`, `[`, or `{`, found `two` +} diff --git a/src/test/ui/macros/issue-10536.stderr b/src/test/ui/macros/issue-10536.stderr new file mode 100644 index 00000000000..cc048445871 --- /dev/null +++ b/src/test/ui/macros/issue-10536.stderr @@ -0,0 +1,14 @@ +error: expected one of `(`, `[`, or `{`, found `two` + --> $DIR/issue-10536.rs:14:19 + | +LL | assert!({one! two()}); + | ^^^ expected one of `(`, `[`, or `{` + +error: expected one of `(`, `[`, or `{`, found `two` + --> $DIR/issue-10536.rs:18:19 + | +LL | assert!({one! two}); + | ^^^ expected one of `(`, `[`, or `{` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/nll/issue-54189.rs b/src/test/ui/nll/issue-54189.rs new file mode 100644 index 00000000000..70aecc384ef --- /dev/null +++ b/src/test/ui/nll/issue-54189.rs @@ -0,0 +1,6 @@ +fn bug() -> impl for <'r> Fn() -> &'r () { || { &() } } +//~^ ERROR binding for associated type `Output` references lifetime `'r` + +fn main() { + let f = bug(); +} diff --git a/src/test/ui/nll/issue-54189.stderr b/src/test/ui/nll/issue-54189.stderr new file mode 100644 index 00000000000..4787abd49d1 --- /dev/null +++ b/src/test/ui/nll/issue-54189.stderr @@ -0,0 +1,9 @@ +error[E0582]: binding for associated type `Output` references lifetime `'r`, which does not appear in the trait input types + --> $DIR/issue-54189.rs:1:35 + | +LL | fn bug() -> impl for <'r> Fn() -> &'r () { || { &() } } + | ^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0582`. diff --git a/src/test/ui/traits/issue-99875.rs b/src/test/ui/traits/issue-99875.rs new file mode 100644 index 00000000000..cf73fd8d31f --- /dev/null +++ b/src/test/ui/traits/issue-99875.rs @@ -0,0 +1,16 @@ +struct Argument; +struct Return; + +fn function(_: Argument) -> Return { todo!() } + +trait Trait {} +impl Trait for fn(Argument) -> Return {} + +fn takes(_: impl Trait) {} + +fn main() { + takes(function); + //~^ ERROR the trait bound + takes(|_: Argument| -> Return { todo!() }); + //~^ ERROR the trait bound +} diff --git a/src/test/ui/traits/issue-99875.stderr b/src/test/ui/traits/issue-99875.stderr new file mode 100644 index 00000000000..3ff8f12f1b8 --- /dev/null +++ b/src/test/ui/traits/issue-99875.stderr @@ -0,0 +1,33 @@ +error[E0277]: the trait bound `fn(Argument) -> Return {function}: Trait` is not satisfied + --> $DIR/issue-99875.rs:12:11 + | +LL | takes(function); + | ----- ^^^^^^^^ the trait `Trait` is not implemented for fn item `fn(Argument) -> Return {function}` + | | + | required by a bound introduced by this call + | + = help: the trait `Trait` is implemented for fn pointer `fn(Argument) -> Return` +note: required by a bound in `takes` + --> $DIR/issue-99875.rs:9:18 + | +LL | fn takes(_: impl Trait) {} + | ^^^^^ required by this bound in `takes` + +error[E0277]: the trait bound `[closure@$DIR/issue-99875.rs:14:11: 14:34]: Trait` is not satisfied + --> $DIR/issue-99875.rs:14:11 + | +LL | takes(|_: Argument| -> Return { todo!() }); + | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for closure `[closure@$DIR/issue-99875.rs:14:11: 14:34]` + | | + | required by a bound introduced by this call + | + = help: the trait `Trait` is implemented for fn pointer `fn(Argument) -> Return` +note: required by a bound in `takes` + --> $DIR/issue-99875.rs:9:18 + | +LL | fn takes(_: impl Trait) {} + | ^^^^^ required by this bound in `takes` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/typeck/issue-18937-1.rs b/src/test/ui/typeck/issue-18937-1.rs new file mode 100644 index 00000000000..57e56d832c6 --- /dev/null +++ b/src/test/ui/typeck/issue-18937-1.rs @@ -0,0 +1,21 @@ +// run-pass +// Test that we are able to type-check this example. In particular, +// knowing that `T: 'a` allows us to deduce that `[U]: 'a` (because +// when `T=[U]` it implies that `U: 'a`). +// +// Regr. test for live code we found in the wild when fixing #18937. + +pub trait Leak { + fn leak<'a>(self) -> &'a T where T: 'a; +} + +impl Leak<[U]> for Vec { + fn leak<'a>(mut self) -> &'a [U] where [U]: 'a { + let r: *mut [U] = &mut self[..]; + std::mem::forget(self); + unsafe { &mut *r } + } +} +fn main() { + println!("Hello, world!"); +} diff --git a/src/test/ui/typeck/issue-18937.rs b/src/test/ui/typeck/issue-18937.rs new file mode 100644 index 00000000000..af85e5b2b02 --- /dev/null +++ b/src/test/ui/typeck/issue-18937.rs @@ -0,0 +1,40 @@ +// Regression test for #18937. + +use std::fmt; + +#[derive(Debug)] +struct MyString<'a>(&'a String); + +struct B { + list: Vec>, +} + +trait A<'a> { + fn foo(&mut self, f: F) + where F: fmt::Debug + 'a, + Self: Sized; +} + +impl<'a> A<'a> for B { + fn foo(&mut self, f: F) + where F: fmt::Debug + 'static, //~ ERROR impl has stricter + { + self.list.push(Box::new(f)); + } +} + +fn main() { + let mut b = B { list: Vec::new() }; + + // Create a borrowed pointer, put it in `b`, then drop what's borrowing it + let a = "hello".to_string(); + b.foo(MyString(&a)); + + // Drop the data which `b` has a reference to + drop(a); + + // Use the data, probably segfaulting + for b in b.list.iter() { + println!("{:?}", b); + } +} diff --git a/src/test/ui/typeck/issue-18937.stderr b/src/test/ui/typeck/issue-18937.stderr new file mode 100644 index 00000000000..5e2ba0ef4fc --- /dev/null +++ b/src/test/ui/typeck/issue-18937.stderr @@ -0,0 +1,14 @@ +error[E0276]: impl has stricter requirements than trait + --> $DIR/issue-18937.rs:20:31 + | +LL | / fn foo(&mut self, f: F) +LL | | where F: fmt::Debug + 'a, +LL | | Self: Sized; + | |__________________________- definition of `foo` from trait +... +LL | where F: fmt::Debug + 'static, + | ^^^^^^^ impl has extra requirement `F: 'static` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0276`. diff --git a/src/test/ui/typeck/issue-31173.rs b/src/test/ui/typeck/issue-31173.rs new file mode 100644 index 00000000000..f678df5b42b --- /dev/null +++ b/src/test/ui/typeck/issue-31173.rs @@ -0,0 +1,15 @@ +use std::vec::IntoIter; + +pub fn get_tok(it: &mut IntoIter) { + let mut found_e = false; + + let temp: Vec = it + .take_while(|&x| { + found_e = true; + false + }) + .cloned() //~ ERROR to be an iterator that yields `&_`, but it yields `u8` + .collect(); //~ ERROR the method +} + +fn main() {} diff --git a/src/test/ui/typeck/issue-31173.stderr b/src/test/ui/typeck/issue-31173.stderr new file mode 100644 index 00000000000..f3be99f9bcb --- /dev/null +++ b/src/test/ui/typeck/issue-31173.stderr @@ -0,0 +1,45 @@ +error[E0271]: expected `TakeWhile<&mut IntoIter, [closure@issue-31173.rs:7:21]>` to be an iterator that yields `&_`, but it yields `u8` + --> $DIR/issue-31173.rs:11:10 + | +LL | .cloned() + | ^^^^^^ expected reference, found `u8` + | + = note: expected reference `&_` + found type `u8` +note: the method call chain might not have had the expected associated types + --> $DIR/issue-31173.rs:3:20 + | +LL | pub fn get_tok(it: &mut IntoIter) { + | ^^^^^^^^^^^^^^^^^ `Iterator::Item` is `u8` here +... +LL | .take_while(|&x| { + | __________- +LL | | found_e = true; +LL | | false +LL | | }) + | |__________- `Iterator::Item` remains `u8` here +note: required by a bound in `cloned` + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + +error[E0599]: the method `collect` exists for struct `Cloned, [closure@issue-31173.rs:7:21]>>`, but its trait bounds were not satisfied + --> $DIR/issue-31173.rs:12:10 + | +LL | .collect(); + | ^^^^^^^ method cannot be called due to unsatisfied trait bounds + --> $SRC_DIR/core/src/iter/adapters/take_while.rs:LL:COL + | + = note: doesn't satisfy `<_ as Iterator>::Item = &_` + --> $SRC_DIR/core/src/iter/adapters/cloned.rs:LL:COL + | + = note: doesn't satisfy `_: Iterator` + | + = note: the following trait bounds were not satisfied: + `, [closure@$DIR/issue-31173.rs:7:21: 7:25]> as Iterator>::Item = &_` + which is required by `Cloned, [closure@$DIR/issue-31173.rs:7:21: 7:25]>>: Iterator` + `Cloned, [closure@$DIR/issue-31173.rs:7:21: 7:25]>>: Iterator` + which is required by `&mut Cloned, [closure@$DIR/issue-31173.rs:7:21: 7:25]>>: Iterator` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0271, E0599. +For more information about an error, try `rustc --explain E0271`. diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 070e72437be..166d09fa8b0 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -10,7 +10,7 @@ use std::path::Path; const ENTRY_LIMIT: usize = 1000; // FIXME: The following limits should be reduced eventually. const ROOT_ENTRY_LIMIT: usize = 939; -const ISSUES_ENTRY_LIMIT: usize = 2050; +const ISSUES_ENTRY_LIMIT: usize = 1998; fn check_entries(path: &Path, bad: &mut bool) { for dir in Walk::new(&path.join("test/ui")) { -- cgit 1.4.1-3-g733a5