Skip to content

Commit

Permalink
Auto merge of #53449 - frewsxcv:rollup, r=frewsxcv
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Aug 17, 2018
2 parents 8dad6be + f214666 commit de21ea8
Show file tree
Hide file tree
Showing 73 changed files with 750 additions and 183 deletions.
8 changes: 4 additions & 4 deletions src/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "chalk-engine"
version = "0.6.0"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"chalk-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -1897,7 +1897,7 @@ dependencies = [
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"chalk-engine 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"chalk-engine 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fmt_macros 0.0.0",
"graphviz 0.0.0",
Expand Down Expand Up @@ -2408,7 +2408,7 @@ name = "rustc_traits"
version = "0.0.0"
dependencies = [
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"chalk-engine 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"chalk-engine 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"graphviz 0.0.0",
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
Expand Down Expand Up @@ -3135,7 +3135,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d6809b327f87369e6f3651efd2c5a96c49847a3ed2559477ecba79014751ee1"
"checksum cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "2119ea4867bd2b8ed3aecab467709720b2d55b1bcfe09f772fd68066eaf15275"
"checksum cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efe5c877e17a9c717a0bf3613b2709f723202c4e4675cc8f12926ded29bcb17e"
"checksum chalk-engine 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a146c19172c7eea48ea55a7123ac95da786639bc665097f1e14034ee5f1d8699"
"checksum chalk-engine 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "25ce2f28f55ed544a2a3756b7acf41dd7d6f27acffb2086439950925506af7d0"
"checksum chalk-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "295635afd6853aa9f20baeb7f0204862440c0fe994c5a253d5f479dac41d047e"
"checksum chrono 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6962c635d530328acc53ac6a955e83093fedc91c5809dfac1fa60fa470830a37"
"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
Expand Down
9 changes: 2 additions & 7 deletions src/doc/unstable-book/src/language-features/crate-in-paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ The tracking issue for this feature is: [#44660]
The `crate_in_paths` feature allows to explicitly refer to the crate root in absolute paths
using keyword `crate`.

`crate` can be used *only* in absolute paths, i.e. either in `::crate::a::b::c` form or in `use`
items where the starting `::` is added implicitly.
Paths like `crate::a::b::c` are not accepted currently.

This feature is required in `feature(extern_absolute_paths)` mode to refer to any absolute path
in the local crate (absolute paths refer to extern crates by default in that mode), but can be
used without `feature(extern_absolute_paths)` as well.
Expand All @@ -39,15 +35,14 @@ mod n
use crate as root;
pub fn check() {
assert_eq!(f(), 1);
// `::` is required in non-import paths
assert_eq!(::crate::m::g(), 2);
assert_eq!(crate::m::g(), 2);
assert_eq!(root::m::h(), 3);
}
}

fn main() {
assert_eq!(f(), 1);
assert_eq!(::crate::m::g(), 2);
assert_eq!(crate::m::g(), 2);
assert_eq!(root::m::h(), 3);
n::check();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The `extern_absolute_paths` feature enables mode allowing to refer to names from
`::my_crate::a::b` will resolve to path `a::b` in crate `my_crate`.

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

`feature(extern_in_paths)` provides the same effect by using keyword `extern` to refer to
paths from other crates (`extern::my_crate::a::b`).
Expand Down
21 changes: 21 additions & 0 deletions src/etc/debugger_pretty_printers_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
TYPE_KIND_OS_STRING = 18
TYPE_KIND_STD_VECDEQUE = 19
TYPE_KIND_STD_BTREESET = 20
TYPE_KIND_STD_BTREEMAP = 21

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

# std::collections::BTreeMap<> related constants
STD_BTREEMAP_FIELD_NAMES = ["root", "length"]

# std::String related constants
STD_STRING_FIELD_NAMES = ["vec"]

Expand Down Expand Up @@ -184,6 +188,11 @@ def __classify_struct(self):
self.__conforms_to_field_layout(STD_BTREESET_FIELD_NAMES)):
return TYPE_KIND_STD_BTREESET

# STD COLLECTION BTREEMAP
if (unqualified_type_name.startswith("BTreeMap<") and
self.__conforms_to_field_layout(STD_BTREEMAP_FIELD_NAMES)):
return TYPE_KIND_STD_BTREEMAP

# STD STRING
if (unqualified_type_name.startswith("String") and
self.__conforms_to_field_layout(STD_STRING_FIELD_NAMES)):
Expand Down Expand Up @@ -380,6 +389,18 @@ def extract_length_and_ptr_from_std_btreeset(vec_val):
return (length, data_ptr)


def extract_length_and_ptr_from_std_btreemap(vec_val):
assert vec_val.type.get_type_kind() == TYPE_KIND_STD_BTREEMAP
root = vec_val.get_child_at_index(0)
length = vec_val.get_child_at_index(1).as_integer()
node = root.get_child_at_index(0)
ptr = node.get_child_at_index(0)
unique_ptr_val = ptr.get_child_at_index(0)
data_ptr = unique_ptr_val.get_child_at_index(0)
assert data_ptr.type.get_dwarf_type_kind() == DWARF_TYPE_CODE_PTR
return (length, data_ptr)


def extract_length_and_ptr_from_slice(slice_val):
assert (slice_val.type.get_type_kind() == TYPE_KIND_SLICE or
slice_val.type.get_type_kind() == TYPE_KIND_STR_SLICE)
Expand Down
30 changes: 30 additions & 0 deletions src/etc/gdb_rust_pretty_printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ def rust_pretty_printer_lookup_function(gdb_val):
if type_kind == rustpp.TYPE_KIND_STD_BTREESET:
return RustStdBTreeSetPrinter(val)

if type_kind == rustpp.TYPE_KIND_STD_BTREEMAP:
return RustStdBTreeMapPrinter(val)

if type_kind == rustpp.TYPE_KIND_STD_STRING:
return RustStdStringPrinter(val)

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


class RustStdBTreeMapPrinter(object):
def __init__(self, val):
self.__val = val

@staticmethod
def display_hint():
return "map"

def to_string(self):
(length, data_ptr) = \
rustpp.extract_length_and_ptr_from_std_btreemap(self.__val)
return (self.__val.type.get_unqualified_type_name() +
("(len: %i)" % length))

def children(self):
(length, data_ptr) = \
rustpp.extract_length_and_ptr_from_std_btreemap(self.__val)
keys = GdbValue(data_ptr.get_wrapped_value().dereference()).get_child_at_index(3)
keys_ptr = keys.get_wrapped_value()
vals = GdbValue(data_ptr.get_wrapped_value().dereference()).get_child_at_index(4)
vals_ptr = vals.get_wrapped_value()
for index in xrange(length):
yield (str(index), keys_ptr[index])
yield (str(index), vals_ptr[index])


class RustStdStringPrinter(object):
def __init__(self, val):
self.__val = val
Expand All @@ -338,6 +367,7 @@ def to_string(self):
def display_hint(self):
return "string"


class RustOsStringPrinter(object):
def __init__(self, val):
self.__val = val
Expand Down
108 changes: 90 additions & 18 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,7 @@ $EndFeature, "
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let bytes = 0x12345678i32.to_be_bytes();
/// let bytes = 0x12_34_56_78_i32.to_be_bytes();
/// assert_eq!(bytes, [0x12, 0x34, 0x56, 0x78]);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
Expand All @@ -1908,7 +1908,7 @@ $EndFeature, "
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let bytes = 0x12345678i32.to_le_bytes();
/// let bytes = 0x12_34_56_78_i32.to_le_bytes();
/// assert_eq!(bytes, [0x78, 0x56, 0x34, 0x12]);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
Expand Down Expand Up @@ -3568,47 +3568,119 @@ $EndFeature, "
}
}

