@@ -78,7 +78,7 @@ use hir_ty::{
7878use itertools:: Itertools ;
7979use nameres:: diagnostics:: DefDiagnosticKind ;
8080use rustc_hash:: FxHashSet ;
81- use span:: { Edition , EditionedFileId , FileId , MacroCallId } ;
81+ use span:: { Edition , EditionedFileId , FileId , MacroCallId , SyntaxContextId } ;
8282use stdx:: { impl_from, never} ;
8383use syntax:: {
8484 ast:: { self , HasAttrs as _, HasGenericParams , HasName } ,
@@ -4379,6 +4379,22 @@ impl Type {
43794379 method_resolution:: implements_trait ( & canonical_ty, db, & self . env , trait_)
43804380 }
43814381
4382+ /// This does **not** resolve `IntoFuture`, only `Future`.
4383+ pub fn future_output ( self , db : & dyn HirDatabase ) -> Option < Type > {
4384+ let future_output =
4385+ db. lang_item ( self . env . krate , LangItem :: FutureOutput ) ?. as_type_alias ( ) ?;
4386+ self . normalize_trait_assoc_type ( db, & [ ] , future_output. into ( ) )
4387+ }
4388+
4389+ /// This does **not** resolve `IntoIterator`, only `Iterator`.
4390+ pub fn iterator_item ( self , db : & dyn HirDatabase ) -> Option < Type > {
4391+ let iterator_trait = db. lang_item ( self . env . krate , LangItem :: Iterator ) ?. as_trait ( ) ?;
4392+ let iterator_item = db
4393+ . trait_data ( iterator_trait)
4394+ . associated_type_by_name ( & Name :: new_symbol ( sym:: Item . clone ( ) , SyntaxContextId :: ROOT ) ) ?;
4395+ self . normalize_trait_assoc_type ( db, & [ ] , iterator_item. into ( ) )
4396+ }
4397+
43824398 /// Checks that particular type `ty` implements `std::ops::FnOnce`.
43834399 ///
43844400 /// This function can be used to check if a particular type is callable, since FnOnce is a
0 commit comments