authorbors <bors@rust-lang.org> 2024-08-15 03:44:39 UTC
committerbors <bors@rust-lang.org> 2024-08-15 03:44:39 UTC
log0ba9db87e61adcfd9a978188f61c20d9b423a099
treef527e3b8de113dad5eb0bcfeeb092b707e833fc9
parent13a52890dde8cfeb95069d77c223ac37c0cf3a46
parente14f171e96f3b1cfccfe77d991a2b815d9659981

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

38 files changed, 419 insertions(+), 66 deletions(-)

.github/workflows/dependencies.yml+1-1
......@@ -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
......@@ -1775,9 +1775,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
17751775
17761776[[package]]
17771777name = "indexmap"
1778version = "2.2.6"
1778version = "2.4.0"
17791779source = "registry+https://github.com/rust-lang/crates.io-index"
1780checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
1780checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c"
17811781dependencies = [
17821782 "equivalent",
17831783 "hashbrown",
compiler/rustc_data_structures/Cargo.toml+1-1
......@@ -10,7 +10,7 @@ bitflags = "2.4.1"
1010either = "1.0"
1111elsa = "=1.7.1"
1212ena = "0.14.3"
13indexmap = { version = "2.0.0" }
13indexmap = { version = "2.4.0" }
1414jobserver_crate = { version = "0.1.28", package = "jobserver" }
1515measureme = "11"
1616rustc-hash = "1.1.0"
compiler/rustc_feature/src/builtin_attrs.rs-6
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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),
compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_muslspe.rs created+28
......@@ -0,0 +1,28 @@
1use crate::abi::Endian;
2use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
3
4pub 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 {
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")]
10661066pub macro SmartPointer($item:item) {
library/core/src/net/ip_addr.rs+23-2
......@@ -1,6 +1,7 @@
11use super::display_buffer::DisplayBuffer;
22use crate::cmp::Ordering;
33use crate::fmt::{self, Write};
4use crate::hash::{Hash, Hasher};
45use crate::iter;
56use crate::mem::transmute;
67use 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")]
7273pub struct Ipv4Addr {
7374 octets: [u8; 4],
7475}
7576
77#[stable(feature = "rust1", since = "1.0.0")]
78impl 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")]
154165pub struct Ipv6Addr {
155166 octets: [u8; 16],
156167}
157168
169#[stable(feature = "rust1", since = "1.0.0")]
170impl 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
......@@ -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/book+1-1
......@@ -1 +1 @@
1Subproject commit 67fa536768013d9d5a13f3a06790521d511ef711
1Subproject commit 04bc1396bb857f35b5dda1d773c9571e1f253304
src/doc/edition-guide+1-1
......@@ -1 +1 @@
1Subproject commit 5454de3d12b9ccc6375b629cf7ccda8264640aac
1Subproject commit aeeb287d41a0332c210da122bea8e0e91844ab3e
src/doc/nomicon+1-1
......@@ -1 +1 @@
1Subproject commit 0ebdacadbda8ce2cd8fbf93985e15af61a7ab895
1Subproject commit 6ecf95c5f2bfa0e6314dfe282bf775fd1405f7e9
src/doc/reference+1-1
......@@ -1 +1 @@
1Subproject commit 2e191814f163ee1e77e2d6094eee4dd78a289c5b
1Subproject commit 62cd0df95061ba0ac886333f5cd7f3012f149da1
src/doc/rust-by-example+1-1
......@@ -1 +1 @@
1Subproject commit 89aecb6951b77bc746da73df8c9f2b2ceaad494a
1Subproject commit 8f94061936e492159f4f6c09c0f917a7521893ff
src/doc/rustc-dev-guide+1-1
......@@ -1 +1 @@
1Subproject commit 0c4d55cb59fe440d1a630e4e5774d043968edb3f
1Subproject commit 43d83780db545a1ed6d45773312fc578987e3968
src/doc/rustc/src/SUMMARY.md+1
......@@ -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
......@@ -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) | ✓ | |
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
5This target is very similar to already existing ones like `powerpc_unknown_linux_musl` and `powerpc_unknown_linux_gnuspe`.
6This 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
14This target is cross-compiled. There is no support for `std`. There is no
15default allocator, but it's possible to use `alloc` by supplying an allocator.
16
17This target generated binaries in the ELF format.
18
19## Building the target
20
21This 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
25Rust does not yet ship pre-compiled artifacts for this target. To compile for
26this 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
32This 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() {}
515515
516516Note that the third item is the crate root, which in this case is undocumented.
517517
518If you want the JSON output to be displayed on `stdout` instead of having a file generated, you can
519use `-o -`.
520
518521### `-w`/`--output-format`: output format
519522
520523`--output-format json` emits documentation in the experimental
src/librustdoc/config.rs+10-5
......@@ -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 }
src/librustdoc/json/mod.rs+31-16
......@@ -9,7 +9,7 @@ mod import_finder;
99
1010use std::cell::RefCell;
1111use std::fs::{create_dir_all, File};
12use std::io::{BufWriter, Write};
12use std::io::{stdout, BufWriter, Write};
1313use std::path::PathBuf;
1414use std::rc::Rc;
1515
......@@ -37,7 +37,7 @@ pub(crate) struct JsonRenderer<'tcx> {
3737 /// level field of the JSON blob.
3838 index: Rc<RefCell<FxHashMap<types::Id, types::Item>>>,
3939 /// The directory where the blob will be written to.
40 out_path: PathBuf,
40 out_path: Option<PathBuf>,
4141 cache: Rc<Cache>,
4242 imported_items: DefIdSet,
4343}
......@@ -97,6 +97,20 @@ impl<'tcx> JsonRenderer<'tcx> {
9797 })
9898 .unwrap_or_default()
9999 }
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 }
100114}
101115
102116impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
......@@ -120,7 +134,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
120134 JsonRenderer {
121135 tcx,
122136 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) },
124138 cache: Rc::new(cache),
125139 imported_items,
126140 },
......@@ -264,20 +278,21 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
264278 .collect(),
265279 format_version: types::FORMAT_VERSION,
266280 };
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);
269284
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 }
281296 }
282297
283298 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 {
8484pub fn filename_contains<P: AsRef<Path>>(path: P, needle: &str) -> bool {
8585 path.as_ref().file_name().is_some_and(|name| name.to_str().unwrap().contains(needle))
8686}
87
88/// Helper for reading entries in a given directory and its children.
89pub 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 = [
303303 "crypto-common",
304304]
305305
306[[package]]
307name = "doc-comment"
308version = "0.3.3"
309source = "registry+https://github.com/rust-lang/crates.io-index"
310checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
311
306312[[package]]
307313name = "elasticlunr-rs"
308314version = "3.0.2"
......@@ -465,6 +471,21 @@ dependencies = [
465471 "syn",
466472]
467473
474[[package]]
475name = "html_parser"
476version = "0.7.0"
477source = "registry+https://github.com/rust-lang/crates.io-index"
478checksum = "f6f56db07b6612644f6f7719f8ef944f75fff9d6378fdf3d316fd32194184abd"
479dependencies = [
480 "doc-comment",
481 "pest",
482 "pest_derive",
483 "serde",
484 "serde_derive",
485 "serde_json",
486 "thiserror",
487]
488
468489[[package]]
469490name = "humantime"
470491version = "2.1.0"
......@@ -680,13 +701,13 @@ name = "mdbook-trpl-listing"
680701version = "0.1.0"
681702dependencies = [
682703 "clap",
704 "html_parser",
683705 "mdbook",
684706 "pulldown-cmark",
685707 "pulldown-cmark-to-cmark",
686708 "serde_json",
687709 "thiserror",
688710 "toml 0.8.14",
689 "xmlparser",
690711]
691712
692713[[package]]
......@@ -1767,12 +1788,6 @@ dependencies = [
17671788 "memchr",
17681789]
17691790
1770[[package]]
1771name = "xmlparser"
1772version = "0.13.6"
1773source = "registry+https://github.com/rust-lang/crates.io-index"
1774checksum = "66fee0b777b0f5ac1c69bb06d361268faafa61cd4682ae064a171c16c433e9e4"
1775
17761791[[package]]
17771792name = "yaml-rust"
17781793version = "0.4.5"
tests/assembly/targets/targets-elf.rs+3
......@@ -345,6 +345,9 @@
345345//@ revisions: powerpc_unknown_linux_musl
346346//@ [powerpc_unknown_linux_musl] compile-flags: --target powerpc-unknown-linux-musl
347347//@ [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
348351//@ revisions: powerpc_unknown_netbsd
349352//@ [powerpc_unknown_netbsd] compile-flags: --target powerpc-unknown-netbsd
350353//@ [powerpc_unknown_netbsd] needs-llvm-components: powerpc
tests/run-make/rustdoc-output-stdout/foo.rs created+1
......@@ -0,0 +1 @@
1pub 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
4use std::path::PathBuf;
5
6use run_make_support::path_helpers::{cwd, has_extension, read_dir_entries_recursive};
7use run_make_support::rustdoc;
8
9fn 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
7extern crate proc_macro;
8
9use proc_macro::{quote, TokenStream};
10
11#[proc_macro_derive(AnotherMacro, attributes(pointee))]
12pub fn derive(_input: TokenStream) -> TokenStream {
13 quote! {
14 const _: () = {
15 const ANOTHER_MACRO_DERIVED: () = ();
16 };
17 }
18 .into()
19}
20
21#[proc_macro_attribute]
22pub 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]
35pub 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]
8extern crate another_proc_macro;
9
10use another_proc_macro::{pointee, AnotherMacro};
11
12#[derive(core::marker::SmartPointer)]
13#[repr(transparent)]
14pub struct Ptr<'a, #[pointee] T: ?Sized> {
15 data: &'a mut T,
16}
17
18#[pointee]
19fn f() {}
20
21#[derive(AnotherMacro)]
22#[pointee]
23struct MyStruct;
24
25fn 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]
9use ::std::prelude::rust_2015::*;
10#[macro_use]
11extern crate std;
12
13#[macro_use]
14extern crate another_proc_macro;
15
16use another_proc_macro::{pointee, AnotherMacro};
17
18#[repr(transparent)]
19pub struct Ptr<'a, #[pointee] T: ?Sized> {
20 data: &'a mut T,
21}
22#[automatically_derived]
23impl<'a, T: ?Sized + ::core::marker::Unsize<__S>, __S: ?Sized>
24 ::core::ops::DispatchFromDyn<Ptr<'a, __S>> for Ptr<'a, T> {
25}
26#[automatically_derived]
27impl<'a, T: ?Sized + ::core::marker::Unsize<__S>, __S: ?Sized>
28 ::core::ops::CoerceUnsized<Ptr<'a, __S>> for Ptr<'a, T> {
29}
30
31
32
33const _: () =
34 {
35 const POINTEE_MACRO_ATTR_DERIVED: () = ();
36 };
37#[pointee]
38struct MyStruct;
39const _: () =
40 {
41 const ANOTHER_MACRO_DERIVED: () = ();
42 };
43fn 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]
14extern crate another_proc_macro;
15
16#[pointee]
17fn f() {}
18
19#[default]
20fn 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]
15use ::std::prelude::rust_2015::*;
16#[macro_use]
17extern crate std;
18
19#[macro_use]
20extern crate another_proc_macro;
21
22
23const _: () =
24 {
25 const POINTEE_MACRO_ATTR_DERIVED: () = ();
26 };
27const _: () =
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
33#[derive(SmartPointer)] //~ ERROR use of unstable library feature 'derive_smart_pointer'
44#[repr(transparent)]
55struct MyPointer<'a, #[pointee] T: ?Sized> {
6 //~^ ERROR the `#[pointee]` attribute is an experimental feature
76 ptr: &'a T,
87}
98
tests/ui/feature-gates/feature-gate-derive-smart-pointer.stderr+1-11
......@@ -8,16 +8,6 @@ LL | #[derive(SmartPointer)]
88 = help: add `#![feature(derive_smart_pointer)]` to the crate attributes to enable
99 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010
11error[E0658]: the `#[pointee]` attribute is an experimental feature
12 --> $DIR/feature-gate-derive-smart-pointer.rs:5:22
13 |
14LL | 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
2111error[E0658]: use of unstable library feature 'derive_smart_pointer'
2212 --> $DIR/feature-gate-derive-smart-pointer.rs:1:5
2313 |
......@@ -28,6 +18,6 @@ LL | use std::marker::SmartPointer;
2818 = help: add `#![feature(derive_smart_pointer)]` to the crate attributes to enable
2919 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
3020
31error: aborting due to 3 previous errors
21error: aborting due to 2 previous errors
3222
3323For more information about this error, try `rustc --explain E0658`.
tests/ui/rust-2024/unsafe-before_exec.e2024.stderr created+11
......@@ -0,0 +1,11 @@
1error[E0133]: call to unsafe function `before_exec` is unsafe and requires unsafe block
2 --> $DIR/unsafe-before_exec.rs:14:5
3 |
4LL | 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
9error: aborting due to 1 previous error
10
11For 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
8use std::process::Command;
9use std::os::unix::process::CommandExt;
10
11#[allow(deprecated)]
12fn 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}