/// Return the memory representation of this integer as a byte array.
/// Return the memory representation of this integer as a byte array in
/// big-endian (network) byte order.
///
/// # Examples
///
/// The target platform’s native endianness is used.
/// Portable code likely wants to use this after [`to_be`] or [`to_le`].
/// ```
/// #![feature(int_to_from_bytes)]
///
/// [`to_be`]: #method.to_be
/// [`to_le`]: #method.to_le
/// let bytes = 0x12_34_56_78_i32.to_be_bytes();
/// assert_eq!(bytes, [0x12, 0x34, 0x56, 0x78]);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[inline]
pub fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
self.to_be().to_ne_bytes()
}

/// Return the memory representation of this integer as a byte array in
/// little-endian byte order.
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let bytes = 0x1234_5678_u32.to_be().to_bytes();
/// assert_eq!(bytes, [0x12, 0x34, 0x56, 0x78]);
/// let bytes = 0x12_34_56_78_i32.to_le_bytes();
/// assert_eq!(bytes, [0x78, 0x56, 0x34, 0x12]);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[inline]
pub fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
self.to_le().to_ne_bytes()
}

/// Return the memory representation of this integer as a byte array in
/// native byte order.
///
/// As the target platform's native endianness is used, portable code
/// should use [`to_be_bytes`] or [`to_le_bytes`], as appropriate,
/// instead.
///
/// [`to_be_bytes`]: #method.to_be_bytes
/// [`to_le_bytes`]: #method.to_le_bytes
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let bytes = i32::min_value().to_be().to_ne_bytes();
/// assert_eq!(bytes, [0x80, 0, 0, 0]);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[inline]
pub fn to_bytes(self) -> [u8; mem::size_of::<Self>()] {
pub fn to_ne_bytes(self) -> [u8; mem::size_of::<Self>()] {
unsafe { mem::transmute(self) }
}

/// Create an integer value from its memory representation as a byte array.
/// Create an integer value from its representation as a byte array in
/// big endian.
///
/// # Examples
///
/// The target platform’s native endianness is used.
/// Portable code likely wants to use [`to_be`] or [`to_le`] after this.
/// ```
/// #![feature(int_to_from_bytes)]
///
/// [`to_be`]: #method.to_be
/// [`to_le`]: #method.to_le
/// let int = i32::from_be_bytes([0x12, 0x34, 0x56, 0x78]);
/// assert_eq!(int, 0x12_34_56_78);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[inline]
pub fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
Self::from_be(Self::from_ne_bytes(bytes))
}

