Make note of forks that can be optimized
diff --git a/src/data.rs b/src/data.rs
index f54f5b9..d616832 100644
--- a/src/data.rs
+++ b/src/data.rs
@@ -268,6 +268,7 @@
let pub_token = input.parse::<Token![pub]>()?;
if input.peek(token::Paren) {
+ // TODO: optimize using advance_to
let ahead = input.fork();
let mut content;
parenthesized!(content in ahead);
diff --git a/src/expr.rs b/src/expr.rs
index 69f449d..1caa049 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -1234,6 +1234,7 @@
// box <trailer>
#[cfg(feature = "full")]
fn unary_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> {
+ // TODO: optimize using advance_to
let ahead = input.fork();
ahead.call(Attribute::parse_outer)?;
if ahead.peek(Token![&])
@@ -1270,6 +1271,7 @@
#[cfg(not(feature = "full"))]
fn unary_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> {
+ // TODO: optimize using advance_to
let ahead = input.fork();
ahead.call(Attribute::parse_outer)?;
if ahead.peek(Token![*]) || ahead.peek(Token![!]) || ahead.peek(Token![-]) {
@@ -2185,6 +2187,7 @@
let mut fields = Punctuated::new();
loop {
let attrs = content.call(Attribute::parse_outer)?;
+ // TODO: optimize using advance_to
if content.fork().parse::<Member>().is_err() {
if attrs.is_empty() {
break;
@@ -2416,6 +2419,7 @@
#[cfg(feature = "full")]
fn parse_stmt(input: ParseStream, allow_nosemi: bool) -> Result<Stmt> {
+ // TODO: optimize using advance_to
let ahead = input.fork();
ahead.call(Attribute::parse_outer)?;
diff --git a/src/item.rs b/src/item.rs
index a8f19a0..aaa99f9 100644
--- a/src/item.rs
+++ b/src/item.rs
@@ -767,6 +767,7 @@
impl Parse for Item {
fn parse(input: ParseStream) -> Result<Self> {
+ // TODO: optimize using advance_to
let ahead = input.fork();
ahead.call(Attribute::parse_outer)?;
let vis: Visibility = ahead.parse()?;
@@ -1139,6 +1140,8 @@
impl Parse for FnArg {
fn parse(input: ParseStream) -> Result<Self> {
+ // TODO: optimize using advance_to
+
if input.peek(Token![&]) {
let ahead = input.fork();
if ahead.call(arg_self_ref).is_ok() && !ahead.peek(Token![:]) {
@@ -1273,6 +1276,7 @@
impl Parse for ForeignItem {
fn parse(input: ParseStream) -> Result<Self> {
+ // TODO: optimize using advance_to
let ahead = input.fork();
ahead.call(Attribute::parse_outer)?;
let vis: Visibility = ahead.parse()?;
@@ -1664,6 +1668,7 @@
impl Parse for TraitItem {
fn parse(input: ParseStream) -> Result<Self> {
+ // TODO: optimize using advance_to
let ahead = input.fork();
ahead.call(Attribute::parse_outer)?;
@@ -1864,6 +1869,7 @@
};
let trait_ = {
+ // TODO: optimize using advance_to
let ahead = input.fork();
if ahead.parse::<Option<Token![!]>>().is_ok()
&& ahead.parse::<Path>().is_ok()
@@ -1908,6 +1914,7 @@
impl Parse for ImplItem {
fn parse(input: ParseStream) -> Result<Self> {
+ // TODO: optimize using advance_to
let ahead = input.fork();
ahead.call(Attribute::parse_outer)?;
let vis: Visibility = ahead.parse()?;