Files
rust/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
620 B
Rust
Raw Normal View History

#![feature(const_trait_impl)]
//@ edition: 2021
2025-07-13 16:49:19 +08:00
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
2025-07-13 16:49:19 +08:00
//~| ERROR `const` can only be applied to `const` traits
const fn take(_: &dyn [const] NonConst) {}
//~^ ERROR `[const]` is not allowed here
2025-07-13 16:49:19 +08:00
//~| ERROR `[const]` can only be applied to `const` traits