Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0bf2d00
fix: updated slice tests to pass for big endian hosts
rwardd Jan 28, 2026
5265ee0
fix: refactored to use directives instead of `CHECK-DAG`
rwardd Feb 8, 2026
d351448
add more tests for `unused_results` lints
WaffleLapkin Feb 27, 2026
8958cb9
don't emit `unused_results` lint for tuples of trivial types
WaffleLapkin Feb 27, 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
253c696
Make non-queries available to `rustc_with_all_queries`.
nnethercote Feb 27, 2026
40b2274
Change how query vtables are constructed.
nnethercote Feb 27, 2026
f538526
vec/mod.rs: add missing period in "ie." in docs
DanielEScherzer Mar 2, 2026
66786fc
fix next-solver ICE on PointeeSized goals
TaKO8Ki Feb 1, 2026
6cda9bf
replace issue number with link
TaKO8Ki Feb 1, 2026
ca74063
simplify test case and add revisions for both solvers
TaKO8Ki Mar 2, 2026
2d8ceee
add tests for a thumb program calling arm code
folkertdev Feb 26, 2026
88cec3a
update debuginfo visualizers and tests
joboet Feb 24, 2026
e9ca34f
reference more reliable items in rustdoc tests
joboet Feb 25, 2026
b4d36db
tests: codegen-llvm: vec-calloc: do not require the uwtable attribute
Gelbpunkt Mar 2, 2026
f1a4d0c
library: std: process: skip tests on Hermit
Gelbpunkt Mar 2, 2026
778e602
Do not ping kobzol on rustc-dev-guide changes
Kobzol Mar 2, 2026
6d16e3b
Rollup merge of #153153 - folkertdev:thumb-and-arm, r=jieyouxu
JonathanBrouwer Mar 2, 2026
1654b17
Rollup merge of #151780 - rwardd:ryan/fix-option-permutations, r=nikic
JonathanBrouwer Mar 2, 2026
4a3d3cb
Rollup merge of #151962 - TaKO8Ki:pointee-sized-next-solver-ice, r=lcnr
JonathanBrouwer Mar 2, 2026
ef4cff2
Rollup merge of #153015 - joboet:atomic_alias_generic, r=jhpratt
JonathanBrouwer Mar 2, 2026
34fd06e
Rollup merge of #153161 - nnethercote:rejig-rustc_with_all_queries, r…
JonathanBrouwer Mar 2, 2026
2fe8b01
Rollup merge of #153191 - WaffleLapkin:shouldnt_use_trivial_tuples, r…
JonathanBrouwer Mar 2, 2026
671dc27
Rollup merge of #153273 - DanielEScherzer:patch-2, r=joboet
JonathanBrouwer Mar 2, 2026
bcfe737
Rollup merge of #153292 - Gelbpunkt:vec-calloc-uwtables-optional, r=j…
JonathanBrouwer Mar 2, 2026
b2dfd76
Rollup merge of #153293 - Gelbpunkt:skip-process-tests-hermit, r=joboet
JonathanBrouwer Mar 2, 2026
273b3aa
Rollup merge of #153301 - Kobzol:remove-kobzol-rdg-ping, r=Kobzol
JonathanBrouwer 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: 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
32 changes: 16 additions & 16 deletions compiler/rustc_lint/src/unused/must_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,6 @@ impl IsTyMustUse {
_ => self,
}
}

fn yes(self) -> Option<MustUsePath> {
match self {
Self::Yes(must_use_path) => Some(must_use_path),
_ => None,
}
}
}

/// A path through a type to a `must_use` source. Contains useful info for the lint.
Expand Down Expand Up @@ -254,16 +247,23 @@ pub fn is_ty_must_use<'tcx>(
// Default to `expr`.
let elem_exprs = elem_exprs.iter().chain(iter::repeat(expr));

let nested_must_use = tys
.iter()
.zip(elem_exprs)
.enumerate()
.filter_map(|(i, (ty, expr))| {
is_ty_must_use(cx, ty, expr, simplify_uninhabited).yes().map(|path| (i, path))
})
.collect::<Vec<_>>();
let mut all_trivial = true;
let mut nested_must_use = Vec::new();

tys.iter().zip(elem_exprs).enumerate().for_each(|(i, (ty, expr))| {
let must_use = is_ty_must_use(cx, ty, expr, simplify_uninhabited);

all_trivial &= matches!(must_use, IsTyMustUse::Trivial);
if let IsTyMustUse::Yes(path) = must_use {
nested_must_use.push((i, path));
}
});

