about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/crashes/130956.rs37
-rw-r--r--tests/crashes/130967.rs13
-rw-r--r--tests/crashes/131046.rs15
-rw-r--r--tests/crashes/131048.rs7
-rw-r--r--tests/crashes/131050.rs27
-rw-r--r--tests/crashes/131052.rs8
-rw-r--r--tests/crashes/131101.rs12
-rw-r--r--tests/crashes/131102.rs4
-rw-r--r--tests/crashes/131103.rs6
-rw-r--r--tests/crashes/131190.rs19
-rw-r--r--tests/crashes/131227.rs16
-rw-r--r--tests/crashes/131292.rs7
-rw-r--r--tests/crashes/131294-2.rs25
-rw-r--r--tests/crashes/131294.rs16
-rw-r--r--tests/crashes/131295.rs9
-rw-r--r--tests/crashes/131298.rs12
-rw-r--r--tests/crashes/131342-2.rs40
-rw-r--r--tests/crashes/131342.rs16
-rw-r--r--tests/crashes/131347.rs9
-rw-r--r--tests/crashes/131373.rs33
-rw-r--r--tests/crashes/131406.rs12
-rw-r--r--tests/run-make/broken-pipe-no-ice/rmake.rs6
-rw-r--r--tests/ui/layout/post-mono-layout-cycle-2.rs59
-rw-r--r--tests/ui/layout/post-mono-layout-cycle-2.stderr23
-rw-r--r--tests/ui/layout/post-mono-layout-cycle.rs25
-rw-r--r--tests/ui/layout/post-mono-layout-cycle.stderr16
26 files changed, 472 insertions, 0 deletions
diff --git a/tests/crashes/130956.rs b/tests/crashes/130956.rs
new file mode 100644
index 00000000000..ebb986d123f
--- /dev/null
+++ b/tests/crashes/130956.rs
@@ -0,0 +1,37 @@
+//@ known-bug: #130956
+
+mod impl_trait_mod {
+    use super::*;
+    pub type OpaqueBlock = impl Trait;
+    pub type OpaqueIf = impl Trait;
+
+    pub struct BlockWrapper(OpaqueBlock);
+    pub struct IfWrapper(pub OpaqueIf);
+
+    pub fn if_impl() -> Parser<OpaqueIf> {
+        bind(option(block()), |_| block())
+    }
+}
+use impl_trait_mod::*;
+
+pub trait Trait {
+    type Assoc;
+}
+pub struct Parser<P>(P);
+pub struct Bind<P, F>(P, F);
+impl<P, F> Trait for Bind<P, F> { type Assoc = (); }
+impl Trait for BlockWrapper { type Assoc = (); }
+impl Trait for IfWrapper { type Assoc = (); }
+
+pub fn block() -> Parser<BlockWrapper> {
+    loop {}
+}
+pub fn option<P: Trait>(arg: Parser<P>) -> Parser<impl Trait> {
+    bind(arg, |_| block())
+}
+fn bind<P: Trait, P2, F: Fn(P::Assoc) -> Parser<P2>>(_: Parser<P>, _: F) -> Parser<Bind<P, F>>
+    { loop {} }
+
+fn main() {
+    if_impl().0;
+}
diff --git a/tests/crashes/130967.rs b/tests/crashes/130967.rs
new file mode 100644
index 00000000000..8a3aae72c20
--- /dev/null
+++ b/tests/crashes/130967.rs
@@ -0,0 +1,13 @@
+//@ known-bug: #130967
+
+trait Producer {
+    type Produced;
+    fn make_one() -> Self::Produced;
+}
+
+impl<E: ?Sized> Producer for () {
+    type Produced = Option<E>;
+    fn make_one() -> Self::Produced {
+        loop {}
+    }
+}
diff --git a/tests/crashes/131046.rs b/tests/crashes/131046.rs
new file mode 100644
index 00000000000..2638705ae18
--- /dev/null
+++ b/tests/crashes/131046.rs
@@ -0,0 +1,15 @@
+//@ known-bug: #131046
+
+trait Owner {
+    const C<const N: u32>: u32;
+}
+
+impl Owner for () {
+    const C<const N: u32>: u32 = N;
+}
+
+fn take0<const N: u64>(_: impl Owner<C<N> = { N }>) {}
+
+fn main() {
+    take0::<128>(());
+}
diff --git a/tests/crashes/131048.rs b/tests/crashes/131048.rs
new file mode 100644
index 00000000000..d57e9921a8a
--- /dev/null
+++ b/tests/crashes/131048.rs
@@ -0,0 +1,7 @@
+//@ known-bug: #131048
+
+impl<A> std::ops::CoerceUnsized<A> for A {}
+
+fn main() {
+    format_args!("Hello, world!");
+}
diff --git a/tests/crashes/131050.rs b/tests/crashes/131050.rs
new file mode 100644
index 00000000000..07f8662d016
--- /dev/null
+++ b/tests/crashes/131050.rs
@@ -0,0 +1,27 @@
+//@ known-bug: #131050
+//@ compile-flags: --edition=2021
+
+fn query_as<D>() {}
+
+async fn create_user() {
+    query_as();
+}
+
+async fn post_user_filter() -> impl Filter {
+    AndThen(&(), || async { create_user().await })
+}
+
+async fn get_app() -> impl Send {
+    post_user_filter().await
+}
+
+trait Filter {}
+
+struct AndThen<T, F>(T, F);
+
+impl<T, F, R> Filter for AndThen<T, F>
+where
+    F: Fn() -> R,
+    R: Send,
+{
+}
diff --git a/tests/crashes/131052.rs b/tests/crashes/131052.rs
new file mode 100644
index 00000000000..7ae3ec08f3e
--- /dev/null
+++ b/tests/crashes/131052.rs
@@ -0,0 +1,8 @@
+//@ known-bug: #131052
+#![feature(adt_const_params)]
+
+struct ConstBytes<const T: &'static [*mut u8; 3]>;
+
+pub fn main() {
+    let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">;
+}
diff --git a/tests/crashes/131101.rs b/tests/crashes/131101.rs
new file mode 100644
index 00000000000..3ec441101b7
--- /dev/null
+++ b/tests/crashes/131101.rs
@@ -0,0 +1,12 @@
+//@ known-bug: #131101
+trait Foo<const N: u8> {
+    fn do_x(&self) -> [u8; N];
+}
+
+struct Bar;
+
+impl Foo<const 3> for Bar {
+    fn do_x(&self) -> [u8; 3] {
+        [0u8; 3]
+    }
+}
diff --git a/tests/crashes/131102.rs b/tests/crashes/131102.rs
new file mode 100644
index 00000000000..12b35f8d1b2
--- /dev/null
+++ b/tests/crashes/131102.rs
@@ -0,0 +1,4 @@
+//@ known-bug: #131102
+pub struct Blorb<const N: u16>([String; N]);
+pub struct Wrap(Blorb<0>);
+pub const fn i(_: Wrap) {}
diff --git a/tests/crashes/131103.rs b/tests/crashes/131103.rs
new file mode 100644
index 00000000000..70193e8b3bd
--- /dev/null
+++ b/tests/crashes/131103.rs
@@ -0,0 +1,6 @@
+//@ known-bug: #131103
+struct Struct<const N: i128>(pub [u8; N]);
+
+pub fn function(value: Struct<3>) -> u8 {
+    value.0[0]
+}
diff --git a/tests/crashes/131190.rs b/tests/crashes/131190.rs
new file mode 100644
index 00000000000..3a0e64c69d5
--- /dev/null
+++ b/tests/crashes/131190.rs
@@ -0,0 +1,19 @@
+//@ known-bug: #131190
+//@ compile-flags: -Cinstrument-coverage --edition=2018
+
+use std::future::Future;
+
+pub fn block_on<T>(fut: impl Future<Output = T>) -> T {}
+
+async fn call_once(f: impl async FnOnce(DropMe)) {
+    f(DropMe("world")).await;
+}
+
+struct DropMe(&'static str);
+
+pub fn main() {
+    block_on(async {
+        let async_closure = async move |a: DropMe| {};
+        call_once(async_closure).await;
+    });
+}
diff --git a/tests/crashes/131227.rs b/tests/crashes/131227.rs
new file mode 100644
index 00000000000..f46185b5b4a
--- /dev/null
+++ b/tests/crashes/131227.rs
@@ -0,0 +1,16 @@
+//@ known-bug: #131227
+//@ compile-flags: -Zmir-opt-level=3
+
+static mut G: () = ();
+
+fn myfunc() -> i32 {
+    let var = &raw mut G;
+    if var.is_null() {
+        return 0;
+    }
+    0
+}
+
+fn main() {
+    myfunc();
+}
diff --git a/tests/crashes/131292.rs b/tests/crashes/131292.rs
new file mode 100644
index 00000000000..01e0eca0bd6
--- /dev/null
+++ b/tests/crashes/131292.rs
@@ -0,0 +1,7 @@
+//@ known-bug: #131292
+//@ only-x86_64
+use std::arch::asm;
+
+unsafe fn f6() {
+    asm!(concat!(r#"lJ𐏿Æ�.𐏿�"#, "{}/day{:02}.txt"));
+}
diff --git a/tests/crashes/131294-2.rs b/tests/crashes/131294-2.rs
new file mode 100644
index 00000000000..130a8b10fb7
--- /dev/null
+++ b/tests/crashes/131294-2.rs
@@ -0,0 +1,25 @@
+//@ known-bug: #131294
+//@ compile-flags: -Zmir-opt-level=5 -Zvalidate-mir -Zcross-crate-inline-threshold=always
+
+// https://github.com/rust-lang/rust/issues/131294#issuecomment-2395088049 second comment
+struct Rows;
+
+impl Iterator for Rows {
+    type Item = String;
+
+    fn next() -> Option<String> {
+        let args = format_args!("Hello world");
+
+        {
+            match args.as_str() {
+                Some(t) => t.to_owned(),
+                None => String::new(),
+            }
+        }
+            .into()
+    }
+}
+
+fn main() {
+    Rows.next();
+}
diff --git a/tests/crashes/131294.rs b/tests/crashes/131294.rs
new file mode 100644
index 00000000000..ec6c9567467
--- /dev/null
+++ b/tests/crashes/131294.rs
@@ -0,0 +1,16 @@
+//@ known-bug: #131294
+//@ compile-flags: -Zmir-opt-level=5 -Zvalidate-mir -Zcross-crate-inline-threshold=always
+
+struct Rows;
+
+impl Iterator for Rows {
+    type Item = String;
+
+    fn next() -> Option<Self::Item> {
+        std::fmt::format(format_args!("Hello world")).into()
+    }
+}
+
+fn main() {
+    Rows.next();
+}
diff --git a/tests/crashes/131295.rs b/tests/crashes/131295.rs
new file mode 100644
index 00000000000..f31d6bc324a
--- /dev/null
+++ b/tests/crashes/131295.rs
@@ -0,0 +1,9 @@
+//@ known-bug: #131295
+
+#![feature(generic_const_exprs)]
+
+async fn foo<'a>() -> [(); {
+       let _y: &'a ();
+       4
+   }] {
+}
diff --git a/tests/crashes/131298.rs b/tests/crashes/131298.rs
new file mode 100644
index 00000000000..833f1b04ffa
--- /dev/null
+++ b/tests/crashes/131298.rs
@@ -0,0 +1,12 @@
+//@ known-bug: #131298
+
+fn dyn_hoops<T>() -> *const dyn Iterator<Item = impl Captures> {
+    loop {}
+}
+
+mod typeck {
+    type Opaque = impl Sized;
+    fn define() -> Opaque {
+        let _: Opaque = super::dyn_hoops::<u8>();
+    }
+}
diff --git a/tests/crashes/131342-2.rs b/tests/crashes/131342-2.rs
new file mode 100644
index 00000000000..79b6a837a49
--- /dev/null
+++ b/tests/crashes/131342-2.rs
@@ -0,0 +1,40 @@
+//@ known-bug: #131342
+// see also: 131342.rs
+
+fn main() {
+    problem_thingy(Once);
+}
+
+struct Once;
+
+impl Iterator for Once {
+    type Item = ();
+}
+
+fn problem_thingy(items: impl Iterator) {
+    let peeker = items.peekable();
+    problem_thingy(&peeker);
+}
+
+trait Iterator {
+    type Item;
+
+    fn peekable(self) -> Peekable<Self>
+    where
+        Self: Sized,
+    {
+        loop {}
+    }
+}
+
+struct Peekable<I: Iterator> {
+    _peeked: I::Item,
+}
+
+impl<I: Iterator> Iterator for Peekable<I> {
+    type Item = I::Item;
+}
+
+impl<I: Iterator + ?Sized> Iterator for &I {
+    type Item = I::Item;
+}
diff --git a/tests/crashes/131342.rs b/tests/crashes/131342.rs
new file mode 100644
index 00000000000..7f7ee9c9ac1
--- /dev/null
+++ b/tests/crashes/131342.rs
@@ -0,0 +1,16 @@
+//@ known-bug: #131342
+// see also: 131342-2.rs
+
+fn main() {
+  let mut items = vec![1, 2, 3, 4, 5].into_iter();
+  problem_thingy(&mut items);
+}
+
+fn problem_thingy(items: &mut impl Iterator<Item = u8>) {
+  let mut peeker = items.peekable();
+  match peeker.peek() {
+    Some(_) => (),
+    None => return (),
+  }
+  problem_thingy(&mut peeker);
+}
diff --git a/tests/crashes/131347.rs b/tests/crashes/131347.rs
new file mode 100644
index 00000000000..15f367d79e2
--- /dev/null
+++ b/tests/crashes/131347.rs
@@ -0,0 +1,9 @@
+//@ known-bug: #131347
+//@ compile-flags: -Zmir-opt-level=5 -Zvalidate-mir
+
+struct S;
+static STUFF: [i8] = [0; S::N];
+
+fn main() {
+    assert_eq!(STUFF, [0; 63]);
+}
diff --git a/tests/crashes/131373.rs b/tests/crashes/131373.rs
new file mode 100644
index 00000000000..661fecd7620
--- /dev/null
+++ b/tests/crashes/131373.rs
@@ -0,0 +1,33 @@
+//@ known-bug: #131373
+
+trait LockReference: 'static {
+    type Ref<'a>;
+}
+
+struct SliceRef<'a, T: ?Sized> {
+    _x: &'a T,
+}
+
+impl<'a, T: ?Sized, SR: LockReference> IntoIterator for SliceRef<'a, T>
+where
+    &'a T: IntoIterator<Item = &'a SR>,
+{
+    type Item = SR::Ref<'a>;
+    type IntoIter = std::iter::Map<<&'a T as IntoIterator>::IntoIter,
+        for<'c> fn(&'c SR) -> SR::Ref<'c>>;
+    fn into_iter(self) -> Self::IntoIter {
+        loop {}
+    }
+}
+
+impl LockReference for () {
+    type Ref<'a> = ();
+}
+
+fn locked() -> SliceRef<'static, [()]> {
+    loop {}
+}
+
+fn main() {
+    let _ = locked().into_iter();
+}
diff --git a/tests/crashes/131406.rs b/tests/crashes/131406.rs
new file mode 100644
index 00000000000..ea642f94928
--- /dev/null
+++ b/tests/crashes/131406.rs
@@ -0,0 +1,12 @@
+//@ known-bug: #131406
+
+trait Owner {
+    const C<const N: u32>: u32 = N;
+}
+
+impl Owner for () {}
+fn take0<const N: u64>(_: impl Owner<C<N> = { N }>) {}
+
+fn main() {
+    take0::<128>(());
+}
diff --git a/tests/run-make/broken-pipe-no-ice/rmake.rs b/tests/run-make/broken-pipe-no-ice/rmake.rs
index d1db0bc7368..378c3289cb7 100644
--- a/tests/run-make/broken-pipe-no-ice/rmake.rs
+++ b/tests/run-make/broken-pipe-no-ice/rmake.rs
@@ -5,6 +5,12 @@
 
 //@ ignore-cross-compile (needs to run test binary)
 
