Skip to content

Commit ee268a8

Browse files
committed
Auto merge of #150206 - Kivooeo:rollup-ddh45d8, r=Kivooeo
Rollup of 7 pull requests Successful merges: - #147552 ([Debugger Visualizers] Optimize lookup behavior) - #149437 (Fix trailing newline in JUnit formatter) - #149812 (Add const default for OnceCell and OnceLock) - #150035 (fix docustring on fetch_or) - #150160 (Fix ICE (#149980) for invalid EII in statement position) - #150191 (change non-canonical clone impl to {*self}, fix some doc comments) - #150203 (Drop the From derive macro from the v1 prelude) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 24139cf + 5cbd1ca commit ee268a8

File tree

27 files changed

+439
-294
lines changed

27 files changed

+439
-294
lines changed

compiler/rustc_builtin_macros/src/eii.rs

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,18 @@ fn eii_(
6060
) -> Vec<Annotatable> {
6161
let eii_attr_span = ecx.with_def_site_ctxt(eii_attr_span);
6262

63-
let (item, stmt) = if let Annotatable::Item(item) = item {
64-
(item, false)
63+
let (item, wrap_item): (_, &dyn Fn(_) -> _) = if let Annotatable::Item(item) = item {
64+
(item, &Annotatable::Item)
6565
} else if let Annotatable::Stmt(ref stmt) = item
6666
&& let StmtKind::Item(ref item) = stmt.kind
6767
{
68-
(item.clone(), true)
68+
(item.clone(), &|item| {
69+
Annotatable::Stmt(Box::new(Stmt {
70+
id: DUMMY_NODE_ID,
71+
kind: StmtKind::Item(item),
72+
span: eii_attr_span,
73+
}))
74+
})
6975
} else {
7076
ecx.dcx().emit_err(EiiSharedMacroExpectedFunction {
7177
span: eii_attr_span,
@@ -74,23 +80,25 @@ fn eii_(
7480
return vec![item];
7581
};
7682

77-
let orig_item = item.clone();
78-
79-
let item = *item;
80-
81-
let ast::Item { attrs, id: _, span: _, vis, kind: ItemKind::Fn(func), tokens: _ } = item else {
83+
let ast::Item { attrs, id: _, span: _, vis, kind: ItemKind::Fn(func), tokens: _ } =
84+
item.as_ref()
85+
else {
8286
ecx.dcx().emit_err(EiiSharedMacroExpectedFunction {
8387
span: eii_attr_span,
8488
name: path_to_string(&meta_item.path),
8589
});
86-
return vec![Annotatable::Item(Box::new(item))];
90+
return vec![wrap_item(item)];
8791
};
92+
// only clone what we need
93+
let attrs = attrs.clone();
94+
let func = (**func).clone();
95+
let vis = vis.clone();
8896

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

92100
let Ok(macro_name) = name_for_impl_macro(ecx, &func, &meta_item) else {
93-
return vec![Annotatable::Item(orig_item)];
101+
return vec![wrap_item(item)];
94102
};
95103

96104
// span of the declaring item without attributes
@@ -115,7 +123,7 @@ fn eii_(
115123
ecx,
116124
eii_attr_span,
117125
item_span,
118-
*func,
126+
func,
119127
vis,
120128
&attrs_from_decl,
121129
)));
@@ -128,20 +136,7 @@ fn eii_(
128136
decl_span,
129137
)));
130138

131-
if stmt {
132-
return_items
133-
.into_iter()
134-
.map(|i| {
135-
Annotatable::Stmt(Box::new(Stmt {
136-
id: DUMMY_NODE_ID,
137-
kind: StmtKind::Item(i),
138-
span: eii_attr_span,
139-
}))
140-
})
141-
.collect()
142-
} else {
143-
return_items.into_iter().map(|i| Annotatable::Item(i)).collect()
144-
}
139+
return_items.into_iter().map(wrap_item).collect()
145140
}
146141

147142
/// Decide on the name of the macro that can be used to implement the EII.

compiler/rustc_graphviz/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ impl<'a> Id<'a> {
416416
/// it in the generated .dot file. They can also provide more
417417
/// elaborate (and non-unique) label text that is used in the graphviz
418418
/// rendered output.
419-
419+
///
420420
/// The graph instance is responsible for providing the DOT compatible
421421
/// identifiers for the nodes and (optionally) rendered labels for the nodes and
422422
/// edges, as well as an identifier for the graph itself.

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2654,7 +2654,7 @@ struct InternedInSet<'tcx, T: ?Sized + PointeeSized>(&'tcx T);
26542654

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

compiler/rustc_pattern_analysis/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub struct MatchArm<'p, Cx: PatCx> {
141141

142142
impl<'p, Cx: PatCx> Clone for MatchArm<'p, Cx> {
143143
fn clone(&self) -> Self {
144-
Self { pat: self.pat, has_guard: self.has_guard, arm_data: self.arm_data }
144+
*self
145145
}
146146
}
147147

compiler/rustc_pattern_analysis/src/pat.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,7 @@ pub(crate) enum PatOrWild<'p, Cx: PatCx> {
174174

175175
impl<'p, Cx: PatCx> Clone for PatOrWild<'p, Cx> {
176176
fn clone(&self) -> Self {
177-
match self {
178-
PatOrWild::Wild => PatOrWild::Wild,
179-
PatOrWild::Pat(pat) => PatOrWild::Pat(pat),
180-
}
177+
*self
181178
}
182179
}
183180

compiler/rustc_pattern_analysis/src/usefulness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ struct PlaceCtxt<'a, Cx: PatCx> {
824824
impl<'a, Cx: PatCx> Copy for PlaceCtxt<'a, Cx> {}
825825
impl<'a, Cx: PatCx> Clone for PlaceCtxt<'a, Cx> {
826826
fn clone(&self) -> Self {
827-
Self { cx: self.cx, ty: self.ty }
827+
*self
828828
}
829829
}
830830

compiler/rustc_thread_pool/src/registry.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ pub struct Registry {
153153
terminate_count: AtomicUsize,
154154
}
155155

156-
/// ////////////////////////////////////////////////////////////////////////
157-
/// Initialization
156+
///////////////////////////////////////////////////////////////////////////
157+
// Initialization
158158

159159
static mut THE_REGISTRY: Option<Arc<Registry>> = None;
160160
static THE_REGISTRY_SET: Once = Once::new();
@@ -407,12 +407,12 @@ impl Registry {
407407
}
408408
}
409409

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

