Skip to content

Commit 6bd2ecb

Browse files
committed
Add ui test
1 parent b5afa68 commit 6bd2ecb

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// This tests feature gates for const impls in the standard library.
2+
3+
// revisions: stock gated
4+
//[gated] run-pass
5+
6+
#![cfg_attr(gated, feature(const_trait_impl, const_default_impls))]
7+
8+
fn non_const_context() -> Vec<usize> {
9+
Default::default()
10+
}
11+
12+
const fn const_context() -> Vec<usize> {
13+
Default::default()
14+
//[stock]~^ ERROR calls in constant functions are limited
15+
}
16+
17+
fn main() {
18+
const VAL: Vec<usize> = const_context();
19+
20+
assert_eq!(VAL, non_const_context());
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
2+
--> $DIR/std-impl-gate.rs:13:5
3+
|
4+
LL | Default::default()
5+
| ^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0015`.

0 commit comments

Comments
 (0)