diff --git a/compiler/rustc_middle/src/ty/list.rs b/compiler/rustc_middle/src/ty/list.rs
index 44dfcbf1866a7..1dceda6c7aad0 100644
--- a/compiler/rustc_middle/src/ty/list.rs
+++ b/compiler/rustc_middle/src/ty/list.rs
@@ -63,17 +63,17 @@ impl List {
let (layout, _offset) =
Layout::new::().extend(Layout::for_value::<[T]>(slice)).unwrap();
- let mem = arena.dropless.alloc_raw(layout);
+ let mem = arena.dropless.alloc_raw(layout) as *mut List;
unsafe {
- let result = &mut *(mem as *mut List);
// Write the length
- result.len = slice.len();
+ ptr::addr_of_mut!((*mem).len).write(slice.len());
// Write the elements
- let arena_slice = slice::from_raw_parts_mut(result.data.as_mut_ptr(), result.len);
- arena_slice.copy_from_slice(slice);
+ ptr::addr_of_mut!((*mem).data)
+ .cast::()
+ .copy_from_nonoverlapping(slice.as_ptr(), slice.len());
- result
+ &mut *mem
}
}
diff --git a/compiler/rustc_typeck/src/hir_wf_check.rs b/compiler/rustc_typeck/src/hir_wf_check.rs
index fa9c44bb89191..a8ec7b79e571f 100644
--- a/compiler/rustc_typeck/src/hir_wf_check.rs
+++ b/compiler/rustc_typeck/src/hir_wf_check.rs
@@ -121,7 +121,11 @@ fn diagnostic_hir_wf_check<'tcx>(
let ty = match tcx.hir().get(hir_id) {
hir::Node::ImplItem(item) => match item.kind {
- hir::ImplItemKind::TyAlias(ref ty) => Some(ty),
+ hir::ImplItemKind::TyAlias(ty) => Some(ty),
+ _ => None,
+ },
+ hir::Node::TraitItem(item) => match item.kind {
+ hir::TraitItemKind::Type(_, ty) => ty,
_ => None,
},
_ => None,
diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
index 8bbce7e552c9b..540cdf124ee9c 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -316,5 +316,35 @@ pub mod primitive;
#[unstable(feature = "stdsimd", issue = "48556")]
mod core_arch;
+#[doc = include_str!("../../stdarch/crates/core_arch/src/core_arch_docs.md")]
#[stable(feature = "simd_arch", since = "1.27.0")]
-pub use core_arch::arch;
+pub mod arch {
+ #[stable(feature = "simd_arch", since = "1.27.0")]
+ pub use crate::core_arch::arch::*;
+
+ /// Inline assembly.
+ ///
+ /// Read the [unstable book] for the usage.
+ ///
+ /// [unstable book]: ../../unstable-book/library-features/asm.html
+ #[unstable(
+ feature = "asm",
+ issue = "72016",
+ reason = "inline assembly is not stable enough for use and is subject to change"
+ )]
+ #[rustc_builtin_macro]
+ pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
+ /* compiler built-in */
+ }
+
+ /// Module-level inline assembly.
+ #[unstable(
+ feature = "global_asm",
+ issue = "35119",
+ reason = "`global_asm!` is not stable enough for use and is subject to change"
+ )]
+ #[rustc_builtin_macro]
+ pub macro global_asm("assembly template", $(operands,)* $(options($(option),*))?) {
+ /* compiler built-in */
+ }
+}
diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs
index 57eedde91643d..3ca8f27c79ab7 100644
--- a/library/core/src/macros/mod.rs
+++ b/library/core/src/macros/mod.rs
@@ -1312,27 +1312,6 @@ pub(crate) mod builtin {
($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};
}
- /// Inline assembly.
- ///
- /// Read the [unstable book] for the usage.
- ///
- /// [unstable book]: ../unstable-book/library-features/asm.html
- #[unstable(
- feature = "asm",
- issue = "72016",
- reason = "inline assembly is not stable enough for use and is subject to change"
- )]
- #[rustc_builtin_macro]
- #[macro_export]
- macro_rules! asm {
- ("assembly template",
- $(operands,)*
- $(options($(option),*))?
- ) => {
- /* compiler built-in */
- };
- }
-
/// LLVM-style inline assembly.
///
/// Read the [unstable book] for the usage.
@@ -1355,23 +1334,6 @@ pub(crate) mod builtin {
};
}
- /// Module-level inline assembly.
- #[unstable(
- feature = "global_asm",
- issue = "35119",
- reason = "`global_asm!` is not stable enough for use and is subject to change"
- )]
- #[rustc_builtin_macro]
- #[macro_export]
- macro_rules! global_asm {
- ("assembly template",
- $(operands,)*
- $(options($(option),*))?
- ) => {
- /* compiler built-in */
- };
- }
-
/// Prints passed tokens into the standard output.
#[unstable(
feature = "log_syntax",
diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs
index c89fe57cb05ce..6b51ef5b0122d 100644
--- a/library/core/src/prelude/v1.rs
+++ b/library/core/src/prelude/v1.rs
@@ -55,11 +55,27 @@ pub use crate::hash::macros::Hash;
#[allow(deprecated)]
#[doc(no_inline)]
pub use crate::{
- asm, assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
- format_args_nl, global_asm, include, include_bytes, include_str, line, llvm_asm, log_syntax,
- module_path, option_env, stringify, trace_macros,
+ assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
+ format_args_nl, include, include_bytes, include_str, line, llvm_asm, log_syntax, module_path,
+ option_env, stringify, trace_macros,
};
+#[unstable(
+ feature = "asm",
+ issue = "72016",
+ reason = "inline assembly is not stable enough for use and is subject to change"
+)]
+#[doc(no_inline)]
+pub use crate::arch::asm;
+
+#[unstable(
+ feature = "global_asm",
+ issue = "35119",
+ reason = "`global_asm!` is not stable enough for use and is subject to change"
+)]
+#[doc(no_inline)]
+pub use crate::arch::global_asm;
+
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
#[allow(deprecated, deprecated_in_future)]
#[doc(no_inline)]
diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs
index a157a222c43e9..cfbfe7cc19160 100644
--- a/library/std/src/lib.rs
+++ b/library/std/src/lib.rs
@@ -556,9 +556,9 @@ pub use core::{
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
#[allow(deprecated)]
pub use core::{
- asm, assert, assert_matches, cfg, column, compile_error, concat, concat_idents, env, file,
- format_args, format_args_nl, global_asm, include, include_bytes, include_str, line, llvm_asm,
- log_syntax, module_path, option_env, stringify, trace_macros,
+ assert, assert_matches, cfg, column, compile_error, concat, concat_idents, env, file,
+ format_args, format_args_nl, include, include_bytes, include_str, line, llvm_asm, log_syntax,
+ module_path, option_env, stringify, trace_macros,
};
#[stable(feature = "core_primitive", since = "1.43.0")]
diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs
index 4a3c3ba163598..772044f014920 100644
--- a/library/std/src/prelude/v1.rs
+++ b/library/std/src/prelude/v1.rs
@@ -39,12 +39,28 @@ pub use crate::result::Result::{self, Err, Ok};
#[allow(deprecated)]
#[doc(no_inline)]
pub use core::prelude::v1::{
- asm, assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
- format_args_nl, global_asm, include, include_bytes, include_str, line, llvm_asm, log_syntax,
- module_path, option_env, stringify, trace_macros, Clone, Copy, Debug, Default, Eq, Hash, Ord,
- PartialEq, PartialOrd,
+ assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
+ format_args_nl, include, include_bytes, include_str, line, llvm_asm, log_syntax, module_path,
+ option_env, stringify, trace_macros, Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq,
+ PartialOrd,
};
+#[unstable(
+ feature = "asm",
+ issue = "72016",
+ reason = "inline assembly is not stable enough for use and is subject to change"
+)]
+#[doc(no_inline)]
+pub use core::prelude::v1::asm;
+
+#[unstable(
+ feature = "global_asm",
+ issue = "35119",
+ reason = "`global_asm!` is not stable enough for use and is subject to change"
+)]
+#[doc(no_inline)]
+pub use core::prelude::v1::global_asm;
+
// FIXME: Attribute and internal derive macros are not documented because for them rustdoc generates
// dead links which fail link checker testing.
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
diff --git a/library/std/src/sys/unix/args.rs b/library/std/src/sys/unix/args.rs
index fc423e393d4a4..ad93fa610c481 100644
--- a/library/std/src/sys/unix/args.rs
+++ b/library/std/src/sys/unix/args.rs
@@ -14,11 +14,6 @@ pub unsafe fn init(argc: isize, argv: *const *const u8) {
imp::init(argc, argv)
}
-/// One-time global cleanup.
-pub unsafe fn cleanup() {
- imp::cleanup()
-}
-
/// Returns the command line arguments
pub fn args() -> Args {
imp::args()
@@ -82,16 +77,10 @@ mod imp {
use crate::ptr;
use crate::sync::atomic::{AtomicIsize, AtomicPtr, Ordering};
- use crate::sys_common::mutex::StaticMutex;
-
static ARGC: AtomicIsize = AtomicIsize::new(0);
static ARGV: AtomicPtr<*const u8> = AtomicPtr::new(ptr::null_mut());
- // We never call `ENV_LOCK.init()`, so it is UB to attempt to
- // acquire this mutex reentrantly!
- static LOCK: StaticMutex = StaticMutex::new();
unsafe fn really_init(argc: isize, argv: *const *const u8) {
- let _guard = LOCK.lock();
ARGC.store(argc, Ordering::Relaxed);
ARGV.store(argv as *mut _, Ordering::Relaxed);
}
@@ -127,21 +116,16 @@ mod imp {
init_wrapper
};
- pub unsafe fn cleanup() {
- let _guard = LOCK.lock();
- ARGC.store(0, Ordering::Relaxed);
- ARGV.store(ptr::null_mut(), Ordering::Relaxed);
- }
-
pub fn args() -> Args {
Args { iter: clone().into_iter() }
}
fn clone() -> Vec {
unsafe {
- let _guard = LOCK.lock();
- let argc = ARGC.load(Ordering::Relaxed);
+ // Load ARGC and ARGV without a lock. If the store to either ARGV or
+ // ARGC isn't visible yet, we'll return an empty argument list.
let argv = ARGV.load(Ordering::Relaxed);
+ let argc = if argv.is_null() { 0 } else { ARGC.load(Ordering::Relaxed) };
(0..argc)
.map(|i| {
let cstr = CStr::from_ptr(*argv.offset(i) as *const libc::c_char);
@@ -159,8 +143,6 @@ mod imp {
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {}
- pub fn cleanup() {}
-
#[cfg(target_os = "macos")]
pub fn args() -> Args {
use crate::os::unix::prelude::*;
diff --git a/library/std/src/sys/unix/mod.rs b/library/std/src/sys/unix/mod.rs
index 2da71b2a448ac..9e553ec7682b1 100644
--- a/library/std/src/sys/unix/mod.rs
+++ b/library/std/src/sys/unix/mod.rs
@@ -123,7 +123,6 @@ pub unsafe fn init(argc: isize, argv: *const *const u8) {
// SAFETY: must be called only once during runtime cleanup.
// NOTE: this is not guaranteed to run, for example when the program aborts.
pub unsafe fn cleanup() {
- args::cleanup();
stack_overflow::cleanup();
}
diff --git a/src/doc/rustdoc/src/command-line-arguments.md b/src/doc/rustdoc/src/command-line-arguments.md
index 2e4016e24bc3f..c8af369a9695e 100644
--- a/src/doc/rustdoc/src/command-line-arguments.md
+++ b/src/doc/rustdoc/src/command-line-arguments.md
@@ -417,3 +417,10 @@ This flag is **deprecated** and **has no effect**.
Rustdoc only supports Rust source code and Markdown input formats. If the
file ends in `.md` or `.markdown`, `rustdoc` treats it as a Markdown file.
Otherwise, it assumes that the input file is Rust.
+
+## `--nocapture`
+
+When this flag is used with `--test`, the output (stdout and stderr) of your tests won't be
+captured by rustdoc. Instead, the output will be directed to your terminal,
+as if you had run the test executable manually. This is especially useful
+for debugging your tests!
diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs
index 4cf647a81ae4b..adbdde0d92cd6 100644
--- a/src/librustdoc/config.rs
+++ b/src/librustdoc/config.rs
@@ -156,6 +156,8 @@ crate struct Options {
crate run_check: bool,
/// Whether doctests should emit unused externs
crate json_unused_externs: bool,
+ /// Whether to skip capturing stdout and stderr of tests.
+ crate nocapture: bool,
}
impl fmt::Debug for Options {
@@ -199,6 +201,7 @@ impl fmt::Debug for Options {
.field("enable-per-target-ignores", &self.enable_per_target_ignores)
.field("run_check", &self.run_check)
.field("no_run", &self.no_run)
+ .field("nocapture", &self.nocapture)
.finish()
}
}
@@ -627,6 +630,7 @@ impl Options {
let run_check = matches.opt_present("check");
let generate_redirect_map = matches.opt_present("generate-redirect-map");
let show_type_layout = matches.opt_present("show-type-layout");
+ let nocapture = matches.opt_present("nocapture");
let (lint_opts, describe_lints, lint_cap, _) =
get_cmd_lint_options(matches, error_format, &debugging_opts);
@@ -665,6 +669,7 @@ impl Options {
test_builder,
run_check,
no_run,
+ nocapture,
render_options: RenderOptions {
output,
external_html,
diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs
index c5ca396e72029..5ce7c49278d23 100644
--- a/src/librustdoc/doctest.rs
+++ b/src/librustdoc/doctest.rs
@@ -107,6 +107,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
let mut test_args = options.test_args.clone();
let display_warnings = options.display_warnings;
+ let nocapture = options.nocapture;
let externs = options.externs.clone();
let json_unused_externs = options.json_unused_externs;
@@ -166,6 +167,9 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
};
test_args.insert(0, "rustdoctest".to_string());
+ if nocapture {
+ test_args.push("--nocapture".to_string());
+ }
test::test_main(&test_args, tests, Some(test::Options::new().display_output(display_warnings)));
@@ -456,7 +460,16 @@ fn run_test(
cmd.current_dir(run_directory);
}
- match cmd.output() {
+ let result = if options.nocapture {
+ cmd.status().map(|status| process::Output {
+ status,
+ stdout: Vec::new(),
+ stderr: Vec::new(),
+ })
+ } else {
+ cmd.output()
+ };
+ match result {
Err(e) => return Err(TestFailure::ExecutionError(e)),
Ok(out) => {
if should_panic && out.status.success() {
diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs
index 61057ff515b16..b6c3220901f06 100644
--- a/src/librustdoc/html/render/context.rs
+++ b/src/librustdoc/html/render/context.rs
@@ -539,7 +539,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
};
let sidebar = if let Some(ref version) = self.cache.crate_version {
format!(
- "Crate {}
\
+ "Crate {}
\
\
@@ -567,7 +567,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
page.root_path = "./";
let mut style_files = self.shared.style_files.clone();
- let sidebar = "Settings
";
+ let sidebar = "Settings
";
style_files.push(StylePath { path: PathBuf::from("settings.css"), disabled: false });
let v = layout::render(
&self.shared.templates,
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index 7de023cabeff5..68c59612ccc44 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -1654,7 +1654,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
{
write!(
buffer,
- "{}{}
",
+ "{}{}
",
match *it.kind {
clean::StructItem(..) => "Struct ",
clean::TraitItem(..) => "Trait ",
@@ -1718,7 +1718,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
// to navigate the documentation (though slightly inefficiently).
if !it.is_mod() {
- buffer.write_str("Other items in
");
+ buffer.write_str("
Other items in
");
for (i, name) in cx.current.iter().take(parentlen).enumerate() {
if i > 0 {
buffer.write_str("::");
@@ -1730,7 +1730,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
*name
);
}
- buffer.write_str("
");
+ buffer.write_str("");
}
// Sidebar refers to the enclosing module, not this module.
@@ -1841,7 +1841,7 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
ret.sort();
out.push_str(
- "\
+ "\