Skip to content

Commit 12fe21b

Browse files
committed
Delegation: support generics in associated items
1 parent ac0bd3c commit 12fe21b

19 files changed

+743
-455
lines changed

compiler/rustc_hir_analysis/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ hir_analysis_must_implement_not_function_span_note = required by this annotation
316316
hir_analysis_must_implement_one_of_attribute = the `#[rustc_must_implement_one_of]` attribute must be used with at least 2 args
317317
318318
hir_analysis_not_supported_delegation =
319-
{$descr} is not supported yet
319+
{$descr}
320320
.label = callee defined here
321321
322322
hir_analysis_only_current_traits_adt = `{$name}` is not defined in the current crate

compiler/rustc_hir_analysis/src/collect/generics_of.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
5656
}
5757

5858
// For a delegation item inherit generics from callee.
59-
if let Some(sig_id) = tcx.hir().opt_delegation_sig_id(def_id)
60-
&& let Some(generics) = inherit_generics_for_delegation_item(tcx, def_id, sig_id)
61-
{
62-
return generics;
59+
if let Some(sig_id) = tcx.hir().opt_delegation_sig_id(def_id) {
60+
return inherit_generics_for_delegation_item(tcx, def_id, sig_id);
6361
}
6462

6563
let hir_id = tcx.local_def_id_to_hir_id(def_id);

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::collect::ItemCtxt;
33
use crate::constrained_generic_params as cgp;
44
use crate::delegation::inherit_predicates_for_delegation_item;
55
use crate::hir_ty_lowering::{HirTyLowerer, OnlySelfBounds, PredicateFilter, RegionInferReason};
6-
use crate::hir_ty_lowering::{HirTyLowerer, OnlySelfBounds, PredicateFilter};
76
use hir::{HirId, Node};
87
use rustc_data_structures::fx::FxIndexSet;
98
use rustc_hir as hir;
@@ -117,10 +116,8 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
117116
}
118117

119118
// For a delegation item inherit predicates from callee.
120-
if let Some(sig_id) = tcx.hir().opt_delegation_sig_id(def_id)
121-
&& let Some(predicates) = inherit_predicates_for_delegation_item(tcx, def_id, sig_id)
122-
{
123-
return predicates;
119+
if let Some(sig_id) = tcx.hir().opt_delegation_sig_id(def_id) {
120+
return inherit_predicates_for_delegation_item(tcx, def_id, sig_id);
124121
}
125122

126123
let hir_id = tcx.local_def_id_to_hir_id(def_id);

0 commit comments

Comments
 (0)