671-
/// ////////////////////////////////////////////////////////////////////////
672-
/// WorkerThread identifiers
671+
///////////////////////////////////////////////////////////////////////////
672+
// WorkerThread identifiers
673673

674674
pub(super) struct WorkerThread {
675675
/// the "worker" half of our local deque
@@ -1019,8 +1019,6 @@ impl WorkerThread {
10191019
}
10201020
}
10211021

1022-
/// ////////////////////////////////////////////////////////////////////////
1023-
10241022
unsafe fn main_loop(thread: ThreadBuilder) {
10251023
let worker_thread = &WorkerThread::from(thread);
10261024
unsafe { WorkerThread::set_current(worker_thread) };

library/core/src/cell/once.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ impl<T> OnceCell<T> {
353353
}
354354

355355
#[stable(feature = "once_cell", since = "1.70.0")]
356-
impl<T> Default for OnceCell<T> {
356+
#[rustc_const_unstable(feature = "const_default", issue = "143894")]
357+
impl<T> const Default for OnceCell<T> {
357358
#[inline]
358359
fn default() -> Self {
359360
Self::new()

library/core/src/prelude/v1.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,6 @@ pub use crate::macros::builtin::deref;
118118
)]
119119
pub use crate::macros::builtin::define_opaque;
120120

121-
#[unstable(
122-
feature = "derive_from",
123-
issue = "144889",
124-
reason = "`derive(From)` is unstable"
125-
)]
126-
pub use crate::macros::builtin::From;
127-
128121
#[unstable(feature = "extern_item_impls", issue = "125418")]
129122
pub use crate::macros::builtin::{eii, unsafe_eii};
130123

library/core/src/sync/atomic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,8 +1151,8 @@ impl AtomicBool {
11511151
/// assert_eq!(foo.fetch_or(false, Ordering::SeqCst), true);
11521152
/// assert_eq!(foo.load(Ordering::SeqCst), true);
11531153
///
1154-
/// let foo = AtomicBool::new(true);
1155-
/// assert_eq!(foo.fetch_or(true, Ordering::SeqCst), true);
1154+
/// let foo = AtomicBool::new(false);
1155+
/// assert_eq!(foo.fetch_or(true, Ordering::SeqCst), false);
11561156
/// assert_eq!(foo.load(Ordering::SeqCst), true);
11571157
///
11581158
/// let foo = AtomicBool::new(false);

0 commit comments

Comments
 (0)