From a627799e2a0989201416a11b8d3bf1af0be86073 Mon Sep 17 00:00:00 2001 From: Akshay Date: Thu, 28 Oct 2021 17:14:21 +0530 Subject: improve json output The `at` field now includes a `from` and `to` position with line and column information, instead of a [usize; 2]. --- lib/src/lib.rs | 6 ++++++ lib/src/lints/manual_inherit_from.rs | 1 + 2 files changed, 7 insertions(+) (limited to 'lib/src') diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 753e5c1..ec96f50 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -13,6 +13,12 @@ use serde::{ Serialize, }; +#[cfg_attr(feature = "json-out", derive(Serialize))] +pub struct Position { + line: usize, + column: usize, +} + /// Report generated by a lint #[derive(Debug, Default)] #[cfg_attr(feature = "json-out", derive(Serialize))] diff --git a/lib/src/lints/manual_inherit_from.rs b/lib/src/lints/manual_inherit_from.rs index 355ed8a..794aaf9 100644 --- a/lib/src/lints/manual_inherit_from.rs +++ b/lib/src/lints/manual_inherit_from.rs @@ -22,6 +22,7 @@ impl Rule for ManualInherit { if let Some(key_value_stmt) = KeyValue::cast(node.clone()); if let mut key_path = key_value_stmt.key()?.path(); if let Some(key_node) = key_path.next(); + // ensure that path has exactly one component if key_path.next().is_none(); if let Some(key) = Ident::cast(key_node); -- cgit v1.2.3