Skip to content

Commit de21ea8

Browse files
committed
Auto merge of #53449 - frewsxcv:rollup, r=frewsxcv
Rollup of 11 pull requests Successful merges: - #52858 (Implement Iterator::size_hint for Elaborator.) - #53321 (Fix usage of `wasm_target_feature`) - #53326 ([nll] add regression test for issue #27868) - #53347 (rustc_resolve: don't allow paths starting with `::crate`.) - #53349 ([nll] add tests for #48697 and #30104) - #53357 (Pretty print btreemap for GDB) - #53358 (`{to,from}_{ne,le,be}_bytes` for unsigned integer types) - #53406 (Do not suggest conversion method that is already there) - #53407 (make more ported compile fail tests more robust w.r.t. NLL) - #53413 (Warn that `#![feature(rust_2018_preview)]` is implied when the edition is set to Rust 2018.) - #53434 (wasm: Remove --strip-debug argument to LLD) Failed merges: r? @ghost
2 parents 8dad6be + f214666 commit de21ea8

File tree

73 files changed

+750
-183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+750
-183
lines changed

src/Cargo.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
308308

309309
[[package]]
310310
name = "chalk-engine"
311-
version = "0.6.0"
311+
version = "0.7.0"
312312
source = "registry+https://github.com/rust-lang/crates.io-index"
313313
dependencies = [
314314
"chalk-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1897,7 +1897,7 @@ dependencies = [
18971897
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
18981898
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
18991899
"byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
1900-
"chalk-engine 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
1900+
"chalk-engine 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
19011901
"flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
19021902
"fmt_macros 0.0.0",
19031903
"graphviz 0.0.0",
@@ -2408,7 +2408,7 @@ name = "rustc_traits"
24082408
version = "0.0.0"
24092409
dependencies = [
24102410
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
2411-
"chalk-engine 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
2411+
"chalk-engine 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
24122412
"graphviz 0.0.0",
24132413
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
24142414
"rustc 0.0.0",
@@ -3135,7 +3135,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
31353135
"checksum cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d6809b327f87369e6f3651efd2c5a96c49847a3ed2559477ecba79014751ee1"
31363136
"checksum cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "2119ea4867bd2b8ed3aecab467709720b2d55b1bcfe09f772fd68066eaf15275"
31373137
"checksum cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efe5c877e17a9c717a0bf3613b2709f723202c4e4675cc8f12926ded29bcb17e"
3138-
"checksum chalk-engine 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a146c19172c7eea48ea55a7123ac95da786639bc665097f1e14034ee5f1d8699"
3138+
"checksum chalk-engine 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "25ce2f28f55ed544a2a3756b7acf41dd7d6f27acffb2086439950925506af7d0"
31393139
"checksum chalk-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "295635afd6853aa9f20baeb7f0204862440c0fe994c5a253d5f479dac41d047e"
31403140
"checksum chrono 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6962c635d530328acc53ac6a955e83093fedc91c5809dfac1fa60fa470830a37"
31413141
"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"

src/doc/unstable-book/src/language-features/crate-in-paths.md

+2-7
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ The tracking issue for this feature is: [#44660]
99
The `crate_in_paths` feature allows to explicitly refer to the crate root in absolute paths
1010
using keyword `crate`.
1111

12-
`crate` can be used *only* in absolute paths, i.e. either in `::crate::a::b::c` form or in `use`
13-
items where the starting `::` is added implicitly.
14-
Paths like `crate::a::b::c` are not accepted currently.
15-
1612
This feature is required in `feature(extern_absolute_paths)` mode to refer to any absolute path
1713
in the local crate (absolute paths refer to extern crates by default in that mode), but can be
1814
used without `feature(extern_absolute_paths)` as well.
@@ -39,15 +35,14 @@ mod n
3935
use crate as root;
4036
pub fn check() {
4137
assert_eq!(f(), 1);
42-
// `::` is required in non-import paths
43-
assert_eq!(::crate::m::g(), 2);
38+
assert_eq!(crate::m::g(), 2);
4439
assert_eq!(root::m::h(), 3);
4540
}
4641
}
4742

4843
fn main() {
4944
assert_eq!(f(), 1);
50-
assert_eq!(::crate::m::g(), 2);
45+
assert_eq!(crate::m::g(), 2);
5146
assert_eq!(root::m::h(), 3);
5247
n::check();
5348
}

src/doc/unstable-book/src/language-features/extern-absolute-paths.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The `extern_absolute_paths` feature enables mode allowing to refer to names from
1212
`::my_crate::a::b` will resolve to path `a::b` in crate `my_crate`.
1313

1414
`feature(crate_in_paths)` can be used in `feature(extern_absolute_paths)` mode for referring
15-
to absolute paths in the local crate (`::crate::a::b`).
15+
to absolute paths in the local crate (`crate::a::b`).
1616

1717
`feature(extern_in_paths)` provides the same effect by using keyword `extern` to refer to
1818
paths from other crates (`extern::my_crate::a::b`).

src/etc/debugger_pretty_printers_common.py

+21
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
TYPE_KIND_OS_STRING = 18
5050
TYPE_KIND_STD_VECDEQUE = 19
5151
TYPE_KIND_STD_BTREESET = 20
52+
TYPE_KIND_STD_BTREEMAP = 21
5253

5354
ENCODED_ENUM_PREFIX = "RUST$ENCODED$ENUM$"
5455
ENUM_DISR_FIELD_NAME = "RUST$ENUM$DISR"
@@ -75,6 +76,9 @@
7576
# std::collections::BTreeSet<> related constants
7677
STD_BTREESET_FIELD_NAMES = ["map"]
7778

79+
# std::collections::BTreeMap<> related constants
80+
STD_BTREEMAP_FIELD_NAMES = ["root", "length"]
81+
7882
# std::String related constants
7983
STD_STRING_FIELD_NAMES = ["vec"]
8084

@@ -184,6 +188,11 @@ def __classify_struct(self):
184188
self.__conforms_to_field_layout(STD_BTREESET_FIELD_NAMES)):
185189
return TYPE_KIND_STD_BTREESET
186190

191+
# STD COLLECTION BTREEMAP
192+
if (unqualified_type_name.startswith("BTreeMap<") and
193+
self.__conforms_to_field_layout(STD_BTREEMAP_FIELD_NAMES)):
194+
return TYPE_KIND_STD_BTREEMAP
195+
187196
# STD STRING
188197
if (unqualified_type_name.startswith("String") and
189198
self.__conforms_to_field_layout(STD_STRING_FIELD_NAMES)):
@@ -380,6 +389,18 @@ def extract_length_and_ptr_from_std_btreeset(vec_val):
380389
return (length, data_ptr)
381390

382391

392+
def extract_length_and_ptr_from_std_btreemap(vec_val):
393+
assert vec_val.type.get_type_kind() == TYPE_KIND_STD_BTREEMAP
394+
root = vec_val.get_child_at_index(0)
395+
length = vec_val.get_child_at_index(1).as_integer()
396+
node = root.get_child_at_index(0)
397+
ptr = node.get_child_at_index(0)
398+
unique_ptr_val = ptr.get_child_at_index(0)
399+
data_ptr = unique_ptr_val.get_child_at_index(0)
400+
assert data_ptr.type.get_dwarf_type_kind() == DWARF_TYPE_CODE_PTR
401+
return (length, data_ptr)
402+
403+
383404
def extract_length_and_ptr_from_slice(slice_val):
384405
assert (slice_val.type.get_type_kind() == TYPE_KIND_SLICE or
385406
slice_val.type.get_type_kind() == TYPE_KIND_STR_SLICE)

src/etc/gdb_rust_pretty_printing.py

+30
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ def rust_pretty_printer_lookup_function(gdb_val):
130130
if type_kind == rustpp.TYPE_KIND_STD_BTREESET:
131131
return RustStdBTreeSetPrinter(val)
132132

133+
if type_kind == rustpp.TYPE_KIND_STD_BTREEMAP:
134+
return RustStdBTreeMapPrinter(val)
135+
133136
if type_kind == rustpp.TYPE_KIND_STD_STRING:
134137
return RustStdStringPrinter(val)
135138

@@ -325,6 +328,32 @@ def children(self):
325328
yield (str(index), gdb_ptr[index])
326329

327330

331+
class RustStdBTreeMapPrinter(object):
332+
def __init__(self, val):
333+
self.__val = val
334+
335+
@staticmethod
336+
def display_hint():
337+
return "map"
338+
339+
def to_string(self):
340+
(length, data_ptr) = \
341+
rustpp.extract_length_and_ptr_from_std_btreemap(self.__val)
342+
return (self.__val.type.get_unqualified_type_name() +
343+
("(len: %i)" % length))
344+
345+
def children(self):
346+
(length, data_ptr) = \
347+
rustpp.extract_length_and_ptr_from_std_btreemap(self.__val)
348+
keys = GdbValue(data_ptr.get_wrapped_value().dereference()).get_child_at_index(3)
349+
keys_ptr = keys.get_wrapped_value()
350+
vals = GdbValue(data_ptr.get_wrapped_value().dereference()).get_child_at_index(4)
351+
vals_ptr = vals.get_wrapped_value()
352+
for index in xrange(length):
353+
yield (str(index), keys_ptr[index])
354+
yield (str(index), vals_ptr[index])
355+
356+
328357
class RustStdStringPrinter(object):
329358
def __init__(self, val):
330359
self.__val = val
@@ -338,6 +367,7 @@ def to_string(self):
338367
def display_hint(self):
339368
return "string"
340369

370+
341371
class RustOsStringPrinter(object):
342372
def __init__(self, val):
343373
self.__val = val

src/libcore/num/mod.rs

+90-18
Original file line numberDiff line numberDiff line change
@@ -1891,7 +1891,7 @@ $EndFeature, "
18911891
/// ```
18921892
/// #![feature(int_to_from_bytes)]
18931893
///
1894-
/// let bytes = 0x12345678i32.to_be_bytes();
1894+
/// let bytes = 0x12_34_56_78_i32.to_be_bytes();
18951895
/// assert_eq!(bytes, [0x12, 0x34, 0x56, 0x78]);
18961896
/// ```
18971897
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
@@ -1908,7 +1908,7 @@ $EndFeature, "
19081908
/// ```
19091909
/// #![feature(int_to_from_bytes)]
19101910
///
1911-
/// let bytes = 0x12345678i32.to_le_bytes();
1911+
/// let bytes = 0x12_34_56_78_i32.to_le_bytes();
19121912
/// assert_eq!(bytes, [0x78, 0x56, 0x34, 0x12]);
19131913
/// ```
19141914
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
@@ -3568,47 +3568,119 @@ $EndFeature, "
35683568
}
35693569
}
35703570

