1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//! The REWRITE MODE's front half — what `remote = "…"` does to the item the macro sits on.
//!
//! Every other word in this grammar adds a fact BESIDE the declaration. This one changes what the
//! declaration IS: the fields the author wrote stop being the type's own storage and become a
//! MANIFEST — the shape of a foreign type, restated so this framework can read it — and the item
//! the compiler sees becomes
//!
//! ```text
//! #[repr(transparent)]
//! pub struct Dimensions(mediaframe::Dimensions);
//! ```
//!
//! The orphan rule is why the restatement exists at all: a type another crate owns cannot be given
//! this framework's faces where it is declared, and a wrapper is the position where it can. The
//! wrapper is TRANSPARENT so that the reference family below it — `Deref`, `AsRef`, `Borrow` and
//! their mutable halves — is the language's own guarantee rather than a layout claim: `self.0` is a
//! field access, and no `transmute` is written anywhere in this device. The size/align-plus-
//! `transmute` alternative was examined and refused on soundness — a `repr(Rust)` layout is not
//! verifiable from outside, and `offset_of!` cannot name a private field of a foreign type — and
//! that refusal is settled rather than open.
//!
//! # What is checked HERE, and what the compiler is left to check
//!
//! This module owns the two rules about ATTRIBUTES, because both are about tokens the rewrite would
//! otherwise swallow. Everything else the mode demands is an API-surface fact about a type this
//! crate cannot see — the remote has an accessor per manifest field, of a type that crosses — and
//! those are checked where they are spent, by the compiler, at spans the emission puts on the
//! author's own tokens. See `ingraph_codegen::remote`, which writes them.
use crateErrors;
/// The attribute the macro's own markers are written in.
const ATTRIBUTE: &str = "ingraph";
/// The one item attribute a rewrite may not carry.
const REPRESENTATION: &str = "repr";
/// The two attributes a manifest field may carry BESIDES a doc comment.
///
/// `cfg` states whether the field exists, and the CONDITION SEAT carries it to every artifact the
/// field mints; `cfg_attr` decorates, and rides the reader beside the docs. Both are read by
/// [`crate::attribute::condition`], which is where the family-level rule lives — this list is only
/// what [`refuse_an_unplaceable_attribute`] must not refuse.
const CONDITIONAL: = ;
/// Whether an attribute is a doc comment — `///` or the `#[doc = "…"]` it desugars to.
/// Whether an attribute is this macro's own, and therefore consumed rather than carried.
/// The item attributes a rewrite CARRIES onto the wrapper, in the order they were written.
///
/// The family law, applied at the one position that rewrites: a non-`ingraph` attribute is
/// forwarded VERBATIM and in order, so an author's `#[derive(…)]`, their `#[cfg]`, their `///` and
/// anything a third-party macro reads all land on the item the compiler sees. Nothing is
/// interpreted — an attribute this grammar does not own is not this grammar's to read.
///
/// Only two things do not come through: the `#[ingraph(…)]` markers, which are the macro's own and
/// were read, and a `#[repr(…)]` — refused by [`refuse_a_representation`] before this is ever
/// reached, so the filter here would be unreachable and is deliberately not written.
pub
/// A manifest field's doc comments, for the reader they migrate onto.
///
/// The field is about to stop existing, so its documentation has to be carried or deleted. It is
/// carried to the READER — the method that answers what the field held — which is the one place in
/// the rewritten item where that field's meaning is still a question somebody can ask.
///
/// It does NOT reach the wire face. What a schema publishes is `attrs(desc = "…")` and nothing
/// else, which is a standing law of this grammar rather than a gap: *what reaches a schema is what
/// a declaration says reaches it*. A rewrite is not the occasion to overturn it.
pub
/// **THE MACRO OWNS THE REPRESENTATION** — a hand-written `#[repr(…)]` on a rewrite is refused.
///
/// `#[repr(transparent)]` is not decoration here; it is the premise the whole reference family
/// stands on. An author's own `#[repr(…)]` would either be overwritten silently or emitted beside
/// this macro's and refused by rustc inside an expansion, and both of those are worse than saying
/// so at the token that wrote it.
pub
/// **A MANIFEST FIELD HAS NO REAL BODY TO CARRY AN ATTRIBUTE**, so one that is not placeable is
/// refused by name rather than swallowed.
///
/// Three answers, and each is about where the attribute could LAND:
///
/// * a doc comment MIGRATES — see [`docs`] — so it is silently accepted here;
/// * `cfg` and `cfg_attr` are the CONDITION, read by [`crate::attribute::condition`] — the first
/// reaching the field's WHOLE generated family and the second riding its reader, so both have a
/// destination and neither is refused. That is what the earlier refuse-until promised and what the
/// condition seat made true: a `cfg` here takes the reader, the column in every database, the
/// filter seat, the order-by term and the place on the wire face, all together;
/// * anything else has no destination at all. The field is not emitted, so an attribute on it would
/// be read by nobody — and an attribute nobody reads is a rule its author believes they declared.
pub