2024-06-25 07:52:44 +00:00
|
|
|
#![feature(const_trait_impl)]
|
2023-12-18 17:55:55 +01:00
|
|
|
//@ edition: 2021
|
|
|
|
|
|
2025-07-13 16:49:19 +08:00
|
|
|
const trait Trait {}
|
2023-12-18 17:55:55 +01:00
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
let _: &dyn const Trait; //~ ERROR const trait bounds are not allowed in trait object types
|
2025-03-11 12:08:45 +00:00
|
|
|
let _: &dyn [const] Trait; //~ ERROR `[const]` is not allowed here
|
2023-12-18 17:55:55 +01:00
|
|
|
}
|
2024-01-03 09:24:42 +01:00
|
|
|
|
|
|
|
|
// 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
|
2025-03-11 12:08:45 +00:00
|
|
|
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
|