mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-10-31 12:04:43 +00:00 
			
		
		
		
	Minor docs improvement
This commit is contained in:
		
							parent
							
								
									71f1c4470d
								
							
						
					
					
						commit
						24e1db2f0c
					
				
					 2 changed files with 17 additions and 16 deletions
				
			
		|  | @ -4855,6 +4855,7 @@ impl Type { | |||
|         self.normalize_trait_assoc_type(db, &[], iterator_item.into()) | ||||
|     } | ||||
| 
 | ||||
|     /// Resolves the projection `<Self as IntoIterator>::IntoIter` and returns the resulting type
 | ||||
|     pub fn into_iterator_iter(self, db: &dyn HirDatabase) -> Option<Type> { | ||||
|         let trait_ = db.lang_item(self.env.krate, LangItem::IntoIterIntoIter).and_then(|it| { | ||||
|             let into_iter_fn = it.as_function()?; | ||||
|  |  | |||
|  | @ -32,10 +32,11 @@ pub(crate) fn complete_dot( | |||
| 
 | ||||
|     // Suggest .await syntax for types that implement Future trait
 | ||||
|     if let Some(future_output) = receiver_ty.into_future_output(ctx.db) { | ||||
|         let await_str = SmolStr::new_static("await"); | ||||
|         let mut item = CompletionItem::new( | ||||
|             CompletionItemKind::Keyword, | ||||
|             ctx.source_range(), | ||||
|             SmolStr::new_static("await"), | ||||
|             await_str.clone(), | ||||
|             ctx.edition, | ||||
|         ); | ||||
|         item.detail("expr.await"); | ||||
|  | @ -58,17 +59,13 @@ pub(crate) fn complete_dot( | |||
|             acc, | ||||
|             ctx, | ||||
|             &future_output, | ||||
|             |acc, field, ty| { | ||||
|                 acc.add_field(ctx, &dot_access, Some(SmolStr::new_static("await")), field, &ty) | ||||
|             }, | ||||
|             |acc, field, ty| { | ||||
|                 acc.add_tuple_field(ctx, Some(SmolStr::new_static("await")), field, &ty) | ||||
|             }, | ||||
|             |acc, field, ty| acc.add_field(ctx, &dot_access, Some(await_str.clone()), field, &ty), | ||||
|             |acc, field, ty| acc.add_tuple_field(ctx, Some(await_str.clone()), field, &ty), | ||||
|             is_field_access, | ||||
|             is_method_access_with_parens, | ||||
|         ); | ||||
|         complete_methods(ctx, &future_output, &traits_in_scope, |func| { | ||||
|             acc.add_method(ctx, &dot_access, func, Some(SmolStr::new_static("await")), None) | ||||
|             acc.add_method(ctx, &dot_access, func, Some(await_str.clone()), None) | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|  | @ -85,20 +82,23 @@ pub(crate) fn complete_dot( | |||
|         acc.add_method(ctx, dot_access, func, None, None) | ||||
|     }); | ||||
| 
 | ||||
|     // FIXME:
 | ||||
|     // Checking for the existence of `iter()` is complicated in our setup, because we need to substitute
 | ||||
|     // its return type, so we instead check for `<&Self as IntoIterator>::IntoIter`.
 | ||||
|     // Does <&receiver_ty as IntoIterator>::IntoIter` exist? Assume `iter` is valid
 | ||||
|     let iter = receiver_ty | ||||
|         .strip_references() | ||||
|         .add_reference(hir::Mutability::Shared) | ||||
|         .into_iterator_iter(ctx.db) | ||||
|         .map(|ty| (ty, SmolStr::new_static("iter()"))) | ||||
|         .or_else(|| { | ||||
|             receiver_ty | ||||
|                 .clone() | ||||
|                 .into_iterator_iter(ctx.db) | ||||
|                 .map(|ty| (ty, SmolStr::new_static("into_iter()"))) | ||||
|         }); | ||||
|     if let Some((iter, iter_sym)) = iter { | ||||
|         .map(|ty| (ty, SmolStr::new_static("iter()"))); | ||||
|     // Does <receiver_ty as IntoIterator>::IntoIter` exist?
 | ||||
|     let into_iter = || { | ||||
|         receiver_ty | ||||
|             .clone() | ||||
|             .into_iterator_iter(ctx.db) | ||||
|             .map(|ty| (ty, SmolStr::new_static("into_iter()"))) | ||||
|     }; | ||||
|     if let Some((iter, iter_sym)) = iter.or_else(into_iter) { | ||||
|         // Skip iterators, e.g. complete `.iter().filter_map()`.
 | ||||
|         let dot_access_kind = match &dot_access.kind { | ||||
|             DotAccessKind::Field { receiver_is_ambiguous_float_literal: _ } => { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lukas Wirth
						Lukas Wirth