Skip to content

Commit

Permalink
Auto merge of #87269 - GuillaumeGomez:rollup-qukedv0, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Rollup of 8 pull requests

Successful merges:

 - #86230 (Add --nocapture option to rustdoc)
 - #87210 (Rustdoc accessibility: make the sidebar headers actual headers)
 - #87227 (Move asm! and global_asm! to core::arch)
 - #87236 (Simplify command-line argument initialization on unix)
 - #87251 (Fix "item info" width)
 - #87256 (Extend HIR-based WF checking to associated type defaults)
 - #87259 (triagebot shortcut config)
 - #87268 (Don't create references to uninitialized data in `List::from_arena`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Jul 19, 2021
2 parents 83f0822 + 6cb69ea commit 8df945c
Show file tree
Hide file tree
Showing 35 changed files with 239 additions and 126 deletions.
12 changes: 6 additions & 6 deletions compiler/rustc_middle/src/ty/list.rs
Expand Up @@ -63,17 +63,17 @@ impl<T: Copy> List<T> {

let (layout, _offset) =
Layout::new::<usize>().extend(Layout::for_value::<[T]>(slice)).unwrap();
let mem = arena.dropless.alloc_raw(layout);
let mem = arena.dropless.alloc_raw(layout) as *mut List<T>;
unsafe {
let result = &mut *(mem as *mut List<T>);
// 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::<T>()
.copy_from_nonoverlapping(slice.as_ptr(), slice.len());

result
&mut *mem
}
}

Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_typeck/src/hir_wf_check.rs
Expand Up @@ -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,
Expand Down
32 changes: 31 additions & 1 deletion library/core/src/lib.rs
Expand Up @@ -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 */
}
}
38 changes: 0 additions & 38 deletions library/core/src/macros/mod.rs
Expand Up @@ -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.
Expand All @@ -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",
Expand Down
22 changes: 19 additions & 3 deletions library/core/src/prelude/v1.rs
Expand Up @@ -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)]
Expand Down
6 changes: 3 additions & 3 deletions library/std/src/lib.rs
Expand Up @@ -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")]
Expand Down
24 changes: 20 additions & 4 deletions library/std/src/prelude/v1.rs
Expand Up @@ -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")]
Expand Down
24 changes: 3 additions & 21 deletions library/std/src/sys/unix/args.rs
Expand Up @@ -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()
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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<OsString> {
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);
Expand All @@ -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::*;
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/unix/mod.rs
Expand Up @@ -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();
}

Expand Down
7 changes: 7 additions & 0 deletions src/doc/rustdoc/src/command-line-arguments.md
Expand Up @@ -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!
5 changes: 5 additions & 0 deletions src/librustdoc/config.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
}
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -665,6 +669,7 @@ impl Options {
test_builder,
run_check,
no_run,
nocapture,
render_options: RenderOptions {
output,
external_html,
Expand Down
15 changes: 14 additions & 1 deletion src/librustdoc/doctest.rs
Expand Up @@ -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;

Expand Down Expand Up @@ -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)));

Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/render/context.rs
Expand Up @@ -539,7 +539,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
};
let sidebar = if let Some(ref version) = self.cache.crate_version {
format!(
"<p class=\"location\">Crate {}</p>\
"<h2 class=\"location\">Crate {}</h2>\
<div class=\"block version\">\
<p>Version {}</p>\
</div>\
Expand Down Expand Up @@ -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 = "<p class=\"location\">Settings</p><div class=\"sidebar-elems\"></div>";
let sidebar = "<h2 class=\"location\">Settings</h2><div class=\"sidebar-elems\"></div>";
style_files.push(StylePath { path: PathBuf::from("settings.css"), disabled: false });
let v = layout::render(
&self.shared.templates,
Expand Down

0 comments on commit 8df945c

Please sign in to comment.