Allow '_ to be parsed as a lifetime
diff --git a/src/lifetime.rs b/src/lifetime.rs
index e2c5b4f..40c1e20 100644
--- a/src/lifetime.rs
+++ b/src/lifetime.rs
@@ -19,7 +19,6 @@
///
/// - Must start with an apostrophe.
/// - Must not consist of just an apostrophe: `'`.
-/// - Must not consist of apostrophe + underscore: `'_`.
/// - Character after the apostrophe must be `_` or a Unicode code point with
/// the XID_Start property.
/// - All following characters must be Unicode code points with the XID_Continue
@@ -50,10 +49,6 @@
panic!("lifetime name must not be empty");
}
- if s == "'_" {
- panic!("\"'_\" is not a valid lifetime name");
- }
-
fn xid_ok(s: &str) -> bool {
let mut chars = s.chars();
let first = chars.next().unwrap();
diff --git a/tests/test_generics.rs b/tests/test_generics.rs
index 93cb44f..b96d652 100644
--- a/tests/test_generics.rs
+++ b/tests/test_generics.rs
@@ -117,6 +117,13 @@
common::parse::syn::<TypeParamBound>(tokens.into())
);
+ let tokens = quote!('_);
+ let expected = TypeParamBound::Lifetime(Lifetime::new(Term::intern("'_"), Span::def_site()));
+ assert_eq!(
+ expected,
+ common::parse::syn::<TypeParamBound>(tokens.into())
+ );
+
let tokens = quote!(Debug);
let expected = TypeParamBound::Trait(TraitBound {
modifier: TraitBoundModifier::None,