aboutsummaryrefslogtreecommitdiff
path: root/lib/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src/lib.rs')
-rw-r--r--lib/src/lib.rs30
1 files changed, 17 insertions, 13 deletions
diff --git a/lib/src/lib.rs b/lib/src/lib.rs
index 196cbf8..5347666 100644
--- a/lib/src/lib.rs
+++ b/lib/src/lib.rs
@@ -226,25 +226,29 @@ pub trait Rule {
226/// Contains information about the lint itself. Do not implement manually, 226/// Contains information about the lint itself. Do not implement manually,
227/// look at the `lint` attribute macro instead for implementing rules 227/// look at the `lint` attribute macro instead for implementing rules
228pub trait Metadata { 228pub trait Metadata {
229 fn name() -> &'static str 229 fn name(&self) -> &'static str;
230 where 230 fn note(&self) -> &'static str;
231 Self: Sized; 231 fn code(&self) -> u32;
232 fn note() -> &'static str 232 fn report(&self) -> Report;
233 where
234 Self: Sized;
235 fn code() -> u32
236 where
237 Self: Sized;
238 fn report() -> Report
239 where
240 Self: Sized;
241 fn match_with(&self, with: &SyntaxKind) -> bool; 233 fn match_with(&self, with: &SyntaxKind) -> bool;
242 fn match_kind(&self) -> Vec<SyntaxKind>; 234 fn match_kind(&self) -> Vec<SyntaxKind>;
243} 235}
244 236
237/// Contains offline explanation for each lint
238/// The `lint` macro scans nearby doc comments for
239/// explanations and derives this trait.
240///
241/// FIXME: the lint macro does way too much, maybe
242/// split it into smaller macros.
243pub trait Explain {
244 fn explanation(&self) -> &'static str {
245 "no explanation found"
246 }
247}
248
245/// Combines Rule and Metadata, do not implement manually, this is derived by 249/// Combines Rule and Metadata, do not implement manually, this is derived by
246/// the `lint` macro. 250/// the `lint` macro.
247pub trait Lint: Metadata + Rule + Send + Sync {} 251pub trait Lint: Metadata + Explain + Rule + Send + Sync {}
248 252
249/// Helper utility to take lints from modules and insert them into a map for efficient 253/// Helper utility to take lints from modules and insert them into a map for efficient
250/// access. Mapping is from a SyntaxKind to a list of lints that apply on that Kind. 254/// access. Mapping is from a SyntaxKind to a list of lints that apply on that Kind.