From b55f84c0a864c0212ada8240407a636e5c8d8693 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 11 Jul 2020 15:03:17 +0300 Subject: [PATCH] vfmt: turn off module is imported but never used for vfmt --- vlib/v/fmt/tests/file_with_just_imports_keep.vv | 3 +++ vlib/v/parser/module.v | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 vlib/v/fmt/tests/file_with_just_imports_keep.vv diff --git a/vlib/v/fmt/tests/file_with_just_imports_keep.vv b/vlib/v/fmt/tests/file_with_just_imports_keep.vv new file mode 100644 index 0000000000..122510a32a --- /dev/null +++ b/vlib/v/fmt/tests/file_with_just_imports_keep.vv @@ -0,0 +1,3 @@ +module proto +import emily33901.vproto + diff --git a/vlib/v/parser/module.v b/vlib/v/parser/module.v index ded7e65879..3f13650aa8 100644 --- a/vlib/v/parser/module.v +++ b/vlib/v/parser/module.v @@ -37,7 +37,7 @@ fn (mut p Parser) check_unused_imports() { for import_m in p.ast_imports { alias := import_m.alias mod := import_m.mod - if !p.is_used_import(alias) { + if !p.is_used_import(alias) && !p.pref.is_fmt { mod_alias := if alias == mod { alias } else { '$alias ($mod)' } p.warn_with_pos("module '$mod_alias' is imported but never used", import_m.pos) }