Skip to content

Commit d27aa96

Browse files
committed
Remove unused Display implementation for consts
1 parent 34812e8 commit d27aa96

File tree

1 file changed

+0
-86
lines changed

1 file changed

+0
-86
lines changed

src/consts.rs

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ use rustc::middle::def::PathResolution;
66
use rustc::middle::def::Def;
77
use rustc_front::hir::*;
88
use syntax::ptr::P;
9-
use std::char;
109
use std::cmp::PartialOrd;
1110
use std::cmp::Ordering::{self, Greater, Less, Equal};
1211
use std::rc::Rc;
1312
use std::ops::Deref;
14-
use std::fmt;
1513

1614
use syntax::ast::Lit_;
1715
use syntax::ast::LitIntType;
@@ -173,90 +171,6 @@ impl PartialOrd for Constant {
173171
}
174172
}
175173

176-
fn format_byte(fmt: &mut fmt::Formatter, b: u8) -> fmt::Result {
177-
if b == b'\\' {
178-
write!(fmt, "\\\\")
179-
} else if 0x20 <= b && b <= 0x7e {
180-
write!(fmt, "{}", char::from_u32(b as u32).expect("all u8 are valid char"))
181-
} else if b == 0x0a {
182-
write!(fmt, "\\n")
183-
} else if b == 0x0d {
184-
write!(fmt, "\\r")
185-
} else {
186-
write!(fmt, "\\x{:02x}", b)
187-
}
188-
}
189-
190-
impl fmt::Display for Constant {
191-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
192-
match *self {
193-
Constant::Str(ref s, _) => write!(fmt, "{:?}", s),
194-
Constant::Byte(ref b) => {
195-
write!(fmt, "b'")
196-
.and_then(|_| format_byte(fmt, *b))
197-
.and_then(|_| write!(fmt, "'"))
198-
}
199-
Constant::Binary(ref bs) => {
200-
try!(write!(fmt, "b\""));
201-
for b in bs.iter() {
202-
try!(format_byte(fmt, *b));
203-
}
204-
write!(fmt, "\"")
205-
}
206-
Constant::Char(ref c) => write!(fmt, "'{}'", c),
207-
Constant::Int(ref i, ref ity) => {
208-
let (sign, suffix) = match *ity {
209-
LitIntType::SignedIntLit(ref sity, ref sign) => {
210-
(if let Sign::Minus = *sign {
211-
"-"
212-
} else {
213-
""
214-
},
215-
sity.ty_to_string())
216-
}
217-
LitIntType::UnsignedIntLit(ref uity) => ("", uity.ty_to_string()),
218-
LitIntType::UnsuffixedIntLit(ref sign) => {
219-
(if let Sign::Minus = *sign {
220-
"-"
221-
} else {
222-
""
223-
},
224-
"".into())
225-
}
226-
};
227-
write!(fmt, "{}{}{}", sign, i, suffix)
228-
}
229-
Constant::Float(ref s, ref fw) => {
230-
let suffix = match *fw {
231-
FloatWidth::Fw32 => "f32",
232-
FloatWidth::Fw64 => "f64",
233-
FloatWidth::FwAny => "",
234-
};
235-
write!(fmt, "{}{}", s, suffix)
236-
}
237-
Constant::Bool(ref b) => write!(fmt, "{}", b),
238-
Constant::Repeat(ref c, ref n) => write!(fmt, "[{}; {}]", c, n),
239-
Constant::Vec(ref v) => {
240-
write!(fmt,
241-
"[{}]",
242-
v.iter()
243-
.map(|i| format!("{}", i))
244-
.collect::<Vec<_>>()
245-
.join(", "))
246-
}
247-
Constant::Tuple(ref t) => {
248-
write!(fmt,
249-
"({})",
250-
t.iter()
251-
.map(|i| format!("{}", i))
252-
.collect::<Vec<_>>()
253-
.join(", "))
254-
}
255-
}
256-
}
257-
}
258-
259-
260174
fn lit_to_constant(lit: &Lit_) -> Constant {
261175
match *lit {
262176
Lit_::LitStr(ref is, style) => Constant::Str(is.to_string(), style),

0 commit comments

Comments
 (0)