Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
fc1b45f
constify DoubleEndedIterator
Randl Jan 31, 2026
bf5adeb
Add reference link for HIR ID validator
reddevilmidzy Mar 12, 2026
8e932ed
Use convergent attribute to funcs for GPU targets
Flakebi Dec 4, 2025
df4242f
Document AST lowering implementation
reddevilmidzy Mar 19, 2026
126c923
new on_unimplemented match values
malezjaa Mar 21, 2026
e182fef
stabilize s390x vector registers
folkertdev Mar 21, 2026
2c09d28
start paragraph with upper case
tshepang Mar 23, 2026
8662d07
Merge pull request #2804 from rust-lang/tshepang/fix
tshepang Mar 23, 2026
6a4a3b3
Update information about adding unit tests
Nokel81 Mar 26, 2026
04cec1e
Tweak wording of adding new tests guide
Nokel81 Mar 26, 2026
ea73452
Merge pull request #2806 from Nokel81/patch-1
jyn514 Mar 26, 2026
c9d6463
Mention GPU notification group
apiraino Mar 26, 2026
6eb9ff6
Explain how nested generic args are represented
khyperia Mar 28, 2026
99f0fd9
reflow sentence regarding early bounds
tshepang Mar 28, 2026
66067c6
Merge pull request #2805 from rust-lang/tshepang-patch-1
tshepang Mar 28, 2026
74b3d55
Fix rustc_hir::Crate links
reddevilmidzy Mar 29, 2026
6071f4d
Merge pull request #2810 from reddevilmidzy/hir-crate
reddevilmidzy Mar 29, 2026
a1fd54e
move borrowck tests out of tests/ui/issues
danieljofficial Mar 27, 2026
bb21934
Add explanation of default flags for UI tests
reddevilmidzy Mar 30, 2026
5cbbc61
Merge pull request #2811 from rust-lang/ui
jyn514 Mar 30, 2026
10d2822
add chapter on projection vs trait split
lcnr Mar 30, 2026
ee44565
Merge pull request #2812 from lcnr/main
lcnr Mar 30, 2026
4ffd0b5
reword `Self` parameter bullet point
BoxyUwU Mar 30, 2026
9b073a0
Merge pull request #2809 from khyperia/fix-2776
BoxyUwU Mar 30, 2026
dab7d0a
cleanup
lcnr Mar 30, 2026
c29def2
Merge pull request #2813 from lcnr/main
lcnr Mar 30, 2026
20ce0f0
Fix rustc-pull CI workflow
Kobzol Apr 1, 2026
c11636c
Merge pull request #2815 from Kobzol/ci-pr-author
Kobzol Apr 1, 2026
9a01adc
Change 'ConstValue::ByRef' to 'ConstValue::Indirect'
gurry Apr 2, 2026
8616930
Merge pull request #2817 from gurry/patch-1
tshepang Apr 2, 2026
972b088
Merge pull request #2807 from apiraino/add-gpu-target
apiraino Apr 2, 2026
938b564
Extend and tweak the glossary
fmease Nov 4, 2024
4b81ebf
Merge pull request #2818 from fmease/extend-glossary
fmease Apr 2, 2026
9e06819
Update hir::Crate link
reddevilmidzy Apr 3, 2026
004a414
Merge pull request #2820 from reddevilmidzy/hir
reddevilmidzy Apr 3, 2026
cb37ee2
make field representing types invariant over the base type
BennoLossin Apr 3, 2026
8e36508
test that FRTs are invariant over T
BennoLossin Apr 3, 2026
48db8c7
Update docs to use `TyCtxtEnsureOk::typeck`
reddevilmidzy Apr 3, 2026
20f89a5
Merge pull request #2819 from reddevilmidzy/typeck
reddevilmidzy Apr 4, 2026
8f0bd63
Fix private fields diagnostics and improve error messages
chenyukang Apr 6, 2026
28c9494
Prepare for merging from rust-lang/rust
invalid-email-address Apr 6, 2026
1b2376b
Merge ref '9602bda1dd0c' from rust-lang/rust
invalid-email-address Apr 6, 2026
069e5e0
Merge pull request #2823 from rust-lang/rustc-pull
reddevilmidzy Apr 6, 2026
f9430bb
Don't store `pattern_ty` in `TestableCase`
Zalathar Apr 6, 2026
05320a2
Add getters for `rustc_pattern_analysis::constructor::Slice` fields
ChayimFriedman2 Apr 7, 2026
b400f22
Show the guard exhaustivity note only when it's the guards alone that…
jakubadamw Apr 7, 2026
db8ce5f
Update results for tests affected by the change
jakubadamw Apr 7, 2026
50686ff
add a test for deriving traits on adt with never field
WaffleLapkin Apr 6, 2026
d8c8028
add issue links and blessborrowck tests
danieljofficial Mar 27, 2026
89a4742
Fix ICE in next-solver dyn-compatibility check
cijiugechu Apr 7, 2026
975761c
Use derived impl for `GappedRange` subdiagnostic
mejrs Apr 7, 2026
ef9b7c2
replace span_look_ahead with span_followed_by
chenyukang Apr 3, 2026
ca69168
missing pause
tshepang Apr 8, 2026
8b7de24
Merge pull request #2801 from malezjaa/new-on-unimplemented-match-values
tshepang Apr 8, 2026
1b09ce5
Prepare for merging from rust-lang/rust
invalid-email-address Apr 8, 2026
444452b
Merge ref '30d0309fa821' from rust-lang/rust
invalid-email-address Apr 8, 2026
fdb83d4
Merge pull request #2824 from rust-lang/rustc-pull
tshepang Apr 8, 2026
f803c18
Merge pull request #2800 from reddevilmidzy/ast-low
tshepang Apr 8, 2026
97eb1be
sembr src/appendix/code-index.md
tshepang Apr 8, 2026
49b1d75
re-wrap
tshepang Apr 8, 2026
91cfd3b
sembr src/const-eval/interpret.md
tshepang Apr 8, 2026
238aabb
whitespace
tshepang Apr 8, 2026
67ce02b
sembr src/traits/separate-projection-bounds.md
tshepang Apr 8, 2026
66bf17e
slight improvements
tshepang Apr 8, 2026
425b2b3
skipped by sembr tool (due to "e.g.")
tshepang Apr 8, 2026
b03b12e
sembr src/ty-module/generic-arguments.md
tshepang Apr 8, 2026
7440567
re-wrap
tshepang Apr 8, 2026
2554c21
sembr src/hir.md
tshepang Apr 8, 2026
9634bb7
re-wrap
tshepang Apr 8, 2026
d82e7c1
sembr src/rustdoc-internals.md
tshepang Apr 8, 2026
9c0a072
re-wrap
tshepang Apr 8, 2026
da97a7f
sembr src/tests/adding.md
tshepang Apr 8, 2026
050110d
re-flow
tshepang Apr 8, 2026
5f86947
Merge pull request #2826 from rust-lang/tshepang/nits
tshepang Apr 8, 2026
ee33056
Merge pull request #2825 from rust-lang/tshepang/sembr
tshepang Apr 8, 2026
6f03341
remove unnecessary variables and delimiter check
bb1yd Mar 23, 2026
dd19e01
drive-by cleanup
WaffleLapkin Apr 6, 2026
ddf9d4c
suppress unreachable code lint in automatically derived impls
WaffleLapkin Apr 6, 2026
66a00ba
Rollup merge of #153995 - Flakebi:gpu-use-convergent, r=nnethercote
JonathanBrouwer Apr 8, 2026
3e027ff
Rollup merge of #154184 - folkertdev:stabilize-s390x-vector-registers…
JonathanBrouwer Apr 8, 2026
c8b04b6
Rollup merge of #151898 - Randl:const-double-iter, r=oli-obk
JonathanBrouwer Apr 8, 2026
404ee74
Rollup merge of #154235 - bb1yd:simplify-delim-check, r=fmease
JonathanBrouwer Apr 8, 2026
4ba9940
Rollup merge of #154473 - danieljofficial:move-tests-borrowck, r=Kivooeo
JonathanBrouwer Apr 8, 2026
4a3978a
Rollup merge of #154745 - chenyukang:yukang-fix-span-api, r=nnethercote
JonathanBrouwer Apr 8, 2026
532c2b6
Rollup merge of #154778 - BennoLossin:frt-invariant, r=oli-obk
JonathanBrouwer Apr 8, 2026
7300b25
Rollup merge of #154867 - chenyukang:yukang-fix-151408-private-fields…
JonathanBrouwer Apr 8, 2026
03cf715
Rollup merge of #154879 - Zalathar:pattern-ty, r=Nadrieril
JonathanBrouwer Apr 8, 2026
839aaee
Rollup merge of #154910 - WaffleLapkin:unreachable-derive, r=nnethercote
JonathanBrouwer Apr 8, 2026
faefad7
Rollup merge of #154923 - cijiugechu:fix-ice-unsafe-binders-next-solv…
JonathanBrouwer Apr 8, 2026
e1b15f4
Rollup merge of #154934 - ChayimFriedman2:export-pat-slice, r=Nadrieril
JonathanBrouwer Apr 8, 2026
6b8320f
Rollup merge of #154938 - jakubadamw:issue-104653, r=Nadrieril
JonathanBrouwer Apr 8, 2026
5ef7a3d
Rollup merge of #154961 - mejrs:yeet_the_fixme, r=Nadrieril
JonathanBrouwer Apr 8, 2026
aa6dfed
Rollup merge of #154980 - tshepang:rdg-sync, r=tshepang
JonathanBrouwer Apr 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,23 +129,23 @@ fn get_substructure_equality_expr(
EnumMatching(.., fields) | Struct(.., fields) => {
let combine = move |acc, field| {
let rhs = get_field_equality_expr(cx, field);
if let Some(lhs) = acc {
match acc {
// Combine the previous comparison with the current field
// using logical AND.
return Some(cx.expr_binary(field.span, BinOpKind::And, lhs, rhs));
Some(lhs) => Some(cx.expr_binary(field.span, BinOpKind::And, lhs, rhs)),
// Start the chain with the first field's comparison.
None => Some(rhs),
}
// Start the chain with the first field's comparison.
Some(rhs)
};

// First compare scalar fields, then compound fields, combining all
// with logical AND.
return fields
fields
.iter()
.filter(|field| !field.maybe_scalar)
.fold(fields.iter().filter(|field| field.maybe_scalar).fold(None, combine), combine)
// If there are no fields, treat as always equal.
.unwrap_or_else(|| cx.expr_bool(span, true));
.unwrap_or_else(|| cx.expr_bool(span, true))
}
EnumDiscr(disc, match_expr) => {
let lhs = get_field_equality_expr(cx, disc);
Expand All @@ -154,7 +154,7 @@ fn get_substructure_equality_expr(
};
// Compare the discriminant first (cheaper), then the rest of the
// fields.
return cx.expr_binary(disc.span, BinOpKind::And, lhs, match_expr.clone());
cx.expr_binary(disc.span, BinOpKind::And, lhs, match_expr.clone())
}
StaticEnum(..) => cx.dcx().span_bug(
span,
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_codegen_llvm/src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ fn create_wrapper_function(
None
};

if tcx.sess.target.is_like_gpu {
// Conservatively apply convergent to all functions in case they may call
// a convergent function. Rely on LLVM to optimize away the unnecessary
// convergent attributes.
attributes::apply_to_llfn(
llfn,
llvm::AttributePlace::Function,
&[llvm::AttributeKind::Convergent.create_attr(cx.llcx)],
);
}

let llbb = unsafe { llvm::LLVMAppendBasicBlockInContext(cx.llcx, llfn, c"entry".as_ptr()) };
let mut bx = SBuilder::build(&cx, llbb);

Expand Down
9 changes: 8 additions & 1 deletion compiler/rustc_codegen_llvm/src/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use std::borrow::Borrow;

use itertools::Itertools;
use rustc_codegen_ssa::traits::TypeMembershipCodegenMethods;
use rustc_codegen_ssa::traits::{MiscCodegenMethods, TypeMembershipCodegenMethods};
use rustc_data_structures::fx::FxIndexSet;
use rustc_middle::ty::{Instance, Ty};
use rustc_sanitizers::{cfi, kcfi};
Expand Down Expand Up @@ -70,6 +70,13 @@ pub(crate) fn declare_raw_fn<'ll, 'tcx>(

let mut attrs = SmallVec::<[_; 4]>::new();

if cx.sess().target.is_like_gpu {
// Conservatively apply convergent to all functions in case they may call
// a convergent function. Rely on LLVM to optimize away the unnecessary
// convergent attributes.
attrs.push(llvm::AttributeKind::Convergent.create_attr(cx.llcx));
}

if cx.tcx.sess.opts.cg.no_redzone.unwrap_or(cx.tcx.sess.target.disable_redzone) {
attrs.push(llvm::AttributeKind::NoRedZone.create_attr(cx.llcx));
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ pub(crate) enum AttributeKind {
CapturesNone = 46,
SanitizeRealtimeNonblocking = 47,
SanitizeRealtimeBlocking = 48,
Convergent = 49,
}

/// LLVMIntPredicate
Expand Down
37 changes: 20 additions & 17 deletions compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2439,25 +2439,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
})
.partition(|field| field.2);
err.span_labels(used_private_fields.iter().map(|(_, span, _)| *span), "private field");
if !remaining_private_fields.is_empty() {
let names = if remaining_private_fields.len() > 6 {
String::new()
} else {
format!(
"{} ",
listify(&remaining_private_fields, |(name, _, _)| format!("`{name}`"))
.expect("expected at least one private field to report")
)
};
err.note(format!(
"{}private field{s} {names}that {were} not provided",
if used_fields.is_empty() { "" } else { "...and other " },
s = pluralize!(remaining_private_fields.len()),
were = pluralize!("was", remaining_private_fields.len()),
));
}

if let ty::Adt(def, _) = adt_ty.kind() {
if (def.did().is_local() || !used_fields.is_empty())
&& !remaining_private_fields.is_empty()
{
let names = if remaining_private_fields.len() > 6 {
String::new()
} else {
format!(
"{} ",
listify(&remaining_private_fields, |(name, _, _)| format!("`{name}`"))
.expect("expected at least one private field to report")
)
};
err.note(format!(
"{}private field{s} {names}that {were} not provided",
if used_fields.is_empty() { "" } else { "...and other " },
s = pluralize!(remaining_private_fields.len()),
were = pluralize!("was", remaining_private_fields.len()),
));
}

let def_id = def.did();
let mut items = self
.tcx
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ => {}
}

// Don't emit the lint if we are in an impl marked as `#[automatically_derive]`.
// This is relevant for deriving `Clone` and `PartialEq` on types containing `!`.
if self.tcx.is_automatically_derived(self.tcx.parent(id.owner.def_id.into())) {
return;
}

// Don't warn twice.
self.diverges.set(Diverges::WarnedAlways);

Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ enum class LLVMRustAttributeKind {
CapturesNone = 46,
SanitizeRealtimeNonblocking = 47,
SanitizeRealtimeBlocking = 48,
Convergent = 49,
};

static Attribute::AttrKind fromRust(LLVMRustAttributeKind Kind) {
Expand Down Expand Up @@ -461,6 +462,8 @@ static Attribute::AttrKind fromRust(LLVMRustAttributeKind Kind) {
return Attribute::SanitizeRealtime;
case LLVMRustAttributeKind::SanitizeRealtimeBlocking:
return Attribute::SanitizeRealtimeBlocking;
case LLVMRustAttributeKind::Convergent:
return Attribute::Convergent;
}
report_fatal_error("bad LLVMRustAttributeKind");
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/builder/matches/match_pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ impl<'tcx> MatchPairTree<'tcx> {
}

PatKind::Range(ref range) => {
assert_eq!(pattern.ty, range.ty);
if range.is_full_range(cx.tcx) == Some(true) {
None
} else {
Expand Down Expand Up @@ -380,7 +381,6 @@ impl<'tcx> MatchPairTree<'tcx> {
place,
testable_case,
subpairs,
pattern_ty: pattern.ty,
pattern_span: pattern.span,
})
} else {
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_mir_build/src/builder/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ enum PatConstKind {
/// tested, and a test to perform on that place.
///
/// Each node also has a list of subpairs (possibly empty) that must also match,
/// and a reference to the THIR pattern it represents.
/// and some additional information from the THIR pattern it represents.
#[derive(Debug, Clone)]
pub(crate) struct MatchPairTree<'tcx> {
/// This place...
Expand All @@ -1301,9 +1301,7 @@ pub(crate) struct MatchPairTree<'tcx> {
/// that tests its field for the value `3`.
subpairs: Vec<Self>,

/// Type field of the pattern this node was created from.
pattern_ty: Ty<'tcx>,
/// Span field of the pattern this node was created from.
/// Span field of the THIR pattern this node was created from.
pattern_span: Span,
}

Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_mir_build/src/builder/matches/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
TestKind::ScalarEq { value }
}

TestableCase::Range(ref range) => {
assert_eq!(range.ty, match_pair.pattern_ty);
TestKind::Range(Arc::clone(range))
}
TestableCase::Range(ref range) => TestKind::Range(Arc::clone(range)),

TestableCase::Slice { len, op } => TestKind::SliceLen { len, op },

Expand Down
20 changes: 16 additions & 4 deletions compiler/rustc_mir_build/src/thir/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,18 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
| hir::MatchSource::AwaitDesugar
| hir::MatchSource::FormatArgs => None,
};

// Check if the match would be exhaustive if all guards were removed.
// If so, we leave a note that guards don't count towards exhaustivity.
let would_be_exhaustive_without_guards = {
let any_arm_has_guard = tarms.iter().any(|arm| arm.has_guard);
any_arm_has_guard && {
let guardless_arms: Vec<_> =
tarms.iter().map(|arm| MatchArm { has_guard: false, ..*arm }).collect();
rustc_pattern_analysis::rustc::analyze_match(&cx, &guardless_arms, scrut.ty)
.is_ok_and(|report| report.non_exhaustiveness_witnesses.is_empty())
}
};
self.error = Err(report_non_exhaustive_match(
&cx,
self.thir,
Expand All @@ -540,6 +552,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
witnesses,
arms,
braces_span,
would_be_exhaustive_without_guards,
));
}
}
Expand Down Expand Up @@ -1100,8 +1113,7 @@ fn report_arm_reachability<'p, 'tcx>(
let arm_span = cx.tcx.hir_span(hir_id);
let whole_arm_span = if is_match_arm {
// If the arm is followed by a comma, extend the span to include it.
let with_whitespace = sm.span_extend_while_whitespace(arm_span);
if let Some(comma) = sm.span_look_ahead(with_whitespace, ",", Some(1)) {
if let Some(comma) = sm.span_followed_by(arm_span, ",") {
Some(arm_span.to(comma))
} else {
Some(arm_span)
Expand Down Expand Up @@ -1154,6 +1166,7 @@ fn report_non_exhaustive_match<'p, 'tcx>(
witnesses: Vec<WitnessPat<'p, 'tcx>>,
arms: &[ArmId],
braces_span: Option<Span>,
would_be_exhaustive_without_guards: bool,
) -> ErrorGuaranteed {
let is_empty_match = arms.is_empty();
let non_empty_enum = match scrut_ty.kind() {
Expand Down Expand Up @@ -1364,8 +1377,7 @@ fn report_non_exhaustive_match<'p, 'tcx>(
},
);

let all_arms_have_guards = arms.iter().all(|arm_id| thir[*arm_id].guard.is_some());
if !is_empty_match && all_arms_have_guards {
if would_be_exhaustive_without_guards {
err.subdiagnostic(NonExhaustiveMatchAllArmsGuarded);
}
if let Some((span, sugg)) = suggestion {
Expand Down
11 changes: 4 additions & 7 deletions compiler/rustc_parse/src/lexer/tokentrees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,11 @@ impl<'psess, 'src> Lexer<'psess, 'src> {
let close_spacing = if let Some(close_delim) = self.token.kind.close_delim() {
if close_delim == open_delim {
// Correct delimiter.
let (open_delimiter, open_delimiter_span) =
self.diag_info.open_delimiters.pop().unwrap();
self.diag_info.open_delimiters.pop().unwrap();
let close_delimiter_span = self.token.span;

if tts.is_empty() && close_delim == Delimiter::Brace {
let empty_block_span = open_delimiter_span.to(close_delimiter_span);
let empty_block_span = pre_span.to(close_delimiter_span);
if !sm.is_multiline(empty_block_span) {
// Only track if the block is in the form of `{}`, otherwise it is
// likely that it was written on purpose.
Expand All @@ -86,11 +85,9 @@ impl<'psess, 'src> Lexer<'psess, 'src> {
}

// only add braces
if let (Delimiter::Brace, Delimiter::Brace) = (open_delimiter, open_delim) {
if Delimiter::Brace == open_delim {
// Add all the matching spans, we will sort by span later
self.diag_info
.matching_block_spans
.push((open_delimiter_span, close_delimiter_span));
self.diag_info.matching_block_spans.push((pre_span, close_delimiter_span));
}

// Move past the closing delimiter.
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_pattern_analysis/src/constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,15 @@ impl Slice {
other.kind.covers_length(self.arity())
}

// Getters. They are used by rust-analyzer.
pub fn array_len(self) -> Option<usize> {
self.array_len
}

pub fn kind(self) -> SliceKind {
self.kind
}

/// This computes constructor splitting for variable-length slices, as explained at the top of
/// the file.
///
Expand Down
19 changes: 5 additions & 14 deletions compiler/rustc_pattern_analysis/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use rustc_errors::{Diag, EmissionGuarantee, Subdiagnostic};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_middle::ty::Ty;
use rustc_span::Span;
Expand Down Expand Up @@ -99,25 +98,17 @@ pub struct ExclusiveRangeMissingGap {
pub gap_with: Vec<GappedRange>,
}

#[derive(Subdiagnostic)]
#[label(
"this could appear to continue range `{$first_range}`, but `{$gap}` isn't matched by either of them"
)]
pub struct GappedRange {
#[primary_span]
pub span: Span,
pub gap: String, // a printed pattern
pub first_range: String, // a printed pattern
}

impl Subdiagnostic for GappedRange {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
let GappedRange { span, gap, first_range } = self;

// FIXME(mejrs) Use `#[subdiagnostic(eager)]` instead
let message = format!(
"this could appear to continue range `{first_range}`, but `{gap}` isn't matched by \
either of them"
);
diag.span_label(span, message);
}
}

#[derive(Diagnostic)]
#[diag("some variants are not matched explicitly")]
#[help("ensure that all variants are matched explicitly by adding the suggested match arms")]
Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc_resolve/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1467,11 +1467,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// `const name: Ty = expr;`. This is a heuristic, it will
// break down in the presence of macros.
let sm = self.tcx.sess.source_map();
let type_span = match sm.span_look_ahead(
original_rib_ident_def.span,
":",
None,
) {
let type_span = match sm
.span_followed_by(original_rib_ident_def.span, ":")
{
None => {
Some(original_rib_ident_def.span.shrink_to_hi())
}
Expand Down
Loading
Loading