Skip to content

Commit f7d86b2

Browse files
author
Jakub Wieczorek
committed
Remove the dead code identified by the new lint
1 parent 0271224 commit f7d86b2

35 files changed

+61
-146
lines changed

src/libglob/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ use std::string::String;
4444
* pattern - see the `glob` function for more details.
4545
*/
4646
pub struct Paths {
47-
root: Path,
4847
dir_patterns: Vec<Pattern>,
4948
require_dir: bool,
5049
options: MatchOptions,
@@ -108,7 +107,6 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Paths {
108107
// FIXME: How do we want to handle verbatim paths? I'm inclined to return nothing,
109108
// since we can't very well find all UNC shares with a 1-letter server name.
110109
return Paths {
111-
root: root,
112110
dir_patterns: Vec::new(),
113111
require_dir: false,
114112
options: options,
@@ -134,7 +132,6 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Paths {
134132
}
135133

136134
Paths {
137-
root: root,
138135
dir_patterns: dir_patterns,
139136
require_dir: require_dir,
140137
options: options,

src/libnative/io/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ fn keep_going(data: &[u8], f: |*u8, uint| -> i64) -> i64 {
152152
/// Implementation of rt::rtio's IoFactory trait to generate handles to the
153153
/// native I/O functionality.
154154
pub struct IoFactory {
155-
cannot_construct_outside_of_this_module: ()
155+
_cannot_construct_outside_of_this_module: ()
156156
}
157157

158158
impl IoFactory {
159159
pub fn new() -> IoFactory {
160160
net::init();
161-
IoFactory { cannot_construct_outside_of_this_module: () }
161+
IoFactory { _cannot_construct_outside_of_this_module: () }
162162
}
163163
}
164164

src/libnative/io/net.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,10 @@ pub struct TcpStream {
254254

255255
struct Inner {
256256
fd: sock_t,
257-
lock: mutex::NativeMutex,
257+
258+
// Unused on Linux, where this lock is not necessary.
259+
#[allow(dead_code)]
260+
lock: mutex::NativeMutex
258261
}
259262

260263
pub struct Guard<'a> {

src/libnative/io/pipe_unix.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ fn addr_to_sockaddr_un(addr: &CString) -> IoResult<(libc::sockaddr_storage, uint
5858

5959
struct Inner {
6060
fd: fd_t,
61-
lock: mutex::NativeMutex,
61+
62+
// Unused on Linux, where this lock is not necessary.
63+
#[allow(dead_code)]
64+
lock: mutex::NativeMutex
6265
}
6366

6467
impl Inner {

src/librand/distributions/gamma.rs

-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ struct GammaSmallShape {
8181
/// See `Gamma` for sampling from a Gamma distribution with general
8282
/// shape parameters.
8383
struct GammaLargeShape {
84-
shape: f64,
8584
scale: f64,
8685
c: f64,
8786
d: f64
@@ -118,7 +117,6 @@ impl GammaLargeShape {
118117
fn new_raw(shape: f64, scale: f64) -> GammaLargeShape {
119118
let d = shape - 1. / 3.;
120119
GammaLargeShape {
121-
shape: shape,
122120
scale: scale,
123121
c: 1. / (9. * d).sqrt(),
124122
d: d

src/librustc/front/std_inject.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ fn inject_crates_ref(sess: &Session, krate: ast::Crate) -> ast::Crate {
130130
fold.fold_crate(krate)
131131
}
132132

133-
struct PreludeInjector<'a> {
134-
sess: &'a Session,
135-
}
133+
struct PreludeInjector<'a>;
136134

137135

138136
impl<'a> fold::Folder for PreludeInjector<'a> {
@@ -223,9 +221,7 @@ impl<'a> fold::Folder for PreludeInjector<'a> {
223221
}
224222
}
225223

226-
fn inject_prelude(sess: &Session, krate: ast::Crate) -> ast::Crate {
227-
let mut fold = PreludeInjector {
228-
sess: sess,
229-
};
224+
fn inject_prelude(_: &Session, krate: ast::Crate) -> ast::Crate {
225+
let mut fold = PreludeInjector;
230226
fold.fold_crate(krate)
231227
}

src/librustc/metadata/loader.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub struct Library {
8686
}
8787

8888
pub struct ArchiveMetadata {
89-
archive: ArchiveRO,
89+
_archive: ArchiveRO,
9090
// See comments in ArchiveMetadata::new for why this is static
9191
data: &'static [u8],
9292
}
@@ -487,7 +487,7 @@ impl ArchiveMetadata {
487487
unsafe { mem::transmute(data) }
488488
};
489489
Some(ArchiveMetadata {
490-
archive: ar,
490+
_archive: ar,
491491
data: data,
492492
})
493493
}

src/librustc/metadata/tyencode.rs

-4
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ pub struct ctxt<'a> {
4242
// Extra parameters are for converting to/from def_ids in the string rep.
4343
// Whatever format you choose should not contain pipe characters.
4444
pub struct ty_abbrev {
45-
pos: uint,
46-
len: uint,
4745
s: String
4846
}
4947

@@ -68,8 +66,6 @@ pub fn enc_ty(w: &mut MemWriter, cx: &ctxt, t: ty::t) {
6866
if abbrev_len < len {
6967
// I.e. it's actually an abbreviation.
7068
cx.abbrevs.borrow_mut().insert(t, ty_abbrev {
71-
pos: pos as uint,
72-
len: len as uint,
7369
s: format!("\\#{:x}:{:x}\\#", pos, len)
7470
});
7571
}

src/librustc/middle/borrowck/gather_loans/lifetime.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn guarantee_lifetime(bccx: &BorrowckCtxt,
2929
cause: euv::LoanCause,
3030
cmt: mc::cmt,
3131
loan_region: ty::Region,
32-
loan_kind: ty::BorrowKind)
32+
_: ty::BorrowKind)
3333
-> Result<(),()> {
3434
debug!("guarantee_lifetime(cmt={}, loan_region={})",
3535
cmt.repr(bccx.tcx), loan_region.repr(bccx.tcx));
@@ -38,7 +38,6 @@ pub fn guarantee_lifetime(bccx: &BorrowckCtxt,
3838
span: span,
3939
cause: cause,
4040
loan_region: loan_region,
41-
loan_kind: loan_kind,
4241
cmt_original: cmt.clone()};
4342
ctxt.check(&cmt, None)
4443
}
@@ -55,7 +54,6 @@ struct GuaranteeLifetimeContext<'a> {
5554
span: Span,
5655
cause: euv::LoanCause,
5756
loan_region: ty::Region,
58-
loan_kind: ty::BorrowKind,
5957
cmt_original: mc::cmt
6058
}
6159

src/librustc/middle/borrowck/gather_loans/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ impl<'a> GatherLoanCtxt<'a> {
310310
Loan {
311311
index: self.all_loans.len(),
312312
loan_path: loan_path,
313-
cmt: cmt,
314313
kind: req_kind,
315314
gen_scope: gen_scope,
316315
kill_scope: kill_scope,
@@ -481,8 +480,7 @@ impl<'a> GatherLoanCtxt<'a> {
481480
/// This visitor walks static initializer's expressions and makes
482481
/// sure the loans being taken are sound.
483482
struct StaticInitializerCtxt<'a> {
484-
bccx: &'a BorrowckCtxt<'a>,
485-
item_ub: ast::NodeId,
483+
bccx: &'a BorrowckCtxt<'a>
486484
}
487485

488486
impl<'a> visit::Visitor<()> for StaticInitializerCtxt<'a> {
@@ -509,8 +507,7 @@ pub fn gather_loans_in_static_initializer(bccx: &mut BorrowckCtxt, expr: &ast::E
509507
debug!("gather_loans_in_static_initializer(expr={})", expr.repr(bccx.tcx));
510508

511509
let mut sicx = StaticInitializerCtxt {
512-
bccx: bccx,
513-
item_ub: expr.id,
510+
bccx: bccx
514511
};
515512

516513
sicx.visit_expr(expr, ());

src/librustc/middle/borrowck/gather_loans/restrictions.rs

-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ pub fn compute_restrictions(bccx: &BorrowckCtxt,
3636
bccx: bccx,
3737
span: span,
3838
cause: cause,
39-
cmt_original: cmt.clone(),
4039
loan_region: loan_region,
4140
};
4241

@@ -49,7 +48,6 @@ pub fn compute_restrictions(bccx: &BorrowckCtxt,
4948
struct RestrictionsContext<'a> {
5049
bccx: &'a BorrowckCtxt<'a>,
5150
span: Span,
52-
cmt_original: mc::cmt,
5351
loan_region: ty::Region,
5452
cause: euv::LoanCause,
5553
}

src/librustc/middle/borrowck/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ pub enum PartialTotal {
180180
pub struct Loan {
181181
index: uint,
182182
loan_path: Rc<LoanPath>,
183-
cmt: mc::cmt,
184183
kind: ty::BorrowKind,
185184
restrictions: Vec<Restriction>,
186185
gen_scope: ast::NodeId,

src/librustc/middle/liveness.rs

+4-44
Original file line numberDiff line numberDiff line change
@@ -225,21 +225,12 @@ fn invalid_node() -> LiveNode { LiveNode(uint::MAX) }
225225

226226
struct CaptureInfo {
227227
ln: LiveNode,
228-
is_move: bool,
229228
var_nid: NodeId
230229
}
231230

232-
enum LocalKind {
233-
FromMatch(BindingMode),
234-
FromLetWithInitializer,
235-
FromLetNoInitializer
236-
}
237-
238231
struct LocalInfo {
239232
id: NodeId,
240-
ident: Ident,
241-
is_mutbl: bool,
242-
kind: LocalKind,
233+
ident: Ident
243234
}
244235

245236
enum VarKind {
@@ -405,23 +396,13 @@ fn visit_fn(ir: &mut IrMaps,
405396
}
406397

407398
fn visit_local(ir: &mut IrMaps, local: &Local) {
408-
pat_util::pat_bindings(&ir.tcx.def_map, local.pat, |bm, p_id, sp, path| {
399+
pat_util::pat_bindings(&ir.tcx.def_map, local.pat, |_, p_id, sp, path| {
409400
debug!("adding local variable {}", p_id);
410401
let name = ast_util::path_to_ident(path);
411402
ir.add_live_node_for_node(p_id, VarDefNode(sp));
412-
let kind = match local.init {
413-
Some(_) => FromLetWithInitializer,
414-
None => FromLetNoInitializer
415-
};
416-
let mutbl = match bm {
417-
BindByValue(MutMutable) => true,
418-
_ => false
419-
};
420403
ir.add_variable(Local(LocalInfo {
421404
id: p_id,
422-
ident: name,
423-
is_mutbl: mutbl,
424-
kind: kind
405+
ident: name
425406
}));
426407
});
427408
visit::walk_local(ir, local, ());
@@ -433,16 +414,10 @@ fn visit_arm(ir: &mut IrMaps, arm: &Arm) {
433414
debug!("adding local variable {} from match with bm {:?}",
434415
p_id, bm);
435416
let name = ast_util::path_to_ident(path);
436-
let mutbl = match bm {
437-
BindByValue(MutMutable) => true,
438-
_ => false
439-
};
440417
ir.add_live_node_for_node(p_id, VarDefNode(sp));
441418
ir.add_variable(Local(LocalInfo {
442419
id: p_id,
443-
ident: name,
444-
is_mutbl: mutbl,
445-
kind: FromMatch(bm)
420+
ident: name
446421
}));
447422
})
448423
}
@@ -480,27 +455,12 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
480455
// in better error messages than just pointing at the closure
481456
// construction site.
482457
let mut call_caps = Vec::new();
483-
let fv_mode = freevars::get_capture_mode(ir.tcx, expr.id);
484458
freevars::with_freevars(ir.tcx, expr.id, |freevars| {
485459
for fv in freevars.iter() {
486460
match moved_variable_node_id_from_def(fv.def) {
487461
Some(rv) => {
488462
let fv_ln = ir.add_live_node(FreeVarNode(fv.span));
489-
let fv_id = fv.def.def_id().node;
490-
let fv_ty = ty::node_id_to_type(ir.tcx, fv_id);
491-
let is_move = match fv_mode {
492-
// var must be dead afterwards
493-
freevars::CaptureByValue => {
494-
ty::type_moves_by_default(ir.tcx, fv_ty)
495-
}
496-
497-
// var can still be used
498-
freevars::CaptureByRef => {
499-
false
500-
}
501-
};
502463
call_caps.push(CaptureInfo {ln: fv_ln,
503-
is_move: is_move,
504464
var_nid: rv});
505465
}
506466
None => {}

src/librustc/middle/privacy.rs

-2
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> {
353353
struct PrivacyVisitor<'a> {
354354
tcx: &'a ty::ctxt,
355355
curitem: ast::NodeId,
356-
in_fn: bool,
357356
in_foreign: bool,
358357
parents: NodeMap<ast::NodeId>,
359358
external_exports: resolve::ExternalExports,
@@ -1445,7 +1444,6 @@ pub fn check_crate(tcx: &ty::ctxt,
14451444
// Use the parent map to check the privacy of everything
14461445
let mut visitor = PrivacyVisitor {
14471446
curitem: ast::DUMMY_NODE_ID,
1448-
in_fn: false,
14491447
in_foreign: false,
14501448
tcx: tcx,
14511449
parents: visitor.parents,

src/librustc/middle/resolve.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,6 @@ fn namespace_error_to_str(ns: NamespaceError) -> &'static str {
806806
/// The main resolver class.
807807
struct Resolver<'a> {
808808
session: &'a Session,
809-
lang_items: &'a LanguageItems,
810809

811810
graph_root: NameBindings,
812811

@@ -843,9 +842,6 @@ struct Resolver<'a> {
843842
// The idents for the primitive types.
844843
primitive_type_table: PrimitiveTypeTable,
845844

846-
// The four namespaces.
847-
namespaces: Vec<Namespace> ,
848-
849845
def_map: DefMap,
850846
export_map2: ExportMap2,
851847
trait_map: TraitMap,
@@ -902,7 +898,7 @@ impl<'a, 'b> Visitor<()> for UnusedImportCheckVisitor<'a, 'b> {
902898
}
903899

904900
impl<'a> Resolver<'a> {
905-
fn new(session: &'a Session, lang_items: &'a LanguageItems, crate_span: Span) -> Resolver<'a> {
901+
fn new(session: &'a Session, crate_span: Span) -> Resolver<'a> {
906902
let graph_root = NameBindings::new();
907903

908904
graph_root.define_module(NoParentLink,
@@ -916,7 +912,6 @@ impl<'a> Resolver<'a> {
916912

917913
Resolver {
918914
session: session,
919-
lang_items: lang_items,
920915

921916
// The outermost module has def ID 0; this is not reflected in the
922917
// AST.
@@ -941,8 +936,6 @@ impl<'a> Resolver<'a> {
941936

942937
primitive_type_table: PrimitiveTypeTable::new(),
943938

944-
namespaces: vec!(TypeNS, ValueNS),
945-
946939
def_map: RefCell::new(NodeMap::new()),
947940
export_map2: RefCell::new(NodeMap::new()),
948941
trait_map: NodeMap::new(),
@@ -5576,10 +5569,10 @@ pub struct CrateMap {
55765569

55775570
/// Entry point to crate resolution.
55785571
pub fn resolve_crate(session: &Session,
5579-
lang_items: &LanguageItems,
5572+
_: &LanguageItems,
55805573
krate: &Crate)
55815574
-> CrateMap {
5582-
let mut resolver = Resolver::new(session, lang_items, krate.span);
5575+
let mut resolver = Resolver::new(session, krate.span);
55835576
resolver.resolve(krate);
55845577
let Resolver { def_map, export_map2, trait_map, last_private,
55855578
external_exports, .. } = resolver;

0 commit comments

Comments
 (0)