Skip to content

Commit 0a2b55d

Browse files
Revert "Make nested RPITIT inherit the parent opaque's generics." and adjust test
This reverts commit e2d41f4.
1 parent d4203ed commit 0a2b55d

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

compiler/rustc_hir_analysis/src/collect/generics_of.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use hir::{
44
GenericParamKind, HirId, Node,
55
};
66
use rustc_hir as hir;
7+
use rustc_hir::def::DefKind;
78
use rustc_hir::def_id::DefId;
89
use rustc_middle::ty::{self, TyCtxt};
910
use rustc_session::lint;
@@ -142,7 +143,20 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
142143
Some(tcx.typeck_root_def_id(def_id))
143144
}
144145
Node::Item(item) => match item.kind {
145-
ItemKind::OpaqueTy(hir::OpaqueTy { .. }) => {
146+
ItemKind::OpaqueTy(hir::OpaqueTy {
147+
origin:
148+
hir::OpaqueTyOrigin::FnReturn(fn_def_id) | hir::OpaqueTyOrigin::AsyncFn(fn_def_id),
149+
in_trait,
150+
..
151+
}) => {
152+
if in_trait {
153+
assert!(matches!(tcx.def_kind(fn_def_id), DefKind::AssocFn))
154+
} else {
155+
assert!(matches!(tcx.def_kind(fn_def_id), DefKind::AssocFn | DefKind::Fn))
156+
}
157+
Some(fn_def_id.to_def_id())
158+
}
159+
ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::TyAlias, .. }) => {
146160
let parent_id = tcx.hir().get_parent_item(hir_id);
147161
assert_ne!(parent_id, hir::CRATE_OWNER_ID);
148162
debug!("generics_of: parent of opaque ty {:?} is {:?}", def_id, parent_id);

tests/ui/async-await/in-trait/nested-rpit.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
// check-pass
21
// edition: 2021
2+
// known-bug: #105197
3+
// failure-status:101
4+
// dont-check-compiler-stderr
35

46
#![feature(async_fn_in_trait)]
57
#![feature(return_position_impl_trait_in_trait)]

0 commit comments

Comments
 (0)