@@ -144,6 +144,11 @@ pub enum ErrorKind {
144144 ///
145145 /// The span of this error corresponds to the unclosed parenthesis.
146146 GroupUnclosed ,
147+ /// An unclosed look-around, e.g., `(?<ab`.
148+ ///
149+ /// The span of this error corresponds to the unclosed parenthesis.
150+ #[ cfg( feature = "look-behinds" ) ]
151+ LookAroundUnclosed ,
147152 /// An unopened group, e.g., `ab)`.
148153 GroupUnopened ,
149154 /// The nest limit was exceeded. The limit stored here is the limit
@@ -186,7 +191,19 @@ pub enum ErrorKind {
186191 /// not necessarily limited to, `(?=re)`, `(?!re)`, `(?<=re)` and
187192 /// `(?<!re)`. Note that all of these syntaxes are otherwise invalid; this
188193 /// error is used to improve the user experience.
194+ #[ cfg( not( feature = "look-behinds" ) ) ]
189195 UnsupportedLookAround ,
196+ /// When syntax similar to PCRE's look-ahead is used, this error is
197+ /// returned. Some example syntaxes that are rejected include, but are
198+ /// not necessarily limited to, `(?=re)` and `(?!re)`.
199+ /// Note that all of these syntaxes are otherwise invalid; this
200+ /// error is used to improve the user experience.
201+ #[ cfg( feature = "look-behinds" ) ]
202+ UnsupportedLookAhead ,
203+ /// When a capture group is used in a look-behind assertion, this error is
204+ /// returned. Look-behind assertions do not support capturing groups.
205+ #[ cfg( feature = "look-behinds" ) ]
206+ UnsupportedCaptureInLookBehind ,
190207}
191208
192209#[ cfg( feature = "std" ) ]
@@ -251,6 +268,8 @@ impl core::fmt::Display for ErrorKind {
251268 GroupNameInvalid => write ! ( f, "invalid capture group character" ) ,
252269 GroupNameUnexpectedEof => write ! ( f, "unclosed capture group name" ) ,
253270 GroupUnclosed => write ! ( f, "unclosed group" ) ,
271+ #[ cfg( feature = "look-behinds" ) ]
272+ LookAroundUnclosed => write ! ( f, "unclosed look-around" ) ,
254273 GroupUnopened => write ! ( f, "unopened group" ) ,
255274 NestLimitExceeded ( limit) => write ! (
256275 f,
@@ -301,11 +320,18 @@ impl core::fmt::Display for ErrorKind {
301320 UnsupportedBackreference => {
302321 write ! ( f, "backreferences are not supported" )
303322 }
323+ #[ cfg( not( feature = "look-behinds" ) ) ]
304324 UnsupportedLookAround => write ! (
305325 f,
306326 "look-around, including look-ahead and look-behind, \
307327 is not supported"
308328 ) ,
329+ #[ cfg( feature = "look-behinds" ) ]
330+ UnsupportedLookAhead => write ! ( f, "look-aheads are not supported" ) ,
331+ #[ cfg( feature = "look-behinds" ) ]
332+ UnsupportedCaptureInLookBehind => {
333+ write ! ( f, "capture groups are not supported in look-behinds" )
334+ }
309335 }
310336 }
311337}
0 commit comments