Skip to content

Commit b71451f

Browse files
authored
Rollup merge of rust-lang#89768 - hellow554:tests, r=Mark-Simulacrum
add some more testcases resolves rust-lang#52893 resolves rust-lang#68295 resolves rust-lang#87750 resolves rust-lang#88071 All these issues have been fixed according to glacier. Just adding a test so it can be closed. Can anybody tell me why the github keywords do not work? 🤔 Please edit this post if you can fix it.
2 parents ef4b306 + 0767ed3 commit b71451f

File tree

7 files changed

+188
-0
lines changed

7 files changed

+188
-0
lines changed

src/test/ui/consts/issue-88071.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// check-pass
2+
//
3+
// regression test for #88071
4+
5+
#![feature(const_btree_new)]
6+
#![feature(const_fn_trait_bound)]
7+
8+
use std::collections::BTreeMap;
9+
10+
pub struct CustomMap<K, V>(BTreeMap<K, V>);
11+
12+
impl<K, V> CustomMap<K, V>
13+
where
14+
K: Ord,
15+
{
16+
pub const fn new() -> Self {
17+
CustomMap(BTreeMap::new())
18+
}
19+
}
20+
21+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#![feature(generic_associated_types)]
2+
3+
trait PointerFamily {
4+
type Pointer<T>;
5+
}
6+
7+
struct Rc<T>(Box<T>);
8+
struct RcFamily;
9+
10+
impl PointerFamily for RcFamily {
11+
type Pointer<T> = Rc<T>;
12+
}
13+
14+
#[allow(dead_code)]
15+
enum Node<T, P: PointerFamily> where P::Pointer<Node<T, P>>: Sized {
16+
Cons(P::Pointer<Node<T, P>>),
17+
}
18+
19+
fn main() {
20+
let _list: <RcFamily as PointerFamily>::Pointer<Node<i32, RcFamily>>;
21+
//~^ ERROR overflow evaluating the requirement `Node<i32, RcFamily>: Sized`
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0275]: overflow evaluating the requirement `Node<i32, RcFamily>: Sized`
2+
--> $DIR/issue-87750.rs:20:16
3+
|
4+
LL | let _list: <RcFamily as PointerFamily>::Pointer<Node<i32, RcFamily>>;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0275`.

src/test/ui/traits/issue-52893.rs

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// check-fail
2+
//
3+
// regression test for issue 52893
4+
trait At<Name> {
5+
type AtRes;
6+
fn at(self) -> Self::AtRes;
7+
}
8+
9+
trait Push<T> {
10+
type PushRes;
11+
fn push(self, other: T) -> Self::PushRes;
12+
}
13+
14+
trait AddClass<Name, F> {
15+
type AddRes;
16+
fn init(self, func: F);
17+
}
18+
19+
trait ToRef {
20+
type RefRes;
21+
fn to_ref(&self) -> Self::RefRes;
22+
}
23+
24+
struct Class<P>(P);
25+
26+
impl<P> Class<P> {
27+
fn with<Name, F>(self) -> <Self as AddClass<Name, F>>::AddRes
28+
where
29+
Self: AddClass<Name, F>,
30+
{
31+
todo!()
32+
}
33+
34+
fn from<F>(self) -> <Self as AddClass<P, F>>::AddRes
35+
where
36+
Self: AddClass<P, F>,
37+
{
38+
todo!()
39+
}
40+
}
41+
42+
impl<F, Name, P> AddClass<Name, F> for Class<P>
43+
where
44+
Self: At<Name>,
45+
<Self as At<Name>>::AtRes: Push<F>,
46+
<<Self as At<Name>>::AtRes as Push<F>>::PushRes: ToRef<RefRes = Self> + Push<F>,
47+
{
48+
type AddRes = ();
49+
50+
fn init(self, func: F) {
51+
let builder = self.at().push(func);
52+
let output = builder.to_ref();
53+
builder.push(output); //~ ERROR mismatched types [E0308]
54+
}
55+
}
56+
57+
fn main() {}

src/test/ui/traits/issue-52893.stderr

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-52893.rs:53:22
3+
|
4+
LL | impl<F, Name, P> AddClass<Name, F> for Class<P>
5+
| - this type parameter
6+
...
7+
LL | builder.push(output);
8+
| ^^^^^^ expected type parameter `F`, found struct `Class`
9+
|
10+
= note: expected type parameter `F`
11+
found struct `Class<P>`
12+
13+
error: aborting due to previous error
14+
15+
For more information about this error, try `rustc --explain E0308`.

src/test/ui/traits/issue-68295.rs

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// check-fail
2+
//
3+
// regression test for #68295
4+
5+
struct Matrix<R, C, S>(R, C, S);
6+
7+
impl<R, C, S> Matrix<R, C, S> {
8+
fn into_owned(self) -> Matrix<R, C, Owned<R, C, ()>>
9+
where
10+
(): Allocator<R, C>,
11+
{
12+
unimplemented!()
13+
}
14+
}
15+
16+
impl<D, S> Matrix<D, D, S> {
17+
fn hermitian_part(&self) -> Matrix<D, D, Owned<D, D, ()>>
18+
where
19+
(): Allocator<D, D>,
20+
{
21+
unimplemented!()
22+
}
23+
}
24+
25+
trait Allocator<R, C> {
26+
type Buffer;
27+
}
28+
29+
trait Trait<R, C, A> {
30+
type Power;
31+
}
32+
33+
impl<R, C, A: Allocator<R, C>> Trait<R, C, A> for () {
34+
type Power = A::Buffer;
35+
}
36+
37+
type Owned<R, C, G> = <G as Trait<R, C, ()>>::Power;
38+
39+
fn crash<R, C>(input: Matrix<R, C, ()>) -> Matrix<R, C, u32>
40+
where
41+
(): Allocator<R, C>,
42+
{
43+
input.into_owned()
44+
//~^ ERROR mismatched types [E0308]
45+
}
46+
47+
fn main() {}

src/test/ui/traits/issue-68295.stderr

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-68295.rs:43:5
3+
|
4+
LL | fn crash<R, C>(input: Matrix<R, C, ()>) -> Matrix<R, C, u32>
5+
| ----------------- expected `Matrix<R, C, u32>` because of return type
6+
...
7+
LL | input.into_owned()
8+
| ^^^^^^^^^^^^^^^^^^ expected `u32`, found associated type
9+
|
10+
= note: expected struct `Matrix<_, _, u32>`
11+
found struct `Matrix<_, _, <() as Allocator<R, C>>::Buffer>`
12+
= help: consider constraining the associated type `<() as Allocator<R, C>>::Buffer` to `u32`
13+
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)