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 9 pull requests #79252

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
60c85f1
Add exploit mitigations chapter to the rustc book
rcvalle Sep 18, 2020
9b45292
Remove reference to specific rustc version
rcvalle Sep 21, 2020
a9f7e1b
Remove additional historical information
rcvalle Sep 21, 2020
6a38a63
Clarify implementations will be available
rcvalle Sep 21, 2020
344d835
Remove mention of disabling features
rcvalle Sep 21, 2020
9e1e73d
Add software name to figure captions
rcvalle Sep 23, 2020
2b9e505
Add target audience and prior knowledge
rcvalle Sep 29, 2020
dc5745d
Fix documentation tests
rcvalle Sep 30, 2020
3b5aa44
Remove additional mention of disabling features
rcvalle Sep 30, 2020
78a4656
Add changes from additional copy editing
rcvalle Sep 30, 2020
410fc0e
Do not provide suggestions for non standard characters
JohnTitor Oct 10, 2020
c555aab
clarify rules for ZST Boxes
RalfJung Oct 12, 2020
0f572a9
explicitly talk about integer literals
RalfJung Oct 13, 2020
28df283
Add paragraph about not discussing effectiveness
rcvalle Oct 15, 2020
d977464
Rephrase paragraph about ARM MTE
rcvalle Oct 15, 2020
9999616
Remove deadwood from sentence
rcvalle Oct 30, 2020
5f08568
x.py: allow a custom string appended to the version
cuviper Nov 16, 2020
a7677f7
reference NonNull::dangling
RalfJung Nov 20, 2020
a64d0d4
Add `core::slice::fill_with`
yoshuawuyts Nov 20, 2020
993bb07
rustc_expand: Mark inner `#![test]` attributes as soft-unstable
petrochenkov Nov 12, 2020
5ed2d42
Direct RUSTC_LOG (tracing/log) output to stderr instead of stdout.
eddyb Nov 20, 2020
f99410b
std: Update the backtrace crate submodule
alexcrichton Nov 20, 2020
0f61664
update miri
RalfJung Nov 20, 2020
ce2b2fb
Rollup merge of #76858 - rcvalle:rust-lang-exploit-mitigations, r=ste…
Dylan-DPC Nov 21, 2020
575d3a1
Rollup merge of #77805 - JohnTitor:non-standard-char-sugg, r=Dylan-DPC
Dylan-DPC Nov 21, 2020
9549ff5
Rollup merge of #77844 - RalfJung:zst-box, r=nikomatsakis
Dylan-DPC Nov 21, 2020
2899583
Rollup merge of #79003 - petrochenkov:innertest, r=estebank
Dylan-DPC Nov 21, 2020
642de64
Rollup merge of #79115 - cuviper:rust-description, r=Mark-Simulacrum
Dylan-DPC Nov 21, 2020
7af4939
Rollup merge of #79222 - yoshuawuyts:slice-fill-with, r=m-ou-se
Dylan-DPC Nov 21, 2020
29a2aaf
Rollup merge of #79237 - alexcrichton:update-backtrace, r=Mark-Simula…
Dylan-DPC Nov 21, 2020
64abd99
Rollup merge of #79238 - eddyb:rustc-log-stderr, r=jyn514
Dylan-DPC Nov 21, 2020
4123fb5
Rollup merge of #79250 - RalfJung:miri, r=RalfJung
Dylan-DPC Nov 21, 2020
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
26 changes: 10 additions & 16 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# It is not intended for manual editing.
[[package]]
name = "addr2line"
version = "0.13.0"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072"
checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423"
dependencies = [
"compiler_builtins",
"gimli",
Expand Down Expand Up @@ -132,13 +132,13 @@ checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"

[[package]]
name = "backtrace"
version = "0.3.53"
version = "0.3.55"
dependencies = [
"addr2line",
"cfg-if 1.0.0",
"libc",
"miniz_oxide",
"object 0.21.1",
"object",
"rustc-demangle",
]

Expand Down Expand Up @@ -1292,9 +1292,9 @@ dependencies = [

[[package]]
name = "gimli"
version = "0.22.0"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724"
checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-alloc",
Expand Down Expand Up @@ -2181,21 +2181,15 @@ dependencies = [

[[package]]
name = "object"
version = "0.20.0"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"
checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-alloc",
"rustc-std-workspace-core",
]

[[package]]
name = "object"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693"

[[package]]
name = "once_cell"
version = "1.4.1"
Expand Down Expand Up @@ -4668,7 +4662,7 @@ dependencies = [
"hermit-abi",
"libc",
"miniz_oxide",
"object 0.20.0",
"object",
"panic_abort",
"panic_unwind",
"profiler_builtins",
Expand Down Expand Up @@ -5262,7 +5256,7 @@ dependencies = [
"chrono",
"lazy_static",
"matchers",
"parking_lot 0.9.0",
"parking_lot 0.11.0",
"regex",
"serde",
"serde_json",
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,7 @@ pub fn init_env_logger(env: &str) {
}
let filter = tracing_subscriber::EnvFilter::from_env(env);
let layer = tracing_tree::HierarchicalLayer::default()
.with_writer(io::stderr)
.with_indent_lines(true)
.with_ansi(true)
.with_targets(true)
Expand Down
54 changes: 35 additions & 19 deletions compiler/rustc_lint/src/nonstandard_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,20 @@ impl NonCamelCaseTypes {
if !is_camel_case(name) {
cx.struct_span_lint(NON_CAMEL_CASE_TYPES, ident.span, |lint| {
let msg = format!("{} `{}` should have an upper camel case name", sort, name);
lint.build(&msg)
.span_suggestion(
let mut err = lint.build(&msg);
let cc = to_camel_case(name);
// We cannot provide meaningful suggestions
// if the characters are in the category of "Lowercase Letter".
if name.to_string() != cc {
err.span_suggestion(
ident.span,
"convert the identifier to upper camel case",
to_camel_case(name),
Applicability::MaybeIncorrect,
)
.emit()
);
}

err.emit();
})
}
}
Expand Down Expand Up @@ -263,17 +269,21 @@ impl NonSnakeCase {
let sc = NonSnakeCase::to_snake_case(name);
let msg = format!("{} `{}` should have a snake case name", sort, name);
let mut err = lint.build(&msg);
// We have a valid span in almost all cases, but we don't have one when linting a crate
// name provided via the command line.
if !ident.span.is_dummy() {
err.span_suggestion(
ident.span,
"convert the identifier to snake case",
sc,
Applicability::MaybeIncorrect,
);
} else {
err.help(&format!("convert the identifier to snake case: `{}`", sc));
// We cannot provide meaningful suggestions
// if the characters are in the category of "Uppercase Letter".
if name.to_string() != sc {
// We have a valid span in almost all cases, but we don't have one when linting a crate
// name provided via the command line.
if !ident.span.is_dummy() {
err.span_suggestion(
ident.span,
"convert the identifier to snake case",
sc,
Applicability::MaybeIncorrect,
);
} else {
err.help(&format!("convert the identifier to snake case: `{}`", sc));
}
}

err.emit();
Expand Down Expand Up @@ -441,14 +451,20 @@ impl NonUpperCaseGlobals {
if name.chars().any(|c| c.is_lowercase()) {
cx.struct_span_lint(NON_UPPER_CASE_GLOBALS, ident.span, |lint| {
let uc = NonSnakeCase::to_snake_case(&name).to_uppercase();
lint.build(&format!("{} `{}` should have an upper case name", sort, name))
.span_suggestion(
let mut err =
lint.build(&format!("{} `{}` should have an upper case name", sort, name));
// We cannot provide meaningful suggestions
// if the characters are in the category of "Lowercase Letter".
if name.to_string() != uc {
err.span_suggestion(
ident.span,
"convert the identifier to upper case",
uc,
Applicability::MaybeIncorrect,
)
.emit();
);
}

err.emit();
})
}
}
Expand Down
29 changes: 14 additions & 15 deletions compiler/rustc_resolve/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use rustc_hir::def::{self, DefKind, NonMacroAttrKind};
use rustc_hir::def_id;
use rustc_middle::middle::stability;
use rustc_middle::ty;
use rustc_session::lint::builtin::UNUSED_MACROS;
use rustc_session::lint::builtin::{SOFT_UNSTABLE, UNUSED_MACROS};
use rustc_session::parse::feature_err;
use rustc_session::Session;
use rustc_span::edition::Edition;
Expand Down Expand Up @@ -459,22 +459,21 @@ impl<'a> Resolver<'a> {
}

// We are trying to avoid reporting this error if other related errors were reported.
if inner_attr
if res != Res::Err
&& inner_attr
&& !self.session.features_untracked().custom_inner_attributes
&& path != &sym::test
&& res != Res::Err
{
feature_err(
&self.session.parse_sess,
sym::custom_inner_attributes,
path.span,
match res {
Res::Def(..) => "inner macro attributes are unstable",
Res::NonMacroAttr(..) => "custom inner attributes are unstable",
_ => unreachable!(),
},
)
.emit();
let msg = match res {
Res::Def(..) => "inner macro attributes are unstable",
Res::NonMacroAttr(..) => "custom inner attributes are unstable",
_ => unreachable!(),
};
if path == &sym::test {
self.session.parse_sess.buffer_lint(SOFT_UNSTABLE, path.span, node_id, msg);
} else {
feature_err(&self.session.parse_sess, sym::custom_inner_attributes, path.span, msg)
.emit();
}
}

Ok((ext, res))
Expand Down
5 changes: 5 additions & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@ changelog-seen = 2
# nightly features
#channel = "dev"

# A descriptive string to be appended to `rustc --version` output, which is
# also used in places like debuginfo `DW_AT_producer`. This may be useful for
# supplementary build information, like distro-specific package versions.
#description = ""

# The root location of the musl installation directory.
#musl-root = "..."

Expand Down
11 changes: 11 additions & 0 deletions library/alloc/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@
//! T` obtained from [`Box::<T>::into_raw`] may be deallocated using the
//! [`Global`] allocator with [`Layout::for_value(&*value)`].
//!
//! For zero-sized values, the `Box` pointer still has to be [valid] for reads
//! and writes and sufficiently aligned. In particular, casting any aligned
//! non-zero integer literal to a raw pointer produces a valid pointer, but a
//! pointer pointing into previously allocated memory that since got freed is
//! not valid. The recommended way to build a Box to a ZST if `Box::new` cannot
//! be used is to use [`ptr::NonNull::dangling`].
//!
//! So long as `T: Sized`, a `Box<T>` is guaranteed to be represented
//! as a single pointer and is also ABI-compatible with C pointers
//! (i.e. the C type `T*`). This means that if you have extern "C"
Expand Down Expand Up @@ -125,6 +132,7 @@
//! [`Global`]: crate::alloc::Global
//! [`Layout`]: crate::alloc::Layout
//! [`Layout::for_value(&*value)`]: crate::alloc::Layout::for_value
//! [valid]: ptr#safety

#![stable(feature = "rust1", since = "1.0.0")]

Expand Down Expand Up @@ -530,7 +538,10 @@ impl<T: ?Sized> Box<T> {
/// memory problems. For example, a double-free may occur if the
/// function is called twice on the same raw pointer.
///
/// The safety conditions are described in the [memory layout] section.
///
/// # Examples
///
/// Recreate a `Box` which was previously converted to a raw pointer
/// using [`Box::into_raw`]:
/// ```
Expand Down
8 changes: 6 additions & 2 deletions library/core/src/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
//! provided at this point are very minimal:
//!
//! * A [null] pointer is *never* valid, not even for accesses of [size zero][zst].
//! * All pointers (except for the null pointer) are valid for all operations of
//! [size zero][zst].
//! * For a pointer to be valid, it is necessary, but not always sufficient, that the pointer
//! be *dereferenceable*: the memory range of the given size starting at the pointer must all be
//! within the bounds of a single allocated object. Note that in Rust,
//! every (stack-allocated) variable is considered a separate allocated object.
//! * Even for operations of [size zero][zst], the pointer must not be pointing to deallocated
//! memory, i.e., deallocation makes pointers invalid even for zero-sized operations. However,
//! casting any non-zero integer *literal* to a pointer is valid for zero-sized accesses, even if
//! some memory happens to exist at that address and gets deallocated. This corresponds to writing
//! your own allocator: allocating zero-sized objects is not very hard. The canonical way to
//! obtain a pointer that is valid for zero-sized accesses is [`NonNull::dangling`].
//! * All accesses performed by functions in this module are *non-atomic* in the sense
//! of [atomic operations] used to synchronize between threads. This means it is
//! undefined behavior to perform two concurrent accesses to the same location from different
Expand Down
28 changes: 28 additions & 0 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2599,6 +2599,34 @@ impl<T> [T] {
}
}

/// Fills `self` with elements returned by calling a closure repeatedly.
///
/// This method uses a closure to create new values. If you'd rather
/// [`Clone`] a given value, use [`fill`]. If you want to use the [`Default`]
/// trait to generate values, you can pass [`Default::default`] as the
/// argument.
///
/// [`fill`]: #method.fill
///
/// # Examples
///
/// ```
/// #![feature(slice_fill_with)]
///
/// let mut buf = vec![1; 10];
/// buf.fill_with(Default::default);
/// assert_eq!(buf, vec![0; 10]);
/// ```
#[unstable(feature = "slice_fill_with", issue = "79221")]
pub fn fill_with<F>(&mut self, mut f: F)
where
F: FnMut() -> T,
{
for el in self {
*el = f();
}
}

/// Copies the elements from `src` into `self`.
///
/// The length of `src` must be the same as `self`.
Expand Down
6 changes: 3 additions & 3 deletions library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ unwind = { path = "../unwind" }
hashbrown = { version = "0.9.0", default-features = false, features = ['rustc-dep-of-std'] }

# Dependencies of the `backtrace` crate
addr2line = { version = "0.13.0", optional = true, default-features = false }
addr2line = { version = "0.14.0", optional = true, default-features = false }
rustc-demangle = { version = "0.1.18", features = ['rustc-dep-of-std'] }
miniz_oxide = { version = "0.4.0", optional = true, default-features = false }
[dependencies.object]
version = "0.20"
version = "0.22"
optional = true
default-features = false
features = ['read_core', 'elf', 'macho', 'pe']
features = ['read_core', 'elf', 'macho', 'pe', 'unaligned', 'archive']

[dev-dependencies]
rand = "0.7"
Expand Down
6 changes: 3 additions & 3 deletions library/std/src/num/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ fn test_checked_mul() {

macro_rules! test_is_power_of_two {
($test_name:ident, $T:ident) => {
#[test]
fn $test_name() {
#![test]
assert_eq!((0 as $T).is_power_of_two(), false);
assert_eq!((1 as $T).is_power_of_two(), true);
assert_eq!((2 as $T).is_power_of_two(), true);
Expand All @@ -96,8 +96,8 @@ test_is_power_of_two! { test_is_power_of_two_uint, usize }

macro_rules! test_next_power_of_two {
($test_name:ident, $T:ident) => {
#[test]
fn $test_name() {
#![test]
assert_eq!((0 as $T).next_power_of_two(), 1);
let mut next_power = 1;
for i in 1 as $T..40 {
Expand All @@ -118,8 +118,8 @@ test_next_power_of_two! { test_next_power_of_two_uint, usize }

macro_rules! test_checked_next_power_of_two {
($test_name:ident, $T:ident) => {
#[test]
fn $test_name() {
#![test]
assert_eq!((0 as $T).checked_next_power_of_two(), Some(1));
let smax = $T::MAX >> 1;
assert_eq!(smax.checked_next_power_of_two(), Some(smax + 1));
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ pub struct Config {
// misc
pub low_priority: bool,
pub channel: String,
pub description: Option<String>,
pub verbose_tests: bool,
pub save_toolstates: Option<PathBuf>,
pub print_step_timings: bool,
Expand Down Expand Up @@ -470,6 +471,7 @@ struct Rust {
parallel_compiler: Option<bool>,
default_linker: Option<String>,
channel: Option<String>,
description: Option<String>,
musl_root: Option<String>,
rpath: Option<bool>,
verbose_tests: Option<bool>,
Expand Down Expand Up @@ -841,6 +843,7 @@ impl Config {
.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind"));
set(&mut config.backtrace, rust.backtrace);
set(&mut config.channel, rust.channel);
config.description = rust.description;
set(&mut config.rust_dist_src, rust.dist_src);
set(&mut config.verbose_tests, rust.verbose_tests);
// in the case "false" is set explicitly, do not overwrite the command line args
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def v(*args):
v("experimental-targets", "llvm.experimental-targets",
"experimental LLVM targets to build")
v("release-channel", "rust.channel", "the name of the release channel to build")
v("release-description", "rust.description", "optional descriptive string for version output")

# Used on systems where "cc" is unavailable
v("default-linker", "rust.default-linker", "the default linker")
Expand Down
Loading