Skip to content

Commit b7772e6

Browse files
committed
convert-id: tests for const gating.
1 parent f84ec02 commit b7772e6

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

Diff for: src/test/ui/rfc-2306/convert-id-const-no-gate.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// This test should fail since identity is not stable as a const fn yet.
12+
13+
#![feature(convert_id)]
14+
15+
fn main() {
16+
const _FOO: u8 = ::std::convert::identity(42u8);
17+
}

Diff for: src/test/ui/rfc-2306/convert-id-const-no-gate.stderr

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: `std::convert::identity` is not yet stable as a const fn
2+
--> $DIR/convert-id-const-no-gate.rs:16:22
3+
|
4+
LL | const _FOO: u8 = ::std::convert::identity(42u8);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: in Nightly builds, add `#![feature(const_convert_id)]` to the crate attributes to enable
8+
9+
error: aborting due to previous error
10+

Diff for: src/test/ui/rfc-2306/convert-id-const-with-gate.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// This test should pass since we've opted into 'identity' as an
12+
// unstable const fn.
13+
14+
// compile-pass
15+
16+
#![feature(convert_id, const_convert_id)]
17+
18+
fn main() {
19+
const _FOO: u8 = ::std::convert::identity(42u8);
20+
}

0 commit comments

Comments
 (0)