Skip to content

Rollup of 12 pull requests #75238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7f54cf2
compiletest: ignore-endian-big, fixes #74829, fixes #74885
infinity0 Jul 31, 2020
725d37c
Make doctests of Ipv4Addr::from(u32) easier to read
tesuji Aug 5, 2020
d9f260e
Remove unused FromInner impl for Ipv4Addr
tesuji Aug 5, 2020
188ef3a
Fix typo in `librustc_feature/active.rs`
WaffleLapkin Aug 5, 2020
0d8260e
Label rustfmt toolstate issues with A-rustfmt
Aaron1011 Aug 5, 2020
48bc398
Handle fieldless tuple structs in diagnostic code
Aaron1011 Aug 5, 2020
cd46339
Clean up E0746 explanation
GuillaumeGomez Aug 5, 2020
eff7d56
Note about endianness of returned value
tesuji Aug 6, 2020
57b517b
Clean up E0747 explanation
GuillaumeGomez Aug 6, 2020
ebbf07a
Change the type of `AssertModuleSource::available_cgus`.
nnethercote Aug 6, 2020
6eeae7d
Fix typo "TraitObligatiom" -> "TraitObligation"
leijurv Aug 6, 2020
b809f45
Fix typo "biset" -> "bitset"
syntacticsugarglider Aug 6, 2020
9d5bd59
Rollup merge of #74888 - infinity0:ignore-endian-big, r=nikomatsakis
JohnTitor Aug 7, 2020
c9c7048
Rollup merge of #75175 - lzutao:doctest-ipv4-fromu32, r=cuviper
JohnTitor Aug 7, 2020
1b61fd3
Rollup merge of #75179 - lzutao:unsed-ipv4-frominner, r=alexcrichton
JohnTitor Aug 7, 2020
d36087b
Rollup merge of #75181 - WaffleLapkin:patch-2, r=ecstaticmorse
JohnTitor Aug 7, 2020
5542fba
Rollup merge of #75183 - Aaron1011:toolstate/a-rustfmt, r=nikomatsakis
JohnTitor Aug 7, 2020
665138c
Rollup merge of #75188 - Aaron1011:fix/fieldless-tuple-error, r=varkor
JohnTitor Aug 7, 2020
f49e473
Rollup merge of #75190 - GuillaumeGomez:cleanup-e0746, r=Dylan-DPC
JohnTitor Aug 7, 2020
19d4e1d
Rollup merge of #75210 - nnethercote:change-type-of-available_cgus, r…
JohnTitor Aug 7, 2020
26705d5
Rollup merge of #75211 - lzutao:native-endian-notes, r=lcnr
JohnTitor Aug 7, 2020
76086a2
Rollup merge of #75217 - GuillaumeGomez:cleanup-e0747, r=Dylan-DPC
JohnTitor Aug 7, 2020
6f2fa1e
Rollup merge of #75232 - leijurv:patch-1, r=jonas-schievink
JohnTitor Aug 7, 2020
3c131d6
Rollup merge of #75236 - syntacticsugarglider:patch-1, r=jonas-schievink
JohnTitor Aug 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions library/core/src/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4383,8 +4383,8 @@ assert_eq!(
}

