Skip to content

Commit

Permalink
Remove unused enum variants
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Wieczorek committed Sep 24, 2014
1 parent 3530e4a commit 5bcc154
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 99 deletions.
55 changes: 9 additions & 46 deletions src/libcore/fmt/float.rs
Expand Up @@ -28,21 +28,12 @@ pub enum ExponentFormat {
/// Use exponential notation with the exponent having a base of 10 and the
/// exponent sign being `e` or `E`. For example, 1000 would be printed
/// 1e3.
ExpDec,
/// Use exponential notation with the exponent having a base of 2 and the
/// exponent sign being `p` or `P`. For example, 8 would be printed 1p3.
ExpBin,
ExpDec
}

/// The number of digits used for emitting the fractional part of a number, if
/// any.
pub enum SignificantDigits {
/// All calculable digits will be printed.
///
/// Note that bignums or fractions may cause a surprisingly large number
/// of digits to be printed.
DigAll,

/// At most the given number of digits will be printed, truncating any
/// trailing zeroes.
DigMax(uint),
Expand All @@ -53,17 +44,11 @@ pub enum SignificantDigits {

/// How to emit the sign of a number.
pub enum SignFormat {
/// No sign will be printed. The exponent sign will also be emitted.
SignNone,
/// `-` will be printed for negative values, but no sign will be emitted
/// for positive numbers.
SignNeg,
/// `+` will be printed for positive values, and `-` will be printed for
/// negative values.
SignAll,
SignNeg
}

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

/**
Expand Down Expand Up @@ -111,9 +96,6 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
ExpDec if radix >= DIGIT_E_RADIX // decimal exponent 'e'
=> fail!("float_to_str_bytes_common: radix {} incompatible with \
use of 'e' as decimal exponent", radix),
ExpBin if radix >= DIGIT_P_RADIX // binary exponent 'p'
=> fail!("float_to_str_bytes_common: radix {} incompatible with \
use of 'p' as binary exponent", radix),
_ => ()
}

Expand All @@ -123,16 +105,10 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
match num.classify() {
FPNaN => return f("NaN".as_bytes()),
FPInfinite if num > _0 => {
return match sign {
SignAll => return f("+inf".as_bytes()),
_ => return f("inf".as_bytes()),
};
return f("inf".as_bytes());
}
FPInfinite if num < _0 => {
return match sign {
SignNone => return f("inf".as_bytes()),
_ => return f("-inf".as_bytes()),
};
return f("-inf".as_bytes());
}
_ => {}
}
Expand All @@ -147,11 +123,10 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(

let (num, exp) = match exp_format {
ExpNone => (num, 0i32),
ExpDec | ExpBin if num == _0 => (num, 0i32),
ExpDec | ExpBin => {
ExpDec if num == _0 => (num, 0i32),
ExpDec => {
let (exp, exp_base) = match exp_format {
ExpDec => (num.abs().log10().floor(), cast::<f64, T>(10.0f64).unwrap()),
ExpBin => (num.abs().log2().floor(), cast::<f64, T>(2.0f64).unwrap()),
ExpNone => fail!("unreachable"),
};

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

// If limited digits, calculate one digit more for rounding.
let (limit_digits, digit_count, exact) = match digits {
DigAll => (false, 0u, false),
DigMax(count) => (true, count+1, false),
DigExact(count) => (true, count+1, true)
DigMax(count) => (true, count + 1, false),
DigExact(count) => (true, count + 1, true)
};

// Decide what sign to put in front
match sign {
SignNeg | SignAll if neg => {
SignNeg if neg => {
buf[end] = b'-';
end += 1;
}
SignAll => {
buf[end] = b'+';
end += 1;
}
_ => ()
}

Expand Down Expand Up @@ -329,8 +299,6 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
buf[end] = match exp_format {
ExpDec if exp_upper => 'E',
ExpDec if !exp_upper => 'e',
ExpBin if exp_upper => 'P',
ExpBin if !exp_upper => 'p',
_ => fail!("unreachable"),
} as u8;
end += 1;
Expand All @@ -356,11 +324,6 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
fmt::write(&mut filler, args)
}, "{:-}", exp);
}
SignNone | SignAll => {
let _ = format_args!(|args| {
fmt::write(&mut filler, args)
}, "{}", exp);
}
}
}
}
Expand Down
26 changes: 6 additions & 20 deletions src/librustc/lint/builtin.rs
Expand Up @@ -1269,11 +1269,6 @@ impl LintPass for UnusedMut {
}
}

enum Allocation {
VectorAllocation,
BoxAllocation
}

declare_lint!(UNNECESSARY_ALLOCATION, Warn,
"detects unnecessary allocations that can be eliminated")

Expand All @@ -1285,30 +1280,21 @@ impl LintPass for UnnecessaryAllocation {
}

fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
// Warn if boxing expressions are immediately borrowed.
let allocation = match e.node {
ast::ExprUnary(ast::UnUniq, _) |
ast::ExprUnary(ast::UnBox, _) => BoxAllocation,

match e.node {
ast::ExprUnary(ast::UnUniq, _) | ast::ExprUnary(ast::UnBox, _) => (),
_ => return
};
}

match cx.tcx.adjustments.borrow().find(&e.id) {
Some(adjustment) => {
match *adjustment {
ty::AdjustDerefRef(ty::AutoDerefRef { ref autoref, .. }) => {
match (allocation, autoref) {
(VectorAllocation, &Some(ty::AutoPtr(_, _, None))) => {
cx.span_lint(UNNECESSARY_ALLOCATION, e.span,
"unnecessary allocation, the sigil can be removed");
}
(BoxAllocation,
&Some(ty::AutoPtr(_, ast::MutImmutable, None))) => {
match autoref {
&Some(ty::AutoPtr(_, ast::MutImmutable, None)) => {
cx.span_lint(UNNECESSARY_ALLOCATION, e.span,
"unnecessary allocation, use & instead");
}
(BoxAllocation,
&Some(ty::AutoPtr(_, ast::MutMutable, None))) => {
&Some(ty::AutoPtr(_, ast::MutMutable, None)) => {
cx.span_lint(UNNECESSARY_ALLOCATION, e.span,
"unnecessary allocation, use &mut instead");
}
Expand Down
6 changes: 0 additions & 6 deletions src/librustc/middle/borrowck/mod.rs
Expand Up @@ -243,12 +243,6 @@ struct BorrowStats {

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

#[deriving(PartialEq)]
pub enum PartialTotal {
Partial, // Loan affects some portion
Total // Loan affects entire path
}

///////////////////////////////////////////////////////////////////////////
// Loans and loan paths

Expand Down
4 changes: 0 additions & 4 deletions src/librustc/middle/resolve.rs
Expand Up @@ -488,7 +488,6 @@ enum ParentLink {
#[deriving(PartialEq)]
enum ModuleKind {
NormalModuleKind,
ExternModuleKind,
TraitModuleKind,
ImplModuleKind,
AnonymousModuleKind,
Expand Down Expand Up @@ -3348,7 +3347,6 @@ impl<'a> Resolver<'a> {
parents");
return Failed(None);
}
ExternModuleKind |
TraitModuleKind |
ImplModuleKind |
AnonymousModuleKind => {
Expand Down Expand Up @@ -3446,7 +3444,6 @@ impl<'a> Resolver<'a> {
let new_module = new_module.upgrade().unwrap();
match new_module.kind.get() {
NormalModuleKind => return Some(new_module),
ExternModuleKind |
TraitModuleKind |
ImplModuleKind |
AnonymousModuleKind => module_ = new_module,
Expand All @@ -3462,7 +3459,6 @@ impl<'a> Resolver<'a> {
-> Rc<Module> {
match module_.kind.get() {
NormalModuleKind => return module_,
ExternModuleKind |
TraitModuleKind |
ImplModuleKind |
AnonymousModuleKind => {
Expand Down
7 changes: 0 additions & 7 deletions src/librustc/middle/typeck/check/writeback.rs
Expand Up @@ -361,7 +361,6 @@ enum ResolveReason {
ResolvingLocal(Span),
ResolvingPattern(Span),
ResolvingUpvar(ty::UpvarId),
ResolvingImplRes(Span),
ResolvingUnboxedClosure(ast::DefId),
}

Expand All @@ -374,7 +373,6 @@ impl ResolveReason {
ResolvingUpvar(upvar_id) => {
ty::expr_span(tcx, upvar_id.closure_expr_id)
}
ResolvingImplRes(s) => s,
ResolvingUnboxedClosure(did) => {
if did.krate == ast::LOCAL_CRATE {
ty::expr_span(tcx, did.node)
Expand Down Expand Up @@ -462,11 +460,6 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
infer::fixup_err_to_string(e));
}

ResolvingImplRes(span) => {
span_err!(self.tcx.sess, span, E0105,
"cannot determine a type for impl supertrait");
}

ResolvingUnboxedClosure(_) => {
let span = self.reason.span(self.tcx);
self.tcx.sess.span_err(span,
Expand Down
9 changes: 1 addition & 8 deletions src/librustc/middle/typeck/infer/mod.rs
Expand Up @@ -271,9 +271,7 @@ pub enum RegionVariableOrigin {
pub enum fixup_err {
unresolved_int_ty(IntVid),
unresolved_float_ty(FloatVid),
unresolved_ty(TyVid),
unresolved_region(RegionVid),
region_var_bound_by_region_var(RegionVid, RegionVid)
unresolved_ty(TyVid)
}

pub fn fixup_err_to_string(f: fixup_err) -> String {
Expand All @@ -287,11 +285,6 @@ pub fn fixup_err_to_string(f: fixup_err) -> String {
the type explicitly".to_string()
}
unresolved_ty(_) => "unconstrained type".to_string(),
unresolved_region(_) => "unconstrained region".to_string(),
region_var_bound_by_region_var(r1, r2) => {
format!("region var {:?} bound by another region var {:?}; \
this is a bug in rustc", r1, r2)
}
}
}

Expand Down
9 changes: 1 addition & 8 deletions src/libsyntax/ext/format.rs
Expand Up @@ -24,8 +24,7 @@ use std::string;
#[deriving(PartialEq)]
enum ArgumentType {
Known(string::String),
Unsigned,
String,
Unsigned
}

enum Position {
Expand Down Expand Up @@ -691,12 +690,6 @@ impl<'a, 'b> Context<'a, 'b> {
}
}
}
String => {
return ecx.expr_call_global(sp, vec![
ecx.ident_of("std"),
ecx.ident_of("fmt"),
ecx.ident_of("argumentstr")], vec![arg])
}
Unsigned => {
return ecx.expr_call_global(sp, vec![
ecx.ident_of("std"),
Expand Down

0 comments on commit 5bcc154

Please sign in to comment.