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 11 pull requests #82939

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 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
1ab9fe5
Add {core,std}::prelude::{rust_2015,rust_2018,rust_2021}.
m-ou-se Feb 17, 2021
d3b564c
Pick the injected prelude based on the edition.
m-ou-se Feb 17, 2021
218cf30
Update test output for edition preludes.
m-ou-se Feb 17, 2021
d274d87
Update test/pretty output for edition preludes.
m-ou-se Feb 17, 2021
76fd8d7
Use intra-doc links.
m-ou-se Feb 25, 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
d157bdb
Rollup merge of #79208 - LeSeulArtichaut:stable-unsafe_op_in_unsafe_f…
Dylan-DPC Mar 9, 2021
cdd401a
Rollup merge of #81309 - lcnr:lazy-norm-err-msgh, r=nikomatsakis
Dylan-DPC Mar 9, 2021
517a099
Rollup merge of #82122 - bstrie:dep4real, r=dtolnay
Dylan-DPC Mar 9, 2021
82cc64b
Rollup merge of #82217 - m-ou-se:edition-prelude, r=nikomatsakis
Dylan-DPC Mar 9, 2021
f5b1793
Rollup merge of #82411 - ijackson:fix-exitstatus, r=dtolnay
Dylan-DPC Mar 9, 2021
16e14ce
Rollup merge of #82802 - jyn514:build-rustdoc-fullmake, r=Mark-Simula…
Dylan-DPC Mar 9, 2021
79efa62
Rollup merge of #82849 - camsteffen:option-get-or-default, r=joshtrip…
Dylan-DPC Mar 9, 2021
56853a9
Rollup merge of #82908 - lnicola:rust-analyzer-2021-03-08, r=jonas-sc…
Dylan-DPC Mar 9, 2021
5b82736
Rollup merge of #82924 - sunfishcode:wasi-command, r=alexcrichton
Dylan-DPC Mar 9, 2021
5874d9f
Rollup merge of #82937 - wesleywiser:update_cmake_version_in_readme, …
Dylan-DPC Mar 9, 2021
e6a156f
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
30 changes: 19 additions & 11 deletions compiler/rustc_builtin_macros/src/standard_library_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rustc_ast as ast;
use rustc_expand::base::{ExtCtxt, ResolverExpand};
use rustc_expand::expand::ExpansionConfig;
use rustc_session::Session;
use rustc_span::edition::Edition;
use rustc_span::edition::Edition::*;
use rustc_span::hygiene::AstPass;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::DUMMY_SP;
Expand All @@ -13,7 +13,7 @@ pub fn inject(
sess: &Session,
alt_std_name: Option<Symbol>,
) -> ast::Crate {
let rust_2018 = sess.parse_sess.edition >= Edition::Edition2018;
let edition = sess.parse_sess.edition;

// the first name in this list is the crate name of the crate with the prelude
let names: &[Symbol] = if sess.contains_name(&krate.attrs, sym::no_core) {
Expand Down Expand Up @@ -42,7 +42,11 @@ pub fn inject(

// .rev() to preserve ordering above in combination with insert(0, ...)
for &name in names.iter().rev() {
let ident = if rust_2018 { Ident::new(name, span) } else { Ident::new(name, call_site) };
let ident = if edition >= Edition2018 {
Ident::new(name, span)
} else {
Ident::new(name, call_site)
};
krate.items.insert(
0,
cx.item(
Expand All @@ -58,14 +62,18 @@ pub fn inject(
// the one with the prelude.
let name = names[0];

let import_path = if rust_2018 {
[name, sym::prelude, sym::v1].iter().map(|symbol| Ident::new(*symbol, span)).collect()
} else {
[kw::PathRoot, name, sym::prelude, sym::v1]
.iter()
.map(|symbol| Ident::new(*symbol, span))
.collect()
};
let root = (edition == Edition2015).then(|| kw::PathRoot);

let import_path = root
.iter()
.chain(&[name, sym::prelude])
.chain(&[match edition {
Edition2015 => sym::rust_2015,
Edition2018 => sym::rust_2018,
Edition2021 => sym::rust_2021,
}])
.map(|&symbol| Ident::new(symbol, span))
.collect();

let use_item = cx.item(
span,
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
3 changes: 3 additions & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,8 +958,11 @@ symbols! {
rt,
rtm_target_feature,
rust,
rust_2015,
rust_2015_preview,
rust_2018,
rust_2018_preview,
rust_2021,
rust_2021_preview,
rust_begin_unwind,
rust_eh_catch_typeinfo,
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
36 changes: 36 additions & 0 deletions library/core/src/prelude/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
//! The libcore prelude
//!
//! This module is intended for users of libcore which do not link to libstd as
//! well. This module is imported by default when `#![no_std]` is used in the
//! same manner as the standard library's prelude.

#![stable(feature = "core_prelude", since = "1.4.0")]

pub mod v1;

/// The 2015 version of the core prelude.
///
/// See the [module-level documentation](self) for more.
#[unstable(feature = "prelude_2015", issue = "none")]
pub mod rust_2015 {
#[unstable(feature = "prelude_2015", issue = "none")]
#[doc(no_inline)]
pub use super::v1::*;
}

/// The 2018 version of the core prelude.
///
/// See the [module-level documentation](self) for more.
#[unstable(feature = "prelude_2018", issue = "none")]
pub mod rust_2018 {
#[unstable(feature = "prelude_2018", issue = "none")]
#[doc(no_inline)]
pub use super::v1::*;
}

/// The 2021 version of the core prelude.
///
/// See the [module-level documentation](self) for more.
#[unstable(feature = "prelude_2021", issue = "none")]
pub mod rust_2021 {
#[unstable(feature = "prelude_2021", issue = "none")]
#[doc(no_inline)]
pub use super::v1::*;

// FIXME: Add more things.
}
6 changes: 2 additions & 4 deletions library/core/src/prelude/v1.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! The core prelude
//! The first version of the core prelude.
//!
//! This module is intended for users of libcore which do not link to libstd as
//! well. This module is imported by default when `#![no_std]` is used in the
//! same manner as the standard library's prelude.
//! See the [module-level documentation](super) for more.

#![stable(feature = "core_prelude", since = "1.4.0")]

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
Loading