Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #87269

Merged
merged 26 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
30d49a4
Rustdoc accessibility: make the sidebar headers actual headers
notriddle Jul 17, 2021
ee97b4a
Remove redundant CSS
notriddle Jul 17, 2021
10bdc42
Fix test cases for header titles in sidebar
notriddle Jul 17, 2021
1941764
Fix sidebar-mobile test to focus on an actual focusable element
notriddle Jul 17, 2021
46010c4
Remove args cleanup code.
sunfishcode Jul 17, 2021
9bb11ba
Remove an unnecessary `Mutex` around argument initialization.
sunfishcode Jul 17, 2021
c3df0ae
x.py fmt
sunfishcode Jul 18, 2021
6ca0e5e
Add --nocapture option to rustdoc
GuillaumeGomez Jun 11, 2021
111cca1
Add test for rustdoc --nocapture option
GuillaumeGomez Jun 11, 2021
893e07e
Add doc for --nocapture
GuillaumeGomez Jun 11, 2021
6461cde
Don't capture child process output at all when --no-capture is used
GuillaumeGomez Jul 9, 2021
d5e3294
Add invalid rust code for test
GuillaumeGomez Jul 9, 2021
d10703c
Fix item info display
GuillaumeGomez Jul 18, 2021
57f7501
Add test to check width of item-info
GuillaumeGomez Jul 18, 2021
93aa890
Extend HIR-based WF checking to associated type defaults
Aaron1011 Jul 18, 2021
33a8e9f
triagebot shortcut config
Llandy3d Jul 18, 2021
f26fbe2
Move asm! and global_asm! to core::arch
bstrie Jul 17, 2021
98e9d16
Don't create references to uninitialized data in List::from_arena
SkiFire13 Jul 19, 2021
0fce468
Rollup merge of #86230 - GuillaumeGomez:nocapture, r=camelid
GuillaumeGomez Jul 19, 2021
456ebd3
Rollup merge of #87210 - notriddle:notriddle/rustdoc-sidebar-headers,…
GuillaumeGomez Jul 19, 2021
65b7aa9
Rollup merge of #87227 - bstrie:asm2arch, r=Amanieu
GuillaumeGomez Jul 19, 2021
6df9df7
Rollup merge of #87236 - sunfishcode:avoid-locking-args, r=joshtriplett
GuillaumeGomez Jul 19, 2021
8cf995f
Rollup merge of #87251 - GuillaumeGomez:item-info-width, r=notriddle
GuillaumeGomez Jul 19, 2021
4dd32a1
Rollup merge of #87256 - Aaron1011:hir-wf-assoc-default, r=oli-obk
GuillaumeGomez Jul 19, 2021
5ef6439
Rollup merge of #87259 - Llandy3d:triagebot_shortcuts, r=nikomatsakis
GuillaumeGomez Jul 19, 2021
6cb69ea
Rollup merge of #87268 - SkiFire13:fix-uninit-ref-list, r=nagisa
GuillaumeGomez Jul 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions compiler/rustc_middle/src/ty/list.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading