Skip to content

Commit 72b97b8

Browse files
committed
add completions for clippy lint in attributes
Signed-off-by: Benjamin Coenen <[email protected]>
1 parent b4eacf1 commit 72b97b8

File tree

4 files changed

+9
-43
lines changed

4 files changed

+9
-43
lines changed

Cargo.lock

+1-38
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ide/src/completion/generated_lint_completions.rs

+1-1
Large diffs are not rendered by default.

xtask/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ walkdir = "2.3.1"
2020
write-json = "0.1.0"
2121
fs-err = "2.3"
2222
serde = { version = "1.0", features = ["derive"] }
23-
attohttpc = { version = "0.15.0", default-features = false, features = ["compress", "json"]}
23+
serde_json = "1.0"
2424
# Avoid adding more dependencies to this crate

xtask/src/codegen/gen_lint_completions.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Generates descriptors structure for unstable feature from Unstable Book
22
use std::{
33
collections::HashMap,
4+
fs::File,
45
path::{Path, PathBuf},
56
};
67

@@ -20,8 +21,9 @@ pub fn generate_lint_completions(mode: Mode) -> Result<()> {
2021
}
2122

2223
let ts_features = generate_descriptor("./target/rust/src/doc/unstable-book/src".into())?;
23-
let ts_clippy =
24-
generate_descriptor_clippy("http://rust-lang.github.io/rust-clippy/master/lints.json")?;
24+
run!("curl http://rust-lang.github.io/rust-clippy/master/lints.json --output ./target/clippy_lints.json")?;
25+
26+
let ts_clippy = generate_descriptor_clippy("./target/clippy_lints.json")?;
2527
let ts = quote! {
2628
use crate::completion::complete_attribute::LintCompletion;
2729
#ts_features
@@ -70,7 +72,8 @@ struct ClippyLint {
7072
}
7173

7274
fn generate_descriptor_clippy(uri: &str) -> Result<proc_macro2::TokenStream> {
73-
let clippy_lints: Vec<ClippyLint> = attohttpc::get(uri).send()?.json()?;
75+
let file = File::open(uri)?;
76+
let clippy_lints: Vec<ClippyLint> = serde_json::from_reader(file)?;
7477
let definitions = clippy_lints.into_iter().map(|mut clippy_lint| {
7578
let lint_ident = format!("clippy::{}", clippy_lint.id);
7679
let doc = clippy_lint.docs.remove("What it does").unwrap_or_default();

0 commit comments

Comments
 (0)