summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_middle/src/hir/map
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /compiler/rustc_middle/src/hir/map
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_middle/src/hir/map')
-rw-r--r--compiler/rustc_middle/src/hir/map/mod.rs30
1 files changed, 22 insertions, 8 deletions
diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs
index 4af2d83e9..58c0c6bab 100644
--- a/compiler/rustc_middle/src/hir/map/mod.rs
+++ b/compiler/rustc_middle/src/hir/map/mod.rs
@@ -6,7 +6,7 @@ use rustc_ast as ast;
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::svh::Svh;
-use rustc_data_structures::sync::{par_for_each_in, DynSend, DynSync};
+use rustc_data_structures::sync::{par_for_each_in, try_par_for_each_in, DynSend, DynSync};
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId, LOCAL_CRATE};
use rustc_hir::definitions::{DefKey, DefPath, DefPathData, DefPathHash};
@@ -16,7 +16,7 @@ use rustc_index::Idx;
use rustc_middle::hir::nested_filter;
use rustc_span::def_id::StableCrateId;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
-use rustc_span::Span;
+use rustc_span::{ErrorGuaranteed, Span};
use rustc_target::spec::abi::Abi;
#[inline]
@@ -240,7 +240,7 @@ impl<'hir> Map<'hir> {
Node::Field(_) => DefKind::Field,
Node::Expr(expr) => match expr.kind {
ExprKind::Closure(Closure { movability: None, .. }) => DefKind::Closure,
- ExprKind::Closure(Closure { movability: Some(_), .. }) => DefKind::Generator,
+ ExprKind::Closure(Closure { movability: Some(_), .. }) => DefKind::Coroutine,
_ => bug!("def_kind: unsupported node: {}", self.node_to_string(hir_id)),
},
Node::GenericParam(param) => match param.kind {
@@ -445,7 +445,7 @@ impl<'hir> Map<'hir> {
}
DefKind::InlineConst => BodyOwnerKind::Const { inline: true },
DefKind::Ctor(..) | DefKind::Fn | DefKind::AssocFn => BodyOwnerKind::Fn,
- DefKind::Closure | DefKind::Generator => BodyOwnerKind::Closure,
+ DefKind::Closure | DefKind::Coroutine => BodyOwnerKind::Closure,
DefKind::Static(mt) => BodyOwnerKind::Static(mt),
dk => bug!("{:?} is not a body node: {:?}", def_id, dk),
}
@@ -632,6 +632,17 @@ impl<'hir> Map<'hir> {
})
}
+ #[inline]
+ pub fn try_par_for_each_module(
+ self,
+ f: impl Fn(LocalModDefId) -> Result<(), ErrorGuaranteed> + DynSend + DynSync,
+ ) -> Result<(), ErrorGuaranteed> {
+ let crate_items = self.tcx.hir_crate_items(());
+ try_par_for_each_in(&crate_items.submodules[..], |module| {
+ f(LocalModDefId::new_unchecked(module.def_id))
+ })
+ }
+
/// Returns an iterator for the nodes in the ancestor tree of the `current_id`
/// until the crate root is reached. Prefer this over your own loop using `parent_id`.
#[inline]
@@ -970,12 +981,15 @@ impl<'hir> Map<'hir> {
// SyntaxContext of the visibility.
sig.span.find_ancestor_in_same_ctxt(*outer_span).unwrap_or(*outer_span)
}
+ // Impls, including their where clauses.
+ Node::Item(Item {
+ kind: ItemKind::Impl(Impl { generics, .. }),
+ span: outer_span,
+ ..
+ }) => until_within(*outer_span, generics.where_clause_span),
// Constants and Statics.
Node::Item(Item {
- kind:
- ItemKind::Const(ty, ..)
- | ItemKind::Static(ty, ..)
- | ItemKind::Impl(Impl { self_ty: ty, .. }),
+ kind: ItemKind::Const(ty, ..) | ItemKind::Static(ty, ..),
span: outer_span,
..
})