Skip to content

Commit ace5e0f

Browse files
committed
Auto merge of rust-lang#138114 - compiler-errors:rollup-7xr4b69, r=compiler-errors
Rollup of 25 pull requests Successful merges: - rust-lang#135733 (Implement `&pin const self` and `&pin mut self` sugars) - rust-lang#135895 (Document workings of successors more clearly) - rust-lang#136922 (Pattern types: Avoid having to handle an Option for range ends in the type system or the HIR) - rust-lang#137303 (Remove `MaybeForgetReturn` suggestion) - rust-lang#137327 (Undeprecate env::home_dir) - rust-lang#137358 (Match Ergonomics 2024: add context and examples to the unstable book) - rust-lang#137534 ([rustdoc] hide item that is not marked as doc(inline) and whose src is doc(hidden)) - rust-lang#137565 (Try to point of macro expansion from resolver and method errors if it involves macro var) - rust-lang#137637 (Check dyn flavor before registering upcast goal on wide pointer cast in MIR typeck) - rust-lang#137643 (Add DWARF test case for non-C-like `repr128` enums) - rust-lang#137744 (Re-add `Clone`-derive on `Thir`) - rust-lang#137758 (fix usage of ty decl macro fragments in attributes) - rust-lang#137764 (Ensure that negative auto impls are always applicable) - rust-lang#137772 (Fix char count in `Display` for `ByteStr`) - rust-lang#137798 (ci: use ubuntu 24 on arm large runner) - rust-lang#137802 (miri native-call support: all previously exposed provenance is accessible to the callee) - rust-lang#137805 (adjust Layout debug printing to match the internal field name) - rust-lang#137808 (Do not require that unsafe fields lack drop glue) - rust-lang#137820 (Clarify why InhabitedPredicate::instantiate_opt exists) - rust-lang#137825 (Provide more context on resolve error caused from incorrect RTN) - rust-lang#137834 (rustc_fluent_macro: use CARGO_CRATE_NAME instead of CARGO_PKG_NAME) - rust-lang#137868 (Add minimal platform support documentation for powerpc-unknown-linux-gnuspe) - rust-lang#137910 (Improve error message for `AsyncFn` trait failure for RPIT) - rust-lang#137920 (interpret/provenance_map: consistently use range_is_empty) - rust-lang#138038 (Update `compiler-builtins` to 0.1.151) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 17d426f + e2b4056 commit ace5e0f

File tree

9 files changed

+82
-18
lines changed

9 files changed

+82
-18
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

alloc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ edition = "2021"
1212

1313
[dependencies]
1414
core = { path = "../core", public = true }
15-
compiler_builtins = { version = "=0.1.150", features = ['rustc-dep-of-std'] }
15+
compiler_builtins = { version = "=0.1.151", features = ['rustc-dep-of-std'] }
1616

1717
[dev-dependencies]
1818
rand = { version = "0.9.0", default-features = false, features = ["alloc"] }

core/src/bstr.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ impl fmt::Display for ByteStr {
151151
};
152152
let nchars: usize = self
153153
.utf8_chunks()
154-
.map(|chunk| chunk.valid().len() + if chunk.invalid().is_empty() { 0 } else { 1 })
154+
.map(|chunk| {
155+
chunk.valid().chars().count() + if chunk.invalid().is_empty() { 0 } else { 1 }
156+
})
155157
.sum();
156158
let padding = f.width().unwrap_or(0).saturating_sub(nchars);
157159
let fill = f.fill();

