Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
05d5c23
change RustType from string literals to enum
Walnut356 Oct 5, 2025
1dce926
remove unnecessary regex usage
Walnut356 Oct 6, 2025
58c5266
use direct providers when possible
Walnut356 Oct 10, 2025
4463c58
fix tests
Walnut356 Nov 15, 2025
df38e15
Add const default for OnceCell and OnceLock
tisonkun Dec 9, 2025
e39e127
libtest: Stricter XML validation
ilammy Dec 13, 2025
2cc4348
rustdoc: Test --format=junit
ilammy Dec 13, 2025
069cf9d
rustdoc: Write newline differently
ilammy Nov 29, 2025
3493f8c
fix docustring on fetch_or
agavra Dec 15, 2025
a8f4a67
rustdoc: Test only in stage2
ilammy Dec 16, 2025
897e88c
add test for 149980
jdonszelmann Dec 19, 2025
c316c05
refactor how eii expansion is wrapped fixing 149980
jdonszelmann Dec 19, 2025
5d8a096
change non-canonical clone impl to {*self}, fix some doc comments
hkBst Dec 19, 2025
93fbf3b
Drop the From derive macro from the v1 prelude
jtgeibel Dec 20, 2025
8b70a02
Rollup merge of #147552 - Walnut356:cleanup, r=Mark-Simulacrum
Kivooeo Dec 20, 2025
adcbb1f
Rollup merge of #149437 - ilammy:patch-1, r=Mark-Simulacrum
Kivooeo Dec 20, 2025
2e054a1
Rollup merge of #149812 - tisonkun:oncelock-const-default, r=Mark-Sim…
Kivooeo Dec 20, 2025
6064862
Rollup merge of #150035 - agavra:patch-1, r=Mark-Simulacrum
Kivooeo Dec 20, 2025
27b8c9a
Rollup merge of #150160 - jdonszelmann:fix-149980, r=Kivooeo
Kivooeo Dec 20, 2025
a340500
Rollup merge of #150191 - hkBst:clippy-fix-15, r=Kivooeo
Kivooeo Dec 20, 2025
5cbd1ca
Rollup merge of #150203 - jtgeibel:drop-From-derive-macro-from-prelud…
Kivooeo Dec 20, 2025
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
45 changes: 20 additions & 25 deletions compiler/rustc_builtin_macros/src/eii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,18 @@ fn eii_(
) -> Vec<Annotatable> {
let eii_attr_span = ecx.with_def_site_ctxt(eii_attr_span);

let (item, stmt) = if let Annotatable::Item(item) = item {
(item, false)
let (item, wrap_item): (_, &dyn Fn(_) -> _) = if let Annotatable::Item(item) = item {
(item, &Annotatable::Item)
} else if let Annotatable::Stmt(ref stmt) = item
&& let StmtKind::Item(ref item) = stmt.kind
{
(item.clone(), true)
(item.clone(), &|item| {
Annotatable::Stmt(Box::new(Stmt {
id: DUMMY_NODE_ID,
kind: StmtKind::Item(item),
span: eii_attr_span,
}))
})
} else {
ecx.dcx().emit_err(EiiSharedMacroExpectedFunction {
span: eii_attr_span,
Expand All @@ -74,23 +80,25 @@ fn eii_(
return vec![item];
};

let orig_item = item.clone();

let item = *item;

let ast::Item { attrs, id: _, span: _, vis, kind: ItemKind::Fn(func), tokens: _ } = item else {
let ast::Item { attrs, id: _, span: _, vis, kind: ItemKind::Fn(func), tokens: _ } =
item.as_ref()
else {
ecx.dcx().emit_err(EiiSharedMacroExpectedFunction {
span: eii_attr_span,
name: path_to_string(&meta_item.path),
});
return vec![Annotatable::Item(Box::new(item))];
return vec![wrap_item(item)];
};
// only clone what we need
let attrs = attrs.clone();
let func = (**func).clone();
let vis = vis.clone();

let attrs_from_decl =
filter_attrs_for_multiple_eii_attr(ecx, attrs, eii_attr_span, &meta_item.path);

let Ok(macro_name) = name_for_impl_macro(ecx, &func, &meta_item) else {
return vec![Annotatable::Item(orig_item)];
return vec![wrap_item(item)];
};

// span of the declaring item without attributes
Expand All @@ -115,7 +123,7 @@ fn eii_(
ecx,
eii_attr_span,
item_span,
*func,
func,
vis,
&attrs_from_decl,
)));
Expand All @@ -128,20 +136,7 @@ fn eii_(
decl_span,
)));

if stmt {
return_items
.into_iter()
.map(|i| {
Annotatable::Stmt(Box::new(Stmt {
id: DUMMY_NODE_ID,
kind: StmtKind::Item(i),
span: eii_attr_span,
}))
})
.collect()
} else {
return_items.into_iter().map(|i| Annotatable::Item(i)).collect()
}
return_items.into_iter().map(wrap_item).collect()
}

/// Decide on the name of the macro that can be used to implement the EII.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_graphviz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ impl<'a> Id<'a> {
/// it in the generated .dot file. They can also provide more
/// elaborate (and non-unique) label text that is used in the graphviz
/// rendered output.
///
/// The graph instance is responsible for providing the DOT compatible
/// identifiers for the nodes and (optionally) rendered labels for the nodes and
/// edges, as well as an identifier for the graph itself.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2654,7 +2654,7 @@ struct InternedInSet<'tcx, T: ?Sized + PointeeSized>(&'tcx T);

impl<'tcx, T: 'tcx + ?Sized + PointeeSized> Clone for InternedInSet<'tcx, T> {
fn clone(&self) -> Self {
InternedInSet(self.0)
*self
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_pattern_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub struct MatchArm<'p, Cx: PatCx> {

impl<'p, Cx: PatCx> Clone for MatchArm<'p, Cx> {
fn clone(&self) -> Self {
Self { pat: self.pat, has_guard: self.has_guard, arm_data: self.arm_data }
*self
}
}

Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_pattern_analysis/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,7 @@ pub(crate) enum PatOrWild<'p, Cx: PatCx> {

impl<'p, Cx: PatCx> Clone for PatOrWild<'p, Cx> {
fn clone(&self) -> Self {
match self {
PatOrWild::Wild => PatOrWild::Wild,
PatOrWild::Pat(pat) => PatOrWild::Pat(pat),
}
*self
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_pattern_analysis/src/usefulness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ struct PlaceCtxt<'a, Cx: PatCx> {
impl<'a, Cx: PatCx> Copy for PlaceCtxt<'a, Cx> {}
impl<'a, Cx: PatCx> Clone for PlaceCtxt<'a, Cx> {
fn clone(&self) -> Self {
Self { cx: self.cx, ty: self.ty }
*self
}
}

Expand Down
14 changes: 6 additions & 8 deletions compiler/rustc_thread_pool/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ pub struct Registry {
terminate_count: AtomicUsize,
}

/// ////////////////////////////////////////////////////////////////////////
/// Initialization
///////////////////////////////////////////////////////////////////////////
// Initialization

static mut THE_REGISTRY: Option<Arc<Registry>> = None;
static THE_REGISTRY_SET: Once = Once::new();
Expand Down Expand Up @@ -407,12 +407,12 @@ impl Registry {
}
}

/// ////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
/// MAIN LOOP
///
/// So long as all of the worker threads are hanging out in their
/// top-level loop, there is no work to be done.
///
/// Push a job into the given `registry`. If we are running on a
/// worker thread for the registry, this will push onto the
/// deque. Else, it will inject from the outside (which is slower).
Expand Down Expand Up @@ -668,8 +668,8 @@ impl ThreadInfo {
}
}

/// ////////////////////////////////////////////////////////////////////////
/// WorkerThread identifiers
///////////////////////////////////////////////////////////////////////////
// WorkerThread identifiers

pub(super) struct WorkerThread {
/// the "worker" half of our local deque
Expand Down Expand Up @@ -1019,8 +1019,6 @@ impl WorkerThread {
}
}

/// ////////////////////////////////////////////////////////////////////////
unsafe fn main_loop(thread: ThreadBuilder) {
let worker_thread = &WorkerThread::from(thread);
unsafe { WorkerThread::set_current(worker_thread) };
Expand Down
3 changes: 2 additions & 1 deletion library/core/src/cell/once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ impl<T> OnceCell<T> {
}

#[stable(feature = "once_cell", since = "1.70.0")]
impl<T> Default for OnceCell<T> {
#[rustc_const_unstable(feature = "const_default", issue = "143894")]
impl<T> const Default for OnceCell<T> {
#[inline]
fn default() -> Self {
Self::new()
Expand Down
7 changes: 0 additions & 7 deletions library/core/src/prelude/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,6 @@ pub use crate::macros::builtin::deref;
)]
pub use crate::macros::builtin::define_opaque;

#[unstable(
feature = "derive_from",
issue = "144889",
reason = "`derive(From)` is unstable"
)]
pub use crate::macros::builtin::From;

#[unstable(feature = "extern_item_impls", issue = "125418")]
pub use crate::macros::builtin::{eii, unsafe_eii};

Expand Down
4 changes: 2 additions & 2 deletions library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1151,8 +1151,8 @@ impl AtomicBool {
/// assert_eq!(foo.fetch_or(false, Ordering::SeqCst), true);
/// assert_eq!(foo.load(Ordering::SeqCst), true);
///
/// let foo = AtomicBool::new(true);
/// assert_eq!(foo.fetch_or(true, Ordering::SeqCst), true);
/// let foo = AtomicBool::new(false);
/// assert_eq!(foo.fetch_or(true, Ordering::SeqCst), false);
/// assert_eq!(foo.load(Ordering::SeqCst), true);
///
/// let foo = AtomicBool::new(false);
Expand Down
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@
#![feature(cfg_sanitizer_cfi)]
#![feature(cfg_target_thread_local)]
#![feature(cfi_encoding)]
#![feature(const_default)]
#![feature(const_trait_impl)]
#![feature(core_float_math)]
#![feature(decl_macro)]
Expand Down
3 changes: 2 additions & 1 deletion library/std/src/sync/once_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,8 @@ impl<T: RefUnwindSafe + UnwindSafe> RefUnwindSafe for OnceLock<T> {}
impl<T: UnwindSafe> UnwindSafe for OnceLock<T> {}

#[stable(feature = "once_cell", since = "1.70.0")]
impl<T> Default for OnceLock<T> {
#[rustc_const_unstable(feature = "const_default", issue = "143894")]
impl<T> const Default for OnceLock<T> {
/// Creates a new uninitialized cell.
///
/// # Example
Expand Down
6 changes: 4 additions & 2 deletions library/test/src/formatters/junit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ impl<T: Write> OutputFormatter for JunitFormatter<T> {
compilation_time: f64,
) -> io::Result<()> {
self.write_message(&format!(
"<report total_time=\"{total_time}\" compilation_time=\"{compilation_time}\"></report>\n",
))
"<report total_time=\"{total_time}\" compilation_time=\"{compilation_time}\"></report>",
))?;
self.out.write_all(b"\n")?;
Ok(())
}
}

Expand Down
46 changes: 23 additions & 23 deletions src/etc/gdb_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re

from gdb_providers import *
from rust_types import *
from rust_types import RustType, classify_struct, classify_union


_gdb_version_matched = re.search("([0-9]+)\\.([0-9]+)", gdb.VERSION)
Expand All @@ -28,7 +28,7 @@ def classify_rust_type(type):
if type_class == gdb.TYPE_CODE_UNION:
return classify_union(type.fields())

return RustType.OTHER
return RustType.Other


def check_enum_discriminant(valobj):
Expand Down Expand Up @@ -85,7 +85,7 @@ def __init__(self, name):

def add(self, rust_type, provider):
# Just use the rust_type as the name.
printer = PrintByRustType(rust_type, provider)
printer = PrintByRustType(rust_type.name, provider)
self.type_map[rust_type] = printer
self.subprinters.append(printer)

Expand All @@ -99,23 +99,23 @@ def __call__(self, valobj):
printer = RustPrettyPrinter("rust")
# use enum provider only for GDB <7.12
if gdb_version[0] < 7 or (gdb_version[0] == 7 and gdb_version[1] < 12):
printer.add(RustType.ENUM, enum_provider)
printer.add(RustType.STD_STRING, StdStringProvider)
printer.add(RustType.STD_OS_STRING, StdOsStringProvider)
printer.add(RustType.STD_STR, StdStrProvider)
printer.add(RustType.STD_SLICE, StdSliceProvider)
printer.add(RustType.STD_VEC, StdVecProvider)
printer.add(RustType.STD_VEC_DEQUE, StdVecDequeProvider)
printer.add(RustType.STD_BTREE_SET, StdBTreeSetProvider)
printer.add(RustType.STD_BTREE_MAP, StdBTreeMapProvider)
printer.add(RustType.STD_HASH_MAP, hashmap_provider)
printer.add(RustType.STD_HASH_SET, hashset_provider)
printer.add(RustType.STD_RC, StdRcProvider)
printer.add(RustType.STD_ARC, lambda valobj: StdRcProvider(valobj, is_atomic=True))

printer.add(RustType.STD_CELL, StdCellProvider)
printer.add(RustType.STD_REF, StdRefProvider)
printer.add(RustType.STD_REF_MUT, StdRefProvider)
printer.add(RustType.STD_REF_CELL, StdRefCellProvider)

printer.add(RustType.STD_NONZERO_NUMBER, StdNonZeroNumberProvider)
printer.add(RustType.Enum, enum_provider)
printer.add(RustType.StdString, StdStringProvider)
printer.add(RustType.StdOsString, StdOsStringProvider)
printer.add(RustType.StdStr, StdStrProvider)
printer.add(RustType.StdSlice, StdSliceProvider)
printer.add(RustType.StdVec, StdVecProvider)
printer.add(RustType.StdVecDeque, StdVecDequeProvider)
printer.add(RustType.StdBTreeSet, StdBTreeSetProvider)
printer.add(RustType.StdBTreeMap, StdBTreeMapProvider)
printer.add(RustType.StdHashMap, hashmap_provider)
printer.add(RustType.StdHashSet, hashset_provider)
printer.add(RustType.StdRc, StdRcProvider)
printer.add(RustType.StdArc, lambda valobj: StdRcProvider(valobj, is_atomic=True))

printer.add(RustType.StdCell, StdCellProvider)
printer.add(RustType.StdRef, StdRefProvider)
printer.add(RustType.StdRefMut, StdRefProvider)
printer.add(RustType.StdRefCell, StdRefCellProvider)

printer.add(RustType.StdNonZeroNumber, StdNonZeroNumberProvider)
Loading
Loading