Skip to content

Commit 6fe2371

Browse files
committed
Auto merge of #38914 - est31:tidy-gate-tests, r=nikomatsakis
Make tidy check for lang gate tests Add gate tests to the checks that tidy performs. Excerpt from the commit message of the main commit: Require compile-fail tests for new lang features Its non trivial to test lang feature gates, and people forget to add such tests. So we extend the features lint of the tidy tool to ensure that all new lang features contain a new compile-fail test. Of course, one could drop this requirement and just grep all tests in run-pass for #![feature(abc)] and then run this test again, removing the mention, requiring that it fails. But this only tests for the existence of a compilation failure. Manual tests ensure that also the correct lines spawn the error, and also test the actual error message. For library features, it makes no sense to require such a test, as here code is used that is generic for all library features. The tidy lint extension now checks the compile-fail test suite for occurences of "gate-test-X" where X is a feature. Alternatively, it also accepts file names with the form "feature-gate-X.rs". If a lang feature is found that has no such check, we emit a tidy error. I've applied the markings to all tests I could find in the test suite. I left a small (20 elements) whitelist of features that right now have no gate test, or where I couldn't find one. Once this PR gets merged, I'd like to close issue #22820 and open a new one on suggestion of @nikomatsakis to track the removal of all elements from that whitelist (already have a draft). Writing such a small test can be a good opportunity for a first contribution, so I won't touch it (let others have the fun xD). cc @brson , @pnkfelix (they both discussed about this in the issue linked above).
2 parents b13cc05 + c6f99b4 commit 6fe2371

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+225
-20
lines changed

COMPILER_TESTS.md

Lines changed: 4 additions & 0 deletions

src/test/compile-fail/asm-gated.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// gate-test-asm
12+
1113
fn main() {
1214
unsafe {
1315
asm!(""); //~ ERROR inline assembly is not stable enough

src/test/compile-fail/asm-gated2.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// gate-test-asm
12+
1113
fn main() {
1214
unsafe {
1315
println!("{}", asm!("")); //~ ERROR inline assembly is not stable

src/test/compile-fail/attr-on-generic-formals-wo-feature-gate.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// using `rustc_attrs` feature. There is a separate compile-fail/ test
1717
// ensuring that the attribute feature-gating works in this context.)
1818

19+
// gate-test-generic_param_attrs
20+
1921
#![feature(rustc_attrs)]
2022
#![allow(dead_code)]
2123

src/test/compile-fail/check-static-values-constraints.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// Verifies all possible restrictions for statics values.
1212

13+
// gate-test-drop_types_in_const
14+
1315
#![feature(box_syntax)]
1416

1517
use std::marker;

src/test/compile-fail/concat_idents-gate.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// gate-test-concat_idents
12+
1113
const XY_1: i32 = 10;
1214

1315
fn main() {

src/test/compile-fail/concat_idents-gate2.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// gate-test-concat_idents
12+
1113
const XY_1: i32 = 10;
1214

1315
fn main() {

src/test/compile-fail/const-fn-stability.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// gate-test-const_fn
12+
1113
// Test use of const fn without feature gate.
1214

1315
const fn foo() -> usize { 0 } //~ ERROR const fn is unstable

src/test/compile-fail/feature-gate-abi.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// gate-test-intrinsics
12+
// gate-test-platform_intrinsics
13+
// gate-test-abi_vectorcall
14+
1115
// Functions
1216
extern "rust-intrinsic" fn f1() {} //~ ERROR intrinsics are subject to change
1317
extern "platform-intrinsic" fn f2() {} //~ ERROR platform intrinsics are experimental

src/test/compile-fail/feature-gate-advanced-slice-features.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// gate-test-advanced_slice_patterns
12+
1113
#![feature(slice_patterns)]
1214

1315
fn main() {

0 commit comments

Comments
 (0)