|
1 | 1 | use rustc_attr_data_structures::{AttributeKind, find_attr};
|
2 | | -use rustc_data_structures::fx::FxIndexMap; |
3 | 2 | use rustc_data_structures::sorted_map::SortedIndexMultiMap;
|
4 | 3 | use rustc_hir as hir;
|
5 | 4 | use rustc_hir::def::{DefKind, Namespace};
|
@@ -287,22 +286,21 @@ impl AssocItems {
|
287 | 286 | }
|
288 | 287 | }
|
289 | 288 |
|
290 | | -#[derive(Debug, Clone, PartialEq, Encodable, Decodable, HashStable)] |
291 | | -pub struct AssocTyForImplTraitInTraitOrImpl(pub FxIndexMap<DefId, Vec<DefId>>); |
292 | | - |
293 | | -/// Given an `fn_def_id` of a trait or a trait implementation: |
294 | | -/// |
295 | | -/// if `fn_def_id` is a function defined inside a trait, then it synthesizes |
296 | | -/// a new def id corresponding to a new associated type for each return- |
297 | | -/// position `impl Trait` in the signature. |
298 | | -/// |
299 | | -/// if `fn_def_id` is a function inside of an impl, then for each synthetic |
300 | | -/// associated type generated for the corresponding trait function described |
301 | | -/// above, synthesize a corresponding associated type in the impl. |
302 | | -pub fn associated_types_for_impl_traits_in_associated_fn( |
303 | | - tcx: TyCtxt<'_>, |
304 | | - fn_def_id: DefId, |
305 | | -) -> &'_ [DefId] { |
306 | | - let parent_def_id = tcx.parent(fn_def_id); |
307 | | - &tcx.associated_types_for_impl_traits_in_trait_or_impl(parent_def_id).0[&fn_def_id] |
| 289 | +impl<'tcx> TyCtxt<'tcx> { |
| 290 | + /// Given an `fn_def_id` of a trait or a trait implementation: |
| 291 | + /// |
| 292 | + /// if `fn_def_id` is a function defined inside a trait, then it synthesizes |
| 293 | + /// a new def id corresponding to a new associated type for each return- |
| 294 | + /// position `impl Trait` in the signature. |
| 295 | + /// |
| 296 | + /// if `fn_def_id` is a function inside of an impl, then for each synthetic |
| 297 | + /// associated type generated for the corresponding trait function described |
| 298 | + /// above, synthesize a corresponding associated type in the impl. |
| 299 | + pub fn associated_types_for_impl_traits_in_associated_fn( |
| 300 | + self, |
| 301 | + fn_def_id: DefId, |
| 302 | + ) -> &'tcx [DefId] { |
| 303 | + let parent_def_id = self.parent(fn_def_id); |
| 304 | + &self.associated_types_for_impl_traits_in_trait_or_impl(parent_def_id)[&fn_def_id] |
| 305 | + } |
308 | 306 | }
|
0 commit comments