+//@ ignore-apple
+// FIXME(#131436): on macOS rustc is still reporting the std broken pipe io error panick but it
+// doesn't fail with 101 exit status (it terminates with a wait status of SIGPIPE). It doesn't say
+// Internal Compiler Error strangely, but it doesn't even go through normal diagnostic infra. Very
+// strange.
+
 #![feature(anonymous_pipe)]
 
 use std::io::Read;
diff --git a/tests/ui/layout/post-mono-layout-cycle-2.rs b/tests/ui/layout/post-mono-layout-cycle-2.rs
new file mode 100644
index 00000000000..356f1e777c7
--- /dev/null
+++ b/tests/ui/layout/post-mono-layout-cycle-2.rs
@@ -0,0 +1,59 @@
+//@ build-fail
+//@ edition: 2021
+
+#![feature(async_closure, noop_waker)]
+
+use std::future::Future;
+use std::pin::pin;
+use std::task::*;
+
+pub fn block_on<T>(fut: impl Future<Output = T>) -> T {
+    let mut fut = pin!(fut);
+    // Poll loop, just to test the future...
+    let ctx = &mut Context::from_waker(Waker::noop());
+
+    loop {
+        match fut.as_mut().poll(ctx) {
+            Poll::Pending => {}
+            Poll::Ready(t) => break t,
+        }
+    }
+}
+
+trait Blah {
+    async fn iter<T>(&mut self, iterator: T)
+    where
+        T: IntoIterator<Item = ()>;
+}
+
+impl Blah for () {
+    async fn iter<T>(&mut self, iterator: T)
+    //~^ ERROR recursion in an async fn requires boxing
+    where
+        T: IntoIterator<Item = ()>,
+    {
+        Blah::iter(self, iterator).await
+    }
+}
+
+struct Wrap<T: Blah> {
+    t: T,
+}
+
+impl<T: Blah> Wrap<T>
+where
+    T: Blah,
+{
+    async fn ice(&mut self) {
+        //~^ ERROR a cycle occurred during layout computation
+        let arr: [(); 0] = [];
+        self.t.iter(arr.into_iter()).await;
+    }
+}
+
+fn main() {
+    block_on(async {
+        let mut t = Wrap { t: () };
+        t.ice();
+    })
+}
diff --git a/tests/ui/layout/post-mono-layout-cycle-2.stderr b/tests/ui/layout/post-mono-layout-cycle-2.stderr
new file mode 100644
index 00000000000..ad01c2694fa
--- /dev/null
+++ b/tests/ui/layout/post-mono-layout-cycle-2.stderr
@@ -0,0 +1,23 @@
+error[E0733]: recursion in an async fn requires boxing
+  --> $DIR/post-mono-layout-cycle-2.rs:30:5
+   |
+LL | /     async fn iter<T>(&mut self, iterator: T)
+LL | |
+LL | |     where
+LL | |         T: IntoIterator<Item = ()>,
+   | |___________________________________^
+LL |       {
+LL |           Blah::iter(self, iterator).await
+   |           -------------------------------- recursive call here
+   |
+   = note: a recursive `async fn` call must introduce indirection such as `Box::pin` to avoid an infinitely sized future
+
+error: a cycle occurred during layout computation
+  --> $DIR/post-mono-layout-cycle-2.rs:47:5
+   |
+LL |     async fn ice(&mut self) {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0733`.
diff --git a/tests/ui/layout/post-mono-layout-cycle.rs b/tests/ui/layout/post-mono-layout-cycle.rs
new file mode 100644
index 00000000000..8d136190c00
--- /dev/null
+++ b/tests/ui/layout/post-mono-layout-cycle.rs
@@ -0,0 +1,25 @@
+//@ build-fail
+//~^ cycle detected when computing layout of `Wrapper<()>`
+
+trait Trait {
+    type Assoc;
+}
+
+impl Trait for () {
+    type Assoc = Wrapper<()>;
+}
+
+struct Wrapper<T: Trait> {
+    _x: <T as Trait>::Assoc,
+}
+
+fn abi<T: Trait>(_: Option<Wrapper<T>>) {}
+//~^ ERROR a cycle occurred during layout computation
+
+fn indirect<T: Trait>() {
+    abi::<T>(None);
+}
+
+fn main() {
+    indirect::<()>();
+}
diff --git a/tests/ui/layout/post-mono-layout-cycle.stderr b/tests/ui/layout/post-mono-layout-cycle.stderr
new file mode 100644
index 00000000000..47f7f30b1cb
--- /dev/null
+++ b/tests/ui/layout/post-mono-layout-cycle.stderr
@@ -0,0 +1,16 @@
+error[E0391]: cycle detected when computing layout of `Wrapper<()>`
+   |
+   = note: ...which requires computing layout of `<() as Trait>::Assoc`...
+   = note: ...which again requires computing layout of `Wrapper<()>`, completing the cycle
+   = note: cycle used when computing layout of `core::option::Option<Wrapper<()>>`
+   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
+
+error: a cycle occurred during layout computation
+  --> $DIR/post-mono-layout-cycle.rs:16:1
+   |
+LL | fn abi<T: Trait>(_: Option<Wrapper<T>>) {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0391`.