@@ -1015,49 +1015,21 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
10151015 assoc_ty_def ( selcx, impl_data. impl_def_id , obligation. predicate . item_def_id )
10161016 . map_err ( |ErrorReported | ( ) ) ?;
10171017
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
10361021 } 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-
10481022 // Only reveal a specializable default if we're past type-checking
10491023 // and the obligation is monomorphic, otherwise passes such as
10501024 // transmute checking and polymorphic MIR optimizations could
10511025 // 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 {
10531027 // NOTE(eddyb) inference variables can resolve to parameters, so
10541028 // assume `poly_trait_ref` isn't monomorphic, if it contains any.
10551029 let poly_trait_ref =
10561030 selcx. infcx ( ) . resolve_vars_if_possible ( & poly_trait_ref) ;
10571031 !poly_trait_ref. needs_infer ( ) && !poly_trait_ref. needs_subst ( )
1058- }
1059-
1060- true => {
1032+ } else {
10611033 debug ! (
10621034 "assemble_candidates_from_impls: not eligible due to default: \
10631035 assoc_ty={} predicate={}",
@@ -1422,7 +1394,8 @@ fn confirm_impl_candidate<'cx, 'tcx>(
14221394 return Progress { ty : tcx. types . err , obligations : nested } ;
14231395 }
14241396 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 ) ;
14261399 let ty = if let ty:: AssocKind :: OpaqueTy = assoc_ty. item . kind {
14271400 let item_substs = InternalSubsts :: identity_for_item ( tcx, assoc_ty. item . def_id ) ;
14281401 tcx. mk_opaque ( assoc_ty. item . def_id , item_substs)
@@ -1447,7 +1420,7 @@ fn assoc_ty_def(
14471420 selcx : & SelectionContext < ' _ , ' _ > ,
14481421 impl_def_id : DefId ,
14491422 assoc_ty_def_id : DefId ,
1450- ) -> Result < specialization_graph:: NodeItem < ty :: AssocItem > , ErrorReported > {
1423+ ) -> Result < specialization_graph:: LeafDef , ErrorReported > {
14511424 let tcx = selcx. tcx ( ) ;
14521425 let assoc_ty_name = tcx. associated_item ( assoc_ty_def_id) . ident ;
14531426 let trait_def_id = tcx. impl_trait_ref ( impl_def_id) . unwrap ( ) . def_id ;
@@ -1464,9 +1437,10 @@ fn assoc_ty_def(
14641437 if matches ! ( item. kind, ty:: AssocKind :: Type | ty:: AssocKind :: OpaqueTy )
14651438 && tcx. hygienic_eq ( item. ident , assoc_ty_name, trait_def_id)
14661439 {
1467- return Ok ( specialization_graph:: NodeItem {
1468- node : specialization_graph:: Node :: Impl ( impl_def_id) ,
1440+ return Ok ( specialization_graph:: LeafDef {
14691441 item : * item,
1442+ defining_node : impl_node,
1443+ finalizing_node : if item. defaultness . is_default ( ) { None } else { Some ( impl_node) } ,
14701444 } ) ;
14711445 }
14721446 }
0 commit comments