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
e108da9
`std`: include `dlmalloc` for all non-wasi Wasm targets
Twey Mar 11, 2026
e2923eb
`std`: don't depend on `dlmalloc` when `cfg(unix)`
Twey Mar 11, 2026
c8a5457
core: move `Alignment` from `ptr` to `mem`
GrigorenkoPV Mar 1, 2026
a724880
`core::mem::Alignemnt`: rename `as_nonzero` to `as_nonzero_usize`
GrigorenkoPV Mar 1, 2026
f9752e2
bootstrap: Pass `--features=rustc` to rustc_transmute
jyn514 Mar 19, 2026
3ad92c9
On E0277 tweak help when single type impls traits
estebank Mar 21, 2026
5841fa8
Inline and remove `QueryVTable::is_loadable_from_disk_fn`.
nnethercote Mar 22, 2026
d52943a
Remove assertion in `load_from_disk_or_invoke_provider_green`.
nnethercote Mar 22, 2026
be8dee1
interpret/validity: remove unreachable error kind
RalfJung Mar 22, 2026
8befc9d
refactor RangeFromIter overflow-checks impl
pitaj Mar 21, 2026
fa3e85a
diagnostics: avoid ICE in confusable_method_name for associated funct…
Unique-Usman Mar 22, 2026
cde59f0
Remove another assertion in `load_from_disk_or_invoke_provider_green`.
nnethercote Mar 22, 2026
6f08437
improve inline assembly error messages
folkertdev Mar 22, 2026
327216d
Refactor `load_from_disk_or_invoke_provider_green`.
nnethercote Mar 22, 2026
8dcb257
Document consteval behavior of ub_checks & overflow_checks.
theemathas Mar 23, 2026
338deef
Remove outdated consteval docs for is_val_statically_known.
theemathas Mar 23, 2026
9f248d9
Rollup merge of #153686 - Twey:patch-1, r=Mark-Simulacrum
JonathanBrouwer Mar 23, 2026
c708e9c
Rollup merge of #154004 - GrigorenkoPV:alignment/as_nonzero_usize, r=…
JonathanBrouwer Mar 23, 2026
a2000c2
Rollup merge of #154105 - ferrocene:jyn/test-transmute, r=Mark-Simula…
JonathanBrouwer Mar 23, 2026
a6d8ad3
Rollup merge of #154191 - pitaj:fix-154124, r=tgross35
JonathanBrouwer Mar 23, 2026
fdb9577
Rollup merge of #154207 - nnethercote:refactor-query-loading, r=Zalathar
JonathanBrouwer Mar 23, 2026
4a9a456
Rollup merge of #154140 - theemathas:checks_always_on_in_const, r=Ral…
JonathanBrouwer Mar 23, 2026
89b7bd8
Rollup merge of #154161 - estebank:e0277-ty-impls, r=Kivooeo
JonathanBrouwer Mar 23, 2026
30c1ebb
Rollup merge of #154218 - RalfJung:validity-init-scalar, r=nnethercote
JonathanBrouwer Mar 23, 2026
2d1fd85
Rollup merge of #154225 - Unique-Usman:ua/rustc_confusable, r=Kivooeo
JonathanBrouwer Mar 23, 2026
ee4bcfe
Rollup merge of #154228 - folkertdev:mention-invalid-template-modifie…
JonathanBrouwer Mar 23, 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
29 changes: 9 additions & 20 deletions compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::collections::hash_map::Entry;
use std::fmt::Write;

