Skip to content

Commit 8df945c

Browse files
committed
Auto merge of rust-lang#87269 - GuillaumeGomez:rollup-qukedv0, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - rust-lang#86230 (Add --nocapture option to rustdoc) - rust-lang#87210 (Rustdoc accessibility: make the sidebar headers actual headers) - rust-lang#87227 (Move asm! and global_asm! to core::arch) - rust-lang#87236 (Simplify command-line argument initialization on unix) - rust-lang#87251 (Fix "item info" width) - rust-lang#87256 (Extend HIR-based WF checking to associated type defaults) - rust-lang#87259 (triagebot shortcut config) - rust-lang#87268 (Don't create references to uninitialized data in `List::from_arena`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 83f0822 + 6cb69ea commit 8df945c

35 files changed

+239
-126
lines changed

compiler/rustc_middle/src/ty/list.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ impl<T: Copy> List<T> {
6363

6464
let (layout, _offset) =
6565
Layout::new::<usize>().extend(Layout::for_value::<[T]>(slice)).unwrap();
66-
let mem = arena.dropless.alloc_raw(layout);
66+
let mem = arena.dropless.alloc_raw(layout) as *mut List<T>;
6767
unsafe {
68-
let result = &mut *(mem as *mut List<T>);
6968
// Write the length
70-
result.len = slice.len();
69+
ptr::addr_of_mut!((*mem).len).write(slice.len());
7170

7271
// Write the elements
73-
let arena_slice = slice::from_raw_parts_mut(result.data.as_mut_ptr(), result.len);
74-
arena_slice.copy_from_slice(slice);
72+
ptr::addr_of_mut!((*mem).data)
73+
.cast::<T>()
74+
.copy_from_nonoverlapping(slice.as_ptr(), slice.len());
7575

76-
result
76+
&mut *mem
7777
}
7878
}
7979

compiler/rustc_typeck/src/hir_wf_check.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ fn diagnostic_hir_wf_check<'tcx>(
121121

122122
let ty = match tcx.hir().get(hir_id) {
123123
hir::Node::ImplItem(item) => match item.kind {
124-
hir::ImplItemKind::TyAlias(ref ty) => Some(ty),
124+
hir::ImplItemKind::TyAlias(ty) => Some(ty),
125+
_ => None,
126+
},
127+
hir::Node::TraitItem(item) => match item.kind {
128+
hir::TraitItemKind::Type(_, ty) => ty,
125129
_ => None,
126130
},
127131
_ => None,

library/core/src/lib.rs

+31-1
Original file line numberDiff line numberDiff line change
@@ -316,5 +316,35 @@ pub mod primitive;
316316
#[unstable(feature = "stdsimd", issue = "48556")]
317317
mod core_arch;
318318

319+
#[doc = include_str!("../../stdarch/crates/core_arch/src/core_arch_docs.md")]
319320
#[stable(feature = "simd_arch", since = "1.27.0")]
320-
pub use core_arch::arch;
321+
pub mod arch {
322+
#[stable(feature = "simd_arch", since = "1.27.0")]
323+
pub use crate::core_arch::arch::*;
324+
325+
/// Inline assembly.
326+
///
327+
/// Read the [unstable book] for the usage.
328+
///
329+
/// [unstable book]: ../../unstable-book/library-features/asm.html
330+
#[unstable(
331+
feature = "asm",
332+
issue = "72016",
333+
reason = "inline assembly is not stable enough for use and is subject to change"
334+
)]
335+
#[rustc_builtin_macro]
336+
pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
337+
/* compiler built-in */
338+
}
339+
340+
/// Module-level inline assembly.
341+
#[unstable(
342+
feature = "global_asm",
343+
issue = "35119",
344+
reason = "`global_asm!` is not stable enough for use and is subject to change"
345+
)]
346+
#[rustc_builtin_macro]
347+
pub macro global_asm("assembly template", $(operands,)* $(options($(option),*))?) {
348+
/* compiler built-in */
349+
}
350+
}

library/core/src/macros/mod.rs

-38
Original file line numberDiff line numberDiff line change
@@ -1312,27 +1312,6 @@ pub(crate) mod builtin {
13121312
($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};
13131313
}
13141314

