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 7 pull requests #67384

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3980342
Use structured suggestion for disambiguating method calls
estebank Dec 4, 2019
8c4f1d5
review comments
estebank Dec 12, 2019
6c7c512
Fix the configure.py TOML field for a couple LLVM options
cuviper Dec 13, 2019
094177e
Add Rvalue::AddressOf to MIR
matthewjasper Dec 23, 2018
12f3e24
Start generating AddressOf rvalues in MIR
matthewjasper Apr 20, 2019
623aa82
Make slice drop shims use AddressOf
matthewjasper Apr 20, 2019
e57096d
Add mir opt test for AddressOf
matthewjasper Apr 20, 2019
6f6b372
Check const-propagation of borrows of unsized places
matthewjasper Sep 17, 2019
5eb17c3
Update test now that reference to pointer casts have more checks
matthewjasper Sep 17, 2019
3594d8b
make htons const fn
tesuji Dec 15, 2019
68fed49
Add more tests for raw_ref_op
matthewjasper Sep 18, 2019
f9f85b1
Fix comment ordering
matthewjasper Dec 2, 2019
f365dbc
Set release channel on non-dist builders
Mark-Simulacrum Dec 16, 2019
985127c
Implement `finish_non_exhaustive` for `DebugStruct`.
richard-uk1 Nov 24, 2019
7f00a5f
Revert "Auto merge of #67362 - Mark-Simulacrum:par-4-default, r=alexc…
Mark-Simulacrum Dec 17, 2019
a50f440
Rollup merge of #64588 - matthewjasper:mir-address-of, r=oli-obk
Mark-Simulacrum Dec 18, 2019
624694d
Rollup merge of #66716 - derekdreery:debug_non_exhaustive, r=dtolnay
Mark-Simulacrum Dec 18, 2019
67d560b
Rollup merge of #67127 - estebank:disambiguate-suggestion, r=varkor
Mark-Simulacrum Dec 18, 2019
743869b
Rollup merge of #67286 - cuviper:configure-llvm, r=Dylan-DPC
Mark-Simulacrum Dec 18, 2019
8c05bb6
Rollup merge of #67321 - lzutao:htons, r=dtolnay
Mark-Simulacrum Dec 18, 2019
c31110d
Rollup merge of #67351 - Mark-Simulacrum:always-channel, r=pietroalbini
Mark-Simulacrum Dec 18, 2019
2e6b327
Rollup merge of #67379 - Mark-Simulacrum:revert-par-4-default, r=Mark…
Mark-Simulacrum Dec 18, 2019
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
18 changes: 18 additions & 0 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2060,6 +2060,11 @@ pub enum Rvalue<'tcx> {
/// &x or &mut x
Ref(Region<'tcx>, BorrowKind, Place<'tcx>),

/// Create a raw pointer to the given place
/// Can be generated by raw address of expressions (`&raw const x`),
/// or when casting a reference to a raw pointer.
AddressOf(Mutability, Place<'tcx>),

/// length of a [X] or [X;n] value
Len(Place<'tcx>),

Expand Down Expand Up @@ -2214,6 +2219,15 @@ impl<'tcx> Debug for Rvalue<'tcx> {
write!(fmt, "&{}{}{:?}", region, kind_str, place)
}

AddressOf(mutability, ref place) => {
let kind_str = match mutability {
Mutability::Mut => "mut",
Mutability::Not => "const",
};

write!(fmt, "&raw {} {:?}", kind_str, place)
}

Aggregate(ref kind, ref places) => {
fn fmt_tuple(fmt: &mut Formatter<'_>, places: &[Operand<'_>]) -> fmt::Result {
let mut tuple_fmt = fmt.debug_tuple("");
Expand Down Expand Up @@ -3085,6 +3099,9 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
Ref(region, bk, ref place) => {
Ref(region.fold_with(folder), bk, place.fold_with(folder))
}
AddressOf(mutability, ref place) => {
AddressOf(mutability, place.fold_with(folder))
}
Len(ref place) => Len(place.fold_with(folder)),
Cast(kind, ref op, ty) => Cast(kind, op.fold_with(folder), ty.fold_with(folder)),
BinaryOp(op, ref rhs, ref lhs) => {
Expand Down Expand Up @@ -3125,6 +3142,7 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
Use(ref op) => op.visit_with(visitor),
Repeat(ref op, _) => op.visit_with(visitor),
Ref(region, _, ref place) => region.visit_with(visitor) || place.visit_with(visitor),
AddressOf(_, ref place) => place.visit_with(visitor),
Len(ref place) => place.visit_with(visitor),
Cast(_, ref op, ty) => op.visit_with(visitor) || ty.visit_with(visitor),
BinaryOp(_, ref rhs, ref lhs) | CheckedBinaryOp(_, ref rhs, ref lhs) => {
Expand Down
7 changes: 7 additions & 0 deletions src/librustc/mir/tcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ impl<'tcx> Rvalue<'tcx> {
}
)
}
Rvalue::AddressOf(mutability, ref place) => {
let place_ty = place.ty(local_decls, tcx).ty;
tcx.mk_ptr(ty::TypeAndMut {
ty: place_ty,
mutbl: mutability.into(),
})
}
Rvalue::Len(..) => tcx.types.usize,
Rvalue::Cast(.., ty) => ty,
Rvalue::BinaryOp(op, ref lhs, ref rhs) => {
Expand Down
Loading