diff options
author | Akshay <[email protected]> | 2021-10-19 11:30:03 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2021-10-19 11:30:03 +0100 |
commit | d666cfa6b1739ac17d080790068e31eb26bb9c4a (patch) | |
tree | 814ffd195695ca5e10aef49039be83995127f366 /lib | |
parent | 214e3bc4b675b08ce4df76b1373f4548949e67ee (diff) |
rework few error messages
Diffstat (limited to 'lib')
-rw-r--r-- | lib/src/lib.rs | 7 | ||||
-rw-r--r-- | lib/src/lints/collapsible_let_in.rs | 4 | ||||
-rw-r--r-- | lib/src/lints/manual_inherit.rs | 2 | ||||
-rw-r--r-- | lib/src/lints/manual_inherit_from.rs | 2 |
4 files changed, 11 insertions, 4 deletions
diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 4374ac7..6bb16b6 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs | |||
@@ -42,6 +42,13 @@ impl Report { | |||
42 | .push(Diagnostic::suggest(at, message, suggestion)); | 42 | .push(Diagnostic::suggest(at, message, suggestion)); |
43 | self | 43 | self |
44 | } | 44 | } |
45 | /// A range that encompasses all the suggestions provided in this report | ||
46 | pub fn total_suggestion_range(&self) -> Option<TextRange> { | ||
47 | self.diagnostics | ||
48 | .iter() | ||
49 | .flat_map(|d| Some(d.suggestion.as_ref()?.at)) | ||
50 | .reduce(|acc, next| acc.cover(next)) | ||
51 | } | ||
45 | } | 52 | } |
46 | 53 | ||
47 | /// Mapping from a bytespan to an error message. | 54 | /// Mapping from a bytespan to an error message. |
diff --git a/lib/src/lints/collapsible_let_in.rs b/lib/src/lints/collapsible_let_in.rs index c2cdf9b..878d218 100644 --- a/lib/src/lints/collapsible_let_in.rs +++ b/lib/src/lints/collapsible_let_in.rs | |||
@@ -26,10 +26,10 @@ impl Rule for CollapsibleLetIn { | |||
26 | if LetIn::cast(body.clone()).is_some(); | 26 | if LetIn::cast(body.clone()).is_some(); |
27 | then { | 27 | then { |
28 | let first_annotation = node.text_range(); | 28 | let first_annotation = node.text_range(); |
29 | let first_message = "This let-in expression contains a nested let-in expression"; | 29 | let first_message = "This `let in` expression contains a nested `let in` expression"; |
30 | 30 | ||
31 | let second_annotation = body.text_range(); | 31 | let second_annotation = body.text_range(); |
32 | let second_message = "This let-in expression is nested"; | 32 | let second_message = "This `let in` expression is nested"; |
33 | 33 | ||
34 | let replacement_at = { | 34 | let replacement_at = { |
35 | let start = body | 35 | let start = body |
diff --git a/lib/src/lints/manual_inherit.rs b/lib/src/lints/manual_inherit.rs index 717d190..3524dd3 100644 --- a/lib/src/lints/manual_inherit.rs +++ b/lib/src/lints/manual_inherit.rs | |||
@@ -32,7 +32,7 @@ impl Rule for ManualInherit { | |||
32 | then { | 32 | then { |
33 | let at = node.text_range(); | 33 | let at = node.text_range(); |
34 | let replacement = make::inherit_stmt(&[key]).node().clone(); | 34 | let replacement = make::inherit_stmt(&[key]).node().clone(); |
35 | let message = format!("The assignment `{}` is better written with `inherit`", node); | 35 | let message = format!("This assignment is better written with `inherit`"); |
36 | Some(Self::report().suggest(at, message, Suggestion::new(at, replacement))) | 36 | Some(Self::report().suggest(at, message, Suggestion::new(at, replacement))) |
37 | } else { | 37 | } else { |
38 | None | 38 | None |
diff --git a/lib/src/lints/manual_inherit_from.rs b/lib/src/lints/manual_inherit_from.rs index 41eb5cf..d7a00b2 100644 --- a/lib/src/lints/manual_inherit_from.rs +++ b/lib/src/lints/manual_inherit_from.rs | |||
@@ -37,7 +37,7 @@ impl Rule for ManualInherit { | |||
37 | let set = value.set()?; | 37 | let set = value.set()?; |
38 | make::inherit_from_stmt(set, &[key]).node().clone() | 38 | make::inherit_from_stmt(set, &[key]).node().clone() |
39 | }; | 39 | }; |
40 | let message = format!("The assignment `{}` is better written with `inherit`", node); | 40 | let message = format!("This assignment is better written with `inherit`"); |
41 | Some(Self::report().suggest(at, message, Suggestion::new(at, replacement))) | 41 | Some(Self::report().suggest(at, message, Suggestion::new(at, replacement))) |
42 | } else { | 42 | } else { |
43 | None | 43 | None |