Add internal_features
lint
It lints against features that are inteded to be internal to the compiler and standard library. Implements MCP #596. We allow `internal_features` in the standard library and compiler as those use many features and this _is_ the standard library from the "internal to the compiler and standard library" after all. Marking some features as internal wasn't exactly the most scientific approach, I just marked some mostly obvious features. While there is a categorization in the macro, it's not very well upheld (should probably be fixed in another PR). We always pass `-Ainternal_features` in the testsuite About 400 UI tests and several other tests use internal features. Instead of throwing the attribute on each one, just always allow them. There's nothing wrong with testing internal features^^
This commit is contained in:
parent
c115ec11d2
commit
5830ca216d
68 changed files with 209 additions and 49 deletions
|
@ -4,6 +4,7 @@ Erroneous code example:
|
|||
|
||||
```compile_fail,E0092
|
||||
#![feature(intrinsics)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
fn atomic_foo(); // error: unrecognized atomic operation
|
||||
|
@ -17,6 +18,7 @@ functions are defined in `compiler/rustc_codegen_llvm/src/intrinsic.rs` and in
|
|||
|
||||
```
|
||||
#![feature(intrinsics)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
fn atomic_fence_seqcst(); // ok!
|
||||
|
|
|
@ -4,6 +4,7 @@ Erroneous code example:
|
|||
|
||||
```compile_fail,E0093
|
||||
#![feature(intrinsics)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
fn foo(); // error: unrecognized intrinsic function: `foo`
|
||||
|
@ -22,6 +23,7 @@ functions are defined in `compiler/rustc_codegen_llvm/src/intrinsic.rs` and in
|
|||
|
||||
```
|
||||
#![feature(intrinsics)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
fn atomic_fence_seqcst(); // ok!
|
||||
|
|
|
@ -4,6 +4,7 @@ Erroneous code example:
|
|||
|
||||
```compile_fail,E0094
|
||||
#![feature(intrinsics)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
#[rustc_safe_intrinsic]
|
||||
|
@ -18,6 +19,7 @@ Example:
|
|||
|
||||
```
|
||||
#![feature(intrinsics)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
#[rustc_safe_intrinsic]
|
||||
|
|
|
@ -8,6 +8,7 @@ Erroneous code example:
|
|||
```compile_fail
|
||||
// NOTE: this feature is perma-unstable and should *only* be used for
|
||||
// testing purposes.
|
||||
#![allow(internal_features)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_variance]
|
||||
|
|
|
@ -5,6 +5,7 @@ used. Erroneous code examples:
|
|||
|
||||
```compile_fail
|
||||
#![feature(intrinsics)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
#[rustc_safe_intrinsic]
|
||||
|
@ -41,6 +42,7 @@ For the first code example, please check the function definition. Example:
|
|||
|
||||
```
|
||||
#![feature(intrinsics)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
#[rustc_safe_intrinsic]
|
||||
|
|
|
@ -5,6 +5,7 @@ compiled:
|
|||
|
||||
```compile_fail,E0230
|
||||
#![feature(rustc_attrs)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
#[rustc_on_unimplemented = "error on `{Self}` with params `<{A},{B}>`"] // error
|
||||
trait BadAnnotation<A> {}
|
||||
|
|
|
@ -5,6 +5,7 @@ compiled:
|
|||
|
||||
```compile_fail,E0231
|
||||
#![feature(rustc_attrs)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
#[rustc_on_unimplemented = "error on `{Self}` with params `<{A},{}>`"] // error!
|
||||
trait BadAnnotation<A> {}
|
||||
|
|
|
@ -5,6 +5,7 @@ compiled:
|
|||
|
||||
```compile_fail,E0232
|
||||
#![feature(rustc_attrs)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
#[rustc_on_unimplemented(lorem="")] // error!
|
||||
trait BadAnnotation {}
|
||||
|
|
|
@ -4,6 +4,7 @@ Erroneous code example:
|
|||
|
||||
```compile_fail,E0264
|
||||
#![feature(lang_items)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
extern "C" {
|
||||
#[lang = "cake"] // error: unknown external lang item: `cake`
|
||||
|
@ -16,6 +17,7 @@ A list of available external lang items is available in
|
|||
|
||||
```
|
||||
#![feature(lang_items)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
extern "C" {
|
||||
#[lang = "panic_impl"] // ok!
|
||||
|
|
|
@ -4,6 +4,7 @@ Erroneous code example:
|
|||
|
||||
```compile_fail,E0539
|
||||
#![feature(staged_api)]
|
||||
#![allow(internal_features)]
|
||||
#![stable(since = "1.0.0", feature = "test")]
|
||||
|
||||
#[deprecated(note)] // error!
|
||||
|
@ -28,6 +29,7 @@ To fix these issues you need to give required key-value pairs.
|
|||
|
||||
```
|
||||
#![feature(staged_api)]
|
||||
#![allow(internal_features)]
|
||||
#![stable(since = "1.0.0", feature = "test")]
|
||||
|
||||
#[deprecated(since = "1.39.0", note = "reason")] // ok!
|
||||
|
|
|
@ -4,6 +4,7 @@ Erroneous code example:
|
|||
|
||||
```compile_fail,E0542
|
||||
#![feature(staged_api)]
|
||||
#![allow(internal_features)]
|
||||
#![stable(since = "1.0.0", feature = "test")]
|
||||
|
||||
#[stable(feature = "_stable_fn")] // invalid
|
||||
|
@ -23,6 +24,7 @@ To fix this issue, you need to provide the `since` field. Example:
|
|||
|
||||
```
|
||||
#![feature(staged_api)]
|
||||
#![allow(internal_features)]
|
||||
#![stable(since = "1.0.0", feature = "test")]
|
||||
|
||||
#[stable(feature = "_stable_fn", since = "1.0.0")] // ok!
|
||||
|
|
|
@ -4,6 +4,7 @@ Erroneous code example:
|
|||
|
||||
```compile_fail,E0543
|
||||
#![feature(staged_api)]
|
||||
#![allow(internal_features)]
|
||||
#![stable(since = "1.0.0", feature = "test")]
|
||||
|
||||
#[stable(since = "0.1.0", feature = "_deprecated_fn")]
|
||||
|
@ -17,6 +18,7 @@ To fix this issue, you need to provide the `note` field. Example:
|
|||
|
||||
```
|
||||
#![feature(staged_api)]
|
||||
#![allow(internal_features)]
|
||||
#![stable(since = "1.0.0", feature = "test")]
|
||||
|
||||
#[stable(since = "0.1.0", feature = "_deprecated_fn")]
|
||||
|
|
|
@ -4,6 +4,7 @@ Erroneous code example:
|
|||
|
||||
```compile_fail,E0544
|
||||
#![feature(staged_api)]
|
||||
#![allow(internal_features)]
|
||||
#![stable(since = "1.0.0", feature = "rust1")]
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
@ -15,6 +16,7 @@ To fix this issue, ensure that each item has at most one stability attribute.
|
|||
|
||||
```
|
||||
#![feature(staged_api)]
|
||||
#![allow(internal_features)]
|
||||
#![stable(since = "1.0.0", feature = "rust1")]
|
||||
|
||||
#[stable(feature = "test", since = "2.0.0")] // ok!
|
||||
|
|
|
@ -4,6 +4,7 @@ Erroneous code example:
|
|||
|
||||
```compile_fail,E0545
|
||||
#![feature(staged_api)]
|
||||
#![allow(internal_features)]
|
||||
#![stable(since = "1.0.0", feature = "test")]
|
||||
|
||||
#[unstable(feature = "_unstable_fn", issue = "0")] // invalid
|
||||
|
@ -18,6 +19,7 @@ Example:
|
|||
|
||||
```
|
||||
#![feature(staged_api)]
|
||||
#![allow(internal_features)]
|
||||
#![stable(since = "1.0.0", feature = "test")]
|
||||
|
||||
#[unstable(feature = "_unstable_fn", issue = "none")] // ok!
|
||||
|
|
|
@ -4,6 +4,7 @@ Erroneous code example:
|
|||
|
||||
```compile_fail,E0546
|
||||
#![feature(staged_api)]
|
||||
#![allow(internal_features)]
|
||||
#![stable(since = "1.0.0", feature = "test")]
|
||||
|
||||
#[unstable(issue = "none")] // invalid
|
||||
|
@ -17,6 +18,7 @@ To fix this issue, you need to provide the `feature` field. Example:
|
|||
|
||||
```
|
||||
#![feature(staged_api)]
|
||||
#![allow(internal_features)]
|
||||
#![stable(since = "1.0.0", feature = "test")]
|
||||
|
||||
#[unstable(feature = "unstable_fn", issue = "none")] // ok!
|
||||
|
|
|
@ -4,6 +4,7 @@ Erroneous code example:
|
|||
|
||||
```compile_fail,E0547
|
||||
#![feature(staged_api)]
|
||||
#![allow(internal_features)]
|
||||
#![stable(since = "1.0.0", feature = "test")]
|
||||
|
||||
#[unstable(feature = "_unstable_fn")] // invalid
|
||||
|
@ -17,6 +18,7 @@ To fix this issue, you need to provide the `issue` field. Example:
|
|||
|
||||
```
|
||||
#![feature(staged_api)]
|
||||
#![allow(internal_features)]
|
||||
#![stable(since = "1.0.0", feature = "test")]
|
||||
|
||||
#[unstable(feature = "_unstable_fn", issue = "none")] // ok!
|
||||
|
|
|
@ -5,6 +5,7 @@ Erroneous code example:
|
|||
|
||||
```compile_fail,E0549
|
||||
#![feature(staged_api)]
|
||||
#![allow(internal_features)]
|
||||
#![stable(since = "1.0.0", feature = "test")]
|
||||
|
||||
#[deprecated(
|
||||
|
@ -19,6 +20,7 @@ Example:
|
|||
|
||||
```
|
||||
#![feature(staged_api)]
|
||||
#![allow(internal_features)]
|
||||
#![stable(since = "1.0.0", feature = "test")]
|
||||
|
||||
#[stable(since = "1.0.0", feature = "test")]
|
||||
|
|
|
@ -4,6 +4,8 @@ Erroneous code example:
|
|||
|
||||
```compile_fail,E0622
|
||||
#![feature(intrinsics)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
pub static breakpoint: fn(); // error: intrinsic must be a function
|
||||
}
|
||||
|
@ -17,6 +19,8 @@ error, just declare a function. Example:
|
|||
|
||||
```no_run
|
||||
#![feature(intrinsics)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
pub fn breakpoint(); // ok!
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ Erroneous code example:
|
|||
```compile_fail,E0773
|
||||
#![feature(decl_macro)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
#[rustc_builtin_macro]
|
||||
pub macro test($item:item) {
|
||||
|
@ -24,6 +25,7 @@ To fix the issue, remove the duplicate declaration:
|
|||
```
|
||||
#![feature(decl_macro)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
#[rustc_builtin_macro]
|
||||
pub macro test($item:item) {
|
||||
|
|
|
@ -10,6 +10,7 @@ Erroneous code example:
|
|||
// used outside of the compiler and standard library.
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(staged_api)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
#![unstable(feature = "foo_module", reason = "...", issue = "123")]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue