about summary refs log tree commit diff
path: root/tests/ui/traits/const-traits/super-traits-fail-3.rs
blob: d74bd34678407d8b04f09b8822ae8d29cf584470 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//@ compile-flags: -Znext-solver
#![cfg_attr(any(yyy, yyn, yny, ynn), feature(const_trait_impl))]

//@ revisions: yyy yyn yny ynn nyy nyn nny nnn
//@[yyy] check-pass
/// yyy: feature enabled, Foo is const, Bar is const
/// yyn: feature enabled, Foo is const, Bar is not const
/// yny: feature enabled, Foo is not const, Bar is const
/// ynn: feature enabled, Foo is not const, Bar is not const
/// nyy: feature not enabled, Foo is const, Bar is const
/// nyn: feature not enabled, Foo is const, Bar is not const
/// nny: feature not enabled, Foo is not const, Bar is const
/// nnn: feature not enabled, Foo is not const, Bar is not const

#[cfg_attr(any(yyy, yyn, nyy, nyn), const_trait)]
//[nyy,nyn]~^ ERROR: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future
trait Foo {
    fn a(&self);
}

#[cfg_attr(any(yyy, yny, nyy, nyn), const_trait)]
//[nyy,nyn]~^ ERROR: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future
trait Bar: [const] Foo {}
//[yny,ynn,nny,nnn]~^ ERROR: `[const]` can only be applied to `const` traits
//[yny,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `const` traits
//[yny,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `const` traits
//[yny]~^^^^ ERROR: `[const]` can only be applied to `const` traits
//[yny]~| ERROR: `[const]` can only be applied to `const` traits
//[yyn,ynn,nny,nnn]~^^^^^^ ERROR: `[const]` is not allowed here
//[nyy,nyn,nny,nnn]~^^^^^^^ ERROR: const trait impls are experimental

const fn foo<T: [const] Bar>(x: &T) {
    //[yyn,ynn,nny,nnn]~^ ERROR: `[const]` can only be applied to `const` traits
    //[yyn,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `const` traits
    //[nyy,nyn,nny,nnn]~^^^ ERROR: const trait impls are experimental
    x.a();
    //[yyn]~^ ERROR: the trait bound `T: [const] Foo` is not satisfied
    //[ynn,yny,nny,nnn]~^^ ERROR: cannot call non-const method `<T as Foo>::a` in constant functions
    //[nyy,nyn]~^^^ ERROR: cannot call conditionally-const method `<T as Foo>::a` in constant functions
}

fn main() {}