Skip to content

Commit

Permalink
fix Debug impls
Browse files Browse the repository at this point in the history
  • Loading branch information
arielb1 committed Sep 25, 2017
1 parent c10b23e commit 7bb0923
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/librustc/middle/region.rs
Expand Up @@ -18,6 +18,7 @@ use ich::{StableHashingContext, NodeIdHashingMode};
use util::nodemap::{FxHashMap, FxHashSet};
use ty;

use std::fmt;
use std::mem;
use std::rc::Rc;
use syntax::codemap;
Expand Down Expand Up @@ -96,7 +97,11 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher,
/// placate the same deriving in `ty::FreeRegion`, but we may want to
/// actually attach a more meaningful ordering to scopes than the one
/// generated via deriving here.
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Debug, Copy, RustcEncodable, RustcDecodable)]
///
/// Scope is a bit-packed to save space - if `code` is SCOPE_DATA_REMAINDER_MAX
/// or less, it is a `ScopeData::Remainder`, otherwise it is a type specified
/// by the bitpacking.
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Copy, RustcEncodable, RustcDecodable)]
pub struct Scope {
pub(crate) id: hir::ItemLocalId,
pub(crate) code: u32
Expand Down Expand Up @@ -152,7 +157,7 @@ pub struct BlockRemainder {
}

#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, RustcEncodable,
RustcDecodable, Debug, Copy)]
RustcDecodable, Copy)]
pub struct FirstStatementIndex { pub idx: u32 }

impl Idx for FirstStatementIndex {
Expand All @@ -166,6 +171,12 @@ impl Idx for FirstStatementIndex {
}
}

impl fmt::Debug for FirstStatementIndex {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&self.index(), formatter)
}
}

impl From<ScopeData> for Scope {
#[inline]
fn from(scope_data: ScopeData) -> Self {
Expand All @@ -180,6 +191,12 @@ impl From<ScopeData> for Scope {
}
}

impl fmt::Debug for Scope {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&self.data(), formatter)
}
}

#[allow(non_snake_case)]
impl Scope {
#[inline]
Expand Down

0 comments on commit 7bb0923

Please sign in to comment.