Skip to content

Commit b213d1f

Browse files
committed
Mention that the edition may be observable
1 parent 9a9b8da commit b213d1f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

text/3791-crate-attr.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,19 @@ My awesome crate
126126

127127
`file!`, `include!`, `include_str!`, and `module_path!` all behave the same as when written in source code.
128128

129-
`--crate-attr` shares an edition with the crate (i.e. it is affected by `--edition`). In practice this should not be observable.
129+
`--crate-attr` shares an edition with the crate (i.e. it is affected by `--edition`). This may be observable because `doc` attributes can invoke arbitrary macros. Consider this use of [indoc]:
130+
```
131+
--crate-attr='doc = indoc::indoc! {"
132+
test
133+
this
134+
"}'
135+
```
136+
Edition-related changes to how proc-macros are passed tokens may need to consider how crate-attr is affected.
130137

131138
The behavior of `file!` and `column!` are not specified; see "Unresolved questions".
132139

140+
[indoc]: https://docs.rs/indoc/latest/indoc/
141+
133142
# Drawbacks
134143
[drawbacks]: #drawbacks
135144

@@ -168,3 +177,5 @@ In the author's opinion, having source injected via this mechanism does not make
168177
[future-possibilities]: #future-possibilities
169178

170179
This proposal would make it easier to use external tools with [`#![register_tool]`][`register-tool`], since they could be configured for a whole workspace at once instead of individually; and could be configured without modifying the source code.
180+
181+
I would like to add an `#![edition = ...]` attribute and make `--edition` an alias for `--crate-attr=edition`. At that point the interaction between crate-attr and macros becomes more complicated. But right now there is no interaction because `--edition` must always be a flag.

0 commit comments

Comments
 (0)