Skip to content

Commit a28109a

Browse files
committed
Auto merge of #87540 - JohnTitor:rollup-8xc6bl5, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #87315 (Add docs for raw-dylib to unstable book) - #87330 (Use hashbrown's `extend_reserve()` in `HashMap`) - #87443 (Don't treat git repos as non-existent when `ignore_git` is set) - #87453 (Suggest removing unnecessary &mut as help message) - #87500 (Document math behind MIN/MAX consts on integers) - #87501 (Remove min_type_alias_impl_trait in favor of type_alias_impl_trait) - #87507 (SGX mutex is *not* moveable) - #87513 (bootstrap.py: change `git log` option to indicate desired behavior) - #87523 (Stop creating a reference then immediately dereferencing it.) - #87524 (Fix ICE in `diagnostic_hir_wf_check`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents eba3228 + 7985e4c commit a28109a

File tree

393 files changed

+1125
-5197
lines changed

Some content is hidden

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

393 files changed

+1125
-5197
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ impl<'a> PostExpansionVisitor<'a> {
287287
if let ast::TyKind::ImplTrait(..) = ty.kind {
288288
gate_feature_post!(
289289
&self.vis,
290-
min_type_alias_impl_trait,
290+
type_alias_impl_trait,
291291
ty.span,
292292
"`impl Trait` in type aliases is unstable"
293293
);

compiler/rustc_data_structures/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
#![feature(iter_map_while)]
2222
#![feature(maybe_uninit_uninit_array)]
2323
#![feature(min_specialization)]
24-
#![feature(min_type_alias_impl_trait)]
24+
#![cfg_attr(bootstrap, feature(min_type_alias_impl_trait))]
25+
#![cfg_attr(not(bootstrap), feature(type_alias_impl_trait))]
2526
#![feature(new_uninit)]
2627
#![feature(nll)]
2728
#![feature(once_cell)]

compiler/rustc_feature/src/active.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ declare_features! (
486486
(active, async_closure, "1.37.0", Some(62290), None),
487487

488488
/// Allows `impl Trait` to be used inside type aliases (RFC 2515).
489-
(incomplete, type_alias_impl_trait, "1.38.0", Some(63063), None),
489+
(active, type_alias_impl_trait, "1.38.0", Some(63063), None),
490490

491491
/// Allows the definition of `const extern fn` and `const unsafe extern fn`.
492492
(active, const_extern_fn, "1.40.0", Some(64926), None),
@@ -619,9 +619,6 @@ declare_features! (
619619
/// Allows macro attributes to observe output of `#[derive]`.
620620
(active, macro_attributes_in_derive_output, "1.51.0", Some(81119), None),
621621

622-
/// Allows the use of type alias impl trait in function return positions
623-
(active, min_type_alias_impl_trait, "1.52.0", Some(63063), None),
624-
625622
/// Allows associated types in inherent impls.
626623
(incomplete, inherent_associated_types, "1.52.0", Some(8995), None),
627624

compiler/rustc_feature/src/removed.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ declare_features! (
111111
Some("subsumed by `.await` syntax")),
112112
/// Allows defining `existential type`s.
113113
(removed, existential_type, "1.38.0", Some(63063), None,
114-
Some("removed in favor of `#![feature(min_type_alias_impl_trait)]`")),
114+
Some("removed in favor of `#![feature(type_alias_impl_trait)]`")),
115115
/// Allows using the macros:
116116
/// + `__diagnostic_used`
117117
/// + `__register_diagnostic`
@@ -152,6 +152,10 @@ declare_features! (
152152
(removed, impl_trait_in_bindings, "1.55.0", Some(63065), None,
153153
Some("the implementation was not maintainable, the feature may get reintroduced once the current refactorings are done")),
154154

155+
/// Allows the use of type alias impl trait in function return positions
156+
(removed, min_type_alias_impl_trait, "1.55.0", Some(63063), None,
157+
Some("removed in favor of full type_alias_impl_trait")),
158+
155159
// -------------------------------------------------------------------------
156160
// feature-group-end: removed features
157161
// -------------------------------------------------------------------------

compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
242242
.unwrap_or(false) =>
243243
{
244244
err.span_label(span, format!("cannot {ACT}", ACT = act));
245-
err.span_label(span, "try removing `&mut` here");
245+
err.span_suggestion(
246+
span,
247+
"try removing `&mut` here",
248+
String::new(),
249+
Applicability::MaybeIncorrect,
250+
);
246251
}
247252

248253
// We want to suggest users use `let mut` for local (user
@@ -324,7 +329,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
324329
} =>
325330
{
326331
err.span_label(span, format!("cannot {ACT}", ACT = act));
327-
err.span_label(span, "try removing `&mut` here");
332+
err.span_suggestion(
333+
span,
334+
"try removing `&mut` here",
335+
String::new(),
336+
Applicability::MaybeIncorrect,
337+
);
328338
}
329339

330340
PlaceRef { local, projection: [ProjectionElem::Deref] }

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
240240

241241
let mut err = match *error {
242242
SelectionError::Unimplemented => {
243-
// If this obligation was generated as a result of well-formed checking, see if we
244-
// can get a better error message by performing HIR-based well formed checking.
243+
// If this obligation was generated as a result of well-formedness checking, see if we
244+
// can get a better error message by performing HIR-based well-formedness checking.
245245
if let ObligationCauseCode::WellFormed(Some(wf_loc)) =
246246
root_obligation.cause.code.peel_derives()
247247
{

compiler/rustc_typeck/src/hir_wf_check.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ fn diagnostic_hir_wf_check<'tcx>(
3838
// given the type `Option<MyStruct<u8>>`, we will check
3939
// `Option<MyStruct<u8>>`, `MyStruct<u8>`, and `u8`.
4040
// For each type, we perform a well-formed check, and see if we get
41-
// an erorr that matches our expected predicate. We keep save
41+
// an error that matches our expected predicate. We save
4242
// the `ObligationCause` corresponding to the *innermost* type,
4343
// which is the most specific type that we can point to.
4444
// In general, the different components of an `hir::Ty` may have
45-
// completely differentr spans due to macro invocations. Pointing
45+
// completely different spans due to macro invocations. Pointing
4646
// to the most accurate part of the type can be the difference
4747
// between a useless span (e.g. the macro invocation site)
48-
// and a useful span (e.g. a user-provided type passed in to the macro).
48+
// and a useful span (e.g. a user-provided type passed into the macro).
4949
//
5050
// This approach is quite inefficient - we redo a lot of work done
5151
// by the normal WF checker. However, this code is run at most once
5252
// per reported error - it will have no impact when compilation succeeds,
53-
// and should only have an impact if a very large number of errors are
54-
// displaydd to the user.
53+
// and should only have an impact if a very large number of errors is
54+
// displayed to the user.
5555
struct HirWfCheck<'tcx> {
5656
tcx: TyCtxt<'tcx>,
5757
predicate: ty::Predicate<'tcx>,
@@ -126,10 +126,12 @@ fn diagnostic_hir_wf_check<'tcx>(
126126
WellFormedLoc::Ty(_) => match hir.get(hir_id) {
127127
hir::Node::ImplItem(item) => match item.kind {
128128
hir::ImplItemKind::TyAlias(ty) => Some(ty),
129+
hir::ImplItemKind::Const(ty, _) => Some(ty),
129130
ref item => bug!("Unexpected ImplItem {:?}", item),
130131
},
131132
hir::Node::TraitItem(item) => match item.kind {
132133
hir::TraitItemKind::Type(_, ty) => ty,
134+
hir::TraitItemKind::Const(ty, _) => Some(ty),
133135
ref item => bug!("Unexpected TraitItem {:?}", item),
134136
},
135137
hir::Node::Item(item) => match item.kind {

library/alloc/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@
142142
#![feature(alloc_layout_extra)]
143143
#![feature(trusted_random_access)]
144144
#![feature(try_trait_v2)]
145-
#![feature(min_type_alias_impl_trait)]
145+
#![cfg_attr(bootstrap, feature(min_type_alias_impl_trait))]
146+
#![cfg_attr(not(bootstrap), feature(type_alias_impl_trait))]
146147
#![feature(associated_type_bounds)]
147148
#![feature(slice_group_by)]
148149
#![feature(decl_macro)]

library/core/src/num/int_macros.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
macro_rules! int_impl {
2-
($SelfT:ty, $ActualT:ident, $UnsignedT:ty, $BITS:expr, $Min:expr, $Max:expr,
2+
($SelfT:ty, $ActualT:ident, $UnsignedT:ty, $BITS:expr, $BITS_MINUS_ONE:expr, $Min:expr, $Max:expr,
33
$rot:expr, $rot_op:expr, $rot_result:expr, $swap_op:expr, $swapped:expr,
44
$reversed:expr, $le_bytes:expr, $be_bytes:expr,
55
$to_xe_bytes_doc:expr, $from_xe_bytes_doc:expr) => {
6-
/// The smallest value that can be represented by this integer type.
6+
/// The smallest value that can be represented by this integer type,
7+
#[doc = concat!("-2<sup>", $BITS_MINUS_ONE, "</sup>.")]
78
///
89
/// # Examples
910
///
@@ -15,7 +16,8 @@ macro_rules! int_impl {
1516
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
1617
pub const MIN: Self = !0 ^ ((!0 as $UnsignedT) >> 1) as Self;
1718

18-
/// The largest value that can be represented by this integer type.
19+
/// The largest value that can be represented by this integer type,
20+
#[doc = concat!("2<sup>", $BITS_MINUS_ONE, "</sup> - 1.")]
1921
///
2022
/// # Examples
2123
///

library/core/src/num/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -91,34 +91,34 @@ depending on the target pointer size.
9191

9292
#[lang = "i8"]
9393
impl i8 {
94-
int_impl! { i8, i8, u8, 8, -128, 127, 2, "-0x7e", "0xa", "0x12", "0x12", "0x48",
94+
int_impl! { i8, i8, u8, 8, 7, -128, 127, 2, "-0x7e", "0xa", "0x12", "0x12", "0x48",
9595
"[0x12]", "[0x12]", "", "" }
9696
}
9797

9898
#[lang = "i16"]
9999
impl i16 {
100-
int_impl! { i16, i16, u16, 16, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234", "0x3412",
100+
int_impl! { i16, i16, u16, 16, 15, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234", "0x3412",
101101
"0x2c48", "[0x34, 0x12]", "[0x12, 0x34]", "", "" }
102102
}
103103

104104
#[lang = "i32"]
105105
impl i32 {
106-
int_impl! { i32, i32, u32, 32, -2147483648, 2147483647, 8, "0x10000b3", "0xb301",
106+
int_impl! { i32, i32, u32, 32, 31, -2147483648, 2147483647, 8, "0x10000b3", "0xb301",
107107
"0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]",
108108
"[0x12, 0x34, 0x56, 0x78]", "", "" }
109109
}
110110

111111
#[lang = "i64"]
112112
impl i64 {
113-
int_impl! { i64, i64, u64, 64, -9223372036854775808, 9223372036854775807, 12,
113+
int_impl! { i64, i64, u64, 64, 63, -9223372036854775808, 9223372036854775807, 12,
114114
"0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
115115
"0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
116116
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]", "", "" }
117117
}
118118

119119
#[lang = "i128"]
120120
impl i128 {
121-
int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728,
121+
int_impl! { i128, i128, u128, 128, 127, -170141183460469231731687303715884105728,
122122
170141183460469231731687303715884105727, 16,
123123
"0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012",
124124
"0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48",
@@ -131,15 +131,15 @@ impl i128 {
131131
#[cfg(target_pointer_width = "16")]
132132
#[lang = "isize"]
133133
impl isize {
134-
int_impl! { isize, i16, usize, 16, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234",
134+
int_impl! { isize, i16, usize, 16, 15, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234",
135135
"0x3412", "0x2c48", "[0x34, 0x12]", "[0x12, 0x34]",
136136
usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
137137
}
138138

139139
#[cfg(target_pointer_width = "32")]
140140
#[lang = "isize"]
141141
impl isize {
142-
int_impl! { isize, i32, usize, 32, -2147483648, 2147483647, 8, "0x10000b3", "0xb301",
142+
int_impl! { isize, i32, usize, 32, 31, -2147483648, 2147483647, 8, "0x10000b3", "0xb301",
143143
"0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]",
144144
"[0x12, 0x34, 0x56, 0x78]",
145145
usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
@@ -148,7 +148,7 @@ impl isize {
148148
#[cfg(target_pointer_width = "64")]
149149
#[lang = "isize"]
150150
impl isize {
151-
int_impl! { isize, i64, usize, 64, -9223372036854775808, 9223372036854775807,
151+
int_impl! { isize, i64, usize, 64, 63, -9223372036854775808, 9223372036854775807,
152152
12, "0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
153153
"0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
154154
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]",

library/core/src/num/uint_macros.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ macro_rules! uint_impl {
1515
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
1616
pub const MIN: Self = 0;
1717

18-
/// The largest value that can be represented by this integer type.
18+
/// The largest value that can be represented by this integer type,
19+
#[doc = concat!("2<sup>", $BITS, "</sup> - 1.")]
1920
///
2021
/// # Examples
2122
///

library/core/src/ops/range.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -812,12 +812,12 @@ pub trait RangeBounds<T: ?Sized> {
812812
U: ?Sized + PartialOrd<T>,
813813
{
814814
(match self.start_bound() {
815-
Included(ref start) => *start <= item,
816-
Excluded(ref start) => *start < item,
815+
Included(start) => start <= item,
816+
Excluded(start) => start < item,
817817
Unbounded => true,
818818
}) && (match self.end_bound() {
819-
Included(ref end) => item <= *end,
820-
Excluded(ref end) => item < *end,
819+
Included(end) => item <= end,
820+
Excluded(end) => item < end,
821821
Unbounded => true,
822822
})
823823
}

library/std/src/collections/hash/map.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -2821,15 +2821,7 @@ where
28212821

28222822
#[inline]
28232823
fn extend_reserve(&mut self, additional: usize) {
2824-
// self.base.extend_reserve(additional);
2825-
// FIXME: hashbrown should implement this method.
2826-
// But until then, use the same reservation logic:
2827-
2828-
// Reserve the entire hint lower bound if the map is empty.
2829-
// Otherwise reserve half the hint (rounded up), so the map
2830-
// will only resize twice in the worst case.
2831-
let reserve = if self.is_empty() { additional } else { (additional + 1) / 2 };
2832-
self.base.reserve(reserve);
2824+
self.base.extend_reserve(additional);
28332825
}
28342826
}
28352827

library/std/src/sys/sgx/mutex.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ pub struct Mutex {
88
inner: SpinMutex<WaitVariable<bool>>,
99
}
1010

11-
pub type MovableMutex = Mutex;
11+
// not movable: see UnsafeList implementation
12+
pub type MovableMutex = Box<Mutex>;
1213

1314
// Implementation according to “Operating Systems: Three Easy Pieces”, chapter 28
1415
impl Mutex {

library/std/src/sys/sgx/waitqueue/unsafe_list.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ impl<T> UnsafeListEntry<T> {
2323
}
2424
}
2525

26+
// WARNING: self-referential struct!
2627
pub struct UnsafeList<T> {
2728
head_tail: NonNull<UnsafeListEntry<T>>,
2829
head_tail_entry: Option<UnsafeListEntry<T>>,

src/bootstrap/bootstrap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def download_toolchain(self, stage0=True, rustc_channel=None):
473473
]).decode(sys.getdefaultencoding()).strip()
474474
llvm_sha = subprocess.check_output([
475475
"git", "log", "--author=bors", "--format=%H", "-n1",
476-
"-m", "--first-parent",
476+
"--no-patch", "--first-parent",
477477
"--",
478478
"{}/src/llvm-project".format(top_level),
479479
"{}/src/bootstrap/download-ci-llvm-stamp".format(top_level),

0 commit comments

Comments
 (0)