Skip to content

Commit 4d69696

Browse files
committed
auto merge of #17410 : jakub-/rust/dead-code, r=alexcrichton
2 parents e0bd16c + fd52224 commit 4d69696

32 files changed

+184
-710
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/back/link.rs

-7
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,6 @@ pub fn get_cc_prog(sess: &Session) -> String {
397397
}.to_string()
398398
}
399399

400-
pub fn get_ar_prog(sess: &Session) -> String {
401-
match sess.opts.cg.ar {
402-
Some(ref ar) => (*ar).clone(),
403-
None => "ar".to_string()
404-
}
405-
}
406-
407400
pub fn remove(sess: &Session, path: &Path) {
408401
match fs::unlink(path) {
409402
Ok(..) => {}

src/librustc/diagnostics.rs

-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ register_diagnostics!(
114114
E0102,
115115
E0103,
116116
E0104,
117-
E0105,
118117
E0106,
119118
E0107,
120119
E0108,
@@ -152,7 +151,6 @@ register_diagnostics!(
152151
E0144,
153152
E0145,
154153
E0146,
155-
E0147,
156154
E0148,
157155
E0151,
158156
E0152,

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/astencode.rs

-73
Original file line numberDiff line numberDiff line change
@@ -662,30 +662,6 @@ impl tr for MethodOrigin {
662662
}
663663
}
664664

665-
// ______________________________________________________________________
666-
// Encoding and decoding vtable_res
667-
668-
pub fn encode_vtable_res(ecx: &e::EncodeContext,
669-
rbml_w: &mut Encoder,
670-
dr: &typeck::vtable_res) {
671-
// can't autogenerate this code because automatic code of
672-
// ty::t doesn't work, and there is no way (atm) to have
673-
// hand-written encoding routines combine with auto-generated
674-
// ones. perhaps we should fix this.
675-
encode_vec_per_param_space(
676-
rbml_w, dr,
677-
|rbml_w, param_tables| encode_vtable_param_res(ecx, rbml_w,
678-
param_tables))
679-
}
680-
681-
pub fn encode_vtable_param_res(ecx: &e::EncodeContext,
682-
rbml_w: &mut Encoder,
683-
param_tables: &typeck::vtable_param_res) {
684-
rbml_w.emit_from_vec(param_tables.as_slice(), |rbml_w, vtable_origin| {
685-
Ok(encode_vtable_origin(ecx, rbml_w, vtable_origin))
686-
}).unwrap()
687-
}
688-
689665
pub fn encode_unboxed_closure_kind(ebml_w: &mut Encoder,
690666
kind: ty::UnboxedClosureKind) {
691667
use serialize::Encoder;
@@ -714,55 +690,6 @@ pub fn encode_unboxed_closure_kind(ebml_w: &mut Encoder,
714690
}).unwrap()
715691
}
716692

717-
pub fn encode_vtable_origin(ecx: &e::EncodeContext,
718-
rbml_w: &mut Encoder,
719-
vtable_origin: &typeck::vtable_origin) {
720-
use serialize::Encoder;
721-
722-
rbml_w.emit_enum("vtable_origin", |rbml_w| {
723-
match *vtable_origin {
724-
typeck::vtable_static(def_id, ref substs, ref vtable_res) => {
725-
rbml_w.emit_enum_variant("vtable_static", 0u, 3u, |rbml_w| {
726-
rbml_w.emit_enum_variant_arg(0u, |rbml_w| {
727-
Ok(rbml_w.emit_def_id(def_id))
728-
});
729-
rbml_w.emit_enum_variant_arg(1u, |rbml_w| {
730-
Ok(rbml_w.emit_substs(ecx, substs))
731-
});
732-
rbml_w.emit_enum_variant_arg(2u, |rbml_w| {
733-
Ok(encode_vtable_res(ecx, rbml_w, vtable_res))
734-
})
735-
})
736-
}
737-
typeck::vtable_param(pn, bn) => {
738-
rbml_w.emit_enum_variant("vtable_param", 1u, 3u, |rbml_w| {
739-
rbml_w.emit_enum_variant_arg(0u, |rbml_w| {
740-
pn.encode(rbml_w)
741-
});
742-
rbml_w.emit_enum_variant_arg(1u, |rbml_w| {
743-
rbml_w.emit_uint(bn)
744-
})
745-
})
746-
}
747-
typeck::vtable_unboxed_closure(def_id) => {
748-
rbml_w.emit_enum_variant("vtable_unboxed_closure",
749-
2u,
750-
1u,
751-
|rbml_w| {
752-
rbml_w.emit_enum_variant_arg(0u, |rbml_w| {
753-
Ok(rbml_w.emit_def_id(def_id))
754-
})
755-
})
756-
}
757-
typeck::vtable_error => {
758-
rbml_w.emit_enum_variant("vtable_error", 3u, 3u, |_rbml_w| {
759-
Ok(())
760-
})
761-
}
762-
}
763-
}).unwrap()
764-
}
765-
766693
pub trait vtable_decoder_helpers {
767694
fn read_vec_per_param_space<T>(&mut self,
768695
f: |&mut Self| -> T)

0 commit comments

Comments
 (0)