diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-02-06 08:57:34 +0000 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-02-15 20:22:41 +0000 |
| commit | a32d39274113c30d8e367f729028e605ccbc6313 (patch) | |
| tree | d6bbbce134de8c7a734746cfab544d8be24d5b7a /compiler/rustc_middle | |
| parent | 236ddf36b37cba82cdbfbab7fe9991d113ececf8 (diff) | |
| download | rust-a32d39274113c30d8e367f729028e605ccbc6313.tar.gz rust-a32d39274113c30d8e367f729028e605ccbc6313.zip | |
Copy `ty::AssocItem` all other the place
Diffstat (limited to 'compiler/rustc_middle')
| -rw-r--r-- | compiler/rustc_middle/src/query/mod.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/traits/specialization_graph.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/assoc.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 2 |
4 files changed, 10 insertions, 14 deletions
diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 420c32ce477..a387b845fae 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -736,7 +736,7 @@ rustc_queries! { } /// Collects the associated items defined on a trait or impl. - query associated_items(key: DefId) -> &'tcx ty::AssocItems<'tcx> { + query associated_items(key: DefId) -> &'tcx ty::AssocItems { arena_cache desc { |tcx| "collecting associated items of `{}`", tcx.def_path_str(key) } } diff --git a/compiler/rustc_middle/src/traits/specialization_graph.rs b/compiler/rustc_middle/src/traits/specialization_graph.rs index aad5b2fbe07..c90d422df90 100644 --- a/compiler/rustc_middle/src/traits/specialization_graph.rs +++ b/compiler/rustc_middle/src/traits/specialization_graph.rs @@ -133,11 +133,7 @@ impl Node { /// /// If this returns `None`, the item can potentially still be found in /// parents of this node. - pub fn item<'tcx>( - &self, - tcx: TyCtxt<'tcx>, - trait_item_def_id: DefId, - ) -> Option<&'tcx ty::AssocItem> { + pub fn item<'tcx>(&self, tcx: TyCtxt<'tcx>, trait_item_def_id: DefId) -> Option<ty::AssocItem> { match *self { Node::Trait(_) => Some(tcx.associated_item(trait_item_def_id)), Node::Impl(impl_def_id) => { @@ -239,7 +235,7 @@ impl<'tcx> Ancestors<'tcx> { } } - Some(LeafDef { item: *item, defining_node: node, finalizing_node }) + Some(LeafDef { item, defining_node: node, finalizing_node }) } else { // Item not mentioned. This "finalizes" any defaulted item provided by an ancestor. finalizing_node = Some(node); diff --git a/compiler/rustc_middle/src/ty/assoc.rs b/compiler/rustc_middle/src/ty/assoc.rs index 71cecfb558f..ace96492363 100644 --- a/compiler/rustc_middle/src/ty/assoc.rs +++ b/compiler/rustc_middle/src/ty/assoc.rs @@ -129,13 +129,13 @@ impl std::fmt::Display for AssocKind { /// it is relatively expensive. Instead, items are indexed by `Symbol` and hygienic comparison is /// done only on items with the same name. #[derive(Debug, Clone, PartialEq, HashStable)] -pub struct AssocItems<'tcx> { - items: SortedIndexMultiMap<u32, Symbol, &'tcx ty::AssocItem>, +pub struct AssocItems { + items: SortedIndexMultiMap<u32, Symbol, ty::AssocItem>, } -impl<'tcx> AssocItems<'tcx> { +impl AssocItems { /// Constructs an `AssociatedItems` map from a series of `ty::AssocItem`s in definition order. - pub fn new(items_in_def_order: impl IntoIterator<Item = &'tcx ty::AssocItem>) -> Self { + pub fn new(items_in_def_order: impl IntoIterator<Item = ty::AssocItem>) -> Self { let items = items_in_def_order.into_iter().map(|item| (item.name, item)).collect(); AssocItems { items } } @@ -145,7 +145,7 @@ impl<'tcx> AssocItems<'tcx> { /// New code should avoid relying on definition order. If you need a particular associated item /// for a known trait, make that trait a lang item instead of indexing this array. pub fn in_definition_order(&self) -> impl '_ + Iterator<Item = &ty::AssocItem> { - self.items.iter().map(|(_, v)| *v) + self.items.iter().map(|(_, v)| v) } pub fn len(&self) -> usize { @@ -157,7 +157,7 @@ impl<'tcx> AssocItems<'tcx> { &self, name: Symbol, ) -> impl '_ + Iterator<Item = &ty::AssocItem> { - self.items.get_by_key(name).copied() + self.items.get_by_key(name) } /// Returns the associated item with the given name and `AssocKind`, if one exists. diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 7d9396ecd65..9913fc0a3c5 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -2198,7 +2198,7 @@ impl<'tcx> TyCtxt<'tcx> { Some(Ident::new(def, span)) } - pub fn opt_associated_item(self, def_id: DefId) -> Option<&'tcx AssocItem> { + pub fn opt_associated_item(self, def_id: DefId) -> Option<AssocItem> { if let DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy = self.def_kind(def_id) { Some(self.associated_item(def_id)) } else { |
