Skip to content

Commit 6396dbb

Browse files
committed
Auto merge of rust-lang#75238 - JohnTitor:rollup-llbk0sq, r=JohnTitor
Rollup of 12 pull requests Successful merges: - rust-lang#74888 (compiletest: ignore-endian-big, fixes rust-lang#74829, fixes rust-lang#74885) - rust-lang#75175 (Make doctests of Ipv4Addr::from(u32) easier to read) - rust-lang#75179 (Remove unused FromInner impl for Ipv4Addr) - rust-lang#75181 (Fix typo in `librustc_feature/active.rs`) - rust-lang#75183 (Label rustfmt toolstate issues with A-rustfmt) - rust-lang#75188 (Handle fieldless tuple structs in diagnostic code) - rust-lang#75190 (Clean up E0746 explanation) - rust-lang#75210 (Change the type of `AssertModuleSource::available_cgus`.) - rust-lang#75211 (Note about endianness of returned value of {integer}::from_be_bytes and friends) - rust-lang#75217 (Clean up E0747 explanation) - rust-lang#75232 (Fix typo "TraitObligatiom" -> "TraitObligation") - rust-lang#75236 (Fix typo "biset" -> "bitset") Failed merges: r? @ghost
2 parents 71f8d0c + 3c131d6 commit 6396dbb

File tree

21 files changed

+83
-44
lines changed

21 files changed

+83
-44
lines changed

library/core/src/num/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -4383,8 +4383,8 @@ assert_eq!(
43834383
}
43844384

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

