Skip to content

Commit d09466c

Browse files
committed
Auto merge of #56381 - kennytm:rollup, r=kennytm
Rollup of 19 pull requests Successful merges: - #55011 (Add libstd Cargo feature "panic_immediate_abort") - #55821 (Use sort_by_cached_key when the key function is not trivial/free) - #56014 (add test for issue #21335) - #56131 (Assorted tweaks) - #56214 (Implement chalk unification routines) - #56216 (Add TryFrom<&[T]> for [T; $N] where T: Copy) - #56268 (Reuse the `P` in `InvocationCollector::fold_{,opt_}expr`.) - #56324 (Use raw_entry for more efficient interning) - #56336 (Clean up and streamline the pretty-printer) - #56337 (Fix const_fn ICE with non-const function pointer) - #56339 (Remove not used option) - #56341 (Rename conversion util; remove duplicate util in librustc_codegen_llvm.) - #56349 (rustc 1.30.0's linker flavor inference is a non-backwards compat change to -Clinker) - #56355 (Add inline attributes and add unit to CommonTypes) - #56360 (Optimize local linkchecker program) - #56364 (Fix panic with outlives in existential type) - #56365 (Stabilize self_struct_ctor feature.) - #56367 (Moved some feature gate tests to correct location) - #56373 (Update books)
2 parents d48ab69 + a6c4771 commit d09466c

File tree

76 files changed

+1908
-856
lines changed

Some content is hidden

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

76 files changed

+1908
-856
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,6 @@
6565
[submodule "src/doc/rustc-guide"]
6666
path = src/doc/rustc-guide
6767
url = https://github.com/rust-lang/rustc-guide.git
68+
[submodule "src/doc/edition-guide"]
69+
path = src/doc/edition-guide
70+
url = https://github.com/rust-lang-nursery/edition-guide

