Skip to content

Commit 9bb6d54

Browse files
committed
Auto merge of #83377 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum
[stable] 1.51.0 release Also includes backports of the release notes, as well as: * SplitInclusive is public API #83372 * std: Fix a bug on the wasm32-wasi target opening files #82804 * Fix io::copy specialization using copy_file_range when writer was opened with O_APPEND #82417 r? `@Mark-Simulacrum`
2 parents 73f48e5 + f9dd96d commit 9bb6d54

File tree

6 files changed

+203
-14
lines changed

6 files changed

+203
-14
lines changed

RELEASES.md

+171
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,174 @@
1+
Version 1.51.0 (2021-03-25)
2+
============================
3+
4+
Language
5+
--------
6+
- [You can now parameterize items such as functions, traits, and `struct`s by constant
7+
values in addition to by types and lifetimes.][79135] Also known as "const generics"
8+
E.g. you can now write the following. Note: Only values of primitive integers,
9+
`bool`, or `char` types are currently permitted.
10+
```rust
11+
struct GenericArray<T, const LENGTH: usize> {
12+
inner: [T; LENGTH]
13+
}
14+
15+
impl<T, const LENGTH: usize> GenericArray<T, LENGTH> {
16+
const fn last(&self) -> Option<&T> {
17+
if LENGTH == 0 {
18+
None
19+
} else {
20+
Some(&self.inner[LENGTH - 1])
21+
}
22+
}
23+
}
24+
```
25+
26+
27+
Compiler
28+
--------
29+
30+
- [Added the `-Csplit-debuginfo` codegen option for macOS platforms.][79570]
31+
This option controls whether debug information is split across multiple files
32+
or packed into a single file. **Note** This option is unstable on other platforms.
33+
- [Added tier 3\* support for `aarch64_be-unknown-linux-gnu`,
34+
`aarch64-unknown-linux-gnu_ilp32`, and `aarch64_be-unknown-linux-gnu_ilp32` targets.][81455]
35+
- [Added tier 3 support for `i386-unknown-linux-gnu` and `i486-unknown-linux-gnu` targets.][80662]
36+
- [The `target-cpu=native` option will now detect individual features of CPUs.][80749]
37+
- [Rust now uses `inline-asm` for stack probes when used with LLVM 11.0.1+][77885]
38+
39+
\* Refer to Rust's [platform support page][forge-platform-support] for more
40+
information on Rust's tiered platform support.
41+
42+
Libraries
43+
---------
44+
45+
- [`Box::downcast` is now also implemented for any `dyn Any + Send + Sync` object.][80945]
46+
- [`str` now implements `AsMut<str>`.][80279]
47+
- [`u64` and `u128` now implement `From<char>`.][79502]
48+
- [`Error` is now implemented for `&T` where `T` implements `Error`.][75180]
49+
- [`Poll::{map_ok, map_err}` are now implemented for `Poll<Option<Result<T, E>>>`.][80968]
50+
- [`unsigned_abs` is now implemented for all signed integer types.][80959]
51+
- [`io::Empty` now implements `io::Seek`.][78044]
52+
- [`rc::Weak<T>` and `sync::Weak<T>`'s methods such as `as_ptr` are now implemented for
53+
`T: ?Sized` types.][80764]
54+
55+
Stabilized APIs
56+
---------------
57+
58+
- [`Arc::decrement_strong_count`]
59+
- [`Arc::increment_strong_count`]
60+
- [`Once::call_once_force`]
61+
- [`Peekable::next_if_eq`]
62+
- [`Peekable::next_if`]
63+
- [`Seek::stream_position`]
64+
- [`array::IntoIter`]
65+
- [`panic::panic_any`]
66+
- [`ptr::addr_of!`]
67+
- [`ptr::addr_of_mut!`]
68+
- [`slice::fill_with`]
69+
- [`slice::split_inclusive_mut`]
70+
- [`slice::split_inclusive`]
71+
- [`slice::strip_prefix`]
72+
- [`slice::strip_suffix`]
73+
- [`str::split_inclusive`]
74+
- [`sync::OnceState`]
75+
- [`task::Wake`]
76+
77+
Cargo
78+
-----
79+
- [Added the `split-debuginfo` profile option to control the -Csplit-debuginfo
80+
codegen option.][cargo/9112]
81+
- [Added the `resolver` field to `Cargo.toml` to enable the new feature resolver
82+
and CLI option behavior.][cargo/8997] Version 2 of the feature resolver will try
83+
to avoid unifying features of dependencies where that unification could be unwanted.
84+
Such as using the same dependency with a `std` feature in a build scripts and
85+
proc-macros, while using the `no-std` feature in the final binary. See the
86+
[Cargo book documentation][[email protected]] for more information on the feature.
87+
88+
Rustdoc
89+
-------
90+
91+
- [Rustdoc will now include documentation for methods available from `Deref` traits.][80653]
92+
- [You can now provide a `--default-theme` flag which sets the default theme to use for
93+
documentation.][79642]
94+
95+
Various improvements to intra-doc links:
96+
97+
- [You can link to non-path primitives such as `slice`.][80181]
98+
- [You can link to associated items.][74489]
99+
- [You can now include generic parameters when linking to items, like `Vec<T>`.][76934]
100+
101+
Misc
102+
----
103+
- [You can now pass `--include-ignored` to tests (e.g. with
104+
`cargo test -- --include-ignored`) to include testing tests marked `#[ignore]`.][80053]
105+
106+
Compatibility Notes
107+
-------------------
108+
109+
- [WASI platforms no longer use the `wasm-bindgen` ABI, and instead use the wasm32 ABI.][79998]
110+
- [`rustc` no longer promotes division, modulo and indexing operations to `const` that
111+
could fail.][80579]
112+
- [The minimum version of glibc for the following platforms has been bumped to version 2.31
113+
for the distributed artifacts.][81521]
114+
- `armv5te-unknown-linux-gnueabi`
115+
- `sparc64-unknown-linux-gnu`
116+
- `thumbv7neon-unknown-linux-gnueabihf`
117+
- `armv7-unknown-linux-gnueabi`
118+
- `x86_64-unknown-linux-gnux32`
119+
120+
Internal Only
121+
-------------
122+
123+
- [Consistently avoid constructing optimized MIR when not doing codegen][80718]
124+
125+
[79135]: https://github.com/rust-lang/rust/pull/79135
126+
[74489]: https://github.com/rust-lang/rust/pull/74489
127+
[76934]: https://github.com/rust-lang/rust/pull/76934
128+
[79570]: https://github.com/rust-lang/rust/pull/79570
129+
[80181]: https://github.com/rust-lang/rust/pull/80181
130+
[79642]: https://github.com/rust-lang/rust/pull/79642
131+
[80945]: https://github.com/rust-lang/rust/pull/80945
132+
[80279]: https://github.com/rust-lang/rust/pull/80279
133+
[80053]: https://github.com/rust-lang/rust/pull/80053
134+
[79502]: https://github.com/rust-lang/rust/pull/79502
135+
[75180]: https://github.com/rust-lang/rust/pull/75180
136+
[79135]: https://github.com/rust-lang/rust/pull/79135
137+
[81521]: https://github.com/rust-lang/rust/pull/81521
138+
[80968]: https://github.com/rust-lang/rust/pull/80968
139+
[80959]: https://github.com/rust-lang/rust/pull/80959
140+
[80718]: https://github.com/rust-lang/rust/pull/80718
141+
[80653]: https://github.com/rust-lang/rust/pull/80653
142+
[80579]: https://github.com/rust-lang/rust/pull/80579
143+
[79998]: https://github.com/rust-lang/rust/pull/79998
144+
[78044]: https://github.com/rust-lang/rust/pull/78044
145+
[81455]: https://github.com/rust-lang/rust/pull/81455
146+
[80764]: https://github.com/rust-lang/rust/pull/80764
147+
[80749]: https://github.com/rust-lang/rust/pull/80749
148+
[80662]: https://github.com/rust-lang/rust/pull/80662
149+
[77885]: https://github.com/rust-lang/rust/pull/77885
150+
[cargo/8997]: https://github.com/rust-lang/cargo/pull/8997
151+
[cargo/9112]: https://github.com/rust-lang/cargo/pull/9112
152+
[[email protected]]: https://doc.rust-lang.org/nightly/cargo/reference/features.html#feature-resolver-version-2
153+
[`Once::call_once_force`]: https://doc.rust-lang.org/stable/std/sync/struct.Once.html#method.call_once_force
154+
[`sync::OnceState`]: https://doc.rust-lang.org/stable/std/sync/struct.OnceState.html
155+
[`panic::panic_any`]: https://doc.rust-lang.org/stable/std/panic/fn.panic_any.html
156+
[`slice::strip_prefix`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.strip_prefix
157+
[`slice::strip_suffix`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.strip_prefix
158+
[`Arc::increment_strong_count`]: https://doc.rust-lang.org/nightly/std/sync/struct.Arc.html#method.increment_strong_count
159+
[`Arc::decrement_strong_count`]: https://doc.rust-lang.org/nightly/std/sync/struct.Arc.html#method.decrement_strong_count
160+
[`slice::fill_with`]: https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.fill_with
161+
[`ptr::addr_of!`]: https://doc.rust-lang.org/nightly/std/ptr/macro.addr_of.html
162+
[`ptr::addr_of_mut!`]: https://doc.rust-lang.org/nightly/std/ptr/macro.addr_of_mut.html
163+
[`array::IntoIter`]: https://doc.rust-lang.org/nightly/std/array/struct.IntoIter.html
164+
[`slice::split_inclusive`]: https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.split_inclusive
165+
[`slice::split_inclusive_mut`]: https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.split_inclusive_mut
166+
[`str::split_inclusive`]: https://doc.rust-lang.org/nightly/std/primitive.str.html#method.split_inclusive
167+
[`task::Wake`]: https://doc.rust-lang.org/nightly/std/task/trait.Wake.html
168+
[`Seek::stream_position`]: https://doc.rust-lang.org/nightly/std/io/trait.Seek.html#method.stream_position
169+
[`Peekable::next_if`]: https://doc.rust-lang.org/nightly/std/iter/struct.Peekable.html#method.next_if
170+
[`Peekable::next_if_eq`]: https://doc.rust-lang.org/nightly/std/iter/struct.Peekable.html#method.next_if_eq
171+
1172
Version 1.50.0 (2021-02-11)
2173
============================
3174

library/core/src/str/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub use iter::{EscapeDebug, EscapeDefault, EscapeUnicode};
6666
pub use iter::SplitAsciiWhitespace;
6767

6868
#[stable(feature = "split_inclusive", since = "1.51.0")]
69-
use iter::SplitInclusive;
69+
pub use iter::SplitInclusive;
7070

7171
#[unstable(feature = "str_internals", issue = "none")]
7272
pub use validations::next_code_point;

library/std/src/sys/unix/kernel_copy.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ use crate::process::{ChildStderr, ChildStdin, ChildStdout};
6161
use crate::ptr;
6262
use crate::sync::atomic::{AtomicBool, AtomicU8, Ordering};
6363
use crate::sys::cvt;
64+
use libc::{EBADF, EINVAL, ENOSYS, EOPNOTSUPP, EOVERFLOW, EPERM, EXDEV};
6465

6566
#[cfg(test)]
6667
mod tests;
@@ -535,7 +536,7 @@ pub(super) fn copy_regular_files(reader: RawFd, writer: RawFd, max_len: u64) ->
535536
cvt(copy_file_range(INVALID_FD, ptr::null_mut(), INVALID_FD, ptr::null_mut(), 1, 0))
536537
};
537538

538-
if matches!(result.map_err(|e| e.raw_os_error()), Err(Some(libc::EBADF))) {
539+
if matches!(result.map_err(|e| e.raw_os_error()), Err(Some(EBADF))) {
539540
HAS_COPY_FILE_RANGE.store(AVAILABLE, Ordering::Relaxed);
540541
} else {
541542
HAS_COPY_FILE_RANGE.store(UNAVAILABLE, Ordering::Relaxed);
@@ -573,19 +574,20 @@ pub(super) fn copy_regular_files(reader: RawFd, writer: RawFd, max_len: u64) ->
573574
Err(err) => {
574575
return match err.raw_os_error() {
575576
// when file offset + max_length > u64::MAX
576-
Some(libc::EOVERFLOW) => CopyResult::Fallback(written),
577-
Some(
578-
libc::ENOSYS | libc::EXDEV | libc::EINVAL | libc::EPERM | libc::EOPNOTSUPP,
579-
) => {
577+
Some(EOVERFLOW) => CopyResult::Fallback(written),
578+
Some(ENOSYS | EXDEV | EINVAL | EPERM | EOPNOTSUPP | EBADF) => {
580579
// Try fallback io::copy if either:
581580
// - Kernel version is < 4.5 (ENOSYS¹)
582581
// - Files are mounted on different fs (EXDEV)
583582
// - copy_file_range is broken in various ways on RHEL/CentOS 7 (EOPNOTSUPP)
584583
// - copy_file_range file is immutable or syscall is blocked by seccomp¹ (EPERM)
585584
// - copy_file_range cannot be used with pipes or device nodes (EINVAL)
585+
// - the writer fd was opened with O_APPEND (EBADF²)
586586
//
587587
// ¹ these cases should be detected by the initial probe but we handle them here
588588
// anyway in case syscall interception changes during runtime
589+
// ² actually invalid file descriptors would cause this too, but in that case
590+
// the fallback code path is expected to encounter the same error again
589591
assert_eq!(written, 0);
590592
CopyResult::Fallback(0)
591593
}
@@ -649,7 +651,7 @@ fn sendfile_splice(mode: SpliceMode, reader: RawFd, writer: RawFd, len: u64) ->
649651
Ok(ret) => written += ret as u64,
650652
Err(err) => {
651653
return match err.raw_os_error() {
652-
Some(libc::ENOSYS | libc::EPERM) => {
654+
Some(ENOSYS | EPERM) => {
653655
// syscall not supported (ENOSYS)
654656
// syscall is disallowed, e.g. by seccomp (EPERM)
655657
match mode {
@@ -659,12 +661,12 @@ fn sendfile_splice(mode: SpliceMode, reader: RawFd, writer: RawFd, len: u64) ->
659661
assert_eq!(written, 0);
660662
CopyResult::Fallback(0)
661663
}
662-
Some(libc::EINVAL) => {
664+
Some(EINVAL) => {
663665
// splice/sendfile do not support this particular file descriptor (EINVAL)
664666
assert_eq!(written, 0);
665667
CopyResult::Fallback(0)
666668
}
667-
Some(os_err) if mode == SpliceMode::Sendfile && os_err == libc::EOVERFLOW => {
669+
Some(os_err) if mode == SpliceMode::Sendfile && os_err == EOVERFLOW => {
668670
CopyResult::Fallback(written)
669671
}
670672
_ => CopyResult::Error(err, written),

library/std/src/sys/unix/kernel_copy/tests.rs

+18
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,24 @@ fn copy_specialization() -> Result<()> {
6565
result.and(rm1).and(rm2)
6666
}
6767

68+
#[test]
69+
fn copies_append_mode_sink() -> Result<()> {
70+
let tmp_path = tmpdir();
71+
let source_path = tmp_path.join("copies_append_mode.source");
72+
let sink_path = tmp_path.join("copies_append_mode.sink");
73+
let mut source =
74+
OpenOptions::new().create(true).truncate(true).write(true).read(true).open(&source_path)?;
75+
write!(source, "not empty")?;
76+
source.seek(SeekFrom::Start(0))?;
77+
let mut sink = OpenOptions::new().create(true).append(true).open(&sink_path)?;
78+
79+
let copied = crate::io::copy(&mut source, &mut sink)?;
80+
81+
assert_eq!(copied, 9);
82+
83+
Ok(())
84+
}
85+
6886
#[bench]
6987
fn bench_file_to_file_copy(b: &mut test::Bencher) {
7088
const BYTES: usize = 128 * 1024;

library/std/src/sys/wasi/fs.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -654,13 +654,11 @@ fn open_parent(p: &Path) -> io::Result<(ManuallyDrop<WasiFd>, PathBuf)> {
654654
);
655655
return Err(io::Error::new(io::ErrorKind::Other, msg));
656656
}
657-
let len = CStr::from_ptr(buf.as_ptr().cast()).to_bytes().len();
658-
buf.set_len(len);
659-
buf.shrink_to_fit();
657+
let relative = CStr::from_ptr(relative_path).to_bytes().to_vec();
660658

661659
return Ok((
662660
ManuallyDrop::new(WasiFd::from_raw(fd as u32)),
663-
PathBuf::from(OsString::from_vec(buf)),
661+
PathBuf::from(OsString::from_vec(relative)),
664662
));
665663
}
666664
}

src/ci/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fi
6868
#
6969
# FIXME: need a scheme for changing this `nightly` value to `beta` and `stable`
7070
# either automatically or manually.
71-
export RUST_RELEASE_CHANNEL=beta
71+
export RUST_RELEASE_CHANNEL=stable
7272

7373
# Always set the release channel for bootstrap; this is normally not important (i.e., only dist
7474
# builds would seem to matter) but in practice bootstrap wants to know whether we're targeting

0 commit comments

Comments
 (0)