Skip to content

Commit 08babc8

Browse files
Add documentation of early parsing
1 parent dc9e4b0 commit 08babc8

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl OnUnknownParser {
2525
self.span = Some(span);
2626

2727
// At early parsing we get passed `Target::Crate` regardless of the item we're on.
28-
// Only do target checking if we're late.
28+
// Therefore, only do target checking if we can emit.
2929
let early = matches!(cx.should_emit, ShouldEmit::Nothing);
3030

3131
if !early && !matches!(cx.target, Target::Use) {

compiler/rustc_attr_parsing/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@
7575
//!
7676
//! This is equivalent to `#[repr(C, packed)]` and results in a single `AttributeKind::Repr`
7777
//! containing both `C` and `packed` annotations.
78+
//!
79+
//! ## Early attribute parsing
80+
//!
81+
//! While lowering to the HIR, all attributes are parsed using the attribute parsers.
82+
//! However, sometimes an attributes' parsed form is needed before the HIR is constructed.
83+
//! This is referred to as "early" attribute parsing,
84+
//! and is performed using the `parse_limited_*` family of functions on `AttributeParser`.
7885
7986
// tidy-alphabetical-start
8087
#![feature(decl_macro)]

0 commit comments

Comments
 (0)