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

+1
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

+1
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

+1
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

+1
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

+2
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

+2
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

+2
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

+1
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

+2
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

+1
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> {}

compiler/rustc_error_codes/src/error_codes/E0231.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ compiled:
55

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

compiler/rustc_error_codes/src/error_codes/E0232.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ compiled:
55

66
```compile_fail,E0232
77
#![feature(rustc_attrs)]
8+
#![allow(internal_features)]
89
910
#[rustc_on_unimplemented(lorem="")] // error!
1011
trait BadAnnotation {}

compiler/rustc_error_codes/src/error_codes/E0264.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Erroneous code example:
44

55
```compile_fail,E0264
66
#![feature(lang_items)]
7+
#![allow(internal_features)]
78
89
extern "C" {
910
#[lang = "cake"] // error: unknown external lang item: `cake`
@@ -16,6 +17,7 @@ A list of available external lang items is available in
1617

1718
```
1819
#![feature(lang_items)]
20+
#![allow(internal_features)]
1921
2022
extern "C" {
2123
#[lang = "panic_impl"] // ok!

compiler/rustc_error_codes/src/error_codes/E0539.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Erroneous code example:
44

55
```compile_fail,E0539
66
#![feature(staged_api)]
7+
#![allow(internal_features)]
78
#![stable(since = "1.0.0", feature = "test")]
89
910
#[deprecated(note)] // error!
@@ -28,6 +29,7 @@ To fix these issues you need to give required key-value pairs.
2829

2930
```
3031
#![feature(staged_api)]
32+
#![allow(internal_features)]
3133
#![stable(since = "1.0.0", feature = "test")]
3234
3335
#[deprecated(since = "1.39.0", note = "reason")] // ok!

compiler/rustc_error_codes/src/error_codes/E0542.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Erroneous code example:
44

55
```compile_fail,E0542
66
#![feature(staged_api)]
7+
#![allow(internal_features)]
78
#![stable(since = "1.0.0", feature = "test")]
89
910
#[stable(feature = "_stable_fn")] // invalid
@@ -23,6 +24,7 @@ To fix this issue, you need to provide the `since` field. Example:
2324

2425
```
2526
#![feature(staged_api)]
27+
#![allow(internal_features)]
2628
#![stable(since = "1.0.0", feature = "test")]
2729
2830
#[stable(feature = "_stable_fn", since = "1.0.0")] // ok!

compiler/rustc_error_codes/src/error_codes/E0543.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Erroneous code example:
44

55
```compile_fail,E0543
66
#![feature(staged_api)]
7+
#![allow(internal_features)]
78
#![stable(since = "1.0.0", feature = "test")]
89
910
#[stable(since = "0.1.0", feature = "_deprecated_fn")]
@@ -17,6 +18,7 @@ To fix this issue, you need to provide the `note` field. Example:
1718

1819
```
1920
#![feature(staged_api)]
21+
#![allow(internal_features)]
2022
#![stable(since = "1.0.0", feature = "test")]
2123
2224
#[stable(since = "0.1.0", feature = "_deprecated_fn")]

compiler/rustc_error_codes/src/error_codes/E0544.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Erroneous code example:
44

55
```compile_fail,E0544
66
#![feature(staged_api)]
7+
#![allow(internal_features)]
78
#![stable(since = "1.0.0", feature = "rust1")]
89
910
#[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.
1516

1617
```
1718
#![feature(staged_api)]
19+
#![allow(internal_features)]
1820
#![stable(since = "1.0.0", feature = "rust1")]
1921
2022
#[stable(feature = "test", since = "2.0.0")] // ok!

compiler/rustc_error_codes/src/error_codes/E0545.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Erroneous code example:
44

55
```compile_fail,E0545
66
#![feature(staged_api)]
7+
#![allow(internal_features)]
78
#![stable(since = "1.0.0", feature = "test")]
89
910
#[unstable(feature = "_unstable_fn", issue = "0")] // invalid
@@ -18,6 +19,7 @@ Example:
1819

1920
```
2021
#![feature(staged_api)]
22+
#![allow(internal_features)]
2123
#![stable(since = "1.0.0", feature = "test")]
2224
2325
#[unstable(feature = "_unstable_fn", issue = "none")] // ok!

compiler/rustc_error_codes/src/error_codes/E0546.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Erroneous code example:
44

55
```compile_fail,E0546
66
#![feature(staged_api)]
7+
#![allow(internal_features)]
78
#![stable(since = "1.0.0", feature = "test")]
89
910
#[unstable(issue = "none")] // invalid
@@ -17,6 +18,7 @@ To fix this issue, you need to provide the `feature` field. Example:
1718

1819
```
1920
#![feature(staged_api)]
21+
#![allow(internal_features)]
2022
#![stable(since = "1.0.0", feature = "test")]
2123
2224
#[unstable(feature = "unstable_fn", issue = "none")] // ok!

compiler/rustc_error_codes/src/error_codes/E0547.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Erroneous code example:
44

55
```compile_fail,E0547
66
#![feature(staged_api)]
7+
#![allow(internal_features)]
78
#![stable(since = "1.0.0", feature = "test")]
89
910
#[unstable(feature = "_unstable_fn")] // invalid
@@ -17,6 +18,7 @@ To fix this issue, you need to provide the `issue` field. Example:
1718

1819
```
1920
#![feature(staged_api)]
21+
#![allow(internal_features)]
2022
#![stable(since = "1.0.0", feature = "test")]
2123
2224
#[unstable(feature = "_unstable_fn", issue = "none")] // ok!

compiler/rustc_error_codes/src/error_codes/E0549.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Erroneous code example:
55

66
```compile_fail,E0549
77
#![feature(staged_api)]
8+
#![allow(internal_features)]
89
#![stable(since = "1.0.0", feature = "test")]
910
1011
#[deprecated(
@@ -19,6 +20,7 @@ Example:
1920

2021
```
2122
#![feature(staged_api)]
23+
#![allow(internal_features)]
2224
#![stable(since = "1.0.0", feature = "test")]
2325
2426
#[stable(since = "1.0.0", feature = "test")]

compiler/rustc_error_codes/src/error_codes/E0622.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Erroneous code example:
44

55
```compile_fail,E0622
66
#![feature(intrinsics)]
7+
#![allow(internal_features)]
8+
79
extern "rust-intrinsic" {
810
pub static breakpoint: fn(); // error: intrinsic must be a function
911
}
@@ -17,6 +19,8 @@ error, just declare a function. Example:
1719

1820
```no_run
1921
#![feature(intrinsics)]
22+
#![allow(internal_features)]
23+
2024
extern "rust-intrinsic" {
2125
pub fn breakpoint(); // ok!
2226
}

compiler/rustc_error_codes/src/error_codes/E0773.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Erroneous code example:
55
```compile_fail,E0773
66
#![feature(decl_macro)]
77
#![feature(rustc_attrs)]
8+
#![allow(internal_features)]
89
910
#[rustc_builtin_macro]
1011
pub macro test($item:item) {
@@ -24,6 +25,7 @@ To fix the issue, remove the duplicate declaration:
2425
```
2526
#![feature(decl_macro)]
2627
#![feature(rustc_attrs)]
28+
#![allow(internal_features)]
2729
2830
#[rustc_builtin_macro]
2931
pub macro test($item:item) {

compiler/rustc_error_codes/src/error_codes/E0789.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Erroneous code example:
1010
// used outside of the compiler and standard library.
1111
#![feature(rustc_attrs)]
1212
#![feature(staged_api)]
13+
#![allow(internal_features)]
1314
1415
#![unstable(feature = "foo_module", reason = "...", issue = "123")]
1516

compiler/rustc_error_messages/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![feature(type_alias_impl_trait)]
55
#![deny(rustc::untranslatable_diagnostic)]
66
#![deny(rustc::diagnostic_outside_of_impl)]
7+
#![cfg_attr(not(bootstrap), allow(internal_features))]
78

89
#[macro_use]
910
extern crate tracing;

compiler/rustc_errors/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#![feature(box_patterns)]
1616
#![feature(error_reporter)]
1717
#![allow(incomplete_features)]
18+
#![cfg_attr(not(bootstrap), allow(internal_features))]
1819

1920
#[macro_use]
2021
extern crate rustc_macros;

compiler/rustc_expand/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#![feature(try_blocks)]
1212
#![recursion_limit = "256"]
1313
#![deny(rustc::untranslatable_diagnostic)]
14+
#![cfg_attr(not(bootstrap), allow(internal_features))]
1415

1516
#[macro_use]
1617
extern crate rustc_macros;

0 commit comments

Comments
 (0)