Skip to content

Commit 5295de1

Browse files
committed
Add opt_rpitit_info query
1 parent 5423745 commit 5295de1

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

compiler/rustc_middle/src/hir/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ pub fn provide(providers: &mut Providers) {
177177
}
178178
};
179179
providers.opt_def_kind = |tcx, def_id| tcx.hir().opt_def_kind(def_id.expect_local());
180+
providers.opt_rpitit_info = |_, _| None;
180181
providers.all_local_trait_impls = |tcx, ()| &tcx.resolutions(()).trait_impls;
181182
providers.expn_that_defined = |tcx, id| {
182183
let id = id.expect_local();

compiler/rustc_middle/src/query/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,14 @@ rustc_queries! {
11441144
separate_provide_extern
11451145
}
11461146

1147+
/// The `opt_rpitit_info` query returns the pair of the def id of the function where the RPIT
1148+
/// is defined and the opaque def id if any.
1149+
query opt_rpitit_info(def_id: DefId) -> Option<ty::ImplTraitInTraitData> {
1150+
desc { |tcx| "opt_rpitit_info `{}`", tcx.def_path_str(def_id) }
1151+
cache_on_disk_if { def_id.is_local() }
1152+
feedable
1153+
}
1154+
11471155
/// Gets the span for the definition.
11481156
query def_span(def_id: DefId) -> Span {
11491157
desc { |tcx| "looking up span for `{}`", tcx.def_path_str(def_id) }

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,6 +2071,12 @@ pub enum ImplOverlapKind {
20712071
Issue33140,
20722072
}
20732073

2074+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
2075+
pub enum ImplTraitInTraitData {
2076+
Trait { fn_def_id: DefId, opaque_def_id: DefId },
2077+
Impl { fn_def_id: DefId },
2078+
}
2079+
20742080
impl<'tcx> TyCtxt<'tcx> {
20752081
pub fn typeck_body(self, body: hir::BodyId) -> &'tcx TypeckResults<'tcx> {
20762082
self.typeck(self.hir().body_owner_def_id(body))

0 commit comments

Comments
 (0)