Skip to content

Commit 89b89b2

Browse files
committed
Auto merge of #59737 - pietroalbini:beta-rollup, r=pietroalbini
[beta] Rollup backports Cherry-picked: * #58021: Fix fallout from #57667 * #59599: Updated RELEASES.md for 1.34.0 * #59587: Remove #[doc(hidden)] from Error::type_id * #58994: Hide deprecation warnings inside derive expansions * #58015: Expand docs for `TryFrom` and `TryInto`. * #59770: ci: pin android emulator to 28.0.23 * #59704: ci: Update FreeBSD tarball downloads * #59257: Update CI configuration for building Redox libraries * #59724: Function arguments should never get promoted r? @ghost
2 parents 4655b72 + 8aa5034 commit 89b89b2

21 files changed

+354
-60
lines changed

RELEASES.md

+149
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,149 @@
1+
Version 1.34.0 (2019-04-11)
2+
==========================
3+
4+
Language
5+
--------
6+
- [You can now use `#[deprecated = "reason"]`][58166] as a shorthand for
7+
`#[deprecated(note = "reason")]`. This was previously allowed by mistake
8+
but had no effect.
9+
- [You can now accept token streams in `#[attr()]`,`#[attr[]]`, and
10+
`#[attr{}]` procedural macros.][57367]
11+
- [You can now write `extern crate self as foo;`][57407] to import your
12+
crate's root into the extern prelude.
13+
14+
15+
Compiler
16+
--------
17+
- [You can now target `riscv64imac-unknown-none-elf` and
18+
`riscv64gc-unknown-none-elf`.][58406]
19+
- [You can now enable linker plugin LTO optimisations with
20+
`-C linker-plugin-lto`.][58057] This allows rustc to compile your Rust code
21+
into LLVM bitcode allowing LLVM to perform LTO optimisations across C/C++ FFI
22+
boundaries.
23+
- [You can now target `powerpc64-unknown-freebsd`.][57809]
24+
25+
26+
Libraries
27+
---------
28+
- [The trait bounds have been removed on some of `HashMap<K, V, S>`'s and
29+
`HashSet<T, S>`'s basic methods.][58370] Most notably you no longer require
30+
the `Hash` trait to create an iterator.
31+
- [The `Ord` trait bounds have been removed on some of `BinaryHeap<T>`'s basic
32+
methods.][58421] Most notably you no longer require the `Ord` trait to create
33+
an iterator.
34+
- [The methods `overflowing_neg` and `wrapping_neg` are now `const` functions
35+
for all numeric types.][58044]
36+
- [Indexing a `str` is now generic over all types that
37+
implement `SliceIndex<str>`.][57604]
38+
- [`str::trim`, `str::trim_matches`, `str::trim_{start, end}`, and
39+
`str::trim_{start, end}_matches` are now `#[must_use]`][57106] and will
40+
produce a warning if their returning type is unused.
41+
- [The methods `checked_pow`, `saturating_pow`, `wrapping_pow`, and
42+
`overflowing_pow` are now available for all numeric types.][57873] These are
43+
equivalvent to methods such as `wrapping_add` for the `pow` operation.
44+
45+
46+
Stabilized APIs
47+
---------------
48+
49+
#### std & core
50+
* [`Any::type_id`]
51+
* [`Error::type_id`]
52+
* [`atomic::AtomicI16`]
53+
* [`atomic::AtomicI32`]
54+
* [`atomic::AtomicI64`]
55+
* [`atomic::AtomicI8`]
56+
* [`atomic::AtomicU16`]
57+
* [`atomic::AtomicU32`]
58+
* [`atomic::AtomicU64`]
59+
* [`atomic::AtomicU8`]
60+
* [`convert::Infallible`]
61+
* [`convert::TryFrom`]
62+
* [`convert::TryInto`]
63+
* [`iter::from_fn`]
64+
* [`iter::successors`]
65+
* [`num::NonZeroI128`]
66+
* [`num::NonZeroI16`]
67+
* [`num::NonZeroI32`]
68+
* [`num::NonZeroI64`]
69+
* [`num::NonZeroI8`]
70+
* [`num::NonZeroIsize`]
71+
* [`slice::sort_by_cached_key`]
72+
* [`str::escape_debug`]
73+
* [`str::escape_default`]
74+
* [`str::escape_unicode`]
75+
* [`str::split_ascii_whitespace`]
76+
77+
#### std
78+
* [`Instant::checked_add`]
79+
* [`Instant::checked_sub`]
80+
* [`SystemTime::checked_add`]
81+
* [`SystemTime::checked_sub`]
82+
83+
Cargo
84+
-----
85+
- [You can now use alternative registries to crates.io.][cargo/6654]
86+
87+
Misc
88+
----
89+
- [You can now use the `?` operator in your documentation tests without manually
90+
adding `fn main() -> Result<(), _> {}`.][56470]
91+
92+
Compatibility Notes
93+
-------------------
94+
- [`Command::before_exec` is now deprecated in favor of the
95+
unsafe method `Command::pre_exec`.][58059]
96+
- [Use of `ATOMIC_{BOOL, ISIZE, USIZE}_INIT` is now deprecated.][57425] As you
97+
can now use `const` functions in `static` variables.
98+
99+
[58370]: https://github.com/rust-lang/rust/pull/58370/
100+
[58406]: https://github.com/rust-lang/rust/pull/58406/
101+
[58421]: https://github.com/rust-lang/rust/pull/58421/
102+
[58166]: https://github.com/rust-lang/rust/pull/58166/
103+
[58044]: https://github.com/rust-lang/rust/pull/58044/
104+
[58057]: https://github.com/rust-lang/rust/pull/58057/
105+
[58059]: https://github.com/rust-lang/rust/pull/58059/
106+
[57809]: https://github.com/rust-lang/rust/pull/57809/
107+
[57873]: https://github.com/rust-lang/rust/pull/57873/
108+
[57604]: https://github.com/rust-lang/rust/pull/57604/
109+
[57367]: https://github.com/rust-lang/rust/pull/57367/
110+
[57407]: https://github.com/rust-lang/rust/pull/57407/
111+
[57425]: https://github.com/rust-lang/rust/pull/57425/
112+
[57106]: https://github.com/rust-lang/rust/pull/57106/
113+
[56470]: https://github.com/rust-lang/rust/pull/56470/
114+
[cargo/6654]: https://github.com/rust-lang/cargo/pull/6654/
115+
[`Any::type_id`]: https://doc.rust-lang.org/std/any/trait.Any.html#tymethod.type_id
116+
[`Error::type_id`]: https://doc.rust-lang.org/std/error/trait.Error.html#tymethod.type_id
117+
[`atomic::AtomicI16`]: https://doc.rust-lang.org/std/atomic/struct.AtomicI16.html
118+
[`atomic::AtomicI32`]: https://doc.rust-lang.org/std/atomic/struct.AtomicI32.html
119+
[`atomic::AtomicI64`]: https://doc.rust-lang.org/std/atomic/struct.AtomicI64.html
120+
[`atomic::AtomicI8`]: https://doc.rust-lang.org/std/atomic/struct.AtomicI8.html
121+
[`atomic::AtomicU16`]: https://doc.rust-lang.org/std/atomic/struct.AtomicU16.html
122+
[`atomic::AtomicU32`]: https://doc.rust-lang.org/std/atomic/struct.AtomicU32.html
123+
[`atomic::AtomicU64`]: https://doc.rust-lang.org/std/atomic/struct.AtomicU64.html
124+
[`atomic::AtomicU8`]: https://doc.rust-lang.org/std/atomic/struct.AtomicU8.html
125+
[`convert::Infallible`]: https://doc.rust-lang.org/std/convert/enum.Infallible.html
126+
[`convert::TryFrom`]: https://doc.rust-lang.org/std/convert/trait.TryFrom.html
127+
[`convert::TryInto`]: https://doc.rust-lang.org/std/convert/trait.TryInto.html
128+
[`iter::from_fn`]: https://doc.rust-lang.org/std/iter/fn.from_fn.html
129+
[`iter::successors`]: https://doc.rust-lang.org/std/iter/fn.successors.html
130+
[`num::NonZeroI128`]: https://doc.rust-lang.org/std/num/struct.NonZeroI128.html
131+
[`num::NonZeroI16`]: https://doc.rust-lang.org/std/num/struct.NonZeroI16.html
132+
[`num::NonZeroI32`]: https://doc.rust-lang.org/std/num/struct.NonZeroI32.html
133+
[`num::NonZeroI64`]: https://doc.rust-lang.org/std/num/struct.NonZeroI64.html
134+
[`num::NonZeroI8`]: https://doc.rust-lang.org/std/num/struct.NonZeroI8.html
135+
[`num::NonZeroIsize`]: https://doc.rust-lang.org/std/num/struct.NonZeroIsize.html
136+
[`slice::sort_by_cached_key`]: https://doc.rust-lang.org/std/slice/fn.sort_by_cached_key
137+
[`str::escape_debug`]: https://doc.rust-lang.org/std/primitive.str.html#method.escape_debug
138+
[`str::escape_default`]: https://doc.rust-lang.org/std/primitive.str.html#method.escape_default
139+
[`str::escape_unicode`]: https://doc.rust-lang.org/std/primitive.str.html#method.escape_unicode
140+
[`str::split_ascii_whitespace`]: https://doc.rust-lang.org/std/primitive.str.html#method.split_ascii_whitespace
141+
[`Instant::checked_add`]: https://doc.rust-lang.org/std/time/struct.Instant.html#method.checked_add
142+
[`Instant::checked_sub`]: https://doc.rust-lang.org/std/time/struct.Instant.html#method.checked_sub
143+
[`SystemTime::checked_add`]: https://doc.rust-lang.org/std/time/struct.SystemTime.html#method.checked_add
144+
[`SystemTime::checked_sub`]: https://doc.rust-lang.org/std/time/struct.SystemTime.html#method.checked_sub
145+
146+
1147
Version 1.33.0 (2019-02-28)
2148
==========================
3149

@@ -99,6 +245,8 @@ Stabilized APIs
99245

100246
Cargo
101247
-----
248+
- [You can now publish crates that require a feature flag to compile with
249+
`cargo publish --features` or `cargo publish --all-features`.][cargo/6453]
102250
- [Cargo should now rebuild a crate if a file was modified during the initial
103251
build.][cargo/6484]
104252

@@ -135,6 +283,7 @@ Compatibility Notes
135283
[57535]: https://github.com/rust-lang/rust/pull/57535/
136284
[57566]: https://github.com/rust-lang/rust/pull/57566/
137285
[57615]: https://github.com/rust-lang/rust/pull/57615/
286+
[cargo/6453]: https://github.com/rust-lang/cargo/pull/6453/
138287
[cargo/6484]: https://github.com/rust-lang/cargo/pull/6484/
139288
[`unix::FileExt::read_exact_at`]: https://doc.rust-lang.org/std/os/unix/fs/trait.FileExt.html#method.read_exact_at
140289
[`unix::FileExt::write_all_at`]: https://doc.rust-lang.org/std/os/unix/fs/trait.FileExt.html#method.write_all_at

src/ci/docker/arm-android/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ RUN dpkg --add-architecture i386 && \
2323

2424
COPY scripts/android-sdk.sh /scripts/
2525
RUN . /scripts/android-sdk.sh && \
26-
download_and_create_avd 4333796 armeabi-v7a 18
26+
download_and_create_avd 4333796 armeabi-v7a 18 5264690
2727

2828
ENV PATH=$PATH:/android/sdk/emulator
2929
ENV PATH=$PATH:/android/sdk/tools

src/ci/docker/disabled/dist-x86_64-redox/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ COPY scripts/crosstool-ng.sh /scripts/
77
RUN sh /scripts/crosstool-ng.sh
88

99
WORKDIR /tmp
10-
COPY cross/install-x86_64-redox.sh /tmp/
11-
RUN ./install-x86_64-redox.sh
10+
COPY dist-various-1/install-x86_64-redox.sh /scripts/
11+
RUN sh /scripts/install-x86_64-redox.sh
1212

1313
COPY scripts/sccache.sh /scripts/
1414
RUN sh /scripts/sccache.sh

src/ci/docker/dist-various-1/install-x86_64-redox.sh

+2-8
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,5 @@
33

44
set -ex
55

6-
apt-get update
7-
apt-get install -y --no-install-recommends software-properties-common apt-transport-https
8-
9-
apt-key adv --batch --yes --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys AA12E97F0881517F
10-
add-apt-repository -y 'deb https://static.redox-os.org/toolchain/apt /'
11-
12-
apt-get update
13-
apt-get install -y x86-64-unknown-redox-gcc
6+
curl https://static.redox-os.org/toolchain/x86_64-unknown-redox/relibc-install.tar.gz | \
7+
tar --extract --gzip --directory /usr/local

src/ci/docker/scripts/android-sdk.sh

+14-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,19 @@ download_sysimage() {
2020
# The output from sdkmanager is so noisy that it will occupy all of the 4 MB
2121
# log extremely quickly. Thus we must silence all output.
2222
yes | sdkmanager --licenses > /dev/null
23-
yes | sdkmanager platform-tools emulator \
23+
yes | sdkmanager platform-tools \
2424
"platforms;android-$api" \
2525
"system-images;android-$api;default;$abi" > /dev/null
2626
}
2727

28+
download_emulator() {
29+
# Download a pinned version of the emulator since upgrades can cause issues
30+
curl -fo emulator.zip "https://dl.google.com/android/repository/emulator-linux-$1.zip"
31+
rm -rf "${ANDROID_HOME}/emulator"
32+
unzip -q emulator.zip -d "${ANDROID_HOME}"
33+
rm -f emulator.zip
34+
}
35+
2836
create_avd() {
2937
abi=$1
3038
api=$2
@@ -40,11 +48,12 @@ download_and_create_avd() {
4048
download_sdk $1
4149
download_sysimage $2 $3
4250
create_avd $2 $3
51+
download_emulator $4
4352
}
4453

4554
# Usage:
4655
#
47-
# setup_android_sdk 4333796 armeabi-v7a 18
56+
# download_and_create_avd 4333796 armeabi-v7a 18 5264690
4857
#
4958
# 4333796 =>
5059
# SDK tool version.
@@ -53,3 +62,6 @@ download_and_create_avd() {
5362
# System image ABI
5463
# 18 =>
5564
# Android API Level (18 = Android 4.3 = Jelly Bean MR2)
65+
# 5264690 =>
66+
# Android Emulator version.
67+
# Copy from the "build_id" in the `/android/sdk/emulator/emulator -version` output

src/ci/docker/scripts/freebsd-toolchain.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/bin/bash
2+
# ignore-tidy-linelength
3+
24
set -eux
35

46
arch=$1
@@ -55,7 +57,9 @@ for lib in c++ c_nonshared compiler_rt execinfo gcc pthread rt ssp_nonshared; do
5557
files_to_extract=("${files_to_extract[@]}" "./usr/lib/lib${lib}.*")
5658
done
5759

58-
URL=https://download.freebsd.org/ftp/releases/${freebsd_arch}/${freebsd_version}-RELEASE/base.txz
60+
# Originally downloaded from:
61+
# https://download.freebsd.org/ftp/releases/${freebsd_arch}/${freebsd_version}-RELEASE/base.txz
62+
URL=https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2019-04-04-freebsd-${freebsd_arch}-${freebsd_version}-RELEASE-base.txz
5963
curl "$URL" | tar xJf - -C "$sysroot" --wildcards "${files_to_extract[@]}"
6064

6165
# Fix up absolute symlinks from the system image. This can be removed

src/libcore/convert.rs

+60-6
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,17 @@ pub trait From<T>: Sized {
361361
/// An attempted conversion that consumes `self`, which may or may not be
362362
/// expensive.
363363
///
364-
/// Library authors should not directly implement this trait, but should prefer
365-
/// implementing the [`TryFrom`] trait, which offers greater flexibility and
366-
/// provides an equivalent `TryInto` implementation for free, thanks to a
367-
/// blanket implementation in the standard library. For more information on this,
368-
/// see the documentation for [`Into`].
364+
/// Library authors should usually not directly implement this trait,
365+
/// but should prefer implementing the [`TryFrom`] trait, which offers
366+
/// greater flexibility and provides an equivalent `TryInto`
367+
/// implementation for free, thanks to a blanket implementation in the
368+
/// standard library. For more information on this, see the
369+
/// documentation for [`Into`].
370+
///
371+
/// # Implementing `TryInto`
372+
///
373+
/// This suffers the same restrictions and reasoning as implementing
374+
/// [`Into`], see there for details.
369375
///
370376
/// [`TryFrom`]: trait.TryFrom.html
371377
/// [`Into`]: trait.Into.html
@@ -380,7 +386,55 @@ pub trait TryInto<T>: Sized {
380386
fn try_into(self) -> Result<T, Self::Error>;
381387
}
382388

383-
/// Attempt to construct `Self` via a conversion.
389+
/// Simple and safe type conversions that may fail in a controlled
390+
/// way under some circumstances. It is the reciprocal of [`TryInto`].
391+
///
392+
/// This is useful when you are doing a type conversion that may
393+
/// trivially succeed but may also need special handling.
394+
/// For example, there is no way to convert an `i64` into an `i32`
395+
/// using the [`From`] trait, because an `i64` may contain a value
396+
/// that an `i32` cannot represent and so the conversion would lose data.
397+
/// This might be handled by truncating the `i64` to an `i32` (essentially
398+
/// giving the `i64`'s value modulo `i32::MAX`) or by simply returning
399+
/// `i32::MAX`, or by some other method. The `From` trait is intended
400+
/// for perfect conversions, so the `TryFrom` trait informs the
401+
/// programmer when a type conversion could go bad and lets them
402+
/// decide how to handle it.
403+
///
404+
/// # Generic Implementations
405+
///
406+
/// - `TryFrom<T> for U` implies [`TryInto<U>`]` for T`
407+
/// - [`try_from`] is reflexive, which means that `TryFrom<T> for T`
408+
/// is implemented and cannot fail -- the associated `Error` type for
409+
/// calling `T::try_from()` on a value of type `T` is `Infallible`.
410+
/// When the `!` type is stablized `Infallible` and `!` will be
411+
/// equivalent.
412+
///
413+
/// # Examples
414+
///
415+
/// As described, [`i32`] implements `TryFrom<i64>`:
416+
///
417+
/// ```
418+
/// use std::convert::TryFrom;
419+
///
420+
/// let big_number = 1_000_000_000_000i64;
421+
/// // Silently truncates `big_number`, requires detecting
422+
/// // and handling the truncation after the fact.
423+
/// let smaller_number = big_number as i32;
424+
/// assert_eq!(smaller_number, -727379968);
425+
///
426+
/// // Returns an error because `big_number` is too big to
427+
/// // fit in an `i32`.
428+
/// let try_smaller_number = i32::try_from(big_number);
429+
/// assert!(try_smaller_number.is_err());
430+
///
431+
/// // Returns `Ok(3)`.
432+
/// let try_successful_smaller_number = i32::try_from(3);
433+
/// assert!(try_successful_smaller_number.is_ok());
434+
/// ```
435+
///
436+
/// [`try_from`]: trait.TryFrom.html#tymethod.try_from
437+
/// [`TryInto`]: trait.TryInto.html
384438
#[stable(feature = "try_from", since = "1.34.0")]
385439
pub trait TryFrom<T>: Sized {
386440
/// The type returned in the event of a conversion error.

src/libcore/num/mod.rs

+12
Original file line numberDiff line numberDiff line change
@@ -4544,6 +4544,9 @@ macro_rules! try_from_unbounded {
45444544
impl TryFrom<$source> for $target {
45454545
type Error = TryFromIntError;
45464546

4547+
/// Try to create the target number type from a source
4548+
/// number type. This returns an error if the source value
4549+
/// is outside of the range of the target type.
45474550
#[inline]
45484551
fn try_from(value: $source) -> Result<Self, Self::Error> {
45494552
Ok(value as $target)
@@ -4559,6 +4562,9 @@ macro_rules! try_from_lower_bounded {
45594562
impl TryFrom<$source> for $target {
45604563
type Error = TryFromIntError;
45614564

4565+
/// Try to create the target number type from a source
4566+
/// number type. This returns an error if the source value
4567+
/// is outside of the range of the target type.
45624568
#[inline]
45634569
fn try_from(u: $source) -> Result<$target, TryFromIntError> {
45644570
if u >= 0 {
@@ -4578,6 +4584,9 @@ macro_rules! try_from_upper_bounded {
45784584
impl TryFrom<$source> for $target {
45794585
type Error = TryFromIntError;
45804586

4587+
/// Try to create the target number type from a source
4588+
/// number type. This returns an error if the source value
4589+
/// is outside of the range of the target type.
45814590
#[inline]
45824591
fn try_from(u: $source) -> Result<$target, TryFromIntError> {
45834592
if u > (<$target>::max_value() as $source) {
@@ -4597,6 +4606,9 @@ macro_rules! try_from_both_bounded {
45974606
impl TryFrom<$source> for $target {
45984607
type Error = TryFromIntError;
45994608

4609+
/// Try to create the target number type from a source
4610+
/// number type. This returns an error if the source value
4611+
/// is outside of the range of the target type.
46004612
#[inline]
46014613
fn try_from(u: $source) -> Result<$target, TryFromIntError> {
46024614
let min = <$target>::min_value() as $source;

0 commit comments

Comments
 (0)