about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/llvm_util.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-12-14 05:01:06 +0100
committerGitHub <noreply@github.com>2024-12-14 05:01:06 +0100
commitac6ac81a67600e949747310c45b79c8fb989b7e4 (patch)
tree0203babf7d95e5bfa4608789192c16f9b288ff55 /compiler/rustc_codegen_llvm/src/llvm_util.rs
parent03e328d1786e023e7160bb250395b51bd6b58e9e (diff)
parent2e412fef75ff2f45186863a76fdd7c5a9ec1f018 (diff)
downloadrust-ac6ac81a67600e949747310c45b79c8fb989b7e4.tar.gz
rust-ac6ac81a67600e949747310c45b79c8fb989b7e4.zip
Rollup merge of #134192 - nnethercote:rm-Lexer-Parser-dep, r=compiler-errors
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.

r? ```````@chenyukang```````
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/llvm_util.rs')
0 files changed, 0 insertions, 0 deletions