Consistent `new` signature between Ident and Lifetime
diff --git a/src/lifetime.rs b/src/lifetime.rs
index 321336d..276e2d5 100644
--- a/src/lifetime.rs
+++ b/src/lifetime.rs
@@ -33,9 +33,7 @@
}
impl Lifetime {
- pub fn new(term: Term) -> Self {
- let s = term.as_str();
-
+ pub fn new(s: &str, span: Span) -> Self {
if !s.starts_with('\'') {
panic!(
"lifetime name must start with apostrophe as in \"'a\", \
@@ -67,7 +65,7 @@
}
Lifetime {
- term: term,
+ term: Term::new(s, span),
}
}
diff --git a/tests/test_generics.rs b/tests/test_generics.rs
index a86a41e..84eb529 100644
--- a/tests/test_generics.rs
+++ b/tests/test_generics.rs
@@ -16,7 +16,7 @@
extern crate quote;
extern crate proc_macro2;
-use proc_macro2::{Span, Term, TokenStream};
+use proc_macro2::{Span, TokenStream};
#[macro_use]
mod macros;
@@ -32,14 +32,14 @@
params: punctuated![
GenericParam::Lifetime(LifetimeDef {
attrs: Default::default(),
- lifetime: Lifetime::new(Term::new("'a", Span::call_site())),
+ lifetime: Lifetime::new("'a", Span::call_site()),
bounds: Default::default(),
colon_token: None,
}),
GenericParam::Lifetime(LifetimeDef {
attrs: Default::default(),
- lifetime: Lifetime::new(Term::new("'b", Span::call_site())),
- bounds: punctuated![Lifetime::new(Term::new("'a", Span::call_site()))],
+ lifetime: Lifetime::new("'b", Span::call_site()),
+ bounds: punctuated![Lifetime::new("'a", Span::call_site())],
colon_token: Some(token::Colon::default()),
}),
GenericParam::Type(TypeParam {
@@ -55,7 +55,7 @@
],
ident: "T".into(),
bounds: punctuated![
- TypeParamBound::Lifetime(Lifetime::new(Term::new("'a", Span::call_site()))),
+ TypeParamBound::Lifetime(Lifetime::new("'a", Span::call_site())),
],
default: Some(
TypeTuple {
@@ -111,14 +111,14 @@
#[test]
fn test_ty_param_bound() {
let tokens = quote!('a);
- let expected = TypeParamBound::Lifetime(Lifetime::new(Term::new("'a", Span::call_site())));
+ let expected = TypeParamBound::Lifetime(Lifetime::new("'a", Span::call_site()));
assert_eq!(
expected,
common::parse::syn::<TypeParamBound>(tokens.into())
);
let tokens = quote!('_);
- let expected = TypeParamBound::Lifetime(Lifetime::new(Term::new("'_", Span::call_site())));
+ let expected = TypeParamBound::Lifetime(Lifetime::new("'_", Span::call_site()));
assert_eq!(
expected,
common::parse::syn::<TypeParamBound>(tokens.into())