@@ -42,7 +42,7 @@ use hir_def::{
42
42
adt:: VariantData ,
43
43
body:: { BodyDiagnostic , SyntheticSyntax } ,
44
44
expr:: { BindingAnnotation , ExprOrPatId , LabelId , Pat , PatId } ,
45
- generics:: { TypeOrConstParamData , TypeParamProvenance , LifetimeParamData } ,
45
+ generics:: { LifetimeParamData , TypeOrConstParamData , TypeParamProvenance } ,
46
46
item_tree:: ItemTreeNode ,
47
47
lang_item:: { LangItem , LangItemTarget } ,
48
48
layout:: { Layout , LayoutError , ReprOptions } ,
@@ -1177,13 +1177,16 @@ impl Adt {
1177
1177
Adt :: Union ( u) => u. id . resolver ( db. upcast ( ) ) ,
1178
1178
Adt :: Enum ( e) => e. id . resolver ( db. upcast ( ) ) ,
1179
1179
} ;
1180
- resolver. generic_params ( ) . and_then ( |gp| {
1181
- ( & gp. lifetimes )
1182
- . iter ( )
1183
- // there should only be a single lifetime
1184
- // but `Arena` requires to use an iterator
1185
- . nth ( 0 )
1186
- } ) . map ( |arena| arena. 1 . clone ( ) )
1180
+ resolver
1181
+ . generic_params ( )
1182
+ . and_then ( |gp| {
1183
+ ( & gp. lifetimes )
1184
+ . iter ( )
1185
+ // there should only be a single lifetime
1186
+ // but `Arena` requires to use an iterator
1187
+ . nth ( 0 )
1188
+ } )
1189
+ . map ( |arena| arena. 1 . clone ( ) )
1187
1190
}
1188
1191
1189
1192
pub fn as_enum ( & self ) -> Option < Enum > {
@@ -3355,23 +3358,15 @@ impl Type {
3355
3358
. map ( move |ty| self . derived ( ty) )
3356
3359
}
3357
3360
3358
- /// Combines lifetime indicators and type arguments into a single `Vec<SmolStr>`
3359
- pub fn lifetime_and_type_arguments < ' a > ( & ' a self , db : & ' a dyn HirDatabase ) -> Vec < SmolStr > {
3360
- let mut names = if let Some ( lt) = self
3361
- . as_adt ( )
3362
- . and_then ( |a| {
3363
- a. lifetime ( db)
3364
- . and_then ( |lt| Some ( ( & lt. name ) . to_smol_str ( ) . clone ( ) ) )
3365
- } ) {
3366
- vec ! [ lt]
3367
- } else {
3368
- vec ! [ ]
3369
- } ;
3370
-
3371
- for ty in self . type_arguments ( ) {
3372
- names. push ( SmolStr :: new ( ty. display ( db) . to_string ( ) ) )
3373
- }
3374
- names
3361
+ /// Combines lifetime indicators and type arguments into a single `Iterator`
3362
+ pub fn lifetime_and_type_arguments < ' a > (
3363
+ & ' a self ,
3364
+ db : & ' a dyn HirDatabase ,
3365
+ ) -> impl Iterator < Item = SmolStr > + ' a {
3366
+ self . as_adt ( )
3367
+ . and_then ( |a| a. lifetime ( db) . and_then ( |lt| Some ( ( & lt. name ) . to_smol_str ( ) ) ) )
3368
+ . into_iter ( )
3369
+ . chain ( self . type_arguments ( ) . map ( |ty| SmolStr :: new ( ty. display ( db) . to_string ( ) ) ) )
3375
3370
}
3376
3371
3377
3372
pub fn iterate_method_candidates_with_traits < T > (
0 commit comments