Skip to content

Commit

Permalink
Rollup merge of #134514 - bjorn3:more_driver_refactors, r=jieyouxu
Browse files Browse the repository at this point in the history
Improve dependency_format a bit

* Make `DependencyList` an `IndexVec` rather than emulating one using a `Vec` (which was off-by-one as LOCAL_CRATE was intentionally skipped)
* Update some comments for the fact that we now use `#[global_allocator]` rather than `extern crate alloc_system;`/`extern crate alloc_jemalloc;` for specifying which allocator to use. We still use a similar mechanism for the panic runtime, so refer to the panic runtime in those comments instead.
* An unrelated refactor to `create_and_enter_global_ctxt` I forgot to include in rust-lang/rust#134302. This refactor is too small to be worth it's own PR.
  • Loading branch information
DianQK authored Dec 20, 2024
2 parents 599c3a4 + c0f4cec commit 48b90a0
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,14 @@ pub fn iter_exported_symbols<'tcx>(
let dependency_format = dependency_formats
.get(&CrateType::Executable)
.expect("interpreting a non-executable crate");
for cnum in dependency_format.iter().enumerate().filter_map(|(num, &linkage)| {
// We add 1 to the number because that's what rustc also does everywhere it
// calls `CrateNum::new`...
#[expect(clippy::arithmetic_side_effects)]
(linkage != Linkage::NotLinked).then_some(CrateNum::new(num + 1))
}) {
for cnum in dependency_format
.iter_enumerated()
.filter_map(|(num, &linkage)| (linkage != Linkage::NotLinked).then_some(num))
{
if cnum == LOCAL_CRATE {
continue; // Already handled above
}

// We can ignore `_export_info` here: we are a Rust crate, and everything is exported
// from a Rust crate.
for &(symbol, _export_info) in tcx.exported_symbols(cnum) {
Expand Down

0 comments on commit 48b90a0

Please sign in to comment.