core/src/convert/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,6 @@ impl<T> From<T> for T {
778778
///
779779
/// [#64715]: https://github.com/rust-lang/rust/issues/64715
780780
#[stable(feature = "convert_infallible", since = "1.34.0")]
781-
#[allow(unused_attributes)] // FIXME(#58633): do a principled fix instead.
782781
#[rustc_reservation_impl = "permitting this impl would forbid us from adding \
783782
`impl<T> From<!> for T` later; see rust-lang/rust#64715 for details"]
784783
impl<T> From<!> for T {

core/src/iter/sources/successors.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
use crate::fmt;
22
use crate::iter::FusedIterator;
33

4-
/// Creates a new iterator where each successive item is computed based on the preceding one.
4+
/// Creates an iterator which, starting from an initial item,
5+
/// computes each successive item from the preceding one.
56
///
6-
/// The iterator starts with the given first item (if any)
7-
/// and calls the given `FnMut(&T) -> Option<T>` closure to compute each item’s successor.
8-
/// The iterator will yield the `T`s returned from the closure.
7+
/// This iterator stores an optional item (`Option<T>`) and a successor closure (`impl FnMut(&T) -> Option<T>`).
8+
/// Its `next` method returns the stored optional item and
9+
/// if it is `Some(val)` calls the stored closure on `&val` to compute and store its successor.
10+
/// The iterator will apply the closure successively to the stored option's value until the option is `None`.
11+
/// This also means that once the stored option is `None` it will remain `None`,
12+
/// as the closure will not be called again, so the created iterator is a [`FusedIterator`].
13+
/// The iterator's items will be the initial item and all of its successors as calculated by the successor closure.
914
///
1015
/// ```
1116
/// use std::iter::successors;
@@ -24,7 +29,8 @@ where
2429
Successors { next: first, succ }
2530
}
2631

27-
/// A new iterator where each successive item is computed based on the preceding one.
32+
/// An iterator which, starting from an initial item,
33+
/// computes each successive item from the preceding one.
2834
///
2935
/// This `struct` is created by the [`iter::successors()`] function.
3036
/// See its documentation for more.

core/src/marker.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,8 @@ impl Copy for ! {}
453453
#[stable(feature = "rust1", since = "1.0.0")]
454454
impl<T: ?Sized> Copy for &T {}
455455

456-
/// Marker trait for the types that are allowed in union fields, unsafe fields,
457-
/// and unsafe binder types.
456+
/// Marker trait for the types that are allowed in union fields and unsafe
457+
/// binder types.
458458
///
459459
/// Implemented for:
460460
/// * `&T`, `&mut T` for all `T`,

core/src/pat.rs

+62
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,65 @@ macro_rules! pattern_type {
1212
/* compiler built-in */
1313
};
1414
}
15+
16+
/// A trait implemented for integer types and `char`.
17+
/// Useful in the future for generic pattern types, but
18+
/// used right now to simplify ast lowering of pattern type ranges.
19+
#[unstable(feature = "pattern_type_range_trait", issue = "123646")]
20+
#[rustc_const_unstable(feature = "pattern_type_range_trait", issue = "123646")]
21+
#[const_trait]
22+
#[diagnostic::on_unimplemented(
23+
message = "`{Self}` is not a valid base type for range patterns",
24+
label = "only integer types and `char` are supported"
25+
)]
26+
pub trait RangePattern {
27+
/// Trait version of the inherent `MIN` assoc const.
28+
#[cfg_attr(not(bootstrap), lang = "RangeMin")]
29+
const MIN: Self;
30+
31+
/// Trait version of the inherent `MIN` assoc const.
32+
#[cfg_attr(not(bootstrap), lang = "RangeMax")]
33+
const MAX: Self;
34+
35+
/// A compile-time helper to subtract 1 for exclusive ranges.
36+
#[cfg_attr(not(bootstrap), lang = "RangeSub")]
37+
#[track_caller]
38+
fn sub_one(self) -> Self;
39+
}
40+
41+
macro_rules! impl_range_pat {
42+
($($ty:ty,)*) => {
43+
$(
44+
#[rustc_const_unstable(feature = "pattern_type_range_trait", issue = "123646")]
45+
impl const RangePattern for $ty {
46+
const MIN: $ty = <$ty>::MIN;
47+
const MAX: $ty = <$ty>::MAX;
48+
fn sub_one(self) -> Self {
49+
match self.checked_sub(1) {
50+
Some(val) => val,
51+
None => panic!("exclusive range end at minimum value of type")
52+
}
53+
}
54+
}
55+
)*
56+
}
57+
}
58+
59+
impl_range_pat! {
60+
i8, i16, i32, i64, i128, isize,
61+
u8, u16, u32, u64, u128, usize,
62+
}
63+
64+
#[rustc_const_unstable(feature = "pattern_type_range_trait", issue = "123646")]
65+
impl const RangePattern for char {
66+
const MIN: Self = char::MIN;
67+
68+
const MAX: Self = char::MAX;
69+
70+
fn sub_one(self) -> Self {
71+
match char::from_u32(self as u32 - 1) {
72+
None => panic!("exclusive range to start of valid chars"),
73+
Some(val) => val,
74+
}
75+
}
76+
}

std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
1818
panic_unwind = { path = "../panic_unwind", optional = true }
1919
panic_abort = { path = "../panic_abort" }
2020
core = { path = "../core", public = true }
21-
compiler_builtins = { version = "=0.1.150" }
21+
compiler_builtins = { version = "=0.1.151" }
2222
unwind = { path = "../unwind" }
2323
hashbrown = { version = "0.15", default-features = false, features = [
2424
'rustc-dep-of-std',

std/src/env.rs

-5
Original file line numberDiff line numberDiff line change
@@ -641,11 +641,6 @@ impl Error for JoinPathsError {
641641
/// None => println!("Impossible to get your home dir!"),
642642
/// }
643643
/// ```
644-
#[deprecated(
645-
since = "1.29.0",
646-
note = "This function's behavior may be unexpected on Windows. \
647-
Consider using a crate from crates.io instead."
648-
)]
649644
#[must_use]
650645
#[stable(feature = "env", since = "1.0.0")]
651646
pub fn home_dir() -> Option<PathBuf> {

0 commit comments

Comments
 (0)