From 1fb82b5a038428901818acfdca15a1d61c241146 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Mon, 3 Dec 2018 14:44:58 +0100 Subject: [PATCH] Handle existential types in dead code analysis --- src/librustc/middle/dead.rs | 1 + src/test/ui/existential_types/private_unused.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 src/test/ui/existential_types/private_unused.rs diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 282b5d13e2c61..bb7a6a6ee7b72 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -166,6 +166,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { hir::ItemKind::Fn(..) | hir::ItemKind::Ty(..) | hir::ItemKind::Static(..) + | hir::ItemKind::Existential(..) | hir::ItemKind::Const(..) => { intravisit::walk_item(self, &item); } diff --git a/src/test/ui/existential_types/private_unused.rs b/src/test/ui/existential_types/private_unused.rs new file mode 100644 index 0000000000000..736d812bc0aff --- /dev/null +++ b/src/test/ui/existential_types/private_unused.rs @@ -0,0 +1,13 @@ +// compile-pass + +#[deny(warnings)] + +enum Empty { } +trait Bar {} +impl Bar for () {} + +fn boo() -> impl Bar {} + +fn main() { + boo(); +}