Skip to content

Commit bbdc714

Browse files
gabrielesveltomstange
authored andcommitted
Switch to bitflags 2.x
1 parent 65a0ce3 commit bbdc714

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repository = "https://github.com/mstange/msvc-demangler-rust"
1010
readme = "README.md"
1111

1212
[dependencies]
13-
bitflags = "1.0.1"
13+
bitflags = "2"
1414

1515
[[bin]]
1616
name = "undname"

src/lib.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ impl fmt::Display for Error {
142142
type Result<T> = result::Result<T, Error>;
143143

144144
bitflags! {
145+
#[derive(Clone, Copy, Debug, PartialEq)]
145146
pub struct StorageClass: u32 {
146147
const CONST = 0b0_0000_0001;
147148
const VOLATILE = 0b0_0000_0010;
@@ -156,6 +157,7 @@ bitflags! {
156157
}
157158

158159
bitflags! {
160+
#[derive(Clone, Copy)]
159161
pub struct DemangleFlags: u32 {
160162
/// Undecorate 32-bit decorated names.
161163
const DECODE_32_BIT = 0x0800;
@@ -190,7 +192,7 @@ bitflags! {
190192
// /// Do not undecorate special names, such as vtable, vcall, vector, metatype, and so on.
191193
// const NO_SPECIAL_SYMS = 0x4000;
192194
/// Disable all modifiers on the this type.
193-
const NO_THISTYPE = Self::NO_MS_THISTYPE.bits | Self::NO_CV_THISTYPE.bits;
195+
const NO_THISTYPE = Self::NO_MS_THISTYPE.bits() | Self::NO_CV_THISTYPE.bits();
194196
// /// Disable expansion of throw-signatures for functions and pointers to functions.
195197
// const NO_THROW_SIGNATURES = 0x0100;
196198
/// Disable output of struct/union/class/enum specifiers.
@@ -230,6 +232,7 @@ pub enum CallingConv {
230232
}
231233

232234
bitflags! {
235+
#[derive(Clone, Debug, PartialEq)]
233236
pub struct FuncClass: u32 {
234237
const PUBLIC = 0b0000_0001;
235238
const PROTECTED = 0b0000_0010;
@@ -1601,7 +1604,7 @@ impl<'a> Serializer<'a> {
16011604
Ok(())
16021605
}
16031606

1604-
fn write_calling_conv(&mut self, calling_conv: CallingConv) -> Result<()> {
1607+
fn write_calling_conv(&mut self, calling_conv: &CallingConv) -> Result<()> {
16051608
match self.w.last() {
16061609
Some(b' ') | Some(b'(') => {}
16071610
_ => write!(self.w, " ")?,
@@ -1634,7 +1637,7 @@ impl<'a> Serializer<'a> {
16341637

16351638
// Write the "first half" of a given type.
16361639
fn write_pre(&mut self, t: &Type) -> Result<()> {
1637-
let storage_class = match *t {
1640+
let storage_class = match t {
16381641
Type::None => return Ok(()),
16391642
Type::MemberFunction(func_class, calling_conv, _, _, ref inner) => {
16401643
if func_class.contains(FuncClass::THUNK) {
@@ -1724,7 +1727,7 @@ impl<'a> Serializer<'a> {
17241727
self.write_pre(inner)?;
17251728
self.write_space()?;
17261729
write!(self.w, "(")?;
1727-
self.write_calling_conv(calling_conv)?;
1730+
self.write_calling_conv(&calling_conv)?;
17281731
}
17291732
Type::Array(_, _, _) => {
17301733
self.write_pre(inner)?;
@@ -1736,7 +1739,7 @@ impl<'a> Serializer<'a> {
17361739
}
17371740
}
17381741

1739-
match *t {
1742+
match t {
17401743
Type::Ptr(_, _) => {
17411744
if !self.flags.contains(DemangleFlags::HUG_TYPE) {
17421745
self.write_space()?;

0 commit comments

Comments
 (0)