Skip to content

Commit

Permalink
Add Hash traits where needed
Browse files Browse the repository at this point in the history
  • Loading branch information
pierwill committed Dec 15, 2021
1 parent 6408a3a commit 75f8283
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions chalk-parse/src/ast.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt;
use string_cache::DefaultAtom as Atom;

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
pub struct Span {
pub lo: usize,
pub hi: usize,
Expand Down Expand Up @@ -98,7 +98,7 @@ pub struct AdtRepr {
pub int: Option<Ty>,
}

#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub struct FnSig {
pub abi: FnAbi,
pub safety: Safety,
Expand Down Expand Up @@ -126,7 +126,7 @@ pub struct ClosureDefn {
pub upvars: Vec<Ty>,
}

#[derive(Clone, Eq, PartialEq, Debug)]
#[derive(Clone, Eq, PartialEq, Debug, Hash)]
pub struct FnAbi(pub Atom);

impl Default for FnAbi {
Expand Down Expand Up @@ -189,7 +189,7 @@ pub struct OpaqueTyDefn {
pub where_clauses: Vec<QuantifiedWhereClause>,
}

#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub enum VariableKind {
Ty(Identifier),
IntegerTy(Identifier),
Expand All @@ -198,42 +198,42 @@ pub enum VariableKind {
Const(Identifier),
}

#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub enum GenericArg {
Ty(Ty),
Lifetime(Lifetime),
Id(Identifier),
Const(Const),
}

#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub enum Const {
Id(Identifier),
Value(u32),
}

#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
/// An inline bound, e.g. `: Foo<K>` in `impl<K, T: Foo<K>> SomeType<T>`.
pub enum InlineBound {
TraitBound(TraitBound),
AliasEqBound(AliasEqBound),
}

#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub struct QuantifiedInlineBound {
pub variable_kinds: Vec<VariableKind>,
pub bound: InlineBound,
}

#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
/// Represents a trait bound on e.g. a type or type parameter.
/// Does not know anything about what it's binding.
pub struct TraitBound {
pub trait_name: Identifier,
pub args_no_self: Vec<GenericArg>,
}

#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
/// Represents an alias equality bound on e.g. a type or type parameter.
/// Does not know anything about what it's binding.
pub struct AliasEqBound {
Expand Down Expand Up @@ -284,7 +284,7 @@ pub struct AssocTyValue {
pub default: bool,
}

#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub enum Ty {
Id {
name: Identifier,
Expand Down Expand Up @@ -331,7 +331,7 @@ pub enum Ty {
Never,
}

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
pub enum IntTy {
Isize,
I8,
Expand All @@ -341,7 +341,7 @@ pub enum IntTy {
I128,
}

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
pub enum UintTy {
Usize,
U8,
Expand All @@ -351,13 +351,13 @@ pub enum UintTy {
U128,
}

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
pub enum FloatTy {
F32,
F64,
}

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
pub enum ScalarType {
Bool,
Char,
Expand All @@ -366,13 +366,13 @@ pub enum ScalarType {
Float(FloatTy),
}

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
pub enum Mutability {
Mut,
Not,
}

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
pub enum Safety {
Safe,
Unsafe,
Expand All @@ -384,22 +384,22 @@ impl Default for Safety {
}
}

#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub enum Lifetime {
Id { name: Identifier },
Static,
Erased,
Empty,
}

#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub struct ProjectionTy {
pub trait_ref: TraitRef,
pub name: Identifier,
pub args: Vec<GenericArg>,
}

#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub struct TraitRef {
pub trait_name: Identifier,
pub args: Vec<GenericArg>,
Expand All @@ -424,7 +424,7 @@ impl Polarity {
}
}

#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub struct Identifier {
pub str: Atom,
pub span: Span,
Expand All @@ -436,7 +436,7 @@ impl fmt::Display for Identifier {
}
}

#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub enum WhereClause {
Implemented { trait_ref: TraitRef },
ProjectionEq { projection: ProjectionTy, ty: Ty },
Expand Down Expand Up @@ -469,7 +469,7 @@ pub enum LeafGoal {
SubtypeGenericArgs { a: Ty, b: Ty },
}

#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub struct QuantifiedWhereClause {
pub variable_kinds: Vec<VariableKind>,
pub where_clause: WhereClause,
Expand Down

0 comments on commit 75f8283

Please sign in to comment.