@@ -33,7 +33,7 @@ use crate::{
3333 CompletionContext , CompletionItem , CompletionItemKind ,
3434 context:: {
3535 DotAccess , ItemListKind , NameContext , NameKind , NameRefContext , NameRefKind ,
36- PathCompletionCtx , PathKind , PatternContext , TypeLocation , Visible ,
36+ PathCompletionCtx , PathKind , PatternContext , TypeAscriptionTarget , TypeLocation , Visible ,
3737 } ,
3838 item:: Builder ,
3939 render:: {
@@ -111,11 +111,22 @@ impl Completions {
111111 }
112112 }
113113
114- pub ( crate ) fn add_type_keywords ( & mut self , ctx : & CompletionContext < ' _ > ) {
115- self . add_keyword_snippet ( ctx, "fn" , "fn($1)" ) ;
116- self . add_keyword_snippet ( ctx, "dyn" , "dyn $0" ) ;
117- self . add_keyword_snippet ( ctx, "impl" , "impl $0" ) ;
118- self . add_keyword_snippet ( ctx, "for" , "for<$1>" ) ;
114+ pub ( crate ) fn add_type_keywords (
115+ & mut self ,
116+ ctx : & CompletionContext < ' _ > ,
117+ required_thin_arrow : bool ,
118+ ) {
119+ let mut add_keyword = |kw, snippet| {
120+ if required_thin_arrow {
121+ self . add_keyword_snippet ( ctx, kw, snippet) ;
122+ } else {
123+ self . add_keyword_snippet ( ctx, kw, & snippet[ 3 ..] ) ;
124+ }
125+ } ;
126+ add_keyword ( "fn" , "-> fn($1)" ) ;
127+ add_keyword ( "dyn" , "-> dyn $0" ) ;
128+ add_keyword ( "impl" , "-> impl $0" ) ;
129+ add_keyword ( "for" , "-> for<$1>" ) ;
119130 }
120131
121132 pub ( crate ) fn add_super_keyword (
@@ -746,6 +757,12 @@ pub(super) fn complete_name_ref(
746757 field:: complete_field_list_tuple_variant ( acc, ctx, path_ctx) ;
747758 }
748759 TypeLocation :: TypeAscription ( ascription) => {
760+ if let TypeAscriptionTarget :: RetType { item : Some ( item) , .. } =
761+ ascription
762+ && path_ctx. required_thin_arrow ( )
763+ {
764+ keyword:: complete_for_and_where ( acc, ctx, & item. clone ( ) . into ( ) ) ;
765+ }
749766 r#type:: complete_ascribed_type ( acc, ctx, path_ctx, ascription) ;
750767 }
751768 TypeLocation :: GenericArg { .. }
0 commit comments