mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Add ui test
This commit is contained in:
parent
b5afa6807b
commit
6bd2ecba72
21
src/test/ui/rfc-2632-const-trait-impl/std-impl-gate.rs
Normal file
21
src/test/ui/rfc-2632-const-trait-impl/std-impl-gate.rs
Normal file
@ -0,0 +1,21 @@
|
||||
// This tests feature gates for const impls in the standard library.
|
||||
|
||||
// revisions: stock gated
|
||||
//[gated] run-pass
|
||||
|
||||
#![cfg_attr(gated, feature(const_trait_impl, const_default_impls))]
|
||||
|
||||
fn non_const_context() -> Vec<usize> {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
const fn const_context() -> Vec<usize> {
|
||||
Default::default()
|
||||
//[stock]~^ ERROR calls in constant functions are limited
|
||||
}
|
||||
|
||||
fn main() {
|
||||
const VAL: Vec<usize> = const_context();
|
||||
|
||||
assert_eq!(VAL, non_const_context());
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||
--> $DIR/std-impl-gate.rs:13:5
|
||||
|
|
||||
LL | Default::default()
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0015`.
|
Loading…
Reference in New Issue
Block a user