Skip to content

Commit 330782a

Browse files
committed
refactor: Break up Rationale / Alts into smaller sections
1 parent d32801b commit 330782a

File tree

1 file changed

+57
-47
lines changed

1 file changed

+57
-47
lines changed

text/3389-manifest-lint.md

Lines changed: 57 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ However, we also need to consider how decisions might limit us in the future and
206206
- Whether existing decisions will be revisited
207207
- When new tools are added, like `cargo` and `cargo-semver-check`, which haven't had lint levels and configuration long enough (or at all) to explore their problem and design space.
208208

209+
## Misc
210+
209211
This could be left to `clippy.toml` but that leaves `rustc`, `rustdoc`, and future linters without a solution.
210212

211213
`[lints]` could be `[package.lints]`, tying it to the package unlike `[patch]`
@@ -214,41 +216,7 @@ and other fields that are more workspace related. Instead, we used
214216

215217
`[lints]` could be `[lint]` but we decided to follow the precedence of `[dependencies]`.
216218

217-
Instead of `<tool>.<lint>`, we could use `<tool>::<lint>` (e.g.
218-
`"clipp::enum_glob_use"` instead of `clippy.enum_glob_use`), like in the
219-
diagnostic messages. This would make it easier to copy/paste lint names.
220-
However, with the schema being `<lint> = <level>`, this would require quoting
221-
the keys rather than leaving them as bare words. This might also cause
222-
problems for tool-level configuration. The first is that the lints wouldn't be
223-
easily grouped with their tool's config. The second is if we use `lints.<lint> = <level>`
224-
and tool-level configuration goes under `lints.<tool>`,
225-
then keys under `[lints]` are ambiguous as to whether they are a tool or a
226-
lint, making it harder to collect all lints to forward tools.
227-
228-
We could possibly extend this new field to `rustfmt` by shifting the focus from
229-
"lints" to "rules" (see
230-
[eslint](https://eslint.org/docs/latest/use/configure/rules)). However, the
231-
more we generalize this field, the fewer assumptions we can make about it. On
232-
one extreme is `package.metadata` which is so free-form we can't support it
233-
with workspace inheritance. A less extreme example is if we make the
234-
configuration too general, we would preclude the option of supporting
235-
per-package overrides as we wouldn't know enough about the shape of the data to
236-
know how to merge it. There is likely a middle ground that we could make work
237-
but it would take time and experimentation to figure that out which is at odds
238-
with trying to maintain a stable file format. Another problem with `rules` is
239-
that it is divorced from any context. In eslint, it is in an eslint-specific
240-
config file but a `[rules]` table is not a clear as a `[lints]` table as to
241-
what role it fulfills.
242-
243-
We could support platform or feature specific settings, like with
244-
`[lints.<target>]` or `[target.<target>.lints]` but
245-
- There isn't a defined use case for this yet besides having support for `cfg(feature = "clippy")` or
246-
which does not seem high enough priority to design
247-
around.
248-
- `[lints.<target>]` runs into ambiguity issues around what is a `<target>`
249-
entry vs a `<lint>` entry in the `[lints]` table.
250-
- We have not yet defined semantics for sharing something like this across a
251-
workspace
219+
## Schema
252220

253221
Instead of the `[lints]` table being `lint = "level"`, we could organize
254222
it around `level = ["lint", ...]` like some other linters do (like
@@ -265,19 +233,18 @@ chose `lint` being the keys because
265233
better maps to a users model to just say the package lint table gets merged
266234
into the workspace lint table. This is also easier to implement correctly.
267235

268-
## Workspace Inheritance
236+
## Linter Tables vs Linter Namespaces
269237

270-
Instead of using workspace inheritance for `[lint]`, we could make it
271-
workspace-level configuration, like `[patch]` which is automatically applied to
272-
all workspace members. However, `[patch]` and friends are because they affect
273-
the resolver / `Cargo.toml` and so they can only operate at the workspace
274-
level. `[lints]` is more like `[dependencies]` in being something that applies
275-
at the package level but we want shared across workspaces.
276-
277-
Instead of traditional workspace inheritance where there is a single value to
278-
inherit with `workspace = true`, we could have `[workspace.lints.<preset>]`
279-
which defines presets and the user could do `lints.<preset> = true`. The user
280-
could then name them as they wish to avoid collision with rustc lints.
238+
Instead of `<tool>.<lint>`, we could use `<tool>::<lint>` (e.g.
239+
`"clipp::enum_glob_use"` instead of `clippy.enum_glob_use`), like in the
240+
diagnostic messages. This would make it easier to copy/paste lint names.
241+
However, with the schema being `<lint> = <level>`, this would require quoting
242+
the keys rather than leaving them as bare words. This might also cause
243+
problems for tool-level configuration. The first is that the lints wouldn't be
244+
easily grouped with their tool's config. The second is if we use `lints.<lint> = <level>`
245+
and tool-level configuration goes under `lints.<tool>`,
246+
then keys under `[lints]` are ambiguous as to whether they are a tool or a
247+
lint, making it harder to collect all lints to forward tools.
281248

282249
## Lint Precedence
283250

@@ -330,6 +297,49 @@ Where the order is based on how to pass them on the command-line.
330297
Complex TOML arrays tend to be less friendly to work with including the fact
331298
that TOML 1.0 does not allow multi-line inline tables.
332299

300+
## Workspace Inheritance
301+
302+
Instead of using workspace inheritance for `[lint]`, we could make it
303+
workspace-level configuration, like `[patch]` which is automatically applied to
304+
all workspace members. However, `[patch]` and friends are because they affect
305+
the resolver / `Cargo.toml` and so they can only operate at the workspace
306+
level. `[lints]` is more like `[dependencies]` in being something that applies
307+
at the package level but we want shared across workspaces.
308+
309+
Instead of traditional workspace inheritance where there is a single value to
310+
inherit with `workspace = true`, we could have `[workspace.lints.<preset>]`
311+
which defines presets and the user could do `lints.<preset> = true`. The user
312+
could then name them as they wish to avoid collision with rustc lints.
313+
314+
## `rustfmt`
315+
316+
We could possibly extend this new field to `rustfmt` by shifting the focus from
317+
"lints" to "rules" (see
318+
[eslint](https://eslint.org/docs/latest/use/configure/rules)). However, the
319+
more we generalize this field, the fewer assumptions we can make about it. On
320+
one extreme is `package.metadata` which is so free-form we can't support it
321+
with workspace inheritance. A less extreme example is if we make the
322+
configuration too general, we would preclude the option of supporting
323+
per-package overrides as we wouldn't know enough about the shape of the data to
324+
know how to merge it. There is likely a middle ground that we could make work
325+
but it would take time and experimentation to figure that out which is at odds
326+
with trying to maintain a stable file format. Another problem with `rules` is
327+
that it is divorced from any context. In eslint, it is in an eslint-specific
328+
config file but a `[rules]` table is not a clear as a `[lints]` table as to
329+
what role it fulfills.
330+
331+
## Target-specific lint
332+
333+
We could support platform or feature specific settings, like with
334+
`[lints.<target>]` or `[target.<target>.lints]` but
335+
- There isn't a defined use case for this yet besides having support for `cfg(feature = "clippy")` or
336+
which does not seem high enough priority to design
337+
around.
338+
- `[lints.<target>]` runs into ambiguity issues around what is a `<target>`
339+
entry vs a `<lint>` entry in the `[lints]` table.
340+
- We have not yet defined semantics for sharing something like this across a
341+
workspace
342+
333343
# Prior art
334344
[prior-art]: #prior-art
335345

0 commit comments

Comments
 (0)