Skip to content

Commit c5c650d

Browse files
committed
Split out termination_trait_test feature gate
1 parent c2f4744 commit c5c650d

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

src/libsyntax/feature_gate.rs

+3
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ declare_features! (
432432
// Termination trait in main (RFC 1937)
433433
(active, termination_trait, "1.24.0", Some(43301), None),
434434

435+
// Termination trait in tests (RFC 1937)
436+
(active, termination_trait_test, "1.24.0", Some(48854), None),
437+
435438
// Allows use of the :lifetime macro fragment specifier
436439
(active, macro_lifetime_matcher, "1.24.0", Some(46895), None),
437440

src/libsyntax/test.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ fn is_test_fn(cx: &TestCtxt, i: &ast::Item) -> bool {
332332
ast::ItemKind::Fn(ref decl, _, _, _, ref generics, _) => {
333333
// If the termination trait is active, the compiler will check that the output
334334
// type implements the `Termination` trait as `libtest` enforces that.
335-
let output_matches = if cx.features.termination_trait {
335+
let output_matches = if cx.features.termination_trait_test {
336336
true
337337
} else {
338338
let no_output = match decl.output {
@@ -359,7 +359,7 @@ fn is_test_fn(cx: &TestCtxt, i: &ast::Item) -> bool {
359359
match has_test_signature(cx, i) {
360360
Yes => true,
361361
No => {
362-
if cx.features.termination_trait {
362+
if cx.features.termination_trait_test {
363363
diag.span_err(i.span, "functions used as tests can not have any arguments");
364364
} else {
365365
diag.span_err(i.span, "functions used as tests must have signature fn() -> ()");
@@ -388,7 +388,7 @@ fn is_bench_fn(cx: &TestCtxt, i: &ast::Item) -> bool {
388388

389389
// If the termination trait is active, the compiler will check that the output
390390
// type implements the `Termination` trait as `libtest` enforces that.
391-
let output_matches = if cx.features.termination_trait {
391+
let output_matches = if cx.features.termination_trait_test {
392392
true
393393
} else {
394394
let no_output = match decl.output {
@@ -416,7 +416,7 @@ fn is_bench_fn(cx: &TestCtxt, i: &ast::Item) -> bool {
416416
if has_bench_attr && !has_bench_signature {
417417
let diag = cx.span_diagnostic;
418418

419-
if cx.features.termination_trait {
419+
if cx.features.termination_trait_test {
420420
diag.span_err(i.span, "functions used as benches must have signature \
421421
`fn(&mut Bencher) -> impl Termination`");
422422
} else {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2017 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+
// compile-flags: --test
12+
13+
fn main() {}
14+
15+
#[cfg(test)]
16+
mod tests {
17+
#[test]
18+
fn it_works() -> Result<(), ()> {
19+
//~^ ERROR functions used as tests must have signature fn() -> ()
20+
Ok(())
21+
}
22+
}

src/test/run-pass/rfc-1937-termination-trait/termination-trait-in-test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// compile-flags: --test
1212

13-
#![feature(termination_trait)]
13+
#![feature(termination_trait_test)]
1414
#![feature(test)]
1515

1616
extern crate test;

0 commit comments

Comments
 (0)