@@ -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 }
@@ -543,10 +539,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
543539 }
544540
545541 /// - `blame_specific_*` means that the function will recursively traverse the expression,
546- /// looking for the most-specific-possible span to blame.
542+ /// looking for the most-specific-possible span to blame.
547543 ///
548544 /// - `point_at_*` means that the function will only go "one level", pointing at the specific
549- /// expression mentioned.
545+ /// expression mentioned.
550546 ///
551547 /// `blame_specific_arg_if_possible` will find the most-specific expression anywhere inside
552548 /// the provided function call expression, and mark it as responsible for the fulfillment
@@ -609,6 +605,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
609605 * - want `Vec<i32>: Copy`
610606 * - because `Option<Vec<i32>>: Copy` needs `Vec<i32>: Copy` because `impl <T: Copy> Copy for Option<T>`
611607 * - because `(Option<Vec<i32>, bool)` needs `Option<Vec<i32>>: Copy` because `impl <A: Copy, B: Copy> Copy for (A, B)`
608+ *
612609 * then if you pass in `(Some(vec![1, 2, 3]), false)`, this helper `point_at_specific_expr_if_possible`
613610 * will find the expression `vec![1, 2, 3]` as the "most blameable" reason for this missing constraint.
614611 *
@@ -749,6 +746,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
749746 /// - expr: `(Some(vec![1, 2, 3]), false)`
750747 /// - param: `T`
751748 /// - in_ty: `(Option<Vec<T>, bool)`
749+ ///
752750 /// we would drill until we arrive at `vec![1, 2, 3]`.
753751 ///
754752 /// If successful, we return `Ok(refined_expr)`. If unsuccessful, we return `Err(partially_refined_expr`),
@@ -1016,7 +1014,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10161014 . variant_with_id ( variant_def_id)
10171015 . fields
10181016 . iter ( )
1019- . map ( |field| field. ty ( self . tcx , * in_ty_adt_generic_args) )
1017+ . map ( |field| field. ty ( self . tcx , in_ty_adt_generic_args) )
10201018 . enumerate ( )
10211019 . filter ( |( _index, field_type) | find_param_in_ty ( ( * field_type) . into ( ) , param) ) ,
10221020 ) else {
0 commit comments