Skip to content

Commit 408bbd0

Browse files
committed
Auto merge of #112317 - GuillaumeGomez:rollup-toh0gpo, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - #112243 (Remove unneeded `Buffer` allocations when `&mut fmt::Write` can be used directly) - #112263 (Remove ExtendElement, ExtendWith, extend_with) - #112291 (Disable RustAnalyzer check by default, run Rustfmt check before) - #112299 (Don't double-print status messages in GHA) - #112311 (Ignore fluent message reordering in `git blame`) - #112315 (fix spelling error) Failed merges: - #112251 (rustdoc: convert `if let Some()` that always matches to variable) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2f896da + 7c363c2 commit 408bbd0

File tree

11 files changed

+39
-57
lines changed

11 files changed

+39
-57
lines changed

.git-blame-ignore-revs

+2
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ c34fbfaad38cf5829ef5cfe780dc9d58480adeaa
1414
cf2dff2b1e3fa55fa5415d524200070d0d7aacfe
1515
# Run rustfmt on bootstrap
1616
b39a1d6f1a30ba29f25d7141038b9a5bf0126e36
17+
# reorder fluent message files
18+
f97fddab91fbf290ea5b691fe355d6f915220b6e

compiler/rustc_driver/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This crate is intentionally empty and a rexport of `rustc_driver_impl` to allow the code in
1+
// This crate is intentionally empty and a re-export of `rustc_driver_impl` to allow the code in
22
// `rustc_driver_impl` to be compiled in parallel with other crates.
33

44
pub use rustc_driver_impl::*;

library/alloc/src/vec/mod.rs

+7-23
Original file line numberDiff line numberDiff line change
@@ -2355,7 +2355,7 @@ impl<T: Clone, A: Allocator> Vec<T, A> {
23552355
let len = self.len();
23562356

23572357
if new_len > len {
2358-
self.extend_with(new_len - len, ExtendElement(value))
2358+
self.extend_with(new_len - len, value)
23592359
} else {
23602360
self.truncate(new_len);
23612361
}
@@ -2469,26 +2469,10 @@ impl<T, A: Allocator, const N: usize> Vec<[T; N], A> {
24692469
}
24702470
}
24712471