use rustc_ast::*;
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
Expand Down Expand Up @@ -124,13 +123,9 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
self.dcx().emit_err(ClobberAbiNotSupported { abi_span: *abi_span });
}
Err(supported_abis) => {
let mut abis = format!("`{}`", supported_abis[0]);
for m in &supported_abis[1..] {
let _ = write!(abis, ", `{m}`");
}
self.dcx().emit_err(InvalidAbiClobberAbi {
abi_span: *abi_span,
supported_abis: abis,
supported_abis: supported_abis.to_vec().into(),
});
}
}
Expand Down Expand Up @@ -164,15 +159,12 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
asm::InlineAsmRegOrRegClass::RegClass(if let Some(asm_arch) = asm_arch {
asm::InlineAsmRegClass::parse(asm_arch, reg_class).unwrap_or_else(
|supported_register_classes| {
let mut register_classes =
format!("`{}`", supported_register_classes[0]);
for m in &supported_register_classes[1..] {
let _ = write!(register_classes, ", `{m}`");
}
self.dcx().emit_err(InvalidRegisterClass {
op_span: *op_sp,
reg_class,
supported_register_classes: register_classes,
supported_register_classes: supported_register_classes
.to_vec()
.into(),
});
asm::InlineAsmRegClass::Err
},
Expand Down Expand Up @@ -272,23 +264,20 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
}
let valid_modifiers = class.valid_modifiers(asm_arch.unwrap());
if !valid_modifiers.contains(&modifier) {
let sub = if !valid_modifiers.is_empty() {
let mut mods = format!("`{}`", valid_modifiers[0]);
for m in &valid_modifiers[1..] {
let _ = write!(mods, ", `{m}`");
}
InvalidAsmTemplateModifierRegClassSub::SupportModifier {
let sub = if valid_modifiers.is_empty() {
InvalidAsmTemplateModifierRegClassSub::DoesNotSupportModifier {
class_name: class.name(),
modifiers: mods,
}
} else {
InvalidAsmTemplateModifierRegClassSub::DoesNotSupportModifier {
InvalidAsmTemplateModifierRegClassSub::SupportModifier {
class_name: class.name(),
modifiers: valid_modifiers.to_vec().into(),
}
};
self.dcx().emit_err(InvalidAsmTemplateModifierRegClass {
placeholder_span,
op_span: op_sp,
modifier: modifier.to_string(),
sub,
});
}
Expand Down
13 changes: 7 additions & 6 deletions compiler/rustc_ast_lowering/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rustc_errors::DiagArgFromDisplay;
use rustc_errors::codes::*;
use rustc_errors::{DiagArgFromDisplay, DiagSymbolList};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{Ident, Span, Symbol};

Expand Down Expand Up @@ -191,10 +191,10 @@ pub(crate) struct ClobberAbiNotSupported {
#[derive(Diagnostic)]
#[note("the following ABIs are supported on this target: {$supported_abis}")]
#[diag("invalid ABI for `clobber_abi`")]
pub(crate) struct InvalidAbiClobberAbi {
pub(crate) struct InvalidAbiClobberAbi<'a> {
#[primary_span]
pub abi_span: Span,
pub supported_abis: String,
pub supported_abis: DiagSymbolList<&'a str>,
}

#[derive(Diagnostic)]
Expand All @@ -215,17 +215,18 @@ pub(crate) struct InvalidRegisterClass {
#[primary_span]
pub op_span: Span,
pub reg_class: Symbol,
pub supported_register_classes: String,
pub supported_register_classes: DiagSymbolList<Symbol>,
}

#[derive(Diagnostic)]
#[diag("invalid asm template modifier for this register class")]
#[diag("invalid asm template modifier `{$modifier}` for this register class")]
pub(crate) struct InvalidAsmTemplateModifierRegClass {
#[primary_span]
#[label("template modifier")]
pub placeholder_span: Span,
#[label("argument")]
pub op_span: Span,
pub modifier: String,
#[subdiagnostic]
pub sub: InvalidAsmTemplateModifierRegClassSub,
}
Expand All @@ -235,7 +236,7 @@ pub(crate) enum InvalidAsmTemplateModifierRegClassSub {
#[note(
"the `{$class_name}` register class supports the following template modifiers: {$modifiers}"
)]
SupportModifier { class_name: Symbol, modifiers: String },
SupportModifier { class_name: Symbol, modifiers: DiagSymbolList<char> },
#[note("the `{$class_name}` register class does not support template modifiers")]
DoesNotSupportModifier { class_name: Symbol },
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/global_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl AllocFnFactory<'_, '_> {
}

fn ptr_alignment(&self) -> Box<Ty> {
let path = self.cx.std_path(&[sym::ptr, sym::Alignment]);
let path = self.cx.std_path(&[sym::mem, sym::Alignment]);
let path = self.cx.path(self.span, path);
self.cx.ty_path(path)
}
Expand Down
11 changes: 6 additions & 5 deletions compiler/rustc_const_eval/src/interpret/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ enum ExpectedKind {
Reference,
Box,
RawPtr,
InitScalar,
Bool,
Char,
Float,
Expand All @@ -143,7 +142,6 @@ impl fmt::Display for ExpectedKind {
ExpectedKind::Reference => "expected a reference",
ExpectedKind::Box => "expected a box",
ExpectedKind::RawPtr => "expected a raw pointer",
ExpectedKind::InitScalar => "expected initialized scalar value",
ExpectedKind::Bool => "expected a boolean",
ExpectedKind::Char => "expected a unicode scalar value",
ExpectedKind::Float => "expected a floating point number",
Expand Down Expand Up @@ -1478,7 +1476,9 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt,
BackendRepr::Scalar(scalar_layout) => {
if !scalar_layout.is_uninit_valid() {
// There is something to check here.
let scalar = self.read_scalar(val, ExpectedKind::InitScalar)?;
// We read directly via `ecx` since the read cannot fail -- we already read
// this field above when recursing into the field.
let scalar = self.ecx.read_scalar(val)?;
self.visit_scalar(scalar, scalar_layout)?;
}
}
Expand All @@ -1487,8 +1487,9 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt,
// FIXME: find a way to also check ScalarPair when one side can be uninit but
// the other must be init.
if !a_layout.is_uninit_valid() && !b_layout.is_uninit_valid() {
let (a, b) =
self.read_immediate(val, ExpectedKind::InitScalar)?.to_scalar_pair();
// We read directly via `ecx` since the read cannot fail -- we already read
// this field above when recursing into the field.
let (a, b) = self.ecx.read_immediate(val)?.to_scalar_pair();
self.visit_scalar(a, a_layout)?;
self.visit_scalar(b, b_layout)?;
}
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_data_structures/src/aligned.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::marker::PointeeSized;
#[cfg(not(bootstrap))]
use std::mem::Alignment;
#[cfg(bootstrap)]
use std::ptr::Alignment;

/// Returns the ABI-required minimum alignment of a type in bytes.
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_data_structures/src/tagged_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ pub unsafe trait Tag: Copy {
/// Returns the number of bits available for use for tags in a pointer to `T`
/// (this is based on `T`'s alignment).
pub const fn bits_for<T: ?Sized + Aligned>() -> u32 {
crate::aligned::align_of::<T>().as_nonzero().trailing_zeros()
let alignment = crate::aligned::align_of::<T>();
#[cfg(bootstrap)]
let alignment = alignment.as_nonzero();
#[cfg(not(bootstrap))]
let alignment = alignment.as_nonzero_usize();
alignment.trailing_zeros()
}

/// Returns the correct [`Tag::BITS`] constant for a set of tag values.
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2291,8 +2291,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn_sig,
);
let name = inherent_method.name();
let inputs = fn_sig.inputs();
let expected_inputs =
if inherent_method.is_method() { &inputs[1..] } else { inputs };
if let Some(ref args) = call_args
&& fn_sig.inputs()[1..]
&& expected_inputs
.iter()
.eq_by(args, |expected, found| self.may_coerce(*expected, *found))
{
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_middle/src/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
index: DepNodeIndex,
) -> Option<C::Value>,

pub is_loadable_from_disk_fn:
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.
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_middle/src/ty/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ unsafe impl<H: DynSync, T: DynSync> DynSync for RawList<H, T> {}
// Layouts of `ListSkeleton<H, T>` and `RawList<H, T>` are the same, modulo opaque tail,
// thus aligns of `ListSkeleton<H, T>` and `RawList<H, T>` must be the same.
unsafe impl<H, T> Aligned for RawList<H, T> {
#[cfg(bootstrap)]
const ALIGN: ptr::Alignment = align_of::<ListSkeleton<H, T>>();
#[cfg(not(bootstrap))]
const ALIGN: mem::Alignment = align_of::<ListSkeleton<H, T>>();
}

/// A [`List`] that additionally stores type information inline to speed up
Expand Down
121 changes: 50 additions & 71 deletions compiler/rustc_query_impl/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use tracing::warn;

use crate::dep_graph::{DepNode, DepNodeIndex};
use crate::job::{QueryJobInfo, QueryJobMap, find_cycle_in_stack, report_cycle};
use crate::plumbing::{current_query_job, next_job_id, start_query};
use crate::plumbing::{current_query_job, loadable_from_disk, next_job_id, start_query};
use crate::query_impl::for_each_query_vtable;

#[inline]
Expand Down Expand Up @@ -488,81 +488,59 @@ fn load_from_disk_or_invoke_provider_green<'tcx, C: QueryCache>(

debug_assert!(dep_graph_data.is_index_green(prev_index));

// First we try to load the result from the on-disk cache.
// Some things are never cached on disk.
if let Some(value) = (query.try_load_from_disk_fn)(tcx, key, prev_index, dep_node_index) {
if std::intrinsics::unlikely(tcx.sess.opts.unstable_opts.query_dep_graph) {
dep_graph_data.mark_debug_loaded_from_disk(*dep_node)
// First try to load the result from the on-disk cache. Some things are never cached on disk.
let value;
let verify;
match (query.try_load_from_disk_fn)(tcx, key, prev_index, dep_node_index) {
Some(loaded_value) => {
if std::intrinsics::unlikely(tcx.sess.opts.unstable_opts.query_dep_graph) {
dep_graph_data.mark_debug_loaded_from_disk(*dep_node)
}

value = loaded_value;

let prev_fingerprint = dep_graph_data.prev_value_fingerprint_of(prev_index);
// If `-Zincremental-verify-ich` is specified, re-hash results from
// the cache and make sure that they have the expected fingerprint.
//
// If not, we still seek to verify a subset of fingerprints loaded
// from disk. Re-hashing results is fairly expensive, so we can't
// currently afford to verify every hash. This subset should still
// give us some coverage of potential bugs.
verify = prev_fingerprint.split().1.as_u64().is_multiple_of(32)
|| tcx.sess.opts.unstable_opts.incremental_verify_ich;
}
None => {
// We could not load a result from the on-disk cache, so recompute. The dep-graph for
// this computation is already in-place, so we can just call the query provider.
let prof_timer = tcx.prof.query_provider();
value = tcx.dep_graph.with_ignore(|| (query.invoke_provider_fn)(tcx, key));
prof_timer.finish_with_query_invocation_id(dep_node_index.into());

let prev_fingerprint = dep_graph_data.prev_value_fingerprint_of(prev_index);
// If `-Zincremental-verify-ich` is specified, re-hash results from
// the cache and make sure that they have the expected fingerprint.
//
// If not, we still seek to verify a subset of fingerprints loaded
// from disk. Re-hashing results is fairly expensive, so we can't
// currently afford to verify every hash. This subset should still
// give us some coverage of potential bugs though.
let try_verify = prev_fingerprint.split().1.as_u64().is_multiple_of(32);
if std::intrinsics::unlikely(
try_verify || tcx.sess.opts.unstable_opts.incremental_verify_ich,
) {
incremental_verify_ich(
tcx,
dep_graph_data,
&value,
prev_index,
query.hash_value_fn,
query.format_value,
);
verify = true;
}
};

return value;
if verify {
// Verify that re-running the query produced a result with the expected hash.
// This catches bugs in query implementations, turning them into ICEs.
// For example, a query might sort its result by `DefId` - since `DefId`s are
// not stable across compilation sessions, the result could get up getting sorted
// in a different order when the query is re-run, even though all of the inputs
// (e.g. `DefPathHash` values) were green.
//
// See issue #82920 for an example of a miscompilation that would get turned into
// an ICE by this check
incremental_verify_ich(
tcx,
dep_graph_data,
&value,
prev_index,
query.hash_value_fn,
query.format_value,
);
}

// We always expect to find a cached result for things that
// can be forced from `DepNode`.
debug_assert!(
!(query.will_cache_on_disk_for_key_fn)(tcx, key)
|| !tcx.key_fingerprint_style(dep_node.kind).is_maybe_recoverable(),
"missing on-disk cache entry for {dep_node:?}"
);

// Sanity check for the logic in `ensure`: if the node is green and the result loadable,
// we should actually be able to load it.
debug_assert!(
!(query.is_loadable_from_disk_fn)(tcx, key, prev_index),
"missing on-disk cache entry for loadable {dep_node:?}"
);

// We could not load a result from the on-disk cache, so
// recompute.
let prof_timer = tcx.prof.query_provider();

// The dep-graph for this computation is already in-place.
// Call the query provider.
let value = tcx.dep_graph.with_ignore(|| (query.invoke_provider_fn)(tcx, key));

prof_timer.finish_with_query_invocation_id(dep_node_index.into());

// Verify that re-running the query produced a result with the expected hash
// This catches bugs in query implementations, turning them into ICEs.
// For example, a query might sort its result by `DefId` - since `DefId`s are
// not stable across compilation sessions, the result could get up getting sorted
// in a different order when the query is re-run, even though all of the inputs
// (e.g. `DefPathHash` values) were green.
//
// See issue #82920 for an example of a miscompilation that would get turned into
// an ICE by this check
incremental_verify_ich(
tcx,
dep_graph_data,
&value,
prev_index,
query.hash_value_fn,
query.format_value,
);

value
}

Expand Down Expand Up @@ -624,7 +602,8 @@ fn check_if_ensure_can_skip_execution<'tcx, C: QueryCache>(
// In ensure-done mode, we can only skip execution for this key if
// there's a disk-cached value available to load later if needed,
// which guarantees the query provider will never run for this key.
let is_loadable = (query.is_loadable_from_disk_fn)(tcx, key, serialized_dep_node_index);
let is_loadable = (query.will_cache_on_disk_for_key_fn)(tcx, key)
&& loadable_from_disk(tcx, serialized_dep_node_index);
EnsureCanSkip { skip_execution: is_loadable, dep_node: Some(dep_node) }
}
}
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_query_impl/src/query_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,6 @@ macro_rules! define_queries {
#[cfg(not($cache_on_disk))]
try_load_from_disk_fn: |_tcx, _key, _prev_index, _index| None,

#[cfg($cache_on_disk)]
is_loadable_from_disk_fn: |tcx, key, index| -> bool {
rustc_middle::queries::_cache_on_disk_if_fns::$name(tcx, key) &&
$crate::plumbing::loadable_from_disk(tcx, index)
},
#[cfg(not($cache_on_disk))]
is_loadable_from_disk_fn: |_tcx, _key, _index| false,

// The default just emits `err` and then aborts.
// `from_cycle_error::specialize_query_vtables` overwrites this default for
// certain queries.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,7 @@ symbols! {
maybe_uninit,
maybe_uninit_uninit,
maybe_uninit_zeroed,
mem,
mem_align_const,
mem_discriminant,
mem_drop,
Expand Down
Loading
Loading