|
2 | 2 | //! |
3 | 3 | //! ## Architecture |
4 | 4 | //! This crate is part of a series of crates and modules that handle attribute processing. |
5 | | -//! - [rustc_hir::attrs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/index.html): Defines the data structures that store parsed attributes |
6 | | -//! - [rustc_attr_parsing](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_attr_parsing/index.html): This crate, handles the parsing of attributes |
7 | | -//! - (planned) rustc_attr_validation: Will handle attribute validation, logic currently handled in `rustc_passes` |
| 5 | +//! - [`rustc_hir::attrs`]: Defines the data structures that store parsed attributes |
| 6 | +//! - `rustc_attr_parsing`: This crate, handles the parsing of attributes |
| 7 | +//! - [`rustc_passes::check_attr`] handles attribute validation that cannot be done in this crate |
8 | 8 | //! |
9 | 9 | //! The separation between data structures and parsing follows the principle of separation of concerns. |
10 | 10 | //! Data structures (`rustc_hir::attrs`) define what attributes look like after parsing. |
|
13 | 13 | //! the parsing logic, making the codebase more modular and maintainable. |
14 | 14 | //! |
15 | 15 | //! ## Background |
16 | | -//! Previously, the compiler had a single attribute definition (`ast::Attribute`) with parsing and |
| 16 | +//! Previously, the compiler had a single attribute definition ([`ast::Attribute`]) with parsing and |
17 | 17 | //! validation scattered throughout the codebase. This was reorganized for better maintainability |
18 | 18 | //! (see [#131229](https://github.com/rust-lang/rust/issues/131229)). |
19 | 19 | //! |
|
61 | 61 | //! `#[stable(...)]` and `#[unstable()]` cannot occur together, and both semantically define |
62 | 62 | //! a "stability" of an item. So, the stability attribute has an |
63 | 63 | //! [`AttributeParser`](attributes::AttributeParser) that recognizes both the `#[stable()]` |
64 | | -//! and `#[unstable()]` syntactic attributes, and at the end produce a single |
| 64 | +//! and `#[unstable()]` syntactic attributes, and at the end produces a single |
65 | 65 | //! [`AttributeKind::Stability`](rustc_hir::attrs::AttributeKind::Stability). |
66 | 66 | //! |
67 | 67 | //! When multiple instances of the same attribute are allowed, they're combined into a single |
|
82 | 82 | //! However, sometimes an attributes' parsed form is needed before the HIR is constructed. |
83 | 83 | //! This is referred to as "early" attribute parsing, |
84 | 84 | //! and is performed using the `parse_limited_*` family of functions on `AttributeParser`. |
| 85 | +//! |
| 86 | +//! [`ast::Attribute`]: rustc_ast::ast::Attribute |
| 87 | +//! [`rustc_passes::check_attr`]: ../rustc_passes/check_attr/index.html |
85 | 88 |
|
86 | 89 | // tidy-alphabetical-start |
87 | 90 | #![feature(decl_macro)] |
|
91 | 94 | // tidy-alphabetical-end |
92 | 95 |
|
93 | 96 | #[macro_use] |
94 | | -/// All the individual attribute parsers for each of rustc's built-in attributes. |
95 | 97 | mod attributes; |
96 | | - |
97 | | -/// All the important types given to attribute parsers when parsing |
98 | | -pub(crate) mod context; |
99 | | - |
100 | | -/// Code that other crates interact with, to actually parse a list (or sometimes single) |
101 | | -/// attribute. |
102 | | -mod interface; |
103 | | - |
104 | | -/// Despite this entire module called attribute parsing and the term being a little overloaded, |
105 | | -/// in this module the code lives that actually breaks up tokenstreams into semantic pieces of attributes, |
106 | | -/// like lists or name-value pairs. |
107 | | -pub mod parser; |
108 | | - |
109 | 98 | mod check_cfg; |
| 99 | +mod context; |
110 | 100 | mod early_parsed; |
111 | 101 | mod errors; |
| 102 | +mod interface; |
| 103 | +pub mod parser; |
112 | 104 | mod safety; |
113 | 105 | mod session_diagnostics; |
114 | 106 | mod stability; |
|
0 commit comments