Skip to content

Commit b47fc78

Browse files
authored
Rollup merge of rust-lang#105255 - cjgillot:issue-105197, r=compiler-errors
Make nested RPIT inherit the parent opaque's generics. Fixes rust-lang#105197 r? `@compiler-errors`
2 parents ee74286 + e2d41f4 commit b47fc78

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

compiler/rustc_hir_analysis/src/collect/generics_of.rs

+1-15
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use hir::{
44
GenericParamKind, HirId, Node,
55
};
66
use rustc_hir as hir;
7-
use rustc_hir::def::DefKind;
87
use rustc_hir::def_id::DefId;
98
use rustc_middle::ty::{self, TyCtxt};
109
use rustc_session::lint;
@@ -143,20 +142,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
143142
Some(tcx.typeck_root_def_id(def_id))
144143
}
145144
Node::Item(item) => match item.kind {
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, .. }) => {
145+
ItemKind::OpaqueTy(hir::OpaqueTy { .. }) => {
160146
let parent_id = tcx.hir().get_parent_item(hir_id);
161147
assert_ne!(parent_id, hir::CRATE_OWNER_ID);
162148
debug!("generics_of: parent of opaque ty {:?} is {:?}", def_id, parent_id);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// check-pass
2+
// edition: 2021
3+
4+
#![feature(async_fn_in_trait)]
5+
#![feature(return_position_impl_trait_in_trait)]
6+
#![allow(incomplete_features)]
7+
8+
use std::future::Future;
9+
use std::marker::PhantomData;
10+
11+
trait Lockable<K, V> {
12+
async fn lock_all_entries(&self) -> impl Future<Output = Guard<'_>>;
13+
}
14+
15+
struct Guard<'a>(PhantomData<&'a ()>);
16+
17+
fn main() {}

0 commit comments

Comments
 (0)