@@ -5,22 +5,21 @@ use std::mem;
55
66use either:: Either ;
77use hir_def:: {
8- AdtId , DefWithBodyId , FieldId , FunctionId , VariantId ,
8+ AdtId , CallableDefId , DefWithBodyId , FieldId , FunctionId , VariantId ,
99 expr_store:: { Body , path:: Path } ,
1010 hir:: { AsmOperand , Expr , ExprId , ExprOrPatId , InlineAsmKind , Pat , PatId , Statement , UnaryOp } ,
1111 resolver:: { HasResolver , ResolveValueResult , Resolver , ValueNs } ,
1212 signatures:: StaticFlags ,
1313 type_ref:: Rawness ,
1414} ;
15+ use rustc_type_ir:: inherent:: IntoKind ;
1516use span:: Edition ;
1617
17- use crate :: next_solver:: DbInterner ;
18- use crate :: next_solver:: mapping:: NextSolverToChalk ;
19- use crate :: utils:: TargetFeatureIsSafeInTarget ;
2018use crate :: {
21- InferenceResult , Interner , TargetFeatures , TyExt , TyKind ,
19+ InferenceResult , TargetFeatures ,
2220 db:: HirDatabase ,
23- utils:: { is_fn_unsafe_to_call, target_feature_is_safe_in_target} ,
21+ next_solver:: { CallableIdWrapper , TyKind , abi:: Safety } ,
22+ utils:: { TargetFeatureIsSafeInTarget , is_fn_unsafe_to_call, target_feature_is_safe_in_target} ,
2423} ;
2524
2625#[ derive( Debug , Default ) ]
@@ -151,7 +150,6 @@ struct UnsafeVisitor<'db> {
151150 /// On some targets (WASM), calling safe functions with `#[target_feature]` is always safe, even when
152151 /// the target feature is not enabled. This flag encodes that.
153152 target_feature_is_safe : TargetFeatureIsSafeInTarget ,
154- interner : DbInterner < ' db > ,
155153}
156154
157155impl < ' db > UnsafeVisitor < ' db > {
@@ -186,7 +184,6 @@ impl<'db> UnsafeVisitor<'db> {
186184 def_target_features,
187185 edition,
188186 target_feature_is_safe,
189- interner : DbInterner :: new_with ( db, None , None ) ,
190187 }
191188 }
192189
@@ -289,12 +286,14 @@ impl<'db> UnsafeVisitor<'db> {
289286 let inside_assignment = mem:: replace ( & mut self . inside_assignment , false ) ;
290287 match expr {
291288 & Expr :: Call { callee, .. } => {
292- let callee = self . infer [ callee] . to_chalk ( self . interner ) ;
293- if let Some ( func) = callee. as_fn_def ( self . db ) {
289+ let callee = self . infer [ callee] ;
290+ if let TyKind :: FnDef ( CallableIdWrapper ( CallableDefId :: FunctionId ( func) ) , _) =
291+ callee. kind ( )
292+ {
294293 self . check_call ( current, func) ;
295294 }
296- if let TyKind :: Function ( fn_ptr ) = callee. kind ( Interner )
297- && fn_ptr . sig . safety == chalk_ir :: Safety :: Unsafe
295+ if let TyKind :: FnPtr ( _ , hdr ) = callee. kind ( )
296+ && hdr . safety == Safety :: Unsafe
298297 {
299298 self . on_unsafe_op ( current. into ( ) , UnsafetyReason :: UnsafeFnCall ) ;
300299 }
@@ -342,7 +341,7 @@ impl<'db> UnsafeVisitor<'db> {
342341 }
343342 }
344343 Expr :: UnaryOp { expr, op : UnaryOp :: Deref } => {
345- if let TyKind :: Raw ( ..) = & self . infer [ * expr] . to_chalk ( self . interner ) . kind ( Interner ) {
344+ if let TyKind :: RawPtr ( ..) = self . infer [ * expr] . kind ( ) {
346345 self . on_unsafe_op ( current. into ( ) , UnsafetyReason :: RawPtrDeref ) ;
347346 }
348347 }
0 commit comments