-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #127854 - fmease:glob-import-type_ir_inherent-lint, r=<…
…try> Add internal lint for detecting non-glob imports of `rustc_type_ir::inherent` #127627 (comment) r? compiler-errors
- Loading branch information
Showing
9 changed files
with
168 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//@ compile-flags: -Z unstable-options | ||
//@ ignore-stage1 (can be removed after beta bump, cfg(not(bootstrap))) | ||
#![feature(rustc_private)] | ||
#![deny(rustc::non_glob_import_of_type_ir_inherent)] | ||
|
||
extern crate rustc_type_ir; | ||
|
||
mod ok { | ||
use rustc_type_ir::inherent::*; // OK | ||
use rustc_type_ir::inherent::{}; // OK | ||
use rustc_type_ir::inherent::{*}; // OK | ||
|
||
fn usage<T: rustc_type_ir::inherent::SliceLike>() {} // OK | ||
} | ||
|
||
mod direct { | ||
use rustc_type_ir::inherent::Predicate; //~ ERROR non-glob import of `rustc_type_ir::inherent` | ||
use rustc_type_ir::inherent::{AdtDef, Ty}; | ||
//~^ ERROR non-glob import of `rustc_type_ir::inherent` | ||
//~| ERROR non-glob import of `rustc_type_ir::inherent` | ||
use rustc_type_ir::inherent::ParamEnv as _; //~ ERROR non-glob import of `rustc_type_ir::inherent` | ||
} | ||
|
||
mod indirect0 { | ||
use rustc_type_ir::inherent; //~ ERROR non-glob import of `rustc_type_ir::inherent` | ||
use rustc_type_ir::inherent as inh; //~ ERROR non-glob import of `rustc_type_ir::inherent` | ||
use rustc_type_ir::{inherent as _}; //~ ERROR non-glob import of `rustc_type_ir::inherent` | ||
|
||
fn usage0<T: inherent::SliceLike>() {} | ||
fn usage1<T: inh::SliceLike>() {} | ||
} | ||
|
||
mod indirect1 { | ||
use rustc_type_ir::inherent::{self}; //~ ERROR non-glob import of `rustc_type_ir::inherent` | ||
use rustc_type_ir::inherent::{self as innate}; //~ ERROR non-glob import of `rustc_type_ir::inherent` | ||
} | ||
|
||
fn main() {} |
68 changes: 68 additions & 0 deletions
68
tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
error: non-glob import of `rustc_type_ir::inherent` | ||
--> $DIR/non_glob_import_of_type_ir_inherent.rs:17:9 | ||
| | ||
LL | use rustc_type_ir::inherent::Predicate; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^--------- | ||
| | | ||
| help: try using a glob import instead: `*` | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/non_glob_import_of_type_ir_inherent.rs:4:9 | ||
| | ||
LL | #![deny(rustc::non_glob_import_of_type_ir_inherent)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: non-glob import of `rustc_type_ir::inherent` | ||
--> $DIR/non_glob_import_of_type_ir_inherent.rs:18:35 | ||
| | ||
LL | use rustc_type_ir::inherent::{AdtDef, Ty}; | ||
| ^^^^^^ help: try using a glob import instead: `*` | ||
|
||
error: non-glob import of `rustc_type_ir::inherent` | ||
--> $DIR/non_glob_import_of_type_ir_inherent.rs:18:43 | ||
| | ||
LL | use rustc_type_ir::inherent::{AdtDef, Ty}; | ||
| ^^ help: try using a glob import instead: `*` | ||
|
||
error: non-glob import of `rustc_type_ir::inherent` | ||
--> $DIR/non_glob_import_of_type_ir_inherent.rs:21:9 | ||
| | ||
LL | use rustc_type_ir::inherent::ParamEnv as _; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^------------- | ||
| | | ||
| help: try using a glob import instead: `*` | ||
|
||
error: non-glob import of `rustc_type_ir::inherent` | ||
--> $DIR/non_glob_import_of_type_ir_inherent.rs:25:9 | ||
| | ||
LL | use rustc_type_ir::inherent; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^- help: try using a glob import instead: `::*` | ||
|
||
error: non-glob import of `rustc_type_ir::inherent` | ||
--> $DIR/non_glob_import_of_type_ir_inherent.rs:26:9 | ||
| | ||
LL | use rustc_type_ir::inherent as inh; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^------- help: try using a glob import instead: `::*` | ||
|
||
error: non-glob import of `rustc_type_ir::inherent` | ||
--> $DIR/non_glob_import_of_type_ir_inherent.rs:27:25 | ||
| | ||
LL | use rustc_type_ir::{inherent as _}; | ||
| ^^^^^^^^----- help: try using a glob import instead: `::*` | ||
|
||
error: non-glob import of `rustc_type_ir::inherent` | ||
--> $DIR/non_glob_import_of_type_ir_inherent.rs:34:35 | ||
| | ||
LL | use rustc_type_ir::inherent::{self}; | ||
| ^^^^ help: try using a glob import instead: `*` | ||
|
||
error: non-glob import of `rustc_type_ir::inherent` | ||
--> $DIR/non_glob_import_of_type_ir_inherent.rs:35:35 | ||
| | ||
LL | use rustc_type_ir::inherent::{self as innate}; | ||
| ^^^^---------- | ||
| | | ||
| help: try using a glob import instead: `*` | ||
|
||
error: aborting due to 9 previous errors | ||
|