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 10 pull requests #82941

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5fe84c8
always eagerly eval consts in Relate
lcnr Jan 23, 2021
2beea2c
add test for lazy norm err
lcnr Jan 23, 2021
3e305f6
Deprecate items that accidentally weren't deprecated
bstrie Feb 14, 2021
ec20993
Stabilize `unsafe_op_in_unsafe_fn` lint
LeSeulArtichaut Nov 19, 2020
fbd575a
process::unix: Handle other wait statuses in ExitStatus as Display
ijackson Feb 22, 2021
d8cfd56
process::unix: Test wait status formatting
ijackson Feb 22, 2021
4bb8425
ExitStatus: Improve documentation re wait status vs exit status
ijackson Feb 22, 2021
67cfc22
ExitStatus stop signal display test: Make it Linux only
ijackson Mar 4, 2021
a240ff5
ExitStatus unknown wait status test: Make it Linux only
ijackson Mar 4, 2021
8e4433a
ExitStatus tests: Make less legible to satisfy "tidy"
ijackson Mar 4, 2021
a05a890
Build rustdoc for run-make tests, not just run-make-fulldeps
jyn514 Mar 5, 2021
7e3ebe7
Add Option::get_or_default
camsteffen Mar 6, 2021
1cc8c4d
Use Option::get_or_default
camsteffen Mar 6, 2021
50bdd51
:arrow_up: rust-analyzer
lnicola Mar 8, 2021
fdb899b
WASI: Switch to crt1-command.o to enable support for new-style commands
sunfishcode Mar 9, 2021
11ca644
Always compile the fragile wait status test cases, just run them cond…
ijackson Mar 9, 2021
52d9792
Update README.md to use the correct cmake version number
wesleywiser Mar 9, 2021
62f2d72
Bump tracing-tree dependency
oli-obk Mar 9, 2021
0b1958c
Rollup merge of #79208 - LeSeulArtichaut:stable-unsafe_op_in_unsafe_f…
Dylan-DPC Mar 9, 2021
78bda6c
Rollup merge of #81309 - lcnr:lazy-norm-err-msgh, r=nikomatsakis
Dylan-DPC Mar 9, 2021
c769b60
Rollup merge of #82122 - bstrie:dep4real, r=dtolnay
Dylan-DPC Mar 9, 2021
a72181a
Rollup merge of #82411 - ijackson:fix-exitstatus, r=dtolnay
Dylan-DPC Mar 9, 2021
d8c4e2d
Rollup merge of #82802 - jyn514:build-rustdoc-fullmake, r=Mark-Simula…
Dylan-DPC Mar 9, 2021
f0c61c8
Rollup merge of #82849 - camsteffen:option-get-or-default, r=joshtrip…
Dylan-DPC Mar 9, 2021
077dff5
Rollup merge of #82908 - lnicola:rust-analyzer-2021-03-08, r=jonas-sc…
Dylan-DPC Mar 9, 2021
7c3f684
Rollup merge of #82924 - sunfishcode:wasi-command, r=alexcrichton
Dylan-DPC Mar 9, 2021
7ba271f
Rollup merge of #82937 - wesleywiser:update_cmake_version_in_readme, …
Dylan-DPC Mar 9, 2021
de570f7
Rollup merge of #82938 - oli-obk:tracing_tree_bump, r=Mark-Simulacrum
Dylan-DPC Mar 9, 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
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5460,9 +5460,9 @@ dependencies = [

[[package]]
name = "tracing-tree"
version = "0.1.8"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a60657cfbf397c603257a8230b3f427e6a2a4e5911a59331b9bb4dffff5b608"
checksum = "1712b40907f8d9bc2bc66763ab61dec914b7123d7149e59feb0d4e2a95fc4967"
dependencies = [
"ansi_term 0.12.1",
"atty",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ by running `./x.py --help` or reading the [rustc dev guide][rustcguidebuild].
* `g++` 5.1 or later or `clang++` 3.5 or later
* `python` 3 or 2.7
* GNU `make` 3.81 or later
* `cmake` 3.4.3 or later
* `cmake` 3.13.4 or later
* `ninja`
* `curl`
* `git`
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ libc = "0.2"
atty = "0.2"
tracing = { version = "0.1.25" }
tracing-subscriber = { version = "0.2.16", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] }
tracing-tree = "0.1.8"
tracing-tree = "0.1.9"
rustc_middle = { path = "../rustc_middle" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_target = { path = "../rustc_target" }
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ declare_features! (
(accepted, move_ref_pattern, "1.49.0", Some(68354), None),
/// The smallest useful subset of `const_generics`.
(accepted, min_const_generics, "1.51.0", Some(74878), None),
/// The `unsafe_op_in_unsafe_fn` lint (allowed by default): no longer treat an unsafe function as an unsafe block.
(accepted, unsafe_block_in_unsafe_fn, "1.51.0", Some(71668), None),

// -------------------------------------------------------------------------
// feature-group-end: accepted features
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,6 @@ declare_features! (
/// Allows the use of `#[ffi_const]` on foreign functions.
(active, ffi_const, "1.45.0", Some(58328), None),

/// No longer treat an unsafe function as an unsafe block.
(active, unsafe_block_in_unsafe_fn, "1.45.0", Some(71668), None),

/// Allows `extern "avr-interrupt" fn()` and `extern "avr-non-blocking-interrupt" fn()`.
(active, abi_avr_interrupt, "1.45.0", Some(69664), None),

Expand Down
9 changes: 1 addition & 8 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

use crate::{declare_lint, declare_lint_pass};
use rustc_span::edition::Edition;
use rustc_span::symbol::sym;

declare_lint! {
/// The `forbidden_lint_groups` lint detects violations of
Expand Down Expand Up @@ -2489,16 +2488,11 @@ declare_lint! {

declare_lint! {
/// The `unsafe_op_in_unsafe_fn` lint detects unsafe operations in unsafe
/// functions without an explicit unsafe block. This lint only works on
/// the [**nightly channel**] with the
/// `#![feature(unsafe_block_in_unsafe_fn)]` feature.
///
/// [**nightly channel**]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html
/// functions without an explicit unsafe block.
///
/// ### Example
///
/// ```rust,compile_fail
/// #![feature(unsafe_block_in_unsafe_fn)]
/// #![deny(unsafe_op_in_unsafe_fn)]
///
/// unsafe fn foo() {}
Expand Down Expand Up @@ -2536,7 +2530,6 @@ declare_lint! {
pub UNSAFE_OP_IN_UNSAFE_FN,
Allow,
"unsafe operations in unsafe functions without an explicit unsafe block are deprecated",
@feature_gate = sym::unsafe_block_in_unsafe_fn;
}

declare_lint! {
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_middle/src/mir/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ pub enum UnsafetyViolationKind {
BorrowPacked,
/// Unsafe operation in an `unsafe fn` but outside an `unsafe` block.
/// Has to be handled as a lint for backwards compatibility.
/// Should stay gated under `#![feature(unsafe_block_in_unsafe_fn)]`.
UnsafeFn,
/// Borrow of packed field in an `unsafe fn` but outside an `unsafe` block.
/// Has to be handled as a lint for backwards compatibility.
/// Should stay gated under `#![feature(unsafe_block_in_unsafe_fn)]`.
UnsafeFnBorrowPacked,
}

Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_middle/src/ty/relate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,14 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>(
let t = relation.relate(a_t, b_t)?;
match relation.relate(sz_a, sz_b) {
Ok(sz) => Ok(tcx.mk_ty(ty::Array(t, sz))),
// FIXME(#72219) Implement improved diagnostics for mismatched array
// length?
Err(err) if relation.tcx().lazy_normalization() => Err(err),
Err(err) => {
// Check whether the lengths are both concrete/known values,
// but are unequal, for better diagnostics.
//
// It might seem dubious to eagerly evaluate these constants here,
// we however cannot end up with errors in `Relate` during both
// `type_of` and `predicates_of`. This means that evaluating the
// constants should not cause cycle errors here.
let sz_a = sz_a.try_eval_usize(tcx, relation.param_env());
let sz_b = sz_b.try_eval_usize(tcx, relation.param_env());
match (sz_a, sz_b) {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_mir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Rust MIR: a lowered representation of Rust.
#![feature(stmt_expr_attributes)]
#![feature(trait_alias)]
#![feature(option_expect_none)]
#![feature(option_get_or_default)]
#![feature(or_patterns)]
#![feature(once_cell)]
#![feature(control_flow_enum)]
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_mir/src/transform/check_unsafety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
false
}
// With the RFC 2585, no longer allow `unsafe` operations in `unsafe fn`s
Safety::FnUnsafe if self.tcx.features().unsafe_block_in_unsafe_fn => {
Safety::FnUnsafe => {
for violation in violations {
let mut violation = *violation;

Expand All @@ -355,8 +355,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
}
false
}
// `unsafe` function bodies allow unsafe without additional unsafe blocks (before RFC 2585)
Safety::BuiltinUnsafe | Safety::FnUnsafe => true,
Safety::BuiltinUnsafe => true,
Safety::ExplicitUnsafe(hir_id) => {
// mark unsafe block as used if there are any unsafe operations inside
if !violations.is_empty() {
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_mir/src/transform/coverage/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,7 @@ impl BasicCoverageBlockData {
}
}
let operand = counter_kind.as_operand_id();
if let Some(replaced) = self
.edge_from_bcbs
.get_or_insert_with(FxHashMap::default)
.insert(from_bcb, counter_kind)
if let Some(replaced) = self.edge_from_bcbs.get_or_default().insert(from_bcb, counter_kind)
{
Error::from_string(format!(
"attempt to set an edge counter more than once; from_bcb: \
Expand Down
10 changes: 6 additions & 4 deletions compiler/rustc_target/src/spec/crt_objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,13 @@ pub(super) fn post_mingw() -> CrtObjects {
}

pub(super) fn pre_wasi_fallback() -> CrtObjects {
// Use crt1-command.o instead of crt1.o to enable support for new-style
// commands. See https://reviews.llvm.org/D81689 for more info.
new(&[
(LinkOutputKind::DynamicNoPicExe, &["crt1.o"]),
(LinkOutputKind::DynamicPicExe, &["crt1.o"]),
(LinkOutputKind::StaticNoPicExe, &["crt1.o"]),
(LinkOutputKind::StaticPicExe, &["crt1.o"]),
(LinkOutputKind::DynamicNoPicExe, &["crt1-command.o"]),
(LinkOutputKind::DynamicPicExe, &["crt1-command.o"]),
(LinkOutputKind::StaticNoPicExe, &["crt1-command.o"]),
(LinkOutputKind::StaticPicExe, &["crt1-command.o"]),
(LinkOutputKind::WasiReactorExe, &["crt1-reactor.o"]),
])
}
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
#![feature(trusted_len)]
#![feature(unboxed_closures)]
#![feature(unicode_internals)]
#![feature(unsafe_block_in_unsafe_fn)]
#![cfg_attr(bootstrap, feature(unsafe_block_in_unsafe_fn))]
#![feature(unsize)]
#![feature(unsized_fn_params)]
#![feature(allocator_internals)]
Expand Down
8 changes: 6 additions & 2 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ use crate::sync::atomic::{self, AtomicBool, AtomicI32, AtomicIsize, AtomicU32, O
#[stable(feature = "drop_in_place", since = "1.8.0")]
#[rustc_deprecated(
reason = "no longer an intrinsic - use `ptr::drop_in_place` directly",
since = "1.18.0"
since = "1.52.0"
)]
pub use crate::ptr::drop_in_place;
#[inline]
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
// SAFETY: see `ptr::drop_in_place`
unsafe { crate::ptr::drop_in_place(to_drop) }
}

extern "rust-intrinsic" {
// N.B., these intrinsics take raw pointers because they mutate aliased
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@
#![feature(const_caller_location)]
#![feature(slice_ptr_get)]
#![feature(no_niche)] // rust-lang/rust#68303
#![feature(unsafe_block_in_unsafe_fn)]
#![feature(int_error_matching)]
#![cfg_attr(bootstrap, feature(unsafe_block_in_unsafe_fn))]
#![deny(unsafe_op_in_unsafe_fn)]

#[prelude_import]
Expand Down
28 changes: 28 additions & 0 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,34 @@ impl<T> Option<T> {
// Entry-like operations to insert if None and return a reference
/////////////////////////////////////////////////////////////////////////

/// Inserts the default value into the option if it is [`None`], then
/// returns a mutable reference to the contained value.
///
/// # Examples
///
/// ```
/// #![feature(option_get_or_default)]
///
/// let mut x = None;
///
/// {
/// let y: &mut u32 = x.get_or_default();
/// assert_eq!(y, &0);
///
/// *y = 7;
/// }
///
/// assert_eq!(x, Some(7));
/// ```
#[inline]
#[unstable(feature = "option_get_or_default", issue = "82901")]
pub fn get_or_default(&mut self) -> &mut T
where
T: Default,
{
self.get_or_insert_with(Default::default)
}

/// Inserts `value` into the option if it is [`None`], then
/// returns a mutable reference to the contained value.
///
Expand Down
4 changes: 2 additions & 2 deletions library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@
#![feature(peekable_peek_mut)]
#![cfg_attr(not(bootstrap), feature(ptr_metadata))]
#![feature(once_cell)]
#![feature(unsafe_block_in_unsafe_fn)]
#![feature(unsized_tuple_coercion)]
#![feature(int_bits_const)]
#![feature(nonzero_leading_trailing_zeros)]
#![feature(const_option)]
#![feature(integer_atomics)]
#![feature(slice_group_by)]
#![feature(trusted_random_access)]
#![deny(unsafe_op_in_unsafe_fn)]
#![cfg_attr(bootstrap, feature(unsafe_block_in_unsafe_fn))]
#![cfg_attr(not(bootstrap), feature(unsize))]
#![deny(unsafe_op_in_unsafe_fn)]

extern crate test;

Expand Down
5 changes: 3 additions & 2 deletions library/std/src/collections/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,10 @@
#![stable(feature = "rust1", since = "1.0.0")]

#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(reason = "moved to `std::ops::Bound`", since = "1.26.0")]
#[rustc_deprecated(reason = "moved to `std::ops::Bound`", since = "1.52.0")]
#[doc(hidden)]
pub use crate::ops::Bound;
pub type Bound<T> = crate::ops::Bound<T>;

#[stable(feature = "rust1", since = "1.0.0")]
pub use alloc_crate::collections::{binary_heap, btree_map, btree_set};
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@
#![feature(try_blocks)]
#![feature(try_reserve)]
#![feature(unboxed_closures)]
#![feature(unsafe_block_in_unsafe_fn)]
#![cfg_attr(bootstrap, feature(unsafe_block_in_unsafe_fn))]
#![feature(unsafe_cell_raw_get)]
#![feature(unwind_attributes)]
#![feature(vec_into_raw_parts)]
Expand Down
25 changes: 18 additions & 7 deletions library/std/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ impl Command {
}

/// Executes a command as a child process, waiting for it to finish and
/// collecting its exit status.
/// collecting its status.
///
/// By default, stdin, stdout and stderr are inherited from the parent.
///
Expand All @@ -899,7 +899,7 @@ impl Command {
/// .status()
/// .expect("failed to execute process");
///
/// println!("process exited with: {}", status);
/// println!("process finished with: {}", status);
///
/// assert!(status.success());
/// ```
Expand Down Expand Up @@ -1368,11 +1368,17 @@ impl From<fs::File> for Stdio {

/// Describes the result of a process after it has terminated.
///
/// This `struct` is used to represent the exit status of a child process.
/// This `struct` is used to represent the exit status or other termination of a child process.
/// Child processes are created via the [`Command`] struct and their exit
/// status is exposed through the [`status`] method, or the [`wait`] method
/// of a [`Child`] process.
///
/// An `ExitStatus` represents every possible disposition of a process. On Unix this
/// is the **wait status**. It is *not* simply an *exit status* (a value passed to `exit`).
///
/// For proper error reporting of failed processes, print the value of `ExitStatus` using its
/// implementation of [`Display`](crate::fmt::Display).
///
/// [`status`]: Command::status
/// [`wait`]: Child::wait
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
Expand Down Expand Up @@ -1400,7 +1406,7 @@ impl ExitStatus {
/// if status.success() {
/// println!("'projects/' directory created");
/// } else {
/// println!("failed to create 'projects/' directory");
/// println!("failed to create 'projects/' directory: {}", status);
/// }
/// ```
#[stable(feature = "process", since = "1.0.0")]
Expand All @@ -1410,9 +1416,14 @@ impl ExitStatus {

/// Returns the exit code of the process, if any.
///
/// On Unix, this will return `None` if the process was terminated
/// by a signal; `std::os::unix` provides an extension trait for
/// extracting the signal and other details from the `ExitStatus`.
/// In Unix terms the return value is the **exit status**: the value passed to `exit`, if the
/// process finished by calling `exit`. Note that on Unix the exit status is truncated to 8
/// bits, and that values that didn't come from a program's call to `exit` may be invented the
/// runtime system (often, for example, 255, 254, 127 or 126).
///
/// On Unix, this will return `None` if the process was terminated by a signal.
/// [`ExitStatusExt`](crate::os::unix::process::ExitStatusExt) is an
/// extension trait for extracting any such signal, and other details, from the `ExitStatus`.
///
/// # Examples
///
Expand Down
14 changes: 12 additions & 2 deletions library/std/src/sys/unix/ext/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,20 @@ impl CommandExt for process::Command {

/// Unix-specific extensions to [`process::ExitStatus`].
///
/// On Unix, `ExitStatus` **does not necessarily represent an exit status**, as passed to the
/// `exit` system call or returned by [`ExitStatus::code()`](crate::process::ExitStatus::code).
/// It represents **any wait status**, as returned by one of the `wait` family of system calls.
///
/// This is because a Unix wait status (a Rust `ExitStatus`) can represent a Unix exit status, but
/// can also represent other kinds of process event.
///
/// This trait is sealed: it cannot be implemented outside the standard library.
/// This is so that future additional methods are not breaking changes.
#[stable(feature = "rust1", since = "1.0.0")]
pub trait ExitStatusExt: Sealed {
/// Creates a new `ExitStatus` from the raw underlying `i32` return value of
/// a process.
/// Creates a new `ExitStatus` from the raw underlying integer status value from `wait`
///
/// The value should be a **wait status, not an exit status**.
#[stable(feature = "exit_status_from", since = "1.12.0")]
fn from_raw(raw: i32) -> Self;

Expand Down Expand Up @@ -222,6 +230,8 @@ pub trait ExitStatusExt: Sealed {
fn continued(&self) -> bool;

/// Returns the underlying raw `wait` status.
///
/// The returned integer is a **wait status, not an exit status**.
#[unstable(feature = "unix_process_wait_more", issue = "80695")]
fn into_raw(self) -> i32;
}
Expand Down
Loading