@@ -39,6 +39,22 @@ crate mod unescape_error_reporting;
39
39
40
40
pub type PResult < ' a , T > = Result < T , DiagnosticBuilder < ' a > > ;
41
41
42
+ /// Collected spans during parsing for places where a certain feature was
43
+ /// used and should be feature gated accordingly in `check_crate`.
44
+ #[ derive( Default ) ]
45
+ pub struct GatedSpans {
46
+ /// Spans collected for gating `param_attrs`, e.g. `fn foo(#[attr] x: u8) {}`.
47
+ pub param_attrs : Lock < Vec < Span > > ,
48
+ /// Spans collected for gating `let_chains`, e.g. `if a && let b = c {}`.
49
+ pub let_chains : Lock < Vec < Span > > ,
50
+ /// Spans collected for gating `async_closure`, e.g. `async || ..`.
51
+ pub async_closure : Lock < Vec < Span > > ,
52
+ /// Spans collected for gating `yield e?` expressions (`generators` gate).
53
+ pub yields : Lock < Vec < Span > > ,
54
+ /// Spans collected for gating `or_patterns`, e.g. `Some(Foo | Bar)`.
55
+ pub or_patterns : Lock < Vec < Span > > ,
56
+ }
57
+
42
58
/// Info about a parsing session.
43
59
pub struct ParseSess {
44
60
pub span_diagnostic : Handler ,
@@ -58,16 +74,8 @@ pub struct ParseSess {
58
74
/// operation token that followed it, but that the parser cannot identify without further
59
75
/// analysis.
60
76
pub ambiguous_block_expr_parse : Lock < FxHashMap < Span , Span > > ,
61
- pub param_attr_spans : Lock < Vec < Span > > ,
62
- // Places where `let` exprs were used and should be feature gated according to `let_chains`.
63
- pub let_chains_spans : Lock < Vec < Span > > ,
64
- // Places where `async || ..` exprs were used and should be feature gated.
65
- pub async_closure_spans : Lock < Vec < Span > > ,
66
- // Places where `yield e?` exprs were used and should be feature gated.
67
- pub yield_spans : Lock < Vec < Span > > ,
68
77
pub injected_crate_name : Once < Symbol > ,
69
- // Places where or-patterns e.g. `Some(Foo | Bar)` were used and should be feature gated.
70
- pub or_pattern_spans : Lock < Vec < Span > > ,
78
+ pub gated_spans : GatedSpans ,
71
79
}
72
80
73
81
impl ParseSess {
@@ -93,12 +101,8 @@ impl ParseSess {
93
101
buffered_lints : Lock :: new ( vec ! [ ] ) ,
94
102
edition : ExpnId :: root ( ) . expn_data ( ) . edition ,
95
103
ambiguous_block_expr_parse : Lock :: new ( FxHashMap :: default ( ) ) ,
96
- param_attr_spans : Lock :: new ( Vec :: new ( ) ) ,
97
- let_chains_spans : Lock :: new ( Vec :: new ( ) ) ,
98
- async_closure_spans : Lock :: new ( Vec :: new ( ) ) ,
99
- yield_spans : Lock :: new ( Vec :: new ( ) ) ,
100
104
injected_crate_name : Once :: new ( ) ,
101
- or_pattern_spans : Lock :: new ( Vec :: new ( ) ) ,
105
+ gated_spans : GatedSpans :: default ( ) ,
102
106
}
103
107
}
104
108
0 commit comments