From 0767ed31f3860a7703a4a306f2f266279a55c3dc Mon Sep 17 00:00:00 2001 From: Marcel Hellwig Date: Mon, 11 Oct 2021 16:03:57 +0200 Subject: [PATCH] add some more testcases --- src/test/ui/consts/issue-88071.rs | 21 +++++++ .../generic-associated-types/issue-87750.rs | 22 +++++++ .../issue-87750.stderr | 9 +++ src/test/ui/traits/issue-52893.rs | 57 +++++++++++++++++++ src/test/ui/traits/issue-52893.stderr | 15 +++++ src/test/ui/traits/issue-68295.rs | 47 +++++++++++++++ src/test/ui/traits/issue-68295.stderr | 17 ++++++ 7 files changed, 188 insertions(+) create mode 100644 src/test/ui/consts/issue-88071.rs create mode 100644 src/test/ui/generic-associated-types/issue-87750.rs create mode 100644 src/test/ui/generic-associated-types/issue-87750.stderr create mode 100644 src/test/ui/traits/issue-52893.rs create mode 100644 src/test/ui/traits/issue-52893.stderr create mode 100644 src/test/ui/traits/issue-68295.rs create mode 100644 src/test/ui/traits/issue-68295.stderr diff --git a/src/test/ui/consts/issue-88071.rs b/src/test/ui/consts/issue-88071.rs new file mode 100644 index 0000000000000..a2d4a642128b4 --- /dev/null +++ b/src/test/ui/consts/issue-88071.rs @@ -0,0 +1,21 @@ +// check-pass +// +// regression test for #88071 + +#![feature(const_btree_new)] +#![feature(const_fn_trait_bound)] + +use std::collections::BTreeMap; + +pub struct CustomMap(BTreeMap); + +impl CustomMap +where + K: Ord, +{ + pub const fn new() -> Self { + CustomMap(BTreeMap::new()) + } +} + +fn main() {} diff --git a/src/test/ui/generic-associated-types/issue-87750.rs b/src/test/ui/generic-associated-types/issue-87750.rs new file mode 100644 index 0000000000000..89bd79ac2991e --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-87750.rs @@ -0,0 +1,22 @@ +#![feature(generic_associated_types)] + +trait PointerFamily { + type Pointer; +} + +struct Rc(Box); +struct RcFamily; + +impl PointerFamily for RcFamily { + type Pointer = Rc; +} + +#[allow(dead_code)] +enum Node where P::Pointer>: Sized { + Cons(P::Pointer>), +} + +fn main() { + let _list: ::Pointer>; + //~^ ERROR overflow evaluating the requirement `Node: Sized` +} diff --git a/src/test/ui/generic-associated-types/issue-87750.stderr b/src/test/ui/generic-associated-types/issue-87750.stderr new file mode 100644 index 0000000000000..854541f3d8fda --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-87750.stderr @@ -0,0 +1,9 @@ +error[E0275]: overflow evaluating the requirement `Node: Sized` + --> $DIR/issue-87750.rs:20:16 + | +LL | let _list: ::Pointer>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/traits/issue-52893.rs b/src/test/ui/traits/issue-52893.rs new file mode 100644 index 0000000000000..d72598d5d5942 --- /dev/null +++ b/src/test/ui/traits/issue-52893.rs @@ -0,0 +1,57 @@ +// check-fail +// +// regression test for issue 52893 +trait At { + type AtRes; + fn at(self) -> Self::AtRes; +} + +trait Push { + type PushRes; + fn push(self, other: T) -> Self::PushRes; +} + +trait AddClass { + type AddRes; + fn init(self, func: F); +} + +trait ToRef { + type RefRes; + fn to_ref(&self) -> Self::RefRes; +} + +struct Class

(P); + +impl

Class

{ + fn with(self) -> >::AddRes + where + Self: AddClass, + { + todo!() + } + + fn from(self) -> >::AddRes + where + Self: AddClass, + { + todo!() + } +} + +impl AddClass for Class

+where + Self: At, + >::AtRes: Push, + <>::AtRes as Push>::PushRes: ToRef + Push, +{ + type AddRes = (); + + fn init(self, func: F) { + let builder = self.at().push(func); + let output = builder.to_ref(); + builder.push(output); //~ ERROR mismatched types [E0308] + } +} + +fn main() {} diff --git a/src/test/ui/traits/issue-52893.stderr b/src/test/ui/traits/issue-52893.stderr new file mode 100644 index 0000000000000..bf732e2491566 --- /dev/null +++ b/src/test/ui/traits/issue-52893.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/issue-52893.rs:53:22 + | +LL | impl AddClass for Class

+ | - this type parameter +... +LL | builder.push(output); + | ^^^^^^ expected type parameter `F`, found struct `Class` + | + = note: expected type parameter `F` + found struct `Class

` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/traits/issue-68295.rs b/src/test/ui/traits/issue-68295.rs new file mode 100644 index 0000000000000..7ff54539adc5b --- /dev/null +++ b/src/test/ui/traits/issue-68295.rs @@ -0,0 +1,47 @@ +// check-fail +// +// regression test for #68295 + +struct Matrix(R, C, S); + +impl Matrix { + fn into_owned(self) -> Matrix> + where + (): Allocator, + { + unimplemented!() + } +} + +impl Matrix { + fn hermitian_part(&self) -> Matrix> + where + (): Allocator, + { + unimplemented!() + } +} + +trait Allocator { + type Buffer; +} + +trait Trait { + type Power; +} + +impl> Trait for () { + type Power = A::Buffer; +} + +type Owned = >::Power; + +fn crash(input: Matrix) -> Matrix +where + (): Allocator, +{ + input.into_owned() + //~^ ERROR mismatched types [E0308] +} + +fn main() {} diff --git a/src/test/ui/traits/issue-68295.stderr b/src/test/ui/traits/issue-68295.stderr new file mode 100644 index 0000000000000..cb6e6e0769cb8 --- /dev/null +++ b/src/test/ui/traits/issue-68295.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/issue-68295.rs:43:5 + | +LL | fn crash(input: Matrix) -> Matrix + | ----------------- expected `Matrix` because of return type +... +LL | input.into_owned() + | ^^^^^^^^^^^^^^^^^^ expected `u32`, found associated type + | + = note: expected struct `Matrix<_, _, u32>` + found struct `Matrix<_, _, <() as Allocator>::Buffer>` + = help: consider constraining the associated type `<() as Allocator>::Buffer` to `u32` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`.