diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-07-18 18:10:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-18 18:10:16 +0200 |
| commit | 4ad2c99b6d5c08a4e2993f15b4076e9a125c2d5c (patch) | |
| tree | 0458e3f193e4b35481b21bfb66a7ff68a15ca1db /tests | |
| parent | 6f7fa03a0608c2eaaff2ad9c0afbb3414cd4b978 (diff) | |
| parent | 2507301de0814406175fdb0bbe9da40a348b1f30 (diff) | |
| download | rust-4ad2c99b6d5c08a4e2993f15b4076e9a125c2d5c.tar.gz rust-4ad2c99b6d5c08a4e2993f15b4076e9a125c2d5c.zip | |
Rollup merge of #127854 - fmease:glob-import-type_ir_inherent-lint, r=compiler-errors
Add internal lint for detecting non-glob imports of `rustc_type_ir::inherent` https://github.com/rust-lang/rust/pull/127627#issuecomment-2225295951 r? compiler-errors
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.rs | 38 | ||||
| -rw-r--r-- | tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.stderr | 68 |
2 files changed, 106 insertions, 0 deletions
diff --git a/tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.rs b/tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.rs new file mode 100644 index 00000000000..33e10a00713 --- /dev/null +++ b/tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.rs @@ -0,0 +1,38 @@ +//@ compile-flags: -Z unstable-options +//@ ignore-stage1 (can be removed after beta bump, #[cfg(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() {} diff --git a/tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.stderr b/tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.stderr new file mode 100644 index 00000000000..84e3867c95b --- /dev/null +++ b/tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.stderr @@ -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 + |