src/bootstrap/doc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ macro_rules! book {
7070
book!(
7171
Nomicon, "src/doc/nomicon", "nomicon";
7272
Reference, "src/doc/reference", "reference";
73+
EditionGuide, "src/doc/edition-guide", "edition-guide";
7374
RustdocBook, "src/doc/rustdoc", "rustdoc";
7475
RustcBook, "src/doc/rustc", "rustc";
7576
RustByExample, "src/doc/rust-by-example", "rust-by-example";

src/doc/edition-guide

Submodule edition-guide added at ad89586

src/doc/nomicon

src/doc/unstable-book/src/language-features/self-struct-ctor.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/liballoc/string.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,8 @@ impl String {
618618
/// ```
619619
#[stable(feature = "rust1", since = "1.0.0")]
620620
pub fn from_utf16(v: &[u16]) -> Result<String, FromUtf16Error> {
621+
// This isn't done via collect::<Result<_, _>>() for performance reasons.
622+
// FIXME: the function can be simplified again when #48994 is closed.
621623
let mut ret = String::with_capacity(v.len());
622624
for c in decode_utf16(v.iter().cloned()) {
623625
if let Ok(c) = c {

src/libarena/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ pub struct DroplessArena {
298298
unsafe impl Send for DroplessArena {}
299299

300300
impl Default for DroplessArena {
301+
#[inline]
301302
fn default() -> DroplessArena {
302303
DroplessArena {
303304
ptr: Cell::new(0 as *mut u8),
@@ -319,6 +320,7 @@ impl DroplessArena {
319320
false
320321
}
321322

323+
#[inline]
322324
fn align(&self, align: usize) {
323325
let final_address = ((self.ptr.get() as usize) + align - 1) & !(align - 1);
324326
self.ptr.set(final_address as *mut u8);

src/libcore/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ path = "../libcore/benches/lib.rs"
2121

2222
[dev-dependencies]
2323
rand = "0.5"
24+
25+
[features]
26+
# Make panics and failed asserts immediately abort without formatting any message
27+
panic_immediate_abort = []

src/libcore/array.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ macro_rules! array_impls {
148148
}
149149
}
150150

151+
#[unstable(feature = "try_from", issue = "33417")]
152+
impl<'a, T> TryFrom<&'a [T]> for [T; $N] where T: Copy {
153+
type Error = TryFromSliceError;
154+
155+
fn try_from(slice: &[T]) -> Result<[T; $N], TryFromSliceError> {
156+
<&Self>::try_from(slice).map(|r| *r)
157+
}
158+
}
159+
151160
#[unstable(feature = "try_from", issue = "33417")]
152161
impl<'a, T> TryFrom<&'a [T]> for &'a [T; $N] {
153162
type Error = TryFromSliceError;

src/libcore/num/mod.rs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,6 +1989,19 @@ big endian.
19891989
```
19901990
let value = ", stringify!($SelfT), "::from_be_bytes(", $be_bytes, ");
19911991
assert_eq!(value, ", $swap_op, ");
1992+
```
1993+
1994+
When starting from a slice rather than an array, fallible conversion APIs can be used:
1995+
1996+
```
1997+
#![feature(try_from)]
1998+
use std::convert::TryInto;
1999+
2000+
fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {
2001+
let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());
2002+
*input = rest;
2003+
", stringify!($SelfT), "::from_be_bytes(int_bytes.try_into().unwrap())
2004+
}
19922005
```"),
19932006
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
19942007
#[rustc_const_unstable(feature = "const_int_conversion")]
@@ -2008,6 +2021,19 @@ little endian.
20082021
```
20092022
let value = ", stringify!($SelfT), "::from_le_bytes(", $le_bytes, ");
20102023
assert_eq!(value, ", $swap_op, ");
2024+
```
2025+
2026+
When starting from a slice rather than an array, fallible conversion APIs can be used:
2027+
2028+
```
2029+
#![feature(try_from)]
2030+
use std::convert::TryInto;
2031+
2032+
fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {
2033+
let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());
2034+
*input = rest;
2035+
", stringify!($SelfT), "::from_be_bytes(int_bytes.try_into().unwrap())
2036+
}
20112037
```"),
20122038
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
20132039
#[rustc_const_unstable(feature = "const_int_conversion")]
@@ -2037,6 +2063,19 @@ let value = ", stringify!($SelfT), "::from_ne_bytes(if cfg!(target_endian = \"bi
20372063
", $le_bytes, "
20382064
});
20392065
assert_eq!(value, ", $swap_op, ");
2066+
```
2067+
2068+
When starting from a slice rather than an array, fallible conversion APIs can be used:
2069+
2070+
```
2071+
#![feature(try_from)]
2072+
use std::convert::TryInto;
2073+
2074+
fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {
2075+
let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());
2076+
*input = rest;
2077+
", stringify!($SelfT), "::from_be_bytes(int_bytes.try_into().unwrap())
2078+
}
20402079
```"),
20412080
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
20422081
#[rustc_const_unstable(feature = "const_int_conversion")]
@@ -3614,6 +3653,7 @@ assert_eq!(3", stringify!($SelfT), ".checked_next_power_of_two(), Some(4));
36143653
assert_eq!(", stringify!($SelfT), "::max_value().checked_next_power_of_two(), None);",
36153654
$EndFeature, "
36163655
```"),
3656+
#[inline]
36173657
#[stable(feature = "rust1", since = "1.0.0")]
36183658
pub fn checked_next_power_of_two(self) -> Option<Self> {
36193659
self.one_less_than_next_power_of_two().checked_add(1)
@@ -3719,6 +3759,19 @@ big endian.
37193759
```
37203760
let value = ", stringify!($SelfT), "::from_be_bytes(", $be_bytes, ");
37213761
assert_eq!(value, ", $swap_op, ");
3762+
```
3763+
3764+
When starting from a slice rather than an array, fallible conversion APIs can be used:
3765+
3766+
```
3767+
#![feature(try_from)]
3768+
use std::convert::TryInto;
3769+
3770+
fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {
3771+
let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());
3772+
*input = rest;
3773+
", stringify!($SelfT), "::from_be_bytes(int_bytes.try_into().unwrap())
3774+
}
37223775
```"),
37233776
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
37243777
#[rustc_const_unstable(feature = "const_int_conversion")]
@@ -3738,6 +3791,19 @@ little endian.
37383791
```
37393792
let value = ", stringify!($SelfT), "::from_le_bytes(", $le_bytes, ");
37403793
assert_eq!(value, ", $swap_op, ");
3794+
```
3795+
3796+
When starting from a slice rather than an array, fallible conversion APIs can be used:
3797+
3798+
```
3799+
#![feature(try_from)]
3800+
use std::convert::TryInto;
3801+
3802+
fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {
3803+
let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());
3804+
*input = rest;
3805+
", stringify!($SelfT), "::from_be_bytes(int_bytes.try_into().unwrap())
3806+
}
37413807
```"),
37423808
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
37433809
#[rustc_const_unstable(feature = "const_int_conversion")]
@@ -3767,6 +3833,19 @@ let value = ", stringify!($SelfT), "::from_ne_bytes(if cfg!(target_endian = \"bi
37673833
", $le_bytes, "
37683834
});
37693835
assert_eq!(value, ", $swap_op, ");
3836+
```
3837+
3838+
When starting from a slice rather than an array, fallible conversion APIs can be used:
3839+
3840+
```
3841+
#![feature(try_from)]
3842+
use std::convert::TryInto;
3843+
3844+
fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {
3845+
let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());
3846+
*input = rest;
3847+
", stringify!($SelfT), "::from_be_bytes(int_bytes.try_into().unwrap())
3848+
}
37703849
```"),
37713850
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
37723851
#[rustc_const_unstable(feature = "const_int_conversion")]

0 commit comments

Comments
 (0)