Skip to content

Rollup of 6 pull requests #67388

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

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 src/bootstrap/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ def v(*args):
o("lld", "rust.lld", "build lld")
o("lldb", "rust.lldb", "build lldb")
o("missing-tools", "dist.missing-tools", "allow failures when building tools")
o("use-libcxx", "llvm.use_libcxx", "build LLVM with libc++")
o("use-libcxx", "llvm.use-libcxx", "build LLVM with libc++")

o("cflags", "llvm.cflags", "build LLVM with these extra compiler flags")
o("cxxflags", "llvm.cxxflags", "build LLVM with these extra compiler flags")
o("ldflags", "llvm.ldflags", "build LLVM with these extra linker flags")

o("llvm-libunwind", "rust.llvm_libunwind", "use LLVM libunwind")
o("llvm-libunwind", "rust.llvm-libunwind", "use LLVM libunwind")

# Optimization and debugging options. These may be overridden by the release
# channel, etc.
Expand Down
26 changes: 13 additions & 13 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
//! our CI.

use std::env;
//use std::ffi::OsString;
use std::ffi::OsString;
use std::fmt;
use std::fs;
//use std::iter;
use std::iter;
use std::path::{Path, PathBuf};
use std::process::Command;

Expand Down Expand Up @@ -204,8 +204,8 @@ impl Step for Cargo {
}

/// Runs `cargo test` for `cargo` packaged with Rust.
fn run(self, _builder: &Builder<'_>) {
/*let compiler = builder.compiler(self.stage, self.host);
fn run(self, builder: &Builder<'_>) {
let compiler = builder.compiler(self.stage, self.host);

builder.ensure(tool::Cargo {
compiler,
Expand Down Expand Up @@ -235,7 +235,7 @@ impl Step for Cargo {

cargo.env("PATH", &path_for_cargo(builder, compiler));

try_run(builder, &mut cargo.into());*/
try_run(builder, &mut cargo.into());
}
}

Expand Down Expand Up @@ -590,14 +590,14 @@ impl Step for Clippy {
}
}

