You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: text/3503-frontmatter.md
+20Lines changed: 20 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -168,6 +168,26 @@ When choosing the syntax, our care-abouts are
168
168
- Leave the door open in case we want to reuse the syntax for embedded lockfiles
169
169
- Leave the door open for single-file `lib`s
170
170
171
+
### Why add to Rust syntax, rather than letting Cargo handle it
172
+
173
+
The most naive way for cargo to handle this is for cargo to strip the manifest, write the Rust file to a temporary file, and compile that.
174
+
This is what has traditionally been done with various iterations of "cargo script".
175
+
176
+
This provides a second-class experience which runs counter to one of the design goals
177
+
- Error messages, `cargo metadata`, etc point to the stripped source with an "odd" path, rather than the real source
178
+
- Every tool that plans to support it would need to be updated to do stripping (`cargo fmt`, `cargo clippy`, etc)
179
+
180
+
A key part in there is "plan to support".
181
+
We'd need to build up buy-in for tools to be supporting a Cargo-only syntax.
182
+
This becomes more difficult when the tool in question tries to be Cargo-agnostic.
183
+
By having Cargo-agnostic external tool syntax in Rust, this mostly becomes transparent.
184
+
185
+
We could build a special relationship with rustc to support this.
186
+
For example, rustdoc passes code to rustc on stdin and sets `UNSTABLE_RUSTDOC_TEST_PATH` and `UNSTABLE_RUSTDOC_TEST_LINE` to control how errors are rendered.
187
+
We could then also special case the messages inside of cargo.
188
+
This both adds a major support burden to keep this house of lies standing but still falls short when it comes to tooling support.
189
+
Now every tool that wants to support the Cargo-only syntax has to build their own house of lies.
190
+
171
191
### Frontmatter
172
192
173
193
This proposed syntax builds off of the precedence of Rust having syntax specialized for an external tool
0 commit comments