Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make tidy check for lang gate tests #38914

Merged
merged 9 commits into from
Jan 14, 2017
4 changes: 4 additions & 0 deletions COMPILER_TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ whole, instead of just a few lines inside the test.
* `should-fail` indicates that the test should fail; used for "meta testing",
where we test the compiletest program itself to check that it will generate
errors in appropriate scenarios. This header is ignored for pretty-printer tests.
* `gate-test-X` where `X` is a feature marks the test as "gate test" for feature X.
Such tests are supposed to ensure that the compiler errors when usage of a gated
feature is attempted without the proper `#![feature(X)]` tag.
Each unstable lang feature is required to have a gate test.

## Revisions

Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/asm-gated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-asm

fn main() {
unsafe {
asm!(""); //~ ERROR inline assembly is not stable enough
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/asm-gated2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-asm

fn main() {
unsafe {
println!("{}", asm!("")); //~ ERROR inline assembly is not stable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// using `rustc_attrs` feature. There is a separate compile-fail/ test
// ensuring that the attribute feature-gating works in this context.)

// gate-test-generic_param_attrs

#![feature(rustc_attrs)]
#![allow(dead_code)]

Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/check-static-values-constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

// Verifies all possible restrictions for statics values.

// gate-test-drop_types_in_const

#![feature(box_syntax)]

use std::marker;
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/concat_idents-gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-concat_idents

const XY_1: i32 = 10;

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/concat_idents-gate2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-concat_idents

const XY_1: i32 = 10;

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/const-fn-stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-const_fn

// Test use of const fn without feature gate.

const fn foo() -> usize { 0 } //~ ERROR const fn is unstable
Expand Down
4 changes: 4 additions & 0 deletions src/test/compile-fail/feature-gate-abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-intrinsics
// gate-test-platform_intrinsics
// gate-test-abi_vectorcall

// Functions
extern "rust-intrinsic" fn f1() {} //~ ERROR intrinsics are subject to change
extern "platform-intrinsic" fn f2() {} //~ ERROR platform intrinsics are experimental
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/feature-gate-advanced-slice-features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-advanced_slice_patterns

#![feature(slice_patterns)]

fn main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-allow_internal_unstable

macro_rules! bar {
() => {
// more layers don't help:
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/feature-gate-assoc-type-defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-associated_type_defaults

trait Foo {
type Bar = u8; //~ ERROR associated type defaults are unstable
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/feature-gate-box-expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-box_syntax

// Check that `box EXPR` is feature-gated.
//
// See also feature-gate-placement-expr.rs
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/feature-gate-box-pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-box_patterns

fn main() {
let box x = Box::new('c'); //~ ERROR box pattern syntax is experimental
println!("x: {}", x);
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/feature-gate-dropck-ugeh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-dropck_parametricity

// Ensure that attempts to use the unsafe attribute are feature-gated.

// Example adapted from RFC 1238 text (just left out the feature gate).
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/feature-gate-may-dangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-dropck_eyepatch

// Check that `may_dangle` is rejected if `dropck_eyepatch` feature gate is absent.

#![feature(generic_param_attrs)]
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/feature-gate-placement-expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-placement_in_syntax

// Check that `in PLACE { EXPR }` is feature-gated.
//
// See also feature-gate-box-expr.rs
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/gated-associated_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-associated_consts

trait MyTrait {
const C: bool;
//~^ associated constants are experimental
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/gated-attr-literals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

// Check that literals in attributes don't parse without the feature gate.

// gate-test-attr_literals

#![feature(rustc_attrs)]
#![allow(dead_code)]
#![allow(unused_variables)]
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/gated-box-syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

// Test that the use of the box syntax is gated by `box_syntax` feature gate.

// gate-test-box_syntax

fn main() {
let x = box 3;
//~^ ERROR box expression syntax is experimental; you can call `Box::new` instead.
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/gated-concat_idents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-concat_idents

fn main() {
concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough
}
2 changes: 2 additions & 0 deletions src/test/compile-fail/gated-link-args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// Test that `#[link_args]` attribute is gated by `link_args`
// feature gate.

// gate-test-link_args

#[link_args = "aFdEfSeVEEE"]
extern {}
//~^ ERROR the `link_args` attribute is not portable across platforms
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/gated-link-llvm-intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-link_llvm_intrinsics

extern {
#[link_name = "llvm.sqrt.f32"]
fn sqrt(x: f32) -> f32;
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/gated-naked_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-naked_functions

#[naked]
//~^ the `#[naked]` attribute is an experimental feature
fn naked() {}
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/gated-no-core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-no_core

#![no_core] //~ ERROR no_core is experimental

fn main() {}
2 changes: 2 additions & 0 deletions src/test/compile-fail/gated-non-ascii-idents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-non_ascii_idents

extern crate core as bäz; //~ ERROR non-ascii idents

use föö::bar; //~ ERROR non-ascii idents
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/gated-plugin_registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-plugin_registrar

// Test that `#[plugin_registrar]` attribute is gated by `plugin_registrar`
// feature gate.

Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/gated-target_feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-target_feature

#[target_feature = "+sse2"]
//~^ the `#[target_feature]` attribute is an experimental feature
fn foo() {}
2 changes: 2 additions & 0 deletions src/test/compile-fail/gated-thread-local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-thread_local

// Test that `#[thread_local]` attribute is gated by `thread_local`
// feature gate.
//
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/gated-trace_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-trace_macros

fn main() {
trace_macros!(true); //~ ERROR: `trace_macros` is not stable
Expand Down
3 changes: 3 additions & 0 deletions src/test/compile-fail/i128-feature-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-i128_type

fn test1() -> i128 { //~ ERROR 128-bit type is unstable
0
}
Expand Down
3 changes: 3 additions & 0 deletions src/test/compile-fail/i128-feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-i128_type

fn test2() {
0i128; //~ ERROR 128-bit integers are not stable
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/impl-trait/feature-gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-conservative_impl_trait

fn foo() -> impl Fn() { || {} }
//~^ ERROR `impl Trait` is experimental

Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/link-cfg-gated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-link_cfg

#[link(name = "foo", cfg(foo))]
//~^ ERROR: is feature gated
extern {}
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/linkage1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-linkage

extern {
#[linkage = "extern_weak"] static foo: isize;
//~^ ERROR: the `linkage` attribute is experimental and not portable
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/log-syntax-gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-log_syntax

fn main() {
log_syntax!() //~ ERROR `log_syntax!` is not stable enough
}
2 changes: 2 additions & 0 deletions src/test/compile-fail/log-syntax-gate2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-log_syntax

fn main() {
println!("{}", log_syntax!()); //~ ERROR `log_syntax!` is not stable
}
2 changes: 2 additions & 0 deletions src/test/compile-fail/never-disabled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

// Test that ! errors when used in illegal positions with feature(never_type) disabled

// gate-test-never_type

trait Foo {
type Wub;
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/no-core-gated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-no_core

#![no_core] //~ ERROR no_core is experimental

fn main() {}
2 changes: 2 additions & 0 deletions src/test/compile-fail/numeric-fields-feature-gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-relaxed_adts

struct S(u8);

fn main() {
Expand Down
3 changes: 3 additions & 0 deletions src/test/compile-fail/panic-runtime/needs-gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-needs_panic_runtime
// gate-test-panic_runtime

#![panic_runtime] //~ ERROR: is an experimental feature
#![needs_panic_runtime] //~ ERROR: is an experimental feature

Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/privacy/restricted/feature-gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-pub_restricted

pub(crate) //~ ERROR experimental
mod foo {}

Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/rfc1445/feature-gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

// revisions: with_gate no_gate

// gate-test-structural_match

#![allow(dead_code)]
#![deny(future_incompatible)]
#![feature(rustc_attrs)]
Expand Down
Loading