about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorBen Lewis <benlewisj@gmail.com>2020-01-11 15:22:36 +1300
committerBen Lewis <benlewisj@gmail.com>2020-01-14 07:47:45 +1300
commita6c4025fac3c3a60581af72998230d46aa6f5ade (patch)
treee1e162084cf9245c2b0419b4895fa9a84ca3865f /src/libsyntax
parentbf84eb538fd16743240434b3e837b36c35719fee (diff)
perf: eagerly convert literals to consts, this avoids creating loads on unevaluated consts
which requires a lot of unnecessary work to evaluate them further down the line.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs41
1 files changed, 34 insertions, 7 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 33acba8eba0..ace12a7ffd2 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -1441,8 +1441,17 @@ pub struct MacroDef {
     pub legacy: bool,
 }
 
-// Clippy uses Hash and PartialEq
-#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy, Hash, PartialEq, HashStable_Generic)]
+#[derive(
+    Clone,
+    RustcEncodable,
+    RustcDecodable,
+    Debug,
+    Copy,
+    Hash,
+    Eq,
+    PartialEq,
+    HashStable_Generic
+)]
 pub enum StrStyle {
     /// A regular string, like `"foo"`.
     Cooked,
@@ -1491,9 +1500,18 @@ impl StrLit {
     }
 }
 
-// Clippy uses Hash and PartialEq
 /// Type of the integer literal based on provided suffix.
-#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq, HashStable_Generic)]
+#[derive(
+    Clone,
+    Copy,
+    RustcEncodable,
+    RustcDecodable,
+    Debug,
+    Hash,
+    Eq,
+    PartialEq,
+    HashStable_Generic
+)]
 pub enum LitIntType {
     /// e.g. `42_i32`.
     Signed(IntTy),
@@ -1504,7 +1522,17 @@ pub enum LitIntType {
 }
 
 /// Type of the float literal based on provided suffix.
-#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq, HashStable_Generic)]
+#[derive(
+    Clone,
+    Copy,
+    RustcEncodable,
+    RustcDecodable,
+    Debug,
+    Hash,
+    Eq,
+    PartialEq,
+    HashStable_Generic
+)]
 pub enum LitFloatType {
     /// A float literal with a suffix (`1f32` or `1E10f32`).
     Suffixed(FloatTy),
@@ -1515,8 +1543,7 @@ pub enum LitFloatType {
 /// Literal kind.
 ///
 /// E.g., `"foo"`, `42`, `12.34`, or `bool`.
-// Clippy uses Hash and PartialEq
-#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq, HashStable_Generic)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Hash, Eq, PartialEq, HashStable_Generic)]
 pub enum LitKind {
     /// A string literal (`"foo"`).
     Str(Symbol, StrStyle),