Skip to content

Commit

Permalink
Derive PartialEq, Eq, Hash for Message
Browse files Browse the repository at this point in the history
  • Loading branch information
alopatindev committed Sep 20, 2020
1 parent 3fa3b5e commit e43a0d7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions src/diagnostic.rs
Expand Up @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use std::fmt;

/// The error code associated to this diagnostic.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct DiagnosticCode {
/// The code itself.
pub code: String,
Expand All @@ -16,7 +16,7 @@ pub struct DiagnosticCode {
}

/// A line of code associated with the Diagnostic
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct DiagnosticSpanLine {
/// The line of code associated with the error
pub text: String,
Expand All @@ -30,7 +30,7 @@ pub struct DiagnosticSpanLine {
}

/// Macro expansion information associated with a diagnostic.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct DiagnosticSpanMacroExpansion {
/// span where macro was applied to generate this code; note that
/// this may itself derive from a macro (if
Expand All @@ -48,7 +48,7 @@ pub struct DiagnosticSpanMacroExpansion {
}

/// A section of the source code associated with a Diagnostic
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct DiagnosticSpan {
/// The file name or the macro name this diagnostic comes from.
pub file_name: String,
Expand Down Expand Up @@ -90,7 +90,7 @@ pub struct DiagnosticSpan {
}

/// Whether a suggestion can be safely applied.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub enum Applicability {
/// The suggested replacement can be applied automatically safely
MachineApplicable,
Expand All @@ -108,7 +108,7 @@ pub enum Applicability {
}

/// The diagnostic level
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]
#[serde(rename_all = "lowercase")]
pub enum DiagnosticLevel {
/// Internal compiler error
Expand All @@ -128,7 +128,7 @@ pub enum DiagnosticLevel {
}

/// A diagnostic message generated by rustc
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct Diagnostic {
/// The error message of this diagnostic.
pub message: String,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Expand Up @@ -352,7 +352,7 @@ impl std::fmt::Display for Source {
}
}

#[derive(Clone, Serialize, Deserialize, Debug)]
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, Hash)]
/// A single target (lib, bin, example, ...) provided by a crate
pub struct Target {
/// Name as given in the `Cargo.toml` or generated from the file name
Expand Down
12 changes: 6 additions & 6 deletions src/messages.rs
Expand Up @@ -6,7 +6,7 @@ use std::path::PathBuf;

/// Profile settings used to determine which compiler flags to use for a
/// target.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct ArtifactProfile {
/// Optimization level. Possible values are 0-3, s or z.
pub opt_level: String,
Expand All @@ -25,7 +25,7 @@ pub struct ArtifactProfile {
}

/// A compiler-generated file.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct Artifact {
/// The package this artifact belongs to
pub package_id: PackageId,
Expand All @@ -49,7 +49,7 @@ pub struct Artifact {

/// Message left by the compiler
// TODO: Better name. This one comes from machine_message.rs
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct CompilerMessage {
/// The package this message belongs to
pub package_id: PackageId,
Expand All @@ -63,7 +63,7 @@ pub struct CompilerMessage {
}

/// Output of a build script execution.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct BuildScript {
/// The package this build script execution belongs to
pub package_id: PackageId,
Expand All @@ -86,7 +86,7 @@ pub struct BuildScript {
}

/// Final result of a build.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct BuildFinished {
/// Whether or not the build finished successfully.
pub success: bool,
Expand All @@ -96,7 +96,7 @@ pub struct BuildFinished {
}

/// A cargo message
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
#[serde(tag = "reason", rename_all = "kebab-case")]
pub enum Message {
/// The compiler generated an artifact
Expand Down

0 comments on commit e43a0d7

Please sign in to comment.