Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove mentions of plugin lints #1833

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,6 @@ generally based on how they are registered.
- *Built-in* lints are defined inside the compiler source.
- *Driver-registered* lints are registered when the compiler driver is created
by an external driver. This is the mechanism used by Clippy, for example.
- *Plugin* lints are registered by the [deprecated plugin system].
- *Tool* lints are lints with a path prefix like `clippy::` or `rustdoc::`.
- *Internal* lints are the `rustc::` scoped tool lints that only run on the
rustc source tree itself and are defined in the compiler source like a
Expand All @@ -581,7 +580,6 @@ generally based on how they are registered.
More information about lint registration can be found in the [LintStore]
chapter.

[deprecated plugin system]: https://doc.rust-lang.org/nightly/unstable-book/language-features/plugin.html
[LintStore]: diagnostics/lintstore.md

### Declaring a lint
Expand Down
33 changes: 10 additions & 23 deletions src/diagnostics/lintstore.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ This page documents some of the machinery around lint registration and how we
run lints in the compiler.

The [`LintStore`] is the central piece of infrastructure, around which
everything rotates. It's not available during the early parts of compilation
(i.e., before TyCtxt) in most code, as we need to fill it in with all of the
lints, which can only happen after plugin registration.
everything rotates. The `LintStore` is held as part of the [`Session`], and it
gets populated with the list of lints shortly after the `Session` is created.

## Lints vs. lint passes

Expand Down Expand Up @@ -39,25 +38,23 @@ lints are emitted as part of other work (e.g., type checking, etc.).

### High-level overview

In [`rustc_interface::register_plugins`],
In [`rustc_interface::run_compiler`],
the [`LintStore`] is created,
and all lints are registered.

There are four 'sources' of lints:
There are three 'sources' of lints:

* internal lints: lints only used by the rustc codebase
* builtin lints: lints built into the compiler and not provided by some outside
source
* plugin lints: lints created by plugins through the plugin system.
* `rustc_interface::Config`[`register_lints`]: lints passed into the compiler
during construction

Lints are registered via the [`LintStore::register_lint`] function. This should
happen just once for any lint, or an ICE will occur.

Once the registration is complete, we "freeze" the lint store by placing it in
an `Lrc`. Later in the driver, it's passed into the `GlobalCtxt` constructor
where it lives in an immutable form from then on.
an `Lrc`.

Lint passes are registered separately into one of the categories
(pre-expansion, early, late, late module). Passes are registered as a closure
Expand All @@ -68,8 +65,8 @@ they can keep track of state internally.

#### Internal lints

These are lints used just by the compiler or plugins like `clippy`. They can be
found in `rustc_lint::internal`.
These are lints used just by the compiler or drivers like `clippy`. They can be
found in [`rustc_lint::internal`].

An example of such a lint is the check that lint passes are implemented using
the `declare_lint_pass!` macro and not by hand. This is accomplished with the
Expand All @@ -92,18 +89,6 @@ the [`rustc_lint::register_builtins`] function.
Just like with internal lints,
this happens inside of [`rustc_lint::new_lint_store`].

#### Plugin lints

This is one of the primary use cases remaining for plugins/drivers. Plugins are
given access to the mutable `LintStore` during registration (which happens
inside of [`rustc_interface::register_plugins`]) and they can call any
functions they need on the `LintStore`, just like rustc code.

Plugins are intended to declare lints with the `plugin` field set to true
(e.g., by way of the [`declare_tool_lint!`] macro), but this is purely for
diagnostics and help text; otherwise plugin lints are mostly just as first
class as rustc builtin lints.

#### Driver lints

These are the lints provided by drivers via the `rustc_interface::Config`
Expand All @@ -127,11 +112,13 @@ approach, it is beneficial to do so for performance reasons.

[`LintStore`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/struct.LintStore.html
[`LintStore::register_lint`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/struct.LintStore.html#method.register_lints
[`rustc_interface::register_plugins`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/passes/fn.register_plugins.html
[`rustc_lint::register_builtins`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/fn.register_builtins.html
[`rustc_lint::register_internals`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/fn.register_internals.html
[`rustc_lint::new_lint_store`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/fn.new_lint_store.html
[`declare_lint!`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/macro.declare_lint.html
[`declare_tool_lint!`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/macro.declare_tool_lint.html
[`register_lints`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/interface/struct.Config.html#structfield.register_lints
[`&rustc_lint_defs::Lint`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint_defs/struct.Lint.html
[`Session`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/struct.Session.html
[`rustc_interface::run_compiler`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/index.html#reexport.run_compiler
[`rustc_lint::internal`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/internal/index.html