Skip to content

Commit ca129e3

Browse files
committed
lint: mark associated types as live for the dead_code pass
1 parent 2f34986 commit ca129e3

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

Diff for: src/librustc/middle/dead.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,9 @@ impl<'v> Visitor<'v> for LifeSeeder {
351351
}
352352
hir::ItemImpl(_, _, _, ref opt_trait, _, ref impl_items) => {
353353
for impl_item in impl_items {
354-
match impl_item.node {
355-
hir::ImplItemKind::Const(..) |
356-
hir::ImplItemKind::Method(..) => {
357-
if opt_trait.is_some() ||
358-
has_allow_dead_code_or_lang_attr(&impl_item.attrs) {
359-
self.worklist.push(impl_item.id);
360-
}
361-
}
362-
hir::ImplItemKind::Type(_) => {}
354+
if opt_trait.is_some() ||
355+
has_allow_dead_code_or_lang_attr(&impl_item.attrs) {
356+
self.worklist.push(impl_item.id);
363357
}
364358
}
365359
}

Diff for: src/test/run-pass/lint-dead-code-associated-type.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![deny(dead_code)]
12+
13+
trait Foo {
14+
type Bar;
15+
}
16+
17+
struct Used;
18+
19+
struct Ex;
20+
21+
impl Foo for Ex {
22+
type Bar = Used;
23+
}
24+
25+
pub fn main() {
26+
let _x = Ex;
27+
}

0 commit comments

Comments
 (0)