Skip to content

Commit 51298d4

Browse files
committed
Improve error location at eof in LitStr::parse
1 parent 270c633 commit 51298d4

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/lit.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,11 @@ impl LitStr {
225225

226226
// Parse string literal into a token stream with every span equal to the
227227
// original literal's span.
228+
let span = self.span();
228229
let mut tokens = TokenStream::from_str(&self.value())?;
229-
tokens = respan_token_stream(tokens, self.span());
230+
tokens = respan_token_stream(tokens, span);
230231

231-
let result = parser.parse2(tokens)?;
232+
let result = crate::parse::parse_scoped(parser, span, tokens)?;
232233

233234
let suffix = self.suffix();
234235
if !suffix.is_empty() {

src/parse.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,6 @@ pub trait Parser: Sized {
12681268

12691269
// Not public API.
12701270
#[doc(hidden)]
1271-
#[cfg(any(feature = "full", feature = "derive"))]
12721271
fn __parse_scoped(self, scope: Span, tokens: TokenStream) -> Result<Self::Output> {
12731272
let _ = scope;
12741273
self.parse2(tokens)
@@ -1300,7 +1299,6 @@ where
13001299
}
13011300
}
13021301

1303-
#[cfg(any(feature = "full", feature = "derive"))]
13041302
fn __parse_scoped(self, scope: Span, tokens: TokenStream) -> Result<Self::Output> {
13051303
let buf = TokenBuffer::new2(tokens);
13061304
let cursor = buf.begin();
@@ -1316,7 +1314,6 @@ where
13161314
}
13171315
}
13181316

1319-
#[cfg(any(feature = "full", feature = "derive"))]
13201317
pub(crate) fn parse_scoped<F: Parser>(f: F, scope: Span, tokens: TokenStream) -> Result<F::Output> {
13211318
f.__parse_scoped(scope, tokens)
13221319
}

0 commit comments

Comments
 (0)