1
Fork 0

Auto merge of #126068 - lqd:revert-124976, r=petrochenkov

Revert "use `tcx.used_crates(())` more" before it reaches beta

There are more open issues caused by #124976 than will be fixed by #125493 alone. The beta cut is soon, so let's revert it and buy some time to analyze and fix these issues in our own time.

fixes https://github.com/rust-lang/rust/issues/125474
fixes https://github.com/rust-lang/rust/issues/125484
fixes https://github.com/rust-lang/rust/issues/125646
fixes https://github.com/rust-lang/rust/issues/125707
fixes #126066
fixes #125934
fixes https://github.com/rust-lang/rust/issues/126021

r? `@petrochenkov`
`@bors` p=1
This commit is contained in:
bors 2024-06-06 20:18:43 +00:00
commit 98489f2487
26 changed files with 75 additions and 54 deletions

View file

@ -144,7 +144,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
&& sess.crt_static(Some(ty))
&& !sess.target.crt_static_allows_dylibs)
{
for &cnum in tcx.used_crates(()).iter() {
for &cnum in tcx.crates(()).iter() {
if tcx.dep_kind(cnum).macros_only() {
continue;
}
@ -165,7 +165,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
// Sweep all crates for found dylibs. Add all dylibs, as well as their
// dependencies, ensuring there are no conflicts. The only valid case for a
// dependency to be relied upon twice is for both cases to rely on a dylib.
for &cnum in tcx.used_crates(()).iter() {
for &cnum in tcx.crates(()).iter() {
if tcx.dep_kind(cnum).macros_only() {
continue;
}
@ -183,7 +183,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
}
// Collect what we've got so far in the return vector.
let last_crate = tcx.used_crates(()).len();
let last_crate = tcx.crates(()).len();
let mut ret = (1..last_crate + 1)
.map(|cnum| match formats.get(&CrateNum::new(cnum)) {
Some(&RequireDynamic) => Linkage::Dynamic,
@ -197,7 +197,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
//
// If the crate hasn't been included yet and it's not actually required
// (e.g., it's an allocator) then we skip it here as well.
for &cnum in tcx.used_crates(()).iter() {
for &cnum in tcx.crates(()).iter() {
let src = tcx.used_crate_source(cnum);
if src.dylib.is_none()
&& !formats.contains_key(&cnum)
@ -285,7 +285,7 @@ fn add_library(
fn attempt_static(tcx: TyCtxt<'_>, unavailable: &mut Vec<CrateNum>) -> Option<DependencyList> {
let all_crates_available_as_rlib = tcx
.used_crates(())
.crates(())
.iter()
.copied()
.filter_map(|cnum| {
@ -306,7 +306,7 @@ fn attempt_static(tcx: TyCtxt<'_>, unavailable: &mut Vec<CrateNum>) -> Option<De
// All crates are available in an rlib format, so we're just going to link
// everything in explicitly so long as it's actually required.
let mut ret = tcx
.used_crates(())
.crates(())
.iter()
.map(|&cnum| match tcx.dep_kind(cnum) {
CrateDepKind::Explicit => Linkage::Static,

View file

@ -439,7 +439,7 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
// traversal, but not globally minimal across all crates.
let bfs_queue = &mut VecDeque::new();
for &cnum in tcx.crates_including_speculative(()) {
for &cnum in tcx.crates(()) {
// Ignore crates without a corresponding local `extern crate` item.
if tcx.missing_extern_crate_item(cnum) {
continue;
@ -509,7 +509,7 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
tcx.arena
.alloc_slice(&CStore::from_tcx(tcx).crate_dependencies_in_postorder(LOCAL_CRATE))
},
crates_including_speculative: |tcx, ()| {
crates: |tcx, ()| {
// The list of loaded crates is now frozen in query cache,
// so make sure cstore is not mutably accessed from here on.
tcx.untracked().cstore.freeze();

View file

@ -1899,7 +1899,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
let deps = self
.tcx
.crates_including_speculative(())
.crates(())
.iter()
.map(|&cnum| {
let dep = CrateDep {