Skip to content

Commit

Permalink
Use a not working type param default instead of cfg-gating
Browse files Browse the repository at this point in the history
cfg-gating type params only work in Rust 1.48+
  • Loading branch information
nbdd0121 committed Oct 13, 2021
1 parent f270f9c commit 93b7a39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 33 deletions.
32 changes: 7 additions & 25 deletions src/read/cfi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1822,11 +1822,7 @@ impl<R: Reader> UnwindContextStorage<R> for StoreOnHeap {
/// # }
/// ```
#[derive(Clone, PartialEq, Eq)]
pub struct UnwindContext<
R: Reader,
#[cfg(not(feature = "read"))] A: UnwindContextStorage<R>,
#[cfg(feature = "read")] A: UnwindContextStorage<R> = StoreOnHeap,
> {
pub struct UnwindContext<R: Reader, A: UnwindContextStorage<R> = 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.
Expand Down Expand Up @@ -2049,13 +2045,7 @@ impl<R: Reader, A: UnwindContextStorage<R>> UnwindContext<R, A> {
/// > 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<R>,
#[cfg(feature = "read")] A: UnwindContextStorage<R> = StoreOnHeap,
> {
pub struct UnwindTable<'a, 'ctx, R: Reader, A: UnwindContextStorage<R> = StoreOnHeap> {
code_alignment_factor: Wrapping<u64>,
data_alignment_factor: Wrapping<i64>,
next_start_address: u64,
Expand Down Expand Up @@ -2366,11 +2356,7 @@ impl<'a, 'ctx, R: Reader, A: UnwindContextStorage<R>> 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<R>,
#[cfg(feature = "read")] S: UnwindContextStorage<R> = StoreOnHeap,
> {
struct RegisterRuleMap<R: Reader, S: UnwindContextStorage<R> = StoreOnHeap> {
rules: ArrayVec<S::Rules>,
}

Expand Down Expand Up @@ -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<R>,
#[cfg(feature = "read")] S: UnwindContextStorage<R> = StoreOnHeap,
> {
pub struct UnwindTableRow<R: Reader, S: UnwindContextStorage<R> = StoreOnHeap> {
start_address: u64,
end_address: u64,
saved_args_size: u64,
Expand Down
10 changes: 2 additions & 8 deletions src/read/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -1092,11 +1090,7 @@ impl<R: Reader> EvaluationStorage<R> for StoreOnHeap {
/// println!("{:?}", result);
/// ```
#[derive(Debug)]
pub struct Evaluation<
R: Reader,
#[cfg(not(feature = "read"))] S: EvaluationStorage<R>,
#[cfg(feature = "read")] S: EvaluationStorage<R> = StoreOnHeap,
> {
pub struct Evaluation<R: Reader, S: EvaluationStorage<R> = StoreOnHeap> {
bytecode: R,
encoding: Encoding,
object_address: Option<u64>,
Expand Down

0 comments on commit 93b7a39

Please sign in to comment.