Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some tests for associated-type-bounds issues #81485

Merged
merged 1 commit into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/test/ui/associated-types/issue-38917.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// check-pass

use std::borrow::Borrow;

trait TNode: Sized {
type ConcreteElement: TElement<ConcreteNode = Self>;
}

trait TElement: Sized {
type ConcreteNode: TNode<ConcreteElement = Self>;
}

trait DomTraversal<N: TNode> {
type BorrowElement: Borrow<N::ConcreteElement>;
}

#[allow(dead_code)]
fn recalc_style_at<E, D>()
where
E: TElement,
D: DomTraversal<E::ConcreteNode>,
{
}

fn main() {}
14 changes: 14 additions & 0 deletions src/test/ui/associated-types/issue-40093.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// check-pass

pub trait Test {
type Item;
type Bundle: From<Self::Item>;
}

fn fails<T>()
where
T: Test<Item = String>,
{
}

fn main() {}
10 changes: 10 additions & 0 deletions src/test/ui/associated-types/issue-43475.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// check-pass

trait Foo { type FooT: Foo; }
impl Foo for () { type FooT = (); }
trait Bar<T: Foo> { type BarT: Bar<T::FooT>; }
impl Bar<()> for () { type BarT = (); }

#[allow(dead_code)]
fn test<C: Bar<()>>() { }
fn main() { }
24 changes: 24 additions & 0 deletions src/test/ui/associated-types/issue-63591.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// check-pass

#![feature(associated_type_bounds)]
#![feature(type_alias_impl_trait)]

fn main() {}

trait Bar { type Assoc; }

trait Thing {
type Out;
fn func() -> Self::Out;
}

struct AssocIsCopy;
impl Bar for AssocIsCopy { type Assoc = u8; }

impl Thing for AssocIsCopy {
type Out = impl Bar<Assoc: Copy>;

fn func() -> Self::Out {
AssocIsCopy
}
}