@@ -78,7 +78,7 @@ use hir_ty::{
78
78
use itertools:: Itertools ;
79
79
use nameres:: diagnostics:: DefDiagnosticKind ;
80
80
use rustc_hash:: FxHashSet ;
81
- use span:: { Edition , EditionedFileId , FileId , MacroCallId } ;
81
+ use span:: { Edition , EditionedFileId , FileId , MacroCallId , SyntaxContextId } ;
82
82
use stdx:: { impl_from, never} ;
83
83
use syntax:: {
84
84
ast:: { self , HasAttrs as _, HasGenericParams , HasName } ,
@@ -4379,6 +4379,22 @@ impl Type {
4379
4379
method_resolution:: implements_trait ( & canonical_ty, db, & self . env , trait_)
4380
4380
}
4381
4381
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
+
4382
4398
/// Checks that particular type `ty` implements `std::ops::FnOnce`.
4383
4399
///
4384
4400
/// This function can be used to check if a particular type is callable, since FnOnce is a
0 commit comments