Rollup merge of #138964 - compiler-errors:usage-of-interner, r=lcnr
Implement lint against using Interner and InferCtxtLike in random compiler crates Often `Interner` defines similar methods to `TyCtxt` (but often simplified due to the simpler API surface of the type system layer for the new solver), which people will either unintentionally or intentionally import and use. Let's discourage that. r? lcnr
This commit is contained in:
commit
cb39217d44
13 changed files with 139 additions and 47 deletions
16
tests/ui-fulldeps/internal-lints/import-of-type-ir-traits.rs
Normal file
16
tests/ui-fulldeps/internal-lints/import-of-type-ir-traits.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
//@ compile-flags: -Z unstable-options
|
||||
//@ ignore-stage1
|
||||
|
||||
#![feature(rustc_private)]
|
||||
#![deny(rustc::usage_of_type_ir_traits)]
|
||||
|
||||
extern crate rustc_type_ir;
|
||||
|
||||
use rustc_type_ir::Interner;
|
||||
|
||||
fn foo<I: Interner>(cx: I, did: I::DefId) {
|
||||
let _ = cx.trait_is_unsafe(did);
|
||||
//~^ ERROR do not use `rustc_type_ir::Interner` or `rustc_type_ir::InferCtxtLike` unless you're inside of the trait solver
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,15 @@
|
|||
error: do not use `rustc_type_ir::Interner` or `rustc_type_ir::InferCtxtLike` unless you're inside of the trait solver
|
||||
--> $DIR/import-of-type-ir-traits.rs:12:13
|
||||
|
|
||||
LL | let _ = cx.trait_is_unsafe(did);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the method or struct you're looking for is likely defined somewhere else downstream in the compiler
|
||||
note: the lint level is defined here
|
||||
--> $DIR/import-of-type-ir-traits.rs:5:9
|
||||
|
|
||||
LL | #![deny(rustc::usage_of_type_ir_traits)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue