Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a357411

Browse files
committed
Auto merge of rust-lang#128719 - matthiaskrgr:rollup-rbjs7bc, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#122792 (Stabilize `min_exhaustive_patterns`) - rust-lang#124944 (On trait bound mismatch, detect multiple crate versions in dep tree) - rust-lang#128273 (Improve `Ord` violation help) - rust-lang#128406 (implement BufReader::peek) - rust-lang#128539 (Forbid unused unsafe in vxworks-specific std modules) - rust-lang#128692 (Add a triagebot mention for `library/Cargo.lock`) - rust-lang#128710 (Don't ICE when getting an input file name's stem fails) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8c7e0e1 + db95a01 commit a357411

File tree

116 files changed

+1477
-1070
lines changed

Some content is hidden

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

116 files changed

+1477
-1070
lines changed

compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ pub enum E2<X> {
585585
V4,
586586
}
587587

588+
#[allow(unreachable_patterns)]
588589
fn check_niche_behavior() {
589590
if let E1::V2 { .. } = (E1::V1 { f: true }) {
590591
intrinsics::abort();

compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ pub enum E2<X> {
430430
V4,
431431
}
432432

433+
#[allow(unreachable_patterns)]
433434
fn check_niche_behavior () {
434435
if let E1::V2 { .. } = (E1::V1 { f: true }) {
435436
intrinsics::abort();

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,16 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
741741
self
742742
}
743743

744+
#[rustc_lint_diagnostics]
745+
pub fn highlighted_span_note(
746+
&mut self,
747+
span: impl Into<MultiSpan>,
748+
msg: Vec<StringPart>,
749+
) -> &mut Self {
750+
self.sub_with_highlights(Level::Note, msg, span.into());
751+
self
752+
}
753+
744754
/// This is like [`Diag::note()`], but it's only printed once.
745755
#[rustc_lint_diagnostics]
746756
pub fn note_once(&mut self, msg: impl Into<SubdiagMessage>) -> &mut Self {
@@ -815,6 +825,17 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
815825
self
816826
}
817827

828+
/// Add a help message attached to this diagnostic with a customizable highlighted message.
829+
#[rustc_lint_diagnostics]
830+
pub fn highlighted_span_help(
831+
&mut self,
832+
span: impl Into<MultiSpan>,
833+
msg: Vec<StringPart>,
834+
) -> &mut Self {
835+
self.sub_with_highlights(Level::Help, msg, span.into());
836+
self
837+
}
838+
818839
/// Prints the span with some help above it.
819840
/// This is like [`Diag::help()`], but it gets its own span.
820841
#[rustc_lint_diagnostics]

compiler/rustc_errors/src/diagnostic_impls.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ macro_rules! into_diag_arg_for_number {
6666
impl IntoDiagArg for $ty {
6767
fn into_diag_arg(self) -> DiagArgValue {
6868
// Convert to a string if it won't fit into `Number`.
69+
#[allow(irrefutable_let_patterns)]
6970
if let Ok(n) = TryInto::<i32>::try_into(self) {
7071
DiagArgValue::Number(n)
7172
} else {

compiler/rustc_errors/src/emitter.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ impl HumanEmitter {
13461346
buffer.append(0, ": ", header_style);
13471347
label_width += 2;
13481348
}
1349-
for (text, _) in msgs.iter() {
1349+
for (text, style) in msgs.iter() {
13501350
let text = self.translate_message(text, args).map_err(Report::new).unwrap();
13511351
// Account for newlines to align output to its label.
13521352
for (line, text) in normalize_whitespace(&text).lines().enumerate() {
@@ -1357,7 +1357,10 @@ impl HumanEmitter {
13571357
if line == 0 { String::new() } else { " ".repeat(label_width) },
13581358
text
13591359
),
1360-
header_style,
1360+
match style {
1361+
Style::Highlight => *style,
1362+
_ => header_style,
1363+
},
13611364
);
13621365
}
13631366
}

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ declare_features! (
267267
(accepted, min_const_generics, "1.51.0", Some(74878)),
268268
/// Allows calling `const unsafe fn` inside `unsafe` blocks in `const fn` functions.
269269
(accepted, min_const_unsafe_fn, "1.33.0", Some(55607)),
270+
/// Allows exhaustive pattern matching on uninhabited types when matched by value.
271+
(accepted, min_exhaustive_patterns, "CURRENT_RUSTC_VERSION", Some(119612)),
270272
/// Allows using `Self` and associated types in struct expressions and patterns.
271273
(accepted, more_struct_aliases, "1.16.0", Some(37544)),
272274
/// Allows using the MOVBE target feature.

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,6 @@ declare_features! (
519519
(unstable, macro_metavar_expr_concat, "1.81.0", Some(124225)),
520520
/// Allows `#[marker]` on certain traits allowing overlapping implementations.
521521
(unstable, marker_trait_attr, "1.30.0", Some(29864)),
522-
/// Allows exhaustive pattern matching on types that contain uninhabited types in cases that are
523-
/// unambiguously sound.
524-
(unstable, min_exhaustive_patterns, "1.77.0", Some(119612)),
525522
/// A minimal, sound subset of specialization intended to be used by the
526523
/// standard library until the soundness issues with specialization
527524
/// are fixed.

compiler/rustc_middle/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#![allow(rustc::diagnostic_outside_of_impl)]
2929
#![allow(rustc::potential_query_instability)]
3030
#![allow(rustc::untranslatable_diagnostic)]
31+
#![cfg_attr(bootstrap, feature(min_exhaustive_patterns))]
3132
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
3233
#![doc(rust_logo)]
3334
#![feature(allocator_api)]
@@ -48,7 +49,6 @@
4849
#![feature(iter_from_coroutine)]
4950
#![feature(let_chains)]
5051
#![feature(macro_metavar_expr)]
51-
#![feature(min_exhaustive_patterns)]
5252
#![feature(min_specialization)]
5353
#![feature(negative_impls)]
5454
#![feature(never_type)]

compiler/rustc_mir_build/src/build/matches/match_pair.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,11 @@ impl<'pat, 'tcx> MatchPairTree<'pat, 'tcx> {
208208
subpairs = cx.field_match_pairs(downcast_place, subpatterns);
209209

210210
let irrefutable = adt_def.variants().iter_enumerated().all(|(i, v)| {
211-
i == variant_index || {
212-
(cx.tcx.features().exhaustive_patterns
213-
|| cx.tcx.features().min_exhaustive_patterns)
214-
&& !v
215-
.inhabited_predicate(cx.tcx, adt_def)
216-
.instantiate(cx.tcx, args)
217-
.apply_ignore_module(cx.tcx, cx.param_env)
218-
}
211+
i == variant_index
212+
|| !v
213+
.inhabited_predicate(cx.tcx, adt_def)
214+
.instantiate(cx.tcx, args)
215+
.apply_ignore_module(cx.tcx, cx.param_env)
219216
}) && (adt_def.did().is_local()
220217
|| !adt_def.is_variant_list_non_exhaustive());
221218
if irrefutable {

compiler/rustc_mir_build/src/thir/pattern/check_match.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
695695

696696
// Emit an extra note if the first uncovered witness would be uninhabited
697697
// if we disregard visibility.
698-
let witness_1_is_privately_uninhabited = if (self.tcx.features().exhaustive_patterns
699-
|| self.tcx.features().min_exhaustive_patterns)
700-
&& let Some(witness_1) = witnesses.get(0)
698+
let witness_1_is_privately_uninhabited = if let Some(witness_1) = witnesses.get(0)
701699
&& let ty::Adt(adt, args) = witness_1.ty().kind()
702700
&& adt.is_enum()
703701
&& let Constructor::Variant(variant_index) = witness_1.ctor()
@@ -1059,7 +1057,7 @@ fn report_non_exhaustive_match<'p, 'tcx>(
10591057
err.note("`&str` cannot be matched exhaustively, so a wildcard `_` is necessary");
10601058
} else if cx.is_foreign_non_exhaustive_enum(ty) {
10611059
err.note(format!("`{ty}` is marked as non-exhaustive, so a wildcard `_` is necessary to match exhaustively"));
1062-
} else if cx.is_uninhabited(ty.inner()) && cx.tcx.features().min_exhaustive_patterns {
1060+
} else if cx.is_uninhabited(ty.inner()) {
10631061
// The type is uninhabited yet there is a witness: we must be in the `MaybeInvalid`
10641062
// case.
10651063
err.note(format!("`{ty}` is uninhabited but is not being matched by value, so a wildcard `_` is required"));

0 commit comments

Comments
 (0)