Skip to content

Commit 4b9ac51

Browse files
committed
Auto merge of rust-lang#75388 - JohnTitor:rollup-9tgkxnl, r=JohnTitor
Rollup of 10 pull requests Successful merges: - rust-lang#74744 (Update RELEASES.md for 1.46.0) - rust-lang#75085 (Transmute big endian `s6_addr` and `[u16; 8]`) - rust-lang#75226 (Miri: Renamed "undef" to "uninit") - rust-lang#75333 (polymorphize: constrain unevaluated const handling) - rust-lang#75338 (move stack size check to const_eval machine) - rust-lang#75347 (Rustdoc: Fix natural ordering to look at all numbers.) - rust-lang#75352 (Tweak conditions for E0026 and E0769) - rust-lang#75353 (Tiny cleanup, remove unnecessary `unwrap`) - rust-lang#75359 (unused_delims: trim expr) - rust-lang#75360 (Add sample fix for E0749) Failed merges: r? @ghost
2 parents 441fd22 + 5320028 commit 4b9ac51

File tree

30 files changed

+319
-140
lines changed

30 files changed

+319
-140
lines changed

RELEASES.md

+103
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,104 @@
1+
Version 1.46.0 (2020-08-27)
2+
==========================
3+
4+
Language
5+
--------
6+
- [`if`, `match`, and `loop` expressions can now be used in const functions.][72437]
7+
- [Additionally you are now also able to coerce and cast to slices (`&[T]`) in
8+
const functions.][73862]
9+
- [The `#[track_caller]` attribute can now be added to functions to use the
10+
function's caller's location information for panic messages.][72445]
11+
- [Recursively indexing into tuples no longer needs parentheses.][71322] E.g.
12+
`x.0.0` over `(x.0).0`.
13+
- [`mem::transmute` can now be used in static and constants.][72920] **Note**
14+
You currently can't use `mem::transmute` in constant functions.
15+
16+
Compiler
17+
--------
18+
- [You can now use the `cdylib` target on Apple iOS and tvOS platforms.][73516]
19+
- [Enabled static "Position Independent Executables" by default
20+
for `x86_64-unknown-linux-musl`.][70740]
21+
22+
Libraries
23+
---------
24+
- [`mem::forget` is now a `const fn`.][73887]
25+
- [`String` now implements `From<char>`.][73466]
26+
- [The `leading_ones`, and `trailing_ones` methods have been stabilised for all
27+
integer types.][73032]
28+
- [`vec::IntoIter<T>` now implements `AsRef<[T]>`.][72583]
29+
- [All non-zero integer types (`NonZeroU8`) now implement `TryFrom` for their
30+
zero-able equivalent (e.g. `TryFrom<u8>`).][72717]
31+
- [`&[T]` and `&mut [T]` now implement `PartialEq<Vec<T>>`.][71660]
32+
- [`(String, u16)` now implements `ToSocketAddrs`.][73007]
33+
- [`vec::Drain<'_, T>` now implements `AsRef<[T]>`.][72584]
34+
35+
Stabilized APIs
36+
---------------
37+
- [`Option::zip`]
38+
- [`vec::Drain::as_slice`]
39+
40+
Cargo
41+
-----
42+
Added a number of new environment variables that are now available when
43+
compiling your crate.
44+
45+
- [`CARGO_BIN_NAME` and `CARGO_CRATE_NAME`][cargo/8270] Providing the name of
46+
the specific binary being compiled and the name of the crate.
47+
- [`CARGO_PKG_LICENSE`][cargo/8325] The license from the manifest of the package.
48+
- [`CARGO_PKG_LICENSE_FILE`][cargo/8387] The path to the license file.
49+
50+
Compatibility Notes
51+
-------------------
52+
- [The target configuration option `abi_blacklist` has been renamed
53+
to `unsupported_abis`.][74150] The old name will still continue to work.
54+
- [Rustc will now warn if you have a C-like enum that implements `Drop`.][72331]
55+
This was previously accepted but will become a hard error in a future release.
56+
- [Rustc will fail to compile if you have a struct with
57+
`#[repr(i128)]` or `#[repr(u128)]`.][74109] This representation is currently only
58+
allowed on `enum`s.
59+
- [Tokens passed to `macro_rules!` are now always captured.][73293] This helps
60+
ensure that spans have the correct information, and may cause breakage if you
61+
were relying on receiving spans with dummy information.
62+
- [The InnoSetup installer for Windows is no longer available.][72569] This was
63+
a legacy installer that was replaced by a MSI installer a few years ago but
64+
was still being built.
65+
- [`{f32, f64}::asinh` now returns the correct values for negative numbers.][72486]
66+
- [Rustc will no longer accept overlapping trait implementations that only
67+
differ in how the lifetime was bound.][72493]
68+
- [Rustc now correctly relates the lifetime of an existential associated
69+
type.][71896] This fixes some edge cases where `rustc` would erroneously allow
70+
you to pass a shorter lifetime than expected.
71+
72+
[74109]: https://github.com/rust-lang/rust/pull/74109/
73+
[74150]: https://github.com/rust-lang/rust/pull/74150/
74+
[73862]: https://github.com/rust-lang/rust/pull/73862/
75+
[73887]: https://github.com/rust-lang/rust/pull/73887/
76+
[73466]: https://github.com/rust-lang/rust/pull/73466/
77+
[73516]: https://github.com/rust-lang/rust/pull/73516/
78+
[73293]: https://github.com/rust-lang/rust/pull/73293/
79+
[73007]: https://github.com/rust-lang/rust/pull/73007/
80+
[73032]: https://github.com/rust-lang/rust/pull/73032/
81+
[72920]: https://github.com/rust-lang/rust/pull/72920/
82+
[72569]: https://github.com/rust-lang/rust/pull/72569/
83+
[72583]: https://github.com/rust-lang/rust/pull/72583/
84+
[72584]: https://github.com/rust-lang/rust/pull/72584/
85+
[72717]: https://github.com/rust-lang/rust/pull/72717/
86+
[72437]: https://github.com/rust-lang/rust/pull/72437/
87+
[72445]: https://github.com/rust-lang/rust/pull/72445/
88+
[72486]: https://github.com/rust-lang/rust/pull/72486/
89+
[72493]: https://github.com/rust-lang/rust/pull/72493/
90+
[72331]: https://github.com/rust-lang/rust/pull/72331/
91+
[71896]: https://github.com/rust-lang/rust/pull/71896/
92+
[71660]: https://github.com/rust-lang/rust/pull/71660/
93+
[71322]: https://github.com/rust-lang/rust/pull/71322/
94+
[70740]: https://github.com/rust-lang/rust/pull/70740/
95+
[cargo/8270]: https://github.com/rust-lang/cargo/pull/8270/
96+
[cargo/8325]: https://github.com/rust-lang/cargo/pull/8325/
97+
[cargo/8387]: https://github.com/rust-lang/cargo/pull/8387/
98+
[`Option::zip`]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.zip
99+
[`vec::Drain::as_slice`]: https://doc.rust-lang.org/stable/std/vec/struct.Drain.html#method.as_slice
100+
101+
1102
Version 1.45.2 (2020-08-03)
2103
==========================
3104

