Skip to content

Commit 5bcc154

Browse files
author
Jakub Wieczorek
committed
Remove unused enum variants
1 parent 3530e4a commit 5bcc154

File tree

7 files changed

+17
-99
lines changed

7 files changed

+17
-99
lines changed

src/libcore/fmt/float.rs

+9-46
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,12 @@ pub enum ExponentFormat {
2828
/// Use exponential notation with the exponent having a base of 10 and the
2929
/// exponent sign being `e` or `E`. For example, 1000 would be printed
3030
/// 1e3.
31-
ExpDec,
32-
/// Use exponential notation with the exponent having a base of 2 and the
33-
/// exponent sign being `p` or `P`. For example, 8 would be printed 1p3.
34-
ExpBin,
31+
ExpDec
3532
}
3633

3734
/// The number of digits used for emitting the fractional part of a number, if
3835
/// any.
3936
pub enum SignificantDigits {
40-
/// All calculable digits will be printed.
41-
///
42-
/// Note that bignums or fractions may cause a surprisingly large number
43-
/// of digits to be printed.
44-
DigAll,
45-
4637
/// At most the given number of digits will be printed, truncating any
4738
/// trailing zeroes.
4839
DigMax(uint),
@@ -53,17 +44,11 @@ pub enum SignificantDigits {
5344

5445
/// How to emit the sign of a number.
5546
pub enum SignFormat {
56-
/// No sign will be printed. The exponent sign will also be emitted.
57-
SignNone,
5847
/// `-` will be printed for negative values, but no sign will be emitted
5948
/// for positive numbers.
60-
SignNeg,
61-
/// `+` will be printed for positive values, and `-` will be printed for
62-
/// negative values.
63-
SignAll,
49+
SignNeg
6450
}
6551

66-
static DIGIT_P_RADIX: uint = ('p' as uint) - ('a' as uint) + 11u;
6752
static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u;
6853

6954
/**
@@ -111,9 +96,6 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
11196
ExpDec if radix >= DIGIT_E_RADIX // decimal exponent 'e'
11297
=> fail!("float_to_str_bytes_common: radix {} incompatible with \
11398
use of 'e' as decimal exponent", radix),
114-
ExpBin if radix >= DIGIT_P_RADIX // binary exponent 'p'
115-
=> fail!("float_to_str_bytes_common: radix {} incompatible with \
116-
use of 'p' as binary exponent", radix),
11799
_ => ()
118100
}
119101

@@ -123,16 +105,10 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
123105
match num.classify() {
124106
FPNaN => return f("NaN".as_bytes()),
125107
FPInfinite if num > _0 => {
126-
return match sign {
127-
SignAll => return f("+inf".as_bytes()),
128-
_ => return f("inf".as_bytes()),
129-
};
108+
return f("inf".as_bytes());
130109
}
131110
FPInfinite if num < _0 => {
132-
return match sign {
133-
SignNone => return f("inf".as_bytes()),
134-
_ => return f("-inf".as_bytes()),
135-
};
111+
return f("-inf".as_bytes());
136112
}
137113
_ => {}
138114
}
@@ -147,11 +123,10 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
147123

148124
let (num, exp) = match exp_format {
149125
ExpNone => (num, 0i32),
150-
ExpDec | ExpBin if num == _0 => (num, 0i32),
151-
ExpDec | ExpBin => {
126+
ExpDec if num == _0 => (num, 0i32),
127+
ExpDec => {
152128
let (exp, exp_base) = match exp_format {
153129
ExpDec => (num.abs().log10().floor(), cast::<f64, T>(10.0f64).unwrap()),
154-
ExpBin => (num.abs().log2().floor(), cast::<f64, T>(2.0f64).unwrap()),
155130
ExpNone => fail!("unreachable"),
156131
};
157132

@@ -185,21 +160,16 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
185160

186161
// If limited digits, calculate one digit more for rounding.
187162
let (limit_digits, digit_count, exact) = match digits {
188-
DigAll => (false, 0u, false),
189-
DigMax(count) => (true, count+1, false),
190-
DigExact(count) => (true, count+1, true)
163+
DigMax(count) => (true, count + 1, false),
164+
DigExact(count) => (true, count + 1, true)
191165
};
192166

193167
// Decide what sign to put in front
194168
match sign {
195-
SignNeg | SignAll if neg => {
169+
SignNeg if neg => {
196170
buf[end] = b'-';
197171
end += 1;
198172
}
199-
SignAll => {
200-
buf[end] = b'+';
201-
end += 1;
202-
}
203173
_ => ()
204174
}
205175

@@ -329,8 +299,6 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
329299
buf[end] = match exp_format {
330300
ExpDec if exp_upper => 'E',
331301
ExpDec if !exp_upper => 'e',
332-
ExpBin if exp_upper => 'P',
333-
ExpBin if !exp_upper => 'p',
334302
_ => fail!("unreachable"),
335303
} as u8;
336304
end += 1;
@@ -356,11 +324,6 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
356324
fmt::write(&mut filler, args)
357325
}, "{:-}", exp);
358326
}
359-
SignNone | SignAll => {
360-
let _ = format_args!(|args| {
361-
fmt::write(&mut filler, args)
362-
}, "{}", exp);
363-
}
364327
}
365328
}
366329
}

src/librustc/lint/builtin.rs

+6-20
Original file line numberDiff line numberDiff line change
@@ -1269,11 +1269,6 @@ impl LintPass for UnusedMut {
12691269
}
12701270
}
12711271

1272-
enum Allocation {
1273-
VectorAllocation,
1274-
BoxAllocation
1275-
}
1276-
12771272
declare_lint!(UNNECESSARY_ALLOCATION, Warn,
12781273
"detects unnecessary allocations that can be eliminated")
12791274

@@ -1285,30 +1280,21 @@ impl LintPass for UnnecessaryAllocation {
12851280
}
12861281

12871282
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
1288-
// Warn if boxing expressions are immediately borrowed.
1289-
let allocation = match e.node {
1290-
ast::ExprUnary(ast::UnUniq, _) |
1291-
ast::ExprUnary(ast::UnBox, _) => BoxAllocation,
1292-
1283+
match e.node {
1284+
ast::ExprUnary(ast::UnUniq, _) | ast::ExprUnary(ast::UnBox, _) => (),
12931285
_ => return
1294-
};
1286+
}
12951287

12961288
match cx.tcx.adjustments.borrow().find(&e.id) {
12971289
Some(adjustment) => {
12981290
match *adjustment {
12991291
ty::AdjustDerefRef(ty::AutoDerefRef { ref autoref, .. }) => {
1300-
match (allocation, autoref) {
1301-
(VectorAllocation, &Some(ty::AutoPtr(_, _, None))) => {
1302-
cx.span_lint(UNNECESSARY_ALLOCATION, e.span,
1303-
"unnecessary allocation, the sigil can be removed");
1304-
}
1305-
(BoxAllocation,
1306-
&Some(ty::AutoPtr(_, ast::MutImmutable, None))) => {
1292+
match autoref {
1293+
&Some(ty::AutoPtr(_, ast::MutImmutable, None)) => {
13071294
cx.span_lint(UNNECESSARY_ALLOCATION, e.span,
13081295
"unnecessary allocation, use & instead");
13091296
}
1310-
(BoxAllocation,
1311-
&Some(ty::AutoPtr(_, ast::MutMutable, None))) => {
1297+
&Some(ty::AutoPtr(_, ast::MutMutable, None)) => {
13121298
cx.span_lint(UNNECESSARY_ALLOCATION, e.span,
13131299
"unnecessary allocation, use &mut instead");
13141300
}

src/librustc/middle/borrowck/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,6 @@ struct BorrowStats {
243243

244244
pub type BckResult<T> = Result<T, BckError>;
245245

246-
#[deriving(PartialEq)]
247-
pub enum PartialTotal {
248-
Partial, // Loan affects some portion
249-
Total // Loan affects entire path
250-
}
251-
252246
///////////////////////////////////////////////////////////////////////////
253247
// Loans and loan paths
254248

src/librustc/middle/resolve.rs

-4
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,6 @@ enum ParentLink {
488488
#[deriving(PartialEq)]
489489
enum ModuleKind {
490490
NormalModuleKind,
491-
ExternModuleKind,
492491
TraitModuleKind,
493492
ImplModuleKind,
494493
AnonymousModuleKind,
@@ -3348,7 +3347,6 @@ impl<'a> Resolver<'a> {
33483347
parents");
33493348
return Failed(None);
33503349
}
3351-
ExternModuleKind |
33523350
TraitModuleKind |
33533351
ImplModuleKind |
33543352
AnonymousModuleKind => {
@@ -3446,7 +3444,6 @@ impl<'a> Resolver<'a> {
34463444
let new_module = new_module.upgrade().unwrap();
34473445
match new_module.kind.get() {
34483446
NormalModuleKind => return Some(new_module),
3449-
ExternModuleKind |
34503447
TraitModuleKind |
34513448
ImplModuleKind |
34523449
AnonymousModuleKind => module_ = new_module,
@@ -3462,7 +3459,6 @@ impl<'a> Resolver<'a> {
34623459
-> Rc<Module> {
34633460
match module_.kind.get() {
34643461
NormalModuleKind => return module_,
3465-
ExternModuleKind |
34663462
TraitModuleKind |
34673463
ImplModuleKind |
34683464
AnonymousModuleKind => {

src/librustc/middle/typeck/check/writeback.rs

-7
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ enum ResolveReason {
361361
ResolvingLocal(Span),
362362
ResolvingPattern(Span),
363363
ResolvingUpvar(ty::UpvarId),
364-
ResolvingImplRes(Span),
365364
ResolvingUnboxedClosure(ast::DefId),
366365
}
367366

@@ -374,7 +373,6 @@ impl ResolveReason {
374373
ResolvingUpvar(upvar_id) => {
375374
ty::expr_span(tcx, upvar_id.closure_expr_id)
376375
}
377-
ResolvingImplRes(s) => s,
378376
ResolvingUnboxedClosure(did) => {
379377
if did.krate == ast::LOCAL_CRATE {
380378
ty::expr_span(tcx, did.node)
@@ -462,11 +460,6 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
462460
infer::fixup_err_to_string(e));
463461
}
464462

465-
ResolvingImplRes(span) => {
466-
span_err!(self.tcx.sess, span, E0105,
467-
"cannot determine a type for impl supertrait");
468-
}
469-
470463
ResolvingUnboxedClosure(_) => {
471464
let span = self.reason.span(self.tcx);
472465
self.tcx.sess.span_err(span,

src/librustc/middle/typeck/infer/mod.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,7 @@ pub enum RegionVariableOrigin {
271271
pub enum fixup_err {
272272
unresolved_int_ty(IntVid),
273273
unresolved_float_ty(FloatVid),
274-
unresolved_ty(TyVid),
275-
unresolved_region(RegionVid),
276-
region_var_bound_by_region_var(RegionVid, RegionVid)
274+
unresolved_ty(TyVid)
277275
}
278276

279277
pub fn fixup_err_to_string(f: fixup_err) -> String {
@@ -287,11 +285,6 @@ pub fn fixup_err_to_string(f: fixup_err) -> String {
287285
the type explicitly".to_string()
288286
}
289287
unresolved_ty(_) => "unconstrained type".to_string(),
290-
unresolved_region(_) => "unconstrained region".to_string(),
291-
region_var_bound_by_region_var(r1, r2) => {
292-
format!("region var {:?} bound by another region var {:?}; \
293-
this is a bug in rustc", r1, r2)
294-
}
295288
}
296289
}
297290

src/libsyntax/ext/format.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ use std::string;
2424
#[deriving(PartialEq)]
2525
enum ArgumentType {
2626
Known(string::String),
27-
Unsigned,
28-
String,
27+
Unsigned
2928
}
3029

3130
enum Position {
@@ -691,12 +690,6 @@ impl<'a, 'b> Context<'a, 'b> {
691690
}
692691
}
693692
}
694-
String => {
695-
return ecx.expr_call_global(sp, vec![
696-
ecx.ident_of("std"),
697-
ecx.ident_of("fmt"),
698-
ecx.ident_of("argumentstr")], vec![arg])
699-
}
700693
Unsigned => {
701694
return ecx.expr_call_global(sp, vec![
702695
ecx.ident_of("std"),

0 commit comments

Comments
 (0)