about summary refs log tree commit diff
path: root/tests/ui/parser/brace-in-let-chain.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-12-12 11:49:31 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2024-12-13 07:10:20 +1100
commit2e412fef75ff2f45186863a76fdd7c5a9ec1f018 (patch)
treeff854e50dc44167857247a95912936b16e5a51ad /tests/ui/parser/brace-in-let-chain.rs
parenta94fce97e3ab3b2fd5773b13ca4f087dd84dd19b (diff)
downloadrust-2e412fef75ff2f45186863a76fdd7c5a9ec1f018.tar.gz
rust-2e412fef75ff2f45186863a76fdd7c5a9ec1f018.zip
Remove `Lexer`'s dependency on `Parser`.
Lexing precedes parsing, as you'd expect: `Lexer` creates a
`TokenStream` and `Parser` then parses that `TokenStream`.

But, in a horrendous violation of layering abstractions and common
sense, `Lexer` depends on `Parser`! The `Lexer::unclosed_delim_err`
method does some error recovery that relies on creating a `Parser` to do
some post-processing of the `TokenStream` that the `Lexer` just created.

This commit just removes `unclosed_delim_err`. This change removes
`Lexer`'s dependency on `Parser`, and also means that `lex_token_tree`'s
return value can have a more typical form.

The cost is slightly worse error messages in two obscure cases, as shown
in these tests:
- tests/ui/parser/brace-in-let-chain.rs: there is slightly less
  explanation in this case involving an extra `{`.
- tests/ui/parser/diff-markers/unclosed-delims{,-in-macro}.rs: the diff
  marker detection is no longer supported (because that detection is
  implemented in the parser).

In my opinion this cost is outweighed by the magnitude of the code
cleanup.
Diffstat (limited to 'tests/ui/parser/brace-in-let-chain.rs')
-rw-r--r--tests/ui/parser/brace-in-let-chain.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/ui/parser/brace-in-let-chain.rs b/tests/ui/parser/brace-in-let-chain.rs
index 1f34c73a2c3..2009bc88d9e 100644
--- a/tests/ui/parser/brace-in-let-chain.rs
+++ b/tests/ui/parser/brace-in-let-chain.rs
@@ -3,7 +3,7 @@
 #![feature(let_chains)]
 fn main() {
     if let () = ()
-        && let () = () { //~ERROR: found a `{` in the middle of a let-chain
+        && let () = () {
         && let () = ()
     {
     }
@@ -11,7 +11,7 @@ fn main() {
 
 fn quux() {
     while let () = ()
-        && let () = () { //~ERROR: found a `{` in the middle of a let-chain
+        && let () = () {
         && let () = ()
     {
     }