Skip to content

Commit 3751350

Browse files
Get rid of references to the refractored libsyntax crate (#598)
* Get rid of references to the refractored `libsyntax` crate * Apply suggestions from code review Co-authored-by: Yuki Okushi <[email protected]>
1 parent d752bd3 commit 3751350

11 files changed

+44
-44
lines changed

src/appendix/code-index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ Item | Kind | Short description | Chapter |
88
----------------|----------|-----------------------------|--------------------|-------------------
99
`BodyId` | struct | One of four types of HIR node identifiers | [Identifiers in the HIR] | [src/librustc_hir/hir.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/struct.BodyId.html)
1010
`Compiler` | struct | Represents a compiler session and can be used to drive a compilation. | [The Rustc Driver and Interface] | [src/librustc_interface/interface.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/interface/struct.Compiler.html)
11-
`ast::Crate` | struct | A syntax-level representation of a parsed crate | [The parser] | [src/libsyntax/ast.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast/struct.Crate.html)
11+
`ast::Crate` | struct | A syntax-level representation of a parsed crate | [The parser] | [src/librustc_ast/ast.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/ast/struct.Crate.html)
1212
`rustc_hir::Crate` | struct | A more abstract, compiler-friendly form of a crate's AST | [The Hir] | [src/librustc_hir/hir.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/struct.Crate.html)
1313
`DefId` | struct | One of four types of HIR node identifiers | [Identifiers in the HIR] | [src/librustc_hir/def_id.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def_id/struct.DefId.html)
1414
`DiagnosticBuilder` | struct | A struct for building up compiler diagnostics, such as errors or lints | [Emitting Diagnostics] | [src/librustc_errors/diagnostic_builder.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.DiagnosticBuilder.html)
1515
`DocContext` | struct | A state container used by rustdoc when crawling through a crate to gather its documentation | [Rustdoc] | [src/librustdoc/core.rs](https://github.com/rust-lang/rust/blob/master/src/librustdoc/core.rs)
1616
`HirId` | struct | One of four types of HIR node identifiers | [Identifiers in the HIR] | [src/librustc_hir/hir_id.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir_id/struct.HirId.html)
17-
`NodeId` | struct | One of four types of HIR node identifiers. Being phased out | [Identifiers in the HIR] | [src/libsyntax/ast.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/node_id/struct.NodeId.html)
18-
`P` | struct | An owned immutable smart pointer. By contrast, `&T` is not owned, and `Box<T>` is not immutable. | None | [src/syntax/ptr.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ptr/struct.P.html)
17+
`NodeId` | struct | One of four types of HIR node identifiers. Being phased out | [Identifiers in the HIR] | [src/librustc_ast/ast.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/node_id/struct.NodeId.html)
18+
`P` | struct | An owned immutable smart pointer. By contrast, `&T` is not owned, and `Box<T>` is not immutable. | None | [src/librustc_ast/ptr.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/ptr/struct.P.html)
1919
`ParamEnv` | struct | Information about generic parameters or `Self`, useful for working with associated or generic items | [Parameter Environment] | [src/librustc/ty/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.ParamEnv.html)
20-
`ParseSess` | struct | This struct contains information about a parsing session | [The parser] | [src/libsyntax/parse/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/parse/struct.ParseSess.html)
20+
`ParseSess` | struct | This struct contains information about a parsing session | [The parser] | [src/librustc_session/parse/parse.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/parse/struct.ParseSess.html)
2121
`Query` | struct | Represents the result of query to the `Compiler` interface and allows stealing, borrowing, and returning the results of compiler passes. | [The Rustc Driver and Interface] | [src/librustc_interface/queries.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/queries/struct.Query.html)
2222
`Rib` | struct | Represents a single scope of names | [Name resolution] | [src/librustc_resolve/lib.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/late/struct.Rib.html)
2323
`Session` | struct | The data associated with a compilation session | [The parser], [The Rustc Driver and Interface] | [src/librustc/session/mod.html](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/struct.Session.html)
2424
`SourceFile` | struct | Part of the `SourceMap`. Maps AST nodes to their source code for a single source file. Was previously called FileMap | [The parser] | [src/librustc_span/lib.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/struct.SourceFile.html)
2525
`SourceMap` | struct | Maps AST nodes to their source code. It is composed of `SourceFile`s. Was previously called CodeMap | [The parser] | [src/librustc_span/source_map.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/source_map/struct.SourceMap.html)
2626
`Span` | struct | A location in the user's source code, used for error reporting primarily | [Emitting Diagnostics] | [src/librustc_span/span_encoding.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/struct.Span.html)
2727
`StringReader` | struct | This is the lexer used during parsing. It consumes characters from the raw source code being compiled and produces a series of tokens for use by the rest of the parser | [The parser] | [src/librustc_parse/lexer/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/lexer/struct.StringReader.html)
28-
`syntax::token_stream::TokenStream` | struct | An abstract sequence of tokens, organized into `TokenTree`s | [The parser], [Macro expansion] | [src/libsyntax/tokenstream.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/tokenstream/struct.TokenStream.html)
28+
`rustc_ast::token_stream::TokenStream` | struct | An abstract sequence of tokens, organized into `TokenTree`s | [The parser], [Macro expansion] | [src/librustc_ast/tokenstream.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/tokenstream/struct.TokenStream.html)
2929
`TraitDef` | struct | This struct contains a trait's definition with type information | [The `ty` modules] | [src/librustc/ty/trait_def.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/trait_def/struct.TraitDef.html)
3030
`TraitRef` | struct | The combination of a trait and its input types (e.g. `P0: Trait<P1...Pn>`) | [Trait Solving: Goals and Clauses], [Trait Solving: Lowering impls] | [src/librustc/ty/sty.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TraitRef.html)
3131
`Ty<'tcx>` | struct | This is the internal representation of a type used for type checking | [Type checking] | [src/librustc/ty/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/type.Ty.html)

src/appendix/glossary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ them better.
77
Term | Meaning
88
------------------------|--------
99
arena/arena allocation | an _arena_ is a large memory buffer from which other memory allocations are made. This style of allocation is called _area allocation_. See [this chapter](../memory.md) for more info.
10-
AST | the abstract syntax tree produced by the syntax crate; reflects user syntax very closely.
10+
AST | the abstract syntax tree produced by the `rustc_ast` crate; reflects user syntax very closely.
1111
binder | a "binder" is a place where a variable or type is declared; for example, the `<T>` is a binder for the generic type parameter `T` in `fn foo<T>(..)`, and \|`a`\|` ...` is a binder for the parameter `a`. See [the background chapter for more](./background.html#free-vs-bound)
1212
bound variable | a "bound variable" is one that is declared within an expression/term. For example, the variable `a` is bound within the closure expression \|`a`\|` a * 2`. See [the background chapter for more](./background.html#free-vs-bound)
1313
codegen | the code to translate MIR into LLVM IR.

src/appendix/stupid-stats.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Macros and syntax extensions are expanded, and `cfg` attributes will cause some
6161
code to disappear. The resulting AST won't have any macros or macro uses left
6262
in.
6363

64-
The code for these first two phases is in [libsyntax](https://github.com/rust-lang/rust/tree/master/src/libsyntax).
64+
The code for these first two phases is in [librustc_ast](https://github.com/rust-lang/rust/tree/master/src/librustc_ast).
6565

6666
After this phase, the compiler allocates ids to each node in the AST
6767
(technically not every node, but most of them). If we are writing out
@@ -356,7 +356,7 @@ struct StupidVisitor {
356356

357357
The `StupidVisitor` struct just keeps track of the number of `println!`s it has
358358
seen and the count for each number of arguments. It implements
359-
`syntax::visit::Visitor` to walk the AST. Mostly we just use the default
359+
`rustc_ast::visit::Visitor` to walk the AST. Mostly we just use the default
360360
methods, these walk the AST taking no action. We override `visit_item` and
361361
`visit_mac` to implement custom behaviour when we walk into items (items include
362362
functions, modules, traits, structs, and so forth, we're only interested in

src/bug-fix-procedure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ described in more detail below):
6565
1. Once the change has been in the wild for at least one cycle, we can
6666
**stabilize the change**, converting those warnings into errors.
6767

68-
Finally, for changes to libsyntax that will affect plugins, the general policy
68+
Finally, for changes to `librustc_ast` that will affect plugins, the general policy
6969
is to batch these changes. That is discussed below in more detail.
7070

7171
### Tracking issue

src/diagnostics.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,12 @@ like normal but invokes the lint with `buffer_lint`.
322322

323323
#### Linting even earlier in the compiler
324324

325-
The parser (`libsyntax`) is interesting in that it cannot have dependencies on
325+
The parser (`librustc_ast`) is interesting in that it cannot have dependencies on
326326
any of the other `librustc*` crates. In particular, it cannot depend on
327327
`librustc::lint` or `librustc_lint`, where all of the compiler linting
328328
infrastructure is defined. That's troublesome!
329329

330-
To solve this, `libsyntax` defines its own buffered lint type, which
330+
To solve this, `librustc_ast` defines its own buffered lint type, which
331331
`ParseSess::buffer_lint` uses. After macro expansion, these buffered lints are
332332
then dumped into the `Session::buffered_lints` used by the rest of the compiler.
333333

@@ -358,7 +358,7 @@ the structured JSON and see the "human" output (well, _sans_ colors)
358358
without having to compile everything twice.
359359

360360
The "human" readable and the json format emitter can be found under
361-
librustc_errors, both were moved from the libsyntax crate to the
361+
librustc_errors, both were moved from the `librustc_ast` crate to the
362362
[librustc_errors crate](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/index.html).
363363

364364
The JSON emitter defines [its own `Diagnostic`

src/high-level-overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ there live many crates. These crates contain the sources for the
77
standard library and the compiler. This document, of course, focuses
88
on the latter.
99

10-
Rustc consists of a number of crates, including `syntax`,
10+
Rustc consists of a number of crates, including `rustc_ast`,
1111
`rustc`, `rustc_target`, `rustc_codegen`, `rustc_driver`, and
1212
many more. The source for each crate can be found in a directory
1313
like `src/libXXX`, where `XXX` is the crate name.
@@ -33,7 +33,7 @@ rustc_codegen rustc_borrowck ... rustc_metadata
3333
rustc
3434
|
3535
v
36-
syntax
36+
rustc_ast
3737
/ \
3838
/ \
3939
rustc_span rustc_builtin_macros
@@ -92,7 +92,7 @@ take:
9292
1. **Parsing input**
9393
- this processes the `.rs` files and produces the AST
9494
("abstract syntax tree")
95-
- the AST is defined in `src/libsyntax/ast.rs`. It is intended to match the lexical
95+
- the AST is defined in `src/librustc_ast/ast.rs`. It is intended to match the lexical
9696
syntax of the Rust language quite closely.
9797
2. **Name resolution, macro expansion, and configuration**
9898
- once parsing is complete, we process the AST recursively, resolving

src/hir.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ sorts of identifiers in active use:
100100
[`DefId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def_id/struct.DefId.html
101101
[`HirId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir_id/struct.HirId.html
102102
[`BodyId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/struct.BodyId.html
103-
[`NodeId`]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/node_id/struct.NodeId.html
103+
[`NodeId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/node_id/struct.NodeId.html
104104

105105
We also have an internal map to go from `DefId` to what’s called "Def path". "Def path" is like a
106106
module path but a bit more rich. For example, it may be `crate::foo::MyStruct` that identifies

src/macro-expansion.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Macro expansion
22

3-
> `libsyntax`, `librustc_expand`, and `librustc_builtin_macros` are all undergoing
3+
> `librustc_ast`, `librustc_expand`, and `librustc_builtin_macros` are all undergoing
44
> refactoring, so some of the links in this chapter may be broken.
55
66
Macro expansion happens during parsing. `rustc` has two parsers, in fact: the
@@ -361,24 +361,24 @@ be accessed from any Ident without any context) librustc_span/lib.rs - some
361361
secondary methods like macro backtrace using primary methods from hygiene.rs
362362
librustc_builtin_macros - implementations of built-in macros (including macro attributes
363363
and derives) and some other early code generation facilities like injection of
364-
standard library imports or generation of test harness. libsyntax/config.rs -
364+
standard library imports or generation of test harness. librustc_ast/config.rs -
365365
implementation of cfg/cfg_attr (they treated specially from other macros),
366-
should probably be moved into libsyntax/ext. libsyntax/tokenstream.rs +
367-
libsyntax/parse/token.rs - structures for compiler-side tokens, token trees,
368-
and token streams. libsyntax/ext - various expansion-related stuff
369-
libsyntax/ext/base.rs - basic structures used by expansion
370-
libsyntax/ext/expand.rs - some expansion structures and the bulk of expansion
366+
should probably be moved into librustc_ast/ext. librustc_ast/tokenstream.rs +
367+
librustc_ast/parse/token.rs - structures for compiler-side tokens, token trees,
368+
and token streams. librustc_ast/ext - various expansion-related stuff
369+
librustc_ast/ext/base.rs - basic structures used by expansion
370+
librustc_ast/ext/expand.rs - some expansion structures and the bulk of expansion
371371
infrastructure code - collecting macro invocations, calling into resolve for
372372
them, calling their expanding functions, and integrating the results back into
373-
AST libsyntax/ext/placeholder.rs - the part of expand.rs responsible for
373+
AST librustc_ast/ext/placeholder.rs - the part of expand.rs responsible for
374374
"integrating the results back into AST" basicallly, "placeholder" is a
375375
temporary AST node replaced with macro expansion result nodes
376-
libsyntax/ext/builer.rs - helper functions for building AST for built-in macros
376+
librustc_ast/ext/builer.rs - helper functions for building AST for built-in macros
377377
in librustc_builtin_macros (and user-defined syntactic plugins previously), can probably
378-
be moved into librustc_builtin_macros these days libsyntax/ext/proc_macro.rs +
379-
libsyntax/ext/proc_macro_server.rs - interfaces between the compiler and the
378+
be moved into librustc_builtin_macros these days librustc_ast/ext/proc_macro.rs +
379+
librustc_ast/ext/proc_macro_server.rs - interfaces between the compiler and the
380380
stable proc_macro library, converting tokens and token streams between the two
381-
representations and sending them through C ABI libsyntax/ext/tt -
381+
representations and sending them through C ABI librustc_ast/ext/tt -
382382
implementation of macro_rules, turns macro_rules DSL into something with
383383
signature Fn(TokenStream) -> TokenStream that can eat and produce tokens,
384384
@mark-i-m knows more about this librustc_resolve/macros.rs - resolving macro
@@ -408,8 +408,8 @@ piece of AST, etc), this is an enum that lists them
408408
ProcMacro/TTMacroExpander/AttrProcMacro/MultiItemModifier - traits representing
409409
the expander signatures (TODO: change and rename the signatures into something
410410
more consistent) trait Resolver - a trait used to break crate dependencies (so
411-
resolver services can be used in libsyntax, despite librustc_resolve and pretty
412-
much everything else depending on libsyntax) ExtCtxt/ExpansionData - various
411+
resolver services can be used in librustc_ast, despite librustc_resolve and pretty
412+
much everything else depending on librustc_ast) ExtCtxt/ExpansionData - various
413413
intermediate data kept and used by expansion infra in the process of its work
414414
AstFragment - a piece of AST that can be produced by a macro (may include
415415
multiple homogeneous AST nodes, like e.g. a list of items) Annotatable - a

src/name-resolution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespaces and therefore can co-exist.
2020
The name resolution in Rust is a two-phase process. In the first phase, which runs
2121
during macro expansion, we build a tree of modules and resolve imports. Macro
2222
expansion and name resolution communicate with each other via the `Resolver`
23-
trait, defined in `libsyntax`.
23+
trait, defined in `librustc_ast`.
2424

2525
The input to the second phase is the syntax tree, produced by parsing input
2626
files and expanding macros. This phase produces links from all the names in the

src/test-implementation.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ How does any sort of `main` function invoke these tests if they're not visible?
3131
What exactly is `rustc --test` doing?
3232

3333
`#[test]` is implemented as a syntactic transformation inside the compiler's
34-
[`libsyntax` crate][libsyntax]. Essentially, it's a fancy macro, that
34+
[`librustc_ast` crate][librustc_ast]. Essentially, it's a fancy macro, that
3535
rewrites the crate in 3 steps:
3636

3737
#### Step 1: Re-Exporting
3838

3939
As mentioned earlier, tests can exist inside private modules, so we need a
4040
way of exposing them to the main function, without breaking any existing
41-
code. To that end, `libsyntax` will create local modules called
41+
code. To that end, `librustc_ast` will create local modules called
4242
`__test_reexports` that recursively reexport tests. This expansion translates
4343
the above example into:
4444

@@ -78,7 +78,7 @@ hygiene.
7878

7979
#### Step 2: Harness Generation
8080
Now that our tests are accessible from the root of our crate, we need to do
81-
something with them. `libsyntax` generates a module like so:
81+
something with them. `librustc_ast` generates a module like so:
8282

8383
```rust,ignore
8484
#[main]
@@ -115,7 +115,7 @@ fn foo() {
115115
This means our tests are more than just simple functions, they have
116116
configuration information as well. `test` encodes this configuration data
117117
into a struct called [`TestDesc`][TestDesc]. For each test function in a
118-
crate, `libsyntax` will parse its attributes and generate a `TestDesc`
118+
crate, `librustc_ast` will parse its attributes and generate a `TestDesc`
119119
instance. It then combines the `TestDesc` and test function into the
120120
predictably named `TestDescAndFn` struct, that `test_main_static` operates
121121
on. For a given test, the generated `TestDescAndFn` instance looks like so:
@@ -146,7 +146,7 @@ $ rustc my_mod.rs -Z unpretty=hir
146146

147147
[test]: https://doc.rust-lang.org/test/index.html
148148
[TestDesc]: https://doc.rust-lang.org/test/struct.TestDesc.html
149-
[Symbol]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast/struct.Ident.html
150-
[Ident]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast/struct.Ident.html
149+
[Symbol]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/ast/struct.Ident.html
150+
[Ident]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/ast/struct.Ident.html
151151
[eRFC]: https://github.com/rust-lang/rfcs/blob/master/text/2318-custom-test-frameworks.md
152-
[libsyntax]: https://github.com/rust-lang/rust/tree/master/src/libsyntax
152+
[librustc_ast]: https://github.com/rust-lang/rust/tree/master/src/librustc_ast

0 commit comments

Comments
 (0)