@@ -7,6 +108,7 @@ Version 1.45.2 (2020-08-03)
7108
[74954]: https://github.com/rust-lang/rust/issues/74954
8109
[74784]: https://github.com/rust-lang/rust/issues/74784
9110

111+
10112
Version 1.45.1 (2020-07-30)
11113
==========================
12114

@@ -20,6 +122,7 @@ Version 1.45.1 (2020-07-30)
20122
[74509]: https://github.com/rust-lang/rust/pull/74509
21123
[74457]: https://github.com/rust-lang/rust/pull/74457
22124

125+
23126
Version 1.45.0 (2020-07-16)
24127
==========================
25128

library/std/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@
249249
#![feature(clamp)]
250250
#![feature(concat_idents)]
251251
#![feature(const_cstr_unchecked)]
252+
#![feature(const_fn_transmute)]
252253
#![feature(const_raw_ptr_deref)]
253254
#![feature(container_error_extra)]
254255
#![feature(core_intrinsics)]

library/std/src/net/ip.rs

+27-27
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use crate::cmp::Ordering;
1010
use crate::fmt::{self, Write as FmtWrite};
1111
use crate::hash;
1212
use crate::io::Write as IoWrite;
13+
use crate::mem::transmute;
1314
use crate::sys::net::netc as c;
1415
use crate::sys_common::{AsInner, FromInner};
1516

