From 93b7a394873698862953bdc336fa884eaa6b2159 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Wed, 13 Oct 2021 01:52:28 +0100 Subject: [PATCH] Use a not working type param default instead of cfg-gating cfg-gating type params only work in Rust 1.48+ --- src/read/cfi.rs | 32 +++++++------------------------- src/read/op.rs | 10 ++-------- 2 files changed, 9 insertions(+), 33 deletions(-) diff --git a/src/read/cfi.rs b/src/read/cfi.rs index 61d39d5d..b6a81f3f 100644 --- a/src/read/cfi.rs +++ b/src/read/cfi.rs @@ -11,9 +11,9 @@ use super::util::{ArrayLike, ArrayVec}; use crate::common::{DebugFrameOffset, EhFrameOffset, Encoding, Format, Register, SectionId}; use crate::constants::{self, DwEhPe}; use crate::endianity::Endianity; -#[cfg(feature = "read")] -use crate::read::StoreOnHeap; -use crate::read::{EndianSlice, Error, Expression, Reader, ReaderOffset, Result, Section}; +use crate::read::{ + EndianSlice, Error, Expression, Reader, ReaderOffset, Result, Section, StoreOnHeap, +}; /// `DebugFrame` contains the `.debug_frame` section's frame unwinding /// information required to unwind to and recover registers from older frames on @@ -1822,11 +1822,7 @@ impl UnwindContextStorage for StoreOnHeap { /// # } /// ``` #[derive(Clone, PartialEq, Eq)] -pub struct UnwindContext< - R: Reader, - #[cfg(not(feature = "read"))] A: UnwindContextStorage, - #[cfg(feature = "read")] A: UnwindContextStorage = StoreOnHeap, -> { +pub struct UnwindContext = StoreOnHeap> { // Stack of rows. The last row is the row currently being built by the // program. There is always at least one row. The vast majority of CFI // programs will only ever have one row on the stack. @@ -2049,13 +2045,7 @@ impl> UnwindContext { /// > recording just the differences starting at the beginning address of each /// > subroutine in the program. #[derive(Debug)] -pub struct UnwindTable< - 'a, - 'ctx, - R: Reader, - #[cfg(not(feature = "read"))] A: UnwindContextStorage, - #[cfg(feature = "read")] A: UnwindContextStorage = StoreOnHeap, -> { +pub struct UnwindTable<'a, 'ctx, R: Reader, A: UnwindContextStorage = StoreOnHeap> { code_alignment_factor: Wrapping, data_alignment_factor: Wrapping, next_start_address: u64, @@ -2366,11 +2356,7 @@ impl<'a, 'ctx, R: Reader, A: UnwindContextStorage> UnwindTable<'a, 'ctx, R, A // - https://github.com/libunwind/libunwind/blob/11fd461095ea98f4b3e3a361f5a8a558519363fa/include/tdep-aarch64/dwarf-config.h#L32 // - https://github.com/libunwind/libunwind/blob/11fd461095ea98f4b3e3a361f5a8a558519363fa/include/tdep-arm/dwarf-config.h#L31 // - https://github.com/libunwind/libunwind/blob/11fd461095ea98f4b3e3a361f5a8a558519363fa/include/tdep-mips/dwarf-config.h#L31 -struct RegisterRuleMap< - R: Reader, - #[cfg(not(feature = "read"))] S: UnwindContextStorage, - #[cfg(feature = "read")] S: UnwindContextStorage = StoreOnHeap, -> { +struct RegisterRuleMap = StoreOnHeap> { rules: ArrayVec, } @@ -2513,11 +2499,7 @@ impl<'iter, R: Reader> Iterator for RegisterRuleIter<'iter, R> { /// A row in the virtual unwind table that describes how to find the values of /// the registers in the *previous* frame for a range of PC addresses. #[derive(PartialEq, Eq)] -pub struct UnwindTableRow< - R: Reader, - #[cfg(not(feature = "read"))] S: UnwindContextStorage, - #[cfg(feature = "read")] S: UnwindContextStorage = StoreOnHeap, -> { +pub struct UnwindTableRow = StoreOnHeap> { start_address: u64, end_address: u64, saved_args_size: u64, diff --git a/src/read/op.rs b/src/read/op.rs index 5665d08d..2ca6247b 100644 --- a/src/read/op.rs +++ b/src/read/op.rs @@ -7,9 +7,7 @@ use core::mem; use super::util::{ArrayLike, ArrayVec}; use crate::common::{DebugAddrIndex, DebugInfoOffset, Encoding, Register}; use crate::constants; -#[cfg(feature = "read")] -use crate::read::StoreOnHeap; -use crate::read::{Error, Reader, ReaderOffset, Result, UnitOffset, Value, ValueType}; +use crate::read::{Error, Reader, ReaderOffset, Result, StoreOnHeap, UnitOffset, Value, ValueType}; /// A reference to a DIE, either relative to the current CU or /// relative to the section. @@ -1092,11 +1090,7 @@ impl EvaluationStorage for StoreOnHeap { /// println!("{:?}", result); /// ``` #[derive(Debug)] -pub struct Evaluation< - R: Reader, - #[cfg(not(feature = "read"))] S: EvaluationStorage, - #[cfg(feature = "read")] S: EvaluationStorage = StoreOnHeap, -> { +pub struct Evaluation = StoreOnHeap> { bytecode: R, encoding: Encoding, object_address: Option,