@@ -217,22 +217,42 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
217
217
flags. push( ( sym:: _Self, Some ( shortname. to_owned( ) ) ) ) ;
218
218
}
219
219
220
+ // Slices give us `[]`, `[{ty}]`
221
+ if let ty:: Slice ( aty) = self_ty. kind( ) {
222
+ flags. push( ( sym:: _Self, Some ( "[]" . to_string( ) ) ) ) ;
223
+ if let Some ( def) = aty. ty_adt_def( ) {
224
+ // We also want to be able to select the slice's type's original
225
+ // signature with no type arguments resolved
226
+ let type_string = self . tcx. type_of( def. did( ) ) . to_string( ) ;
227
+ flags. push( ( sym:: _Self, Some ( format!( "[{type_string}]" ) ) ) ) ;
228
+ }
229
+ if aty. is_integral( ) {
230
+ flags. push( ( sym:: _Self, Some ( "[{integral}]" . to_string( ) ) ) ) ;
231
+ }
232
+ }
233
+
234
+ // Arrays give us `[]`, `[{ty}; _]` and `[{ty}; N]`
220
235
if let ty:: Array ( aty, len) = self_ty. kind( ) {
221
- flags. push( ( sym:: _Self, Some ( "[]" . to_owned( ) ) ) ) ;
222
- flags. push( ( sym:: _Self, Some ( format!( "[{}]" , aty) ) ) ) ;
236
+ flags. push( ( sym:: _Self, Some ( "[]" . to_string( ) ) ) ) ;
237
+ let len = len. val( ) . try_to_value( ) . and_then( |v| v. try_to_machine_usize( self . tcx) ) ;
238
+ flags. push( ( sym:: _Self, Some ( format!( "[{}; _]" , aty) ) ) ) ;
239
+ if let Some ( n) = len {
240
+ flags. push( ( sym:: _Self, Some ( format!( "[{}; {}]" , aty, n) ) ) ) ;
241
+ }
223
242
if let Some ( def) = aty. ty_adt_def( ) {
224
243
// We also want to be able to select the array's type's original
225
244
// signature with no type arguments resolved
226
245
let type_string = self . tcx. type_of( def. did( ) ) . to_string( ) ;
227
- flags. push( ( sym:: _Self, Some ( format!( "[{}]" , type_string) ) ) ) ;
228
-
229
- let len =
230
- len. val( ) . try_to_value( ) . and_then( |v| v. try_to_machine_usize( self . tcx) ) ;
231
- let string = match len {
232
- Some ( n) => format!( "[{}; {}]" , type_string, n) ,
233
- None => format!( "[{}; _]" , type_string) ,
234
- } ;
235
- flags. push( ( sym:: _Self, Some ( string) ) ) ;
246
+ flags. push( ( sym:: _Self, Some ( format!( "[{type_string}; _]" ) ) ) ) ;
247
+ if let Some ( n) = len {
248
+ flags. push( ( sym:: _Self, Some ( format!( "[{type_string}; {n}]" ) ) ) ) ;
249
+ }
250
+ }
251
+ if aty. is_integral( ) {
252
+ flags. push( ( sym:: _Self, Some ( "[{integral}; _]" . to_string( ) ) ) ) ;
253
+ if let Some ( n) = len {
254
+ flags. push( ( sym:: _Self, Some ( format!( "[{{integral}}; {n}]" ) ) ) ) ;
255
+ }
236
256
}
237
257
}
238
258
if let ty:: Dynamic ( traits, _) = self_ty. kind( ) {
0 commit comments