@@ -1045,27 +1046,23 @@ impl Ipv6Addr {
10451046
/// ```
10461047
#[stable(feature = "rust1", since = "1.0.0")]
10471048
#[rustc_const_stable(feature = "const_ipv6", since = "1.32.0")]
1049+
#[allow_internal_unstable(const_fn_transmute)]
10481050
pub const fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16, h: u16) -> Ipv6Addr {
1051+
let addr16 = [
1052+
a.to_be(),
1053+
b.to_be(),
1054+
c.to_be(),
1055+
d.to_be(),
1056+
e.to_be(),
1057+
f.to_be(),
1058+
g.to_be(),
1059+
h.to_be(),
1060+
];
10491061
Ipv6Addr {
10501062
inner: c::in6_addr {
1051-
s6_addr: [
1052-
(a >> 8) as u8,
1053-
a as u8,
1054-
(b >> 8) as u8,
1055-
b as u8,
1056-
(c >> 8) as u8,
1057-
c as u8,
1058-
(d >> 8) as u8,
1059-
d as u8,
1060-
(e >> 8) as u8,
1061-
e as u8,
1062-
(f >> 8) as u8,
1063-
f as u8,
1064-
(g >> 8) as u8,
1065-
g as u8,
1066-
(h >> 8) as u8,
1067-
h as u8,
1068-
],
1063+
// All elements in `addr16` are big endian.
1064+
// SAFETY: `[u16; 8]` is always safe to transmute to `[u8; 16]`.
1065+
s6_addr: unsafe { transmute::<_, [u8; 16]>(addr16) },
10691066
},
10701067
}
10711068
}
@@ -1108,16 +1105,19 @@ impl Ipv6Addr {
11081105
/// ```
11091106
#[stable(feature = "rust1", since = "1.0.0")]
11101107
pub fn segments(&self) -> [u16; 8] {
1111-
let arr = &self.inner.s6_addr;
1108+
// All elements in `s6_addr` must be big endian.
1109+
// SAFETY: `[u8; 16]` is always safe to transmute to `[u16; 8]`.
1110+
let [a, b, c, d, e, f, g, h] = unsafe { transmute::<_, [u16; 8]>(self.inner.s6_addr) };
1111+
// We want native endian u16
11121112
[
1113-
u16::from_be_bytes([arr[0], arr[1]]),
1114-
u16::from_be_bytes([arr[2], arr[3]]),
1115-
u16::from_be_bytes([arr[4], arr[5]]),
1116-
u16::from_be_bytes([arr[6], arr[7]]),
1117-
u16::from_be_bytes([arr[8], arr[9]]),
1118-
u16::from_be_bytes([arr[10], arr[11]]),
1119-
u16::from_be_bytes([arr[12], arr[13]]),
1120-
u16::from_be_bytes([arr[14], arr[15]]),
1113+
u16::from_be(a),
1114+
u16::from_be(b),
1115+
u16::from_be(c),
1116+
u16::from_be(d),
1117+
u16::from_be(e),
1118+
u16::from_be(f),
1119+
u16::from_be(g),
1120+
u16::from_be(h),
11211121
]
11221122
}
11231123

src/librustc_codegen_llvm/consts.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ pub fn const_alloc_to_llvm(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll
4141
// some arbitrary byte value.
4242
//
4343
// FIXME: relay undef bytes to codegen as undef const bytes
44-
let bytes = alloc.inspect_with_undef_and_ptr_outside_interpreter(next_offset..offset);
44+
let bytes = alloc.inspect_with_uninit_and_ptr_outside_interpreter(next_offset..offset);
4545
llvals.push(cx.const_bytes(bytes));
4646
}
4747
let ptr_offset = read_target_uint(
4848
dl.endian,
4949
// This `inspect` is okay since it is within the bounds of the allocation, it doesn't
5050
// affect interpreter execution (we inspect the result after interpreter execution),
5151
// and we properly interpret the relocation as a relocation pointer offset.
52-
alloc.inspect_with_undef_and_ptr_outside_interpreter(offset..(offset + pointer_size)),
52+
alloc.inspect_with_uninit_and_ptr_outside_interpreter(offset..(offset + pointer_size)),
5353
)
5454
.expect("const_alloc_to_llvm: could not read relocation pointer")
5555
as u64;
@@ -74,7 +74,7 @@ pub fn const_alloc_to_llvm(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll
7474
// arbitrary byte value.
7575
//
7676
// FIXME: relay undef bytes to codegen as undef const bytes
77-
let bytes = alloc.inspect_with_undef_and_ptr_outside_interpreter(range);
77+
let bytes = alloc.inspect_with_uninit_and_ptr_outside_interpreter(range);
7878
llvals.push(cx.const_bytes(bytes));
7979
}
8080

@@ -452,7 +452,7 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
452452
// BSS.
453453
let all_bytes_are_zero = alloc.relocations().is_empty()
454454
&& alloc
455-
.inspect_with_undef_and_ptr_outside_interpreter(0..alloc.len())
455+
.inspect_with_uninit_and_ptr_outside_interpreter(0..alloc.len())
456456
.iter()
457457
.all(|&byte| byte == 0);
458458

@@ -480,7 +480,7 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
480480
// because we are doing this access to inspect the final interpreter state (not
481481
// as part of the interpreter execution).
482482
let bytes =
483-
alloc.inspect_with_undef_and_ptr_outside_interpreter(0..alloc.len());
483+
alloc.inspect_with_uninit_and_ptr_outside_interpreter(0..alloc.len());
484484
let alloc = llvm::LLVMMDStringInContext(
485485
self.llcx,
486486
bytes.as_ptr().cast(),

src/librustc_error_codes/error_codes/E0749.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,19 @@ trait MyTrait {
1111
impl !MyTrait for u32 {
1212
type Foo = i32; // error!
1313
}
14-
# fn main() {}
1514
```
1615

1716
Negative impls are not allowed to have any items. Negative impls declare that a
1817
trait is **not** implemented (and never will be) and hence there is no need to
1918
specify the values for trait methods or other items.
19+
20+
One way to fix this is to remove the items in negative impls:
21+
22+
```
23+
# #![feature(negative_impls)]
24+
trait MyTrait {
25+
type Foo;
26+
}
27+
28+
impl !MyTrait for u32 {}
29+
```

src/librustc_lint/unused.rs

+19-17
Original file line numberDiff line numberDiff line change
@@ -481,25 +481,27 @@ trait UnusedDelimLint {
481481
let mut err = lint.build(&span_msg);
482482
let mut ate_left_paren = false;
483483
let mut ate_right_paren = false;
484-
let parens_removed = pattern.trim_matches(|c| match c {
485-
'(' | '{' => {
486-
if ate_left_paren {
487-
false
488-
} else {
489-
ate_left_paren = true;
490-
true
484+
let parens_removed = pattern
485+
.trim_matches(|c| match c {
486+
'(' | '{' => {
487+
if ate_left_paren {
488+
false
489+
} else {
490+
ate_left_paren = true;
491+
true
492+
}
491493
}
492-
}
493-
')' | '}' => {
494-
if ate_right_paren {
495-
false
496-
} else {
497-
ate_right_paren = true;
498-
true
494+
')' | '}' => {
495+
if ate_right_paren {
496+
false
497+
} else {
498+
ate_right_paren = true;
499+
true
500+
}
499501
}
500-
}
501-
_ => false,
502-
});
502+
_ => false,
503+
})
504+
.trim();
503505

504506
let replace = {
505507
let mut replace = if keep_space.0 {

0 commit comments

Comments
 (0)