| author | bors <bors@rust-lang.org> 2024-08-15 03:44:39 UTC |
| committer | bors <bors@rust-lang.org> 2024-08-15 03:44:39 UTC |
| log | 0ba9db87e61adcfd9a978188f61c20d9b423a099 |
| tree | f527e3b8de113dad5eb0bcfeeb092b707e833fc9 |
| parent | 13a52890dde8cfeb95069d77c223ac37c0cf3a46 |
| parent | e14f171e96f3b1cfccfe77d991a2b815d9659981 |
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: rollup38 files changed, 419 insertions(+), 66 deletions(-)
.github/workflows/dependencies.yml+1-1| ... | ... | @@ -67,7 +67,7 @@ jobs: |
| 67 | 67 | - name: cargo update rustbook |
| 68 | 68 | run: | |
| 69 | 69 | 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 | |
| 71 | 71 | - name: upload Cargo.lock artifact for use in PR |
| 72 | 72 | uses: actions/upload-artifact@v4 |
| 73 | 73 | with: |
Cargo.lock+2-2| ... | ... | @@ -1775,9 +1775,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" |
| 1775 | 1775 | |
| 1776 | 1776 | [[package]] |
| 1777 | 1777 | name = "indexmap" |
| 1778 | version = "2.2.6" | |
| 1778 | version = "2.4.0" | |
| 1779 | 1779 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1780 | checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" | |
| 1780 | checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" | |
| 1781 | 1781 | dependencies = [ |
| 1782 | 1782 | "equivalent", |
| 1783 | 1783 | "hashbrown", |
compiler/rustc_data_structures/Cargo.toml+1-1| ... | ... | @@ -10,7 +10,7 @@ bitflags = "2.4.1" |
| 10 | 10 | either = "1.0" |
| 11 | 11 | elsa = "=1.7.1" |
| 12 | 12 | ena = "0.14.3" |
| 13 | indexmap = { version = "2.0.0" } | |
| 13 | indexmap = { version = "2.4.0" } | |
| 14 | 14 | jobserver_crate = { version = "0.1.28", package = "jobserver" } |
| 15 | 15 | measureme = "11" |
| 16 | 16 | rustc-hash = "1.1.0" |
compiler/rustc_feature/src/builtin_attrs.rs-6| ... | ... | @@ -578,12 +578,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ |
| 578 | 578 | EncodeCrossCrate::No, coroutines, experimental!(coroutines) |
| 579 | 579 | ), |
| 580 | 580 | |
| 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 | ||
| 587 | 581 | // RFC 3543 |
| 588 | 582 | // `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]` |
| 589 | 583 | gated!( |
compiler/rustc_index/src/vec.rs+5| ... | ... | @@ -188,6 +188,11 @@ impl<I: Idx, T> IndexVec<I, T> { |
| 188 | 188 | let min_new_len = elem.index() + 1; |
| 189 | 189 | self.raw.resize_with(min_new_len, fill_value); |
| 190 | 190 | } |
| 191 | ||
| 192 | #[inline] | |
| 193 | pub fn append(&mut self, other: &mut Self) { | |
| 194 | self.raw.append(&mut other.raw); | |
| 195 | } | |
| 191 | 196 | } |
| 192 | 197 | |
| 193 | 198 | /// `IndexVec` is often used as a map, so it provides some map-like APIs. |
compiler/rustc_mir_transform/src/inline.rs+2-2| ... | ... | @@ -726,7 +726,7 @@ impl<'tcx> Inliner<'tcx> { |
| 726 | 726 | |
| 727 | 727 | // Insert all of the (mapped) parts of the callee body into the caller. |
| 728 | 728 | 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); | |
| 730 | 730 | if self |
| 731 | 731 | .tcx |
| 732 | 732 | .sess |
| ... | ... | @@ -740,7 +740,7 @@ impl<'tcx> Inliner<'tcx> { |
| 740 | 740 | // still getting consistent results from the mir-opt tests. |
| 741 | 741 | caller_body.var_debug_info.append(&mut callee_body.var_debug_info); |
| 742 | 742 | } |
| 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()); | |
| 744 | 744 | |
| 745 | 745 | caller_body[callsite.block].terminator = Some(Terminator { |
| 746 | 746 | source_info: callsite.source_info, |
compiler/rustc_monomorphize/src/partitioning.rs+2-2| ... | ... | @@ -371,7 +371,7 @@ fn merge_codegen_units<'tcx>( |
| 371 | 371 | // Move the items from `cgu_src` to `cgu_dst`. Some of them may be |
| 372 | 372 | // duplicate inlined items, in which case the destination CGU is |
| 373 | 373 | // 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()); | |
| 375 | 375 | cgu_dst.compute_size_estimate(); |
| 376 | 376 | |
| 377 | 377 | // Record that `cgu_dst` now contains all the stuff that was in |
| ... | ... | @@ -410,7 +410,7 @@ fn merge_codegen_units<'tcx>( |
| 410 | 410 | // Move the items from `smallest` to `second_smallest`. Some of them |
| 411 | 411 | // may be duplicate inlined items, in which case the destination CGU is |
| 412 | 412 | // unaffected. Recalculate size estimates afterwards. |
| 413 | second_smallest.items_mut().extend(smallest.items_mut().drain(..)); | |
| 413 | second_smallest.items_mut().append(smallest.items_mut()); | |
| 414 | 414 | second_smallest.compute_size_estimate(); |
| 415 | 415 | |
| 416 | 416 | // Don't update `cgu_contents`, that's only for incremental builds. |
compiler/rustc_target/src/spec/mod.rs+1| ... | ... | @@ -1561,6 +1561,7 @@ supported_targets! { |
| 1561 | 1561 | ("powerpc-unknown-linux-gnu", powerpc_unknown_linux_gnu), |
| 1562 | 1562 | ("powerpc-unknown-linux-gnuspe", powerpc_unknown_linux_gnuspe), |
| 1563 | 1563 | ("powerpc-unknown-linux-musl", powerpc_unknown_linux_musl), |
| 1564 | ("powerpc-unknown-linux-muslspe", powerpc_unknown_linux_muslspe), | |
| 1564 | 1565 | ("powerpc64-ibm-aix", powerpc64_ibm_aix), |
| 1565 | 1566 | ("powerpc64-unknown-linux-gnu", powerpc64_unknown_linux_gnu), |
| 1566 | 1567 | ("powerpc64-unknown-linux-musl", powerpc64_unknown_linux_musl), |
compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_muslspe.rs created+28| ... | ... | @@ -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| ... | ... | @@ -1060,7 +1060,7 @@ pub trait FnPtr: Copy + Clone { |
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | 1062 | /// Derive macro generating impls of traits related to smart pointers. |
| 1063 | #[rustc_builtin_macro] | |
| 1063 | #[rustc_builtin_macro(SmartPointer, attributes(pointee))] | |
| 1064 | 1064 | #[allow_internal_unstable(dispatch_from_dyn, coerce_unsized, unsize)] |
| 1065 | 1065 | #[unstable(feature = "derive_smart_pointer", issue = "123430")] |
| 1066 | 1066 | pub macro SmartPointer($item:item) { |
library/core/src/net/ip_addr.rs+23-2| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | use super::display_buffer::DisplayBuffer; |
| 2 | 2 | use crate::cmp::Ordering; |
| 3 | 3 | use crate::fmt::{self, Write}; |
| 4 | use crate::hash::{Hash, Hasher}; | |
| 4 | 5 | use crate::iter; |
| 5 | 6 | use crate::mem::transmute; |
| 6 | 7 | use crate::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, Not}; |
| ... | ... | @@ -67,12 +68,22 @@ pub enum IpAddr { |
| 67 | 68 | /// assert!("0000000.0.0.0".parse::<Ipv4Addr>().is_err()); // first octet is a zero in octal |
| 68 | 69 | /// assert!("0xcb.0x0.0x71.0x00".parse::<Ipv4Addr>().is_err()); // all octets are in hex |
| 69 | 70 | /// ``` |
| 70 | #[derive(Copy, Clone, PartialEq, Eq, Hash)] | |
| 71 | #[derive(Copy, Clone, PartialEq, Eq)] | |
| 71 | 72 | #[stable(feature = "rust1", since = "1.0.0")] |
| 72 | 73 | pub struct Ipv4Addr { |
| 73 | 74 | octets: [u8; 4], |
| 74 | 75 | } |
| 75 | 76 | |
| 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 | ||
| 76 | 87 | /// An IPv6 address. |
| 77 | 88 | /// |
| 78 | 89 | /// IPv6 addresses are defined as 128-bit integers in [IETF RFC 4291]. |
| ... | ... | @@ -149,12 +160,22 @@ pub struct Ipv4Addr { |
| 149 | 160 | /// assert_eq!("::1".parse(), Ok(localhost)); |
| 150 | 161 | /// assert_eq!(localhost.is_loopback(), true); |
| 151 | 162 | /// ``` |
| 152 | #[derive(Copy, Clone, PartialEq, Eq, Hash)] | |
| 163 | #[derive(Copy, Clone, PartialEq, Eq)] | |
| 153 | 164 | #[stable(feature = "rust1", since = "1.0.0")] |
| 154 | 165 | pub struct Ipv6Addr { |
| 155 | 166 | octets: [u8; 16], |
| 156 | 167 | } |
| 157 | 168 | |
| 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 | ||
| 158 | 179 | /// Scope of an [IPv6 multicast address] as defined in [IETF RFC 7346 section 2]. |
| 159 | 180 | /// |
| 160 | 181 | /// # Stability Guarantees |
library/std/src/os/unix/process.rs+11-3| ... | ... | @@ -109,13 +109,21 @@ pub trait CommandExt: Sealed { |
| 109 | 109 | /// Schedules a closure to be run just before the `exec` function is |
| 110 | 110 | /// invoked. |
| 111 | 111 | /// |
| 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. | |
| 114 | 117 | /// |
| 115 | 118 | /// [`pre_exec`]: CommandExt::pre_exec |
| 116 | 119 | #[stable(feature = "process_exec", since = "1.15.0")] |
| 117 | 120 | #[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 | |
| 119 | 127 | where |
| 120 | 128 | F: FnMut() -> io::Result<()> + Send + Sync + 'static, |
| 121 | 129 | { |
src/doc/book+1-1| ... | ... | @@ -1 +1 @@ |
| 1 | Subproject commit 67fa536768013d9d5a13f3a06790521d511ef711 | |
| 1 | Subproject commit 04bc1396bb857f35b5dda1d773c9571e1f253304 |
src/doc/edition-guide+1-1| ... | ... | @@ -1 +1 @@ |
| 1 | Subproject commit 5454de3d12b9ccc6375b629cf7ccda8264640aac | |
| 1 | Subproject commit aeeb287d41a0332c210da122bea8e0e91844ab3e |
src/doc/nomicon+1-1| ... | ... | @@ -1 +1 @@ |
| 1 | Subproject commit 0ebdacadbda8ce2cd8fbf93985e15af61a7ab895 | |
| 1 | Subproject commit 6ecf95c5f2bfa0e6314dfe282bf775fd1405f7e9 |
src/doc/reference+1-1| ... | ... | @@ -1 +1 @@ |
| 1 | Subproject commit 2e191814f163ee1e77e2d6094eee4dd78a289c5b | |
| 1 | Subproject commit 62cd0df95061ba0ac886333f5cd7f3012f149da1 |
src/doc/rust-by-example+1-1| ... | ... | @@ -1 +1 @@ |
| 1 | Subproject commit 89aecb6951b77bc746da73df8c9f2b2ceaad494a | |
| 1 | Subproject commit 8f94061936e492159f4f6c09c0f917a7521893ff |
src/doc/rustc-dev-guide+1-1| ... | ... | @@ -1 +1 @@ |
| 1 | Subproject commit 0c4d55cb59fe440d1a630e4e5774d043968edb3f | |
| 1 | Subproject commit 43d83780db545a1ed6d45773312fc578987e3968 |
src/doc/rustc/src/SUMMARY.md+1| ... | ... | @@ -61,6 +61,7 @@ |
| 61 | 61 | - [mipsisa\*r6\*-unknown-linux-gnu\*](platform-support/mips-release-6.md) |
| 62 | 62 | - [nvptx64-nvidia-cuda](platform-support/nvptx64-nvidia-cuda.md) |
| 63 | 63 | - [powerpc-unknown-openbsd](platform-support/powerpc-unknown-openbsd.md) |
| 64 | - [powerpc-unknown-linux-muslspe](platform-support/powerpc-unknown-linux-muslspe.md) | |
| 64 | 65 | - [powerpc64-ibm-aix](platform-support/aix.md) |
| 65 | 66 | - [riscv32im-risc0-zkvm-elf](platform-support/riscv32im-risc0-zkvm-elf.md) |
| 66 | 67 | - [riscv32imac-unknown-xous-elf](platform-support/riscv32imac-unknown-xous-elf.md) |
src/doc/rustc/src/platform-support.md+1| ... | ... | @@ -332,6 +332,7 @@ target | std | host | notes |
| 332 | 332 | `msp430-none-elf` | * | | 16-bit MSP430 microcontrollers |
| 333 | 333 | `powerpc-unknown-linux-gnuspe` | ✓ | | PowerPC SPE Linux |
| 334 | 334 | `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 | |
| 335 | 336 | [`powerpc-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | NetBSD 32-bit powerpc systems |
| 336 | 337 | [`powerpc-unknown-openbsd`](platform-support/powerpc-unknown-openbsd.md) | * | | |
| 337 | 338 | [`powerpc-wrs-vxworks-spe`](platform-support/vxworks.md) | ✓ | | |
src/doc/rustc/src/platform-support/powerpc-unknown-linux-muslspe.md created+32| ... | ... | @@ -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| ... | ... | @@ -515,6 +515,9 @@ pub fn no_documentation() {} |
| 515 | 515 | |
| 516 | 516 | Note that the third item is the crate root, which in this case is undocumented. |
| 517 | 517 | |
| 518 | If you want the JSON output to be displayed on `stdout` instead of having a file generated, you can | |
| 519 | use `-o -`. | |
| 520 | ||
| 518 | 521 | ### `-w`/`--output-format`: output format |
| 519 | 522 | |
| 520 | 523 | `--output-format json` emits documentation in the experimental |
src/librustdoc/config.rs+10-5| ... | ... | @@ -286,6 +286,9 @@ pub(crate) struct RenderOptions { |
| 286 | 286 | pub(crate) no_emit_shared: bool, |
| 287 | 287 | /// If `true`, HTML source code pages won't be generated. |
| 288 | 288 | 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, | |
| 289 | 292 | } |
| 290 | 293 | |
| 291 | 294 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] |
| ... | ... | @@ -548,16 +551,17 @@ impl Options { |
| 548 | 551 | dcx.fatal("the `--test` flag must be passed to enable `--no-run`"); |
| 549 | 552 | } |
| 550 | 553 | |
| 554 | let mut output_to_stdout = false; | |
| 551 | 555 | let test_builder_wrappers = |
| 552 | 556 | 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")) { | |
| 556 | 558 | (Some(_), Some(_)) => { |
| 557 | 559 | dcx.fatal("cannot use both 'out-dir' and 'output' at once"); |
| 558 | 560 | } |
| 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 | } | |
| 561 | 565 | (None, None) => PathBuf::from("doc"), |
| 562 | 566 | }; |
| 563 | 567 | |
| ... | ... | @@ -818,6 +822,7 @@ impl Options { |
| 818 | 822 | call_locations, |
| 819 | 823 | no_emit_shared: false, |
| 820 | 824 | html_no_source, |
| 825 | output_to_stdout, | |
| 821 | 826 | }; |
| 822 | 827 | Some((options, render_options)) |
| 823 | 828 | } |
src/librustdoc/json/mod.rs+31-16| ... | ... | @@ -9,7 +9,7 @@ mod import_finder; |
| 9 | 9 | |
| 10 | 10 | use std::cell::RefCell; |
| 11 | 11 | use std::fs::{create_dir_all, File}; |
| 12 | use std::io::{BufWriter, Write}; | |
| 12 | use std::io::{stdout, BufWriter, Write}; | |
| 13 | 13 | use std::path::PathBuf; |
| 14 | 14 | use std::rc::Rc; |
| 15 | 15 | |
| ... | ... | @@ -37,7 +37,7 @@ pub(crate) struct JsonRenderer<'tcx> { |
| 37 | 37 | /// level field of the JSON blob. |
| 38 | 38 | index: Rc<RefCell<FxHashMap<types::Id, types::Item>>>, |
| 39 | 39 | /// The directory where the blob will be written to. |
| 40 | out_path: PathBuf, | |
| 40 | out_path: Option<PathBuf>, | |
| 41 | 41 | cache: Rc<Cache>, |
| 42 | 42 | imported_items: DefIdSet, |
| 43 | 43 | } |
| ... | ... | @@ -97,6 +97,20 @@ impl<'tcx> JsonRenderer<'tcx> { |
| 97 | 97 | }) |
| 98 | 98 | .unwrap_or_default() |
| 99 | 99 | } |
| 100 | ||
| 101 | fn write<T: Write>( | |
| 102 | &self, | |
| 103 | output: types::Crate, | |
| 104 | mut writer: BufWriter<T>, | |
| 105 | path: &str, | |
| 106 | ) -> Result<(), Error> { | |
| 107 | self.tcx | |
| 108 | .sess | |
| 109 | .time("rustdoc_json_serialization", || serde_json::ser::to_writer(&mut writer, &output)) | |
| 110 | .unwrap(); | |
| 111 | try_err!(writer.flush(), path); | |
| 112 | Ok(()) | |
| 113 | } | |
| 100 | 114 | } |
| 101 | 115 | |
| 102 | 116 | impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { |
| ... | ... | @@ -120,7 +134,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { |
| 120 | 134 | JsonRenderer { |
| 121 | 135 | tcx, |
| 122 | 136 | index: Rc::new(RefCell::new(FxHashMap::default())), |
| 123 | out_path: options.output, | |
| 137 | out_path: if options.output_to_stdout { None } else { Some(options.output) }, | |
| 124 | 138 | cache: Rc::new(cache), |
| 125 | 139 | imported_items, |
| 126 | 140 | }, |
| ... | ... | @@ -264,20 +278,21 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { |
| 264 | 278 | .collect(), |
| 265 | 279 | format_version: types::FORMAT_VERSION, |
| 266 | 280 | }; |
| 267 | let out_dir = self.out_path.clone(); | |
| 268 | try_err!(create_dir_all(&out_dir), out_dir); | |
| 281 | if let Some(ref out_path) = self.out_path { | |
| 282 | let out_dir = out_path.clone(); | |
| 283 | try_err!(create_dir_all(&out_dir), out_dir); | |
| 269 | 284 | |
| 270 | let mut p = out_dir; | |
| 271 | p.push(output.index.get(&output.root).unwrap().name.clone().unwrap()); | |
| 272 | p.set_extension("json"); | |
| 273 | let mut file = BufWriter::new(try_err!(File::create(&p), p)); | |
| 274 | self.tcx | |
| 275 | .sess | |
| 276 | .time("rustdoc_json_serialization", || serde_json::ser::to_writer(&mut file, &output)) | |
| 277 | .unwrap(); | |
| 278 | try_err!(file.flush(), p); | |
| 279 | ||
| 280 | Ok(()) | |
| 285 | let mut p = out_dir; | |
| 286 | p.push(output.index.get(&output.root).unwrap().name.clone().unwrap()); | |
| 287 | p.set_extension("json"); | |
| 288 | self.write( | |
| 289 | output, | |
| 290 | BufWriter::new(try_err!(File::create(&p), p)), | |
| 291 | &p.display().to_string(), | |
| 292 | ) | |
| 293 | } else { | |
| 294 | self.write(output, BufWriter::new(stdout()), "<stdout>") | |
| 295 | } | |
| 281 | 296 | } |
| 282 | 297 | |
| 283 | 298 | fn cache(&self) -> &Cache { |
src/tools/run-make-support/src/path_helpers.rs+15| ... | ... | @@ -84,3 +84,18 @@ pub fn has_suffix<P: AsRef<Path>>(path: P, suffix: &str) -> bool { |
| 84 | 84 | pub fn filename_contains<P: AsRef<Path>>(path: P, needle: &str) -> bool { |
| 85 | 85 | path.as_ref().file_name().is_some_and(|name| name.to_str().unwrap().contains(needle)) |
| 86 | 86 | } |
| 87 | ||
| 88 | /// Helper for reading entries in a given directory and its children. | |
| 89 | pub fn read_dir_entries_recursive<P: AsRef<Path>, F: FnMut(&Path)>(dir: P, mut callback: F) { | |
| 90 | fn read_dir_entries_recursive_inner<P: AsRef<Path>, F: FnMut(&Path)>(dir: P, callback: &mut F) { | |
| 91 | for entry in rfs::read_dir(dir) { | |
| 92 | let path = entry.unwrap().path(); | |
| 93 | callback(&path); | |
| 94 | if path.is_dir() { | |
| 95 | read_dir_entries_recursive_inner(path, callback); | |
| 96 | } | |
| 97 | } | |
| 98 | } | |
| 99 | ||
| 100 | read_dir_entries_recursive_inner(dir, &mut callback); | |
| 101 | } |
src/tools/rustbook/Cargo.lock+22-7| ... | ... | @@ -303,6 +303,12 @@ dependencies = [ |
| 303 | 303 | "crypto-common", |
| 304 | 304 | ] |
| 305 | 305 | |
| 306 | [[package]] | |
| 307 | name = "doc-comment" | |
| 308 | version = "0.3.3" | |
| 309 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 310 | checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" | |
| 311 | ||
| 306 | 312 | [[package]] |
| 307 | 313 | name = "elasticlunr-rs" |
| 308 | 314 | version = "3.0.2" |
| ... | ... | @@ -465,6 +471,21 @@ dependencies = [ |
| 465 | 471 | "syn", |
| 466 | 472 | ] |
| 467 | 473 | |
| 474 | [[package]] | |
| 475 | name = "html_parser" | |
| 476 | version = "0.7.0" | |
| 477 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 478 | checksum = "f6f56db07b6612644f6f7719f8ef944f75fff9d6378fdf3d316fd32194184abd" | |
| 479 | dependencies = [ | |
| 480 | "doc-comment", | |
| 481 | "pest", | |
| 482 | "pest_derive", | |
| 483 | "serde", | |
| 484 | "serde_derive", | |
| 485 | "serde_json", | |
| 486 | "thiserror", | |
| 487 | ] | |
| 488 | ||
| 468 | 489 | [[package]] |
| 469 | 490 | name = "humantime" |
| 470 | 491 | version = "2.1.0" |
| ... | ... | @@ -680,13 +701,13 @@ name = "mdbook-trpl-listing" |
| 680 | 701 | version = "0.1.0" |
| 681 | 702 | dependencies = [ |
| 682 | 703 | "clap", |
| 704 | "html_parser", | |
| 683 | 705 | "mdbook", |
| 684 | 706 | "pulldown-cmark", |
| 685 | 707 | "pulldown-cmark-to-cmark", |
| 686 | 708 | "serde_json", |
| 687 | 709 | "thiserror", |
| 688 | 710 | "toml 0.8.14", |
| 689 | "xmlparser", | |
| 690 | 711 | ] |
| 691 | 712 | |
| 692 | 713 | [[package]] |
| ... | ... | @@ -1767,12 +1788,6 @@ dependencies = [ |
| 1767 | 1788 | "memchr", |
| 1768 | 1789 | ] |
| 1769 | 1790 | |
| 1770 | [[package]] | |
| 1771 | name = "xmlparser" | |
| 1772 | version = "0.13.6" | |
| 1773 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1774 | checksum = "66fee0b777b0f5ac1c69bb06d361268faafa61cd4682ae064a171c16c433e9e4" | |
| 1775 | ||
| 1776 | 1791 | [[package]] |
| 1777 | 1792 | name = "yaml-rust" |
| 1778 | 1793 | version = "0.4.5" |
tests/assembly/targets/targets-elf.rs+3| ... | ... | @@ -345,6 +345,9 @@ |
| 345 | 345 | //@ revisions: powerpc_unknown_linux_musl |
| 346 | 346 | //@ [powerpc_unknown_linux_musl] compile-flags: --target powerpc-unknown-linux-musl |
| 347 | 347 | //@ [powerpc_unknown_linux_musl] needs-llvm-components: powerpc |
| 348 | //@ revisions: powerpc_unknown_linux_muslspe | |
| 349 | //@ [powerpc_unknown_linux_muslspe] compile-flags: --target powerpc-unknown-linux-muslspe | |
| 350 | //@ [powerpc_unknown_linux_muslspe] needs-llvm-components: powerpc | |
| 348 | 351 | //@ revisions: powerpc_unknown_netbsd |
| 349 | 352 | //@ [powerpc_unknown_netbsd] compile-flags: --target powerpc-unknown-netbsd |
| 350 | 353 | //@ [powerpc_unknown_netbsd] needs-llvm-components: powerpc |
tests/run-make/rustdoc-output-stdout/foo.rs created+1| ... | ... | @@ -0,0 +1 @@ |
| 1 | pub struct Foo; |
tests/run-make/rustdoc-output-stdout/rmake.rs created+25| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | // This test verifies that rustdoc `-o -` prints JSON on stdout and doesn't generate | |
| 2 | // a JSON file. | |
| 3 | ||
| 4 | use std::path::PathBuf; | |
| 5 | ||
| 6 | use run_make_support::path_helpers::{cwd, has_extension, read_dir_entries_recursive}; | |
| 7 | use run_make_support::rustdoc; | |
| 8 | ||
| 9 | fn main() { | |
| 10 | // First we check that we generate the JSON in the stdout. | |
| 11 | rustdoc() | |
| 12 | .input("foo.rs") | |
| 13 | .output("-") | |
| 14 | .arg("-Zunstable-options") | |
| 15 | .output_format("json") | |
| 16 | .run() | |
| 17 | .assert_stdout_contains("{\""); | |
| 18 | ||
| 19 | // Then we check it didn't generate any JSON file. | |
| 20 | read_dir_entries_recursive(cwd(), |path| { | |
| 21 | if path.is_file() && has_extension(path, "json") { | |
| 22 | panic!("Found a JSON file {path:?}"); | |
| 23 | } | |
| 24 | }); | |
| 25 | } |
tests/ui/deriving/auxiliary/another-proc-macro.rs created+45| ... | ... | @@ -0,0 +1,45 @@ |
| 1 | //@ force-host | |
| 2 | //@ no-prefer-dynamic | |
| 3 | ||
| 4 | #![crate_type = "proc-macro"] | |
| 5 | #![feature(proc_macro_quote)] | |
| 6 | ||
| 7 | extern crate proc_macro; | |
| 8 | ||
| 9 | use proc_macro::{quote, TokenStream}; | |
| 10 | ||
| 11 | #[proc_macro_derive(AnotherMacro, attributes(pointee))] | |
| 12 | pub fn derive(_input: TokenStream) -> TokenStream { | |
| 13 | quote! { | |
| 14 | const _: () = { | |
| 15 | const ANOTHER_MACRO_DERIVED: () = (); | |
| 16 | }; | |
| 17 | } | |
| 18 | .into() | |
| 19 | } | |
| 20 | ||
| 21 | #[proc_macro_attribute] | |
| 22 | pub fn pointee( | |
| 23 | _attr: proc_macro::TokenStream, | |
| 24 | _item: proc_macro::TokenStream, | |
| 25 | ) -> proc_macro::TokenStream { | |
| 26 | quote! { | |
| 27 | const _: () = { | |
| 28 | const POINTEE_MACRO_ATTR_DERIVED: () = (); | |
| 29 | }; | |
| 30 | } | |
| 31 | .into() | |
| 32 | } | |
| 33 | ||
| 34 | #[proc_macro_attribute] | |
| 35 | pub fn default( | |
| 36 | _attr: proc_macro::TokenStream, | |
| 37 | _item: proc_macro::TokenStream, | |
| 38 | ) -> proc_macro::TokenStream { | |
| 39 | quote! { | |
| 40 | const _: () = { | |
| 41 | const DEFAULT_MACRO_ATTR_DERIVED: () = (); | |
| 42 | }; | |
| 43 | } | |
| 44 | .into() | |
| 45 | } |
tests/ui/deriving/built-in-proc-macro-scope.rs created+25| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | //@ check-pass | |
| 2 | //@ aux-build: another-proc-macro.rs | |
| 3 | //@ compile-flags: -Zunpretty=expanded | |
| 4 | ||
| 5 | #![feature(derive_smart_pointer)] | |
| 6 | ||
| 7 | #[macro_use] | |
| 8 | extern crate another_proc_macro; | |
| 9 | ||
| 10 | use another_proc_macro::{pointee, AnotherMacro}; | |
| 11 | ||
| 12 | #[derive(core::marker::SmartPointer)] | |
| 13 | #[repr(transparent)] | |
| 14 | pub struct Ptr<'a, #[pointee] T: ?Sized> { | |
| 15 | data: &'a mut T, | |
| 16 | } | |
| 17 | ||
| 18 | #[pointee] | |
| 19 | fn f() {} | |
| 20 | ||
| 21 | #[derive(AnotherMacro)] | |
| 22 | #[pointee] | |
| 23 | struct MyStruct; | |
| 24 | ||
| 25 | fn main() {} |
tests/ui/deriving/built-in-proc-macro-scope.stdout created+43| ... | ... | @@ -0,0 +1,43 @@ |
| 1 | #![feature(prelude_import)] | |
| 2 | #![no_std] | |
| 3 | //@ check-pass | |
| 4 | //@ aux-build: another-proc-macro.rs | |
| 5 | //@ compile-flags: -Zunpretty=expanded | |
| 6 | ||
| 7 | #![feature(derive_smart_pointer)] | |
| 8 | #[prelude_import] | |
| 9 | use ::std::prelude::rust_2015::*; | |
| 10 | #[macro_use] | |
| 11 | extern crate std; | |
| 12 | ||
| 13 | #[macro_use] | |
| 14 | extern crate another_proc_macro; | |
| 15 | ||
| 16 | use another_proc_macro::{pointee, AnotherMacro}; | |
| 17 | ||
| 18 | #[repr(transparent)] | |
| 19 | pub struct Ptr<'a, #[pointee] T: ?Sized> { | |
| 20 | data: &'a mut T, | |
| 21 | } | |
| 22 | #[automatically_derived] | |
| 23 | impl<'a, T: ?Sized + ::core::marker::Unsize<__S>, __S: ?Sized> | |
| 24 | ::core::ops::DispatchFromDyn<Ptr<'a, __S>> for Ptr<'a, T> { | |
| 25 | } | |
| 26 | #[automatically_derived] | |
| 27 | impl<'a, T: ?Sized + ::core::marker::Unsize<__S>, __S: ?Sized> | |
| 28 | ::core::ops::CoerceUnsized<Ptr<'a, __S>> for Ptr<'a, T> { | |
| 29 | } | |
| 30 | ||
| 31 | ||
| 32 | ||
| 33 | const _: () = | |
| 34 | { | |
| 35 | const POINTEE_MACRO_ATTR_DERIVED: () = (); | |
| 36 | }; | |
| 37 | #[pointee] | |
| 38 | struct MyStruct; | |
| 39 | const _: () = | |
| 40 | { | |
| 41 | const ANOTHER_MACRO_DERIVED: () = (); | |
| 42 | }; | |
| 43 | fn main() {} |
tests/ui/deriving/proc-macro-attribute-mixing.rs created+20| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | // This test certify that we can mix attribute macros from Rust and external proc-macros. | |
| 2 | // For instance, `#[derive(Default)]` uses `#[default]` and `#[derive(SmartPointer)]` uses | |
| 3 | // `#[pointee]`. | |
| 4 | // The scoping rule should allow the use of the said two attributes when external proc-macros | |
| 5 | // are in scope. | |
| 6 | ||
| 7 | //@ check-pass | |
| 8 | //@ aux-build: another-proc-macro.rs | |
| 9 | //@ compile-flags: -Zunpretty=expanded | |
| 10 | ||
| 11 | #![feature(derive_smart_pointer)] | |
| 12 | ||
| 13 | #[macro_use] | |
| 14 | extern crate another_proc_macro; | |
| 15 | ||
| 16 | #[pointee] | |
| 17 | fn f() {} | |
| 18 | ||
| 19 | #[default] | |
| 20 | fn g() {} |
tests/ui/deriving/proc-macro-attribute-mixing.stdout created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | #![feature(prelude_import)] | |
| 2 | #![no_std] | |
| 3 | // This test certify that we can mix attribute macros from Rust and external proc-macros. | |
| 4 | // For instance, `#[derive(Default)]` uses `#[default]` and `#[derive(SmartPointer)]` uses | |
| 5 | // `#[pointee]`. | |
| 6 | // The scoping rule should allow the use of the said two attributes when external proc-macros | |
| 7 | // are in scope. | |
| 8 | ||
| 9 | //@ check-pass | |
| 10 | //@ aux-build: another-proc-macro.rs | |
| 11 | //@ compile-flags: -Zunpretty=expanded | |
| 12 | ||
| 13 | #![feature(derive_smart_pointer)] | |
| 14 | #[prelude_import] | |
| 15 | use ::std::prelude::rust_2015::*; | |
| 16 | #[macro_use] | |
| 17 | extern crate std; | |
| 18 | ||
| 19 | #[macro_use] | |
| 20 | extern crate another_proc_macro; | |
| 21 | ||
| 22 | ||
| 23 | const _: () = | |
| 24 | { | |
| 25 | const POINTEE_MACRO_ATTR_DERIVED: () = (); | |
| 26 | }; | |
| 27 | const _: () = | |
| 28 | { | |
| 29 | const DEFAULT_MACRO_ATTR_DERIVED: () = (); | |
| 30 | }; |
tests/ui/feature-gates/feature-gate-derive-smart-pointer.rs-1| ... | ... | @@ -3,7 +3,6 @@ use std::marker::SmartPointer; //~ ERROR use of unstable library feature 'derive |
| 3 | 3 | #[derive(SmartPointer)] //~ ERROR use of unstable library feature 'derive_smart_pointer' |
| 4 | 4 | #[repr(transparent)] |
| 5 | 5 | struct MyPointer<'a, #[pointee] T: ?Sized> { |
| 6 | //~^ ERROR the `#[pointee]` attribute is an experimental feature | |
| 7 | 6 | ptr: &'a T, |
| 8 | 7 | } |
| 9 | 8 |
tests/ui/feature-gates/feature-gate-derive-smart-pointer.stderr+1-11| ... | ... | @@ -8,16 +8,6 @@ LL | #[derive(SmartPointer)] |
| 8 | 8 | = help: add `#![feature(derive_smart_pointer)]` to the crate attributes to enable |
| 9 | 9 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 10 | 10 | |
| 11 | error[E0658]: the `#[pointee]` attribute is an experimental feature | |
| 12 | --> $DIR/feature-gate-derive-smart-pointer.rs:5:22 | |
| 13 | | | |
| 14 | LL | struct MyPointer<'a, #[pointee] T: ?Sized> { | |
| 15 | | ^^^^^^^^^^ | |
| 16 | | | |
| 17 | = note: see issue #123430 <https://github.com/rust-lang/rust/issues/123430> for more information | |
| 18 | = help: add `#![feature(derive_smart_pointer)]` to the crate attributes to enable | |
| 19 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | |
| 20 | ||
| 21 | 11 | error[E0658]: use of unstable library feature 'derive_smart_pointer' |
| 22 | 12 | --> $DIR/feature-gate-derive-smart-pointer.rs:1:5 |
| 23 | 13 | | |
| ... | ... | @@ -28,6 +18,6 @@ LL | use std::marker::SmartPointer; |
| 28 | 18 | = help: add `#![feature(derive_smart_pointer)]` to the crate attributes to enable |
| 29 | 19 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 30 | 20 | |
| 31 | error: aborting due to 3 previous errors | |
| 21 | error: aborting due to 2 previous errors | |
| 32 | 22 | |
| 33 | 23 | For more information about this error, try `rustc --explain E0658`. |
tests/ui/rust-2024/unsafe-before_exec.e2024.stderr created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | error[E0133]: call to unsafe function `before_exec` is unsafe and requires unsafe block | |
| 2 | --> $DIR/unsafe-before_exec.rs:14:5 | |
| 3 | | | |
| 4 | LL | cmd.before_exec(|| Ok(())); | |
| 5 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | |
| 6 | | | |
| 7 | = note: consult the function's documentation for information on how to avoid undefined behavior | |
| 8 | ||
| 9 | error: aborting due to 1 previous error | |
| 10 | ||
| 11 | For more information about this error, try `rustc --explain E0133`. |
tests/ui/rust-2024/unsafe-before_exec.rs created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | //@ revisions: e2021 e2024 | |
| 2 | //@ only-unix | |
| 3 | //@[e2021] edition: 2021 | |
| 4 | //@[e2021] check-pass | |
| 5 | //@[e2024] edition: 2024 | |
| 6 | //@[e2024] compile-flags: -Zunstable-options | |
| 7 | ||
| 8 | use std::process::Command; | |
| 9 | use std::os::unix::process::CommandExt; | |
| 10 | ||
| 11 | #[allow(deprecated)] | |
| 12 | fn main() { | |
| 13 | let mut cmd = Command::new("sleep"); | |
| 14 | cmd.before_exec(|| Ok(())); | |
| 15 | //[e2024]~^ ERROR call to unsafe function `before_exec` is unsafe | |
| 16 | drop(cmd); // we don't actually run the command. | |
| 17 | } |