From 2efec3c18050b4093ed8be9537145bdc2a50f7e7 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Sat, 14 Jan 2017 07:35:54 +0000 Subject: [PATCH 1/3] Improve `unused_extern_crate` warnings. --- src/librustc_resolve/build_reduced_graph.rs | 27 ++++++++++--------- src/librustc_resolve/check_unused.rs | 27 +++++++++++-------- src/librustc_resolve/lib.rs | 11 +++----- src/librustc_resolve/resolve_imports.rs | 2 ++ .../compile-fail/lint-unused-extern-crate.rs | 5 ++++ 5 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 5e9856878865a..0217aefc227c3 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -249,6 +249,8 @@ impl<'a> Resolver<'a> { // n.b. we don't need to look at the path option here, because cstore already did let crate_id = self.session.cstore.extern_mod_stmt_cnum(item.id).unwrap(); let module = self.get_extern_crate_root(crate_id); + self.populate_module_if_necessary(module); + let used = self.process_legacy_macro_imports(item, module, expansion); let binding = (module, ty::Visibility::Public, sp, expansion).to_name_binding(self.arenas); let directive = self.arenas.alloc_import_directive(ImportDirective { @@ -260,11 +262,11 @@ impl<'a> Resolver<'a> { module_path: Vec::new(), vis: Cell::new(vis), expansion: expansion, + used: Cell::new(used), }); + self.potentially_unused_imports.push(directive); let imported_binding = self.import(binding, directive); self.define(parent, ident, TypeNS, imported_binding); - self.populate_module_if_necessary(module); - self.process_legacy_macro_imports(item, module, expansion); } ItemKind::Mod(..) if item.ident == keywords::Invalid.ident() => {} // Crate root @@ -522,7 +524,6 @@ impl<'a> Resolver<'a> { binding: &'a NameBinding<'a>, span: Span, allow_shadowing: bool) { - self.used_crates.insert(binding.def().def_id().krate); self.macro_names.insert(name); if self.builtin_macros.insert(name, binding).is_some() && !allow_shadowing { let msg = format!("`{}` is already in scope", name); @@ -532,22 +533,23 @@ impl<'a> Resolver<'a> { } } - fn process_legacy_macro_imports(&mut self, item: &Item, module: Module<'a>, expansion: Mark) { + // This returns true if we should consider the underlying `extern crate` to be used. + fn process_legacy_macro_imports(&mut self, item: &Item, module: Module<'a>, expansion: Mark) + -> bool { let allow_shadowing = expansion == Mark::root(); let legacy_imports = self.legacy_macro_imports(&item.attrs); - let cnum = module.def_id().unwrap().krate; + let mut used = legacy_imports != LegacyMacroImports::default(); // `#[macro_use]` and `#[macro_reexport]` are only allowed at the crate root. - if self.current_module.parent.is_some() && legacy_imports != LegacyMacroImports::default() { + if self.current_module.parent.is_some() && used { span_err!(self.session, item.span, E0468, "an `extern crate` loading macros must be at the crate root"); - } else if !self.use_extern_macros && - self.session.cstore.dep_kind(cnum).macros_only() && - legacy_imports == LegacyMacroImports::default() { + } else if !self.use_extern_macros && !used && + self.session.cstore.dep_kind(module.def_id().unwrap().krate).macros_only() { let msg = "custom derive crates and `#[no_link]` crates have no effect without \ `#[macro_use]`"; self.session.span_warn(item.span, msg); - self.used_crates.insert(cnum); // Avoid the normal unused extern crate warning + used = true; // Avoid the normal unused extern crate warning } if let Some(span) = legacy_imports.import_all { @@ -566,9 +568,7 @@ impl<'a> Resolver<'a> { } } for (name, span) in legacy_imports.reexports { - let krate = module.def_id().unwrap().krate; - self.used_crates.insert(krate); - self.session.cstore.export_macros(krate); + self.session.cstore.export_macros(module.def_id().unwrap().krate); let ident = Ident::with_empty_ctxt(name); let result = self.resolve_ident_in_module(module, ident, MacroNS, false, None); if let Ok(binding) = result { @@ -577,6 +577,7 @@ impl<'a> Resolver<'a> { span_err!(self.session, span, E0470, "reexported macro not found"); } } + used } // does this attribute list contain "macro_use"? diff --git a/src/librustc_resolve/check_unused.rs b/src/librustc_resolve/check_unused.rs index 41391c65a128d..0e44f4556dd08 100644 --- a/src/librustc_resolve/check_unused.rs +++ b/src/librustc_resolve/check_unused.rs @@ -22,8 +22,9 @@ use std::ops::{Deref, DerefMut}; use Resolver; +use resolve_imports::ImportDirectiveSubclass; -use rustc::lint; +use rustc::{lint, ty}; use rustc::util::nodemap::NodeMap; use syntax::ast::{self, ViewPathGlob, ViewPathList, ViewPathSimple}; use syntax::visit::{self, Visitor}; @@ -86,16 +87,6 @@ impl<'a, 'b> Visitor<'a> for UnusedImportCheckVisitor<'a, 'b> { } match item.node { - ast::ItemKind::ExternCrate(_) => { - if let Some(crate_num) = self.session.cstore.extern_mod_stmt_cnum(item.id) { - if !self.used_crates.contains(&crate_num) { - self.session.add_lint(lint::builtin::UNUSED_EXTERN_CRATES, - item.id, - item.span, - "unused extern crate".to_string()); - } - } - } ast::ItemKind::Use(ref p) => { match p.node { ViewPathSimple(..) => { @@ -124,6 +115,20 @@ impl<'a, 'b> Visitor<'a> for UnusedImportCheckVisitor<'a, 'b> { } pub fn check_crate(resolver: &mut Resolver, krate: &ast::Crate) { + for directive in resolver.potentially_unused_imports.iter() { + match directive.subclass { + _ if directive.used.get() || + directive.vis.get() == ty::Visibility::Public || + directive.span.source_equal(&DUMMY_SP) => {} + ImportDirectiveSubclass::ExternCrate => { + let lint = lint::builtin::UNUSED_EXTERN_CRATES; + let msg = "unused extern crate".to_string(); + resolver.session.add_lint(lint, directive.id, directive.span, msg); + } + _ => {} + } + } + let mut visitor = UnusedImportCheckVisitor { resolver: resolver, unused_imports: NodeMap(), diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 971b91ea313f3..8a206664a7d3a 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1099,7 +1099,6 @@ pub struct Resolver<'a> { pub glob_map: GlobMap, used_imports: FxHashSet<(NodeId, Namespace)>, - used_crates: FxHashSet, pub maybe_unused_trait_imports: NodeSet, privacy_errors: Vec>, @@ -1130,6 +1129,8 @@ pub struct Resolver<'a> { // A set of procedural macros imported by `#[macro_use]` that have already been warned about warned_proc_macros: FxHashSet, + + potentially_unused_imports: Vec<&'a ImportDirective<'a>>, } pub struct ResolverArenas<'a> { @@ -1279,7 +1280,6 @@ impl<'a> Resolver<'a> { glob_map: NodeMap(), used_imports: FxHashSet(), - used_crates: FxHashSet(), maybe_unused_trait_imports: NodeSet(), privacy_errors: Vec::new(), @@ -1309,6 +1309,7 @@ impl<'a> Resolver<'a> { whitelisted_legacy_custom_derives: Vec::new(), proc_macro_enabled: features.proc_macro, warned_proc_macros: FxHashSet(), + potentially_unused_imports: Vec::new(), } } @@ -1354,15 +1355,11 @@ impl<'a> Resolver<'a> { fn record_use(&mut self, ident: Ident, ns: Namespace, binding: &'a NameBinding<'a>, span: Span) -> bool /* true if an error was reported */ { - // track extern crates for unused_extern_crate lint - if let Some(DefId { krate, .. }) = binding.module().and_then(ModuleData::def_id) { - self.used_crates.insert(krate); - } - match binding.kind { NameBindingKind::Import { directive, binding, ref used, legacy_self_import } if !used.get() => { used.set(true); + directive.used.set(true); if legacy_self_import { self.warn_legacy_self_import(directive); return false; diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 65e599ac6c7e8..8d94fd86b1751 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -62,6 +62,7 @@ pub struct ImportDirective<'a> { pub span: Span, pub vis: Cell, pub expansion: Mark, + pub used: Cell, } impl<'a> ImportDirective<'a> { @@ -257,6 +258,7 @@ impl<'a> Resolver<'a> { id: id, vis: Cell::new(vis), expansion: expansion, + used: Cell::new(false), }); self.indeterminate_imports.push(directive); diff --git a/src/test/compile-fail/lint-unused-extern-crate.rs b/src/test/compile-fail/lint-unused-extern-crate.rs index 52cb84f662dd0..515e3b833d9f0 100644 --- a/src/test/compile-fail/lint-unused-extern-crate.rs +++ b/src/test/compile-fail/lint-unused-extern-crate.rs @@ -33,6 +33,11 @@ use rand::isaac::IsaacRng; use other::*; +mod foo { + // Test that this is unused even though an earler `extern crate rand` is used. + extern crate rand; //~ ERROR unused extern crate +} + fn main() { let x: collecs::vec::Vec = Vec::new(); let y = foo(); From 356fa2c5db18beb5d4787ea2997f555504bb26dc Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Sat, 14 Jan 2017 08:58:50 +0000 Subject: [PATCH 2/3] Warn on unused `#[macro_use]` imports. --- src/libproc_macro_tokens/lib.rs | 2 +- src/librustc/lib.rs | 2 +- src/librustc_const_math/lib.rs | 4 ++-- src/librustc_driver/lib.rs | 1 - src/librustc_errors/lib.rs | 2 -- src/librustc_incremental/lib.rs | 2 +- src/librustc_lint/lib.rs | 1 - src/librustc_plugin/Cargo.toml | 1 - src/librustc_plugin/lib.rs | 3 +-- src/librustc_resolve/build_reduced_graph.rs | 23 +++++++++++++++++-- src/librustc_resolve/check_unused.rs | 5 ++++ src/librustc_resolve/macros.rs | 16 ++++++++----- src/librustc_resolve/resolve_imports.rs | 2 ++ src/libserialize/lib.rs | 2 +- .../compile-fail/imports/unused-macro-use.rs | 21 +++++++++++++++++ .../compile-fail/lint-unused-extern-crate.rs | 2 -- src/tools/cargotest/main.rs | 2 +- 17 files changed, 67 insertions(+), 24 deletions(-) create mode 100644 src/test/compile-fail/imports/unused-macro-use.rs diff --git a/src/libproc_macro_tokens/lib.rs b/src/libproc_macro_tokens/lib.rs index 0dd9aaab1c63a..b99b8f29299c2 100644 --- a/src/libproc_macro_tokens/lib.rs +++ b/src/libproc_macro_tokens/lib.rs @@ -59,7 +59,7 @@ extern crate syntax; extern crate syntax_pos; -#[macro_use] extern crate log; +extern crate log; pub mod build; pub mod parse; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 151d7cd17ab14..bf0829cbdd041 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -57,7 +57,7 @@ extern crate rustc_const_math; extern crate rustc_errors as errors; #[macro_use] extern crate log; #[macro_use] extern crate syntax; -#[macro_use] extern crate syntax_pos; +extern crate syntax_pos; #[macro_use] #[no_link] extern crate rustc_bitflags; extern crate serialize as rustc_serialize; // used by deriving diff --git a/src/librustc_const_math/lib.rs b/src/librustc_const_math/lib.rs index cd933c0059945..beecf4cd8eb3b 100644 --- a/src/librustc_const_math/lib.rs +++ b/src/librustc_const_math/lib.rs @@ -28,8 +28,8 @@ #![feature(const_fn)] #![cfg_attr(not(stage0), feature(i128))] -#[macro_use] extern crate log; -#[macro_use] extern crate syntax; +extern crate log; +extern crate syntax; // SNAP: remove use of this crate extern crate rustc_i128; diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 48eb6f68564f0..e82ba32c34ac8 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -57,7 +57,6 @@ extern crate serialize; extern crate rustc_llvm as llvm; #[macro_use] extern crate log; -#[macro_use] extern crate syntax; extern crate syntax_ext; extern crate syntax_pos; diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index bcae7b262c626..7946f6a0a46dc 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -27,9 +27,7 @@ extern crate serialize; extern crate term; -#[macro_use] extern crate log; -#[macro_use] extern crate libc; extern crate std_unicode; extern crate serialize as rustc_serialize; // used by deriving diff --git a/src/librustc_incremental/lib.rs b/src/librustc_incremental/lib.rs index e96d59774191d..2d25baf6960fb 100644 --- a/src/librustc_incremental/lib.rs +++ b/src/librustc_incremental/lib.rs @@ -30,7 +30,7 @@ extern crate rustc_data_structures; extern crate serialize as rustc_serialize; #[macro_use] extern crate log; -#[macro_use] extern crate syntax; +extern crate syntax; extern crate syntax_pos; extern crate rustc_i128; diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 60497fe171ccb..34bc57884ecbb 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -37,7 +37,6 @@ #![feature(slice_patterns)] #![feature(staged_api)] -#[macro_use] extern crate syntax; #[macro_use] extern crate rustc; diff --git a/src/librustc_plugin/Cargo.toml b/src/librustc_plugin/Cargo.toml index 48d4437358c58..42d1d3c2ba574 100644 --- a/src/librustc_plugin/Cargo.toml +++ b/src/librustc_plugin/Cargo.toml @@ -13,7 +13,6 @@ crate-type = ["dylib"] log = { path = "../liblog" } rustc = { path = "../librustc" } rustc_back = { path = "../librustc_back" } -rustc_bitflags = { path = "../librustc_bitflags" } rustc_metadata = { path = "../librustc_metadata" } syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } diff --git a/src/librustc_plugin/lib.rs b/src/librustc_plugin/lib.rs index 8d4e61ad8e54e..8f389499dd64a 100644 --- a/src/librustc_plugin/lib.rs +++ b/src/librustc_plugin/lib.rs @@ -63,9 +63,8 @@ #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] -#[macro_use] extern crate log; +extern crate log; #[macro_use] extern crate syntax; -#[macro_use] #[no_link] extern crate rustc_bitflags; extern crate rustc; extern crate rustc_back; diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 0217aefc227c3..f74af416cde09 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -552,16 +552,35 @@ impl<'a> Resolver<'a> { used = true; // Avoid the normal unused extern crate warning } + let (graph_root, arenas) = (self.graph_root, self.arenas); + let macro_use_directive = |span| arenas.alloc_import_directive(ImportDirective { + id: item.id, + parent: graph_root, + imported_module: Cell::new(Some(module)), + subclass: ImportDirectiveSubclass::MacroUse, + span: span, + module_path: Vec::new(), + vis: Cell::new(ty::Visibility::Restricted(DefId::local(CRATE_DEF_INDEX))), + expansion: expansion, + used: Cell::new(false), + }); + if let Some(span) = legacy_imports.import_all { + let directive = macro_use_directive(span); + self.potentially_unused_imports.push(directive); module.for_each_child(|ident, ns, binding| if ns == MacroNS { - self.legacy_import_macro(ident.name, binding, span, allow_shadowing); + let imported_binding = self.import(binding, directive); + self.legacy_import_macro(ident.name, imported_binding, span, allow_shadowing); }); } else { for (name, span) in legacy_imports.imports { let ident = Ident::with_empty_ctxt(name); let result = self.resolve_ident_in_module(module, ident, MacroNS, false, None); if let Ok(binding) = result { - self.legacy_import_macro(name, binding, span, allow_shadowing); + let directive = macro_use_directive(span); + self.potentially_unused_imports.push(directive); + let imported_binding = self.import(binding, directive); + self.legacy_import_macro(name, imported_binding, span, allow_shadowing); } else { span_err!(self.session, span, E0469, "imported macro not found"); } diff --git a/src/librustc_resolve/check_unused.rs b/src/librustc_resolve/check_unused.rs index 0e44f4556dd08..d150ff1ff81f5 100644 --- a/src/librustc_resolve/check_unused.rs +++ b/src/librustc_resolve/check_unused.rs @@ -125,6 +125,11 @@ pub fn check_crate(resolver: &mut Resolver, krate: &ast::Crate) { let msg = "unused extern crate".to_string(); resolver.session.add_lint(lint, directive.id, directive.span, msg); } + ImportDirectiveSubclass::MacroUse => { + let lint = lint::builtin::UNUSED_IMPORTS; + let msg = "unused `#[macro_use]` import".to_string(); + resolver.session.add_lint(lint, directive.id, directive.span, msg); + } _ => {} } } diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 9b7d6f33a7f3b..682b3ff834fad 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -341,12 +341,15 @@ impl<'a> Resolver<'a> { }; } - let binding = match binding { - Some(binding) => MacroBinding::Legacy(binding), - None => match self.builtin_macros.get(&name).cloned() { - Some(binding) => MacroBinding::Modern(binding), - None => return None, - }, + let binding = if let Some(binding) = binding { + MacroBinding::Legacy(binding) + } else if let Some(binding) = self.builtin_macros.get(&name).cloned() { + if !self.use_extern_macros { + self.record_use(Ident::with_empty_ctxt(name), MacroNS, binding, DUMMY_SP); + } + MacroBinding::Modern(binding) + } else { + return None; }; if !self.use_extern_macros { @@ -378,6 +381,7 @@ impl<'a> Resolver<'a> { let (legacy_resolution, resolution) = match (legacy_resolution, resolution) { (Some(legacy_resolution), Ok(resolution)) => (legacy_resolution, resolution), (Some(MacroBinding::Modern(binding)), Err(_)) => { + self.record_use(ident, MacroNS, binding, span); self.err_if_macro_use_proc_macro(ident.name, span, binding); continue }, diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 8d94fd86b1751..65cdeb9253d89 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -49,6 +49,7 @@ pub enum ImportDirectiveSubclass<'a> { // n.b. `max_vis` is only used in `finalize_import` to check for reexport errors. }, ExternCrate, + MacroUse, } /// One import directive. @@ -835,5 +836,6 @@ fn import_directive_subclass_to_string(subclass: &ImportDirectiveSubclass) -> St SingleImport { source, .. } => source.to_string(), GlobImport { .. } => "*".to_string(), ExternCrate => "".to_string(), + MacroUse => "#[macro_use]".to_string(), } } diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index cfa09361ccec7..3d9ce864ec121 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -39,7 +39,7 @@ Core encoding and decoding interfaces. // test harness access #[cfg(test)] extern crate test; -#[macro_use] extern crate log; +extern crate log; extern crate std_unicode; extern crate collections; diff --git a/src/test/compile-fail/imports/unused-macro-use.rs b/src/test/compile-fail/imports/unused-macro-use.rs new file mode 100644 index 0000000000000..365521970cd21 --- /dev/null +++ b/src/test/compile-fail/imports/unused-macro-use.rs @@ -0,0 +1,21 @@ +// Copyright 2016 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unused)] + +#[macro_use] //~ ERROR unused `#[macro_use]` import +extern crate core; + +#[macro_use( + panic //~ ERROR unused `#[macro_use]` import +)] +extern crate core as core_2; + +fn main() {} diff --git a/src/test/compile-fail/lint-unused-extern-crate.rs b/src/test/compile-fail/lint-unused-extern-crate.rs index 515e3b833d9f0..40671353f8ac6 100644 --- a/src/test/compile-fail/lint-unused-extern-crate.rs +++ b/src/test/compile-fail/lint-unused-extern-crate.rs @@ -26,8 +26,6 @@ extern crate rand; // no error, the use marks it as used extern crate lint_unused_extern_crate as other; // no error, the use * marks it as used -#[macro_use] extern crate core; // no error, the `#[macro_use]` marks it as used - #[allow(unused_imports)] use rand::isaac::IsaacRng; diff --git a/src/tools/cargotest/main.rs b/src/tools/cargotest/main.rs index 8a891d624f402..83fd766c54739 100644 --- a/src/tools/cargotest/main.rs +++ b/src/tools/cargotest/main.rs @@ -25,7 +25,7 @@ const TEST_REPOS: &'static [Test] = &[ Test { name: "cargo", repo: "https://github.com/rust-lang/cargo", - sha: "b7be4f2ef2cf743492edc6dfb55d087ed88f2d76", + sha: "2324c2bbaf7fc6ea9cbdd77c034ef1af769cb617", lock: None, }, Test { From 191abc42642c29f589a34e7f6cdebd081c373138 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Sat, 14 Jan 2017 09:21:43 +0000 Subject: [PATCH 3/3] Remove unused `extern crate`s. --- src/Cargo.lock | 17 ----------------- src/libproc_macro_plugin/Cargo.toml | 1 - src/libproc_macro_plugin/lib.rs | 1 - src/libproc_macro_tokens/Cargo.toml | 2 -- src/libproc_macro_tokens/build.rs | 3 --- src/libproc_macro_tokens/lib.rs | 2 -- src/libproc_macro_tokens/parse.rs | 2 -- src/librustc/Cargo.toml | 1 - src/librustc/lib.rs | 7 ------- src/librustc_const_eval/Cargo.toml | 1 - src/librustc_const_eval/lib.rs | 1 - src/librustc_const_math/Cargo.toml | 1 - src/librustc_const_math/lib.rs | 1 - src/librustc_driver/Cargo.toml | 1 - src/librustc_driver/lib.rs | 1 - src/librustc_errors/Cargo.toml | 2 -- src/librustc_errors/lib.rs | 5 ----- src/librustc_incremental/Cargo.toml | 1 - src/librustc_incremental/lib.rs | 2 -- src/librustc_mir/Cargo.toml | 1 - src/librustc_mir/lib.rs | 1 - src/librustc_passes/lib.rs | 1 - src/librustc_plugin/Cargo.toml | 1 - src/librustc_plugin/lib.rs | 1 - src/librustc_trans/Cargo.toml | 3 --- src/librustc_trans/lib.rs | 4 ---- src/libserialize/Cargo.toml | 1 - src/libserialize/lib.rs | 7 ------- src/libsyntax/lib.rs | 4 ---- 29 files changed, 76 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index d153945dc091f..2c10272916fdc 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -212,16 +212,13 @@ dependencies = [ "proc_macro_tokens 0.0.0", "rustc_plugin 0.0.0", "syntax 0.0.0", - "syntax_pos 0.0.0", ] [[package]] name = "proc_macro_tokens" version = "0.0.0" dependencies = [ - "log 0.0.0", "syntax 0.0.0", - "syntax_pos 0.0.0", ] [[package]] @@ -240,7 +237,6 @@ name = "rustc" version = "0.0.0" dependencies = [ "arena 0.0.0", - "flate 0.0.0", "fmt_macros 0.0.0", "graphviz 0.0.0", "log 0.0.0", @@ -310,7 +306,6 @@ dependencies = [ "rustc_data_structures 0.0.0", "rustc_errors 0.0.0", "rustc_i128 0.0.0", - "serialize 0.0.0", "syntax 0.0.0", "syntax_pos 0.0.0", ] @@ -319,7 +314,6 @@ dependencies = [ name = "rustc_const_math" version = "0.0.0" dependencies = [ - "log 0.0.0", "rustc_i128 0.0.0", "serialize 0.0.0", "syntax 0.0.0", @@ -339,7 +333,6 @@ name = "rustc_driver" version = "0.0.0" dependencies = [ "arena 0.0.0", - "flate 0.0.0", "graphviz 0.0.0", "log 0.0.0", "proc_macro_plugin 0.0.0", @@ -371,8 +364,6 @@ dependencies = [ name = "rustc_errors" version = "0.0.0" dependencies = [ - "log 0.0.0", - "serialize 0.0.0", "syntax_pos 0.0.0", ] @@ -388,7 +379,6 @@ dependencies = [ "log 0.0.0", "rustc 0.0.0", "rustc_data_structures 0.0.0", - "rustc_i128 0.0.0", "serialize 0.0.0", "syntax 0.0.0", "syntax_pos 0.0.0", @@ -443,7 +433,6 @@ dependencies = [ "graphviz 0.0.0", "log 0.0.0", "rustc 0.0.0", - "rustc_back 0.0.0", "rustc_bitflags 0.0.0", "rustc_const_eval 0.0.0", "rustc_const_math 0.0.0", @@ -474,10 +463,8 @@ version = "0.0.0" name = "rustc_plugin" version = "0.0.0" dependencies = [ - "log 0.0.0", "rustc 0.0.0", "rustc_back 0.0.0", - "rustc_bitflags 0.0.0", "rustc_errors 0.0.0", "rustc_metadata 0.0.0", "syntax 0.0.0", @@ -520,9 +507,7 @@ dependencies = [ name = "rustc_trans" version = "0.0.0" dependencies = [ - "arena 0.0.0", "flate 0.0.0", - "graphviz 0.0.0", "log 0.0.0", "rustc 0.0.0", "rustc_back 0.0.0", @@ -535,7 +520,6 @@ dependencies = [ "rustc_incremental 0.0.0", "rustc_llvm 0.0.0", "rustc_platform_intrinsics 0.0.0", - "serialize 0.0.0", "syntax 0.0.0", "syntax_pos 0.0.0", ] @@ -585,7 +569,6 @@ dependencies = [ name = "serialize" version = "0.0.0" dependencies = [ - "log 0.0.0", "rustc_i128 0.0.0", ] diff --git a/src/libproc_macro_plugin/Cargo.toml b/src/libproc_macro_plugin/Cargo.toml index 4bc3f488d3280..33fd814cd5f8b 100644 --- a/src/libproc_macro_plugin/Cargo.toml +++ b/src/libproc_macro_plugin/Cargo.toml @@ -11,5 +11,4 @@ crate-type = ["dylib"] log = { path = "../liblog" } rustc_plugin = { path = "../librustc_plugin" } syntax = { path = "../libsyntax" } -syntax_pos = { path = "../libsyntax_pos" } proc_macro_tokens = { path = "../libproc_macro_tokens" } diff --git a/src/libproc_macro_plugin/lib.rs b/src/libproc_macro_plugin/lib.rs index 0a7d352584872..9d8bb7fa0f57c 100644 --- a/src/libproc_macro_plugin/lib.rs +++ b/src/libproc_macro_plugin/lib.rs @@ -88,7 +88,6 @@ extern crate rustc_plugin; extern crate syntax; -extern crate syntax_pos; extern crate proc_macro_tokens; #[macro_use] extern crate log; diff --git a/src/libproc_macro_tokens/Cargo.toml b/src/libproc_macro_tokens/Cargo.toml index b4365e4fb265a..2cec4d7af54cb 100644 --- a/src/libproc_macro_tokens/Cargo.toml +++ b/src/libproc_macro_tokens/Cargo.toml @@ -10,5 +10,3 @@ crate-type = ["dylib"] [dependencies] syntax = { path = "../libsyntax" } -syntax_pos = { path = "../libsyntax_pos" } -log = { path = "../liblog" } diff --git a/src/libproc_macro_tokens/build.rs b/src/libproc_macro_tokens/build.rs index 89c84b6bc221a..18aa60f9df16e 100644 --- a/src/libproc_macro_tokens/build.rs +++ b/src/libproc_macro_tokens/build.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate syntax; -extern crate syntax_pos; - use syntax::ast::Ident; use syntax::codemap::DUMMY_SP; use syntax::parse::token::{self, Token}; diff --git a/src/libproc_macro_tokens/lib.rs b/src/libproc_macro_tokens/lib.rs index b99b8f29299c2..e20ed6899154e 100644 --- a/src/libproc_macro_tokens/lib.rs +++ b/src/libproc_macro_tokens/lib.rs @@ -58,8 +58,6 @@ #![feature(rustc_private)] extern crate syntax; -extern crate syntax_pos; -extern crate log; pub mod build; pub mod parse; diff --git a/src/libproc_macro_tokens/parse.rs b/src/libproc_macro_tokens/parse.rs index 5ab4fcd5dab29..73268d0e66283 100644 --- a/src/libproc_macro_tokens/parse.rs +++ b/src/libproc_macro_tokens/parse.rs @@ -10,8 +10,6 @@ //! Parsing utilities for writing procedural macros. -extern crate syntax; - use syntax::parse::{ParseSess, filemap_to_tts}; use syntax::tokenstream::TokenStream; diff --git a/src/librustc/Cargo.toml b/src/librustc/Cargo.toml index 51494885e7369..3c455eb05011e 100644 --- a/src/librustc/Cargo.toml +++ b/src/librustc/Cargo.toml @@ -10,7 +10,6 @@ crate-type = ["dylib"] [dependencies] arena = { path = "../libarena" } -flate = { path = "../libflate" } fmt_macros = { path = "../libfmt_macros" } graphviz = { path = "../libgraphviz" } log = { path = "../liblog" } diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index bf0829cbdd041..619a3e995c3a5 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -26,7 +26,6 @@ #![feature(associated_consts)] #![feature(box_patterns)] #![feature(box_syntax)] -#![feature(collections)] #![feature(conservative_impl_trait)] #![feature(const_fn)] #![feature(core_intrinsics)] @@ -39,11 +38,9 @@ #![feature(slice_patterns)] #![feature(staged_api)] #![feature(unboxed_closures)] -#![cfg_attr(test, feature(test))] extern crate arena; extern crate core; -extern crate flate; extern crate fmt_macros; extern crate getopts; extern crate graphviz; @@ -52,7 +49,6 @@ extern crate rustc_llvm as llvm; extern crate rustc_back; extern crate rustc_data_structures; extern crate serialize; -extern crate collections; extern crate rustc_const_math; extern crate rustc_errors as errors; #[macro_use] extern crate log; @@ -65,9 +61,6 @@ extern crate serialize as rustc_serialize; // used by deriving // SNAP: extern crate rustc_i128; -#[cfg(test)] -extern crate test; - #[macro_use] mod macros; diff --git a/src/librustc_const_eval/Cargo.toml b/src/librustc_const_eval/Cargo.toml index 7148e181bbd6d..ff028c202a849 100644 --- a/src/librustc_const_eval/Cargo.toml +++ b/src/librustc_const_eval/Cargo.toml @@ -11,7 +11,6 @@ crate-type = ["dylib"] [dependencies] arena = { path = "../libarena" } log = { path = "../liblog" } -serialize = { path = "../libserialize" } rustc = { path = "../librustc" } rustc_back = { path = "../librustc_back" } rustc_const_math = { path = "../librustc_const_math" } diff --git a/src/librustc_const_eval/lib.rs b/src/librustc_const_eval/lib.rs index 67b4efdbd1f44..2b6f487c2c942 100644 --- a/src/librustc_const_eval/lib.rs +++ b/src/librustc_const_eval/lib.rs @@ -40,7 +40,6 @@ extern crate rustc_data_structures; extern crate rustc_errors; extern crate graphviz; extern crate syntax_pos; -extern crate serialize as rustc_serialize; // used by deriving extern crate rustc_i128; diff --git a/src/librustc_const_math/Cargo.toml b/src/librustc_const_math/Cargo.toml index 3d7a4865e45af..e6db1557fbe3d 100644 --- a/src/librustc_const_math/Cargo.toml +++ b/src/librustc_const_math/Cargo.toml @@ -9,7 +9,6 @@ path = "lib.rs" crate-type = ["dylib"] [dependencies] -log = { path = "../liblog" } serialize = { path = "../libserialize" } syntax = { path = "../libsyntax" } rustc_i128 = { path = "../librustc_i128" } diff --git a/src/librustc_const_math/lib.rs b/src/librustc_const_math/lib.rs index beecf4cd8eb3b..d40a6aa32fd46 100644 --- a/src/librustc_const_math/lib.rs +++ b/src/librustc_const_math/lib.rs @@ -28,7 +28,6 @@ #![feature(const_fn)] #![cfg_attr(not(stage0), feature(i128))] -extern crate log; extern crate syntax; // SNAP: remove use of this crate diff --git a/src/librustc_driver/Cargo.toml b/src/librustc_driver/Cargo.toml index 99d3e155e8936..caa5c8b7e0058 100644 --- a/src/librustc_driver/Cargo.toml +++ b/src/librustc_driver/Cargo.toml @@ -10,7 +10,6 @@ crate-type = ["dylib"] [dependencies] arena = { path = "../libarena" } -flate = { path = "../libflate" } graphviz = { path = "../libgraphviz" } log = { path = "../liblog" } proc_macro_plugin = { path = "../libproc_macro_plugin" } diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index e82ba32c34ac8..0ecd12b3a903a 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -32,7 +32,6 @@ #![feature(staged_api)] extern crate arena; -extern crate flate; extern crate getopts; extern crate graphviz; extern crate libc; diff --git a/src/librustc_errors/Cargo.toml b/src/librustc_errors/Cargo.toml index c92e4d8f5aba5..2ba1f501a63d8 100644 --- a/src/librustc_errors/Cargo.toml +++ b/src/librustc_errors/Cargo.toml @@ -9,6 +9,4 @@ path = "lib.rs" crate-type = ["dylib"] [dependencies] -log = { path = "../liblog" } -serialize = { path = "../libserialize" } syntax_pos = { path = "../libsyntax_pos" } diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 7946f6a0a46dc..bf5f7cde7eb06 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -23,14 +23,9 @@ #![feature(staged_api)] #![feature(range_contains)] #![feature(libc)] -#![feature(unicode)] -extern crate serialize; extern crate term; -extern crate log; extern crate libc; -extern crate std_unicode; -extern crate serialize as rustc_serialize; // used by deriving extern crate syntax_pos; pub use emitter::ColorConfig; diff --git a/src/librustc_incremental/Cargo.toml b/src/librustc_incremental/Cargo.toml index 8a38f36a5d133..e3ee752754504 100644 --- a/src/librustc_incremental/Cargo.toml +++ b/src/librustc_incremental/Cargo.toml @@ -16,4 +16,3 @@ serialize = { path = "../libserialize" } log = { path = "../liblog" } syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } -rustc_i128 = { path = "../librustc_i128" } diff --git a/src/librustc_incremental/lib.rs b/src/librustc_incremental/lib.rs index 2d25baf6960fb..a866a15c4d280 100644 --- a/src/librustc_incremental/lib.rs +++ b/src/librustc_incremental/lib.rs @@ -33,8 +33,6 @@ extern crate serialize as rustc_serialize; extern crate syntax; extern crate syntax_pos; -extern crate rustc_i128; - const ATTR_DIRTY: &'static str = "rustc_dirty"; const ATTR_CLEAN: &'static str = "rustc_clean"; const ATTR_DIRTY_METADATA: &'static str = "rustc_metadata_dirty"; diff --git a/src/librustc_mir/Cargo.toml b/src/librustc_mir/Cargo.toml index 7e26aa9a57bf5..9f49d02f86cec 100644 --- a/src/librustc_mir/Cargo.toml +++ b/src/librustc_mir/Cargo.toml @@ -12,7 +12,6 @@ crate-type = ["dylib"] graphviz = { path = "../libgraphviz" } log = { path = "../liblog" } rustc = { path = "../librustc" } -rustc_back = { path = "../librustc_back" } rustc_const_eval = { path = "../librustc_const_eval" } rustc_const_math = { path = "../librustc_const_math" } rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index e7493850aa7cd..e7764d58d75ff 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -31,7 +31,6 @@ extern crate graphviz as dot; #[macro_use] extern crate rustc; extern crate rustc_data_structures; -extern crate rustc_back; #[macro_use] #[no_link] extern crate rustc_bitflags; diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index 143c1efed5a93..7a465f0ec4239 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -27,7 +27,6 @@ #![feature(staged_api)] #![feature(rustc_private)] -extern crate core; #[macro_use] extern crate rustc; extern crate rustc_const_eval; diff --git a/src/librustc_plugin/Cargo.toml b/src/librustc_plugin/Cargo.toml index 42d1d3c2ba574..7f41d0527617a 100644 --- a/src/librustc_plugin/Cargo.toml +++ b/src/librustc_plugin/Cargo.toml @@ -10,7 +10,6 @@ path = "lib.rs" crate-type = ["dylib"] [dependencies] -log = { path = "../liblog" } rustc = { path = "../librustc" } rustc_back = { path = "../librustc_back" } rustc_metadata = { path = "../librustc_metadata" } diff --git a/src/librustc_plugin/lib.rs b/src/librustc_plugin/lib.rs index 8f389499dd64a..8aa680ca12d10 100644 --- a/src/librustc_plugin/lib.rs +++ b/src/librustc_plugin/lib.rs @@ -63,7 +63,6 @@ #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] -extern crate log; #[macro_use] extern crate syntax; extern crate rustc; diff --git a/src/librustc_trans/Cargo.toml b/src/librustc_trans/Cargo.toml index 93e2e472b75f1..36d2ba4f3676b 100644 --- a/src/librustc_trans/Cargo.toml +++ b/src/librustc_trans/Cargo.toml @@ -10,9 +10,7 @@ crate-type = ["dylib"] test = false [dependencies] -arena = { path = "../libarena" } flate = { path = "../libflate" } -graphviz = { path = "../libgraphviz" } log = { path = "../liblog" } rustc = { path = "../librustc" } rustc_back = { path = "../librustc_back" } @@ -25,6 +23,5 @@ rustc_incremental = { path = "../librustc_incremental" } rustc_llvm = { path = "../librustc_llvm" } rustc_i128 = { path = "../librustc_i128" } rustc_platform_intrinsics = { path = "../librustc_platform_intrinsics" } -serialize = { path = "../libserialize" } syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index d8c0bde963e33..659dbb441ee35 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -40,10 +40,7 @@ use rustc::dep_graph::WorkProduct; -extern crate arena; extern crate flate; -extern crate getopts; -extern crate graphviz; extern crate libc; #[macro_use] extern crate rustc; extern crate rustc_back; @@ -51,7 +48,6 @@ extern crate rustc_data_structures; extern crate rustc_incremental; pub extern crate rustc_llvm as llvm; extern crate rustc_platform_intrinsics as intrinsics; -extern crate serialize; extern crate rustc_const_math; extern crate rustc_const_eval; #[macro_use] diff --git a/src/libserialize/Cargo.toml b/src/libserialize/Cargo.toml index 3213b4e4208be..47403b459817b 100644 --- a/src/libserialize/Cargo.toml +++ b/src/libserialize/Cargo.toml @@ -9,5 +9,4 @@ path = "lib.rs" crate-type = ["dylib", "rlib"] [dependencies] -log = { path = "../liblog" } rustc_i128 = { path = "../librustc_i128" } diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index 3d9ce864ec121..2cfc3924c036e 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -31,17 +31,10 @@ Core encoding and decoding interfaces. #![feature(collections)] #![feature(core_intrinsics)] #![feature(enumset)] -#![feature(rustc_private)] #![feature(specialization)] #![feature(staged_api)] -#![feature(unicode)] #![cfg_attr(test, feature(test))] -// test harness access -#[cfg(test)] extern crate test; -extern crate log; - -extern crate std_unicode; extern crate collections; extern crate rustc_i128; diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 00bf744507713..f3c5a49bcf8b6 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -26,7 +26,6 @@ #![feature(associated_consts)] #![feature(const_fn)] -#![feature(libc)] #![feature(optin_builtin_traits)] #![feature(rustc_private)] #![feature(staged_api)] @@ -35,10 +34,7 @@ #![feature(rustc_diagnostic_macros)] #![feature(specialization)] -extern crate core; extern crate serialize; -extern crate term; -extern crate libc; #[macro_use] extern crate log; #[macro_use] #[no_link] extern crate rustc_bitflags; extern crate std_unicode;