Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/completions/attribute/lint.rs')
-rw-r--r--crates/ide-completion/src/completions/attribute/lint.rs32
1 files changed, 16 insertions, 16 deletions
diff --git a/crates/ide-completion/src/completions/attribute/lint.rs b/crates/ide-completion/src/completions/attribute/lint.rs
index df577b8ed0..f810196bfe 100644
--- a/crates/ide-completion/src/completions/attribute/lint.rs
+++ b/crates/ide-completion/src/completions/attribute/lint.rs
@@ -1,5 +1,9 @@
//! Completion for lints
-use ide_db::{SymbolKind, documentation::Documentation, generated::lints::Lint};
+use ide_db::{
+ SymbolKind,
+ documentation::Documentation,
+ generated::lints::{CLIPPY_LINT_GROUPS, CLIPPY_LINTS, DEFAULT_LINTS, Lint, RUSTDOC_LINTS},
+};
use syntax::ast;
use crate::{Completions, context::CompletionContext, item::CompletionItem};
@@ -9,21 +13,17 @@ pub(super) fn complete_lint(
ctx: &CompletionContext<'_>,
is_qualified: bool,
existing_lints: &[ast::Path],
- lints_completions: &[Lint],
) {
- for &Lint { label, description, .. } in lints_completions {
- let (qual, name) = {
- // FIXME: change `Lint`'s label to not store a path in it but split the prefix off instead?
- let mut parts = label.split("::");
- let ns_or_label = match parts.next() {
- Some(it) => it,
- None => continue,
- };
- let label = parts.next();
- match label {
- Some(label) => (Some(ns_or_label), label),
- None => (None, ns_or_label),
- }
+ let lints = (CLIPPY_LINT_GROUPS.iter().map(|g| &g.lint))
+ .chain(DEFAULT_LINTS)
+ .chain(CLIPPY_LINTS)
+ .chain(RUSTDOC_LINTS);
+
+ for &Lint { label, description, .. } in lints {
+ // FIXME: change `Lint`'s label to not store a path in it but split the prefix off instead?
+ let (qual, name) = match label.split_once("::") {
+ Some((qual, name)) => (Some(qual), name),
+ None => (None, label),
};
if qual.is_none() && is_qualified {
// qualified completion requested, but this lint is unqualified
@@ -56,7 +56,7 @@ pub(super) fn complete_lint(
};
let mut item =
CompletionItem::new(SymbolKind::Attribute, ctx.source_range(), label, ctx.edition);
- item.documentation(Documentation::new_owned(description.to_owned()));
+ item.documentation(Documentation::new_borrowed(description));
item.add_to(acc, ctx.db)
}
}