@@ -14,7 +14,9 @@ pub(crate) fn complete_expr_path(
1414 path_ctx : & PathCompletionCtx ,
1515) {
1616 let _p = profile:: span ( "complete_expr_path" ) ;
17-
17+ if !ctx. qualifier_ctx . none ( ) {
18+ return ;
19+ }
1820 let (
1921 qualified,
2022 in_block_expr,
@@ -23,6 +25,9 @@ pub(crate) fn complete_expr_path(
2325 after_if_expr,
2426 wants_mut_token,
2527 in_condition,
28+ ty,
29+ incomplete_let,
30+ impl_,
2631 ) = match path_ctx {
2732 & PathCompletionCtx {
2833 kind :
@@ -31,19 +36,26 @@ pub(crate) fn complete_expr_path(
3136 in_loop_body,
3237 after_if_expr,
3338 in_condition,
39+ incomplete_let,
3440 ref ref_expr_parent,
3541 ref is_func_update,
42+ ref innermost_ret_ty,
43+ ref impl_,
44+ ..
3645 } ,
3746 ref qualified,
3847 ..
39- } if ctx . qualifier_ctx . none ( ) => (
48+ } => (
4049 qualified,
4150 in_block_expr,
4251 in_loop_body,
4352 is_func_update. is_some ( ) ,
4453 after_if_expr,
4554 ref_expr_parent. as_ref ( ) . map ( |it| it. mut_token ( ) . is_none ( ) ) . unwrap_or ( false ) ,
4655 in_condition,
56+ innermost_ret_ty,
57+ incomplete_let,
58+ impl_,
4759 ) ,
4860 _ => return ,
4961 } ;
@@ -172,8 +184,7 @@ pub(crate) fn complete_expr_path(
172184 if let Some ( adt) =
173185 ctx. expected_type . as_ref ( ) . and_then ( |ty| ty. strip_references ( ) . as_adt ( ) )
174186 {
175- let self_ty =
176- ( || ctx. sema . to_def ( ctx. impl_def . as_ref ( ) ?) ?. self_ty ( ctx. db ) . as_adt ( ) ) ( ) ;
187+ let self_ty = ( || ctx. sema . to_def ( impl_. as_ref ( ) ?) ?. self_ty ( ctx. db ) . as_adt ( ) ) ( ) ;
177188 let complete_self = self_ty == Some ( adt) ;
178189
179190 match adt {
@@ -201,9 +212,15 @@ pub(crate) fn complete_expr_path(
201212 }
202213 }
203214 hir:: Adt :: Enum ( e) => {
204- super :: enum_variants_with_paths ( acc, ctx, e, |acc, ctx, variant, path| {
205- acc. add_qualified_enum_variant ( ctx, variant, path)
206- } ) ;
215+ super :: enum_variants_with_paths (
216+ acc,
217+ ctx,
218+ e,
219+ impl_,
220+ |acc, ctx, variant, path| {
221+ acc. add_qualified_enum_variant ( ctx, variant, path)
222+ } ,
223+ ) ;
207224 }
208225 }
209226 }
@@ -214,7 +231,8 @@ pub(crate) fn complete_expr_path(
214231 } ) ;
215232
216233 if !is_func_update {
217- let mut add_keyword = |kw, snippet| acc. add_keyword_snippet ( ctx, kw, snippet) ;
234+ let mut add_keyword =
235+ |kw, snippet| acc. add_keyword_snippet_expr ( ctx, kw, snippet, incomplete_let) ;
218236
219237 if !in_block_expr {
220238 add_keyword ( "unsafe" , "unsafe {\n $0\n }" ) ;
@@ -252,10 +270,10 @@ pub(crate) fn complete_expr_path(
252270 }
253271 }
254272
255- if let Some ( fn_def ) = & ctx . function_def {
273+ if let Some ( ty ) = ty {
256274 add_keyword (
257275 "return" ,
258- match ( in_block_expr, fn_def . ret_type ( ) . is_some ( ) ) {
276+ match ( in_block_expr, ty . is_unit ( ) ) {
259277 ( true , true ) => "return ;" ,
260278 ( true , false ) => "return;" ,
261279 ( false , true ) => "return $0" ,
0 commit comments