3571-
/// Return the memory representation of this integer as a byte array.
3571+
/// Return the memory representation of this integer as a byte array in
3572+
/// big-endian (network) byte order.
3573+
///
3574+
/// # Examples
35723575
///
3573-
/// The target platform’s native endianness is used.
3574-
/// Portable code likely wants to use this after [`to_be`] or [`to_le`].
3576+
/// ```
3577+
/// #![feature(int_to_from_bytes)]
35753578
///
3576-
/// [`to_be`]: #method.to_be
3577-
/// [`to_le`]: #method.to_le
3579+
/// let bytes = 0x12_34_56_78_i32.to_be_bytes();
3580+
/// assert_eq!(bytes, [0x12, 0x34, 0x56, 0x78]);
3581+
/// ```
3582+
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
3583+
#[inline]
3584+
pub fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
3585+
self.to_be().to_ne_bytes()
3586+
}
3587+
3588+
/// Return the memory representation of this integer as a byte array in
3589+
/// little-endian byte order.
35783590
///
35793591
/// # Examples
35803592
///
35813593
/// ```
35823594
/// #![feature(int_to_from_bytes)]
35833595
///
3584-
/// let bytes = 0x1234_5678_u32.to_be().to_bytes();
3585-
/// assert_eq!(bytes, [0x12, 0x34, 0x56, 0x78]);
3596+
/// let bytes = 0x12_34_56_78_i32.to_le_bytes();
3597+
/// assert_eq!(bytes, [0x78, 0x56, 0x34, 0x12]);
3598+
/// ```
3599+
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
3600+
#[inline]
3601+
pub fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
3602+
self.to_le().to_ne_bytes()
3603+
}
3604+
3605+
/// Return the memory representation of this integer as a byte array in
3606+
/// native byte order.
3607+
///
3608+
/// As the target platform's native endianness is used, portable code
3609+
/// should use [`to_be_bytes`] or [`to_le_bytes`], as appropriate,
3610+
/// instead.
3611+
///
3612+
/// [`to_be_bytes`]: #method.to_be_bytes
3613+
/// [`to_le_bytes`]: #method.to_le_bytes
3614+
///
3615+
/// # Examples
3616+
///
3617+
/// ```
3618+
/// #![feature(int_to_from_bytes)]
3619+
///
3620+
/// let bytes = i32::min_value().to_be().to_ne_bytes();
3621+
/// assert_eq!(bytes, [0x80, 0, 0, 0]);
35863622
/// ```
35873623
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
35883624
#[inline]
3589-
pub fn to_bytes(self) -> [u8; mem::size_of::<Self>()] {
3625+
pub fn to_ne_bytes(self) -> [u8; mem::size_of::<Self>()] {
35903626
unsafe { mem::transmute(self) }
35913627
}
35923628

3593-
/// Create an integer value from its memory representation as a byte array.
3629+
/// Create an integer value from its representation as a byte array in
3630+
/// big endian.
3631+
///
3632+
/// # Examples
35943633
///
3595-
/// The target platform’s native endianness is used.
3596-
/// Portable code likely wants to use [`to_be`] or [`to_le`] after this.
3634+
/// ```
3635+
/// #![feature(int_to_from_bytes)]
35973636
///
3598-
/// [`to_be`]: #method.to_be
3599-
/// [`to_le`]: #method.to_le
3637+
/// let int = i32::from_be_bytes([0x12, 0x34, 0x56, 0x78]);
3638+
/// assert_eq!(int, 0x12_34_56_78);
3639+
/// ```
3640+
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
3641+
#[inline]
3642+
pub fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
3643+
Self::from_be(Self::from_ne_bytes(bytes))
3644+
}
3645+
3646+
/// Create an integer value from its representation as a byte array in
3647+
/// little endian.
36003648
///
36013649
/// # Examples
36023650
///
36033651
/// ```
36043652
/// #![feature(int_to_from_bytes)]
36053653
///
3606-
/// let int = u32::from_be(u32::from_bytes([0x12, 0x34, 0x56, 0x78]));
3607-
/// assert_eq!(int, 0x1234_5678_u32);
3654+
/// let int = i32::from_le_bytes([0x12, 0x34, 0x56, 0x78]);
3655+
/// assert_eq!(int, 0x78_56_34_12);
36083656
/// ```
36093657
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
36103658
#[inline]
3611-
pub fn from_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
3659+
pub fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
3660+
Self::from_le(Self::from_ne_bytes(bytes))
3661+
}
3662+
3663+
/// Create an integer value from its memory representation as a byte
3664+
/// array in native endianness.
3665+
///
3666+
/// As the target platform's native endianness is used, portable code
3667+
/// likely wants to use [`from_be_bytes`] or [`from_le_bytes`], as
3668+
/// appropriate instead.
3669+
///
3670+
/// [`from_be_bytes`]: #method.from_be_bytes
3671+
/// [`from_le_bytes`]: #method.from_le_bytes
3672+
///
3673+
/// # Examples
3674+
///
3675+
/// ```
3676+
/// #![feature(int_to_from_bytes)]
3677+
///
3678+
/// let int = i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0]));
3679+
/// assert_eq!(int, i32::min_value());
3680+
/// ```
3681+
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
3682+
#[inline]
3683+
pub fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
36123684
unsafe { mem::transmute(bytes) }
36133685
}
36143686
}

