Disentangle AST crates and error crates#155237
Disentangle AST crates and error crates#155237rust-bors[bot] merged 2 commits intorust-lang:mainfrom
Conversation
|
The parser was modified, potentially altering the grammar of (stable) Rust cc @fmease These commits modify the If this was unintentional then you should revert the changes before this PR is merged. Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in compiler/rustc_codegen_gcc
cc @TaKO8Ki |
This comment has been minimized.
This comment has been minimized.
|
@nnethercote that crate graph visualization looks nice, what tool did you use to generate it? |
Requires installing cargo-depgraph. |
rustc_ast* dependencies696f8d9 to
6ee5111
Compare
This comment has been minimized.
This comment has been minimized.
6ee5111 to
9b693c1
Compare
|
@davidtwco: this is now ready for review. |
This comment has been minimized.
This comment has been minimized.
9b693c1 to
14bd0c8
Compare
This comment has been minimized.
This comment has been minimized.
|
I rebased. |
|
I think, ideally, generic linting APIs living in crates like That would untangle some users of the generic linting infra, like That's why I don't like that
I wouldn't classify |
Hmmm, perhaps their definitions can be moved to |
|
So I checked again what depends on what, and this my suggestion would then translate to:
The first two commits are definitely good to go. |
4449be3 to
1509578
Compare
This comment has been minimized.
This comment has been minimized.
I'll just merge the first two commits; they are the more important ones. I don't want to move @bors r=petrochenkov |
…trochenkov Disentangle AST crates and error crates Currently the `rustc_ast*` crates and the `rustc_error*` crates (and `rustc_lint_defs`) are quite intertwined. This PR disentangles them. Details in individual commits. r? @davidtwco
Rollup of 6 pull requests Successful merges: - #155853 (Use `_mcount` as the mcount symbol name on RISC-V Linux GNU targets) - #155939 (Add feature gate for view_types experiment) - #155974 (add `c_variadic_experimental_arch` feature) - #155523 (Reorganize `tests/ui/issues/` - 02) - #155980 (Move `feature*` methods from `parse` mod to `errors` mod.) - #155987 (Make lifting infallible) Failed merges: - #155237 (Disentangle AST crates and error crates)
This comment has been minimized.
This comment has been minimized.
`rustc_error_messages` currently depends on `rustc_ast`/`rustc_ast_pretty`. This is odd, because `rustc_error_messages` feels like a very low-level module but `rustc_ast`/`rustc_ast_pretty` do not. The reason is that a few AST types impl `IntoDiagArg` via pretty-printing. `rustc_error_messages` can define `IntoDiagArg` and then impl it for the AST types. But if we invert the dependency we hit a problem with the orphan rule: `rustc_ast` must impl `IntoDiagArg` for the AST types, but that requires calling pretty-printing code which is in `rustc_ast_pretty`, a downstream crate. This commit avoids this problem by just removing the `IntoDiagArg` impls for these AST types. There aren't that many of them, and we can just use `String` in the relevant error structs and use the pretty printer in the downstream crates that construct the error structs. There are plenty of existing examples where `String` is used in error structs. There is now no dependency between `rustc_ast*` and `rustc_error_messages`.
It currently only depends on two things: - `rustc_ast::AttrId`: this is just a re-export of `rustc_span::AttrId`, so we can import the original instead. - `rustc_ast::AttributeExt`: needed only for the `name` and `id` methods. We can instead pass in the `name` and `id` directly.
1509578 to
339797e
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
I rebased. @bors r=petrochenkov |
Rollup of 19 pull requests Successful merges: - #155237 (Disentangle AST crates and error crates) - #155249 (Fix: On wasm targets, call `panic_in_cleanup` if panic occurs in cleanup) - #155853 (Use `_mcount` as the mcount symbol name on RISC-V Linux GNU targets) - #155919 (simplify `ast_fragments!`) - #155939 (Add feature gate for view_types experiment) - #155954 (rustdoc: preserve parent doc cfg for `macro_export` macros) - #155974 (add `c_variadic_experimental_arch` feature) - #155991 (Catch unwinds from the global ctxt callback to complete queries profiling data in more cases) - #156003 (Pass Session to optimize_and_codegen_fat_lto) - #153566 (Add suggestion for E0401 on inner const items) - #154610 (Suggest public re-exports when a private module makes an import path inaccessible) - #155523 (Reorganize `tests/ui/issues/` - 02) - #155821 (c-variadic: document `Clone` and `Drop` instances and require `VaArgSafe: Copy`) - #155980 (Move `feature*` methods from `parse` mod to `errors` mod.) - #155987 (Make lifting infallible) - #155988 (tests/run-make/print-cfg: add Android target_env case) - #156000 (Fix ICE when using -Zinstrument-mcount and -Clinker-flavor=lld) - #156002 (Allow to use `Diagnostic` directly in `SharedContext::emit_lint`) - #156015 (rustc-dev-guide subtree update)
Rollup merge of #155237 - nnethercote:ast-errors-rejig, r=petrochenkov Disentangle AST crates and error crates Currently the `rustc_ast*` crates and the `rustc_error*` crates (and `rustc_lint_defs`) are quite intertwined. This PR disentangles them. Details in individual commits. r? @davidtwco


View all comments
Currently the
rustc_ast*crates and therustc_error*crates (andrustc_lint_defs) are quite intertwined. This PR disentangles them. Details in individual commits.r? @davidtwco