Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b391494
add ChildExt(::send_signal)
Qelxiros Jun 18, 2025
b64fd13
convert the `optimize` attribute to a new parser
jdonszelmann Mar 9, 2025
5bd918f
vec_deque tests: remove static mut
hkBst Jun 18, 2025
3c418ec
bump rustdoc json format number for pretty print change of attribute
jdonszelmann Jun 18, 2025
021bcb9
fmt tests: remove static mut
hkBst Jun 18, 2025
c6e77b3
Reduce uses of `hir_crate`.
cjgillot Jun 18, 2025
7fa94af
Make feature suggestion more consistent.
cjgillot Jun 18, 2025
d70ec32
move cfg(target_feature) computation into shared place
RalfJung May 10, 2025
cd08652
move -Ctarget-feature handling into shared code
RalfJung May 23, 2025
e46c234
unify two -Ctarget-feature parsers
RalfJung May 11, 2025
8bec5bb
cg_gcc: properly populate cfg(target_features) with -Ctarget-features
RalfJung May 11, 2025
0c4b0f5
line-wrap and extend comments, typos
RalfJung Jun 12, 2025
a50a3b8
various minor target feature cleanups
RalfJung Jun 14, 2025
f45ab4f
Update books
rustbot Jun 19, 2025
7760f8e
add comment to `src/bootstrap/build.rs`
fee1-dead Jun 19, 2025
ede4891
Update compiler/rustc_interface/src/passes.rs
cjgillot Jun 19, 2025
ecdf220
vec tests: remove static mut
hkBst Jun 19, 2025
456c9da
vec_deque alloctests: remove static mut
hkBst Jun 19, 2025
9c22768
atomic tests: remove static mut
hkBst Jun 19, 2025
e14e137
Update library dependencies
tgross35 Jun 19, 2025
bab4ca9
Rollup merge of #138291 - jdonszelmann:optimize-attr, r=oli-obk
tgross35 Jun 20, 2025
c117ebe
Rollup merge of #140920 - RalfJung:target-feature-unification, r=nnet…
tgross35 Jun 20, 2025
e381a14
Rollup merge of #141990 - Qelxiros:141975-unix_send_signal, r=ChrisDe…
tgross35 Jun 20, 2025
52758b7
Rollup merge of #142668 - hkBst:less-static-mut, r=tgross35
tgross35 Jun 20, 2025
dd41c06
Rollup merge of #142687 - cjgillot:less-hir_crate, r=oli-obk
tgross35 Jun 20, 2025
a96e64c
Rollup merge of #142699 - rustbot:docs-update, r=ehuss
tgross35 Jun 20, 2025
1828650
Rollup merge of #142714 - fee1-dead-contrib:push-roxtwrlvtzur, r=Kobzol
tgross35 Jun 20, 2025
bb72cc7
Rollup merge of #142753 - tgross35:library-lockfile, r=Mark-Simulacrum
tgross35 Jun 20, 2025
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reduce uses of hir_crate.
  • Loading branch information
