diff options
| author | Michael Goulet <michael@errs.io> | 2022-05-26 20:22:28 -0700 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-05-28 11:38:22 -0700 |
| commit | 34e05812e029206add91fa39df86765fcb3f8b5a (patch) | |
| tree | fc2d0bfaf18186b591d68aa830c54026df9316b9 /src | |
| parent | a056a953f00d7b78d12dc192b34c47cca6fa7b6b (diff) | |
| download | rust-34e05812e029206add91fa39df86765fcb3f8b5a.tar.gz rust-34e05812e029206add91fa39df86765fcb3f8b5a.zip | |
Fix TyKind lint, make consts no longer fn, etc
Diffstat (limited to 'src')
3 files changed, 120 insertions, 88 deletions
diff --git a/src/test/run-make-fulldeps/obtain-borrowck/driver.rs b/src/test/run-make-fulldeps/obtain-borrowck/driver.rs index c3b82aa853c..8f78bda033e 100644 --- a/src/test/run-make-fulldeps/obtain-borrowck/driver.rs +++ b/src/test/run-make-fulldeps/obtain-borrowck/driver.rs @@ -154,7 +154,7 @@ fn get_bodies<'tcx>(tcx: TyCtxt<'tcx>) -> Vec<(String, BodyWithBorrowckFacts<'tc // SAFETY: For soundness we need to ensure that the bodies have // the same lifetime (`'tcx`), which they had before they were // stored in the thread local. - (def_path.to_string_no_crate_verbose(), body) + (def_path.to_string_no_crate_verbose(), unsafe { std::mem::transmute(body) }) }) .collect() }) diff --git a/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs index 973294e985f..2cb1ed6fcb7 100644 --- a/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs +++ b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs @@ -3,41 +3,43 @@ #![feature(rustc_private)] extern crate rustc_middle; +extern crate rustc_type_ir; use rustc_middle::ty::{self, Ty, TyKind}; +use rustc_type_ir::{Interner, TyKind as IrTyKind}; #[deny(rustc::usage_of_ty_tykind)] fn main() { let kind = TyKind::Bool; //~ ERROR usage of `ty::TyKind::<kind>` match kind { - TyKind::Bool => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Char => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Int(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Uint(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Float(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Adt(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Foreign(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Str => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Array(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Slice(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::RawPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Ref(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::FnDef(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::FnPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Dynamic(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Closure(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Generator(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Bool => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Char => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Int(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Uint(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Float(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Adt(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Foreign(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Str => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Array(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Slice(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::RawPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Ref(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::FnDef(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::FnPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Dynamic(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Closure(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Generator(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::GeneratorWitness(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Never => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Tuple(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Projection(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Opaque(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Param(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Bound(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Placeholder(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Infer(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Error(_) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Never => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Tuple(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Projection(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Opaque(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Param(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Bound(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Placeholder(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Infer(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Error(_) => (), //~ ERROR usage of `ty::TyKind::<kind>` } if let ty::Int(int_ty) = kind {} @@ -45,4 +47,10 @@ fn main() { if let TyKind::Int(int_ty) = kind {} //~ ERROR usage of `ty::TyKind::<kind>` fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {} //~ ERROR usage of `ty::TyKind` + + fn ir_ty_kind<I: Interner>(bad: IrTyKind<I>) -> IrTyKind<I> { + //~^ ERROR usage of `ty::TyKind` + //~| ERROR usage of `ty::TyKind` + IrTyKind::Bool //~ ERROR usage of `ty::TyKind::<kind>` + } } diff --git a/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr index d6e4c85c190..171f49087d6 100644 --- a/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr +++ b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr @@ -1,190 +1,214 @@ error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:11:16 + --> $DIR/ty_tykind_usage.rs:13:16 | LL | let kind = TyKind::Bool; - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` | note: the lint level is defined here - --> $DIR/ty_tykind_usage.rs:9:8 + --> $DIR/ty_tykind_usage.rs:11:8 | LL | #[deny(rustc::usage_of_ty_tykind)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:14:9 + --> $DIR/ty_tykind_usage.rs:16:9 | LL | TyKind::Bool => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:15:9 + --> $DIR/ty_tykind_usage.rs:17:9 | LL | TyKind::Char => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:16:9 + --> $DIR/ty_tykind_usage.rs:18:9 | LL | TyKind::Int(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:17:9 + --> $DIR/ty_tykind_usage.rs:19:9 | LL | TyKind::Uint(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:18:9 + --> $DIR/ty_tykind_usage.rs:20:9 | LL | TyKind::Float(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:19:9 + --> $DIR/ty_tykind_usage.rs:21:9 | LL | TyKind::Adt(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:20:9 + --> $DIR/ty_tykind_usage.rs:22:9 | LL | TyKind::Foreign(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:21:9 + --> $DIR/ty_tykind_usage.rs:23:9 | LL | TyKind::Str => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:22:9 + --> $DIR/ty_tykind_usage.rs:24:9 | LL | TyKind::Array(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:23:9 + --> $DIR/ty_tykind_usage.rs:25:9 | LL | TyKind::Slice(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:24:9 + --> $DIR/ty_tykind_usage.rs:26:9 | LL | TyKind::RawPtr(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:25:9 + --> $DIR/ty_tykind_usage.rs:27:9 | LL | TyKind::Ref(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:26:9 + --> $DIR/ty_tykind_usage.rs:28:9 | LL | TyKind::FnDef(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:27:9 + --> $DIR/ty_tykind_usage.rs:29:9 | LL | TyKind::FnPtr(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:28:9 + --> $DIR/ty_tykind_usage.rs:30:9 | LL | TyKind::Dynamic(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:29:9 + --> $DIR/ty_tykind_usage.rs:31:9 | LL | TyKind::Closure(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:30:9 + --> $DIR/ty_tykind_usage.rs:32:9 | LL | TyKind::Generator(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:31:9 + --> $DIR/ty_tykind_usage.rs:33:9 | LL | TyKind::GeneratorWitness(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:32:9 + --> $DIR/ty_tykind_usage.rs:34:9 | LL | TyKind::Never => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:33:9 + --> $DIR/ty_tykind_usage.rs:35:9 | LL | TyKind::Tuple(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:34:9 + --> $DIR/ty_tykind_usage.rs:36:9 | LL | TyKind::Projection(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:35:9 + --> $DIR/ty_tykind_usage.rs:37:9 | LL | TyKind::Opaque(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:36:9 + --> $DIR/ty_tykind_usage.rs:38:9 | LL | TyKind::Param(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:37:9 + --> $DIR/ty_tykind_usage.rs:39:9 | LL | TyKind::Bound(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:38:9 + --> $DIR/ty_tykind_usage.rs:40:9 | LL | TyKind::Placeholder(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:39:9 + --> $DIR/ty_tykind_usage.rs:41:9 | LL | TyKind::Infer(..) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:40:9 + --> $DIR/ty_tykind_usage.rs:42:9 | LL | TyKind::Error(_) => (), - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:45:12 + --> $DIR/ty_tykind_usage.rs:47:12 | LL | if let TyKind::Int(int_ty) = kind {} - | ^^^^^^ help: try using ty::<kind> directly: `ty` + | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind` - --> $DIR/ty_tykind_usage.rs:47:24 + --> $DIR/ty_tykind_usage.rs:49:24 | LL | fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {} | ^^^^^^^^^^ | = help: try using `Ty` instead -error: aborting due to 30 previous errors +error: usage of `ty::TyKind` + --> $DIR/ty_tykind_usage.rs:51:37 + | +LL | fn ir_ty_kind<I: Interner>(bad: IrTyKind<I>) -> IrTyKind<I> { + | ^^^^^^^^^^^ + | + = help: try using `Ty` instead + +error: usage of `ty::TyKind` + --> $DIR/ty_tykind_usage.rs:51:53 + | +LL | fn ir_ty_kind<I: Interner>(bad: IrTyKind<I>) -> IrTyKind<I> { + | ^^^^^^^^^^^ + | + = help: try using `Ty` instead + +error: usage of `ty::TyKind::<kind>` + --> $DIR/ty_tykind_usage.rs:54:9 + | +LL | IrTyKind::Bool + | --------^^^^^^ + | | + | help: try using `ty::<kind>` directly: `ty` + +error: aborting due to 33 previous errors |
