@@ -1832,8 +1832,8 @@ struct PropertiesI {
1832
1832
look_set_prefix : LookSet ,
1833
1833
look_set_suffix : LookSet ,
1834
1834
utf8 : bool ,
1835
- captures_len : usize ,
1836
- static_captures_len : Option < usize > ,
1835
+ explicit_captures_len : usize ,
1836
+ static_explicit_captures_len : Option < usize > ,
1837
1837
literal : bool ,
1838
1838
alternation_literal : bool ,
1839
1839
}
@@ -1981,14 +1981,14 @@ impl Properties {
1981
1981
/// ```
1982
1982
/// use regex_syntax::parse;
1983
1983
///
1984
- /// assert_eq!(0, parse("a")?.properties().captures_len ());
1985
- /// assert_eq!(1, parse("(a)")?.properties().captures_len ());
1984
+ /// assert_eq!(0, parse("a")?.properties().explicit_captures_len ());
1985
+ /// assert_eq!(1, parse("(a)")?.properties().explicit_captures_len ());
1986
1986
///
1987
1987
/// # Ok::<(), Box<dyn std::error::Error>>(())
1988
1988
/// ```
1989
1989
#[ inline]
1990
- pub fn captures_len ( & self ) -> usize {
1991
- self . 0 . captures_len
1990
+ pub fn explicit_captures_len ( & self ) -> usize {
1991
+ self . 0 . explicit_captures_len
1992
1992
}
1993
1993
1994
1994
/// Returns the total number of explicit capturing groups that appear in
@@ -2010,7 +2010,9 @@ impl Properties {
2010
2010
/// use regex_syntax::parse;
2011
2011
///
2012
2012
/// let len = |pattern| {
2013
- /// parse(pattern).map(|h| h.properties().static_captures_len())
2013
+ /// parse(pattern).map(|h| {
2014
+ /// h.properties().static_explicit_captures_len()
2015
+ /// })
2014
2016
/// };
2015
2017
///
2016
2018
/// assert_eq!(Some(0), len("a")?);
@@ -2025,8 +2027,8 @@ impl Properties {
2025
2027
/// # Ok::<(), Box<dyn std::error::Error>>(())
2026
2028
/// ```
2027
2029
#[ inline]
2028
- pub fn static_captures_len ( & self ) -> Option < usize > {
2029
- self . 0 . static_captures_len
2030
+ pub fn static_explicit_captures_len ( & self ) -> Option < usize > {
2031
+ self . 0 . static_explicit_captures_len
2030
2032
}
2031
2033
2032
2034
/// Return true if and only if this HIR is a simple literal. This is
@@ -2144,8 +2146,8 @@ impl Properties {
2144
2146
// alternate. If any subsequent alternate has a different number of
2145
2147
// static capture groups, then we overall have a variation and not a
2146
2148
// static number of groups.
2147
- let static_captures_len =
2148
- it. peek ( ) . and_then ( |p| p. borrow ( ) . static_captures_len ( ) ) ;
2149
+ let static_explicit_captures_len =
2150
+ it. peek ( ) . and_then ( |p| p. borrow ( ) . static_explicit_captures_len ( ) ) ;
2149
2151
// The base case is an empty alternation, which matches nothing.
2150
2152
// Note though that empty alternations aren't possible, because the
2151
2153
// Hir::alternation smart constructor rewrites those as empty character
@@ -2157,8 +2159,8 @@ impl Properties {
2157
2159
look_set_prefix : fix,
2158
2160
look_set_suffix : fix,
2159
2161
utf8 : true ,
2160
- captures_len : 0 ,
2161
- static_captures_len ,
2162
+ explicit_captures_len : 0 ,
2163
+ static_explicit_captures_len ,
2162
2164
literal : false ,
2163
2165
alternation_literal : true ,
2164
2166
} ;
@@ -2170,10 +2172,13 @@ impl Properties {
2170
2172
props. look_set_prefix . set_intersect ( p. look_set_prefix ( ) ) ;
2171
2173
props. look_set_suffix . set_intersect ( p. look_set_suffix ( ) ) ;
2172
2174
props. utf8 = props. utf8 && p. is_utf8 ( ) ;
2173
- props. captures_len =
2174
- props. captures_len . saturating_add ( p. captures_len ( ) ) ;
2175
- if props. static_captures_len != p. static_captures_len ( ) {
2176
- props. static_captures_len = None ;
2175
+ props. explicit_captures_len = props
2176
+ . explicit_captures_len
2177
+ . saturating_add ( p. explicit_captures_len ( ) ) ;
2178
+ if props. static_explicit_captures_len
2179
+ != p. static_explicit_captures_len ( )
2180
+ {
2181
+ props. static_explicit_captures_len = None ;
2177
2182
}
2178
2183
props. alternation_literal =
2179
2184
props. alternation_literal && p. is_alternation_literal ( ) ;
@@ -2229,8 +2234,8 @@ impl Properties {
2229
2234
// were false, for example, then 'a*' would also need to be false
2230
2235
// since it too can match the empty string.
2231
2236
utf8 : true ,
2232
- captures_len : 0 ,
2233
- static_captures_len : Some ( 0 ) ,
2237
+ explicit_captures_len : 0 ,
2238
+ static_explicit_captures_len : Some ( 0 ) ,
2234
2239
literal : false ,
2235
2240
alternation_literal : false ,
2236
2241
} ;
@@ -2246,8 +2251,8 @@ impl Properties {
2246
2251
look_set_prefix : LookSet :: empty ( ) ,
2247
2252
look_set_suffix : LookSet :: empty ( ) ,
2248
2253
utf8 : core:: str:: from_utf8 ( & lit. 0 ) . is_ok ( ) ,
2249
- captures_len : 0 ,
2250
- static_captures_len : Some ( 0 ) ,
2254
+ explicit_captures_len : 0 ,
2255
+ static_explicit_captures_len : Some ( 0 ) ,
2251
2256
literal : true ,
2252
2257
alternation_literal : true ,
2253
2258
} ;
@@ -2263,8 +2268,8 @@ impl Properties {
2263
2268
look_set_prefix : LookSet :: empty ( ) ,
2264
2269
look_set_suffix : LookSet :: empty ( ) ,
2265
2270
utf8 : class. is_utf8 ( ) ,
2266
- captures_len : 0 ,
2267
- static_captures_len : Some ( 0 ) ,
2271
+ explicit_captures_len : 0 ,
2272
+ static_explicit_captures_len : Some ( 0 ) ,
2268
2273
literal : false ,
2269
2274
alternation_literal : false ,
2270
2275
} ;
@@ -2293,8 +2298,8 @@ impl Properties {
2293
2298
// considered to match invalid UTF-8. That in turn makes this
2294
2299
// property borderline useless.
2295
2300
utf8 : true ,
2296
- captures_len : 0 ,
2297
- static_captures_len : Some ( 0 ) ,
2301
+ explicit_captures_len : 0 ,
2302
+ static_explicit_captures_len : Some ( 0 ) ,
2298
2303
literal : false ,
2299
2304
alternation_literal : false ,
2300
2305
} ;
@@ -2321,8 +2326,8 @@ impl Properties {
2321
2326
look_set_prefix : LookSet :: empty ( ) ,
2322
2327
look_set_suffix : LookSet :: empty ( ) ,
2323
2328
utf8 : p. is_utf8 ( ) ,
2324
- captures_len : p. captures_len ( ) ,
2325
- static_captures_len : p. static_captures_len ( ) ,
2329
+ explicit_captures_len : p. explicit_captures_len ( ) ,
2330
+ static_explicit_captures_len : p. static_explicit_captures_len ( ) ,
2326
2331
literal : false ,
2327
2332
alternation_literal : false ,
2328
2333
} ;
@@ -2338,16 +2343,16 @@ impl Properties {
2338
2343
// of the repetition. Otherwise, it might change, but only when the
2339
2344
// repetition can match 0 times.
2340
2345
if rep. min == 0
2341
- && inner. static_captures_len . map_or ( false , |len| len > 0 )
2346
+ && inner. static_explicit_captures_len . map_or ( false , |len| len > 0 )
2342
2347
{
2343
2348
// If we require a match 0 times, then our captures len is
2344
2349
// guaranteed to be zero. Otherwise, if we *can* match the empty
2345
2350
// string, then it's impossible to know how many captures will be
2346
2351
// in the resulting match.
2347
2352
if rep. max == Some ( 0 ) {
2348
- inner. static_captures_len = Some ( 0 ) ;
2353
+ inner. static_explicit_captures_len = Some ( 0 ) ;
2349
2354
} else {
2350
- inner. static_captures_len = None ;
2355
+ inner. static_explicit_captures_len = None ;
2351
2356
}
2352
2357
}
2353
2358
Properties ( Box :: new ( inner) )
@@ -2357,9 +2362,9 @@ impl Properties {
2357
2362
fn capture ( capture : & Capture ) -> Properties {
2358
2363
let p = capture. sub . properties ( ) ;
2359
2364
Properties ( Box :: new ( PropertiesI {
2360
- captures_len : p. captures_len ( ) . saturating_add ( 1 ) ,
2361
- static_captures_len : p
2362
- . static_captures_len ( )
2365
+ explicit_captures_len : p. explicit_captures_len ( ) . saturating_add ( 1 ) ,
2366
+ static_explicit_captures_len : p
2367
+ . static_explicit_captures_len ( )
2363
2368
. map ( |len| len. saturating_add ( 1 ) ) ,
2364
2369
literal : false ,
2365
2370
alternation_literal : false ,
@@ -2380,8 +2385,8 @@ impl Properties {
2380
2385
look_set_prefix : LookSet :: empty ( ) ,
2381
2386
look_set_suffix : LookSet :: empty ( ) ,
2382
2387
utf8 : true ,
2383
- captures_len : 0 ,
2384
- static_captures_len : Some ( 0 ) ,
2388
+ explicit_captures_len : 0 ,
2389
+ static_explicit_captures_len : Some ( 0 ) ,
2385
2390
literal : true ,
2386
2391
alternation_literal : true ,
2387
2392
} ;
@@ -2390,11 +2395,14 @@ impl Properties {
2390
2395
let p = x. properties ( ) ;
2391
2396
props. look_set . set_union ( p. look_set ( ) ) ;
2392
2397
props. utf8 = props. utf8 && p. is_utf8 ( ) ;
2393
- props. captures_len =
2394
- props. captures_len . saturating_add ( p. captures_len ( ) ) ;
2395
- props. static_captures_len = p
2396
- . static_captures_len ( )
2397
- . and_then ( |len1| Some ( ( len1, props. static_captures_len ?) ) )
2398
+ props. explicit_captures_len = props
2399
+ . explicit_captures_len
2400
+ . saturating_add ( p. explicit_captures_len ( ) ) ;
2401
+ props. static_explicit_captures_len = p
2402
+ . static_explicit_captures_len ( )
2403
+ . and_then ( |len1| {
2404
+ Some ( ( len1, props. static_explicit_captures_len ?) )
2405
+ } )
2398
2406
. and_then ( |( len1, len2) | Some ( len1. saturating_add ( len2) ) ) ;
2399
2407
props. literal = props. literal && p. is_literal ( ) ;
2400
2408
props. alternation_literal =
0 commit comments