@@ -1015,49 +1015,21 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
1015
1015
assoc_ty_def ( selcx, impl_data. impl_def_id , obligation. predicate . item_def_id )
1016
1016
. map_err ( |ErrorReported | ( ) ) ?;
1017
1017
1018
- let is_default = if node_item. node . is_from_trait ( ) {
1019
- // If true, the impl inherited a `type Foo = Bar`
1020
- // given in the trait, which is implicitly default.
1021
- // Otherwise, the impl did not specify `type` and
1022
- // neither did the trait:
1023
- //
1024
- // ```rust
1025
- // trait Foo { type T; }
1026
- // impl Foo for Bar { }
1027
- // ```
1028
- //
1029
- // This is an error, but it will be
1030
- // reported in `check_impl_items_against_trait`.
1031
- // We accept it here but will flag it as
1032
- // an error when we confirm the candidate
1033
- // (which will ultimately lead to `normalize_to_error`
1034
- // being invoked).
1035
- false
1018
+ if node_item. is_final ( ) {
1019
+ // Non-specializable items are always projectable.
1020
+ true
1036
1021
} else {
1037
- // If we're looking at a trait *impl*, the item is
1038
- // specializable if the impl or the item are marked
1039
- // `default`.
1040
- node_item. item . defaultness . is_default ( )
1041
- || super :: util:: impl_is_default ( selcx. tcx ( ) , node_item. node . def_id ( ) )
1042
- } ;
1043
-
1044
- match is_default {
1045
- // Non-specializable items are always projectable
1046
- false => true ,
1047
-
1048
1022
// Only reveal a specializable default if we're past type-checking
1049
1023
// and the obligation is monomorphic, otherwise passes such as
1050
1024
// transmute checking and polymorphic MIR optimizations could
1051
1025
// get a result which isn't correct for all monomorphizations.
1052
- true if obligation. param_env . reveal == Reveal :: All => {
1026
+ if obligation. param_env . reveal == Reveal :: All {
1053
1027
// NOTE(eddyb) inference variables can resolve to parameters, so
1054
1028
// assume `poly_trait_ref` isn't monomorphic, if it contains any.
1055
1029
let poly_trait_ref =
1056
1030
selcx. infcx ( ) . resolve_vars_if_possible ( & poly_trait_ref) ;
1057
1031
!poly_trait_ref. needs_infer ( ) && !poly_trait_ref. needs_subst ( )
1058
- }
1059
-
1060
- true => {
1032
+ } else {
1061
1033
debug ! (
1062
1034
"assemble_candidates_from_impls: not eligible due to default: \
1063
1035
assoc_ty={} predicate={}",
@@ -1422,7 +1394,8 @@ fn confirm_impl_candidate<'cx, 'tcx>(
1422
1394
return Progress { ty : tcx. types . err , obligations : nested } ;
1423
1395
}
1424
1396
let substs = obligation. predicate . substs . rebase_onto ( tcx, trait_def_id, substs) ;
1425
- let substs = translate_substs ( selcx. infcx ( ) , param_env, impl_def_id, substs, assoc_ty. node ) ;
1397
+ let substs =
1398
+ translate_substs ( selcx. infcx ( ) , param_env, impl_def_id, substs, assoc_ty. defining_node ) ;
1426
1399
let ty = if let ty:: AssocKind :: OpaqueTy = assoc_ty. item . kind {
1427
1400
let item_substs = InternalSubsts :: identity_for_item ( tcx, assoc_ty. item . def_id ) ;
1428
1401
tcx. mk_opaque ( assoc_ty. item . def_id , item_substs)
@@ -1447,7 +1420,7 @@ fn assoc_ty_def(
1447
1420
selcx : & SelectionContext < ' _ , ' _ > ,
1448
1421
impl_def_id : DefId ,
1449
1422
assoc_ty_def_id : DefId ,
1450
- ) -> Result < specialization_graph:: NodeItem < ty :: AssocItem > , ErrorReported > {
1423
+ ) -> Result < specialization_graph:: LeafDef , ErrorReported > {
1451
1424
let tcx = selcx. tcx ( ) ;
1452
1425
let assoc_ty_name = tcx. associated_item ( assoc_ty_def_id) . ident ;
1453
1426
let trait_def_id = tcx. impl_trait_ref ( impl_def_id) . unwrap ( ) . def_id ;
@@ -1464,9 +1437,10 @@ fn assoc_ty_def(
1464
1437
if matches ! ( item. kind, ty:: AssocKind :: Type | ty:: AssocKind :: OpaqueTy )
1465
1438
&& tcx. hygienic_eq ( item. ident , assoc_ty_name, trait_def_id)
1466
1439
{
1467
- return Ok ( specialization_graph:: NodeItem {
1468
- node : specialization_graph:: Node :: Impl ( impl_def_id) ,
1440
+ return Ok ( specialization_graph:: LeafDef {
1469
1441
item : * item,
1442
+ defining_node : impl_node,
1443
+ finalizing_node : if item. defaultness . is_default ( ) { None } else { Some ( impl_node) } ,
1470
1444
} ) ;
1471
1445
}
1472
1446
}
0 commit comments