Add ui test

This commit is contained in:
Deadbeef 2021-08-16 15:55:35 +00:00
parent b5afa6807b
commit 6bd2ecba72
No known key found for this signature in database
GPG Key ID: 027DF9338862ADDD
2 changed files with 30 additions and 0 deletions

View 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());
}

View File

@ -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`.