Skip to content

Commit 788128e

Browse files
author
The Miri Cronjob Bot
committed
Merge ref 'f6d23413c399' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: f6d2341 Filtered ref: fc132ae45e682a2556f99caed7bca9b8a2e909c8 This merge was created using https://github.com/rust-lang/josh-sync.
2 parents c9f79d7 + 99e758b commit 788128e

File tree

13 files changed

+2045
-779
lines changed

13 files changed

+2045
-779
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/src/char/methods.rs

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,28 +1872,33 @@ pub const unsafe fn encode_utf8_raw_unchecked(code: u32, dst: *mut u8) {
18721872
// SAFETY: The caller must guarantee that the buffer pointed to by `dst`
18731873
// is at least `len` bytes long.
18741874
unsafe {
1875-
match len {
1876-
1 => {
1877-
*dst = code as u8;
1878-
}
1879-
2 => {
1880-
*dst = (code >> 6 & 0x1F) as u8 | TAG_TWO_B;
1881-
*dst.add(1) = (code & 0x3F) as u8 | TAG_CONT;
1882-
}
1883-
3 => {
1884-
*dst = (code >> 12 & 0x0F) as u8 | TAG_THREE_B;
1885-
*dst.add(1) = (code >> 6 & 0x3F) as u8 | TAG_CONT;
1886-
*dst.add(2) = (code & 0x3F) as u8 | TAG_CONT;
1887-
}
1888-
4 => {
1889-
*dst = (code >> 18 & 0x07) as u8 | TAG_FOUR_B;
1890-
*dst.add(1) = (code >> 12 & 0x3F) as u8 | TAG_CONT;
1891-
*dst.add(2) = (code >> 6 & 0x3F) as u8 | TAG_CONT;
1892-
*dst.add(3) = (code & 0x3F) as u8 | TAG_CONT;
1893-
}
1894-
// SAFETY: `char` always takes between 1 and 4 bytes to encode in UTF-8.
1895-
_ => crate::hint::unreachable_unchecked(),
1875+
if len == 1 {
1876+
*dst = code as u8;
1877+
return;
1878+
}
1879+
1880+
let last1 = (code >> 0 & 0x3F) as u8 | TAG_CONT;
1881+
let last2 = (code >> 6 & 0x3F) as u8 | TAG_CONT;
1882+
let last3 = (code >> 12 & 0x3F) as u8 | TAG_CONT;
1883+
let last4 = (code >> 18 & 0x3F) as u8 | TAG_FOUR_B;
1884+
1885+
if len == 2 {
1886+
*dst = last2 | TAG_TWO_B;
1887+
*dst.add(1) = last1;
1888+
return;
18961889
}
1890+
1891+
if len == 3 {
1892+
*dst = last3 | TAG_THREE_B;
1893+
*dst.add(1) = last2;
1894+
*dst.add(2) = last1;
1895+
return;
1896+
}
1897+
1898+
*dst = last4;
1899+
*dst.add(1) = last3;
1900+
*dst.add(2) = last2;
1901+
*dst.add(3) = last1;
18971902
}
18981903
}
18991904

core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
#![feature(no_core)]
173173
#![feature(optimize_attribute)]
174174
#![feature(prelude_import)]
175+
#![feature(reborrow)]
175176
#![feature(repr_simd)]
176177
#![feature(rustc_allow_const_fn_unstable)]
177178
#![feature(rustc_attrs)]

core/src/marker.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,3 +1365,11 @@ pub macro CoercePointee($item:item) {
13651365
pub trait CoercePointeeValidated {
13661366
/* compiler built-in */
13671367
}
1368+
1369+
/// Allows value to be reborrowed as exclusive, creating a copy of the value
1370+
/// that disables the source for reads and writes for the lifetime of the copy.
1371+
#[lang = "reborrow"]
1372+
#[unstable(feature = "reborrow", issue = "145612")]
1373+
pub trait Reborrow {
1374+
// Empty.
1375+
}

core/src/panic/location.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl<'a> Location<'a> {
183183
#[must_use]
184184
#[stable(feature = "panic_hooks", since = "1.10.0")]
185185
#[rustc_const_stable(feature = "const_location_fields", since = "1.79.0")]
186-
pub const fn file(&self) -> &str {
186+
pub const fn file(&self) -> &'a str {
187187
// SAFETY: The filename is valid.
188188
unsafe { self.filename.as_ref() }
189189
}
@@ -195,7 +195,7 @@ impl<'a> Location<'a> {
195195
#[must_use]
196196
#[unstable(feature = "file_with_nul", issue = "141727")]
197197
#[inline]
198-
pub const fn file_with_nul(&self) -> &CStr {
198+
pub const fn file_with_nul(&self) -> &'a CStr {
199199
let filename = self.filename.as_ptr();
200200

201201
// SAFETY: The filename is valid for `filename_len+1` bytes, so this addition can't

coretests/tests/panic/location.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,19 @@ fn location_const_column() {
4747
assert_eq!(COLUMN, 40);
4848
}
4949

50+
#[test]
51+
fn location_file_lifetime<'x>() {
52+
// Verify that the returned `&str`s lifetime is derived from the generic
53+
// lifetime 'a, not the lifetime of `&self`, when calling `Location::file`.
54+
// Test failure is indicated by a compile failure, not a runtime panic.
55+
let _: for<'a> fn(&'a Location<'x>) -> &'x str = Location::file;
56+
}
57+
5058
#[test]
5159
fn location_debug() {
5260
let f = format!("{:?}", Location::caller());
5361
assert!(f.contains(&format!("{:?}", file!())));
54-
assert!(f.contains("52"));
62+
assert!(f.contains("60"));
5563
assert!(f.contains("29"));
5664
}
5765

std/src/sync/nonpoison.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,10 @@ impl fmt::Display for WouldBlock {
3333
pub use self::mutex::MappedMutexGuard;
3434
#[unstable(feature = "nonpoison_mutex", issue = "134645")]
3535
pub use self::mutex::{Mutex, MutexGuard};
36+
#[unstable(feature = "mapped_lock_guards", issue = "117108")]
37+
pub use self::rwlock::{MappedRwLockReadGuard, MappedRwLockWriteGuard};
38+
#[unstable(feature = "nonpoison_rwlock", issue = "134645")]
39+
pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
3640

3741
mod mutex;
42+
mod rwlock;

0 commit comments

Comments
 (0)