1315-
/// Inline assembly.
1316-
///
1317-
/// Read the [unstable book] for the usage.
1318-
///
1319-
/// [unstable book]: ../unstable-book/library-features/asm.html
1320-
#[unstable(
1321-
feature = "asm",
1322-
issue = "72016",
1323-
reason = "inline assembly is not stable enough for use and is subject to change"
1324-
)]
1325-
#[rustc_builtin_macro]
1326-
#[macro_export]
1327-
macro_rules! asm {
1328-
("assembly template",
1329-
$(operands,)*
1330-
$(options($(option),*))?
1331-
) => {
1332-
/* compiler built-in */
1333-
};
1334-
}
1335-
13361315
/// LLVM-style inline assembly.
13371316
///
13381317
/// Read the [unstable book] for the usage.
@@ -1355,23 +1334,6 @@ pub(crate) mod builtin {
13551334
};
13561335
}
13571336

1358-
/// Module-level inline assembly.
1359-
#[unstable(
1360-
feature = "global_asm",
1361-
issue = "35119",
1362-
reason = "`global_asm!` is not stable enough for use and is subject to change"
1363-
)]
1364-
#[rustc_builtin_macro]
1365-
#[macro_export]
1366-
macro_rules! global_asm {
1367-
("assembly template",
1368-
$(operands,)*
1369-
$(options($(option),*))?
1370-
) => {
1371-
/* compiler built-in */
1372-
};
1373-
}
1374-
13751337
/// Prints passed tokens into the standard output.
13761338
#[unstable(
13771339
feature = "log_syntax",

library/core/src/prelude/v1.rs

+19-3
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,27 @@ pub use crate::hash::macros::Hash;
5555
#[allow(deprecated)]
5656
#[doc(no_inline)]
5757
pub use crate::{
58-
asm, assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
59-
format_args_nl, global_asm, include, include_bytes, include_str, line, llvm_asm, log_syntax,
60-
module_path, option_env, stringify, trace_macros,
58+
assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
59+
format_args_nl, include, include_bytes, include_str, line, llvm_asm, log_syntax, module_path,
60+
option_env, stringify, trace_macros,
6161
};
6262

63+
#[unstable(
64+
feature = "asm",
65+
issue = "72016",
66+
reason = "inline assembly is not stable enough for use and is subject to change"
67+
)]
68+
#[doc(no_inline)]
69+
pub use crate::arch::asm;
70+
71+
#[unstable(
72+
feature = "global_asm",
73+
issue = "35119",
74+
reason = "`global_asm!` is not stable enough for use and is subject to change"
75+
)]
76+
#[doc(no_inline)]
77+
pub use crate::arch::global_asm;
78+
6379
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
6480
#[allow(deprecated, deprecated_in_future)]
6581
#[doc(no_inline)]

library/std/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,9 @@ pub use core::{
556556
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
557557
#[allow(deprecated)]
558558
pub use core::{
559-
asm, assert, assert_matches, cfg, column, compile_error, concat, concat_idents, env, file,
560-
format_args, format_args_nl, global_asm, include, include_bytes, include_str, line, llvm_asm,
561-
log_syntax, module_path, option_env, stringify, trace_macros,
559+
assert, assert_matches, cfg, column, compile_error, concat, concat_idents, env, file,
560+
format_args, format_args_nl, include, include_bytes, include_str, line, llvm_asm, log_syntax,
561+
module_path, option_env, stringify, trace_macros,
562562
};
563563

564564
#[stable(feature = "core_primitive", since = "1.43.0")]

library/std/src/prelude/v1.rs

+20-4
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,28 @@ pub use crate::result::Result::{self, Err, Ok};
3939
#[allow(deprecated)]
4040
#[doc(no_inline)]
4141
pub use core::prelude::v1::{
42-
asm, assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
43-
format_args_nl, global_asm, include, include_bytes, include_str, line, llvm_asm, log_syntax,
44-
module_path, option_env, stringify, trace_macros, Clone, Copy, Debug, Default, Eq, Hash, Ord,
45-
PartialEq, PartialOrd,
42+
assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
43+
format_args_nl, include, include_bytes, include_str, line, llvm_asm, log_syntax, module_path,
44+
option_env, stringify, trace_macros, Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq,
45+
PartialOrd,
4646
};
4747

48+
#[unstable(
49+
feature = "asm",
50+
issue = "72016",
51+
reason = "inline assembly is not stable enough for use and is subject to change"
52+
)]
53+
#[doc(no_inline)]
54+
pub use core::prelude::v1::asm;
55+
56+
#[unstable(
57+
feature = "global_asm",
58+
issue = "35119",
59+
reason = "`global_asm!` is not stable enough for use and is subject to change"
60+
)]
61+
#[doc(no_inline)]
62+
pub use core::prelude::v1::global_asm;
63+
4864
// FIXME: Attribute and internal derive macros are not documented because for them rustdoc generates
4965
// dead links which fail link checker testing.
5066
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]