44174417
doc_comment! {
44184418
concat!("
4419-
Create an integer value from its representation as a byte array in
4420-
little endian.
4419+
Create a native endian integer value from its representation
4420+
as a byte array in little endian.
44214421
",
44224422
$from_xe_bytes_doc,
44234423
"
@@ -4448,8 +4448,8 @@ fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
44484448
}
44494449

44504450
doc_comment! {
4451-
concat!("Create an integer value from its memory representation as a byte
4452-
array in native endianness.
4451+
concat!("Create a native endian integer value from its memory representation
4452+
as a byte array in native endianness.
44534453
44544454
As the target platform's native endianness is used, portable code
44554455
likely wants to use [`from_be_bytes`] or [`from_le_bytes`], as

library/std/src/net/ip.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -961,11 +961,6 @@ impl AsInner<c::in_addr> for Ipv4Addr {
961961
&self.inner
962962
}
963963
}
964-
impl FromInner<c::in_addr> for Ipv4Addr {
965-
fn from_inner(addr: c::in_addr) -> Ipv4Addr {
966-
Ipv4Addr { inner: addr }
967-
}
968-
}
969964

970965
#[stable(feature = "ip_u32", since = "1.1.0")]
971966
impl From<Ipv4Addr> for u32 {
@@ -976,8 +971,8 @@ impl From<Ipv4Addr> for u32 {
976971
/// ```
977972
/// use std::net::Ipv4Addr;
978973
///
979-
/// let addr = Ipv4Addr::new(13, 12, 11, 10);
980-
/// assert_eq!(0x0d0c0b0au32, u32::from(addr));
974+
/// let addr = Ipv4Addr::new(0xca, 0xfe, 0xba, 0xbe);
975+
/// assert_eq!(0xcafebabe, u32::from(addr));
981976
/// ```
982977
fn from(ip: Ipv4Addr) -> u32 {
983978
let ip = ip.octets();
@@ -994,8 +989,8 @@ impl From<u32> for Ipv4Addr {
994989
/// ```
995990
/// use std::net::Ipv4Addr;
996991
///
997-
/// let addr = Ipv4Addr::from(0x0d0c0b0au32);
998-
/// assert_eq!(Ipv4Addr::new(13, 12, 11, 10), addr);
992+
/// let addr = Ipv4Addr::from(0xcafebabe);
993+
/// assert_eq!(Ipv4Addr::new(0xca, 0xfe, 0xba, 0xbe), addr);
999994
/// ```
1000995
fn from(ip: u32) -> Ipv4Addr {
1001996
Ipv4Addr::from(ip.to_be_bytes())

src/librustc_error_codes/error_codes/E0746.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Return types cannot be `dyn Trait`s as they must be `Sized`.
1+
An unboxed trait object was used as a return value.
22

33
Erroneous code example:
44

@@ -13,11 +13,13 @@ impl T for S {
1313
1414
// Having the trait `T` as return type is invalid because
1515
// unboxed trait objects do not have a statically known size:
16-
fn foo() -> dyn T {
16+
fn foo() -> dyn T { // error!
1717
S(42)
1818
}
1919
```
2020

21+
Return types cannot be `dyn Trait`s as they must be `Sized`.
22+
2123
To avoid the error there are a couple of options.
2224

2325
If there is a single type involved, you can use [`impl Trait`]:
@@ -32,7 +34,7 @@ If there is a single type involved, you can use [`impl Trait`]:
3234
# }
3335
// The compiler will select `S(usize)` as the materialized return type of this
3436
// function, but callers will only know that the return type implements `T`.
35-
fn foo() -> impl T {
37+
fn foo() -> impl T { // ok!
3638
S(42)
3739
}
3840
```
@@ -57,7 +59,7 @@ impl T for O {
5759
5860
// This now returns a "trait object" and callers are only be able to access
5961
// associated items from `T`.
60-
fn foo(x: bool) -> Box<dyn T> {
62+
fn foo(x: bool) -> Box<dyn T> { // ok!
6163
if x {
6264
Box::new(S(42))
6365
} else {

src/librustc_error_codes/error_codes/E0747.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Generic arguments must be provided in the same order as the corresponding
1+
Generic arguments were not provided in the same order as the corresponding
22
generic parameters are declared.
33

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

1313
The argument order should be changed to match the parameter declaration
14-
order, as in the following.
14+
order, as in the following:
1515

1616
```
1717
struct S<'a, T>(&'a T);

src/librustc_feature/active.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ declare_features! (
576576
/// Lazily evaluate constants. This allows constants to depend on type parameters.
577577
(active, lazy_normalization_consts, "1.46.0", Some(72219), None),
578578

579-
/// Alloc calling `transmute` in const fn
579+
/// Allows calling `transmute` in const fn
580580
(active, const_fn_transmute, "1.46.0", Some(53605), None),
581581

582582
// -------------------------------------------------------------------------

src/librustc_incremental/assert_module_sources.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>) {
3939
.collect_and_partition_mono_items(LOCAL_CRATE)
4040
.1
4141
.iter()
42-
.map(|cgu| cgu.name())
43-
.collect::<BTreeSet<Symbol>>();
42+
.map(|cgu| cgu.name().to_string())
43+
.collect::<BTreeSet<String>>();
4444

4545
let ams = AssertModuleSource { tcx, available_cgus };
4646

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

5353
struct AssertModuleSource<'tcx> {
5454
tcx: TyCtxt<'tcx>,
55-
available_cgus: BTreeSet<Symbol>,
55+
available_cgus: BTreeSet<String>,
5656
}
5757

5858
impl AssertModuleSource<'tcx> {
@@ -121,12 +121,11 @@ impl AssertModuleSource<'tcx> {
121121

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

124-
if !self.available_cgus.contains(&cgu_name) {
124+
if !self.available_cgus.contains(&*cgu_name.as_str()) {
125125
self.tcx.sess.span_err(
126126
attr.span,
127127
&format!(
128-
"no module named `{}` (mangled: {}). \
129-
Available modules: {}",
128+
"no module named `{}` (mangled: {}). Available modules: {}",
130129
user_path,
131130
cgu_name,
132131
self.available_cgus

src/librustc_resolve/diagnostics.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1075,10 +1075,9 @@ impl<'a> Resolver<'a> {
10751075
) = binding.kind
10761076
{
10771077
let def_id = (&*self).parent(ctor_def_id).expect("no parent for a constructor");
1078-
if let Some(fields) = self.field_names.get(&def_id) {
1079-
let first_field = fields.first().expect("empty field list in the map");
1080-
return Some(fields.iter().fold(first_field.span, |acc, field| acc.to(field.span)));
1081-
}
1078+
let fields = self.field_names.get(&def_id)?;
1079+
let first_field = fields.first()?; // Handle `struct Foo()`
1080+
return Some(fields.iter().fold(first_field.span, |acc, field| acc.to(field.span)));
10821081
}
10831082
None
10841083
}

src/librustc_trait_selection/traits/select/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
440440
obligation
441441
);
442442

443-
// `previous_stack` stores a `TraitObligatiom`, while `obligation` is
443+
// `previous_stack` stores a `TraitObligation`, while `obligation` is
444444
// a `PredicateObligation`. These are distinct types, so we can't
445445
// use any `Option` combinator method that would force them to be
446446
// the same.

src/test/mir-opt/const-promotion-extern-static.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
// ignore-endian-big
12
extern "C" {
23
static X: i32;
34
}
4-
55
static Y: i32 = 42;
66

77
// EMIT_MIR const_promotion_extern_static.BAR.PromoteTemps.diff

src/test/mir-opt/const_allocation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
// ignore-endian-big
12
// EMIT_MIR_FOR_EACH_BIT_WIDTH
2-
33
static FOO: &[(Option<i32>, &[&str])] =
44
&[(None, &[]), (None, &["foo", "bar"]), (Some(42), &["meh", "mop", "möp"])];
55

src/test/mir-opt/const_allocation2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
// ignore-endian-big
12
// EMIT_MIR_FOR_EACH_BIT_WIDTH
2-
33
// EMIT_MIR const_allocation2.main.ConstProp.after.mir
44
fn main() {
55
FOO;

src/test/mir-opt/const_allocation3.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
// ignore-endian-big
12
// EMIT_MIR_FOR_EACH_BIT_WIDTH
2-
33
// EMIT_MIR const_allocation3.main.ConstProp.after.mir
44
fn main() {
55
FOO;

src/test/mir-opt/inline/inline-into-box-place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
// ignore-endian-big
12
// ignore-wasm32-bare compiled with panic=abort by default
23
// compile-flags: -Z mir-opt-level=3
34
// EMIT_MIR_FOR_EACH_BIT_WIDTH
45
#![feature(box_syntax)]
5-
66
// EMIT_MIR inline_into_box_place.main.Inline.diff
77
fn main() {
88
let _x: Box<Vec<u32>> = box Vec::new();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Regression test for issue #75062
2+
// Tests that we don't ICE on a privacy error for a fieldless tuple struct.
3+
4+
mod foo {
5+
struct Bar();
6+
}
7+
8+
fn main() {
9+
foo::Bar(); //~ ERROR tuple struct
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0603]: tuple struct `Bar` is private
2+
--> $DIR/issue-75062-fieldless-tuple-struct.rs:9:10
3+
|
4+
LL | foo::Bar();
5+
| ^^^ private tuple struct
6+
|
7+
note: the tuple struct `Bar` is defined here
8+
--> $DIR/issue-75062-fieldless-tuple-struct.rs:5:5
9+
|
10+
LL | struct Bar();
11+
| ^^^^^^^^^^^^^
12+
13+
error: aborting due to previous error
14+
15+
For more information about this error, try `rustc --explain E0603`.

src/test/ui/simd/simd-intrinsic-generic-bitmask.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![allow(non_camel_case_types)]
33

44
// ignore-emscripten
5+
// ignore-endian-big behavior of simd_bitmask is endian-specific
56

67
// Test that the simd_bitmask intrinsic produces correct results.
78

src/test/ui/simd/simd-intrinsic-generic-select.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
#![allow(non_camel_case_types)]
33

44
// ignore-emscripten
5-
// ignore-mips behavior of simd_select_bitmask is endian-specific
6-
// ignore-mips64 behavior of simd_select_bitmask is endian-specific
7-
// ignore-powerpc behavior of simd_select_bitmask is endian-specific
8-
// ignore-powerpc64 behavior of simd_select_bitmask is endian-specific
5+
// ignore-endian-big behavior of simd_select_bitmask is endian-specific
96

107
// Test that the simd_select intrinsics produces correct results.
118

src/tools/compiletest/src/header.rs

+1
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ impl Config {
827827
name == util::get_pointer_width(&self.target) || // pointer width
828828
name == self.stage_id.split('-').next().unwrap() || // stage
829829
(self.target != self.host && name == "cross-compile") ||
830+
(name == "endian-big" && util::is_big_endian(&self.target)) ||
830831
(self.remote_test_client.is_some() && name == "remote") ||
831832
match self.compare_mode {
832833
Some(CompareMode::Nll) => name == "compare-mode-nll",

src/tools/compiletest/src/util.rs

+20
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,20 @@ pub const MSAN_SUPPORTED_TARGETS: &'static [&'static str] =
9999
pub const TSAN_SUPPORTED_TARGETS: &'static [&'static str] =
100100
&["aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu"];
101101

102+
const BIG_ENDIAN: &'static [&'static str] = &[
103+
"armebv7r",
104+
"mips",
105+
"mips64",
106+
"mipsisa32r6",
107+
"mipsisa64r6",
108+
"powerpc",
109+
"powerpc64",
110+
"s390x",
111+
"sparc",
112+
"sparc64",
113+
"sparcv9",
114+
];
115+
102116
pub fn matches_os(triple: &str, name: &str) -> bool {
103117
// For the wasm32 bare target we ignore anything also ignored on emscripten
104118
// and then we also recognize `wasm32-bare` as the os for the target
@@ -125,6 +139,12 @@ pub fn get_arch(triple: &str) -> &'static str {
125139
panic!("Cannot determine Architecture from triple");
126140
}
127141

142+
/// Determine the endianness from `triple`
143+
pub fn is_big_endian(triple: &str) -> bool {
144+
let triple_arch = triple.split('-').next().unwrap();
145+
BIG_ENDIAN.contains(&triple_arch)
146+
}
147+
128148
pub fn matches_env(triple: &str, name: &str) -> bool {
129149
if let Some(env) = triple.split('-').nth(3) { env.starts_with(name) } else { false }
130150
}

src/tools/publish_toolstate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
LABELS = {
4343
'miri': ['A-miri', 'C-bug'],
4444
'rls': ['A-rls', 'C-bug'],
45-
'rustfmt': ['C-bug'],
45+
'rustfmt': ['A-rustfmt', 'C-bug'],
4646
'book': ['C-bug'],
4747
'nomicon': ['C-bug'],
4848
'reference': ['C-bug'],

src/tools/unicode-table-generator/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//! We have two separate encoding schemes: a skiplist-like approach, and a
1616
//! compressed bitset. The datasets we consider mostly use the skiplist (it's
1717
//! smaller) but the lowercase and uppercase sets are sufficiently sparse for
18-
//! the bitset to be worthwhile -- for those sets the biset is a 2x size win.
18+
//! the bitset to be worthwhile -- for those sets the bitset is a 2x size win.
1919
//! Since the bitset is also faster, this seems an obvious choice. (As a
2020
//! historical note, the bitset was also the prior implementation, so its
2121
//! relative complexity had already been paid).

0 commit comments

Comments
 (0)