Skip to content

Commit

Permalink
Merge pull request #105 from CensoredUsername/master
Browse files Browse the repository at this point in the history
Fix the implementation of Formatting traits when other formatting traits were present in scope.
  • Loading branch information
dtolnay committed May 29, 2017
2 parents 8dbf9b9 + 8c99399 commit 8e8569c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,22 +393,22 @@ macro_rules! __impl_bitflags {
}
impl $crate::_core::fmt::Binary for $BitFlags {
fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
self.bits.fmt(f)
$crate::_core::fmt::Binary::fmt(&self.bits, f)
}
}
impl $crate::_core::fmt::Octal for $BitFlags {
fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
self.bits.fmt(f)
$crate::_core::fmt::Octal::fmt(&self.bits, f)
}
}
impl $crate::_core::fmt::LowerHex for $BitFlags {
fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
self.bits.fmt(f)
$crate::_core::fmt::LowerHex::fmt(&self.bits, f)
}
}
impl $crate::_core::fmt::UpperHex for $BitFlags {
fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
self.bits.fmt(f)
$crate::_core::fmt::UpperHex::fmt(&self.bits, f)
}
}

Expand Down
20 changes: 20 additions & 0 deletions tests/conflicting_trait_impls.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#![allow(dead_code)]
#![no_std]

#[macro_use]
extern crate bitflags;

#[allow(unused_imports)]
use core::fmt::Display;

bitflags! {
/// baz
struct Flags: u32 {
const A = 0b00000001;
}
}

#[test]
fn main() {

}

0 comments on commit 8e8569c

Please sign in to comment.