@@ -30,14 +30,27 @@ macro_rules! gate {
30
30
}
31
31
32
32
/// The unusual case, where the `has_feature` condition is non-standard.
33
- macro_rules! gate_alt {
33
+ macro_rules! gate_complex {
34
34
( $visitor: expr, $has_feature: expr, $name: expr, $span: expr, $explain: expr) => { {
35
35
if !$has_feature && !$span. allows_unstable( $name) {
36
36
feature_err( & $visitor. sess. parse_sess, $name, $span, $explain) . emit( ) ;
37
37
}
38
38
} } ;
39
39
}
40
40
41
+ /// The case involving a multispan.
42
+ macro_rules! gate_multi {
43
+ ( $visitor: expr, $feature: ident, $spans: expr, $explain: expr) => { {
44
+ if !$visitor. features. $feature {
45
+ let spans: Vec <_> =
46
+ $spans. filter( |span| !span. allows_unstable( sym:: $feature) ) . collect( ) ;
47
+ if !spans. is_empty( ) {
48
+ feature_err( & $visitor. sess. parse_sess, sym:: $feature, spans, $explain) . emit( ) ;
49
+ }
50
+ }
51
+ } } ;
52
+ }
53
+
41
54
/// The legacy case.
42
55
macro_rules! gate_legacy {
43
56
( $visitor: expr, $feature: ident, $span: expr, $explain: expr) => { {
@@ -141,23 +154,16 @@ impl<'a> PostExpansionVisitor<'a> {
141
154
fn check_late_bound_lifetime_defs ( & self , params : & [ ast:: GenericParam ] ) {
142
155
// Check only lifetime parameters are present and that the lifetime
143
156
// parameters that are present have no bounds.
144
- let non_lt_param_spans: Vec < _ > = params
145
- . iter ( )
146
- . filter_map ( |param| match param. kind {
147
- ast:: GenericParamKind :: Lifetime { .. } => None ,
148
- _ => Some ( param. ident . span ) ,
149
- } )
150
- . collect ( ) ;
151
- // FIXME: gate_feature_post doesn't really handle multispans...
152
- if !non_lt_param_spans. is_empty ( ) && !self . features . non_lifetime_binders {
153
- feature_err (
154
- & self . sess . parse_sess ,
155
- sym:: non_lifetime_binders,
156
- non_lt_param_spans,
157
- crate :: fluent_generated:: ast_passes_forbidden_non_lifetime_param,
158
- )
159
- . emit ( ) ;
160
- }
157
+ let non_lt_param_spans = params. iter ( ) . filter_map ( |param| match param. kind {
158
+ ast:: GenericParamKind :: Lifetime { .. } => None ,
159
+ _ => Some ( param. ident . span ) ,
160
+ } ) ;
161
+ gate_multi ! (
162
+ & self ,
163
+ non_lifetime_binders,
164
+ non_lt_param_spans,
165
+ crate :: fluent_generated:: ast_passes_forbidden_non_lifetime_param
166
+ ) ;
161
167
for param in params {
162
168
if !param. bounds . is_empty ( ) {
163
169
let spans: Vec < _ > = param. bounds . iter ( ) . map ( |b| b. span ( ) ) . collect ( ) ;
0 commit comments