Skip to content

Commit

Permalink
Auto merge of rust-lang#8947 - Serial-ATA:lint-produces-output, r=xFr…
Browse files Browse the repository at this point in the history
…ednet

Add lint output to lint list

changelog: Add the ability to show the lint output in the lint list

This just adds the logic to produce the output, it hasn't been added to any lints yet. It did help find some mistakes in some docs though 😄.

### Screenshots

<details>
<summary>A single code block</summary>

![single-code-block](https://user-images.githubusercontent.com/69764315/172013766-145b22b1-1d91-4fb8-9cd0-b967a52d6330.png)
</details>

<details>
<summary>A single code block with a "Use instead" section</summary>

![with-usage](https://user-images.githubusercontent.com/69764315/172013792-d2dd6c9c-defa-41e0-8c27-8e8e311adb63.png)
</details>

<details>
<summary>Multiple code blocks</summary>

![multi-code-block](https://user-images.githubusercontent.com/69764315/172013808-5328f59b-e7c5-4914-a396-253822a6d350.png)
</details>

This is the last task in rust-lang#7172 🎉.
r? `@xFrednet` (?)
  • Loading branch information
bors committed Jun 14, 2022
2 parents c07cbb9 + fdadebe commit 5a45805
Show file tree
Hide file tree
Showing 9 changed files with 246 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ rustc_tools_util = { version = "0.2", path = "rustc_tools_util" }
[features]
deny-warnings = ["clippy_lints/deny-warnings"]
integration = ["tempfile"]
internal = ["clippy_lints/internal"]
internal = ["clippy_lints/internal", "tempfile"]

[package.metadata.rust-analyzer]
# This package uses #[feature(rustc_private)]
Expand Down
4 changes: 3 additions & 1 deletion clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ edition = "2021"

[dependencies]
cargo_metadata = "0.14"
clippy_dev = { path = "../clippy_dev", optional = true }
clippy_utils = { path = "../clippy_utils" }
if_chain = "1.0"
itertools = "0.10.1"
Expand All @@ -18,6 +19,7 @@ quine-mc_cluskey = "0.2"
regex-syntax = "0.6"
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", optional = true }
tempfile = { version = "3.3.0", optional = true }
toml = "0.5"
unicode-normalization = "0.1"
unicode-script = { version = "0.5", default-features = false }
Expand All @@ -30,7 +32,7 @@ url = { version = "2.2", features = ["serde"] }
[features]
deny-warnings = ["clippy_utils/deny-warnings"]
# build clippy with internal lints enabled, off by default
internal = ["clippy_utils/internal", "serde_json"]
internal = ["clippy_utils/internal", "serde_json", "tempfile", "clippy_dev"]

[package.metadata.rust-analyzer]
# This crate uses #[feature(rustc_private)]
Expand Down
12 changes: 6 additions & 6 deletions clippy_lints/src/collapsible_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ declare_clippy_lint! {
/// makes code look more complex than it really is.
///
/// ### Example
/// ```rust,ignore
/// ```rust
/// # let (x, y) = (true, true);
/// if x {
/// if y {
/// …
/// //
/// }
/// }
///
/// ```
///
/// Use instead:
///
/// ```rust,ignore
/// ```rust
/// # let (x, y) = (true, true);
/// if x && y {
/// …
/// //
/// }
/// ```
#[clippy::version = "pre 1.29.0"]
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ declare_clippy_lint! {
/// if the `fn main()` is left implicit.
///
/// ### Examples
/// ``````rust
/// ```rust
/// /// An example of a doctest with a `main()` function
/// ///
/// /// # Examples
Expand All @@ -191,7 +191,7 @@ declare_clippy_lint! {
/// fn needless_main() {
/// unimplemented!();
/// }
/// ``````
/// ```
#[clippy::version = "1.40.0"]
pub NEEDLESS_DOCTEST_MAIN,
style,
Expand Down
3 changes: 2 additions & 1 deletion clippy_lints/src/large_include_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ declare_clippy_lint! {
/// let included_bytes = include_bytes!("very_large_file.txt");
/// ```
///
/// Instead, you can load the file at runtime:
/// Use instead:
/// ```rust,ignore
/// use std::fs;
///
/// // You can load the file at runtime
/// let string = fs::read_to_string("very_large_file.txt")?;
/// let bytes = fs::read("very_large_file.txt")?;
/// ```
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/literal_representation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ declare_clippy_lint! {
/// - Does not match on `_127` since that is a valid grouping for decimal and octal numbers
///
/// ### Example
/// ```ignore
/// `2_32` => `2_i32`
/// `250_8 => `250_u8`
/// ```
Expand Down
Loading

0 comments on commit 5a45805

Please sign in to comment.