Skip to content

Commit 5830ca2

Browse files
committed
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^^
1 parent c115ec1 commit 5830ca2

File tree

68 files changed

+209
-49
lines changed

Some content is hidden

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

68 files changed

+209
-49
lines changed

compiler/rustc_abi/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![cfg_attr(feature = "nightly", feature(step_trait, rustc_attrs, min_specialization))]
2+
#![cfg_attr(all(not(bootstrap), feature = "nightly"), allow(internal_features))]
23

34
use std::fmt;
45
#[cfg(feature = "nightly")]

compiler/rustc_arena/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#![deny(unsafe_op_in_unsafe_fn)]
2424
#![deny(rustc::untranslatable_diagnostic)]
2525
#![deny(rustc::diagnostic_outside_of_impl)]
26+
#![cfg_attr(not(bootstrap), allow(internal_features))]
2627
#![allow(clippy::mut_from_ref)] // Arena allocators are one of the places where this pattern is fine.
2728

2829
use smallvec::SmallVec;

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#![feature(trusted_step)]
1212
#![feature(try_blocks)]
1313
#![recursion_limit = "256"]
14+
#![cfg_attr(not(bootstrap), allow(internal_features))]
1415

1516
#[macro_use]
1617
extern crate rustc_middle;

compiler/rustc_data_structures/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#![allow(rustc::potential_query_instability)]
3838
#![deny(rustc::untranslatable_diagnostic)]
3939
#![deny(rustc::diagnostic_outside_of_impl)]
40+
#![cfg_attr(not(bootstrap), allow(internal_features))]
4041
#![deny(unsafe_op_in_unsafe_fn)]
4142

4243
#[macro_use]

compiler/rustc_error_codes/src/error_codes/E0092.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Erroneous code example:
44

55
```compile_fail,E0092
66
#![feature(intrinsics)]
7+
#![allow(internal_features)]
78
89
extern "rust-intrinsic" {
910
fn atomic_foo(); // error: unrecognized atomic operation
@@ -17,6 +18,7 @@ functions are defined in `compiler/rustc_codegen_llvm/src/intrinsic.rs` and in
1718

1819
```
1920
#![feature(intrinsics)]
21+
#![allow(internal_features)]
2022
2123
extern "rust-intrinsic" {
2224
fn atomic_fence_seqcst(); // ok!

compiler/rustc_error_codes/src/error_codes/E0093.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Erroneous code example:
44

55
```compile_fail,E0093
66
#![feature(intrinsics)]
7+
#![allow(internal_features)]
78
89
extern "rust-intrinsic" {
910
fn foo(); // error: unrecognized intrinsic function: `foo`
@@ -22,6 +23,7 @@ functions are defined in `compiler/rustc_codegen_llvm/src/intrinsic.rs` and in
2223

2324
```
2425
#![feature(intrinsics)]
26+
#![allow(internal_features)]
2527
2628
extern "rust-intrinsic" {
2729
fn atomic_fence_seqcst(); // ok!

compiler/rustc_error_codes/src/error_codes/E0094.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Erroneous code example:
44

55
```compile_fail,E0094
66
#![feature(intrinsics)]
7+
#![allow(internal_features)]
78
89
extern "rust-intrinsic" {
910
#[rustc_safe_intrinsic]
@@ -18,6 +19,7 @@ Example:
1819

1920
```
2021
#![feature(intrinsics)]
22+
#![allow(internal_features)]
2123
2224
extern "rust-intrinsic" {
2325
#[rustc_safe_intrinsic]

compiler/rustc_error_codes/src/error_codes/E0208.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Erroneous code example:
88
```compile_fail
99
// NOTE: this feature is perma-unstable and should *only* be used for
1010
// testing purposes.
11+
#![allow(internal_features)]
1112
#![feature(rustc_attrs)]
1213
1314
#[rustc_variance]

compiler/rustc_error_codes/src/error_codes/E0211.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ used. Erroneous code examples:
55

66
```compile_fail
77
#![feature(intrinsics)]
8+
#![allow(internal_features)]
89
910
extern "rust-intrinsic" {
1011
#[rustc_safe_intrinsic]
@@ -41,6 +42,7 @@ For the first code example, please check the function definition. Example:
4142

4243
```
4344
#![feature(intrinsics)]
45+
#![allow(internal_features)]
4446
4547
extern "rust-intrinsic" {
4648
#[rustc_safe_intrinsic]

compiler/rustc_error_codes/src/error_codes/E0230.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ compiled:
55

66
```compile_fail,E0230
77
#![feature(rustc_attrs)]
8+
#![allow(internal_features)]
89
910
#[rustc_on_unimplemented = "error on `{Self}` with params `<{A},{B}>`"] // error
1011
trait BadAnnotation<A> {}

0 commit comments

Comments
 (0)