//fn path_for_cargo(builder: &Builder<'_>, compiler: Compiler) -> OsString {
// // Configure PATH to find the right rustc. NB. we have to use PATH
// // and not RUSTC because the Cargo test suite has tests that will
// // fail if rustc is not spelled `rustc`.
// let path = builder.sysroot(compiler).join("bin");
// let old_path = env::var_os("PATH").unwrap_or_default();
// env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
//}
fn path_for_cargo(builder: &Builder<'_>, compiler: Compiler) -> OsString {
// Configure PATH to find the right rustc. NB. we have to use PATH
// and not RUSTC because the Cargo test suite has tests that will
// fail if rustc is not spelled `rustc`.
let path = builder.sysroot(compiler).join("bin");
let old_path = env::var_os("PATH").unwrap_or_default();
env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct RustdocTheme {
Expand Down
12 changes: 9 additions & 3 deletions src/ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,30 @@ if [ "$DIST_SRC" = "" ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-dist-src"
fi

RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.parallel-compiler"

# If we're deploying artifacts then we set the release channel, otherwise if
# we're not deploying then we want to be sure to enable all assertions because
# we'll be running tests
#
# FIXME: need a scheme for changing this `nightly` value to `beta` and `stable`
# either automatically or manually.
export RUST_RELEASE_CHANNEL=nightly

# Always set the release channel for bootstrap; this is normally not important (i.e., only dist
# builds would seem to matter) but in practice bootstrap wants to know whether we're targeting
# master, beta, or stable with a build to determine whether to run some checks (notably toolstate).
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL"

if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.remap-debuginfo"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --debuginfo-level-std=1"

if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"
elif [ "$DEPLOY_ALT" != "" ]; then
if [ "$NO_PARALLEL_COMPILER" = "" ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.parallel-compiler"
fi
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"
fi
Expand Down
69 changes: 63 additions & 6 deletions src/libcore/fmt/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,62 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
self
}

/// Marks the struct as non-exhaustive, indicating to the reader that there are some other
/// fields that are not shown in the debug representation.
///
/// # Examples
///
/// ```
/// # #![feature(debug_non_exhaustive)]
/// use std::fmt;
///
/// struct Bar {
/// bar: i32,
/// hidden: f32,
/// }
///
/// impl fmt::Debug for Bar {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// fmt.debug_struct("Bar")
/// .field("bar", &self.bar)
/// .finish_non_exhaustive() // Show that some other field(s) exist.
/// }
/// }
///
/// assert_eq!(
/// format!("{:?}", Bar { bar: 10, hidden: 1.0 }),
/// "Bar { bar: 10, .. }",
/// );
/// ```
#[unstable(feature = "debug_non_exhaustive", issue = "67364")]
pub fn finish_non_exhaustive(&mut self) -> fmt::Result {
self.result = self.result.and_then(|_| {
// Draw non-exhaustive dots (`..`), and open brace if necessary (no fields).
if self.is_pretty() {
if !self.has_fields {
self.fmt.write_str(" {\n")?;
}
let mut slot = None;
let mut state = Default::default();
let mut writer = PadAdapter::wrap(&mut self.fmt, &mut slot, &mut state);
writer.write_str("..\n")?;
} else {
if self.has_fields {
self.fmt.write_str(", ..")?;
} else {
self.fmt.write_str(" { ..")?;
}
}
if self.is_pretty() {
self.fmt.write_str("}")?
} else {
self.fmt.write_str(" }")?;
}
Ok(())
});
self.result
}

/// Finishes output and returns any error encountered.
///
/// # Examples
Expand Down Expand Up @@ -194,15 +250,16 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
/// ```
#[stable(feature = "debug_builders", since = "1.2.0")]
pub fn finish(&mut self) -> fmt::Result {
if self.has_fields {
self.result = self.result.and_then(|_| {
self.result = self.result.and_then(|_| {
if self.has_fields {
if self.is_pretty() {
self.fmt.write_str("}")
self.fmt.write_str("}")?
} else {
self.fmt.write_str(" }")
self.fmt.write_str(" }")?;
}
});
}
}
Ok(())
});
self.result
}

Expand Down
83 changes: 83 additions & 0 deletions src/libcore/tests/fmt/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,89 @@ mod debug_struct {
}",
format!("{:#?}", Bar));
}

#[test]
fn test_only_non_exhaustive() {
struct Foo;

impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Foo")
.finish_non_exhaustive()
}
}


assert_eq!("Foo { .. }", format!("{:?}", Foo));
assert_eq!(
"Foo {
..
}",
format!("{:#?}", Foo));
}

#[test]
fn test_multiple_and_non_exhaustive() {
struct Foo;

impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Foo")
.field("bar", &true)
.field("baz", &format_args!("{}/{}", 10, 20))
.finish_non_exhaustive()
}
}

assert_eq!("Foo { bar: true, baz: 10/20, .. }", format!("{:?}", Foo));
assert_eq!(
"Foo {
bar: true,
baz: 10/20,
..
}",
format!("{:#?}", Foo));
}

#[test]
fn test_nested_non_exhaustive() {
struct Foo;

impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Foo")
.field("bar", &true)
.field("baz", &format_args!("{}/{}", 10, 20))
.finish_non_exhaustive()
}
}

struct Bar;

impl fmt::Debug for Bar {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Bar")
.field("foo", &Foo)
.field("hello", &"world")
.finish_non_exhaustive()
}
}

assert_eq!("Bar { foo: Foo { bar: true, baz: 10/20, .. }, hello: \"world\", .. }",
format!("{:?}", Bar));
assert_eq!(
"Bar {
foo: Foo {
bar: true,
baz: 10/20,
..
},
hello: \"world\",
..
}",
format!("{:#?}", Bar));
}

}

