Remove the bogus special case from `Parser::look_ahead`. · rust-lang/rust@ebe1305
@@ -1424,12 +1424,15 @@ fn look_ahead() {
14241424look!(p, 1, token::Colon);
14251425look!(p, 2, token::Ident(sym::u32, raw_no));
14261426look!(p, 3, token::CloseDelim(Delimiter::Parenthesis));
1427-// FIXME(nnethercote) If we lookahead any distance past a close delim
1428-// we currently return that close delim.
1429-look!(p, 4, token::CloseDelim(Delimiter::Parenthesis));
1430-look!(p, 5, token::CloseDelim(Delimiter::Parenthesis));
1431-look!(p, 6, token::CloseDelim(Delimiter::Parenthesis));
1432-look!(p, 100, token::CloseDelim(Delimiter::Parenthesis));
1427+look!(p, 4, token::OpenDelim(Delimiter::Brace));
1428+look!(p, 5, token::Ident(sym_x, raw_no));
1429+look!(p, 6, token::CloseDelim(Delimiter::Brace));
1430+look!(p, 7, token::Ident(kw::Struct, raw_no));
1431+look!(p, 8, token::Ident(sym_S, raw_no));
1432+look!(p, 9, token::Semi);
1433+look!(p, 10, token::Eof);
1434+look!(p, 11, token::Eof);
1435+look!(p, 100, token::Eof);
1433143614341437// Move forward to the `;`.
14351438for _ in 0..9 {
@@ -1454,12 +1457,13 @@ fn look_ahead() {
14541457});
14551458}
145614591457-/// FIXME(nnethercote) Currently there is some buggy behaviour when using
1458-/// `look_ahead` not within the outermost token stream, as this test shows.
1460+/// There used to be some buggy behaviour when using `look_ahead` not within
1461+/// the outermost token stream, which this test covers.
14591462#[test]
14601463fn look_ahead_non_outermost_stream() {
14611464create_default_session_globals_then(|| {
14621465let sym_f = Symbol::intern("f");
1466+let sym_x = Symbol::intern("x");
14631467#[allow(non_snake_case)]
14641468let sym_S = Symbol::intern("S");
14651469let raw_no = IdentIsRaw::No;
@@ -1475,20 +1479,21 @@ fn look_ahead_non_outermost_stream() {
14751479look!(p, 0, token::Ident(kw::Fn, raw_no));
14761480look!(p, 1, token::Ident(sym_f, raw_no));
14771481look!(p, 2, token::OpenDelim(Delimiter::Parenthesis));
1478-// FIXME(nnethercote) The current code incorrectly skips the `x: u32)`
1479-// to the next token tree.
1480-look!(p, 3, token::OpenDelim(Delimiter::Brace));
1481-// FIXME(nnethercote) The current code incorrectly skips the `x }`
1482-// to the next token tree.
1483-look!(p, 4, token::Ident(kw::Struct, raw_no));
1484-look!(p, 5, token::Ident(sym_S, raw_no));
1485-look!(p, 6, token::Semi);
1486-// FIXME(nnethercote) If we lookahead any distance past a close delim
1487-// we currently return that close delim.
1488-look!(p, 7, token::CloseDelim(Delimiter::Brace));
1489-look!(p, 8, token::CloseDelim(Delimiter::Brace));
1482+look!(p, 3, token::Ident(sym_x, raw_no));
1483+look!(p, 4, token::Colon);
1484+look!(p, 5, token::Ident(sym::u32, raw_no));
1485+look!(p, 6, token::CloseDelim(Delimiter::Parenthesis));
1486+look!(p, 7, token::OpenDelim(Delimiter::Brace));
1487+look!(p, 8, token::Ident(sym_x, raw_no));
14901488look!(p, 9, token::CloseDelim(Delimiter::Brace));
1491-look!(p, 100, token::CloseDelim(Delimiter::Brace));
1489+look!(p, 10, token::Ident(kw::Struct, raw_no));
1490+look!(p, 11, token::Ident(sym_S, raw_no));
1491+look!(p, 12, token::Semi);
1492+look!(p, 13, token::CloseDelim(Delimiter::Brace));
1493+// Any lookahead past the end of the token stream returns `Eof`.
1494+look!(p, 14, token::Eof);
1495+look!(p, 15, token::Eof);
1496+look!(p, 100, token::Eof);
14921497});
14931498}
14941499