Skip to content

Commit 3400c9e

Browse files
committed
Auto merge of rust-lang#23357 - Manishearth:oops, r=Manishearth
Oops, merged rust-lang#21468 by accident.
2 parents 766a4e1 + c908d1c commit 3400c9e

File tree

4 files changed

+1
-94
lines changed

4 files changed

+1
-94
lines changed

src/librustc/middle/dead.rs

+1-27
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> {
4747
struct_has_extern_repr: bool,
4848
ignore_non_const_paths: bool,
4949
inherited_pub_visibility: bool,
50-
ignore_variant_stack: Vec<ast::NodeId>,
5150
}
5251

5352
impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
@@ -60,7 +59,6 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
6059
struct_has_extern_repr: false,
6160
ignore_non_const_paths: false,
6261
inherited_pub_visibility: false,
63-
ignore_variant_stack: vec![],
6462
}
6563
}
6664

@@ -81,9 +79,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
8179
def::DefPrimTy(_) => (),
8280
def::DefVariant(enum_id, variant_id, _) => {
8381
self.check_def_id(enum_id);
84-
if !self.ignore_variant_stack.contains(&variant_id.node) {
85-
self.check_def_id(variant_id);
86-
}
82+
self.check_def_id(variant_id);
8783
}
8884
_ => {
8985
self.check_def_id(def.def_id());
@@ -282,23 +278,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
282278
visit::walk_expr(self, expr);
283279
}
284280

285-
fn visit_arm(&mut self, arm: &ast::Arm) {
286-
if arm.pats.len() == 1 {
287-
let pat = &*arm.pats[0];
288-
let variants = pat_util::necessary_variants(&self.tcx.def_map, pat);
289-
290-
// Inside the body, ignore constructions of variants
291-
// necessary for the pattern to match. Those construction sites
292-
// can't be reached unless the variant is constructed elsewhere.
293-
let len = self.ignore_variant_stack.len();
294-
self.ignore_variant_stack.push_all(&*variants);
295-
visit::walk_arm(self, arm);
296-
self.ignore_variant_stack.truncate(len);
297-
} else {
298-
visit::walk_arm(self, arm);
299-
}
300-
}
301-
302281
fn visit_pat(&mut self, pat: &ast::Pat) {
303282
let def_map = &self.tcx.def_map;
304283
match pat.node {
@@ -418,11 +397,6 @@ fn create_and_seed_worklist(tcx: &ty::ctxt,
418397
worklist.push(*id);
419398
}
420399
for id in reachable_symbols {
421-
// Reachable variants can be dead, because we warn about
422-
// variants never constructed, not variants never used.
423-
if let Some(ast_map::NodeVariant(..)) = tcx.map.find(*id) {
424-
continue;
425-
}
426400
worklist.push(*id);
427401
}
428402

src/librustc/middle/pat_util.rs

-24
Original file line numberDiff line numberDiff line change
@@ -155,27 +155,3 @@ pub fn def_to_path(tcx: &ty::ctxt, id: ast::DefId) -> ast::Path {
155155
span: DUMMY_SP,
156156
})
157157
}
158-
159-
/// Return variants that are necessary to exist for the pattern to match.
160-
pub fn necessary_variants(dm: &DefMap, pat: &ast::Pat) -> Vec<ast::NodeId> {
161-
let mut variants = vec![];
162-
walk_pat(pat, |p| {
163-
match p.node {
164-
ast::PatEnum(_, _) |
165-
ast::PatIdent(_, _, None) |
166-
ast::PatStruct(..) => {
167-
match dm.borrow().get(&p.id) {
168-
Some(&PathResolution {base_def: DefVariant(_, id, _), ..}) => {
169-
variants.push(id.node);
170-
}
171-
_ => ()
172-
}
173-
}
174-
_ => ()
175-
}
176-
true
177-
});
178-
variants.sort();
179-
variants.dedup();
180-
variants
181-
}

src/libtest/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ impl fmt::Display for TestName {
123123
#[derive(Clone, Copy)]
124124
enum NamePadding {
125125
PadNone,
126-
#[allow(dead_code)]
127126
PadOnLeft,
128127
PadOnRight,
129128
}

src/test/compile-fail/lint-dead-code-variant.rs

-42
This file was deleted.

0 commit comments

Comments
 (0)