Skip to content

Commit

Permalink
Auto merge of #108955 - Nilstrieb:dont-use-me-pls, r=oli-obk
Browse files Browse the repository at this point in the history
Add `internal_features` lint

Implements rust-lang/compiler-team#596

Also requires some more test blessing for codegen tests etc

`@jyn514` had the idea of just `allow`ing the lint by default in the test suite. I'm not sure whether this is a good idea, but it's definitely one worth considering. Additional input encouraged.
  • Loading branch information
bors committed Aug 3, 2023
2 parents 474709a + 5830ca2 commit 1fe3846
Show file tree
Hide file tree
Showing 68 changed files with 209 additions and 49 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![cfg_attr(feature = "nightly", feature(step_trait, rustc_attrs, min_specialization))]
#![cfg_attr(all(not(bootstrap), feature = "nightly"), allow(internal_features))]

use std::fmt;
#[cfg(feature = "nightly")]
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_arena/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#![deny(unsafe_op_in_unsafe_fn)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
#![cfg_attr(not(bootstrap), allow(internal_features))]
#![allow(clippy::mut_from_ref)] // Arena allocators are one of the places where this pattern is fine.

use smallvec::SmallVec;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#![feature(trusted_step)]
#![feature(try_blocks)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(internal_features))]

#[macro_use]
extern crate rustc_middle;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#![allow(rustc::potential_query_instability)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
#![cfg_attr(not(bootstrap), allow(internal_features))]
#![deny(unsafe_op_in_unsafe_fn)]

#[macro_use]
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0092.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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!
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0093.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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!
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0094.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Erroneous code example:

```compile_fail,E0094
#![feature(intrinsics)]
#![allow(internal_features)]
extern "rust-intrinsic" {
#[rustc_safe_intrinsic]
Expand All @@ -18,6 +19,7 @@ Example:

```
#![feature(intrinsics)]
#![allow(internal_features)]
extern "rust-intrinsic" {
#[rustc_safe_intrinsic]
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_error_codes/src/error_codes/E0208.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0211.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ used. Erroneous code examples:

```compile_fail
#![feature(intrinsics)]
#![allow(internal_features)]
extern "rust-intrinsic" {
#[rustc_safe_intrinsic]
Expand Down Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_error_codes/src/error_codes/E0230.md
Original file line number Diff line number Diff line change
Expand Up @@ -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> {}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_error_codes/src/error_codes/E0231.md
Original file line number Diff line number Diff line change
Expand Up @@ -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> {}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_error_codes/src/error_codes/E0232.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ compiled:

```compile_fail,E0232
#![feature(rustc_attrs)]
#![allow(internal_features)]
#[rustc_on_unimplemented(lorem="")] // error!
trait BadAnnotation {}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0264.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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!
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0539.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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!
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0542.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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!
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0543.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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")]
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0544.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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!
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0545.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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!
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0546.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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!
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0547.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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!
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0549.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Erroneous code example:

```compile_fail,E0549
#![feature(staged_api)]
#![allow(internal_features)]
#![stable(since = "1.0.0", feature = "test")]
#[deprecated(
Expand All @@ -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")]
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0622.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -17,6 +19,8 @@ error, just declare a function. Example:

```no_run
#![feature(intrinsics)]
#![allow(internal_features)]
extern "rust-intrinsic" {
pub fn breakpoint(); // ok!
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0773.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_error_codes/src/error_codes/E0789.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_error_messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#![feature(type_alias_impl_trait)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
#![cfg_attr(not(bootstrap), allow(internal_features))]

#[macro_use]
extern crate tracing;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#![feature(box_patterns)]
#![feature(error_reporter)]
#![allow(incomplete_features)]
#![cfg_attr(not(bootstrap), allow(internal_features))]

#[macro_use]
extern crate rustc_macros;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_expand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#![feature(try_blocks)]
#![recursion_limit = "256"]
#![deny(rustc::untranslatable_diagnostic)]
#![cfg_attr(not(bootstrap), allow(internal_features))]

#[macro_use]
extern crate rustc_macros;
Expand Down
Loading

0 comments on commit 1fe3846

Please sign in to comment.