Skip to content

Commit

Permalink
Auto merge of #68067 - JohnTitor:rollup-vsj5won, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 10 pull requests

Successful merges:

 - #66254 (Make Layout::new const)
 - #67122 (Do not deduplicate diagnostics in UI tests)
 - #67358 (Add HashSet::get_or_insert_owned)
 - #67725 (Simplify into_key_slice_mut)
 - #67935 (Relax the Sized bounds on Pin::map_unchecked(_mut))
 - #67967 (Delay bug to prevent ICE in MIR borrowck)
 - #67975 (Export public scalar statics in wasm)
 - #68006 (Recognise riscv64 in compiletest)
 - #68040 (Cleanup)
 - #68054 (doc: add Null-unchecked version section to mut pointer as_mut method)

Failed merges:

 - #67258 (Introduce `X..`, `..X`, and `..=X` range patterns)

r? @ghost
  • Loading branch information
bors committed Jan 9, 2020
2 parents 59eb49d + 9e83df0 commit 72b2bd5
Show file tree
Hide file tree
Showing 235 changed files with 3,078 additions and 418 deletions.
10 changes: 0 additions & 10 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3079,8 +3079,6 @@ dependencies = [
"graphviz",
"jobserver",
"log",
"measureme",
"num_cpus",
"parking_lot",
"polonius-engine",
"rustc-rayon",
Expand All @@ -3090,7 +3088,6 @@ dependencies = [
"rustc_error_codes",
"rustc_errors",
"rustc_feature",
"rustc_fs_util",
"rustc_hir",
"rustc_index",
"rustc_macros",
Expand Down Expand Up @@ -3278,7 +3275,6 @@ dependencies = [
"jemalloc-sys",
"rustc_codegen_ssa",
"rustc_driver",
"rustc_target",
]

[[package]]
Expand Down Expand Up @@ -3409,7 +3405,6 @@ dependencies = [
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_errors",
"rustc_expand",
"rustc_feature",
"rustc_fs_util",
"rustc_hir",
Expand Down Expand Up @@ -3497,7 +3492,6 @@ name = "rustc_driver"
version = "0.0.0"
dependencies = [
"env_logger 0.7.1",
"graphviz",
"lazy_static 1.3.0",
"log",
"rustc",
Expand All @@ -3513,7 +3507,6 @@ dependencies = [
"rustc_mir",
"rustc_parse",
"rustc_plugin_impl",
"rustc_resolve",
"rustc_save_analysis",
"rustc_span",
"rustc_target",
Expand Down Expand Up @@ -3660,7 +3653,6 @@ dependencies = [
"log",
"rustc",
"rustc_data_structures",
"rustc_error_codes",
"rustc_feature",
"rustc_hir",
"rustc_index",
Expand Down Expand Up @@ -4464,8 +4456,6 @@ dependencies = [
name = "syntax"
version = "0.0.0"
dependencies = [
"bitflags",
"lazy_static 1.3.0",
"log",
"rustc_data_structures",
"rustc_error_codes",
Expand Down
23 changes: 10 additions & 13 deletions src/liballoc/collections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {

/// Borrows a view into the values stored in the node.
/// The caller must ensure that the node is not the shared root.
/// This function is not public, so doesn't have to support shared roots like `keys` does.
fn vals(&self) -> &[V] {
self.reborrow().into_val_slice()
}
Expand Down Expand Up @@ -514,6 +515,7 @@ impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
}

/// The caller must ensure that the node is not the shared root.
/// This function is not public, so doesn't have to support shared roots like `keys` does.
fn keys_mut(&mut self) -> &mut [K] {
unsafe { self.reborrow_mut().into_key_slice_mut() }
}
Expand Down Expand Up @@ -589,20 +591,15 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
unsafe { &mut *(self.root as *mut Root<K, V>) }
}

/// The caller must ensure that the node is not the shared root.
fn into_key_slice_mut(mut self) -> &'a mut [K] {
// Same as for `into_key_slice` above, we try to avoid a run-time check.
if (mem::align_of::<NodeHeader<K, V, K>>() > mem::align_of::<NodeHeader<K, V>>()
|| mem::size_of::<NodeHeader<K, V, K>>() != mem::size_of::<NodeHeader<K, V>>())
&& self.is_shared_root()
{
&mut []
} else {
unsafe {
slice::from_raw_parts_mut(
MaybeUninit::first_ptr_mut(&mut (*self.as_leaf_mut()).keys),
self.len(),
)
}
debug_assert!(!self.is_shared_root());
// We cannot be the shared root, so `as_leaf_mut` is okay.
unsafe {
slice::from_raw_parts_mut(
MaybeUninit::first_ptr_mut(&mut (*self.as_leaf_mut()).keys),
self.len(),
)
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/liballoc/collections/btree/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ where
}
}

/// Returns the index in the node at which the key (or an equivalent) exists
/// or could exist, and whether it exists in the node itself. If it doesn't
/// exist in the node itself, it may exist in the subtree with that index
/// (if the node has subtrees). If the key doesn't exist in node or subtree,
/// the returned index is the position or subtree to insert at.
pub fn search_linear<BorrowType, K, V, Type, Q: ?Sized>(
node: &NodeRef<BorrowType, K, V, Type>,
key: &Q,
Expand All @@ -54,6 +59,12 @@ where
Q: Ord,
K: Borrow<Q>,
{
// This function is defined over all borrow types (immutable, mutable, owned),
// and may be called on the shared root in each case.
// Crucially, we use `keys()` here, i.e., we work with immutable data.
// `keys_mut()` does not support the shared root, so we cannot use it.
// Using `keys()` is fine here even if BorrowType is mutable, as all we return
// is an index -- not a reference.
for (i, k) in node.keys().iter().enumerate() {
match key.cmp(k.borrow()) {
Ordering::Greater => {}
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::usize;
#[derive(Debug)]
pub struct Excess(pub NonNull<u8>, pub usize);

fn size_align<T>() -> (usize, usize) {
const fn size_align<T>() -> (usize, usize) {
(mem::size_of::<T>(), mem::align_of::<T>())
}

Expand Down Expand Up @@ -120,14 +120,14 @@ impl Layout {

/// Constructs a `Layout` suitable for holding a value of type `T`.
#[stable(feature = "alloc_layout", since = "1.28.0")]
#[rustc_const_stable(feature = "alloc_layout_const_new", since = "1.42.0")]
#[inline]
pub fn new<T>() -> Self {
pub const fn new<T>() -> Self {
let (size, align) = size_align::<T>();
// Note that the align is guaranteed by rustc to be a power of two and
// the size+align combo is guaranteed to fit in our address space. As a
// result use the unchecked constructor here to avoid inserting code
// that panics if it isn't optimized well enough.
debug_assert!(Layout::from_size_align(size, align).is_ok());
unsafe { Layout::from_size_align_unchecked(size, align) }
}

Expand Down
2 changes: 2 additions & 0 deletions src/libcore/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ impl<'a, T: ?Sized> Pin<&'a T> {
#[stable(feature = "pin", since = "1.33.0")]
pub unsafe fn map_unchecked<U, F>(self, func: F) -> Pin<&'a U>
where
U: ?Sized,
F: FnOnce(&T) -> &U,
{
let pointer = &*self.pointer;
Expand Down Expand Up @@ -763,6 +764,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
#[stable(feature = "pin", since = "1.33.0")]
pub unsafe fn map_unchecked_mut<U, F>(self, func: F) -> Pin<&'a mut U>
where
U: ?Sized,
F: FnOnce(&mut T) -> &mut U,
{
let pointer = Pin::get_unchecked_mut(self);
Expand Down
14 changes: 14 additions & 0 deletions src/libcore/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,20 @@ impl<T: ?Sized> *mut T {
/// *first_value = 4;
/// println!("{:?}", s); // It'll print: "[4, 2, 3]".
/// ```
///
/// # Null-unchecked version
///
/// If you are sure the pointer can never be null and are looking for some kind of
/// `as_mut_unchecked` that returns the `&mut T` instead of `Option<&mut T>`, know that
/// you can dereference the pointer directly.
///
/// ```
/// let mut s = [1, 2, 3];
/// let ptr: *mut u32 = s.as_mut_ptr();
/// let first_value = unsafe { &mut *ptr };
/// *first_value = 4;
/// println!("{:?}", s); // It'll print: "[4, 2, 3]".
/// ```
#[stable(feature = "ptr_as_ref", since = "1.9.0")]
#[inline]
pub unsafe fn as_mut<'a>(self) -> Option<&'a mut T> {
Expand Down
3 changes: 0 additions & 3 deletions src/librustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ bitflags = "1.2.1"
fmt_macros = { path = "../libfmt_macros" }
graphviz = { path = "../libgraphviz" }
jobserver = "0.1"
num_cpus = "1.0"
scoped-tls = "1.0"
log = { version = "0.4", features = ["release_max_level_info", "std"] }
rustc-rayon = "0.3.0"
Expand All @@ -36,8 +35,6 @@ backtrace = "0.3.40"
parking_lot = "0.9"
byteorder = { version = "1.3" }
chalk-engine = { version = "0.9.0", default-features=false }
rustc_fs_util = { path = "../librustc_fs_util" }
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
measureme = "0.5"
rustc_error_codes = { path = "../librustc_error_codes" }
rustc_session = { path = "../librustc_session" }
7 changes: 0 additions & 7 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,13 +808,6 @@ pub struct UpvarBorrow<'tcx> {
pub type UpvarListMap = FxHashMap<DefId, FxIndexMap<hir::HirId, UpvarId>>;
pub type UpvarCaptureMap<'tcx> = FxHashMap<UpvarId, UpvarCapture<'tcx>>;

#[derive(Copy, Clone, TypeFoldable)]
pub struct ClosureUpvar<'tcx> {
pub res: Res,
pub span: Span,
pub ty: Ty<'tcx>,
}

#[derive(Clone, Copy, PartialEq, Eq)]
pub enum IntVarValue {
IntType(ast::IntTy),
Expand Down
6 changes: 0 additions & 6 deletions src/librustc/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ impl fmt::Debug for ty::AdtDef {
}
}

impl fmt::Debug for ty::ClosureUpvar<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "ClosureUpvar({:?},{:?})", self.res, self.ty)
}
}

impl fmt::Debug for ty::UpvarId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let name = ty::tls::with(|tcx| tcx.hir().name(self.var_path.hir_id));
Expand Down
1 change: 0 additions & 1 deletion src/librustc_codegen_llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ rustc_session = { path = "../librustc_session" }
rustc_target = { path = "../librustc_target" }
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
syntax = { path = "../libsyntax" }
rustc_expand = { path = "../librustc_expand" }
rustc_span = { path = "../librustc_span" }
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel
if is_extern && !std_internal {
let target = &tcx.sess.target.target.llvm_target;
// WebAssembly cannot export data symbols, so reduce their export level
if target.contains("wasm32") || target.contains("emscripten") {
if target.contains("emscripten") {
if let Some(Node::Item(&hir::Item { kind: hir::ItemKind::Static(..), .. })) =
tcx.hir().get_if_local(sym_def_id)
{
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ path = "lib.rs"
crate-type = ["dylib"]

[dependencies]
graphviz = { path = "../libgraphviz" }
lazy_static = "1.0"
log = "0.4"
env_logger = { version = "0.7", default-features = false }
Expand All @@ -30,7 +29,6 @@ rustc_codegen_utils = { path = "../librustc_codegen_utils" }
rustc_error_codes = { path = "../librustc_error_codes" }
rustc_interface = { path = "../librustc_interface" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
rustc_resolve = { path = "../librustc_resolve" }
syntax = { path = "../libsyntax" }
rustc_span = { path = "../librustc_span" }

Expand Down
1 change: 0 additions & 1 deletion src/librustc_lint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ rustc_span = { path = "../librustc_span" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_feature = { path = "../librustc_feature" }
rustc_index = { path = "../librustc_index" }
rustc_error_codes = { path = "../librustc_error_codes" }
rustc_session = { path = "../librustc_session" }
8 changes: 7 additions & 1 deletion src/librustc_mir/transform/elaborate_drops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops {
let param_env = tcx.param_env(src.def_id()).with_reveal_all();
let move_data = match MoveData::gather_moves(body, tcx, param_env) {
Ok(move_data) => move_data,
Err(_) => bug!("No `move_errors` should be allowed in MIR borrowck"),
Err((move_data, _)) => {
tcx.sess.delay_span_bug(
body.span,
"No `move_errors` should be allowed in MIR borrowck",
);
move_data
}
};
let elaborate_patch = {
let body = &*body;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/upvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

// Returns a list of `ClosureUpvar`s for each upvar.
// Returns a list of `Ty`s for each upvar.
fn final_upvar_tys(&self, closure_id: hir::HirId) -> Vec<Ty<'tcx>> {
// Presently an unboxed closure type cannot "escape" out of a
// function, so we will only encounter ones that originated in the
Expand Down
32 changes: 32 additions & 0 deletions src/libstd/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,38 @@ where
self.map.raw_entry_mut().from_key(&value).or_insert(value, ()).0
}

/// Inserts an owned copy of the given `value` into the set if it is not
/// present, then returns a reference to the value in the set.
///
/// # Examples
///
/// ```
/// #![feature(hash_set_entry)]
///
/// use std::collections::HashSet;
///
/// let mut set: HashSet<String> = ["cat", "dog", "horse"]
/// .iter().map(|&pet| pet.to_owned()).collect();
///
/// assert_eq!(set.len(), 3);
/// for &pet in &["cat", "dog", "fish"] {
/// let value = set.get_or_insert_owned(pet);
/// assert_eq!(value, pet);
/// }
/// assert_eq!(set.len(), 4); // a new "fish" was inserted
/// ```
#[inline]
#[unstable(feature = "hash_set_entry", issue = "60896")]
pub fn get_or_insert_owned<Q: ?Sized>(&mut self, value: &Q) -> &T
where
T: Borrow<Q>,
Q: Hash + Eq + ToOwned<Owned = T>,
{
// Although the raw entry gives us `&mut T`, we only return `&T` to be consistent with
// `get`. Key mutation is "raw" because you're not supposed to affect `Eq` or `Hash`.
self.map.raw_entry_mut().from_key(value).or_insert_with(|| (value.to_owned(), ())).0
}

/// Inserts a value computed from `f` into the set if the given `value` is
/// not present, then returns a reference to the value in the set.
///
Expand Down
2 changes: 0 additions & 2 deletions src/libsyntax/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ path = "lib.rs"
doctest = false

[dependencies]
bitflags = "1.2.1"
rustc_serialize = { path = "../libserialize", package = "serialize" }
log = "0.4"
scoped-tls = "1.0"
lazy_static = "1.0.0"
rustc_span = { path = "../librustc_span" }
errors = { path = "../librustc_errors", package = "rustc_errors" }
rustc_data_structures = { path = "../librustc_data_structures" }
Expand Down
1 change: 0 additions & 1 deletion src/rustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ name = "rustc_binary"
path = "rustc.rs"

[dependencies]
rustc_target = { path = "../librustc_target" }
rustc_driver = { path = "../librustc_driver" }

# Make sure rustc_codegen_ssa ends up in the sysroot, because this
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/consts/const-fn-error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const fn f(x: usize) -> usize {
let mut sum = 0;
for i in 0..x {
//~^ ERROR E0015
//~| ERROR E0015
//~| ERROR E0658
//~| ERROR E0080
//~| ERROR E0744
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/issue-52443.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ fn main() {
//~| WARN denote infinite loops with
[(); { for _ in 0usize.. {}; 0}];
//~^ ERROR calls in constants are limited to constant functions
//~| ERROR calls in constants are limited to constant functions
//~| ERROR `for` is not allowed in a `const`
//~| ERROR references in constants may only refer to immutable values
//~| ERROR evaluation of constant value failed
Expand Down
3 changes: 3 additions & 0 deletions src/test/run-make/wasm-export-all-symbols/bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

#[no_mangle]
pub extern fn foo() {}

#[no_mangle]
pub static FOO: u64 = 42;
Loading

0 comments on commit 72b2bd5

Please sign in to comment.