@@ -75,8 +75,7 @@ pub(crate) struct PathCompletionCtx {
75
75
// FIXME: use this
76
76
/// The parent of the path we are completing.
77
77
pub ( super ) parent : Option < ast:: Path > ,
78
- // FIXME: This should be PathKind, the none case should never occur
79
- pub ( super ) kind : Option < PathKind > ,
78
+ pub ( super ) kind : PathKind ,
80
79
/// Whether the path segment has type args or not.
81
80
pub ( super ) has_type_args : bool ,
82
81
/// `true` if we are a statement or a last expr in the block.
@@ -315,11 +314,11 @@ impl<'a> CompletionContext<'a> {
315
314
}
316
315
317
316
pub ( crate ) fn expects_expression ( & self ) -> bool {
318
- matches ! ( self . path_context, Some ( PathCompletionCtx { kind: Some ( PathKind :: Expr ) , .. } ) )
317
+ matches ! ( self . path_context, Some ( PathCompletionCtx { kind: PathKind :: Expr , .. } ) )
319
318
}
320
319
321
320
pub ( crate ) fn expects_type ( & self ) -> bool {
322
- matches ! ( self . path_context, Some ( PathCompletionCtx { kind: Some ( PathKind :: Type ) , .. } ) )
321
+ matches ! ( self . path_context, Some ( PathCompletionCtx { kind: PathKind :: Type , .. } ) )
323
322
}
324
323
325
324
pub ( crate ) fn path_is_call ( & self ) -> bool {
@@ -341,7 +340,7 @@ impl<'a> CompletionContext<'a> {
341
340
}
342
341
343
342
pub ( crate ) fn path_kind ( & self ) -> Option < PathKind > {
344
- self . path_context . as_ref ( ) . and_then ( |it| it. kind )
343
+ self . path_context . as_ref ( ) . map ( |it| it. kind )
345
344
}
346
345
347
346
pub ( crate ) fn is_immediately_after_macro_bang ( & self ) -> bool {
@@ -837,7 +836,7 @@ impl<'a> CompletionContext<'a> {
837
836
Self :: classify_name_ref ( & self . sema , & original_file, name_ref)
838
837
{
839
838
self . path_context =
840
- Some ( PathCompletionCtx { kind : Some ( PathKind :: Derive ) , ..path_ctx } ) ;
839
+ Some ( PathCompletionCtx { kind : PathKind :: Derive , ..path_ctx } ) ;
841
840
}
842
841
}
843
842
return ;
@@ -969,7 +968,7 @@ impl<'a> CompletionContext<'a> {
969
968
is_absolute_path : false ,
970
969
qualifier : None ,
971
970
parent : path. parent_path ( ) ,
972
- kind : None ,
971
+ kind : PathKind :: Item ,
973
972
has_type_args : false ,
974
973
can_be_stmt : false ,
975
974
in_loop_body : false ,
@@ -1041,7 +1040,7 @@ impl<'a> CompletionContext<'a> {
1041
1040
}
1042
1041
} ;
1043
1042
Some ( kind)
1044
- } ) . flatten ( ) ;
1043
+ } ) . flatten ( ) ? ;
1045
1044
path_ctx. has_type_args = segment. generic_arg_list ( ) . is_some ( ) ;
1046
1045
1047
1046
if let Some ( ( path, use_tree_parent) ) = path_or_use_tree_qualifier ( & path) {
0 commit comments