about summary refs log tree commit diff
path: root/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.rs
blob: 658132441c26551f355217e4d3da592de4831530 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#![feature(const_trait_impl)]
//@ edition: 2021

const trait Trait {}

fn main() {
    let _: &dyn const Trait; //~ ERROR const trait bounds are not allowed in trait object types
    let _: &dyn [const] Trait; //~ ERROR `[const]` is not allowed here
}

// Regression test for issue #119525.
trait NonConst {}
const fn handle(_: &dyn const NonConst) {}
//~^ ERROR const trait bounds are not allowed in trait object types
//~| ERROR `const` can only be applied to `const` traits
const fn take(_: &dyn [const] NonConst) {}
//~^ ERROR `[const]` is not allowed here
//~| ERROR `[const]` can only be applied to `const` traits