@@ -35,7 +35,7 @@ struct PatCtxt<'a, 'tcx> {
35
35
typeck_results : & ' a ty:: TypeckResults < ' tcx > ,
36
36
37
37
/// Used by the Rust 2024 migration lint.
38
- rust_2024_migration_suggestion : Option < Rust2024IncompatiblePatSugg < ' a > > ,
38
+ rust_2024_migration_suggestion : Option < Rust2024IncompatiblePatSugg > ,
39
39
}
40
40
41
41
pub ( super ) fn pat_from_hir < ' a , ' tcx > (
@@ -44,25 +44,23 @@ pub(super) fn pat_from_hir<'a, 'tcx>(
44
44
typeck_results : & ' a ty:: TypeckResults < ' tcx > ,
45
45
pat : & ' tcx hir:: Pat < ' tcx > ,
46
46
) -> Box < Pat < ' tcx > > {
47
+ let migration_labels = typeck_results. rust_2024_migration_desugared_pats ( ) . get ( pat. hir_id ) ;
47
48
let mut pcx = PatCtxt {
48
49
tcx,
49
50
typing_env,
50
51
typeck_results,
51
- rust_2024_migration_suggestion : typeck_results
52
- . rust_2024_migration_desugared_pats ( )
53
- . get ( pat. hir_id )
54
- . map ( |labels| Rust2024IncompatiblePatSugg {
55
- suggestion : Vec :: new ( ) ,
56
- ref_pattern_count : 0 ,
57
- binding_mode_count : 0 ,
58
- labels : labels. as_slice ( ) ,
59
- } ) ,
52
+ rust_2024_migration_suggestion : migration_labels. and ( Some ( Rust2024IncompatiblePatSugg {
53
+ suggestion : Vec :: new ( ) ,
54
+ ref_pattern_count : 0 ,
55
+ binding_mode_count : 0 ,
56
+ } ) ) ,
60
57
} ;
61
58
let result = pcx. lower_pattern ( pat) ;
62
59
debug ! ( "pat_from_hir({:?}) = {:?}" , pat, result) ;
63
- if let Some ( sugg) = pcx. rust_2024_migration_suggestion {
64
- let mut spans = MultiSpan :: from_spans ( sugg. labels . iter ( ) . map ( |( span, _) | * span) . collect ( ) ) ;
65
- for ( span, label) in sugg. labels {
60
+ if let Some ( labels) = migration_labels {
61
+ let sugg = pcx. rust_2024_migration_suggestion . expect ( "suggestion should be present" ) ;
62
+ let mut spans = MultiSpan :: from_spans ( labels. iter ( ) . map ( |( span, _) | * span) . collect ( ) ) ;
63
+ for ( span, label) in labels {
66
64
spans. push_span_label ( * span, label. clone ( ) ) ;
67
65
}
68
66
// If a relevant span is from at least edition 2024, this is a hard error.
0 commit comments