Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
30fc9bd
elf-raw-dylib: set type for functions
mati865 Feb 25, 2026
7371a7f
tests/ui/asm: add annotations for reference rules
DanielEScherzer Feb 20, 2026
6358dcc
test: add regression test for fuzzy_provenance_casts lint ICE
yuyahy Feb 28, 2026
bc4cead
stabilize new RangeToInclusive type
pitaj Feb 7, 2026
fa66fef
core: make atomic primitives type aliases of `Atomic<T>`
joboet Feb 23, 2026
4b86b1a
compiler: manually implement `DynSend` for atomic primitives
joboet Feb 23, 2026
95e571d
update references to `Atomic` in diagnostics
joboet Feb 25, 2026
4d09563
bless UI tests referencing atomic primitives
joboet Feb 23, 2026
57234d3
update debuginfo visualizers and tests
joboet Feb 24, 2026
dc548c9
reference more reliable items in rustdoc tests
joboet Feb 25, 2026
72a001b
Remove `DepKindVTable::is_anon`.
nnethercote Feb 26, 2026
cc1b878
Inline and remove `handle_cycle_error`.
nnethercote Feb 26, 2026
c0770ba
Make `from_cycle_error` consume the `CycleError`.
nnethercote Feb 26, 2026
7a4daa4
Avoid an early return in `try_execute_query`.
nnethercote Feb 26, 2026
fc395ed
Merge two assertion blocks in `execute_job_non_incr`.
nnethercote Feb 26, 2026
8129da8
Remove three single-use type synonyms.
nnethercote Feb 26, 2026
2aaced6
Replace two `abort_if_errors` calls.
nnethercote Feb 27, 2026
6f111d2
Remove a duplicated comment.
nnethercote Feb 27, 2026
5677f7c
Rename trait `Value` as `FromCycleError`.
nnethercote Feb 27, 2026
5bd28b8
Remove `FromCycleError` impl for `SymbolName`.
nnethercote Feb 27, 2026
37e407d
Rollup merge of #153015 - joboet:atomic_alias_generic, r=jhpratt
jhpratt Mar 2, 2026
3695d75
Rollup merge of #153169 - nnethercote:rm-is_anon-etc, r=petrochenkov
jhpratt Mar 2, 2026
e353aa0
Rollup merge of #152304 - pitaj:stabilize-new_range_api, r=tgross35
jhpratt Mar 2, 2026
f421377
Rollup merge of #153090 - mati865:elf-raw-dylib-fns, r=TaKO8Ki
jhpratt Mar 2, 2026
37e4906
Rollup merge of #153225 - DanielEScherzer:test-references-asm, r=ehuss
jhpratt Mar 2, 2026
bc8b480
Rollup merge of #153233 - yuyahy:ice-issue-137588-regression-test, r=…
jhpratt Mar 2, 2026
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
11 changes: 6 additions & 5 deletions compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ fn create_elf_raw_dylib_stub(sess: &Session, soname: &str, symbols: &[DllImport]
vers.push((version_name, dynstr));
id
};
syms.push((name, dynstr, Some(ver)));
syms.push((name, dynstr, Some(ver), symbol.is_fn));
} else {
let dynstr = stub.add_dynamic_string(symbol_name.as_bytes());
syms.push((symbol_name, dynstr, None));
syms.push((symbol_name, dynstr, None, symbol.is_fn));
}
}