src/librustc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ syntax_pos = { path = "../libsyntax_pos" }
3131
backtrace = "0.3.3"
3232
parking_lot = "0.5.5"
3333
byteorder = { version = "1.1", features = ["i128"]}
34-
chalk-engine = { version = "0.6.0", default-features=false }
34+
chalk-engine = { version = "0.7.0", default-features=false }
3535
rustc_fs_util = { path = "../librustc_fs_util" }
3636

3737
# Note that these dependencies are a lie, they're just here to get linkage to

src/librustc/traits/util.rs

+4
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ impl<'cx, 'gcx, 'tcx> Elaborator<'cx, 'gcx, 'tcx> {
239239
impl<'cx, 'gcx, 'tcx> Iterator for Elaborator<'cx, 'gcx, 'tcx> {
240240
type Item = ty::Predicate<'tcx>;
241241

242+
fn size_hint(&self) -> (usize, Option<usize>) {
243+
(self.stack.len(), None)
244+
}
245+
242246
fn next(&mut self) -> Option<ty::Predicate<'tcx>> {
243247
// Extract next item from top-most stack frame, if any.
244248
let next_predicate = match self.stack.pop() {

src/librustc_codegen_llvm/back/linker.rs

-12
Original file line numberDiff line numberDiff line change
@@ -1006,18 +1006,6 @@ impl<'a> Linker for WasmLd<'a> {
10061006
OptLevel::Size => "-O2",
10071007
OptLevel::SizeMin => "-O2"
10081008
});
1009-
match self.sess.opts.optimize {
1010-
OptLevel::No => (),
1011-
OptLevel::Less |
1012-
OptLevel::Default |
1013-
OptLevel::Aggressive |
1014-
OptLevel::Size |
1015-
OptLevel::SizeMin => {
1016-
// LLD generates incorrect debugging information when
1017-
// optimization is applied: strip debug sections.
1018-
self.cmd.arg("--strip-debug");
1019-
}
1020-
}
10211009
}
10221010

10231011
fn pgo_gen(&mut self) {

0 commit comments

Comments
 (0)