rustc_codegen_ssa: Enforce rustc::potential_query_instability
lint
This commit is contained in:
parent
95613d1b23
commit
4612edc53f
5 changed files with 30 additions and 11 deletions
|
@ -267,9 +267,12 @@ impl CguReuseTracker {
|
||||||
|
|
||||||
fn check_expected_reuse(&self, sess: &Session) {
|
fn check_expected_reuse(&self, sess: &Session) {
|
||||||
if let Some(ref data) = self.data {
|
if let Some(ref data) = self.data {
|
||||||
for (cgu_name, &(ref cgu_user_name, ref error_span, expected_reuse, comparison_kind)) in
|
let mut keys = data.expected_reuse.keys().collect::<Vec<_>>();
|
||||||
&data.expected_reuse
|
keys.sort_unstable();
|
||||||
{
|
for cgu_name in keys {
|
||||||
|
let &(ref cgu_user_name, ref error_span, expected_reuse, comparison_kind) =
|
||||||
|
data.expected_reuse.get(cgu_name).unwrap();
|
||||||
|
|
||||||
if let Some(&actual_reuse) = data.actual_reuse.get(cgu_name) {
|
if let Some(&actual_reuse) = data.actual_reuse.get(cgu_name) {
|
||||||
let (error, at_least) = match comparison_kind {
|
let (error, at_least) = match comparison_kind {
|
||||||
ComparisonKind::Exact => (expected_reuse != actual_reuse, false),
|
ComparisonKind::Exact => (expected_reuse != actual_reuse, false),
|
||||||
|
|
|
@ -559,6 +559,11 @@ fn link_staticlib<'a>(
|
||||||
archive_builder_builder
|
archive_builder_builder
|
||||||
.extract_bundled_libs(path, tempdir.as_ref(), &relevant_libs)
|
.extract_bundled_libs(path, tempdir.as_ref(), &relevant_libs)
|
||||||
.unwrap_or_else(|e| sess.dcx().emit_fatal(e));
|
.unwrap_or_else(|e| sess.dcx().emit_fatal(e));
|
||||||
|
|
||||||
|
// We sort the libraries below
|
||||||
|
#[allow(rustc::potential_query_instability)]
|
||||||
|
let mut relevant_libs: Vec<Symbol> = relevant_libs.into_iter().collect();
|
||||||
|
relevant_libs.sort_unstable();
|
||||||
for filename in relevant_libs {
|
for filename in relevant_libs {
|
||||||
let joined = tempdir.as_ref().join(filename.as_str());
|
let joined = tempdir.as_ref().join(filename.as_str());
|
||||||
let path = joined.as_path();
|
let path = joined.as_path();
|
||||||
|
@ -2172,14 +2177,19 @@ fn linker_with_args<'a>(
|
||||||
.iter()
|
.iter()
|
||||||
.find(|(ty, _)| *ty == crate_type)
|
.find(|(ty, _)| *ty == crate_type)
|
||||||
.expect("failed to find crate type in dependency format list");
|
.expect("failed to find crate type in dependency format list");
|
||||||
let native_libraries_from_nonstatics = codegen_results
|
|
||||||
|
// We sort the libraries below
|
||||||
|
#[allow(rustc::potential_query_instability)]
|
||||||
|
let mut native_libraries_from_nonstatics = codegen_results
|
||||||
.crate_info
|
.crate_info
|
||||||
.native_libraries
|
.native_libraries
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(cnum, libraries)| {
|
.filter_map(|(cnum, libraries)| {
|
||||||
(dependency_linkage[cnum.as_usize() - 1] != Linkage::Static).then_some(libraries)
|
(dependency_linkage[cnum.as_usize() - 1] != Linkage::Static).then_some(libraries)
|
||||||
})
|
})
|
||||||
.flatten();
|
.flatten()
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
native_libraries_from_nonstatics.sort_unstable_by(|a, b| a.name.as_str().cmp(b.name.as_str()));
|
||||||
for (raw_dylib_name, raw_dylib_imports) in
|
for (raw_dylib_name, raw_dylib_imports) in
|
||||||
collate_raw_dylibs(sess, native_libraries_from_nonstatics)?
|
collate_raw_dylibs(sess, native_libraries_from_nonstatics)?
|
||||||
{
|
{
|
||||||
|
|
|
@ -333,6 +333,8 @@ fn exported_symbols_provider_local(
|
||||||
|
|
||||||
let (_, cgus) = tcx.collect_and_partition_mono_items(());
|
let (_, cgus) = tcx.collect_and_partition_mono_items(());
|
||||||
|
|
||||||
|
// The symbols created in this loop are sorted below it
|
||||||
|
#[allow(rustc::potential_query_instability)]
|
||||||
for (mono_item, data) in cgus.iter().flat_map(|cgu| cgu.items().iter()) {
|
for (mono_item, data) in cgus.iter().flat_map(|cgu| cgu.items().iter()) {
|
||||||
if data.linkage != Linkage::External {
|
if data.linkage != Linkage::External {
|
||||||
// We can only re-use things with external linkage, otherwise
|
// We can only re-use things with external linkage, otherwise
|
||||||
|
|
|
@ -906,17 +906,22 @@ impl CrateInfo {
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let prefix = if target.is_like_windows && target.arch == "x86" { "_" } else { "" };
|
let prefix = if target.is_like_windows && target.arch == "x86" { "_" } else { "" };
|
||||||
|
|
||||||
|
// This loop only adds new items to values of the hash map, so the order in which we
|
||||||
|
// iterate over the values is not important.
|
||||||
|
#[allow(rustc::potential_query_instability)]
|
||||||
info.linked_symbols
|
info.linked_symbols
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.filter(|(crate_type, _)| {
|
.filter(|(crate_type, _)| {
|
||||||
!matches!(crate_type, CrateType::Rlib | CrateType::Staticlib)
|
!matches!(crate_type, CrateType::Rlib | CrateType::Staticlib)
|
||||||
})
|
})
|
||||||
.for_each(|(_, linked_symbols)| {
|
.for_each(|(_, linked_symbols)| {
|
||||||
linked_symbols.extend(
|
let mut symbols = missing_weak_lang_items
|
||||||
missing_weak_lang_items
|
.iter()
|
||||||
.iter()
|
.map(|item| (format!("{prefix}{item}"), SymbolExportKind::Text))
|
||||||
.map(|item| (format!("{prefix}{item}"), SymbolExportKind::Text)),
|
.collect::<Vec<_>>();
|
||||||
);
|
symbols.sort_unstable_by(|a, b| a.0.cmp(&b.0));
|
||||||
|
linked_symbols.extend(symbols);
|
||||||
if tcx.allocator_kind(()).is_some() {
|
if tcx.allocator_kind(()).is_some() {
|
||||||
// At least one crate needs a global allocator. This crate may be placed
|
// At least one crate needs a global allocator. This crate may be placed
|
||||||
// after the crate that defines it in the linker order, in which case some
|
// after the crate that defines it in the linker order, in which case some
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#![feature(strict_provenance)]
|
#![feature(strict_provenance)]
|
||||||
#![feature(try_blocks)]
|
#![feature(try_blocks)]
|
||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
#![allow(rustc::potential_query_instability)]
|
|
||||||
|
|
||||||
//! This crate contains codegen code that is used by all codegen backends (LLVM and others).
|
//! This crate contains codegen code that is used by all codegen backends (LLVM and others).
|
||||||
//! The backend-agnostic functions of this crate use functions defined in various traits that
|
//! The backend-agnostic functions of this crate use functions defined in various traits that
|
||||||
|
|
Loading…
Add table
Reference in a new issue