Skip to content

Commit 0af4a21

Browse files
committed
Document what is going on in opaque_types_defined_by
1 parent cb161e7 commit 0af4a21

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

compiler/rustc_ty_utils/src/opaque_types.rs

+3
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,17 @@ fn opaque_types_defined_by<'tcx>(tcx: TyCtxt<'tcx>, item: LocalDefId) -> &'tcx [
168168
DefKind::Fn | DefKind::AssocFn | DefKind::AssocTy | DefKind::AssocConst => {
169169
let mut collector = OpaqueTypeCollector::new(tcx, item);
170170
match kind {
171+
// Walk over the signature of the function-like to find the opaques.
171172
DefKind::AssocFn | DefKind::Fn => {
172173
let ty_sig = tcx.fn_sig(item).subst_identity();
173174
let hir_sig = tcx.hir().get_by_def_id(item).fn_sig().unwrap();
175+
// Walk over the inputs and outputs manually in order to get good spans for them.
174176
collector.visit_spanned(hir_sig.decl.output.span(), ty_sig.output());
175177
for (hir, ty) in hir_sig.decl.inputs.iter().zip(ty_sig.inputs().iter()) {
176178
collector.visit_spanned(hir.span, ty.map_bound(|x| *x));
177179
}
178180
}
181+
// Walk over the type of the item to find opaques.
179182
DefKind::AssocTy | DefKind::AssocConst => {
180183
let span = match tcx.hir().get_by_def_id(item).ty() {
181184
Some(ty) => ty.span,

0 commit comments

Comments
 (0)