@@ -581,7 +581,7 @@ impl MaybeExported<'_> {
581
581
}
582
582
583
583
#[ derive( Default ) ]
584
- struct DiagnosticMetadata < ' ast > {
584
+ struct DiagMetadata < ' ast > {
585
585
/// The current trait's associated items' ident, used for diagnostic suggestions.
586
586
current_trait_assoc_items : Option < & ' ast [ P < AssocItem > ] > ,
587
587
@@ -674,7 +674,7 @@ struct LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
674
674
current_trait_ref : Option < ( Module < ' a > , TraitRef ) > ,
675
675
676
676
/// Fields used to add information to diagnostic errors.
677
- diagnostic_metadata : Box < DiagnosticMetadata < ' ast > > ,
677
+ diag_metadata : Box < DiagMetadata < ' ast > > ,
678
678
679
679
/// State used to know whether to ignore resolution errors for function bodies.
680
680
///
@@ -694,12 +694,12 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
694
694
// as they do not correspond to actual code.
695
695
}
696
696
fn visit_item ( & mut self , item : & ' ast Item ) {
697
- let prev = replace ( & mut self . diagnostic_metadata . current_item , Some ( item) ) ;
697
+ let prev = replace ( & mut self . diag_metadata . current_item , Some ( item) ) ;
698
698
// Always report errors in items we just entered.
699
699
let old_ignore = replace ( & mut self . in_func_body , false ) ;
700
700
self . with_lifetime_rib ( LifetimeRibKind :: Item , |this| this. resolve_item ( item) ) ;
701
701
self . in_func_body = old_ignore;
702
- self . diagnostic_metadata . current_item = prev;
702
+ self . diag_metadata . current_item = prev;
703
703
}
704
704
fn visit_arm ( & mut self , arm : & ' ast Arm ) {
705
705
self . resolve_arm ( arm) ;
@@ -716,10 +716,10 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
716
716
self . resolve_expr ( expr, None ) ;
717
717
}
718
718
fn visit_pat ( & mut self , p : & ' ast Pat ) {
719
- let prev = self . diagnostic_metadata . current_pat ;
720
- self . diagnostic_metadata . current_pat = Some ( p) ;
719
+ let prev = self . diag_metadata . current_pat ;
720
+ self . diag_metadata . current_pat = Some ( p) ;
721
721
visit:: walk_pat ( self , p) ;
722
- self . diagnostic_metadata . current_pat = prev;
722
+ self . diag_metadata . current_pat = prev;
723
723
}
724
724
fn visit_local ( & mut self , local : & ' ast Local ) {
725
725
let local_spans = match local. pat . kind {
@@ -731,13 +731,13 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
731
731
local. kind . init ( ) . map ( |init| init. span ) ,
732
732
) ) ,
733
733
} ;
734
- let original = replace ( & mut self . diagnostic_metadata . current_let_binding , local_spans) ;
734
+ let original = replace ( & mut self . diag_metadata . current_let_binding , local_spans) ;
735
735
self . resolve_local ( local) ;
736
- self . diagnostic_metadata . current_let_binding = original;
736
+ self . diag_metadata . current_let_binding = original;
737
737
}
738
738
fn visit_ty ( & mut self , ty : & ' ast Ty ) {
739
- let prev = self . diagnostic_metadata . current_trait_object ;
740
- let prev_ty = self . diagnostic_metadata . current_type_path ;
739
+ let prev = self . diag_metadata . current_trait_object ;
740
+ let prev_ty = self . diag_metadata . current_type_path ;
741
741
match & ty. kind {
742
742
TyKind :: Ref ( None , _) => {
743
743
// Elided lifetime in reference: we resolve as if there was some lifetime `'_` with
@@ -748,7 +748,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
748
748
visit:: walk_ty ( self , ty) ;
749
749
}
750
750
TyKind :: Path ( qself, path) => {
751
- self . diagnostic_metadata . current_type_path = Some ( ty) ;
751
+ self . diag_metadata . current_type_path = Some ( ty) ;
752
752
self . smart_resolve_path ( ty. id , qself, path, PathSource :: Type ) ;
753
753
754
754
// Check whether we should interpret this as a bare trait object.
@@ -795,7 +795,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
795
795
self . lifetime_elision_candidates = candidates;
796
796
}
797
797
TyKind :: TraitObject ( bounds, ..) => {
798
- self . diagnostic_metadata . current_trait_object = Some ( & bounds[ ..] ) ;
798
+ self . diag_metadata . current_trait_object = Some ( & bounds[ ..] ) ;
799
799
visit:: walk_ty ( self , ty)
800
800
}
801
801
TyKind :: BareFn ( bare_fn) => {
@@ -842,8 +842,8 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
842
842
}
843
843
_ => visit:: walk_ty ( self , ty) ,
844
844
}
845
- self . diagnostic_metadata . current_trait_object = prev;
846
- self . diagnostic_metadata . current_type_path = prev_ty;
845
+ self . diag_metadata . current_trait_object = prev;
846
+ self . diag_metadata . current_type_path = prev_ty;
847
847
}
848
848
fn visit_poly_trait_ref ( & mut self , tref : & ' ast PolyTraitRef ) {
849
849
let span = tref. span . shrink_to_lo ( ) . to ( tref. trait_ref . path . span . shrink_to_lo ( ) ) ;
@@ -906,7 +906,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
906
906
}
907
907
}
908
908
fn visit_fn ( & mut self , fn_kind : FnKind < ' ast > , sp : Span , fn_id : NodeId ) {
909
- let previous_value = self . diagnostic_metadata . current_function ;
909
+ let previous_value = self . diag_metadata . current_function ;
910
910
match fn_kind {
911
911
// Bail if the function is foreign, and thus cannot validly have
912
912
// a body, or if there's no body for some other reason.
@@ -939,7 +939,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
939
939
return ;
940
940
}
941
941
FnKind :: Fn ( ..) => {
942
- self . diagnostic_metadata . current_function = Some ( ( fn_kind, sp) ) ;
942
+ self . diag_metadata . current_function = Some ( ( fn_kind, sp) ) ;
943
943
}
944
944
// Do not update `current_function` for closures: it suggests `self` parameters.
945
945
FnKind :: Closure ( ..) => { }
@@ -1040,17 +1040,14 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
1040
1040
}
1041
1041
} )
1042
1042
} ) ;
1043
- self . diagnostic_metadata . current_function = previous_value;
1043
+ self . diag_metadata . current_function = previous_value;
1044
1044
}
1045
1045
fn visit_lifetime ( & mut self , lifetime : & ' ast Lifetime , use_ctxt : visit:: LifetimeCtxt ) {
1046
1046
self . resolve_lifetime ( lifetime, use_ctxt)
1047
1047
}
1048
1048
1049
1049
fn visit_generics ( & mut self , generics : & ' ast Generics ) {
1050
- self . visit_generic_params (
1051
- & generics. params ,
1052
- self . diagnostic_metadata . current_self_item . is_some ( ) ,
1053
- ) ;
1050
+ self . visit_generic_params ( & generics. params , self . diag_metadata . current_self_item . is_some ( ) ) ;
1054
1051
for p in & generics. where_clause . predicates {
1055
1052
self . visit_where_predicate ( p) ;
1056
1053
}
@@ -1062,15 +1059,15 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
1062
1059
ClosureBinder :: For { generic_params, .. } => {
1063
1060
self . visit_generic_params (
1064
1061
generic_params,
1065
- self . diagnostic_metadata . current_self_item . is_some ( ) ,
1062
+ self . diag_metadata . current_self_item . is_some ( ) ,
1066
1063
) ;
1067
1064
}
1068
1065
}
1069
1066
}
1070
1067
1071
1068
fn visit_generic_arg ( & mut self , arg : & ' ast GenericArg ) {
1072
1069
debug ! ( "visit_generic_arg({:?})" , arg) ;
1073
- let prev = replace ( & mut self . diagnostic_metadata . currently_processing_generic_args , true ) ;
1070
+ let prev = replace ( & mut self . diag_metadata . currently_processing_generic_args , true ) ;
1074
1071
match arg {
1075
1072
GenericArg :: Type ( ref ty) => {
1076
1073
// We parse const arguments as path types as we cannot distinguish them during
@@ -1101,7 +1098,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
1101
1098
} ,
1102
1099
) ;
1103
1100
1104
- self . diagnostic_metadata . currently_processing_generic_args = prev;
1101
+ self . diag_metadata . currently_processing_generic_args = prev;
1105
1102
return ;
1106
1103
}
1107
1104
}
@@ -1114,7 +1111,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
1114
1111
self . resolve_anon_const ( ct, AnonConstKind :: ConstArg ( IsRepeatExpr :: No ) )
1115
1112
}
1116
1113
}
1117
- self . diagnostic_metadata . currently_processing_generic_args = prev;
1114
+ self . diag_metadata . currently_processing_generic_args = prev;
1118
1115
}
1119
1116
1120
1117
fn visit_assoc_constraint ( & mut self , constraint : & ' ast AssocConstraint ) {
@@ -1192,8 +1189,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
1192
1189
1193
1190
fn visit_where_predicate ( & mut self , p : & ' ast WherePredicate ) {
1194
1191
debug ! ( "visit_where_predicate {:?}" , p) ;
1195
- let previous_value =
1196
- replace ( & mut self . diagnostic_metadata . current_where_predicate , Some ( p) ) ;
1192
+ let previous_value = replace ( & mut self . diag_metadata . current_where_predicate , Some ( p) ) ;
1197
1193
self . with_lifetime_rib ( LifetimeRibKind :: AnonymousReportError , |this| {
1198
1194
if let WherePredicate :: BoundPredicate ( WhereBoundPredicate {
1199
1195
ref bounded_ty,
@@ -1224,7 +1220,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
1224
1220
visit:: walk_where_predicate ( this, p) ;
1225
1221
}
1226
1222
} ) ;
1227
- self . diagnostic_metadata . current_where_predicate = previous_value;
1223
+ self . diag_metadata . current_where_predicate = previous_value;
1228
1224
}
1229
1225
1230
1226
fn visit_inline_asm ( & mut self , asm : & ' ast InlineAsm ) {
@@ -1297,7 +1293,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
1297
1293
lifetime_ribs : Vec :: new ( ) ,
1298
1294
lifetime_elision_candidates : None ,
1299
1295
current_trait_ref : None ,
1300
- diagnostic_metadata : Default :: default ( ) ,
1296
+ diag_metadata : Default :: default ( ) ,
1301
1297
// errors at module scope should always be reported
1302
1298
in_func_body : false ,
1303
1299
lifetime_uses : Default :: default ( ) ,
@@ -1707,7 +1703,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
1707
1703
return ;
1708
1704
}
1709
1705
LifetimeRibKind :: ElisionFailure => {
1710
- self . diagnostic_metadata . current_elision_failures . push ( missing_lifetime) ;
1706
+ self . diag_metadata . current_elision_failures . push ( missing_lifetime) ;
1711
1707
self . record_lifetime_res ( lifetime. id , LifetimeRes :: Error , elision_candidate) ;
1712
1708
return ;
1713
1709
}
@@ -1911,7 +1907,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
1911
1907
break ;
1912
1908
}
1913
1909
LifetimeRibKind :: ElisionFailure => {
1914
- self . diagnostic_metadata . current_elision_failures . push ( missing_lifetime) ;
1910
+ self . diag_metadata . current_elision_failures . push ( missing_lifetime) ;
1915
1911
for id in node_ids {
1916
1912
self . record_lifetime_res (
1917
1913
id,
@@ -2003,7 +1999,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2003
1999
let elision_lifetime = self . resolve_fn_params ( has_self, inputs) ;
2004
2000
debug ! ( ?elision_lifetime) ;
2005
2001
2006
- let outer_failures = take ( & mut self . diagnostic_metadata . current_elision_failures ) ;
2002
+ let outer_failures = take ( & mut self . diag_metadata . current_elision_failures ) ;
2007
2003
let output_rib = if let Ok ( res) = elision_lifetime. as_ref ( ) {
2008
2004
self . r . lifetime_elision_allowed . insert ( fn_id) ;
2009
2005
LifetimeRibKind :: Elided ( * res)
@@ -2012,7 +2008,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2012
2008
} ;
2013
2009
self . with_lifetime_rib ( output_rib, |this| visit:: walk_fn_ret_ty ( this, output_ty) ) ;
2014
2010
let elision_failures =
2015
- replace ( & mut self . diagnostic_metadata . current_elision_failures , outer_failures) ;
2011
+ replace ( & mut self . diag_metadata . current_elision_failures , outer_failures) ;
2016
2012
if !elision_failures. is_empty ( ) {
2017
2013
let Err ( failure_info) = elision_lifetime else { bug ! ( ) } ;
2018
2014
self . report_missing_lifetime_specifiers ( elision_failures, Some ( failure_info) ) ;
@@ -2187,7 +2183,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2187
2183
}
2188
2184
2189
2185
let impl_self = self
2190
- . diagnostic_metadata
2186
+ . diag_metadata
2191
2187
. current_self_type
2192
2188
. as_ref ( )
2193
2189
. and_then ( |ty| {
@@ -2385,7 +2381,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2385
2381
items : ref impl_items,
2386
2382
..
2387
2383
} ) => {
2388
- self . diagnostic_metadata . current_impl_items = Some ( impl_items) ;
2384
+ self . diag_metadata . current_impl_items = Some ( impl_items) ;
2389
2385
self . resolve_implementation (
2390
2386
& item. attrs ,
2391
2387
generics,
@@ -2394,7 +2390,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2394
2390
item. id ,
2395
2391
impl_items,
2396
2392
) ;
2397
- self . diagnostic_metadata . current_impl_items = None ;
2393
+ self . diag_metadata . current_impl_items = None ;
2398
2394
}
2399
2395
2400
2396
ItemKind :: Trait ( box Trait { ref generics, ref bounds, ref items, .. } ) => {
@@ -2744,24 +2740,23 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2744
2740
fn with_current_self_type < T > ( & mut self , self_type : & Ty , f : impl FnOnce ( & mut Self ) -> T ) -> T {
2745
2741
// Handle nested impls (inside fn bodies)
2746
2742
let previous_value =
2747
- replace ( & mut self . diagnostic_metadata . current_self_type , Some ( self_type. clone ( ) ) ) ;
2743
+ replace ( & mut self . diag_metadata . current_self_type , Some ( self_type. clone ( ) ) ) ;
2748
2744
let result = f ( self ) ;
2749
- self . diagnostic_metadata . current_self_type = previous_value;
2745
+ self . diag_metadata . current_self_type = previous_value;
2750
2746
result
2751
2747
}
2752
2748
2753
2749
fn with_current_self_item < T > ( & mut self , self_item : & Item , f : impl FnOnce ( & mut Self ) -> T ) -> T {
2754
- let previous_value =
2755
- replace ( & mut self . diagnostic_metadata . current_self_item , Some ( self_item. id ) ) ;
2750
+ let previous_value = replace ( & mut self . diag_metadata . current_self_item , Some ( self_item. id ) ) ;
2756
2751
let result = f ( self ) ;
2757
- self . diagnostic_metadata . current_self_item = previous_value;
2752
+ self . diag_metadata . current_self_item = previous_value;
2758
2753
result
2759
2754
}
2760
2755
2761
2756
/// When evaluating a `trait` use its associated types' idents for suggestions in E0412.
2762
2757
fn resolve_trait_items ( & mut self , trait_items : & ' ast [ P < AssocItem > ] ) {
2763
2758
let trait_assoc_items =
2764
- replace ( & mut self . diagnostic_metadata . current_trait_assoc_items , Some ( trait_items) ) ;
2759
+ replace ( & mut self . diag_metadata . current_trait_assoc_items , Some ( trait_items) ) ;
2765
2760
2766
2761
let walk_assoc_item =
2767
2762
|this : & mut Self , generics : & Generics , kind, item : & ' ast AssocItem | {
@@ -2818,7 +2813,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2818
2813
} ;
2819
2814
}
2820
2815
2821
- self . diagnostic_metadata . current_trait_assoc_items = trait_assoc_items;
2816
+ self . diag_metadata . current_trait_assoc_items = trait_assoc_items;
2822
2817
}
2823
2818
2824
2819
/// This is called to resolve a trait reference from an `impl` (i.e., `impl Trait for Foo`).
@@ -2832,7 +2827,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2832
2827
let mut new_id = None ;
2833
2828
if let Some ( trait_ref) = opt_trait_ref {
2834
2829
let path: Vec < _ > = Segment :: from_path ( & trait_ref. path ) ;
2835
- self . diagnostic_metadata . currently_processing_impl_trait =
2830
+ self . diag_metadata . currently_processing_impl_trait =
2836
2831
Some ( ( trait_ref. clone ( ) , self_type. clone ( ) ) ) ;
2837
2832
let res = self . smart_resolve_path_fragment (
2838
2833
& None ,
@@ -2841,7 +2836,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2841
2836
Finalize :: new ( trait_ref. ref_id , trait_ref. path . span ) ,
2842
2837
RecordPartialRes :: Yes ,
2843
2838
) ;
2844
- self . diagnostic_metadata . currently_processing_impl_trait = None ;
2839
+ self . diag_metadata . currently_processing_impl_trait = None ;
2845
2840
if let Some ( def_id) = res. expect_full_res ( ) . opt_def_id ( ) {
2846
2841
new_id = Some ( def_id) ;
2847
2842
new_val = Some ( ( self . r . expect_module ( def_id) , trait_ref. clone ( ) ) ) ;
@@ -3737,7 +3732,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
3737
3732
3738
3733
let def_id = this. parent_scope . module . nearest_parent_mod ( ) ;
3739
3734
let instead = res. is_some ( ) ;
3740
- let suggestion = if let Some ( ( start, end) ) = this. diagnostic_metadata . in_range
3735
+ let suggestion = if let Some ( ( start, end) ) = this. diag_metadata . in_range
3741
3736
&& path[ 0 ] . ident . span . lo ( ) == end. span . lo ( )
3742
3737
{
3743
3738
let mut sugg = "." ;
@@ -3890,7 +3885,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
3890
3885
) {
3891
3886
Ok ( Some ( partial_res) ) if let Some ( res) = partial_res. full_res ( ) => {
3892
3887
// if we also have an associated type that matches the ident, stash a suggestion
3893
- if let Some ( items) = self . diagnostic_metadata . current_trait_assoc_items
3888
+ if let Some ( items) = self . diag_metadata . current_trait_assoc_items
3894
3889
&& let [ Segment { ident, .. } ] = path
3895
3890
&& items. iter ( ) . any ( |item| {
3896
3891
item. ident == * ident && matches ! ( item. kind, AssocItemKind :: Type ( _) )
@@ -4187,7 +4182,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
4187
4182
fn with_resolved_label ( & mut self , label : Option < Label > , id : NodeId , f : impl FnOnce ( & mut Self ) ) {
4188
4183
if let Some ( label) = label {
4189
4184
if label. ident . as_str ( ) . as_bytes ( ) [ 1 ] != b'_' {
4190
- self . diagnostic_metadata . unused_labels . insert ( id, label. ident . span ) ;
4185
+ self . diag_metadata . unused_labels . insert ( id, label. ident . span ) ;
4191
4186
}
4192
4187
4193
4188
if let Ok ( ( _, orig_span) ) = self . resolve_label ( label. ident ) {
@@ -4224,12 +4219,12 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
4224
4219
self . ribs [ ValueNS ] . push ( Rib :: new ( RibKind :: Normal ) ) ;
4225
4220
}
4226
4221
4227
- let prev = self . diagnostic_metadata . current_block_could_be_bare_struct_literal . take ( ) ;
4222
+ let prev = self . diag_metadata . current_block_could_be_bare_struct_literal . take ( ) ;
4228
4223
if let ( true , [ Stmt { kind : StmtKind :: Expr ( expr) , .. } ] ) =
4229
4224
( block. could_be_bare_literal , & block. stmts [ ..] )
4230
4225
&& let ExprKind :: Type ( ..) = expr. kind
4231
4226
{
4232
- self . diagnostic_metadata . current_block_could_be_bare_struct_literal = Some ( block. span ) ;
4227
+ self . diag_metadata . current_block_could_be_bare_struct_literal = Some ( block. span ) ;
4233
4228
}
4234
4229
// Descend into the block.
4235
4230
for stmt in & block. stmts {
@@ -4244,7 +4239,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
4244
4239
4245
4240
self . visit_stmt ( stmt) ;
4246
4241
}
4247
- self . diagnostic_metadata . current_block_could_be_bare_struct_literal = prev;
4242
+ self . diag_metadata . current_block_could_be_bare_struct_literal = prev;
4248
4243
4249
4244
// Move back up.
4250
4245
self . parent_scope . module = orig_module;
@@ -4351,7 +4346,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
4351
4346
Ok ( ( node_id, _) ) => {
4352
4347
// Since this res is a label, it is never read.
4353
4348
self . r . label_res_map . insert ( expr. id , node_id) ;
4354
- self . diagnostic_metadata . unused_labels . remove ( & node_id) ;
4349
+ self . diag_metadata . unused_labels . remove ( & node_id) ;
4355
4350
}
4356
4351
Err ( error) => {
4357
4352
self . report_error ( label. ident . span , error) ;
@@ -4375,9 +4370,9 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
4375
4370
4376
4371
ExprKind :: If ( ref cond, ref then, ref opt_else) => {
4377
4372
self . with_rib ( ValueNS , RibKind :: Normal , |this| {
4378
- let old = this. diagnostic_metadata . in_if_condition . replace ( cond) ;
4373
+ let old = this. diag_metadata . in_if_condition . replace ( cond) ;
4379
4374
this. visit_expr ( cond) ;
4380
- this. diagnostic_metadata . in_if_condition = old;
4375
+ this. diag_metadata . in_if_condition = old;
4381
4376
this. visit_block ( then) ;
4382
4377
} ) ;
4383
4378
if let Some ( expr) = opt_else {
@@ -4392,9 +4387,9 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
4392
4387
ExprKind :: While ( ref cond, ref block, label) => {
4393
4388
self . with_resolved_label ( label, expr. id , |this| {
4394
4389
this. with_rib ( ValueNS , RibKind :: Normal , |this| {
4395
- let old = this. diagnostic_metadata . in_if_condition . replace ( cond) ;
4390
+ let old = this. diag_metadata . in_if_condition . replace ( cond) ;
4396
4391
this. visit_expr ( cond) ;
4397
- this. diagnostic_metadata . in_if_condition = old;
4392
+ this. diag_metadata . in_if_condition = old;
4398
4393
this. visit_block ( block) ;
4399
4394
} )
4400
4395
} ) ;
@@ -4474,20 +4469,20 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
4474
4469
self . visit_expr ( idx) ;
4475
4470
}
4476
4471
ExprKind :: Assign ( ref lhs, ref rhs, _) => {
4477
- if !self . diagnostic_metadata . is_assign_rhs {
4478
- self . diagnostic_metadata . in_assignment = Some ( expr) ;
4472
+ if !self . diag_metadata . is_assign_rhs {
4473
+ self . diag_metadata . in_assignment = Some ( expr) ;
4479
4474
}
4480
4475
self . visit_expr ( lhs) ;
4481
- self . diagnostic_metadata . is_assign_rhs = true ;
4482
- self . diagnostic_metadata . in_assignment = None ;
4476
+ self . diag_metadata . is_assign_rhs = true ;
4477
+ self . diag_metadata . in_assignment = None ;
4483
4478
self . visit_expr ( rhs) ;
4484
- self . diagnostic_metadata . is_assign_rhs = false ;
4479
+ self . diag_metadata . is_assign_rhs = false ;
4485
4480
}
4486
4481
ExprKind :: Range ( Some ( ref start) , Some ( ref end) , RangeLimits :: HalfOpen ) => {
4487
- self . diagnostic_metadata . in_range = Some ( ( start, end) ) ;
4482
+ self . diag_metadata . in_range = Some ( ( start, end) ) ;
4488
4483
self . resolve_expr ( start, Some ( expr) ) ;
4489
4484
self . resolve_expr ( end, Some ( expr) ) ;
4490
- self . diagnostic_metadata . in_range = None ;
4485
+ self . diag_metadata . in_range = None ;
4491
4486
}
4492
4487
_ => {
4493
4488
visit:: walk_expr ( self , expr) ;
@@ -4735,7 +4730,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
4735
4730
let mut late_resolution_visitor = LateResolutionVisitor :: new ( self ) ;
4736
4731
late_resolution_visitor. resolve_doc_links ( & krate. attrs , MaybeExported :: Ok ( CRATE_NODE_ID ) ) ;
4737
4732
visit:: walk_crate ( & mut late_resolution_visitor, krate) ;
4738
- for ( id, span) in late_resolution_visitor. diagnostic_metadata . unused_labels . iter ( ) {
4733
+ for ( id, span) in late_resolution_visitor. diag_metadata . unused_labels . iter ( ) {
4739
4734
self . lint_buffer . buffer_lint ( lint:: builtin:: UNUSED_LABELS , * id, * span, "unused label" ) ;
4740
4735
}
4741
4736
}
0 commit comments