@@ -39,6 +39,22 @@ crate mod unescape_error_reporting;
3939
4040pub type PResult < ' a , T > = Result < T , DiagnosticBuilder < ' a > > ;
4141
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+
4258/// Info about a parsing session.
4359pub struct ParseSess {
4460 pub span_diagnostic : Handler ,
@@ -58,16 +74,8 @@ pub struct ParseSess {
5874 /// operation token that followed it, but that the parser cannot identify without further
5975 /// analysis.
6076 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 > > ,
6877 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 ,
7179}
7280
7381impl ParseSess {
@@ -93,12 +101,8 @@ impl ParseSess {
93101 buffered_lints : Lock :: new ( vec ! [ ] ) ,
94102 edition : ExpnId :: root ( ) . expn_data ( ) . edition ,
95103 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 ( ) ) ,
100104 injected_crate_name : Once :: new ( ) ,
101- or_pattern_spans : Lock :: new ( Vec :: new ( ) ) ,
105+ gated_spans : GatedSpans :: default ( ) ,
102106 }
103107 }
104108
0 commit comments