Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Commit 2f5f030

Browse files
authored
Merge pull request #160 from jsgf/master
Implement common traits for Diagnostic and related types
2 parents 7e88e76 + dff0dba commit 2f5f030

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/diagnostics.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! The following data types are copied from [rust-lang/rust](https://github.com/rust-lang/rust/blob/de78655bca47cac8e783dbb563e7e5c25c1fae40/src/libsyntax/json.rs)
44
5-
#[derive(Deserialize, Debug)]
5+
#[derive(Clone, Deserialize, Debug, Hash, Eq, PartialEq)]
66
pub struct Diagnostic {
77
/// The primary error message.
88
pub message: String,
@@ -18,7 +18,7 @@ pub struct Diagnostic {
1818
pub rendered: Option<String>,
1919
}
2020

21-
#[derive(Deserialize, Debug)]
21+
#[derive(Clone, Deserialize, Debug, Hash, Eq, PartialEq)]
2222
pub struct DiagnosticSpan {
2323
pub file_name: String,
2424
pub byte_start: u32,
@@ -46,15 +46,15 @@ pub struct DiagnosticSpan {
4646
expansion: Option<Box<DiagnosticSpanMacroExpansion>>,
4747
}
4848

49-
#[derive(Copy, Clone, Debug, PartialEq, Deserialize)]
49+
#[derive(Copy, Clone, Debug, PartialEq, Deserialize, Hash, Eq)]
5050
pub enum Applicability {
5151
MachineApplicable,
5252
HasPlaceholders,
5353
MaybeIncorrect,
5454
Unspecified,
5555
}
5656

57-
#[derive(Deserialize, Debug)]
57+
#[derive(Clone, Deserialize, Debug, Eq, PartialEq, Hash)]
5858
pub struct DiagnosticSpanLine {
5959
pub text: String,
6060

@@ -64,7 +64,7 @@ pub struct DiagnosticSpanLine {
6464
pub highlight_end: usize,
6565
}
6666

67-
#[derive(Deserialize, Debug)]
67+
#[derive(Clone, Deserialize, Debug, Eq, PartialEq, Hash)]
6868
struct DiagnosticSpanMacroExpansion {
6969
/// span where macro was applied to generate this code; note that
7070
/// this may itself derive from a macro (if
@@ -78,7 +78,7 @@ struct DiagnosticSpanMacroExpansion {
7878
def_site_span: Option<DiagnosticSpan>,
7979
}
8080

81-
#[derive(Deserialize, Debug)]
81+
#[derive(Clone, Deserialize, Debug, Eq, PartialEq, Hash)]
8282
pub struct DiagnosticCode {
8383
/// The code itself.
8484
pub code: String,

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn get_suggestions_from_json<S: ::std::hash::BuildHasher>(
3737
Ok(result)
3838
}
3939

40-
#[derive(Debug, Copy, Clone, Hash, PartialEq)]
40+
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
4141
pub struct LinePosition {
4242
pub line: usize,
4343
pub column: usize,
@@ -49,7 +49,7 @@ impl std::fmt::Display for LinePosition {
4949
}
5050
}
5151

52-
#[derive(Debug, Copy, Clone, Hash, PartialEq)]
52+
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
5353
pub struct LineRange {
5454
pub start: LinePosition,
5555
pub end: LinePosition,
@@ -61,21 +61,21 @@ impl std::fmt::Display for LineRange {
6161
}
6262
}
6363

64-
#[derive(Debug, Clone, Hash, PartialEq)]
64+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
6565
/// An error/warning and possible solutions for fixing it
6666
pub struct Suggestion {
6767
pub message: String,
6868
pub snippets: Vec<Snippet>,
6969
pub solutions: Vec<Solution>,
7070
}
7171

72-
#[derive(Debug, Clone, Hash, PartialEq)]
72+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
7373
pub struct Solution {
7474
pub message: String,
7575
pub replacements: Vec<Replacement>,
7676
}
7777

78-
#[derive(Debug, Clone, Hash, PartialEq)]
78+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
7979
pub struct Snippet {
8080
pub file_name: String,
8181
pub line_range: LineRange,
@@ -86,7 +86,7 @@ pub struct Snippet {
8686
pub text: (String, String, String),
8787
}
8888

89-
#[derive(Debug, Clone, Hash, PartialEq)]
89+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
9090
pub struct Replacement {
9191
pub snippet: Snippet,
9292
pub replacement: String,

0 commit comments

Comments
 (0)