Skip to content

Commit 0ba9db8

Browse files
committed
Auto merge of #129108 - matthiaskrgr:rollup-t4rjwgp, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #125970 (CommandExt::before_exec: deprecate safety in edition 2024) - #127905 (Add powerpc-unknown-linux-muslspe compile target) - #128925 (derive(SmartPointer): register helper attributes) - #128946 (Hash Ipv*Addr as an integer) - #128963 (Add possibility to generate rustdoc JSON output to stdout) - #129015 (Update books) - #129067 (Use `append` instead of `extend(drain(..))`) - #129100 (Fix dependencies cron job) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 13a5289 + e14f171 commit 0ba9db8

38 files changed

+419
-66
lines changed

.github/workflows/dependencies.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
- name: cargo update rustbook
6868
run: |
6969
echo -e "\nrustbook dependencies:" >> cargo_update.log
70-
cargo update --manifest-path src/tools/rustbook 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
70+
cargo update --manifest-path src/tools/rustbook/Cargo.toml 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
7171
- name: upload Cargo.lock artifact for use in PR
7272
uses: actions/upload-artifact@v4
7373
with:

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1775,9 +1775,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
17751775

17761776
[[package]]
17771777
name = "indexmap"
1778-
version = "2.2.6"
1778+
version = "2.4.0"
17791779
source = "registry+https://github.com/rust-lang/crates.io-index"
1780-
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
1780+
checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c"
17811781
dependencies = [
17821782
"equivalent",
17831783
"hashbrown",

compiler/rustc_data_structures/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ bitflags = "2.4.1"
1010
either = "1.0"
1111
elsa = "=1.7.1"
1212
ena = "0.14.3"
13-
indexmap = { version = "2.0.0" }
13+
indexmap = { version = "2.4.0" }
1414
jobserver_crate = { version = "0.1.28", package = "jobserver" }
1515
measureme = "11"
1616
rustc-hash = "1.1.0"

compiler/rustc_feature/src/builtin_attrs.rs

-6
Original file line numberDiff line numberDiff line change
@@ -578,12 +578,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
578578
EncodeCrossCrate::No, coroutines, experimental!(coroutines)
579579
),
580580

581-
// `#[pointee]` attribute to designate the pointee type in SmartPointer derive-macro
582-
gated!(
583-
pointee, Normal, template!(Word), ErrorFollowing,
584-
EncodeCrossCrate::No, derive_smart_pointer, experimental!(pointee)
585-
),
586-
587581
// RFC 3543
588582
// `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]`
589583
gated!(

compiler/rustc_index/src/vec.rs

+5
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ impl<I: Idx, T> IndexVec<I, T> {
188188
let min_new_len = elem.index() + 1;
189189
self.raw.resize_with(min_new_len, fill_value);
190190
}
191+
192+
#[inline]
193+
pub fn append(&mut self, other: &mut Self) {
194+
self.raw.append(&mut other.raw);
195+
}
191196
}
192197

193198
/// `IndexVec` is often used as a map, so it provides some map-like APIs.

