@@ -94,20 +94,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
9494
9595 let find_param_matching = |matches : & dyn Fn ( ParamTerm ) -> bool | {
9696 predicate_args. iter ( ) . find_map ( |arg| {
97- arg. walk ( ) . find_map ( |arg| {
98- if let ty:: GenericArgKind :: Type ( ty) = arg. kind ( )
99- && let ty:: Param ( param_ty) = * ty. kind ( )
100- && matches ( ParamTerm :: Ty ( param_ty) )
101- {
102- Some ( arg)
103- } else if let ty:: GenericArgKind :: Const ( ct) = arg. kind ( )
104- && let ty:: ConstKind :: Param ( param_ct) = ct. kind ( )
105- && matches ( ParamTerm :: Const ( param_ct) )
97+ arg. walk ( ) . find ( |arg| match arg. kind ( ) {
98+ ty:: GenericArgKind :: Type ( ty) if let ty:: Param ( param_ty) = ty. kind ( ) => {
99+ matches ( ParamTerm :: Ty ( * param_ty) )
100+ }
101+ ty:: GenericArgKind :: Const ( ct)
102+ if let ty:: ConstKind :: Param ( param_ct) = ct. kind ( ) =>
106103 {
107- Some ( arg)
108- } else {
109- None
104+ matches ( ParamTerm :: Const ( param_ct) )
110105 }
106+ _ => false ,
111107 } )
112108 } )
113109 } ;
@@ -162,7 +158,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
162158 . into_iter ( )
163159 . flatten ( )
164160 {
165- if self . point_at_path_if_possible ( error, def_id, param, & qpath) {
161+ if self . point_at_path_if_possible ( error, def_id, param, qpath) {
166162 return true ;
167163 }
168164 }
@@ -194,7 +190,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
194190 args,
195191 ) => {
196192 if let Some ( param) = predicate_self_type_to_point_at
197- && self . point_at_path_if_possible ( error, callee_def_id, param, & qpath)
193+ && self . point_at_path_if_possible ( error, callee_def_id, param, qpath)
198194 {
199195 return true ;
200196 }
@@ -225,7 +221,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
225221 . into_iter ( )
226222 . flatten ( )
227223 {
228- if self . point_at_path_if_possible ( error, callee_def_id, param, & qpath) {
224+ if self . point_at_path_if_possible ( error, callee_def_id, param, qpath) {
229225 return true ;
230226 }
231227 }
@@ -544,10 +540,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
544540 }
545541
546542 /// - `blame_specific_*` means that the function will recursively traverse the expression,
547- /// looking for the most-specific-possible span to blame.
543+ /// looking for the most-specific-possible span to blame.
548544 ///
549545 /// - `point_at_*` means that the function will only go "one level", pointing at the specific
550- /// expression mentioned.
546+ /// expression mentioned.
551547 ///
552548 /// `blame_specific_arg_if_possible` will find the most-specific expression anywhere inside
553549 /// the provided function call expression, and mark it as responsible for the fulfillment
@@ -607,9 +603,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
607603 /**
608604 * Recursively searches for the most-specific blameable expression.
609605 * For example, if you have a chain of constraints like:
610- * - want `Vec<i32>: Copy`
611- * - because `Option<Vec<i32>>: Copy` needs `Vec<i32>: Copy` because `impl <T: Copy> Copy for Option<T>`
612- * - because `(Option<Vec<i32>, bool)` needs `Option<Vec<i32>>: Copy` because `impl <A: Copy, B: Copy> Copy for (A, B)`
606+ * - want `Vec<i32>: Copy`
607+ * - because `Option<Vec<i32>>: Copy` needs `Vec<i32>: Copy` because `impl <T: Copy> Copy for Option<T>`
608+ * - because `(Option<Vec<i32>, bool)` needs `Option<Vec<i32>>: Copy` because `impl <A: Copy, B: Copy> Copy for (A, B)`
609+ *
613610 * then if you pass in `(Some(vec![1, 2, 3]), false)`, this helper `point_at_specific_expr_if_possible`
614611 * will find the expression `vec![1, 2, 3]` as the "most blameable" reason for this missing constraint.
615612 *
@@ -747,9 +744,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
747744
748745 /// Drills into `expr` to arrive at the equivalent location of `find_generic_param` in `in_ty`.
749746 /// For example, given
750- /// - expr: `(Some(vec![1, 2, 3]), false)`
751- /// - param: `T`
752- /// - in_ty: `(Option<Vec<T>, bool)`
747+ /// - expr: `(Some(vec![1, 2, 3]), false)`
748+ /// - param: `T`
749+ /// - in_ty: `(Option<Vec<T>, bool)`
750+ ///
753751 /// we would drill until we arrive at `vec![1, 2, 3]`.
754752 ///
755753 /// If successful, we return `Ok(refined_expr)`. If unsuccessful, we return `Err(partially_refined_expr`),
@@ -1017,7 +1015,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10171015 . variant_with_id ( variant_def_id)
10181016 . fields
10191017 . iter ( )
1020- . map ( |field| field. ty ( self . tcx , * in_ty_adt_generic_args) )
1018+ . map ( |field| field. ty ( self . tcx , in_ty_adt_generic_args) )
10211019 . enumerate ( )
10221020 . filter ( |( _index, field_type) | find_param_in_ty ( ( * field_type) . into ( ) , param) ) ,
10231021 ) else {
0 commit comments