/// Create an integer value from its representation as a byte array in
/// little endian.
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let int = u32::from_be(u32::from_bytes([0x12, 0x34, 0x56, 0x78]));
/// assert_eq!(int, 0x1234_5678_u32);
/// let int = i32::from_le_bytes([0x12, 0x34, 0x56, 0x78]);
/// assert_eq!(int, 0x78_56_34_12);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[inline]
pub fn from_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
pub fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
Self::from_le(Self::from_ne_bytes(bytes))
}

/// Create an integer value from its memory representation as a byte
/// array in native endianness.
///
/// As the target platform's native endianness is used, portable code
/// likely wants to use [`from_be_bytes`] or [`from_le_bytes`], as
/// appropriate instead.
///
/// [`from_be_bytes`]: #method.from_be_bytes
/// [`from_le_bytes`]: #method.from_le_bytes
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let int = i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0]));
/// assert_eq!(int, i32::min_value());
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[inline]
pub fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
unsafe { mem::transmute(bytes) }
}
}
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_pos = { path = "../libsyntax_pos" }
backtrace = "0.3.3"
parking_lot = "0.5.5"
byteorder = { version = "1.1", features = ["i128"]}
chalk-engine = { version = "0.6.0", default-features=false }
chalk-engine = { version = "0.7.0", default-features=false }
rustc_fs_util = { path = "../librustc_fs_util" }

# Note that these dependencies are a lie, they're just here to get linkage to
Expand Down
4 changes: 4 additions & 0 deletions src/librustc/traits/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ impl<'cx, 'gcx, 'tcx> Elaborator<'cx, 'gcx, 'tcx> {
impl<'cx, 'gcx, 'tcx> Iterator for Elaborator<'cx, 'gcx, 'tcx> {
type Item = ty::Predicate<'tcx>;

fn size_hint(&self) -> (usize, Option<usize>) {
(self.stack.len(), None)
}

fn next(&mut self) -> Option<ty::Predicate<'tcx>> {
// Extract next item from top-most stack frame, if any.
let next_predicate = match self.stack.pop() {
Expand Down
12 changes: 0 additions & 12 deletions src/librustc_codegen_llvm/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1006,18 +1006,6 @@ impl<'a> Linker for WasmLd<'a> {
OptLevel::Size => "-O2",
OptLevel::SizeMin => "-O2"
});
match self.sess.opts.optimize {
OptLevel::No => (),
OptLevel::Less |
OptLevel::Default |
OptLevel::Aggressive |
OptLevel::Size |
OptLevel::SizeMin => {
// LLD generates incorrect debugging information when
// optimization is applied: strip debug sections.
self.cmd.arg("--strip-debug");
}
}
}

fn pgo_gen(&mut self) {
Expand Down
Loading

0 comments on commit de21ea8

Please sign in to comment.