compiler/rustc_mir_transform/src/inline.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ impl<'tcx> Inliner<'tcx> {
726726

727727
// Insert all of the (mapped) parts of the callee body into the caller.
728728
caller_body.local_decls.extend(callee_body.drain_vars_and_temps());
729-
caller_body.source_scopes.extend(&mut callee_body.source_scopes.drain(..));
729+
caller_body.source_scopes.append(&mut callee_body.source_scopes);
730730
if self
731731
.tcx
732732
.sess
@@ -740,7 +740,7 @@ impl<'tcx> Inliner<'tcx> {
740740
// still getting consistent results from the mir-opt tests.
741741
caller_body.var_debug_info.append(&mut callee_body.var_debug_info);
742742
}
743-
caller_body.basic_blocks_mut().extend(callee_body.basic_blocks_mut().drain(..));
743+
caller_body.basic_blocks_mut().append(callee_body.basic_blocks_mut());
744744

745745
caller_body[callsite.block].terminator = Some(Terminator {
746746
source_info: callsite.source_info,

compiler/rustc_monomorphize/src/partitioning.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ fn merge_codegen_units<'tcx>(
371371
// Move the items from `cgu_src` to `cgu_dst`. Some of them may be
372372
// duplicate inlined items, in which case the destination CGU is
373373
// unaffected. Recalculate size estimates afterwards.
374-
cgu_dst.items_mut().extend(cgu_src.items_mut().drain(..));
374+
cgu_dst.items_mut().append(cgu_src.items_mut());
375375
cgu_dst.compute_size_estimate();
376376

377377
// Record that `cgu_dst` now contains all the stuff that was in
@@ -410,7 +410,7 @@ fn merge_codegen_units<'tcx>(
410410
// Move the items from `smallest` to `second_smallest`. Some of them
411411
// may be duplicate inlined items, in which case the destination CGU is
412412
// unaffected. Recalculate size estimates afterwards.
413-
second_smallest.items_mut().extend(smallest.items_mut().drain(..));
413+
second_smallest.items_mut().append(smallest.items_mut());
414414
second_smallest.compute_size_estimate();
415415

416416
// Don't update `cgu_contents`, that's only for incremental builds.

compiler/rustc_target/src/spec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,7 @@ supported_targets! {
15611561
("powerpc-unknown-linux-gnu", powerpc_unknown_linux_gnu),
15621562
("powerpc-unknown-linux-gnuspe", powerpc_unknown_linux_gnuspe),
15631563
("powerpc-unknown-linux-musl", powerpc_unknown_linux_musl),
1564+
("powerpc-unknown-linux-muslspe", powerpc_unknown_linux_muslspe),
15641565
("powerpc64-ibm-aix", powerpc64_ibm_aix),
15651566
("powerpc64-unknown-linux-gnu", powerpc64_unknown_linux_gnu),
15661567
("powerpc64-unknown-linux-musl", powerpc64_unknown_linux_musl),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use crate::abi::Endian;
2+
use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
3+
4+
pub fn target() -> Target {
5+
let mut base = base::linux_musl::opts();
6+
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mspe"]);
7+
base.max_atomic_width = Some(32);
8+
base.stack_probes = StackProbeType::Inline;
9+
10+
Target {
11+
llvm_target: "powerpc-unknown-linux-muslspe".into(),
12+
metadata: crate::spec::TargetMetadata {
13+
description: Some("PowerPC SPE Linux with musl".into()),
14+
tier: Some(3),
15+
host_tools: Some(false),
16+
std: Some(true),
17+
},
18+
pointer_width: 32,
19+
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
20+
arch: "powerpc".into(),
21+
options: TargetOptions {
22+
abi: "spe".into(),
23+
endian: Endian::Big,
24+
mcount: "_mcount".into(),
25+
..base
26+
},
27+
}
28+
}

library/core/src/marker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ pub trait FnPtr: Copy + Clone {
10601060
}
10611061

10621062
/// Derive macro generating impls of traits related to smart pointers.
1063-
#[rustc_builtin_macro]
1063+
#[rustc_builtin_macro(SmartPointer, attributes(pointee))]
10641064
#[allow_internal_unstable(dispatch_from_dyn, coerce_unsized, unsize)]
10651065
#[unstable(feature = "derive_smart_pointer", issue = "123430")]
10661066
pub macro SmartPointer($item:item) {

library/core/src/net/ip_addr.rs

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use super::display_buffer::DisplayBuffer;
22
use crate::cmp::Ordering;
33
use crate::fmt::{self, Write};
4+
use crate::hash::{Hash, Hasher};
45
use crate::iter;
56
use crate::mem::transmute;
67
use crate::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, Not};
@@ -67,12 +68,22 @@ pub enum IpAddr {
6768
/// assert!("0000000.0.0.0".parse::<Ipv4Addr>().is_err()); // first octet is a zero in octal
6869
/// assert!("0xcb.0x0.0x71.0x00".parse::<Ipv4Addr>().is_err()); // all octets are in hex
6970
/// ```
70-
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
71+
#[derive(Copy, Clone, PartialEq, Eq)]
7172
#[stable(feature = "rust1", since = "1.0.0")]
7273
pub struct Ipv4Addr {
7374
octets: [u8; 4],
7475
}
7576

77+
#[stable(feature = "rust1", since = "1.0.0")]
78+
impl Hash for Ipv4Addr {
79+
fn hash<H: Hasher>(&self, state: &mut H) {
80+
// Hashers are often more efficient at hashing a fixed-width integer
81+
// than a bytestring, so convert before hashing. We don't use to_bits()
82+
// here as that may involve a byteswap which is unnecessary.
83+
u32::from_ne_bytes(self.octets).hash(state);
84+
}
85+
}
86+
7687
/// An IPv6 address.
7788
///
7889
/// IPv6 addresses are defined as 128-bit integers in [IETF RFC 4291].
@@ -149,12 +160,22 @@ pub struct Ipv4Addr {
149160
/// assert_eq!("::1".parse(), Ok(localhost));
150161
/// assert_eq!(localhost.is_loopback(), true);
151162
/// ```
152-
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
163+
#[derive(Copy, Clone, PartialEq, Eq)]
153164
#[stable(feature = "rust1", since = "1.0.0")]
154165
pub struct Ipv6Addr {
155166
octets: [u8; 16],
156167
}
157168

169+
#[stable(feature = "rust1", since = "1.0.0")]
170+
impl Hash for Ipv6Addr {
171+
fn hash<H: Hasher>(&self, state: &mut H) {
172+
// Hashers are often more efficient at hashing a fixed-width integer
173+
// than a bytestring, so convert before hashing. We don't use to_bits()
174+
// here as that may involve unnecessary byteswaps.
175+
u128::from_ne_bytes(self.octets).hash(state);
176+
}
177+
}
178+
158179
/// Scope of an [IPv6 multicast address] as defined in [IETF RFC 7346 section 2].
159180
///
160181
/// # Stability Guarantees

library/std/src/os/unix/process.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,21 @@ pub trait CommandExt: Sealed {
109109
/// Schedules a closure to be run just before the `exec` function is
110110
/// invoked.
111111
///
112-
/// This method is stable and usable, but it should be unsafe. To fix
113-
/// that, it got deprecated in favor of the unsafe [`pre_exec`].
112+
/// `before_exec` used to be a safe method, but it needs to be unsafe since the closure may only
113+
/// perform operations that are *async-signal-safe*. Hence it got deprecated in favor of the
114+
/// unsafe [`pre_exec`]. Meanwhile, Rust gained the ability to make an existing safe method
115+
/// fully unsafe in a new edition, which is how `before_exec` became `unsafe`. It still also
116+
/// remains deprecated; `pre_exec` should be used instead.
114117
///
115118
/// [`pre_exec`]: CommandExt::pre_exec
116119
#[stable(feature = "process_exec", since = "1.15.0")]
117120
#[deprecated(since = "1.37.0", note = "should be unsafe, use `pre_exec` instead")]
118-
fn before_exec<F>(&mut self, f: F) -> &mut process::Command
121+
#[cfg_attr(bootstrap, rustc_deprecated_safe_2024)]
122+
#[cfg_attr(
123+
not(bootstrap),
124+
rustc_deprecated_safe_2024(audit_that = "the closure is async-signal-safe")
125+
)]
126+
unsafe fn before_exec<F>(&mut self, f: F) -> &mut process::Command
119127
where
120128
F: FnMut() -> io::Result<()> + Send + Sync + 'static,
121129
{

src/doc/rustc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
- [mipsisa\*r6\*-unknown-linux-gnu\*](platform-support/mips-release-6.md)
6262
- [nvptx64-nvidia-cuda](platform-support/nvptx64-nvidia-cuda.md)
6363
- [powerpc-unknown-openbsd](platform-support/powerpc-unknown-openbsd.md)
64+
- [powerpc-unknown-linux-muslspe](platform-support/powerpc-unknown-linux-muslspe.md)
6465
- [powerpc64-ibm-aix](platform-support/aix.md)
6566
- [riscv32im-risc0-zkvm-elf](platform-support/riscv32im-risc0-zkvm-elf.md)
6667
- [riscv32imac-unknown-xous-elf](platform-support/riscv32imac-unknown-xous-elf.md)

src/doc/rustc/src/platform-support.md

+1
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ target | std | host | notes
332332
`msp430-none-elf` | * | | 16-bit MSP430 microcontrollers
333333
`powerpc-unknown-linux-gnuspe` | ✓ | | PowerPC SPE Linux
334334
`powerpc-unknown-linux-musl` | ? | | PowerPC Linux with musl 1.2.3
335+
[`powerpc-unknown-linux-muslspe`](platform-support/powerpc-unknown-linux-muslspe.md) | ? | | PowerPC SPE Linux
335336
[`powerpc-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | NetBSD 32-bit powerpc systems
336337
[`powerpc-unknown-openbsd`](platform-support/powerpc-unknown-openbsd.md) | * | |
337338
[`powerpc-wrs-vxworks-spe`](platform-support/vxworks.md) | ✓ | |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# powerpc-unknown-linux-muslspe
2+
3+
**Tier: 3**
4+
5+
This target is very similar to already existing ones like `powerpc_unknown_linux_musl` and `powerpc_unknown_linux_gnuspe`.
6+
This one has PowerPC SPE support for musl. Unfortunately, the last supported gcc version with PowerPC SPE is 8.4.0.
7+
8+
## Target maintainers
9+
10+
- [@BKPepe](https://github.com/BKPepe)
11+
12+
## Requirements
13+
14+
This target is cross-compiled. There is no support for `std`. There is no
15+
default allocator, but it's possible to use `alloc` by supplying an allocator.
16+
17+
This target generated binaries in the ELF format.
18+
19+
## Building the target
20+
21+
This target was tested and used within the `OpenWrt` build system for CZ.NIC Turris 1.x routers using Freescale P2020.
22+
23+
## Building Rust programs
24+
25+
Rust does not yet ship pre-compiled artifacts for this target. To compile for
26+
this target, you will either need to build Rust with the target enabled (see
27+
"Building the target" above), or build your own copy of `core` by using
28+
`build-std` or similar.
29+
30+
## Testing
31+
32+
This is a cross-compiled target and there is no support to run rustc test suite.

src/doc/rustdoc/src/unstable-features.md

+3
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,9 @@ pub fn no_documentation() {}
515515

516516
Note that the third item is the crate root, which in this case is undocumented.
517517

518+
If you want the JSON output to be displayed on `stdout` instead of having a file generated, you can
519+
use `-o -`.
520+
518521
### `-w`/`--output-format`: output format
519522

520523
`--output-format json` emits documentation in the experimental

src/librustdoc/config.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ pub(crate) struct RenderOptions {
286286
pub(crate) no_emit_shared: bool,
287287
/// If `true`, HTML source code pages won't be generated.
288288
pub(crate) html_no_source: bool,
289+
/// This field is only used for the JSON output. If it's set to true, no file will be created
290+
/// and content will be displayed in stdout directly.
291+
pub(crate) output_to_stdout: bool,
289292
}
290293

291294
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
@@ -548,16 +551,17 @@ impl Options {
548551
dcx.fatal("the `--test` flag must be passed to enable `--no-run`");
549552
}
550553

554+
let mut output_to_stdout = false;
551555
let test_builder_wrappers =
552556
matches.opt_strs("test-builder-wrapper").iter().map(PathBuf::from).collect();
553-
let out_dir = matches.opt_str("out-dir").map(|s| PathBuf::from(&s));
554-
let output = matches.opt_str("output").map(|s| PathBuf::from(&s));
555-
let output = match (out_dir, output) {
557+
let output = match (matches.opt_str("out-dir"), matches.opt_str("output")) {
556558
(Some(_), Some(_)) => {
557559
dcx.fatal("cannot use both 'out-dir' and 'output' at once");
558560
}
559-
(Some(out_dir), None) => out_dir,
560-
(None, Some(output)) => output,
561+
(Some(out_dir), None) | (None, Some(out_dir)) => {
562+
output_to_stdout = out_dir == "-";
563+
PathBuf::from(out_dir)
564+
}
561565
(None, None) => PathBuf::from("doc"),
562566
};
563567

@@ -818,6 +822,7 @@ impl Options {
818822
call_locations,
819823
no_emit_shared: false,
820824
html_no_source,
825+
output_to_stdout,
821826
};
822827
Some((options, render_options))
823828
}

0 commit comments

Comments
 (0)