library/std/src/sys/unix/args.rs

+3-21
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ pub unsafe fn init(argc: isize, argv: *const *const u8) {
1414
imp::init(argc, argv)
1515
}
1616

17-
/// One-time global cleanup.
18-
pub unsafe fn cleanup() {
19-
imp::cleanup()
20-
}
21-
2217
/// Returns the command line arguments
2318
pub fn args() -> Args {
2419
imp::args()
@@ -82,16 +77,10 @@ mod imp {
8277
use crate::ptr;
8378
use crate::sync::atomic::{AtomicIsize, AtomicPtr, Ordering};
8479

85-
use crate::sys_common::mutex::StaticMutex;
86-
8780
static ARGC: AtomicIsize = AtomicIsize::new(0);
8881
static ARGV: AtomicPtr<*const u8> = AtomicPtr::new(ptr::null_mut());
89-
// We never call `ENV_LOCK.init()`, so it is UB to attempt to
90-
// acquire this mutex reentrantly!
91-
static LOCK: StaticMutex = StaticMutex::new();
9282

9383
unsafe fn really_init(argc: isize, argv: *const *const u8) {
94-
let _guard = LOCK.lock();
9584
ARGC.store(argc, Ordering::Relaxed);
9685
ARGV.store(argv as *mut _, Ordering::Relaxed);
9786
}
@@ -127,21 +116,16 @@ mod imp {
127116
init_wrapper
128117
};
129118

130-
pub unsafe fn cleanup() {
131-
let _guard = LOCK.lock();
132-
ARGC.store(0, Ordering::Relaxed);
133-
ARGV.store(ptr::null_mut(), Ordering::Relaxed);
134-
}
135-
136119
pub fn args() -> Args {
137120
Args { iter: clone().into_iter() }
138121
}
139122

140123
fn clone() -> Vec<OsString> {
141124
unsafe {
142-
let _guard = LOCK.lock();
143-
let argc = ARGC.load(Ordering::Relaxed);
125+
// Load ARGC and ARGV without a lock. If the store to either ARGV or
126+
// ARGC isn't visible yet, we'll return an empty argument list.
144127
let argv = ARGV.load(Ordering::Relaxed);
128+
let argc = if argv.is_null() { 0 } else { ARGC.load(Ordering::Relaxed) };
145129
(0..argc)
146130
.map(|i| {
147131
let cstr = CStr::from_ptr(*argv.offset(i) as *const libc::c_char);
@@ -159,8 +143,6 @@ mod imp {
159143

160144
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {}
161145

162-
pub fn cleanup() {}
163-
164146
#[cfg(target_os = "macos")]
165147
pub fn args() -> Args {
166148
use crate::os::unix::prelude::*;

library/std/src/sys/unix/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ pub unsafe fn init(argc: isize, argv: *const *const u8) {
123123
// SAFETY: must be called only once during runtime cleanup.
124124
// NOTE: this is not guaranteed to run, for example when the program aborts.
125125
pub unsafe fn cleanup() {
126-
args::cleanup();
127126
stack_overflow::cleanup();
128127
}
129128

src/doc/rustdoc/src/command-line-arguments.md

+7
Original file line numberDiff line numberDiff line change
@@ -417,3 +417,10 @@ This flag is **deprecated** and **has no effect**.
417417
Rustdoc only supports Rust source code and Markdown input formats. If the
418418
file ends in `.md` or `.markdown`, `rustdoc` treats it as a Markdown file.
419419
Otherwise, it assumes that the input file is Rust.
420+
421+
## `--nocapture`
422+
423+
When this flag is used with `--test`, the output (stdout and stderr) of your tests won't be
424+
captured by rustdoc. Instead, the output will be directed to your terminal,
425+
as if you had run the test executable manually. This is especially useful
426+
for debugging your tests!

src/librustdoc/config.rs

+5
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ crate struct Options {
156156
crate run_check: bool,
157157
/// Whether doctests should emit unused externs
158158
crate json_unused_externs: bool,
159+
/// Whether to skip capturing stdout and stderr of tests.
160+
crate nocapture: bool,
159161
}
160162

161163
impl fmt::Debug for Options {
@@ -199,6 +201,7 @@ impl fmt::Debug for Options {
199201
.field("enable-per-target-ignores", &self.enable_per_target_ignores)
200202
.field("run_check", &self.run_check)
201203
.field("no_run", &self.no_run)
204+
.field("nocapture", &self.nocapture)
202205
.finish()
203206
}
204207
}
@@ -627,6 +630,7 @@ impl Options {
627630
let run_check = matches.opt_present("check");
628631
let generate_redirect_map = matches.opt_present("generate-redirect-map");
629632
let show_type_layout = matches.opt_present("show-type-layout");
633+
let nocapture = matches.opt_present("nocapture");
630634

631635
let (lint_opts, describe_lints, lint_cap, _) =
632636
get_cmd_lint_options(matches, error_format, &debugging_opts);
@@ -665,6 +669,7 @@ impl Options {
665669
test_builder,
666670
run_check,
667671
no_run,
672+
nocapture,
668673
render_options: RenderOptions {
669674
output,
670675
external_html,

src/librustdoc/doctest.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
107107

108108
let mut test_args = options.test_args.clone();
109109
let display_warnings = options.display_warnings;
110+
let nocapture = options.nocapture;
110111
let externs = options.externs.clone();
111112
let json_unused_externs = options.json_unused_externs;
112113

@@ -166,6 +167,9 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
166167
};
167168

168169
test_args.insert(0, "rustdoctest".to_string());
170+
if nocapture {
171+
test_args.push("--nocapture".to_string());
172+
}
169173

170174
test::test_main(&test_args, tests, Some(test::Options::new().display_output(display_warnings)));
171175

@@ -456,7 +460,16 @@ fn run_test(
456460
cmd.current_dir(run_directory);
457461
}
458462

459-
match cmd.output() {
463+
let result = if options.nocapture {
464+
cmd.status().map(|status| process::Output {
465+
status,
466+
stdout: Vec::new(),
467+
stderr: Vec::new(),
468+
})
469+
} else {
470+
cmd.output()
471+
};
472+
match result {
460473
Err(e) => return Err(TestFailure::ExecutionError(e)),
461474
Ok(out) => {
462475
if should_panic && out.status.success() {

src/librustdoc/html/render/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
539539
};
540540
let sidebar = if let Some(ref version) = self.cache.crate_version {
541541
format!(
542-
"<p class=\"location\">Crate {}</p>\
542+
"<h2 class=\"location\">Crate {}</h2>\
543543
<div class=\"block version\">\
544544
<p>Version {}</p>\
545545
</div>\
@@ -567,7 +567,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
567567
page.root_path = "./";
568568

569569
let mut style_files = self.shared.style_files.clone();
570-
let sidebar = "<p class=\"location\">Settings</p><div class=\"sidebar-elems\"></div>";
570+
let sidebar = "<h2 class=\"location\">Settings</h2><div class=\"sidebar-elems\"></div>";
571571
style_files.push(StylePath { path: PathBuf::from("settings.css"), disabled: false });
572572
let v = layout::render(
573573
&self.shared.templates,

0 commit comments

Comments
 (0)