Skip to content

Commit fb24778

Browse files
Resolve self type alias in impl for RTN
1 parent c2d4667 commit fb24778

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -1965,7 +1965,25 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
19651965
};
19661966
(bound_vars, assoc_item.def_id, item_segment)
19671967
}
1968-
Res::SelfTyAlias { is_trait_impl: true, .. } => todo!(),
1968+
Res::SelfTyAlias { alias_to: impl_def_id, is_trait_impl: true, .. } => {
1969+
let hir::ItemKind::Impl(hir::Impl { of_trait: Some(trait_ref), .. }) =
1970+
self.tcx.hir_node_by_def_id(impl_def_id.expect_local()).expect_item().kind
1971+
else {
1972+
return;
1973+
};
1974+
let Some(trait_def_id) = trait_ref.trait_def_id() else {
1975+
return;
1976+
};
1977+
let Some((bound_vars, assoc_item)) = BoundVarContext::supertrait_hrtb_vars(
1978+
self.tcx,
1979+
trait_def_id,
1980+
item_segment.ident,
1981+
ty::AssocKind::Fn,
1982+
) else {
1983+
return;
1984+
};
1985+
(bound_vars, assoc_item.def_id, item_segment)
1986+
}
19691987
_ => return,
19701988
}
19711989
}

tests/ui/associated-type-bounds/return-type-notation/path-self-qself.rs

+11
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,15 @@ trait Bar: Foo {
1313
Self::method(..): Send;
1414
}
1515

16+
fn is_send(_: impl Send) {}
17+
18+
impl<T: Foo> Bar for T {
19+
fn other()
20+
where
21+
Self::method(..): Send,
22+
{
23+
is_send(Self::method());
24+
}
25+
}
26+
1627
fn main() {}

0 commit comments

Comments
 (0)