Add some more tests

This commit is contained in:
Jonas Schievink 2020-11-22 15:51:05 +01:00
parent e69fcea609
commit cb406848ec
2 changed files with 51 additions and 0 deletions

View file

@ -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() {}

View file

@ -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() {}