@@ -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
@@ -654,7 +656,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
654
656
cause. span,
655
657
E0053 ,
656
658
"method `{}` has an incompatible return type for trait" ,
657
- trait_m. name
659
+ trait_m. name( )
658
660
) ;
659
661
infcx. err_ctxt ( ) . note_type_err (
660
662
& mut diag,
@@ -1032,11 +1034,11 @@ fn report_trait_method_mismatch<'tcx>(
1032
1034
impl_err_span,
1033
1035
E0053 ,
1034
1036
"method `{}` has an incompatible type for trait" ,
1035
- trait_m. name
1037
+ trait_m. name( )
1036
1038
) ;
1037
1039
match & terr {
1038
1040
TypeError :: ArgumentMutability ( 0 ) | TypeError :: ArgumentSorts ( _, 0 )
1039
- if trait_m. fn_has_self_parameter =>
1041
+ if trait_m. is_method ( ) =>
1040
1042
{
1041
1043
let ty = trait_sig. inputs ( ) [ 0 ] ;
1042
1044
let sugg = get_self_string ( ty, |ty| ty == impl_trait_ref. self_ty ( ) ) ;
@@ -1255,7 +1257,7 @@ fn compare_self_type<'tcx>(
1255
1257
get_self_string ( self_arg_ty, can_eq_self)
1256
1258
} ;
1257
1259
1258
- match ( trait_m. fn_has_self_parameter , impl_m. fn_has_self_parameter ) {
1260
+ match ( trait_m. is_method ( ) , impl_m. is_method ( ) ) {
1259
1261
( false , false ) | ( true , true ) => { }
1260
1262
1261
1263
( false , true ) => {
@@ -1266,14 +1268,14 @@ fn compare_self_type<'tcx>(
1266
1268
impl_m_span,
1267
1269
E0185 ,
1268
1270
"method `{}` has a `{}` declaration in the impl, but not in the trait" ,
1269
- trait_m. name,
1271
+ trait_m. name( ) ,
1270
1272
self_descr
1271
1273
) ;
1272
1274
err. span_label ( impl_m_span, format ! ( "`{self_descr}` used in impl" ) ) ;
1273
1275
if let Some ( span) = tcx. hir_span_if_local ( trait_m. def_id ) {
1274
1276
err. span_label ( span, format ! ( "trait method declared without `{self_descr}`" ) ) ;
1275
1277
} else {
1276
- err. note_trait_signature ( trait_m. name , trait_m. signature ( tcx) ) ;
1278
+ err. note_trait_signature ( trait_m. name ( ) , trait_m. signature ( tcx) ) ;
1277
1279
}
1278
1280
return Err ( err. emit_unless ( delay) ) ;
1279
1281
}
@@ -1286,14 +1288,14 @@ fn compare_self_type<'tcx>(
1286
1288
impl_m_span,
1287
1289
E0186 ,
1288
1290
"method `{}` has a `{}` declaration in the trait, but not in the impl" ,
1289
- trait_m. name,
1291
+ trait_m. name( ) ,
1290
1292
self_descr
1291
1293
) ;
1292
1294
err. span_label ( impl_m_span, format ! ( "expected `{self_descr}` in impl" ) ) ;
1293
1295
if let Some ( span) = tcx. hir_span_if_local ( trait_m. def_id ) {
1294
1296
err. span_label ( span, format ! ( "`{self_descr}` used in trait" ) ) ;
1295
1297
} else {
1296
- err. note_trait_signature ( trait_m. name , trait_m. signature ( tcx) ) ;
1298
+ err. note_trait_signature ( trait_m. name ( ) , trait_m. signature ( tcx) ) ;
1297
1299
}
1298
1300
1299
1301
return Err ( err. emit_unless ( delay) ) ;
@@ -1363,7 +1365,7 @@ fn compare_number_of_generics<'tcx>(
1363
1365
let mut err_occurred = None ;
1364
1366
for ( kind, trait_count, impl_count) in matchings {
1365
1367
if impl_count != trait_count {
1366
- let arg_spans = |kind : ty:: AssocKind , generics : & hir:: Generics < ' _ > | {
1368
+ let arg_spans = |item : & ty:: AssocItem , generics : & hir:: Generics < ' _ > | {
1367
1369
let mut spans = generics
1368
1370
. params
1369
1371
. iter ( )
@@ -1373,7 +1375,7 @@ fn compare_number_of_generics<'tcx>(
1373
1375
} => {
1374
1376
// A fn can have an arbitrary number of extra elided lifetimes for the
1375
1377
// same signature.
1376
- !matches ! ( kind , ty :: AssocKind :: Fn )
1378
+ !item . is_fn ( )
1377
1379
}
1378
1380
_ => true ,
1379
1381
} )
@@ -1386,7 +1388,7 @@ fn compare_number_of_generics<'tcx>(
1386
1388
} ;
1387
1389
let ( trait_spans, impl_trait_spans) = if let Some ( def_id) = trait_. def_id . as_local ( ) {
1388
1390
let trait_item = tcx. hir_expect_trait_item ( def_id) ;
1389
- let arg_spans: Vec < Span > = arg_spans ( trait_. kind , trait_item. generics ) ;
1391
+ let arg_spans: Vec < Span > = arg_spans ( & trait_, trait_item. generics ) ;
1390
1392
let impl_trait_spans: Vec < Span > = trait_item
1391
1393
. generics
1392
1394
. params
@@ -1412,7 +1414,7 @@ fn compare_number_of_generics<'tcx>(
1412
1414
_ => None ,
1413
1415
} )
1414
1416
. collect ( ) ;
1415
- let spans = arg_spans ( impl_. kind , impl_item. generics ) ;
1417
+ let spans = arg_spans ( & impl_, impl_item. generics ) ;
1416
1418
let span = spans. first ( ) . copied ( ) ;
1417
1419
1418
1420
let mut err = tcx. dcx ( ) . struct_span_err (
@@ -1421,7 +1423,7 @@ fn compare_number_of_generics<'tcx>(
1421
1423
"{} `{}` has {} {kind} parameter{} but its trait \
1422
1424
declaration has {} {kind} parameter{}",
1423
1425
item_kind,
1424
- trait_. name,
1426
+ trait_. name( ) ,
1425
1427
impl_count,
1426
1428
pluralize!( impl_count) ,
1427
1429
trait_count,
@@ -1512,7 +1514,7 @@ fn compare_number_of_method_arguments<'tcx>(
1512
1514
impl_span,
1513
1515
E0050 ,
1514
1516
"method `{}` has {} but the declaration in trait `{}` has {}" ,
1515
- trait_m. name,
1517
+ trait_m. name( ) ,
1516
1518
potentially_plural_count( impl_number_args, "parameter" ) ,
1517
1519
tcx. def_path_str( trait_m. def_id) ,
1518
1520
trait_number_args
@@ -1527,7 +1529,7 @@ fn compare_number_of_method_arguments<'tcx>(
1527
1529
) ,
1528
1530
) ;
1529
1531
} else {
1530
- err. note_trait_signature ( trait_m. name , trait_m. signature ( tcx) ) ;
1532
+ err. note_trait_signature ( trait_m. name ( ) , trait_m. signature ( tcx) ) ;
1531
1533
}
1532
1534
1533
1535
err. span_label (
@@ -1581,7 +1583,7 @@ fn compare_synthetic_generics<'tcx>(
1581
1583
impl_span,
1582
1584
E0643 ,
1583
1585
"method `{}` has incompatible signature for trait" ,
1584
- trait_m. name
1586
+ trait_m. name( )
1585
1587
) ;
1586
1588
err. span_label ( trait_span, "declaration in trait here" ) ;
1587
1589
if impl_synthetic {
@@ -1703,7 +1705,7 @@ fn compare_generic_param_kinds<'tcx>(
1703
1705
trait_item : ty:: AssocItem ,
1704
1706
delay : bool ,
1705
1707
) -> Result < ( ) , ErrorGuaranteed > {
1706
- assert_eq ! ( impl_item. kind , trait_item. kind ) ;
1708
+ assert_eq ! ( impl_item. as_tag ( ) , trait_item. as_tag ( ) ) ;
1707
1709
1708
1710
let ty_const_params_of = |def_id| {
1709
1711
tcx. generics_of ( def_id) . own_params . iter ( ) . filter ( |param| {
@@ -1741,7 +1743,7 @@ fn compare_generic_param_kinds<'tcx>(
1741
1743
E0053 ,
1742
1744
"{} `{}` has an incompatible generic parameter for trait `{}`" ,
1743
1745
impl_item. descr( ) ,
1744
- trait_item. name,
1746
+ trait_item. name( ) ,
1745
1747
& tcx. def_path_str( tcx. parent( trait_item. def_id) )
1746
1748
) ;
1747
1749
@@ -1877,7 +1879,7 @@ fn compare_const_predicate_entailment<'tcx>(
1877
1879
cause. span,
1878
1880
E0326 ,
1879
1881
"implemented const `{}` has an incompatible type for trait" ,
1880
- trait_ct. name
1882
+ trait_ct. name( )
1881
1883
) ;
1882
1884
1883
1885
let trait_c_span = trait_ct. def_id . as_local ( ) . map ( |trait_ct_def_id| {
@@ -2235,16 +2237,19 @@ fn param_env_with_gat_bounds<'tcx>(
2235
2237
// of the RPITITs associated with the same body. This is because checking
2236
2238
// the item bounds of RPITITs often involves nested RPITITs having to prove
2237
2239
// bounds about themselves.
2238
- let impl_tys_to_install = match impl_ty. opt_rpitit_info {
2239
- None => vec ! [ impl_ty] ,
2240
- Some (
2241
- ty:: ImplTraitInTraitData :: Impl { fn_def_id }
2242
- | ty:: ImplTraitInTraitData :: Trait { fn_def_id, .. } ,
2243
- ) => tcx
2240
+ let impl_tys_to_install = match impl_ty. kind {
2241
+ ty:: AssocKind :: Type {
2242
+ data :
2243
+ ty:: AssocTypeData :: Rpitit (
2244
+ ty:: ImplTraitInTraitData :: Impl { fn_def_id }
2245
+ | ty:: ImplTraitInTraitData :: Trait { fn_def_id, .. } ,
2246
+ ) ,
2247
+ } => tcx
2244
2248
. associated_types_for_impl_traits_in_associated_fn ( fn_def_id)
2245
2249
. iter ( )
2246
2250
. map ( |def_id| tcx. associated_item ( * def_id) )
2247
2251
. collect ( ) ,
2252
+ _ => vec ! [ impl_ty] ,
2248
2253
} ;
2249
2254
2250
2255
for impl_ty in impl_tys_to_install {
0 commit comments