Skip to content

Commit 7ac21e7

Browse files
committed
Auto merge of #64526 - Centril:rollup-k4cz2xn, r=Centril
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
2 parents a44881d + 1376ccd commit 7ac21e7

File tree

13 files changed

+46
-33
lines changed

13 files changed

+46
-33
lines changed

Cargo.lock

+3-4
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ dependencies = [
234234

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

241241
[[package]]
242242
name = "bytes"
@@ -2067,7 +2067,7 @@ dependencies = [
20672067
"hex",
20682068
"log",
20692069
"num-traits",
2070-
"rand 0.6.1",
2070+
"rand 0.7.0",
20712071
"rustc-workspace-hack",
20722072
"rustc_version",
20732073
"shell-escape",
@@ -3255,7 +3255,6 @@ dependencies = [
32553255
name = "rustc-workspace-hack"
32563256
version = "1.0.0"
32573257
dependencies = [
3258-
"byteorder",
32593258
"crossbeam-utils 0.6.5",
32603259
"serde",
32613260
"serde_json",

src/libcore/convert.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242

4343
use crate::fmt;
4444

45-
/// An identity function.
45+
/// The identity function.
4646
///
4747
/// Two things are important to note about this function:
4848
///
49-
/// - It is not always equivalent to a closure like `|x| x` since the
49+
/// - It is not always equivalent to a closure like `|x| x`, since the
5050
/// closure may coerce `x` into a different type.
5151
///
5252
/// - It moves the input `x` passed to the function.
@@ -56,31 +56,32 @@ use crate::fmt;
5656
///
5757
/// # Examples
5858
///
59-
/// Using `identity` to do nothing among other interesting functions:
59+
/// Using `identity` to do nothing in a sequence of other, interesting,
60+
/// functions:
6061
///
6162
/// ```rust
6263
/// use std::convert::identity;
6364
///
6465
/// fn manipulation(x: u32) -> u32 {
65-
/// // Let's assume that this function does something interesting.
66+
/// // Let's pretend that adding one is an interesting function.
6667
/// x + 1
6768
/// }
6869
///
6970
/// let _arr = &[identity, manipulation];
7071
/// ```
7172
///
72-
/// Using `identity` to get a function that changes nothing in a conditional:
73+
/// Using `identity` as a "do nothing" base case in a conditional:
7374
///
7475
/// ```rust
7576
/// use std::convert::identity;
7677
///
7778
/// # let condition = true;
78-
///
79+
/// #
7980
/// # fn manipulation(x: u32) -> u32 { x + 1 }
80-
///
81+
/// #
8182
/// let do_stuff = if condition { manipulation } else { identity };
8283
///
83-
/// // do more interesting stuff..
84+
/// // Do more interesting stuff...
8485
///
8586
/// let _results = do_stuff(42);
8687
/// ```

src/librustc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ syntax = { path = "../libsyntax" }
3131
syntax_pos = { path = "../libsyntax_pos" }
3232
backtrace = "0.3.3"
3333
parking_lot = "0.9"
34-
byteorder = { version = "1.1", features = ["i128"]}
34+
byteorder = { version = "1.3" }
3535
chalk-engine = { version = "0.9.0", default-features=false }
3636
rustc_fs_util = { path = "../librustc_fs_util" }
3737
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }

src/librustc/ty/mod.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1938,9 +1938,15 @@ pub struct FieldDef {
19381938
pub vis: Visibility,
19391939
}
19401940

1941-
/// The definition of an abstract data type -- a struct or enum.
1941+
/// The definition of a user-defined type, e.g., a `struct`, `enum`, or `union`.
19421942
///
19431943
/// These are all interned (by `intern_adt_def`) into the `adt_defs` table.
1944+
///
1945+
/// The initialism *"Adt"* stands for an [*algebraic data type (ADT)*][adt].
1946+
/// This is slightly wrong because `union`s are not ADTs.
1947+
/// Moreover, Rust only allows recursive data types through indirection.
1948+
///
1949+
/// [adt]: https://en.wikipedia.org/wiki/Algebraic_data_type
19441950
pub struct AdtDef {
19451951
/// `DefId` of the struct, enum or union item.
19461952
pub did: DefId,

src/librustc_mir/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ rustc_lexer = { path = "../librustc_lexer" }
2424
rustc_serialize = { path = "../libserialize", package = "serialize" }
2525
syntax = { path = "../libsyntax" }
2626
syntax_pos = { path = "../libsyntax_pos" }
27-
byteorder = { version = "1.1", features = ["i128"] }
27+
byteorder = { version = "1.3" }
2828
rustc_apfloat = { path = "../librustc_apfloat" }
2929
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }

src/librustc_mir/borrow_check/conflict_errors.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
614614
projection,
615615
} = first_borrowed_place;
616616

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

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

640-
for (i, elem) in projection.iter().enumerate().rev() {
641-
let proj_base = &projection[..i];
641+
let mut cursor = &**projection;
642+
while let [proj_base @ .., elem] = cursor {
643+
cursor = proj_base;
642644

643645
if let ProjectionElem::Field(field, _) = elem {
644646
if let Some(union_ty) = union_ty(base, proj_base) {

src/librustc_mir/borrow_check/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1758,7 +1758,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
17581758
debug!("check_if_assigned_path_is_moved place: {:?}", place);
17591759

17601760
// None case => assigning to `x` does not require `x` be initialized.
1761-
for (i, elem) in place.projection.iter().enumerate().rev() {
1761+
let mut cursor = &*place.projection;
1762+
while let [proj_base @ .., elem] = cursor {
1763+
cursor = proj_base;
1764+
17621765
match elem {
17631766
ProjectionElem::Index(_/*operand*/) |
17641767
ProjectionElem::ConstantIndex { .. } |
@@ -1771,8 +1774,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
17711774

17721775
// assigning to (*P) requires P to be initialized
17731776
ProjectionElem::Deref => {
1774-
let proj_base = &place.projection[..i];
1775-
17761777
self.check_if_full_path_is_moved(
17771778
location, InitializationRequiringAction::Use,
17781779
(PlaceRef {
@@ -1790,7 +1791,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
17901791
}
17911792

17921793
ProjectionElem::Field(..) => {
1793-
let proj_base = &place.projection[..i];
17941794
// if type of `P` has a dtor, then
17951795
// assigning to `P.f` requires `P` itself
17961796
// be already initialized

src/librustc_mir/borrow_check/nll/type_check/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -2417,9 +2417,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
24172417
"add_reborrow_constraint({:?}, {:?}, {:?})",
24182418
location, borrow_region, borrowed_place
24192419
);
2420-
for (i, elem) in borrowed_place.projection.iter().enumerate().rev() {
2420+
2421+
let mut cursor = &*borrowed_place.projection;
2422+
while let [proj_base @ .., elem] = cursor {
2423+
cursor = proj_base;
2424+
24212425
debug!("add_reborrow_constraint - iteration {:?}", elem);
2422-
let proj_base = &borrowed_place.projection[..i];
24232426

24242427
match elem {
24252428
ProjectionElem::Deref => {

src/librustc_mir/build/matches/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1296,8 +1296,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
12961296
// Insert a Shallow borrow of the prefixes of any fake borrows.
12971297
for place in fake_borrows
12981298
{
1299-
for (i, elem) in place.projection.iter().enumerate().rev() {
1300-
let proj_base = &place.projection[..i];
1299+
let mut cursor = &*place.projection;
1300+
while let [proj_base @ .., elem] = cursor {
1301+
cursor = proj_base;
13011302

13021303
if let ProjectionElem::Deref = elem {
13031304
// Insert a shallow borrow after a deref. For other

src/librustc_mir/transform/check_unsafety.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,9 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
407407
place: &Place<'tcx>,
408408
is_mut_use: bool,
409409
) {
410-
for (i, elem) in place.projection.iter().enumerate().rev() {
411-
let proj_base = &place.projection[..i];
410+
let mut cursor = &*place.projection;
411+
while let [proj_base @ .., elem] = cursor {
412+
cursor = proj_base;
412413

413414
match elem {
414415
ProjectionElem::Field(..) => {

src/librustc_mir/util/alignment.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ fn is_within_packed<'tcx, L>(tcx: TyCtxt<'tcx>, local_decls: &L, place: &Place<'
3838
where
3939
L: HasLocalDecls<'tcx>,
4040
{
41-
for (i, elem) in place.projection.iter().enumerate().rev() {
42-
let proj_base = &place.projection[..i];
41+
let mut cursor = &*place.projection;
42+
while let [proj_base @ .., elem] = cursor {
43+
cursor = proj_base;
4344

4445
match elem {
4546
// encountered a Deref, which is ABI-aligned

src/tools/rustc-workspace-hack/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ crossbeam-utils = { version = "0.6.5", features = ["nightly"] }
6262
serde = { version = "1.0.82", features = ['derive'] }
6363
serde_json = { version = "1.0.31", features = ["raw_value"] }
6464
smallvec = { version = "0.6", features = ['union', 'may_dangle'] }
65-
byteorder = { version = "1.2.7", features = ["i128"] }
6665

6766

6867
[target.'cfg(not(windows))'.dependencies]

0 commit comments

Comments
 (0)