@@ -42,14 +42,13 @@ impl<'tcx> LateLintPass<'tcx> for AndThenThenSome {
42
42
fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' tcx > ) {
43
43
match expr. kind {
44
44
ExprKind :: MethodCall ( method_name, selfarg, [ arg ] , span) => {
45
- dbg ! ( expr) ;
45
+ // (expr);
46
46
//let option_id = cx.tcx.get_diagnostic_item(sym::Option);
47
47
// TODO: check if type of reciever is diagnostic item Option.
48
- let tckr = cx. typeck_results ( ) ;
49
- let def_id = tckr. type_dependent_def_id ( expr. hir_id ) . unwrap ( ) ;
48
+ // let tckr = cx.typeck_results();
49
+ // let def_id = tckr.type_dependent_def_id(expr.hir_id).unwrap();
50
50
//dbg!(method_name, selfarg, arg);
51
- if dbg ! ( match_def_path( cx, dbg!( def_id) ,
52
- & [ "core" , "option" , "Option" , "and_then" ] ) )
51
+ if is_and_then ( cx, expr)
53
52
{
54
53
if let Some ( ( closure_args, predicate) ) = dbg ! ( then_some_closure_arg( cx, arg) ) {
55
54
//dbg!(predicate);
@@ -108,7 +107,7 @@ fn peel_closure_body<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, closu
108
107
ExprKind :: Call ( func, [ pred, arg ] ) => {
109
108
//dbg!(func, fn_def_id(cx, expr));
110
109
//todo!();
111
- if is_then_some ( cx, func ) && dbg ! ( is_local_defined_at( cx, arg, closure_arg_id) ) {
110
+ if dbg ! ( is_then_some( cx, expr ) ) && dbg ! ( is_local_defined_at( cx, arg, closure_arg_id) ) {
112
111
//todo!("it worked!!");
113
112
Some ( pred)
114
113
@@ -155,22 +154,21 @@ fn show_sugg(cx: &LateContext<'_>, span: Span, selfarg: &Expr<'_>, closure_args:
155
154
156
155
fn is_then_some ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) -> bool {
157
156
if let Some ( def_id) = fn_def_id ( cx, expr) {
158
- match_def_path (
157
+ dbg ! ( match_def_path(
159
158
cx, dbg!( def_id) ,
160
- & [ "core" , "bool" , "<impl bool>" , "then_some" ] )
159
+ & [ "core" , "bool" , "<impl bool>" , "then_some" ] ) )
161
160
} else {
162
- //todo!("not type dependent" );
161
+ dbg ! ( expr ) ;
163
162
false
164
163
}
165
164
}
166
165
167
166
fn is_and_then ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) -> bool {
168
167
if let Some ( def_id) = fn_def_id ( cx, expr) {
169
- match_def_path (
168
+ dbg ! ( match_def_path(
170
169
cx, dbg!( def_id) ,
171
- & [ "core" , "option" , "Option" , "and_then" ] )
170
+ & [ "core" , "option" , "Option" , "and_then" ] ) )
172
171
} else {
173
- //todo!("not type dependent");
174
172
false
175
173
}
176
174
}
0 commit comments