if !nested_must_use.is_empty() {
if all_trivial {
// If all tuple elements are trivial, mark the whole tuple as such.
// i.e. don't emit `unused_results` for types such as `((), ())`
IsTyMustUse::Trivial
} else if !nested_must_use.is_empty() {
IsTyMustUse::Yes(MustUsePath::TupleElement(nested_must_use))
} else {
IsTyMustUse::No
Expand Down
71 changes: 52 additions & 19 deletions compiler/rustc_macros/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use syn::{
};

mod kw {
syn::custom_keyword!(non_query);
syn::custom_keyword!(query);
}

Expand Down Expand Up @@ -54,12 +55,37 @@ struct Query {
modifiers: QueryModifiers,
}

impl Parse for Query {
/// Declaration of a non-query dep kind.
/// ```ignore (illustrative)
/// /// Doc comment for `MyNonQuery`.
/// // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doc_comments
/// non_query MyNonQuery
/// // ^^^^^^^^^^ name
/// ```
struct NonQuery {
doc_comments: Vec<Attribute>,
name: Ident,
}

enum QueryEntry {
Query(Query),
NonQuery(NonQuery),
}

impl Parse for QueryEntry {
fn parse(input: ParseStream<'_>) -> Result<Self> {
let mut doc_comments = check_attributes(input.call(Attribute::parse_outer)?)?;

// Try the non-query case first.
if input.parse::<kw::non_query>().is_ok() {
let name: Ident = input.parse()?;
return Ok(QueryEntry::NonQuery(NonQuery { doc_comments, name }));
}

// Parse the query declaration. Like `query type_of(key: DefId) -> Ty<'tcx>`
input.parse::<kw::query>()?;
if input.parse::<kw::query>().is_err() {
return Err(input.error("expected `query` or `non_query`"));
}
let name: Ident = input.parse()?;

// `(key: DefId)`
Expand All @@ -84,7 +110,7 @@ impl Parse for Query {
doc_comments.push(doc_comment_from_desc(&modifiers.desc.expr_list)?);
}

Ok(Query { doc_comments, modifiers, name, key_pat, key_ty, return_ty })
Ok(QueryEntry::Query(Query { doc_comments, modifiers, name, key_pat, key_ty, return_ty }))
}
}

Expand Down Expand Up @@ -375,9 +401,9 @@ fn add_to_analyzer_stream(query: &Query, analyzer_stream: &mut proc_macro2::Toke
// macro producing a higher order macro that has all its token in the macro declaration we lose
// any meaningful spans, resulting in rust-analyzer being unable to make the connection between
// the query name and the corresponding providers field. The trick to fix this is to have
// `rustc_queries` emit a field access with the given name's span which allows it to successfully
// show references / go to definition to the corresponding provider assignment which is usually
// the more interesting place.
// `rustc_queries` emit a field access with the given name's span which allows it to
// successfully show references / go to definition to the corresponding provider assignment
// which is usually the more interesting place.
let ra_hint = quote! {
let crate::query::Providers { #name: _, .. };
};
Expand All @@ -393,9 +419,10 @@ fn add_to_analyzer_stream(query: &Query, analyzer_stream: &mut proc_macro2::Toke
}

pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
let queries = parse_macro_input!(input as List<Query>);
let queries = parse_macro_input!(input as List<QueryEntry>);

let mut query_stream = quote! {};
let mut non_query_stream = quote! {};
let mut helpers = HelperTokenStreams::default();
let mut analyzer_stream = quote! {};
let mut errors = quote! {};
Expand All @@ -411,6 +438,18 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
}

for query in queries.0 {
let query = match query {
QueryEntry::Query(query) => query,
QueryEntry::NonQuery(NonQuery { doc_comments, name }) => {
// Get the exceptional non-query case out of the way first.
non_query_stream.extend(quote! {
#(#doc_comments)*
#name,
});
continue;
}
};

let Query { doc_comments, name, key_ty, return_ty, modifiers, .. } = &query;

// Normalize an absent return type into `-> ()` to make macro-rules parsing easier.
Expand Down Expand Up @@ -486,24 +525,18 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
let HelperTokenStreams { description_fns_stream, cache_on_disk_if_fns_stream } = helpers;

TokenStream::from(quote! {
/// Higher-order macro that invokes the specified macro with a prepared
/// list of all query signatures (including modifiers).
///
/// This allows multiple simpler macros to each have access to the list
/// of queries.
/// Higher-order macro that invokes the specified macro with (a) a list of all query
/// signatures (including modifiers), and (b) a list of non-query names. This allows
/// multiple simpler macros to each have access to these lists.
#[macro_export]
macro_rules! rustc_with_all_queries {
(
// The macro to invoke once, on all queries (plus extras).
// The macro to invoke once, on all queries and non-queries.
$macro:ident!

// Within [], an optional list of extra "query" signatures to
// pass to the given macro, in addition to the actual queries.
$( [$($extra_fake_queries:tt)*] )?
) => {
$macro! {
$( $($extra_fake_queries)* )?
#query_stream
queries { #query_stream }
non_queries { #non_query_stream }
}
}
}
Expand Down
56 changes: 25 additions & 31 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,18 +265,20 @@ impl StableOrd for WorkProductId {
// Note: `$K` and `$V` are unused but present so this can be called by `rustc_with_all_queries`.
macro_rules! define_dep_nodes {
(
$(
$(#[$attr:meta])*
[$($modifiers:tt)*] fn $variant:ident($K:ty) -> $V:ty,
)*
) => {

#[macro_export]
macro_rules! make_dep_kind_array {
($mod:ident) => {[ $($mod::$variant()),* ]};
queries {
$(
$(#[$q_attr:meta])*
[$($modifiers:tt)*]
fn $q_name:ident($K:ty) -> $V:ty,
)*
}

/// This enum serves as an index into arrays built by `make_dep_kind_array`.
non_queries {
$(
$(#[$nq_attr:meta])*
$nq_name:ident,
)*
}
) => {
// This enum has more than u8::MAX variants so we need some kind of multi-byte
// encoding. The derived Encodable/Decodable uses leb128 encoding which is
// dense when only considering this enum. But DepKind is encoded in a larger
Expand All @@ -285,14 +287,18 @@ macro_rules! define_dep_nodes {
#[allow(non_camel_case_types)]
#[repr(u16)] // Must be kept in sync with the rest of `DepKind`.
pub enum DepKind {
$( $( #[$attr] )* $variant),*
$( $(#[$nq_attr])* $nq_name, )*
$( $(#[$q_attr])* $q_name, )*
}

// This computes the number of dep kind variants. Along the way, it sanity-checks that the
// discriminants of the variants have been assigned consecutively from 0 so that they can
// be used as a dense index, and that all discriminants fit in a `u16`.
pub(crate) const DEP_KIND_NUM_VARIANTS: u16 = {
let deps = &[$(DepKind::$variant,)*];
let deps = &[
$(DepKind::$nq_name,)*
$(DepKind::$q_name,)*
];
let mut i = 0;
while i < deps.len() {
if i != deps[i].as_usize() {
Expand All @@ -306,7 +312,8 @@ macro_rules! define_dep_nodes {

pub(super) fn dep_kind_from_label_string(label: &str) -> Result<DepKind, ()> {
match label {
$( stringify!($variant) => Ok(self::DepKind::$variant), )*
$( stringify!($nq_name) => Ok(self::DepKind::$nq_name), )*
$( stringify!($q_name) => Ok(self::DepKind::$q_name), )*
_ => Err(()),
}
}
Expand All @@ -315,27 +322,14 @@ macro_rules! define_dep_nodes {
/// DepNode groups for tests.
#[expect(non_upper_case_globals)]
pub mod label_strs {
$( pub const $variant: &str = stringify!($variant); )*
$( pub const $nq_name: &str = stringify!($nq_name); )*
$( pub const $q_name: &str = stringify!($q_name); )*
}
};
}

// Create various data structures for each query, and also for a few things
// that aren't queries. The key and return types aren't used, hence the use of `()`.
rustc_with_all_queries!(define_dep_nodes![
/// We use this for most things when incr. comp. is turned off.
[] fn Null(()) -> (),
/// We use this to create a forever-red node.
[] fn Red(()) -> (),
/// We use this to create a side effect node.
[] fn SideEffect(()) -> (),
/// We use this to create the anon node with zero dependencies.
[] fn AnonZeroDeps(()) -> (),
[] fn TraitSelect(()) -> (),
[] fn CompileCodegenUnit(()) -> (),
[] fn CompileMonoItem(()) -> (),
[] fn Metadata(()) -> (),
]);
// Create various data structures for each query, and also for a few things that aren't queries.
rustc_with_all_queries! { define_dep_nodes! }

// WARNING: `construct` is generic and does not know that `CompileCodegenUnit` takes `Symbol`s as keys.
// Be very careful changing this type signature!
Expand Down
17 changes: 17 additions & 0 deletions compiler/rustc_middle/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2771,6 +2771,23 @@ rustc_queries! {
cache_on_disk_if { *cnum == LOCAL_CRATE }
separate_provide_extern
}

//-----------------------------------------------------------------------------
// "Non-queries" are special dep kinds that are not queries.
//-----------------------------------------------------------------------------

/// We use this for most things when incr. comp. is turned off.
non_query Null
/// We use this to create a forever-red node.
non_query Red
/// We use this to create a side effect node.
non_query SideEffect
/// We use this to create the anon node with zero dependencies.
non_query AnonZeroDeps
non_query TraitSelect
non_query CompileCodegenUnit
non_query CompileMonoItem
non_query Metadata
}

rustc_with_all_queries! { define_callbacks! }
14 changes: 9 additions & 5 deletions compiler/rustc_middle/src/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,15 @@ macro_rules! define_callbacks {
(
// You might expect the key to be `$K:ty`, but it needs to be `$($K:tt)*` so that
// `query_helper_param_ty!` can match on specific type names.
$(
$(#[$attr:meta])*
[$($modifiers:tt)*]
fn $name:ident($($K:tt)*) -> $V:ty,
)*
queries {
$(
$(#[$attr:meta])*
[$($modifiers:tt)*]
fn $name:ident($($K:tt)*) -> $V:ty,
)*
}
// Non-queries are unused here.
non_queries { $($_:tt)* }
) => {
$(
#[allow(unused_lifetimes)]
Expand Down
Loading
Loading