@@ -15,6 +15,7 @@ mod option_as_ref_deref;
15
15
mod option_map_unwrap_or;
16
16
mod skip_while_next;
17
17
mod suspicious_map;
18
+ mod uninit_assumed_init;
18
19
mod unnecessary_filter_map;
19
20
mod unnecessary_lazy_eval;
20
21
mod unwrap_used;
@@ -1719,7 +1720,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
1719
1720
filter_map_identity:: check ( cx, expr, arg_lists[ 0 ] , method_spans[ 0 ] ) ;
1720
1721
} ,
1721
1722
[ "count" , "map" ] => suspicious_map:: check ( cx, expr) ,
1722
- [ "assume_init" ] => lint_maybe_uninit ( cx, & arg_lists[ 0 ] [ 0 ] , expr) ,
1723
+ [ "assume_init" ] => uninit_assumed_init :: check ( cx, & arg_lists[ 0 ] [ 0 ] , expr) ,
1723
1724
[ "unwrap_or" , arith @ ( "checked_add" | "checked_sub" | "checked_mul" ) ] => {
1724
1725
manual_saturating_arithmetic:: lint ( cx, expr, & arg_lists, & arith[ "checked_" . len ( ) ..] )
1725
1726
} ,
@@ -3548,34 +3549,6 @@ fn lint_into_iter(cx: &LateContext<'_>, expr: &hir::Expr<'_>, self_ref_ty: Ty<'_
3548
3549
}
3549
3550
}
3550
3551
3551
- /// lint for `MaybeUninit::uninit().assume_init()` (we already have the latter)
3552
- fn lint_maybe_uninit ( cx : & LateContext < ' _ > , expr : & hir:: Expr < ' _ > , outer : & hir:: Expr < ' _ > ) {
3553
- if_chain ! {
3554
- if let hir:: ExprKind :: Call ( ref callee, ref args) = expr. kind;
3555
- if args. is_empty( ) ;
3556
- if let hir:: ExprKind :: Path ( ref path) = callee. kind;
3557
- if match_qpath( path, & paths:: MEM_MAYBEUNINIT_UNINIT ) ;
3558
- if !is_maybe_uninit_ty_valid( cx, cx. typeck_results( ) . expr_ty_adjusted( outer) ) ;
3559
- then {
3560
- span_lint(
3561
- cx,
3562
- UNINIT_ASSUMED_INIT ,
3563
- outer. span,
3564
- "this call for this type may be undefined behavior"
3565
- ) ;
3566
- }
3567
- }
3568
- }
3569
-
3570
- fn is_maybe_uninit_ty_valid ( cx : & LateContext < ' _ > , ty : Ty < ' _ > ) -> bool {
3571
- match ty. kind ( ) {
3572
- ty:: Array ( ref component, _) => is_maybe_uninit_ty_valid ( cx, component) ,
3573
- ty:: Tuple ( ref types) => types. types ( ) . all ( |ty| is_maybe_uninit_ty_valid ( cx, ty) ) ,
3574
- ty:: Adt ( ref adt, _) => match_def_path ( cx, adt. did , & paths:: MEM_MAYBEUNINIT ) ,
3575
- _ => false ,
3576
- }
3577
- }
3578
-
3579
3552
fn lint_map_collect (
3580
3553
cx : & LateContext < ' _ > ,
3581
3554
expr : & hir:: Expr < ' _ > ,
0 commit comments