&& !has_allow_dead_code_or_lang_attr(&variant.attrs)
}
+ fn should_warn_about_foreign_item(&mut self, fi: &hir::ForeignItem) -> bool {
+ !self.symbol_is_live(fi.id, None)
+ && !has_allow_dead_code_or_lang_attr(&fi.attrs)
+ }
+
// id := node id of an item's definition.
// ctor_id := `Some` if the item is a struct_ctor (tuple struct),
// `None` otherwise.
}
fn visit_foreign_item(&mut self, fi: &'tcx hir::ForeignItem) {
- if !self.symbol_is_live(fi.id, None) {
+ if self.should_warn_about_foreign_item(fi) {
self.warn_dead_code(fi.id, fi.span, fi.name, fi.node.descriptive_variant());
}
intravisit::walk_foreign_item(self, fi);
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags: --test
+
+#![deny(dead_code)]
+
+extern "C" {
+ #[allow(dead_code)]
+ static Qt: u64;
+}
+
+fn main() {}