mod debug_tuple {
Expand Down
1 change: 1 addition & 0 deletions src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#![feature(core_private_bignum)]
#![feature(core_private_diy_float)]
#![feature(debug_map_key_value)]
#![feature(debug_non_exhaustive)]
#![feature(dec2flt)]
#![feature(exact_size_is_empty)]
#![feature(fixed_size_array)]
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_index::vec::{Idx, IndexVec};
use smallvec::SmallVec;
use rustc_data_structures::sync::{Lrc, Lock, AtomicU32, AtomicUsize, Ordering};
use rustc_data_structures::sync::{Lrc, Lock, AtomicU32, AtomicU64, Ordering};
use rustc_data_structures::sharded::{self, Sharded};
use std::sync::atomic::Ordering::SeqCst;
use std::env;
Expand Down Expand Up @@ -485,8 +485,8 @@ impl DepGraph {
if cfg!(debug_assertions) {
let current_dep_graph = &self.data.as_ref().unwrap().current;

Some((current_dep_graph.total_read_count.load(SeqCst) as u64,
current_dep_graph.total_duplicate_read_count.load(SeqCst) as u64))
Some((current_dep_graph.total_read_count.load(SeqCst),
current_dep_graph.total_duplicate_read_count.load(SeqCst)))
} else {
None
}
Expand Down Expand Up @@ -970,8 +970,8 @@ pub(super) struct CurrentDepGraph {

/// These are simple counters that are for profiling and
/// debugging and only active with `debug_assertions`.
total_read_count: AtomicUsize,
total_duplicate_read_count: AtomicUsize,
total_read_count: AtomicU64,
total_duplicate_read_count: AtomicU64,
}

impl CurrentDepGraph {
Expand Down Expand Up @@ -1012,8 +1012,8 @@ impl CurrentDepGraph {
)),
anon_id_seed: stable_hasher.finish(),
forbidden_edge,
total_read_count: AtomicUsize::new(0),
total_duplicate_read_count: AtomicUsize::new(0),
total_read_count: AtomicU64::new(0),
total_duplicate_read_count: AtomicU64::new(0),
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@ pub enum AssocKind {
Type
}

impl AssocKind {
pub fn suggestion_descr(&self) -> &'static str {
match self {
ty::AssocKind::Method => "method call",
ty::AssocKind::Type |
ty::AssocKind::OpaqueTy => "associated type",
ty::AssocKind::Const => "associated constant",
}
}
}

impl AssocItem {
pub fn def_kind(&self) -> DefKind {
match self.kind {
Expand Down
1 change: 0 additions & 1 deletion src/librustc_data_structures/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#![feature(integer_atomics)]
#![feature(test)]
#![feature(associated_type_bounds)]
#![feature(cfg_target_has_atomic)]

#![cfg_attr(unix, feature(libc))]

Expand Down
4 changes: 1 addition & 3 deletions src/librustc_data_structures/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,7 @@ cfg_if! {
pub use parking_lot::MutexGuard as LockGuard;
pub use parking_lot::MappedMutexGuard as MappedLockGuard;

pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32};
#[cfg(target_has_atomic = "64")]
pub use std::sync::atomic::{AtomicU64};
pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32, AtomicU64};

pub use crossbeam_utils::atomic::AtomicCell;

Expand Down
10 changes: 5 additions & 5 deletions src/librustc_session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1358,11 +1358,11 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"prints the LLVM optimization passes being run"),
ast_json: bool = (false, parse_bool, [UNTRACKED],
"print the AST as JSON and halt"),
// We default to min(4, vCPUs) here since we want to avoid spawning *too*
// many threads -- that causes scalability issues due to contention on
// the jobserver pipe (at least) -- but 4 is a reasonable amount on systems
// with lots of cores.
threads: usize = (std::cmp::min(::num_cpus::get(), 4), parse_threads, [UNTRACKED],
// We default to 1 here since we want to behave like
// a sequential compiler for now. This'll likely be adjusted
// in the future. Note that -Zthreads=0 is the way to get
// the num_cpus behavior.
threads: usize = (1, parse_threads, [UNTRACKED],
"use a thread pool with N threads"),
ast_json_noexpand: bool = (false, parse_bool, [UNTRACKED],
"print the pre-expansion AST as JSON and halt"),
Expand Down
Loading