@@ -2111,14 +2111,24 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2111
2111
extend : impl Fn ( & mut DiagnosticBuilder < ' tcx , ErrorGuaranteed > ) ,
2112
2112
) -> bool {
2113
2113
let args = segments. clone ( ) . flat_map ( |segment| segment. args ( ) . args ) ;
2114
- let types_and_spans: Vec < _ > = segments
2115
- . clone ( )
2116
- . flat_map ( |segment| {
2117
- segment. res . and_then ( |res| {
2118
- if segment. args ( ) . args . is_empty ( ) {
2119
- None
2120
- } else {
2121
- Some ( (
2114
+
2115
+ let ( lt, ty, ct, inf) =
2116
+ args. clone ( ) . fold ( ( false , false , false , false ) , |( lt, ty, ct, inf) , arg| match arg {
2117
+ hir:: GenericArg :: Lifetime ( _) => ( true , ty, ct, inf) ,
2118
+ hir:: GenericArg :: Type ( _) => ( lt, true , ct, inf) ,
2119
+ hir:: GenericArg :: Const ( _) => ( lt, ty, true , inf) ,
2120
+ hir:: GenericArg :: Infer ( _) => ( lt, ty, ct, true ) ,
2121
+ } ) ;
2122
+ let mut emitted = false ;
2123
+ if lt || ty || ct || inf {
2124
+ let types_and_spans: Vec < _ > = segments
2125
+ . clone ( )
2126
+ . flat_map ( |segment| {
2127
+ segment. res . and_then ( |res| {
2128
+ if segment. args ( ) . args . is_empty ( ) {
2129
+ None
2130
+ } else {
2131
+ Some ( (
2122
2132
match res {
2123
2133
Res :: PrimTy ( ty) => format ! ( "{} `{}`" , res. descr( ) , ty. name( ) ) ,
2124
2134
Res :: Def ( _, def_id)
@@ -2130,32 +2140,23 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2130
2140
} ,
2131
2141
segment. ident . span ,
2132
2142
) )
2133
- }
2143
+ }
2144
+ } )
2134
2145
} )
2135
- } )
2136
- . collect ( ) ;
2137
- let this_type = match & types_and_spans[ ..] {
2138
- [ .., _, ( last, _) ] => format ! (
2139
- "{} and {last}" ,
2140
- types_and_spans[ ..types_and_spans. len( ) - 1 ]
2141
- . iter( )
2142
- . map( |( x, _) | x. as_str( ) )
2143
- . intersperse( & ", " )
2144
- . collect:: <String >( )
2145
- ) ,
2146
- [ ( only, _) ] => only. to_string ( ) ,
2147
- [ ] => "this type" . to_string ( ) ,
2148
- } ;
2146
+ . collect ( ) ;
2147
+ let this_type = match & types_and_spans[ ..] {
2148
+ [ .., _, ( last, _) ] => format ! (
2149
+ "{} and {last}" ,
2150
+ types_and_spans[ ..types_and_spans. len( ) - 1 ]
2151
+ . iter( )
2152
+ . map( |( x, _) | x. as_str( ) )
2153
+ . intersperse( & ", " )
2154
+ . collect:: <String >( )
2155
+ ) ,
2156
+ [ ( only, _) ] => only. to_string ( ) ,
2157
+ [ ] => "this type" . to_string ( ) ,
2158
+ } ;
2149
2159
2150
- let ( lt, ty, ct, inf) =
2151
- args. clone ( ) . fold ( ( false , false , false , false ) , |( lt, ty, ct, inf) , arg| match arg {
2152
- hir:: GenericArg :: Lifetime ( _) => ( true , ty, ct, inf) ,
2153
- hir:: GenericArg :: Type ( _) => ( lt, true , ct, inf) ,
2154
- hir:: GenericArg :: Const ( _) => ( lt, ty, true , inf) ,
2155
- hir:: GenericArg :: Infer ( _) => ( lt, ty, ct, true ) ,
2156
- } ) ;
2157
- let mut emitted = false ;
2158
- if lt || ty || ct || inf {
2159
2160
let arg_spans: Vec < Span > = args. map ( |arg| arg. span ( ) ) . collect ( ) ;
2160
2161
2161
2162
let mut kinds = Vec :: with_capacity ( 4 ) ;
0 commit comments