Skip to content

Commit

Permalink
Add some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-schievink committed Nov 22, 2020
1 parent e69fcea commit cb40684
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/test/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//! Basic test for calling methods on generic type parameters in `const fn`.
// check-pass

#![feature(const_fn)]
#![feature(const_trait_impl)]
#![allow(incomplete_features)]

struct S;

impl const PartialEq for S {
fn eq(&self, _: &S) -> bool {
true
}
}

const fn equals_self<T: PartialEq>(t: &T) -> bool {
*t == *t
}

const fn equals_self_wrapper<T: PartialEq>(t: &T) -> bool {
equals_self(t)
}

pub const EQ: bool = equals_self_wrapper(&S);

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// check-pass

#![feature(const_fn)]
#![feature(const_trait_impl)]
#![feature(const_trait_bound_opt_out)]
#![allow(incomplete_features)]

struct S;

impl const PartialEq for S {
fn eq(&self, _: &S) -> bool {
true
}
}

// This duplicate bound should not result in ambiguities. It should be equivalent to a single const
// bound.
const fn equals_self<T: PartialEq + ?const PartialEq>(t: &T) -> bool {
*t == *t
}

pub const EQ: bool = equals_self(&S);

fn main() {}

0 comments on commit cb40684

Please sign in to comment.