]> git.lizzy.rs Git - rust.git/blob - tests/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs
Rollup merge of #106625 - Swatinem:ref/cov6, r=nagisa
[rust.git] / tests / ui / rfc-2632-const-trait-impl / call-generic-method-nonconst.rs
1 #![feature(const_trait_impl)]
2
3 struct S;
4
5 #[const_trait]
6 trait Foo {
7     fn eq(&self, _: &Self) -> bool;
8 }
9
10 impl Foo for S {
11     fn eq(&self, _: &S) -> bool {
12         true
13     }
14 }
15
16 const fn equals_self<T: ~const Foo>(t: &T) -> bool {
17     true
18 }
19
20 // Calling `equals_self` with something that has a non-const impl should throw an error, despite
21 // it not using the impl.
22
23 pub const EQ: bool = equals_self(&S);
24 //~^ ERROR
25
26 fn main() {}