@@ -14,8 +14,8 @@ use {rustc_ast as ast, rustc_hir as hir};
14
14
use crate :: lints:: {
15
15
BadOptAccessDiag , DefaultHashTypesDiag , DiagOutOfImpl , LintPassByHand ,
16
16
NonGlobImportTypeIrInherent , QueryInstability , QueryUntracked , SpanUseEqCtxtDiag ,
17
- SymbolInternStringLiteralDiag , TyQualified , TykindDiag , TykindKind , TypeIrInherentUsage ,
18
- TypeIrTraitUsage , UntranslatableDiag ,
17
+ SymbolInternStringLiteralDiag , TyQualified , TykindDiag , TykindKind , TypeIrDirectUse ,
18
+ TypeIrInherentUsage , TypeIrTraitUsage , UntranslatableDiag ,
19
19
} ;
20
20
use crate :: { EarlyContext , EarlyLintPass , LateContext , LateLintPass , LintContext } ;
21
21
@@ -676,3 +676,26 @@ impl<'tcx> LateLintPass<'tcx> for SymbolInternStringLiteral {
676
676
}
677
677
}
678
678
}
679
+
680
+ declare_tool_lint ! {
681
+ /// The `direct_use_of_rustc_type_ir` lint detects usage of `rustc_type_ir`.
682
+ ///
683
+ /// This module should only be used within the trait solver and some desirable
684
+ /// crates like rustc_middle.
685
+ pub rustc:: DIRECT_USE_OF_RUSTC_TYPE_IR ,
686
+ Allow ,
687
+ "usage `rustc_type_ir` abstraction outside of trait system" ,
688
+ report_in_external_macro: true
689
+ }
690
+ declare_lint_pass ! ( UseOfTypeIr => [ DIRECT_USE_OF_RUSTC_TYPE_IR ] ) ;
691
+
692
+ impl < ' tcx > LateLintPass < ' tcx > for UseOfTypeIr {
693
+ fn check_item ( & mut self , cx : & LateContext < ' tcx > , item : & ' tcx rustc_hir:: Item < ' tcx > ) {
694
+ let rustc_hir:: ItemKind :: Use ( path, _) = item. kind else { return } ;
695
+ if let Some ( segment) = path. segments . first ( )
696
+ && segment. ident . to_string ( ) == "rustc_type_ir"
697
+ {
698
+ cx. emit_span_lint ( DIRECT_USE_OF_RUSTC_TYPE_IR , item. span , TypeIrDirectUse ) ;
699
+ }
700
+ }
701
+ }
0 commit comments