doc_comment! {
concat!("Create an integer value from its representation as a byte array in
big endian.
concat!("Create a native endian integer value from its representation
as a byte array in big endian.
",
$from_xe_bytes_doc,
"
Expand Down Expand Up @@ -4416,8 +4416,8 @@ fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),

doc_comment! {
concat!("
Create an integer value from its representation as a byte array in
little endian.
Create a native endian integer value from its representation
as a byte array in little endian.
",
$from_xe_bytes_doc,
"
Expand Down Expand Up @@ -4448,8 +4448,8 @@ fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
}

doc_comment! {
concat!("Create an integer value from its memory representation as a byte
array in native endianness.
concat!("Create a native endian 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
Expand Down
13 changes: 4 additions & 9 deletions library/std/src/net/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,11 +961,6 @@ impl AsInner<c::in_addr> for Ipv4Addr {
&self.inner
}
}
impl FromInner<c::in_addr> for Ipv4Addr {
fn from_inner(addr: c::in_addr) -> Ipv4Addr {
Ipv4Addr { inner: addr }
}
}

#[stable(feature = "ip_u32", since = "1.1.0")]
impl From<Ipv4Addr> for u32 {
Expand All @@ -976,8 +971,8 @@ impl From<Ipv4Addr> for u32 {
/// ```
/// use std::net::Ipv4Addr;
///
/// let addr = Ipv4Addr::new(13, 12, 11, 10);
/// assert_eq!(0x0d0c0b0au32, u32::from(addr));
/// let addr = Ipv4Addr::new(0xca, 0xfe, 0xba, 0xbe);
/// assert_eq!(0xcafebabe, u32::from(addr));
/// ```
fn from(ip: Ipv4Addr) -> u32 {
let ip = ip.octets();
Expand All @@ -994,8 +989,8 @@ impl From<u32> for Ipv4Addr {
/// ```
/// use std::net::Ipv4Addr;
///
/// let addr = Ipv4Addr::from(0x0d0c0b0au32);
/// assert_eq!(Ipv4Addr::new(13, 12, 11, 10), addr);
/// let addr = Ipv4Addr::from(0xcafebabe);
/// assert_eq!(Ipv4Addr::new(0xca, 0xfe, 0xba, 0xbe), addr);
/// ```
fn from(ip: u32) -> Ipv4Addr {
Ipv4Addr::from(ip.to_be_bytes())
Expand Down
10 changes: 6 additions & 4 deletions src/librustc_error_codes/error_codes/E0746.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Return types cannot be `dyn Trait`s as they must be `Sized`.
An unboxed trait object was used as a return value.

Erroneous code example:

Expand All @@ -13,11 +13,13 @@ impl T for S {

// Having the trait `T` as return type is invalid because
// unboxed trait objects do not have a statically known size:
fn foo() -> dyn T {
fn foo() -> dyn T { // error!
S(42)
}
```

Return types cannot be `dyn Trait`s as they must be `Sized`.

To avoid the error there are a couple of options.

If there is a single type involved, you can use [`impl Trait`]:
Expand All @@ -32,7 +34,7 @@ If there is a single type involved, you can use [`impl Trait`]:
# }
// The compiler will select `S(usize)` as the materialized return type of this
// function, but callers will only know that the return type implements `T`.
fn foo() -> impl T {
fn foo() -> impl T { // ok!
S(42)
}
```
Expand All @@ -57,7 +59,7 @@ impl T for O {

// This now returns a "trait object" and callers are only be able to access
// associated items from `T`.
fn foo(x: bool) -> Box<dyn T> {
fn foo(x: bool) -> Box<dyn T> { // ok!
if x {
Box::new(S(42))
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_error_codes/error_codes/E0747.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Generic arguments must be provided in the same order as the corresponding
Generic arguments were not provided in the same order as the corresponding
generic parameters are declared.

Erroneous code example:
Expand All @@ -11,7 +11,7 @@ type X = S<(), 'static>; // error: the type argument is provided before the
```

The argument order should be changed to match the parameter declaration
order, as in the following.
order, as in the following:

```
struct S<'a, T>(&'a T);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_feature/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ declare_features! (
/// Lazily evaluate constants. This allows constants to depend on type parameters.
(active, lazy_normalization_consts, "1.46.0", Some(72219), None),

/// Alloc calling `transmute` in const fn
/// Allows calling `transmute` in const fn
(active, const_fn_transmute, "1.46.0", Some(53605), None),

// -------------------------------------------------------------------------
Expand Down
11 changes: 5 additions & 6 deletions src/librustc_incremental/assert_module_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>) {
.collect_and_partition_mono_items(LOCAL_CRATE)
.1
.iter()
.map(|cgu| cgu.name())
.collect::<BTreeSet<Symbol>>();
.map(|cgu| cgu.name().to_string())
.collect::<BTreeSet<String>>();

let ams = AssertModuleSource { tcx, available_cgus };

Expand All @@ -52,7 +52,7 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>) {

struct AssertModuleSource<'tcx> {
tcx: TyCtxt<'tcx>,
available_cgus: BTreeSet<Symbol>,
available_cgus: BTreeSet<String>,
}

impl AssertModuleSource<'tcx> {
Expand Down Expand Up @@ -121,12 +121,11 @@ impl AssertModuleSource<'tcx> {

debug!("mapping '{}' to cgu name '{}'", self.field(attr, sym::module), cgu_name);

if !self.available_cgus.contains(&cgu_name) {
if !self.available_cgus.contains(&*cgu_name.as_str()) {
self.tcx.sess.span_err(
attr.span,
&format!(
"no module named `{}` (mangled: {}). \
Available modules: {}",
"no module named `{}` (mangled: {}). Available modules: {}",
user_path,
cgu_name,
self.available_cgus
Expand Down
7 changes: 3 additions & 4 deletions src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,10 +1075,9 @@ impl<'a> Resolver<'a> {
) = binding.kind
{
let def_id = (&*self).parent(ctor_def_id).expect("no parent for a constructor");
if let Some(fields) = self.field_names.get(&def_id) {
let first_field = fields.first().expect("empty field list in the map");
return Some(fields.iter().fold(first_field.span, |acc, field| acc.to(field.span)));
}
let fields = self.field_names.get(&def_id)?;
let first_field = fields.first()?; // Handle `struct Foo()`
return Some(fields.iter().fold(first_field.span, |acc, field| acc.to(field.span)));
}
None
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trait_selection/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
obligation
);

// `previous_stack` stores a `TraitObligatiom`, while `obligation` is
// `previous_stack` stores a `TraitObligation`, while `obligation` is
// a `PredicateObligation`. These are distinct types, so we can't
// use any `Option` combinator method that would force them to be
// the same.
Expand Down
2 changes: 1 addition & 1 deletion src/test/mir-opt/const-promotion-extern-static.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ignore-endian-big
extern "C" {
static X: i32;
}

static Y: i32 = 42;

// EMIT_MIR const_promotion_extern_static.BAR.PromoteTemps.diff
Expand Down
2 changes: 1 addition & 1 deletion src/test/mir-opt/const_allocation.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ignore-endian-big
// EMIT_MIR_FOR_EACH_BIT_WIDTH

static FOO: &[(Option<i32>, &[&str])] =
&[(None, &[]), (None, &["foo", "bar"]), (Some(42), &["meh", "mop", "möp"])];

Expand Down
2 changes: 1 addition & 1 deletion src/test/mir-opt/const_allocation2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ignore-endian-big
// EMIT_MIR_FOR_EACH_BIT_WIDTH

// EMIT_MIR const_allocation2.main.ConstProp.after.mir
fn main() {
FOO;
Expand Down
2 changes: 1 addition & 1 deletion src/test/mir-opt/const_allocation3.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ignore-endian-big
// EMIT_MIR_FOR_EACH_BIT_WIDTH

// EMIT_MIR const_allocation3.main.ConstProp.after.mir
fn main() {
FOO;
Expand Down
2 changes: 1 addition & 1 deletion src/test/mir-opt/inline/inline-into-box-place.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// ignore-endian-big
// ignore-wasm32-bare compiled with panic=abort by default
// compile-flags: -Z mir-opt-level=3
// EMIT_MIR_FOR_EACH_BIT_WIDTH
#![feature(box_syntax)]

// EMIT_MIR inline_into_box_place.main.Inline.diff
fn main() {
let _x: Box<Vec<u32>> = box Vec::new();
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/privacy/issue-75062-fieldless-tuple-struct.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Regression test for issue #75062
// Tests that we don't ICE on a privacy error for a fieldless tuple struct.

mod foo {
struct Bar();
}

fn main() {
foo::Bar(); //~ ERROR tuple struct
}
15 changes: 15 additions & 0 deletions src/test/ui/privacy/issue-75062-fieldless-tuple-struct.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0603]: tuple struct `Bar` is private
--> $DIR/issue-75062-fieldless-tuple-struct.rs:9:10
|
LL | foo::Bar();
| ^^^ private tuple struct
|
note: the tuple struct `Bar` is defined here
--> $DIR/issue-75062-fieldless-tuple-struct.rs:5:5
|
LL | struct Bar();
| ^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0603`.
1 change: 1 addition & 0 deletions src/test/ui/simd/simd-intrinsic-generic-bitmask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![allow(non_camel_case_types)]

// ignore-emscripten
// ignore-endian-big behavior of simd_bitmask is endian-specific

// Test that the simd_bitmask intrinsic produces correct results.

Expand Down
5 changes: 1 addition & 4 deletions src/test/ui/simd/simd-intrinsic-generic-select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
#![allow(non_camel_case_types)]

// ignore-emscripten
// ignore-mips behavior of simd_select_bitmask is endian-specific
// ignore-mips64 behavior of simd_select_bitmask is endian-specific
// ignore-powerpc behavior of simd_select_bitmask is endian-specific
// ignore-powerpc64 behavior of simd_select_bitmask is endian-specific
// ignore-endian-big behavior of simd_select_bitmask is endian-specific

// Test that the simd_select intrinsics produces correct results.

Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ impl Config {
name == util::get_pointer_width(&self.target) || // pointer width
name == self.stage_id.split('-').next().unwrap() || // stage
(self.target != self.host && name == "cross-compile") ||
(name == "endian-big" && util::is_big_endian(&self.target)) ||
(self.remote_test_client.is_some() && name == "remote") ||
match self.compare_mode {
Some(CompareMode::Nll) => name == "compare-mode-nll",
Expand Down
20 changes: 20 additions & 0 deletions src/tools/compiletest/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ pub const MSAN_SUPPORTED_TARGETS: &'static [&'static str] =
pub const TSAN_SUPPORTED_TARGETS: &'static [&'static str] =
&["aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu"];

const BIG_ENDIAN: &'static [&'static str] = &[
"armebv7r",
"mips",
"mips64",
"mipsisa32r6",
"mipsisa64r6",
"powerpc",
"powerpc64",
"s390x",
"sparc",
"sparc64",
"sparcv9",
];

pub fn matches_os(triple: &str, name: &str) -> bool {
// For the wasm32 bare target we ignore anything also ignored on emscripten
// and then we also recognize `wasm32-bare` as the os for the target
Expand All @@ -125,6 +139,12 @@ pub fn get_arch(triple: &str) -> &'static str {
panic!("Cannot determine Architecture from triple");
}

/// Determine the endianness from `triple`
pub fn is_big_endian(triple: &str) -> bool {
let triple_arch = triple.split('-').next().unwrap();
BIG_ENDIAN.contains(&triple_arch)
}

pub fn matches_env(triple: &str, name: &str) -> bool {
if let Some(env) = triple.split('-').nth(3) { env.starts_with(name) } else { false }
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/publish_toolstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
LABELS = {
'miri': ['A-miri', 'C-bug'],
'rls': ['A-rls', 'C-bug'],
'rustfmt': ['C-bug'],
'rustfmt': ['A-rustfmt', 'C-bug'],
'book': ['C-bug'],
'nomicon': ['C-bug'],
'reference': ['C-bug'],
Expand Down
2 changes: 1 addition & 1 deletion src/tools/unicode-table-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! We have two separate encoding schemes: a skiplist-like approach, and a
//! compressed bitset. The datasets we consider mostly use the skiplist (it's
//! smaller) but the lowercase and uppercase sets are sufficiently sparse for
//! the bitset to be worthwhile -- for those sets the biset is a 2x size win.
//! the bitset to be worthwhile -- for those sets the bitset is a 2x size win.
//! Since the bitset is also faster, this seems an obvious choice. (As a
//! historical note, the bitset was also the prior implementation, so its
//! relative complexity had already been paid).
Expand Down