@@ -3,7 +3,8 @@ use crate::{
3
3
linter:: { LateLintPass , LintContext , Snippet } ,
4
4
sol:: { Severity , SolLint } ,
5
5
} ;
6
- use solar_sema:: hir:: { self , ExprKind , TypeKind } ;
6
+ use solar_ast:: { LitKind , StrKind } ;
7
+ use solar_sema:: hir:: { self , ElementaryType , ExprKind , ItemId , Res , TypeKind } ;
7
8
8
9
declare_forge_lint ! (
9
10
UNSAFE_TYPECAST ,
@@ -59,10 +60,7 @@ fn is_unsafe_typecast_hir(
59
60
60
61
/// Infers the elementary type of a source expression.
61
62
/// For cast chains, returns the ultimate source type, not intermediate cast results.
62
- fn infer_source_type ( hir : & hir:: Hir < ' _ > , expr : & hir:: Expr < ' _ > ) -> Option < hir:: ElementaryType > {
63
- use hir:: { ElementaryType , ItemId , Lit as HirLit , Res } ;
64
- use solar_ast:: LitKind ;
65
-
63
+ fn infer_source_type ( hir : & hir:: Hir < ' _ > , expr : & hir:: Expr < ' _ > ) -> Option < ElementaryType > {
66
64
match & expr. kind {
67
65
// Recursive cast: Type(val)
68
66
ExprKind :: Call ( call_expr, args, _) => {
@@ -114,11 +112,9 @@ fn infer_source_type(hir: &hir::Hir<'_>, expr: &hir::Expr<'_>) -> Option<hir::El
114
112
115
113
/// Checks if a type cast from source_type to target_type is unsafe.
116
114
fn is_unsafe_elementary_typecast (
117
- source_type : & hir :: ElementaryType ,
118
- target_type : & hir :: ElementaryType ,
115
+ source_type : & ElementaryType ,
116
+ target_type : & ElementaryType ,
119
117
) -> bool {
120
- use hir:: ElementaryType ;
121
-
122
118
match ( source_type, target_type) {
123
119
// Numeric downcasts (smaller target size)
124
120
( ElementaryType :: UInt ( source_size) , ElementaryType :: UInt ( target_size) )
0 commit comments