2472-
// This code generalizes `extend_with_{element,default}`.
2473-
trait ExtendWith<T> {
2474-
fn next(&mut self) -> T;
2475-
fn last(self) -> T;
2476-
}
2477-
2478-
struct ExtendElement<T>(T);
2479-
impl<T: Clone> ExtendWith<T> for ExtendElement<T> {
2480-
fn next(&mut self) -> T {
2481-
self.0.clone()
2482-
}
2483-
fn last(self) -> T {
2484-
self.0
2485-
}
2486-
}
2487-
2488-
impl<T, A: Allocator> Vec<T, A> {
2472+
impl<T: Clone, A: Allocator> Vec<T, A> {
24892473
#[cfg(not(no_global_oom_handling))]
2490-
/// Extend the vector by `n` values, using the given generator.
2491-
fn extend_with<E: ExtendWith<T>>(&mut self, n: usize, mut value: E) {
2474+
/// Extend the vector by `n` clones of value.
2475+
fn extend_with(&mut self, n: usize, value: T) {
24922476
self.reserve(n);
24932477

24942478
unsafe {
@@ -2500,15 +2484,15 @@ impl<T, A: Allocator> Vec<T, A> {
25002484

25012485
// Write all elements except the last one
25022486
for _ in 1..n {
2503-
ptr::write(ptr, value.next());
2487+
ptr::write(ptr, value.clone());
25042488
ptr = ptr.add(1);
2505-
// Increment the length in every step in case next() panics
2489+
// Increment the length in every step in case clone() panics
25062490
local_len.increment_len(1);
25072491
}
25082492

25092493
if n > 0 {
25102494
// We can write the last element directly without cloning needlessly
2511-
ptr::write(ptr, value.last());
2495+
ptr::write(ptr, value);
25122496
local_len.increment_len(1);
25132497
}
25142498

library/alloc/src/vec/spec_from_elem.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::ptr;
33
use crate::alloc::Allocator;
44
use crate::raw_vec::RawVec;
55

6-
use super::{ExtendElement, IsZero, Vec};
6+
use super::{IsZero, Vec};
77

88
// Specialization trait used for Vec::from_elem
99
pub(super) trait SpecFromElem: Sized {
@@ -13,7 +13,7 @@ pub(super) trait SpecFromElem: Sized {
1313
impl<T: Clone> SpecFromElem for T {
1414
default fn from_elem<A: Allocator>(elem: Self, n: usize, alloc: A) -> Vec<Self, A> {
1515
let mut v = Vec::with_capacity_in(n, alloc);
16-
v.extend_with(n, ExtendElement(elem));
16+
v.extend_with(n, elem);
1717
v
1818
}
1919
}
@@ -25,7 +25,7 @@ impl<T: Clone + IsZero> SpecFromElem for T {
2525
return Vec { buf: RawVec::with_capacity_zeroed_in(n, alloc), len: n };
2626
}
2727
let mut v = Vec::with_capacity_in(n, alloc);
28-
v.extend_with(n, ExtendElement(elem));
28+
v.extend_with(n, elem);
2929
v
3030
}
3131
}

src/bootstrap/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,8 @@ impl<'a> Builder<'a> {
703703
check::CargoMiri,
704704
check::MiroptTestTools,
705705
check::Rls,
706-
check::RustAnalyzer,
707706
check::Rustfmt,
707+
check::RustAnalyzer,
708708
check::Bootstrap
709709
),
710710
Kind::Test => describe!(

src/bootstrap/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ pub struct RustAnalyzer {
347347
impl Step for RustAnalyzer {
348348
type Output = ();
349349
const ONLY_HOSTS: bool = true;
350-
const DEFAULT: bool = true;
350+
const DEFAULT: bool = false;
351351

352352
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
353353
run.path("src/tools/rust-analyzer")

src/bootstrap/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,6 @@ impl Build {
10691069
}
10701070

10711071
fn group(&self, msg: &str) -> Option<gha::Group> {
1072-
self.info(&msg);
10731072
match self.config.dry_run {
10741073
DryRun::SelfCheck => None,
10751074
DryRun::Disabled | DryRun::UserSelected => Some(gha::group(&msg)),

src/librustdoc/html/render/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1040,9 +1040,9 @@ fn render_attributes_in_pre<'a, 'b: 'a>(
10401040

10411041
// When an attribute is rendered inside a <code> tag, it is formatted using
10421042
// a div to produce a newline after it.
1043-
fn render_attributes_in_code(w: &mut Buffer, it: &clean::Item, tcx: TyCtxt<'_>) {
1044-
for a in it.attributes(tcx, false) {
1045-
write!(w, "<div class=\"code-attribute\">{}</div>", a);
1043+
fn render_attributes_in_code(w: &mut impl fmt::Write, it: &clean::Item, tcx: TyCtxt<'_>) {
1044+
for attr in it.attributes(tcx, false) {
1045+
write!(w, "<div class=\"code-attribute\">{attr}</div>").unwrap();
10461046
}
10471047
}
10481048

src/librustdoc/html/render/print_item.rs

+16-21
Original file line numberDiff line numberDiff line change
@@ -1431,30 +1431,28 @@ fn item_proc_macro(
14311431
it: &clean::Item,
14321432
m: &clean::ProcMacro,
14331433
) {
1434-
let mut buffer = Buffer::new();
1435-
wrap_item(&mut buffer, |buffer| {
1434+
wrap_item(w, |buffer| {
14361435
let name = it.name.expect("proc-macros always have names");
14371436
match m.kind {
14381437
MacroKind::Bang => {
1439-
write!(buffer, "{}!() {{ /* proc-macro */ }}", name);
1438+
write!(buffer, "{name}!() {{ /* proc-macro */ }}").unwrap();
14401439
}
14411440
MacroKind::Attr => {
1442-
write!(buffer, "#[{}]", name);
1441+
write!(buffer, "#[{name}]").unwrap();
14431442
}
14441443
MacroKind::Derive => {
1445-
write!(buffer, "#[derive({})]", name);
1444+
write!(buffer, "#[derive({name})]").unwrap();
14461445
if !m.helpers.is_empty() {
1447-
buffer.push_str("\n{\n");
1448-
buffer.push_str(" // Attributes available to this derive:\n");
1446+
buffer.write_str("\n{\n // Attributes available to this derive:\n").unwrap();
14491447
for attr in &m.helpers {
1450-
writeln!(buffer, " #[{}]", attr);
1448+
writeln!(buffer, " #[{attr}]").unwrap();
14511449
}
1452-
buffer.push_str("}\n");
1450+
buffer.write_str("}\n").unwrap();
14531451
}
14541452
}
14551453
}
14561454
});
1457-
write!(w, "{}{}", buffer.into_inner(), document(cx, it, None, HeadingOffset::H2)).unwrap();
1455+
write!(w, "{}", document(cx, it, None, HeadingOffset::H2)).unwrap();
14581456
}
14591457

14601458
fn item_primitive(w: &mut impl fmt::Write, cx: &mut Context<'_>, it: &clean::Item) {
@@ -1571,8 +1569,7 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
15711569
}
15721570

15731571
fn item_static(w: &mut impl fmt::Write, cx: &mut Context<'_>, it: &clean::Item, s: &clean::Static) {
1574-
let mut buffer = Buffer::new();
1575-
wrap_item(&mut buffer, |buffer| {
1572+
wrap_item(w, |buffer| {
15761573
render_attributes_in_code(buffer, it, cx.tcx());
15771574
write!(
15781575
buffer,
@@ -1581,29 +1578,27 @@ fn item_static(w: &mut impl fmt::Write, cx: &mut Context<'_>, it: &clean::Item,
15811578
mutability = s.mutability.print_with_space(),
15821579
name = it.name.unwrap(),
15831580
typ = s.type_.print(cx)
1584-
);
1581+
)
1582+
.unwrap();
15851583
});
15861584

1587-
write!(w, "{}", buffer.into_inner()).unwrap();
1588-
15891585
write!(w, "{}", document(cx, it, None, HeadingOffset::H2)).unwrap();
15901586
}
15911587

15921588
fn item_foreign_type(w: &mut impl fmt::Write, cx: &mut Context<'_>, it: &clean::Item) {
1593-
let mut buffer = Buffer::new();
1594-
wrap_item(&mut buffer, |buffer| {
1595-
buffer.write_str("extern {\n");
1589+
wrap_item(w, |buffer| {
1590+
buffer.write_str("extern {\n").unwrap();
15961591
render_attributes_in_code(buffer, it, cx.tcx());
15971592
write!(
15981593
buffer,
15991594
" {}type {};\n}}",
16001595
visibility_print_with_space(it.visibility(cx.tcx()), it.item_id, cx),
16011596
it.name.unwrap(),
1602-
);
1597+
)
1598+
.unwrap();
16031599
});
16041600

1605-
write!(w, "{}{}", buffer.into_inner(), document(cx, it, None, HeadingOffset::H2)).unwrap();
1606-
1601+
write!(w, "{}", document(cx, it, None, HeadingOffset::H2)).unwrap();
16071602
write!(w, "{}", render_assoc_items(cx, it, it.item_id.expect_def_id(), AssocItemRender::All))
16081603
.unwrap();
16091604
}

src/librustdoc/visit_ast.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
147147

148148
// `#[macro_export] macro_rules!` items are reexported at the top level of the
149149
// crate, regardless of where they're defined. We want to document the
150-
// top level rexport of the macro, not its original definition, since
151-
// the rexport defines the path that a user will actually see. Accordingly,
152-
// we add the rexport as an item here, and then skip over the original
150+
// top level re-export of the macro, not its original definition, since
151+
// the re-export defines the path that a user will actually see. Accordingly,
152+
// we add the re-export as an item here, and then skip over the original
153153
// definition in `visit_item()` below.
154154
//
155155
// We also skip `#[macro_export] macro_rules!` that have already been inserted,

src/tools/build_helper/src/ci.rs

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ pub mod gha {
4646
pub fn group(name: impl std::fmt::Display) -> Group {
4747
if std::env::var_os("GITHUB_ACTIONS").is_some() {
4848
eprintln!("::group::{name}");
49+
} else {
50+
eprintln!("{name}")
4951
}
5052
Group(())
5153
}

0 commit comments

Comments
 (0)