Expand Down Expand Up @@ -398,10 +398,11 @@ fn create_elf_raw_dylib_stub(sess: &Session, soname: &str, symbols: &[DllImport]

// .dynsym
stub.write_null_dynamic_symbol();
for (_name, dynstr, _ver) in syms.iter().copied() {
for (_name, dynstr, _ver, is_fn) in syms.iter().copied() {
let sym_type = if is_fn { elf::STT_FUNC } else { elf::STT_NOTYPE };
stub.write_dynamic_symbol(&write::Sym {
name: Some(dynstr),
st_info: (elf::STB_GLOBAL << 4) | elf::STT_NOTYPE,
st_info: (elf::STB_GLOBAL << 4) | sym_type,
st_other: elf::STV_DEFAULT,
section: Some(text_section),
st_shndx: 0, // ignored by object in favor of the `section` field
Expand All @@ -417,7 +418,7 @@ fn create_elf_raw_dylib_stub(sess: &Session, soname: &str, symbols: &[DllImport]
if !vers.is_empty() {
// .gnu_version
stub.write_null_gnu_versym();
for (_name, _dynstr, ver) in syms.iter().copied() {
for (_name, _dynstr, ver, _is_fn) in syms.iter().copied() {
stub.write_gnu_versym(if let Some(ver) = ver {
assert!((2 + ver as u16) < elf::VERSYM_HIDDEN);
elf::VERSYM_HIDDEN | (2 + ver as u16)
Expand Down
11 changes: 8 additions & 3 deletions compiler/rustc_data_structures/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@ macro_rules! already_send {

// These structures are already `Send`.
already_send!(
[std::backtrace::Backtrace][std::io::Stdout][std::io::Stderr][std::io::Error][std::fs::File][std::panic::Location<'_>]
[rustc_arena::DroplessArena][jobserver_crate::Client][jobserver_crate::HelperThread]
[crate::memmap::Mmap][crate::profiling::SelfProfiler][crate::owned_slice::OwnedSlice]
[std::sync::atomic::AtomicBool][std::sync::atomic::AtomicUsize][std::sync::atomic::AtomicU8]
[std::sync::atomic::AtomicU32][std::backtrace::Backtrace][std::io::Stdout][std::io::Stderr]
[std::io::Error][std::fs::File][std::panic::Location<'_>][rustc_arena::DroplessArena]
[jobserver_crate::Client][jobserver_crate::HelperThread][crate::memmap::Mmap]
[crate::profiling::SelfProfiler][crate::owned_slice::OwnedSlice]
);

#[cfg(target_has_atomic = "64")]
already_send!([std::sync::atomic::AtomicU64]);

macro_rules! impl_dyn_send {
($($($attr: meta)* [$ty: ty where $($generics2: tt)*])*) => {
$(unsafe impl<$($generics2)*> DynSend for $ty {})*
Expand Down
20 changes: 1 addition & 19 deletions compiler/rustc_lint/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,31 +1036,13 @@ impl InvalidAtomicOrdering {
expr: &Expr<'hir>,
recognized_names: &[Symbol], // used for fast path calculation
) -> Option<(Symbol, &'hir [Expr<'hir>])> {
const ATOMIC_TYPES: &[Symbol] = &[
sym::AtomicBool,
sym::AtomicPtr,
sym::AtomicUsize,
sym::AtomicU8,
sym::AtomicU16,
sym::AtomicU32,
sym::AtomicU64,
sym::AtomicU128,
sym::AtomicIsize,
sym::AtomicI8,
sym::AtomicI16,
sym::AtomicI32,
sym::AtomicI64,
sym::AtomicI128,
];
if let ExprKind::MethodCall(method_path, _, args, _) = &expr.kind
&& recognized_names.contains(&method_path.ident.name)
&& let Some(m_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id)
// skip extension traits, only lint functions from the standard library
&& let Some(impl_did) = cx.tcx.inherent_impl_of_assoc(m_def_id)
&& let Some(adt) = cx.tcx.type_of(impl_did).instantiate_identity().ty_adt_def()
&& let parent = cx.tcx.parent(adt.did())
&& cx.tcx.is_diagnostic_item(sym::atomic_mod, parent)
&& ATOMIC_TYPES.contains(&cx.tcx.item_name(adt.did()))
&& cx.tcx.is_diagnostic_item(sym::Atomic, adt.did())
{
return Some((method_path.ident.name, args));
}
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,6 @@ impl fmt::Debug for DepNode {
/// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
/// jump table instead of large matches.
pub struct DepKindVTable<'tcx> {
/// Anonymous queries cannot be replayed from one compiler invocation to the next.
/// When their result is needed, it is recomputed. They are useful for fine-grained
/// dependency tracking, and caching within one compiler invocation.
pub is_anon: bool,

/// Eval-always queries do not track their dependencies, and are always recomputed, even if
/// their inputs have not changed since the last compiler invocation. The result is still
/// cached within one compiler invocation.
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ use crate::{dep_graph, mir, thir};
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// `ty::query::from_cycle_error::FromCycleError`, which produces an appropriate
// placeholder (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.
// as they will raise a fatal error on query cycles instead.
rustc_queries! {
/// Caches the expansion of a derive proc macro, e.g. `#[derive(Serialize)]`.
/// The key is:
Expand Down
43 changes: 14 additions & 29 deletions compiler/rustc_middle/src/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,6 @@ pub enum CycleErrorHandling {
Stash,
}

pub type WillCacheOnDiskForKeyFn<'tcx, Key> = fn(tcx: TyCtxt<'tcx>, key: &Key) -> bool;

pub type TryLoadFromDiskFn<'tcx, Key, Value> = fn(
tcx: TyCtxt<'tcx>,
key: &Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<Value>;

pub type IsLoadableFromDiskFn<'tcx, Key> =
fn(tcx: TyCtxt<'tcx>, key: &Key, index: SerializedDepNodeIndex) -> bool;

#[derive(Clone, Debug)]
pub struct CycleError<I = QueryStackFrameExtra> {
/// The query and related span that uses the cycle.
Expand Down Expand Up @@ -126,7 +114,7 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
pub cycle_error_handling: CycleErrorHandling,
pub state: QueryState<'tcx, C::Key>,
pub cache: C,
pub will_cache_on_disk_for_key_fn: Option<WillCacheOnDiskForKeyFn<'tcx, C::Key>>,
pub will_cache_on_disk_for_key_fn: Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key) -> bool>,

/// Function pointer that calls `tcx.$query(key)` for this query and
/// discards the returned value.
Expand All @@ -142,16 +130,25 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
/// This should be the only code that calls the provider function.
pub invoke_provider_fn: fn(tcx: TyCtxt<'tcx>, key: C::Key) -> C::Value,

pub try_load_from_disk_fn: Option<TryLoadFromDiskFn<'tcx, C::Key, C::Value>>,
pub is_loadable_from_disk_fn: Option<IsLoadableFromDiskFn<'tcx, C::Key>>,
pub try_load_from_disk_fn: Option<
fn(
tcx: TyCtxt<'tcx>,
key: &C::Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<C::Value>,
>,

pub is_loadable_from_disk_fn:
Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key, index: SerializedDepNodeIndex) -> bool>,

/// Function pointer that hashes this query's result values.
///
/// For `no_hash` queries, this function pointer is None.
pub hash_value_fn: Option<fn(&mut StableHashingContext<'_>, &C::Value) -> Fingerprint>,

pub value_from_cycle_error:
fn(tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed) -> C::Value,
fn(tcx: TyCtxt<'tcx>, cycle_error: CycleError, guar: ErrorGuaranteed) -> C::Value,
pub format_value: fn(&C::Value) -> String,

/// Formats a human-readable description of this query and its key, as
Expand Down Expand Up @@ -216,7 +213,7 @@ impl<'tcx, C: QueryCache> QueryVTable<'tcx, C> {
pub fn value_from_cycle_error(
&self,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
cycle_error: CycleError,
guar: ErrorGuaranteed,
) -> C::Value {
(self.value_from_cycle_error)(tcx, cycle_error, guar)
Expand Down Expand Up @@ -650,18 +647,6 @@ macro_rules! define_callbacks {
};
}

// Each of these queries corresponds to a function pointer field in the
// `Providers` struct for requesting a value of that type, and a method
// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
// which memoizes and does dep-graph tracking, wrapping around the actual
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.

mod sealed {
use rustc_hir::def_id::{LocalModDefId, ModDefId};

Expand Down
9 changes: 0 additions & 9 deletions compiler/rustc_query_impl/src/dep_kind_vtables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ mod non_query {
// We use this for most things when incr. comp. is turned off.
pub(crate) fn Null<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node_fn: Some(|_, dep_node, _| {
Expand All @@ -26,7 +25,6 @@ mod non_query {
// We use this for the forever-red node.
pub(crate) fn Red<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node_fn: Some(|_, dep_node, _| {
Expand All @@ -38,7 +36,6 @@ mod non_query {

pub(crate) fn SideEffect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node_fn: Some(|tcx, _, prev_index| {
Expand All @@ -51,7 +48,6 @@ mod non_query {

pub(crate) fn AnonZeroDeps<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node_fn: Some(|_, _, _| bug!("cannot force an anon node")),
Expand All @@ -61,7 +57,6 @@ mod non_query {

pub(crate) fn TraitSelect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node_fn: None,
Expand All @@ -71,7 +66,6 @@ mod non_query {

pub(crate) fn CompileCodegenUnit<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node_fn: None,
Expand All @@ -81,7 +75,6 @@ mod non_query {

pub(crate) fn CompileMonoItem<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node_fn: None,
Expand All @@ -91,7 +84,6 @@ mod non_query {

pub(crate) fn Metadata<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node_fn: None,
Expand Down Expand Up @@ -124,7 +116,6 @@ where
}

DepKindVTable {
is_anon,
is_eval_always,
key_fingerprint_style,
force_from_dep_node_fn: can_recover.then_some(force_from_dep_node_inner::<Q>),
Expand Down
54 changes: 19 additions & 35 deletions compiler/rustc_query_impl/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_data_structures::hash_table::{Entry, HashTable};
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::sync::{DynSend, DynSync};
use rustc_data_structures::{outline, sharded, sync};
use rustc_errors::{Diag, FatalError, StashKey};
use rustc_errors::{FatalError, StashKey};
use rustc_middle::dep_graph::{DepGraphData, DepNodeKey, SerializedDepNodeIndex};
use rustc_middle::query::plumbing::QueryVTable;
use rustc_middle::query::{
Expand Down Expand Up @@ -126,24 +126,14 @@ fn mk_cycle<'tcx, C: QueryCache>(
cycle_error: CycleError,
) -> C::Value {
let error = report_cycle(tcx.sess, &cycle_error);
handle_cycle_error(query, tcx, &cycle_error, error)
}

fn handle_cycle_error<'tcx, C: QueryCache>(
query: &'tcx QueryVTable<'tcx, C>,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
error: Diag<'_>,
) -> C::Value {
match query.cycle_error_handling {
CycleErrorHandling::Error => {
let guar = error.emit();
query.value_from_cycle_error(tcx, cycle_error, guar)
}
CycleErrorHandling::Fatal => {
error.emit();
tcx.dcx().abort_if_errors();
unreachable!()
let guar = error.emit();
guar.raise_fatal();
}
CycleErrorHandling::DelayBug => {
let guar = error.delay_as_bug();
Expand Down Expand Up @@ -340,15 +330,15 @@ fn try_execute_query<'tcx, C: QueryCache, const INCR: bool>(

// Only call `wait_for_query` if we're using a Rayon thread pool
// as it will attempt to mark the worker thread as blocked.
return wait_for_query(query, tcx, span, key, latch, current_job_id);
}

let id = job.id;
drop(state_lock);
wait_for_query(query, tcx, span, key, latch, current_job_id)
} else {
let id = job.id;
drop(state_lock);

// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
}
}
ActiveKeyStatus::Poisoned => FatalError.raise(),
}
Expand Down Expand Up @@ -430,27 +420,21 @@ fn execute_job_non_incr<'tcx, C: QueryCache>(
) -> (C::Value, DepNodeIndex) {
debug_assert!(!tcx.dep_graph.is_fully_enabled());

// Fingerprint the key, just to assert that it doesn't
// have anything we don't consider hashable
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
}

let prof_timer = tcx.prof.query_provider();
// Call the query provider.
let value =
start_query(tcx, job_id, query.depth_limit, || (query.invoke_provider_fn)(tcx, key));
let dep_node_index = tcx.dep_graph.next_virtual_depnode_index();
prof_timer.finish_with_query_invocation_id(dep_node_index.into());

// Similarly, fingerprint the result to assert that
// it doesn't have anything not considered hashable.
if cfg!(debug_assertions)
&& let Some(hash_value_fn) = query.hash_value_fn
{
tcx.with_stable_hashing_context(|mut hcx| {
hash_value_fn(&mut hcx, &value);
});
// Sanity: Fingerprint the key and the result to assert they don't contain anything unhashable.
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
if let Some(hash_value_fn) = query.hash_value_fn {
tcx.with_stable_hashing_context(|mut hcx| {
hash_value_fn(&mut hcx, &value);
});
}
}

(value, dep_node_index)
Expand Down
Loading
Loading