Skip to content

Commit

Permalink
Replace unsafe with unsafe_code, because unsafe is not a lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
Feriixu authored Feb 12, 2024
1 parent 017edf5 commit 56ca413
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions text/3389-manifest-lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ rustc and other tool lints.
[motivation]: #motivation

Currently, you can configure lints through
- `#[<level>(<lint>)]` or `#![<level>(<lint>)]`, like `#[forbid(unsafe)]`
- `#[<level>(<lint>)]` or `#![<level>(<lint>)]`, like `#[forbid(unsafe_code)]`
- But this doesn't scale up with additional targets (benches, examples,
tests) or workspaces
- On the command line, like `cargo clippy -- --forbid unsafe`
- On the command line, like `cargo clippy -- --forbid unsafe_code`
- This puts the burden on the caller
- Through `RUSTFLAGS`, like `RUSTFLAGS=--forbid=unsafe cargo clippy`
- Through `RUSTFLAGS`, like `RUSTFLAGS=--forbid=unsafe_code cargo clippy`
- This puts the burden on the caller
- In `.cargo/config.toml`'s `target.*.rustflags`
- This couples you to the running in specific directories and not running in
Expand All @@ -41,7 +41,7 @@ See also
A new `lints` table would be added to configure lints:
```toml
[lints.rust]
unsafe = "forbid"
unsafe_code = "forbid"
```
and `cargo` would pass these along as flags to `rustc`, `clippy`, or other lint tools.

Expand All @@ -52,7 +52,7 @@ This would work with
workspace = true

[workspace.lints.rust]
unsafe = "forbid"
unsafe_code = "forbid"
```

## Documentation Updates
Expand All @@ -65,13 +65,13 @@ Override the default level of lints from different tools by assigning them to a
table, for example:
```toml
[lints.rust]
unsafe = "forbid"
unsafe_code = "forbid"
```

This is short-hand for:
```toml
[lints.rust]
unsafe = { level = "forbid", priority = 0 }
unsafe_code = { level = "forbid", priority = 0 }
```

`level` corresponds to the lint levels in `rustc`:
Expand All @@ -87,7 +87,7 @@ unsafe = { level = "forbid", priority = 0 }

To know which table under `[lints]` a particular lint belongs under, it is the part before `::` in the lint
name. If there isn't a `::`, then the tool is `rust`. For example a warning
about `unsafe` would be `lints.rust.unsafe` but a lint about
about `unsafe_code` would be `lints.rust.unsafe_code` but a lint about
`clippy::enum_glob_use` would be `lints.clippy.enum_glob_use`.

## The `lints` table
Expand All @@ -106,7 +106,7 @@ Example:
members = ["crates/*"]

[workspace.lints.rust]
unsafe = "forbid"
unsafe_code = "forbid"
```

```toml
Expand Down

0 comments on commit 56ca413

Please sign in to comment.