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

Implement common traits for Diagnostic and related types #160

Merged
merged 2 commits into from
Jan 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! The following data types are copied from [rust-lang/rust](https://github.com/rust-lang/rust/blob/de78655bca47cac8e783dbb563e7e5c25c1fae40/src/libsyntax/json.rs)

#[derive(Deserialize, Debug)]
#[derive(Clone, Deserialize, Debug, Hash, Eq, PartialEq)]
pub struct Diagnostic {
/// The primary error message.
pub message: String,
Expand All @@ -18,7 +18,7 @@ pub struct Diagnostic {
pub rendered: Option<String>,
}

#[derive(Deserialize, Debug)]
#[derive(Clone, Deserialize, Debug, Hash, Eq, PartialEq)]
pub struct DiagnosticSpan {
pub file_name: String,
pub byte_start: u32,
Expand Down Expand Up @@ -46,15 +46,15 @@ pub struct DiagnosticSpan {
expansion: Option<Box<DiagnosticSpanMacroExpansion>>,
}

#[derive(Copy, Clone, Debug, PartialEq, Deserialize)]
#[derive(Copy, Clone, Debug, PartialEq, Deserialize, Hash, Eq)]
pub enum Applicability {
MachineApplicable,
HasPlaceholders,
MaybeIncorrect,
Unspecified,
}

#[derive(Deserialize, Debug)]
#[derive(Clone, Deserialize, Debug, Eq, PartialEq, Hash)]
pub struct DiagnosticSpanLine {
pub text: String,

Expand All @@ -64,7 +64,7 @@ pub struct DiagnosticSpanLine {
pub highlight_end: usize,
}

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

#[derive(Deserialize, Debug)]
#[derive(Clone, Deserialize, Debug, Eq, PartialEq, Hash)]
pub struct DiagnosticCode {
/// The code itself.
pub code: String,
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn get_suggestions_from_json<S: ::std::hash::BuildHasher>(
Ok(result)
}

#[derive(Debug, Copy, Clone, Hash, PartialEq)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct LinePosition {
pub line: usize,
pub column: usize,
Expand All @@ -49,7 +49,7 @@ impl std::fmt::Display for LinePosition {
}
}

#[derive(Debug, Copy, Clone, Hash, PartialEq)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct LineRange {
pub start: LinePosition,
pub end: LinePosition,
Expand All @@ -61,21 +61,21 @@ impl std::fmt::Display for LineRange {
}
}

#[derive(Debug, Clone, Hash, PartialEq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
/// An error/warning and possible solutions for fixing it
pub struct Suggestion {
pub message: String,
pub snippets: Vec<Snippet>,
pub solutions: Vec<Solution>,
}

#[derive(Debug, Clone, Hash, PartialEq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct Solution {
pub message: String,
pub replacements: Vec<Replacement>,
}

#[derive(Debug, Clone, Hash, PartialEq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct Snippet {
pub file_name: String,
pub line_range: LineRange,
Expand All @@ -86,7 +86,7 @@ pub struct Snippet {
pub text: (String, String, String),
}

#[derive(Debug, Clone, Hash, PartialEq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct Replacement {
pub snippet: Snippet,
pub replacement: String,
Expand Down