@@ -290,7 +290,7 @@ impl FunctionBuilder {
290
290
) ;
291
291
292
292
let ( generic_param_list, where_clause) =
293
- fn_generic_params ( ctx, necessary_generic_params, & target) ;
293
+ fn_generic_params ( ctx, necessary_generic_params, & target) ? ;
294
294
295
295
Some ( Self {
296
296
target,
@@ -336,7 +336,7 @@ impl FunctionBuilder {
336
336
) ;
337
337
338
338
let ( generic_param_list, where_clause) =
339
- fn_generic_params ( ctx, necessary_generic_params, & target) ;
339
+ fn_generic_params ( ctx, necessary_generic_params, & target) ? ;
340
340
341
341
Some ( Self {
342
342
target,
@@ -551,7 +551,8 @@ fn fn_args(
551
551
) )
552
552
}
553
553
554
- /// Gets parameter bounds and where predicates in scope and filters out irrelevant ones.
554
+ /// Gets parameter bounds and where predicates in scope and filters out irrelevant ones. Returns
555
+ /// `None` when it fails to get scope information.
555
556
///
556
557
/// See comment on `filter_unnecessary_bounds()` for what bounds we consider relevant.
557
558
///
@@ -562,10 +563,10 @@ fn fn_generic_params(
562
563
ctx : & AssistContext < ' _ > ,
563
564
necessary_params : FxHashSet < hir:: GenericParam > ,
564
565
target : & GeneratedFunctionTarget ,
565
- ) -> ( Option < ast:: GenericParamList > , Option < ast:: WhereClause > ) {
566
+ ) -> Option < ( Option < ast:: GenericParamList > , Option < ast:: WhereClause > ) > {
566
567
if necessary_params. is_empty ( ) {
567
568
// Not really needed but fast path.
568
- return ( None , None ) ;
569
+ return Some ( ( None , None ) ) ;
569
570
}
570
571
571
572
// 1. Get generic parameters (with bounds) and where predicates in scope.
@@ -592,8 +593,8 @@ fn fn_generic_params(
592
593
593
594
// 4. Rewrite paths
594
595
if let Some ( param) = generic_params. first ( ) {
595
- let source_scope = ctx. sema . scope ( param. syntax ( ) ) . unwrap ( ) ;
596
- let target_scope = ctx. sema . scope ( & target. parent ( ) ) . unwrap ( ) ;
596
+ let source_scope = ctx. sema . scope ( param. syntax ( ) ) ? ;
597
+ let target_scope = ctx. sema . scope ( & target. parent ( ) ) ? ;
597
598
if source_scope. module ( ) != target_scope. module ( ) {
598
599
let transform = PathTransform :: generic_transformation ( & target_scope, & source_scope) ;
599
600
let generic_params = generic_params. iter ( ) . map ( |it| it. syntax ( ) ) ;
@@ -606,7 +607,7 @@ fn fn_generic_params(
606
607
let where_clause =
607
608
if where_preds. is_empty ( ) { None } else { Some ( make:: where_clause ( where_preds) ) } ;
608
609
609
- ( Some ( generic_param_list) , where_clause)
610
+ Some ( ( Some ( generic_param_list) , where_clause) )
610
611
}
611
612
612
613
fn params_and_where_preds_in_scope (
0 commit comments