cjgillot committed Jun 18, 2025
commit c6e77b3ba63cc9f824f99b7d356055e22bcf2ae2
6 changes: 5 additions & 1 deletion compiler/rustc_driver_impl/src/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,11 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
}
HirTree => {
debug!("pretty printing HIR tree");
format!("{:#?}", ex.tcx().hir_crate(()))
ex.tcx()
.hir_crate_items(())
.owners()
.map(|owner| format!("{:#?} => {:#?}\n", owner, ex.tcx().hir_owner_nodes(owner)))
.collect()
}
Mir => {
let mut out = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
// Prefetch this to prevent multiple threads from blocking on it later.
// This is needed since the `hir_id_validator::check_crate` call above is not guaranteed
// to use `hir_crate`.
tcx.ensure_done().hir_crate(());
tcx.ensure_done().hir_crate_items(());

let sess = tcx.sess;
sess.time("misc_checking_1", || {
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_lint/src/expect.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use rustc_data_structures::fx::FxHashSet;
use rustc_hir::CRATE_OWNER_ID;
use rustc_middle::lint::LintExpectation;
use rustc_middle::query::Providers;
use rustc_middle::ty::TyCtxt;
Expand All @@ -18,7 +17,7 @@ fn lint_expectations(tcx: TyCtxt<'_>, (): ()) -> Vec<(LintExpectationId, LintExp

let mut expectations = Vec::new();

for owner in std::iter::once(CRATE_OWNER_ID).chain(krate.owners()) {
for owner in krate.owners() {
let lints = tcx.shallow_lint_levels_on(owner);
expectations.extend_from_slice(&lints.expectations);
}
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_middle/src/hir/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,7 @@ impl<'tcx> TyCtxt<'tcx> {
}

/// Returns an iterator of the `DefId`s for all body-owners in this
/// crate. If you would prefer to iterate over the bodies
/// themselves, you can do `self.hir_crate(()).body_ids.iter()`.
/// crate.
#[inline]
pub fn hir_body_owners(self) -> impl Iterator<Item = LocalDefId> {
self.hir_crate_items(()).body_owners.iter().copied()
Expand Down Expand Up @@ -396,12 +395,11 @@ impl<'tcx> TyCtxt<'tcx> {
where
V: Visitor<'tcx>,
{
let krate = self.hir_crate(());
for info in krate.owners.iter() {
if let MaybeOwner::Owner(info) = info {
for attrs in info.attrs.map.values() {
walk_list!(visitor, visit_attribute, *attrs);
}
let krate = self.hir_crate_items(());
for owner in krate.owners() {
let attrs = self.hir_attr_map(owner);
for attrs in attrs.map.values() {
walk_list!(visitor, visit_attribute, *attrs);
}
}
V::Result::output()
Expand Down Expand Up @@ -1225,6 +1223,7 @@ pub(super) fn hir_module_items(tcx: TyCtxt<'_>, module_id: LocalModDefId) -> Mod
..
} = collector;
ModuleItems {
add_root: false,
submodules: submodules.into_boxed_slice(),
free_items: items.into_boxed_slice(),
trait_items: trait_items.into_boxed_slice(),
Expand Down Expand Up @@ -1258,6 +1257,7 @@ pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
} = collector;

ModuleItems {
add_root: true,
submodules: submodules.into_boxed_slice(),
free_items: items.into_boxed_slice(),
trait_items: trait_items.into_boxed_slice(),
Expand Down
10 changes: 7 additions & 3 deletions compiler/rustc_middle/src/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ use crate::ty::{EarlyBinder, ImplSubject, TyCtxt};
/// bodies. The Ids are in visitor order. This is used to partition a pass between modules.
#[derive(Debug, HashStable, Encodable, Decodable)]
pub struct ModuleItems {
/// Whether this represents the whole crate, in which case we need to add `CRATE_OWNER_ID` to
/// the iterators if we want to account for the crate root.
add_root: bool,
submodules: Box<[OwnerId]>,
free_items: Box<[ItemId]>,
trait_items: Box<[TraitItemId]>,
Expand Down Expand Up @@ -60,9 +63,10 @@ impl ModuleItems {
}

pub fn owners(&self) -> impl Iterator<Item = OwnerId> {
self.free_items
.iter()
.map(|id| id.owner_id)
self.add_root
.then_some(CRATE_OWNER_ID)
.into_iter()
.chain(self.free_items.iter().map(|id| id.owner_id))
.chain(self.trait_items.iter().map(|id| id.owner_id))
.chain(self.impl_items.iter().map(|id| id.owner_id))
.chain(self.foreign_items.iter().map(|id| id.owner_id))
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,7 @@ impl<'tcx> TyCtxt<'tcx> {
) -> &'tcx rustc_hir::def_path_hash_map::DefPathHashMap {
// Create a dependency to the crate to be sure we re-execute this when the amount of
// definitions change.
self.ensure_ok().hir_crate(());
self.ensure_ok().hir_crate_items(());
// Freeze definitions once we start iterating on them, to prevent adding new ones
// while iterating. If some query needs to add definitions, it should be `ensure`d above.
self.untracked.definitions.freeze().def_path_hash_to_def_index_map()
Expand Down
2 changes: 0 additions & 2 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,6 @@ pub(crate) fn run_global_ctxt(
ctxt.external_traits.insert(sized_trait_did, sized_trait);
}

debug!("crate: {:?}", tcx.hir_crate(()));

let mut krate = tcx.sess.time("clean_crate", || clean::krate(&mut ctxt));

if krate.module.doc_value().is_empty() {
Expand Down
10 changes: 2 additions & 8 deletions tests/ui/consts/const-unstable-intrinsic.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,15 @@ error: `size_of_val` is not yet stable as a const intrinsic
LL | unstable_intrinsic::size_of_val(&x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: add `#![feature(unstable)]` to the crate attributes to enable
|
LL + #![feature(unstable)]
|
= help: add `#![feature(unstable)]` to the crate attributes to enable

error: `align_of_val` is not yet stable as a const intrinsic
--> $DIR/const-unstable-intrinsic.rs:20:9
|
LL | unstable_intrinsic::align_of_val(&x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: add `#![feature(unstable)]` to the crate attributes to enable
|
LL + #![feature(unstable)]
|
= help: add `#![feature(unstable)]` to the crate attributes to enable

error: const function that might be (indirectly) exposed to stable cannot use `#[feature(local)]`
--> $DIR/const-unstable-intrinsic.rs:24:9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ error: `foobar` is not yet stable as a const fn
LL | foobar();
| ^^^^^^^^
|
help: add `#![feature(const_foobar)]` to the crate attributes to enable
|
LL + #![feature(const_foobar)]
|
= help: add `#![feature(const_foobar)]` to the crate attributes to enable

error: aborting due to 1 previous error

5 changes: 1 addition & 4 deletions tests/ui/traits/const-traits/staged-api-user-crate.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ error: `staged_api::MyTrait` is not yet stable as a const trait
LL | Unstable::func();
| ^^^^^^^^^^^^^^^^
|
help: add `#![feature(unstable)]` to the crate attributes to enable
|
LL + #![feature(unstable)]
|
= help: add `#![feature(unstable)]` to the crate attributes to enable

error: aborting due to 2 previous errors

Expand Down