fix Debug impls

This commit is contained in:
Ariel Ben-Yehuda 2017-09-25 13:47:19 +03:00
parent c10b23e2e0
commit 7bb0923e46

View file

@ -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;
@ -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
@ -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 {
@ -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 {
@ -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]