Skip to content

Commit

Permalink
Add ui test
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Aug 17, 2021
1 parent b5afa68 commit 6bd2ecb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/test/ui/rfc-2632-const-trait-impl/std-impl-gate.rs
Original file line number Diff line number Diff line change
@@ -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());
}
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit 6bd2ecb

Please sign in to comment.