Skip to content

Commit

Permalink
Auto merge of #64526 - Centril:rollup-k4cz2xn, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 4 pull requests

Successful merges:

 - #64357 (`AdtDef` is an algebraic data type, not abstract data type)
 - #64485 (update Miri)
 - #64509 (Make some adjustments to the documentation for `std::convert::identity`)
 - #64518 (Use while let slice_pattern instead of carrying an index around)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Sep 16, 2019
2 parents a44881d + 1376ccd commit 7ac21e7
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 33 deletions.
7 changes: 3 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ dependencies = [

[[package]]
name = "byteorder"
version = "1.2.7"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d"
checksum = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"

[[package]]
name = "bytes"
Expand Down Expand Up @@ -2067,7 +2067,7 @@ dependencies = [
"hex",
"log",
"num-traits",
"rand 0.6.1",
"rand 0.7.0",
"rustc-workspace-hack",
"rustc_version",
"shell-escape",
Expand Down Expand Up @@ -3255,7 +3255,6 @@ dependencies = [
name = "rustc-workspace-hack"
version = "1.0.0"
dependencies = [
"byteorder",
"crossbeam-utils 0.6.5",
"serde",
"serde_json",
Expand Down
17 changes: 9 additions & 8 deletions src/libcore/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@

use crate::fmt;

/// An identity function.
/// The identity function.
///
/// Two things are important to note about this function:
///
/// - It is not always equivalent to a closure like `|x| x` since the
/// - It is not always equivalent to a closure like `|x| x`, since the
/// closure may coerce `x` into a different type.
///
/// - It moves the input `x` passed to the function.
Expand All @@ -56,31 +56,32 @@ use crate::fmt;
///
/// # Examples
///
/// Using `identity` to do nothing among other interesting functions:
/// Using `identity` to do nothing in a sequence of other, interesting,
/// functions:
///
/// ```rust
/// use std::convert::identity;
///
/// fn manipulation(x: u32) -> u32 {
/// // Let's assume that this function does something interesting.
/// // Let's pretend that adding one is an interesting function.
/// x + 1
/// }
///
/// let _arr = &[identity, manipulation];
/// ```
///
/// Using `identity` to get a function that changes nothing in a conditional:
/// Using `identity` as a "do nothing" base case in a conditional:
///
/// ```rust
/// use std::convert::identity;
///
/// # let condition = true;
///
/// #
/// # fn manipulation(x: u32) -> u32 { x + 1 }
///
/// #
/// let do_stuff = if condition { manipulation } else { identity };
///
/// // do more interesting stuff..
/// // Do more interesting stuff...
///
/// let _results = do_stuff(42);
/// ```
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
backtrace = "0.3.3"
parking_lot = "0.9"
byteorder = { version = "1.1", features = ["i128"]}
byteorder = { version = "1.3" }
chalk-engine = { version = "0.9.0", default-features=false }
rustc_fs_util = { path = "../librustc_fs_util" }
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
Expand Down
8 changes: 7 additions & 1 deletion src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1938,9 +1938,15 @@ pub struct FieldDef {
pub vis: Visibility,
}

/// The definition of an abstract data type -- a struct or enum.
/// The definition of a user-defined type, e.g., a `struct`, `enum`, or `union`.
///
/// These are all interned (by `intern_adt_def`) into the `adt_defs` table.
///
/// The initialism *"Adt"* stands for an [*algebraic data type (ADT)*][adt].
/// This is slightly wrong because `union`s are not ADTs.
/// Moreover, Rust only allows recursive data types through indirection.
///
/// [adt]: https://en.wikipedia.org/wiki/Algebraic_data_type
pub struct AdtDef {
/// `DefId` of the struct, enum or union item.
pub did: DefId,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ rustc_lexer = { path = "../librustc_lexer" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
byteorder = { version = "1.1", features = ["i128"] }
byteorder = { version = "1.3" }
rustc_apfloat = { path = "../librustc_apfloat" }
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
10 changes: 6 additions & 4 deletions src/librustc_mir/borrow_check/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
projection,
} = first_borrowed_place;

for (i, elem) in projection.iter().enumerate().rev() {
let proj_base = &projection[..i];
let mut cursor = &**projection;
while let [proj_base @ .., elem] = cursor {
cursor = proj_base;

match elem {
ProjectionElem::Field(field, _) if union_ty(base, proj_base).is_some() => {
Expand All @@ -637,8 +638,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
projection,
} = second_borrowed_place;

for (i, elem) in projection.iter().enumerate().rev() {
let proj_base = &projection[..i];
let mut cursor = &**projection;
while let [proj_base @ .., elem] = cursor {
cursor = proj_base;

if let ProjectionElem::Field(field, _) = elem {
if let Some(union_ty) = union_ty(base, proj_base) {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1758,7 +1758,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
debug!("check_if_assigned_path_is_moved place: {:?}", place);

// None case => assigning to `x` does not require `x` be initialized.
for (i, elem) in place.projection.iter().enumerate().rev() {
let mut cursor = &*place.projection;
while let [proj_base @ .., elem] = cursor {
cursor = proj_base;

match elem {
ProjectionElem::Index(_/*operand*/) |
ProjectionElem::ConstantIndex { .. } |
Expand All @@ -1771,8 +1774,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {

// assigning to (*P) requires P to be initialized
ProjectionElem::Deref => {
let proj_base = &place.projection[..i];

self.check_if_full_path_is_moved(
location, InitializationRequiringAction::Use,
(PlaceRef {
Expand All @@ -1790,7 +1791,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
}

ProjectionElem::Field(..) => {
let proj_base = &place.projection[..i];
// if type of `P` has a dtor, then
// assigning to `P.f` requires `P` itself
// be already initialized
Expand Down
7 changes: 5 additions & 2 deletions src/librustc_mir/borrow_check/nll/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2417,9 +2417,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
"add_reborrow_constraint({:?}, {:?}, {:?})",
location, borrow_region, borrowed_place
);
for (i, elem) in borrowed_place.projection.iter().enumerate().rev() {

let mut cursor = &*borrowed_place.projection;
while let [proj_base @ .., elem] = cursor {
cursor = proj_base;

debug!("add_reborrow_constraint - iteration {:?}", elem);
let proj_base = &borrowed_place.projection[..i];

match elem {
ProjectionElem::Deref => {
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_mir/build/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1296,8 +1296,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// Insert a Shallow borrow of the prefixes of any fake borrows.
for place in fake_borrows
{
for (i, elem) in place.projection.iter().enumerate().rev() {
let proj_base = &place.projection[..i];
let mut cursor = &*place.projection;
while let [proj_base @ .., elem] = cursor {
cursor = proj_base;

if let ProjectionElem::Deref = elem {
// Insert a shallow borrow after a deref. For other
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_mir/transform/check_unsafety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,9 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
place: &Place<'tcx>,
is_mut_use: bool,
) {
for (i, elem) in place.projection.iter().enumerate().rev() {
let proj_base = &place.projection[..i];
let mut cursor = &*place.projection;
while let [proj_base @ .., elem] = cursor {
cursor = proj_base;

match elem {
ProjectionElem::Field(..) => {
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_mir/util/alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ fn is_within_packed<'tcx, L>(tcx: TyCtxt<'tcx>, local_decls: &L, place: &Place<'
where
L: HasLocalDecls<'tcx>,
{
for (i, elem) in place.projection.iter().enumerate().rev() {
let proj_base = &place.projection[..i];
let mut cursor = &*place.projection;
while let [proj_base @ .., elem] = cursor {
cursor = proj_base;

match elem {
// encountered a Deref, which is ABI-aligned
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri
1 change: 0 additions & 1 deletion src/tools/rustc-workspace-hack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ crossbeam-utils = { version = "0.6.5", features = ["nightly"] }
serde = { version = "1.0.82", features = ['derive'] }
serde_json = { version = "1.0.31", features = ["raw_value"] }
smallvec = { version = "0.6", features = ['union', 'may_dangle'] }
byteorder = { version = "1.2.7", features = ["i128"] }


[target.'cfg(not(windows))'.dependencies]
Expand Down

0 comments on commit 7ac21e7

Please sign in to comment.