about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-04-07 09:17:15 +0200
committerGitHub <noreply@github.com>2024-04-07 09:17:15 +0200
commitbbc7807b42b4d7eb27113d39f4b7d0c15f25ba77 (patch)
tree05764f09d21f4d8134082581eaa00d22c0931fd6
parentdc387cf2957eee7b9d5c09094a6045b0045e10db (diff)
parent88aa71f1084cae330345f5c904112cad1686e003 (diff)
downloadrust-bbc7807b42b4d7eb27113d39f4b7d0c15f25ba77.tar.gz
rust-bbc7807b42b4d7eb27113d39f4b7d0c15f25ba77.zip
Rollup merge of #123579 - matthiaskrgr:I_Love_Tests, r=jieyouxu
add some more tests

Fixes https://github.com/rust-lang/rust/issues/115806
Fixes https://github.com/rust-lang/rust/issues/116710
Fixes https://github.com/rust-lang/rust/issues/123145
Fixes https://github.com/rust-lang/rust/issues/105488
Fixes https://github.com/rust-lang/rust/issues/122488
Fixes https://github.com/rust-lang/rust/issues/123078
-rw-r--r--tests/ui/const-generics/generic_const_exprs/unknown-alias-defkind-anonconst-ice-116710.rs15
-rw-r--r--tests/ui/const-generics/generic_const_exprs/unknown-alias-defkind-anonconst-ice-116710.stderr19
-rw-r--r--tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.rs19
-rw-r--r--tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.stderr14
-rw-r--r--tests/ui/impl-trait/failed-to-resolve-instance-ice-105488.rs42
-rw-r--r--tests/ui/impl-trait/failed-to-resolve-instance-ice-105488.stderr16
-rw-r--r--tests/ui/impl-trait/failed-to-resolve-instance-ice-123145.rs20
-rw-r--r--tests/ui/impl-trait/failed-to-resolve-instance-ice-123145.stderr15
-rw-r--r--tests/ui/layout/base-layout-is-sized-ice-123078.rs17
-rw-r--r--tests/ui/layout/base-layout-is-sized-ice-123078.stderr31
-rw-r--r--tests/ui/layout/issue-unsized-tail-restatic-ice-122488.rs10
-rw-r--r--tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr27
12 files changed, 245 insertions, 0 deletions
diff --git a/tests/ui/const-generics/generic_const_exprs/unknown-alias-defkind-anonconst-ice-116710.rs b/tests/ui/const-generics/generic_const_exprs/unknown-alias-defkind-anonconst-ice-116710.rs
new file mode 100644
index 00000000000..dd0b1e8c9f7
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/unknown-alias-defkind-anonconst-ice-116710.rs
@@ -0,0 +1,15 @@
+// ICE unknown alias DefKind: AnonConst
+// issue: rust-lang/rust#116710
+#![feature(generic_const_exprs)]
+#![allow(incomplete_features)]
+
+struct A<const N: u32 = 1, const M: u32 = u8>;
+//~^ ERROR expected value, found builtin type `u8`
+
+trait Trait {}
+impl<const N: u32> Trait for A<N> {}
+
+impl<const N: u32> Trait for A<N> {}
+//~^ ERROR conflicting implementations of trait `Trait` for type `A<_>`
+
+pub fn main() {}
diff --git a/tests/ui/const-generics/generic_const_exprs/unknown-alias-defkind-anonconst-ice-116710.stderr b/tests/ui/const-generics/generic_const_exprs/unknown-alias-defkind-anonconst-ice-116710.stderr
new file mode 100644
index 00000000000..80ac96d4870
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/unknown-alias-defkind-anonconst-ice-116710.stderr
@@ -0,0 +1,19 @@
+error[E0423]: expected value, found builtin type `u8`
+  --> $DIR/unknown-alias-defkind-anonconst-ice-116710.rs:6:43
+   |
+LL | struct A<const N: u32 = 1, const M: u32 = u8>;
+   |                                           ^^ not a value
+
+error[E0119]: conflicting implementations of trait `Trait` for type `A<_>`
+  --> $DIR/unknown-alias-defkind-anonconst-ice-116710.rs:12:1
+   |
+LL | impl<const N: u32> Trait for A<N> {}
+   | --------------------------------- first implementation here
+LL |
+LL | impl<const N: u32> Trait for A<N> {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `A<_>`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0119, E0423.
+For more information about an error, try `rustc --explain E0119`.
diff --git a/tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.rs b/tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.rs
new file mode 100644
index 00000000000..2607013ec63
--- /dev/null
+++ b/tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.rs
@@ -0,0 +1,19 @@
+// ICE: assertion failed: !value.has_infer()
+// issue: rust-lang/rust#115806
+#![feature(associated_const_equality)]
+#![allow(incomplete_features)]
+
+pub struct NoPin;
+
+impl<TA> Pins<TA> for NoPin {}
+
+pub trait PinA<PER> {
+    const A: &'static () = &();
+}
+
+pub trait Pins<USART> {}
+
+impl<USART, T> Pins<USART> for T where T: PinA<USART, A = { &() }> {}
+//~^ ERROR conflicting implementations of trait `Pins<_>` for type `NoPin`
+
+pub fn main() {}
diff --git a/tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.stderr b/tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.stderr
new file mode 100644
index 00000000000..9a9baaddcba
--- /dev/null
+++ b/tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.stderr
@@ -0,0 +1,14 @@
+error[E0119]: conflicting implementations of trait `Pins<_>` for type `NoPin`
+  --> $DIR/assoc-const-no-infer-ice-115806.rs:16:1
+   |
+LL | impl<TA> Pins<TA> for NoPin {}
+   | --------------------------- first implementation here
+...
+LL | impl<USART, T> Pins<USART> for T where T: PinA<USART, A = { &() }> {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `NoPin`
+   |
+   = note: downstream crates may implement trait `PinA<_>` for type `NoPin`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0119`.
diff --git a/tests/ui/impl-trait/failed-to-resolve-instance-ice-105488.rs b/tests/ui/impl-trait/failed-to-resolve-instance-ice-105488.rs
new file mode 100644
index 00000000000..994a5073947
--- /dev/null
+++ b/tests/ui/impl-trait/failed-to-resolve-instance-ice-105488.rs
@@ -0,0 +1,42 @@
+// ICE failed to resolve instance for <fn() -> impl MyFnOnce  ...
+// issue: rust-lang/rust#105488
+//@ build-fail
+//~^^^ ERROR overflow evaluating the requirement `fn() -> impl MyFnOnce
+
+pub trait MyFnOnce {
+    type Output;
+
+    fn call_my_fn_once(self) -> Self::Output;
+}
+
+pub struct WrapFnOnce<F>(F);
+
+impl<F: FnOnce() -> D, D: MyFnOnce> MyFnOnce for WrapFnOnce<F> {
+    type Output = D::Output;
+
+    fn call_my_fn_once(self) -> Self::Output {
+        D::call_my_fn_once(self.0())
+    }
+}
+
+impl<F: FnOnce() -> D, D: MyFnOnce> MyFnOnce for F {
+    type Output = D::Output;
+
+    fn call_my_fn_once(self) -> Self::Output {
+        D::call_my_fn_once(self())
+    }
+}
+
+pub fn my_fn_1() -> impl MyFnOnce {
+    my_fn_2
+}
+
+pub fn my_fn_2() -> impl MyFnOnce {
+    WrapFnOnce(my_fn_1)
+}
+
+fn main() {
+    let v = my_fn_1();
+
+    let _ = v.call_my_fn_once();
+}
diff --git a/tests/ui/impl-trait/failed-to-resolve-instance-ice-105488.stderr b/tests/ui/impl-trait/failed-to-resolve-instance-ice-105488.stderr
new file mode 100644
index 00000000000..c2782b79d90
--- /dev/null
+++ b/tests/ui/impl-trait/failed-to-resolve-instance-ice-105488.stderr
@@ -0,0 +1,16 @@
+error[E0275]: overflow evaluating the requirement `fn() -> impl MyFnOnce {my_fn_2}: MyFnOnce`
+   |
+   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`failed_to_resolve_instance_ice_105488`)
+note: required for `WrapFnOnce<fn() -> impl MyFnOnce {my_fn_1}>` to implement `MyFnOnce`
+  --> $DIR/failed-to-resolve-instance-ice-105488.rs:14:37
+   |
+LL | impl<F: FnOnce() -> D, D: MyFnOnce> MyFnOnce for WrapFnOnce<F> {
+   |                           --------  ^^^^^^^^     ^^^^^^^^^^^^^
+   |                           |
+   |                           unsatisfied trait bound introduced here
+   = note: 126 redundant requirements hidden
+   = note: required for `WrapFnOnce<fn() -> impl MyFnOnce {my_fn_1}>` to implement `MyFnOnce`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0275`.
diff --git a/tests/ui/impl-trait/failed-to-resolve-instance-ice-123145.rs b/tests/ui/impl-trait/failed-to-resolve-instance-ice-123145.rs
new file mode 100644
index 00000000000..977827f3b55
--- /dev/null
+++ b/tests/ui/impl-trait/failed-to-resolve-instance-ice-123145.rs
@@ -0,0 +1,20 @@
+// ICE failed to resolve instance for ...
+// issue: rust-lang/rust#123145
+//@ build-fail
+//~^^^ ERROR overflow evaluating the requirement `(fn() -> impl Handler
+
+trait Handler {
+    fn handle(&self) {}
+}
+
+impl<H: Handler, F: Fn() -> H> Handler for F {}
+
+impl<L: Handler> Handler for (L,) {}
+
+fn one() -> impl Handler {
+    (one,)
+}
+
+fn main() {
+    one.handle();
+}
diff --git a/tests/ui/impl-trait/failed-to-resolve-instance-ice-123145.stderr b/tests/ui/impl-trait/failed-to-resolve-instance-ice-123145.stderr
new file mode 100644
index 00000000000..f61e8c2f8df
--- /dev/null
+++ b/tests/ui/impl-trait/failed-to-resolve-instance-ice-123145.stderr
@@ -0,0 +1,15 @@
+error[E0275]: overflow evaluating the requirement `(fn() -> impl Handler {one},): Handler`
+   |
+note: required for `fn() -> impl Handler {one}` to implement `Handler`
+  --> $DIR/failed-to-resolve-instance-ice-123145.rs:10:32
+   |
+LL | impl<H: Handler, F: Fn() -> H> Handler for F {}
+   |         -------                ^^^^^^^     ^
+   |         |
+   |         unsatisfied trait bound introduced here
+   = note: 2 redundant requirements hidden
+   = note: required for `fn() -> impl Handler {one}` to implement `Handler`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0275`.
diff --git a/tests/ui/layout/base-layout-is-sized-ice-123078.rs b/tests/ui/layout/base-layout-is-sized-ice-123078.rs
new file mode 100644
index 00000000000..b1c33e15075
--- /dev/null
+++ b/tests/ui/layout/base-layout-is-sized-ice-123078.rs
@@ -0,0 +1,17 @@
+// ICE !base.layout().is_sized()
+// issue: rust-lang/rust#123078
+
+struct S {
+    a: [u8],
+    //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+    b: (),
+}
+
+const C: S = unsafe { std::mem::transmute(()) };
+//~^ ERROR cannot transmute between types of different sizes, or dependently-sized types
+const _: [(); {
+    C;
+    0
+}] = [];
+
+pub fn main() {}
diff --git a/tests/ui/layout/base-layout-is-sized-ice-123078.stderr b/tests/ui/layout/base-layout-is-sized-ice-123078.stderr
new file mode 100644
index 00000000000..7e0a41a4367
--- /dev/null
+++ b/tests/ui/layout/base-layout-is-sized-ice-123078.stderr
@@ -0,0 +1,31 @@
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+  --> $DIR/base-layout-is-sized-ice-123078.rs:5:8
+   |
+LL |     a: [u8],
+   |        ^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `[u8]`
+   = note: only the last field of a struct may have a dynamically sized type
+   = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+   |
+LL |     a: &[u8],
+   |        +
+help: the `Box` type always has a statically known size and allocates its contents in the heap
+   |
+LL |     a: Box<[u8]>,
+   |        ++++    +
+
+error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
+  --> $DIR/base-layout-is-sized-ice-123078.rs:10:23
+   |
+LL | const C: S = unsafe { std::mem::transmute(()) };
+   |                       ^^^^^^^^^^^^^^^^^^^
+   |
+   = note: source type: `()` (0 bits)
+   = note: target type: `S` (this type does not have a fixed size)
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0277, E0512.
+For more information about an error, try `rustc --explain E0277`.
diff --git a/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.rs b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.rs
new file mode 100644
index 00000000000..96c993035ef
--- /dev/null
+++ b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.rs
@@ -0,0 +1,10 @@
+// ICE Unexpected unsized type tail: &ReStatic [u8]
+// issue: rust-lang/rust#122488
+use std::ops::Deref;
+
+struct ArenaSet<U: Deref, V: ?Sized = <U as Deref>::Target>(V, U);
+//~^ ERROR the size for values of type `V` cannot be known at compilation time
+
+const DATA: *const ArenaSet<Vec<u8>> = std::ptr::null_mut();
+
+pub fn main() {}
diff --git a/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr
new file mode 100644
index 00000000000..f39cb29868a
--- /dev/null
+++ b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr
@@ -0,0 +1,27 @@
+error[E0277]: the size for values of type `V` cannot be known at compilation time
+  --> $DIR/issue-unsized-tail-restatic-ice-122488.rs:5:61
+   |
+LL | struct ArenaSet<U: Deref, V: ?Sized = <U as Deref>::Target>(V, U);
+   |                           --------------------------------  ^ doesn't have a size known at compile-time
+   |                           |
+   |                           this type parameter needs to be `Sized`
+   |
+   = note: only the last field of a struct may have a dynamically sized type
+   = help: change the field's type to have a statically known size
+help: consider removing the `?Sized` bound to make the type parameter `Sized`
+   |
+LL - struct ArenaSet<U: Deref, V: ?Sized = <U as Deref>::Target>(V, U);
+LL + struct ArenaSet<U: Deref, V = <U as Deref>::Target>(V, U);
+   |
+help: borrowed types always have a statically known size
+   |
+LL | struct ArenaSet<U: Deref, V: ?Sized = <U as Deref>::Target>(&V, U);
+   |                                                             +
+help: the `Box` type always has a statically known size and allocates its contents in the heap
+   |
+LL | struct ArenaSet<U: Deref, V: ?Sized = <U as Deref>::Target>(Box<V>, U);
+   |                                                             ++++ +
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.