From a6c4025fac3c3a60581af72998230d46aa6f5ade Mon Sep 17 00:00:00 2001 From: Ben Lewis Date: Sat, 11 Jan 2020 15:22:36 +1300 Subject: 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. --- src/libsyntax/ast.rs | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'src/libsyntax') 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), -- cgit 1.4.1-3-g733a5