Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2652,9 +2652,9 @@ dependencies = [

[[package]]
name = "objc2-core-foundation"
version = "0.3.2"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"
checksum = "1c10c2894a6fed806ade6027bcd50662746363a9589d3ec9d9bef30a4e4bc166"
dependencies = [
"bitflags",
]
Expand All @@ -2667,9 +2667,9 @@ checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33"

[[package]]
name = "objc2-io-kit"
version = "0.3.2"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15"
checksum = "71c1c64d6120e51cd86033f67176b1cb66780c2efe34dec55176f77befd93c0a"
dependencies = [
"libc",
"objc2-core-foundation",
Expand Down Expand Up @@ -5354,9 +5354,9 @@ dependencies = [

[[package]]
name = "sysinfo"
version = "0.38.0"
version = "0.38.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe840c5b1afe259a5657392a4dbb74473a14c8db999c3ec2f4ae812e028a94da"
checksum = "1efc19935b4b66baa6f654ac7924c192f55b175c00a7ab72410fc24284dacda8"
dependencies = [
"libc",
"objc2-core-foundation",
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ declare_features! (
// feature-group-start: for testing purposes
// -------------------------------------------------------------------------

/// A temporary feature gate used to enable parser extensions needed
/// to bootstrap fix for #5723.
(accepted, issue_5723_bootstrap, "1.0.0", None),
/// These are used to test this portion of the compiler,
/// they don't actually mean anything.
(accepted, test_accepted_feature, "1.0.0", None),
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ declare_features! (
/// Allow anonymous constants from an inline `const` block in pattern position
(removed, inline_const_pat, "1.88.0", Some(76001),
Some("removed due to implementation concerns as it requires significant refactorings"), 138492),
/// A temporary feature gate used to enable parser extensions needed
/// to bootstrap fix for #5723.
(removed, issue_5723_bootstrap, "CURRENT_RUSTC_VERSION", None, None),
/// Lazily evaluate constants. This allows constants to depend on type parameters.
(removed, lazy_normalization_consts, "1.56.0", Some(72219), Some("superseded by `generic_const_exprs`"), 88369),
/// Changes `impl Trait` to capture all lifetimes in scope.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_interface/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use rustc_parse::lexer::StripTokens;
use rustc_parse::new_parser_from_source_str;
use rustc_parse::parser::Recovery;
use rustc_parse::parser::attr::AllowLeadingUnsafe;
use rustc_query_impl::{QueryCtxt, print_query_stack};
use rustc_query_impl::print_query_stack;
use rustc_session::config::{self, Cfg, CheckCfg, ExpectedValues, Input, OutFileName};
use rustc_session::parse::ParseSess;
use rustc_session::{CompilerIO, EarlyDiagCtxt, Session, lint};
Expand Down Expand Up @@ -556,7 +556,7 @@ pub fn try_print_query_stack(
let all_frames = ty::tls::with_context_opt(|icx| {
if let Some(icx) = icx {
ty::print::with_no_queries!(print_query_stack(
QueryCtxt::new(icx.tcx),
icx.tcx,
icx.query,
dcx,
limit_frames,
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_interface/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use rustc_data_structures::sync;
use rustc_metadata::{DylibError, EncodedMetadata, load_symbol_from_dylib};
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_middle::ty::{CurrentGcx, TyCtxt};
use rustc_query_impl::collect_active_jobs_from_all_queries;
use rustc_session::config::{
Cfg, CrateType, OutFileName, OutputFilenames, OutputTypes, Sysroot, host_tuple,
};
Expand Down Expand Up @@ -184,7 +185,7 @@ pub(crate) fn run_in_thread_pool_with_globals<
use rustc_data_structures::defer;
use rustc_data_structures::sync::FromDyn;
use rustc_middle::ty::tls;
use rustc_query_impl::{QueryCtxt, break_query_cycles};
use rustc_query_impl::break_query_cycles;

let thread_stack_size = init_stack_size(thread_builder_diag);

Expand Down Expand Up @@ -253,7 +254,7 @@ internal compiler error: query cycle handler thread panicked, aborting process";
|| {
// Ensure there were no errors collecting all active jobs.
// We need the complete map to ensure we find a cycle to break.
QueryCtxt::new(tcx).collect_active_jobs_from_all_queries(false).expect(
collect_active_jobs_from_all_queries(tcx, false).expect(
"failed to collect active queries in deadlock handler",
)
},
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_metadata/src/native_libs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ pub fn walk_native_lib_search_dirs<R>(
// library directory instead of the self-contained directories.
// Sanitizer libraries have the same issue and are also linked by name on Apple targets.
// The targets here should be in sync with `copy_third_party_objects` in bootstrap.
// Finally there is shared LLVM library, which unlike compiler libraries, is linked by the name,
// therefore requiring the search path for the linker.
// FIXME: implement `-Clink-self-contained=+/-unwind,+/-sanitizers`, move the shipped libunwind
// and sanitizers to self-contained directory, and stop adding this search path.
// FIXME: On AIX this also has the side-effect of making the list of library search paths
Expand All @@ -71,6 +73,9 @@ pub fn walk_native_lib_search_dirs<R>(
|| sess.target.os == Os::Fuchsia
|| sess.target.is_like_aix
|| sess.target.is_like_darwin && !sess.sanitizers().is_empty()
|| sess.target.os == Os::Windows
&& sess.target.env == Env::Gnu
&& sess.target.abi == Abi::Llvm
{
f(&sess.target_tlib_path.dir, false)?;
}
Expand Down
81 changes: 31 additions & 50 deletions compiler/rustc_middle/src/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use {super::debug::EdgeFilter, std::env};

use super::query::DepGraphQuery;
use super::serialized::{GraphEncoder, SerializedDepGraph, SerializedDepNodeIndex};
use super::{DepKind, DepNode, HasDepContext, WorkProductId, read_deps, with_deps};
use super::{DepKind, DepNode, WorkProductId, read_deps, with_deps};
use crate::dep_graph::edges::EdgesVec;
use crate::ich::StableHashingContext;
use crate::ty::TyCtxt;
Expand Down Expand Up @@ -268,17 +268,17 @@ impl DepGraph {
}

#[inline(always)]
pub fn with_task<'tcx, Ctxt: HasDepContext<'tcx>, A: Debug, R>(
pub fn with_task<'tcx, A: Debug, R>(
&self,
key: DepNode,
cx: Ctxt,
arg: A,
task: fn(Ctxt, A) -> R,
dep_node: DepNode,
tcx: TyCtxt<'tcx>,
task_arg: A,
task_fn: fn(tcx: TyCtxt<'tcx>, task_arg: A) -> R,
hash_result: Option<fn(&mut StableHashingContext<'_>, &R) -> Fingerprint>,
) -> (R, DepNodeIndex) {
match self.data() {
Some(data) => data.with_task(key, cx, arg, task, hash_result),
None => (task(cx, arg), self.next_virtual_depnode_index()),
Some(data) => data.with_task(dep_node, tcx, task_arg, task_fn, hash_result),
None => (task_fn(tcx, task_arg), self.next_virtual_depnode_index()),
}
}

Expand Down Expand Up @@ -310,66 +310,50 @@ impl DepGraphData {
/// prevent implicit 'leaks' of tracked state into the task (which
/// could then be read without generating correct edges in the
/// dep-graph -- see the [rustc dev guide] for more details on
/// the dep-graph). To this end, the task function gets exactly two
/// pieces of state: the context `cx` and an argument `arg`. Both
/// of these bits of state must be of some type that implements
/// `DepGraphSafe` and hence does not leak.
///
/// The choice of two arguments is not fundamental. One argument
/// would work just as well, since multiple values can be
/// collected using tuples. However, using two arguments works out
/// to be quite convenient, since it is common to need a context
/// (`cx`) and some argument (e.g., a `DefId` identifying what
/// item to process).
/// the dep-graph).
///
/// For cases where you need some other number of arguments:
///
/// - If you only need one argument, just use `()` for the `arg`
/// parameter.
/// - If you need 3+ arguments, use a tuple for the
/// `arg` parameter.
/// Therefore, the task function takes a `TyCtxt`, plus exactly one
/// additional argument, `task_arg`. The additional argument type can be
/// `()` if no argument is needed, or a tuple if multiple arguments are
/// needed.
///
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/queries/incremental-compilation.html
#[inline(always)]
pub fn with_task<'tcx, Ctxt: HasDepContext<'tcx>, A: Debug, R>(
pub fn with_task<'tcx, A: Debug, R>(
&self,
key: DepNode,
cx: Ctxt,
arg: A,
task: fn(Ctxt, A) -> R,
dep_node: DepNode,
tcx: TyCtxt<'tcx>,
task_arg: A,
task_fn: fn(tcx: TyCtxt<'tcx>, task_arg: A) -> R,
hash_result: Option<fn(&mut StableHashingContext<'_>, &R) -> Fingerprint>,
) -> (R, DepNodeIndex) {
// If the following assertion triggers, it can have two reasons:
// 1. Something is wrong with DepNode creation, either here or
// in `DepGraph::try_mark_green()`.
// 2. Two distinct query keys get mapped to the same `DepNode`
// (see for example #48923).
self.assert_dep_node_not_yet_allocated_in_current_session(
cx.dep_context().sess,
&key,
|| {
format!(
"forcing query with already existing `DepNode`\n\
- query-key: {arg:?}\n\
- dep-node: {key:?}"
)
},
);
self.assert_dep_node_not_yet_allocated_in_current_session(tcx.sess, &dep_node, || {
format!(
"forcing query with already existing `DepNode`\n\
- query-key: {task_arg:?}\n\
- dep-node: {dep_node:?}"
)
});

let with_deps = |task_deps| with_deps(task_deps, || task(cx, arg));
let (result, edges) = if cx.dep_context().is_eval_always(key.kind) {
let with_deps = |task_deps| with_deps(task_deps, || task_fn(tcx, task_arg));
let (result, edges) = if tcx.is_eval_always(dep_node.kind) {
(with_deps(TaskDepsRef::EvalAlways), EdgesVec::new())
} else {
let task_deps = Lock::new(TaskDeps::new(
#[cfg(debug_assertions)]
Some(key),
Some(dep_node),
0,
));
(with_deps(TaskDepsRef::Allow(&task_deps)), task_deps.into_inner().reads)
};

let dep_node_index =
self.hash_result_and_alloc_node(cx.dep_context(), key, edges, &result, hash_result);
self.hash_result_and_alloc_node(tcx, dep_node, edges, &result, hash_result);

(result, dep_node_index)
}
Expand Down Expand Up @@ -954,7 +938,7 @@ impl DepGraphData {

// We failed to mark it green, so we try to force the query.
debug!("trying to force dependency {dep_dep_node:?}");
if !tcx.dep_context().try_force_from_dep_node(*dep_dep_node, parent_dep_node_index, frame) {
if !tcx.try_force_from_dep_node(*dep_dep_node, parent_dep_node_index, frame) {
// The DepNode could not be forced.
debug!("dependency {dep_dep_node:?} could not be forced");
return None;
Expand Down Expand Up @@ -1001,10 +985,7 @@ impl DepGraphData {
let frame = MarkFrame { index: prev_dep_node_index, parent: frame };

// We never try to mark eval_always nodes as green
debug_assert!(
!tcx.dep_context()
.is_eval_always(self.previous.index_to_node(prev_dep_node_index).kind)
);
debug_assert!(!tcx.is_eval_always(self.previous.index_to_node(prev_dep_node_index).kind));

let prev_deps = self.previous.edge_targets_from(prev_dep_node_index);

Expand Down
16 changes: 0 additions & 16 deletions compiler/rustc_middle/src/dep_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,6 @@ mod graph;
mod query;
mod serialized;

pub trait HasDepContext<'tcx>: Copy {
fn dep_context(&self) -> TyCtxt<'tcx>;
}

impl<'tcx> HasDepContext<'tcx> for TyCtxt<'tcx> {
fn dep_context(&self) -> TyCtxt<'tcx> {
*self
}
}

impl<'tcx, T: HasDepContext<'tcx>, Q: Copy> HasDepContext<'tcx> for (T, Q) {
fn dep_context(&self) -> TyCtxt<'tcx> {
self.0.dep_context()
}
}

/// Describes the contents of the fingerprint generated by a given query.
///
/// This is mainly for determining whether and how we can reconstruct a key
Expand Down
Loading
Loading