@@ -43,9 +43,11 @@ pub(super) fn compare_impl_item(
43
43
debug ! ( ?impl_trait_ref) ;
44
44
45
45
match impl_item. kind {
46
- ty:: AssocKind :: Fn => compare_impl_method ( tcx, impl_item, trait_item, impl_trait_ref) ,
47
- ty:: AssocKind :: Type => compare_impl_ty ( tcx, impl_item, trait_item, impl_trait_ref) ,
48
- ty:: AssocKind :: Const => compare_impl_const ( tcx, impl_item, trait_item, impl_trait_ref) ,
46
+ ty:: AssocKind :: Fn { .. } => compare_impl_method ( tcx, impl_item, trait_item, impl_trait_ref) ,
47
+ ty:: AssocKind :: Type { .. } => compare_impl_ty ( tcx, impl_item, trait_item, impl_trait_ref) ,
48
+ ty:: AssocKind :: Const { .. } => {
49
+ compare_impl_const ( tcx, impl_item, trait_item, impl_trait_ref)
50
+ }
49
51
}
50
52
}
51
53
@@ -651,7 +653,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
651
653
cause. span,
652
654
E0053 ,
653
655
"method `{}` has an incompatible return type for trait" ,
654
- trait_m. name
656
+ trait_m. name( )
655
657
) ;
656
658
infcx. err_ctxt ( ) . note_type_err (
657
659
& mut diag,
@@ -1029,11 +1031,11 @@ fn report_trait_method_mismatch<'tcx>(
1029
1031
impl_err_span,
1030
1032
E0053 ,
1031
1033
"method `{}` has an incompatible type for trait" ,
1032
- trait_m. name
1034
+ trait_m. name( )
1033
1035
) ;
1034
1036
match & terr {
1035
1037
TypeError :: ArgumentMutability ( 0 ) | TypeError :: ArgumentSorts ( _, 0 )
1036
- if trait_m. fn_has_self_parameter =>
1038
+ if trait_m. is_method ( ) =>
1037
1039
{
1038
1040
let ty = trait_sig. inputs ( ) [ 0 ] ;
1039
1041
let sugg = get_self_string ( ty, |ty| ty == impl_trait_ref. self_ty ( ) ) ;
@@ -1252,7 +1254,7 @@ fn compare_self_type<'tcx>(
1252
1254
get_self_string ( self_arg_ty, can_eq_self)
1253
1255
} ;
1254
1256
1255
- match ( trait_m. fn_has_self_parameter , impl_m. fn_has_self_parameter ) {
1257
+ match ( trait_m. is_method ( ) , impl_m. is_method ( ) ) {
1256
1258
( false , false ) | ( true , true ) => { }
1257
1259
1258
1260
( false , true ) => {
@@ -1263,14 +1265,14 @@ fn compare_self_type<'tcx>(
1263
1265
impl_m_span,
1264
1266
E0185 ,
1265
1267
"method `{}` has a `{}` declaration in the impl, but not in the trait" ,
1266
- trait_m. name,
1268
+ trait_m. name( ) ,
1267
1269
self_descr
1268
1270
) ;
1269
1271
err. span_label ( impl_m_span, format ! ( "`{self_descr}` used in impl" ) ) ;
1270
1272
if let Some ( span) = tcx. hir_span_if_local ( trait_m. def_id ) {
1271
1273
err. span_label ( span, format ! ( "trait method declared without `{self_descr}`" ) ) ;
1272
1274
} else {
1273
- err. note_trait_signature ( trait_m. name , trait_m. signature ( tcx) ) ;
1275
+ err. note_trait_signature ( trait_m. name ( ) , trait_m. signature ( tcx) ) ;
1274
1276
}
1275
1277
return Err ( err. emit_unless ( delay) ) ;
1276
1278
}
@@ -1283,14 +1285,14 @@ fn compare_self_type<'tcx>(
1283
1285
impl_m_span,
1284
1286
E0186 ,
1285
1287
"method `{}` has a `{}` declaration in the trait, but not in the impl" ,
1286
- trait_m. name,
1288
+ trait_m. name( ) ,
1287
1289
self_descr
1288
1290
) ;
1289
1291
err. span_label ( impl_m_span, format ! ( "expected `{self_descr}` in impl" ) ) ;
1290
1292
if let Some ( span) = tcx. hir_span_if_local ( trait_m. def_id ) {
1291
1293
err. span_label ( span, format ! ( "`{self_descr}` used in trait" ) ) ;
1292
1294
} else {
1293
- err. note_trait_signature ( trait_m. name , trait_m. signature ( tcx) ) ;
1295
+ err. note_trait_signature ( trait_m. name ( ) , trait_m. signature ( tcx) ) ;
1294
1296
}
1295
1297
1296
1298
return Err ( err. emit_unless ( delay) ) ;
@@ -1360,7 +1362,7 @@ fn compare_number_of_generics<'tcx>(
1360
1362
let mut err_occurred = None ;
1361
1363
for ( kind, trait_count, impl_count) in matchings {
1362
1364
if impl_count != trait_count {
1363
- let arg_spans = |kind : ty:: AssocKind , generics : & hir:: Generics < ' _ > | {
1365
+ let arg_spans = |item : & ty:: AssocItem , generics : & hir:: Generics < ' _ > | {
1364
1366
let mut spans = generics
1365
1367
. params
1366
1368
. iter ( )
@@ -1370,7 +1372,7 @@ fn compare_number_of_generics<'tcx>(
1370
1372
} => {
1371
1373
// A fn can have an arbitrary number of extra elided lifetimes for the
1372
1374
// same signature.
1373
- !matches ! ( kind , ty :: AssocKind :: Fn )
1375
+ !item . is_fn ( )
1374
1376
}
1375
1377
_ => true ,
1376
1378
} )
@@ -1383,7 +1385,7 @@ fn compare_number_of_generics<'tcx>(
1383
1385
} ;
1384
1386
let ( trait_spans, impl_trait_spans) = if let Some ( def_id) = trait_. def_id . as_local ( ) {
1385
1387
let trait_item = tcx. hir_expect_trait_item ( def_id) ;
1386
- let arg_spans: Vec < Span > = arg_spans ( trait_. kind , trait_item. generics ) ;
1388
+ let arg_spans: Vec < Span > = arg_spans ( & trait_, trait_item. generics ) ;
1387
1389
let impl_trait_spans: Vec < Span > = trait_item
1388
1390
. generics
1389
1391
. params
@@ -1409,7 +1411,7 @@ fn compare_number_of_generics<'tcx>(
1409
1411
_ => None ,
1410
1412
} )
1411
1413
. collect ( ) ;
1412
- let spans = arg_spans ( impl_. kind , impl_item. generics ) ;
1414
+ let spans = arg_spans ( & impl_, impl_item. generics ) ;
1413
1415
let span = spans. first ( ) . copied ( ) ;
1414
1416
1415
1417
let mut err = tcx. dcx ( ) . struct_span_err (
@@ -1418,7 +1420,7 @@ fn compare_number_of_generics<'tcx>(
1418
1420
"{} `{}` has {} {kind} parameter{} but its trait \
1419
1421
declaration has {} {kind} parameter{}",
1420
1422
item_kind,
1421
- trait_. name,
1423
+ trait_. name( ) ,
1422
1424
impl_count,
1423
1425
pluralize!( impl_count) ,
1424
1426
trait_count,
@@ -1509,7 +1511,7 @@ fn compare_number_of_method_arguments<'tcx>(
1509
1511
impl_span,
1510
1512
E0050 ,
1511
1513
"method `{}` has {} but the declaration in trait `{}` has {}" ,
1512
- trait_m. name,
1514
+ trait_m. name( ) ,
1513
1515
potentially_plural_count( impl_number_args, "parameter" ) ,
1514
1516
tcx. def_path_str( trait_m. def_id) ,
1515
1517
trait_number_args
@@ -1524,7 +1526,7 @@ fn compare_number_of_method_arguments<'tcx>(
1524
1526
) ,
1525
1527
) ;
1526
1528
} else {
1527
- err. note_trait_signature ( trait_m. name , trait_m. signature ( tcx) ) ;
1529
+ err. note_trait_signature ( trait_m. name ( ) , trait_m. signature ( tcx) ) ;
1528
1530
}
1529
1531
1530
1532
err. span_label (
@@ -1578,7 +1580,7 @@ fn compare_synthetic_generics<'tcx>(
1578
1580
impl_span,
1579
1581
E0643 ,
1580
1582
"method `{}` has incompatible signature for trait" ,
1581
- trait_m. name
1583
+ trait_m. name( )
1582
1584
) ;
1583
1585
err. span_label ( trait_span, "declaration in trait here" ) ;
1584
1586
if impl_synthetic {
@@ -1700,7 +1702,7 @@ fn compare_generic_param_kinds<'tcx>(
1700
1702
trait_item : ty:: AssocItem ,
1701
1703
delay : bool ,
1702
1704
) -> Result < ( ) , ErrorGuaranteed > {
1703
- assert_eq ! ( impl_item. kind , trait_item. kind ) ;
1705
+ assert_eq ! ( impl_item. as_tag ( ) , trait_item. as_tag ( ) ) ;
1704
1706
1705
1707
let ty_const_params_of = |def_id| {
1706
1708
tcx. generics_of ( def_id) . own_params . iter ( ) . filter ( |param| {
@@ -1738,7 +1740,7 @@ fn compare_generic_param_kinds<'tcx>(
1738
1740
E0053 ,
1739
1741
"{} `{}` has an incompatible generic parameter for trait `{}`" ,
1740
1742
impl_item. descr( ) ,
1741
- trait_item. name,
1743
+ trait_item. name( ) ,
1742
1744
& tcx. def_path_str( tcx. parent( trait_item. def_id) )
1743
1745
) ;
1744
1746
@@ -1874,7 +1876,7 @@ fn compare_const_predicate_entailment<'tcx>(
1874
1876
cause. span,
1875
1877
E0326 ,
1876
1878
"implemented const `{}` has an incompatible type for trait" ,
1877
- trait_ct. name
1879
+ trait_ct. name( )
1878
1880
) ;
1879
1881
1880
1882
let trait_c_span = trait_ct. def_id . as_local ( ) . map ( |trait_ct_def_id| {
@@ -2232,16 +2234,19 @@ fn param_env_with_gat_bounds<'tcx>(
2232
2234
// of the RPITITs associated with the same body. This is because checking
2233
2235
// the item bounds of RPITITs often involves nested RPITITs having to prove
2234
2236
// bounds about themselves.
2235
- let impl_tys_to_install = match impl_ty. opt_rpitit_info {
2236
- None => vec ! [ impl_ty] ,
2237
- Some (
2238
- ty:: ImplTraitInTraitData :: Impl { fn_def_id }
2239
- | ty:: ImplTraitInTraitData :: Trait { fn_def_id, .. } ,
2240
- ) => tcx
2237
+ let impl_tys_to_install = match impl_ty. kind {
2238
+ ty:: AssocKind :: Type {
2239
+ data :
2240
+ ty:: AssocTypeData :: Rpitit (
2241
+ ty:: ImplTraitInTraitData :: Impl { fn_def_id }
2242
+ | ty:: ImplTraitInTraitData :: Trait { fn_def_id, .. } ,
2243
+ ) ,
2244
+ } => tcx
2241
2245
. associated_types_for_impl_traits_in_associated_fn ( fn_def_id)
2242
2246
. iter ( )
2243
2247
. map ( |def_id| tcx. associated_item ( * def_id) )
2244
2248
. collect ( ) ,
2249
+ _ => vec ! [ impl_ty] ,
2245
2250
} ;
2246
2251
2247
2252
for impl_ty in impl_tys_to_install {
0 commit comments