diff --git a/examples/sokol/drawing.v b/examples/sokol/drawing.v index b45c762bb0..b58b5ab41b 100644 --- a/examples/sokol/drawing.v +++ b/examples/sokol/drawing.v @@ -1,4 +1,3 @@ -import sokol import sokol.sapp import sokol.gfx import sokol.sgl @@ -7,8 +6,6 @@ struct AppState { pass_action gfx.PassAction } -const used_import = sokol.used_import - fn main() { state := &AppState{ pass_action: gfx.create_clear_pass_action(0.1, 0.1, 0.1, 1.0) diff --git a/examples/sokol/particles/particles.v b/examples/sokol/particles/particles.v index 1401202382..f14157b1df 100644 --- a/examples/sokol/particles/particles.v +++ b/examples/sokol/particles/particles.v @@ -3,14 +3,11 @@ module main import time -import sokol import sokol.sapp import sokol.gfx import sokol.sgl import particle -const used_import = sokol.used_import - fn main() { mut app := &App{ width: 800 diff --git a/vlib/fontstash/fontstash.c.v b/vlib/fontstash/fontstash.c.v index f4b15b9a5b..e30a41812f 100644 --- a/vlib/fontstash/fontstash.c.v +++ b/vlib/fontstash/fontstash.c.v @@ -21,8 +21,6 @@ $if windows { pub type Context = C.FONScontext //#flag -lfreetype -// TODO: fontstash.used_import is used to keep v from warning about unused imports -pub const used_import = 1 pub const invalid = C.FONS_INVALID // create_internal returns a fontstash Context allocated on the heap. diff --git a/vlib/gx/text.c.v b/vlib/gx/text.c.v index 80a133de19..6a8eeedd03 100644 --- a/vlib/gx/text.c.v +++ b/vlib/gx/text.c.v @@ -1,8 +1,6 @@ module gx -import fontstash - -const used_import = fontstash.used_import +import fontstash as _ pub enum HorizontalAlign { left = C.FONS_ALIGN_LEFT diff --git a/vlib/json/cjson/cjson_wrapper.c.v b/vlib/json/cjson/cjson_wrapper.c.v index b4131e29a1..e9899661bb 100644 --- a/vlib/json/cjson/cjson_wrapper.c.v +++ b/vlib/json/cjson/cjson_wrapper.c.v @@ -28,8 +28,6 @@ pub: // TODO: `@string &char` from above does not work. It should be fixed, at least inside `struct C.`. } -pub const used = 1 - pub type Node = C.cJSON fn C.cJSON_Version() &char diff --git a/vlib/json/json_primitives.c.v b/vlib/json/json_primitives.c.v index 828f5e6ffa..ac3345d917 100644 --- a/vlib/json/json_primitives.c.v +++ b/vlib/json/json_primitives.c.v @@ -8,8 +8,6 @@ module json #include "cJSON.h" #define js_get(object, key) cJSON_GetObjectItemCaseSensitive((object), (key)) -pub const used = 1 - pub struct C.cJSON { valueint int valuedouble f64 diff --git a/vlib/net/mbedtls/mbedtls.c.v b/vlib/net/mbedtls/mbedtls.c.v index fc72ca69d8..8b6cfe6372 100644 --- a/vlib/net/mbedtls/mbedtls.c.v +++ b/vlib/net/mbedtls/mbedtls.c.v @@ -1,7 +1,5 @@ module mbedtls -pub const is_used = 1 - #flag -I @VEXEROOT/thirdparty/mbedtls/library #flag -I @VEXEROOT/thirdparty/mbedtls/include // #flag -D _FILE_OFFSET_BITS=64 diff --git a/vlib/net/mbedtls/mbedtls_compiles_test.v b/vlib/net/mbedtls/mbedtls_compiles_test.v index b5dfd2e3f1..3434ce42f8 100644 --- a/vlib/net/mbedtls/mbedtls_compiles_test.v +++ b/vlib/net/mbedtls/mbedtls_compiles_test.v @@ -1,6 +1,5 @@ -import net.mbedtls +import net.mbedtls as _ fn test_mbedtls_compiles() { - assert mbedtls.is_used == 1 assert true } diff --git a/vlib/net/openssl/openssl.c.v b/vlib/net/openssl/openssl.c.v index 1012da6072..e407a6f82b 100644 --- a/vlib/net/openssl/openssl.c.v +++ b/vlib/net/openssl/openssl.c.v @@ -156,8 +156,6 @@ fn init() { } } -pub const is_used = true - // ssl_error returns non error ssl code or error if unrecoverable and we should panic fn ssl_error(ret int, ssl voidptr) !SSLError { res := C.SSL_get_error(ssl, ret) diff --git a/vlib/net/openssl/openssl_compiles_test.c.v b/vlib/net/openssl/openssl_compiles_test.c.v index 32e72ad503..1284ec15c5 100644 --- a/vlib/net/openssl/openssl_compiles_test.c.v +++ b/vlib/net/openssl/openssl_compiles_test.c.v @@ -1,4 +1,4 @@ -import net.openssl +import net.openssl as _ struct Abc { x &C.SSL_CTX @@ -10,8 +10,3 @@ fn test_printing_struct_with_reference_field_of_type_ssl_ctx() { sa := a.str() assert sa.contains('&C.SSL_CTX(0x7b)') } - -fn test_openssl_compiles() { - assert openssl.is_used - assert true -} diff --git a/vlib/sokol/c/declaration.c.v b/vlib/sokol/c/declaration.c.v index 96cd75c19d..a54668cea2 100644 --- a/vlib/sokol/c/declaration.c.v +++ b/vlib/sokol/c/declaration.c.v @@ -1,7 +1,5 @@ module c -pub const used_import = 1 - #flag -I @VEXEROOT/thirdparty/sokol #flag -I @VEXEROOT/thirdparty/sokol/util #flag freebsd -I /usr/local/include diff --git a/vlib/sokol/f/f.v b/vlib/sokol/f/f.v index cb389434ad..ce1998bf1d 100644 --- a/vlib/sokol/f/f.v +++ b/vlib/sokol/f/f.v @@ -1,9 +1,7 @@ module f -import fontstash -import sokol.c - -pub const used_import = fontstash.used_import + c.used_import +import fontstash as _ +import sokol.c as _ #flag linux -I. diff --git a/vlib/sokol/gfx/gfx.c.v b/vlib/sokol/gfx/gfx.c.v index 3d0451b4a5..f3c7e220a5 100644 --- a/vlib/sokol/gfx/gfx.c.v +++ b/vlib/sokol/gfx/gfx.c.v @@ -1,12 +1,10 @@ module gfx -import sokol.c +import sokol.c as _ import sokol.memory pub const version = 1 -pub const used_import = c.used_import - // setup initialises the SOKOL's gfx library, based on the information passed in `desc` pub fn setup(desc &Desc) { if desc.allocator.alloc_fn == unsafe { nil } && desc.allocator.free_fn == unsafe { nil } { diff --git a/vlib/sokol/sapp/sapp.c.v b/vlib/sokol/sapp/sapp.c.v index 29f8e5f2c0..a9b0166a89 100644 --- a/vlib/sokol/sapp/sapp.c.v +++ b/vlib/sokol/sapp/sapp.c.v @@ -4,8 +4,6 @@ module sapp import sokol.gfx import sokol.memory -pub const used_import = gfx.used_import - // Android needs a global reference to `g_desc` __global g_desc C.sapp_desc diff --git a/vlib/sokol/sfons/sfons.c.v b/vlib/sokol/sfons/sfons.c.v index 675b476bc3..fb72fe93d8 100644 --- a/vlib/sokol/sfons/sfons.c.v +++ b/vlib/sokol/sfons/sfons.c.v @@ -1,12 +1,9 @@ module sfons import fontstash -import sokol.f +import sokol.f as _ import sokol.memory -// keep v from warning about unused imports -const used_import = f.used_import + fontstash.used_import + 1 - // create a new Context/font atlas, for rendering glyphs, given its dimensions `width` and `height` @[inline] pub fn create(width int, height int, flags int) &fontstash.Context { diff --git a/vlib/sokol/sokol.v b/vlib/sokol/sokol.v index 50a6a98244..8cff28985d 100644 --- a/vlib/sokol/sokol.v +++ b/vlib/sokol/sokol.v @@ -1,17 +1,13 @@ module sokol -import sokol.c -import sokol.f +import sokol.c as _ +import sokol.f as _ -pub const used_import = c.used_import + f.used_import - -/* -pub enum Key { - up=C.SAPP_KEYCODE_UP - left = C.SAPP_KEYCODE_LEFT - right =C.SAPP_KEYCODE_RIGHT - down = C.SAPP_KEYCODE_DOWN +/* pub enum Key { + up = C.SAPP_KEYCODE_UP + left = C.SAPP_KEYCODE_LEFT + right = C.SAPP_KEYCODE_RIGHT + down = C.SAPP_KEYCODE_DOWN escape = C.SAPP_KEYCODE_ESCAPE - space = C.SAPP_KEYCODE_SPACE -} -*/ + space = C.SAPP_KEYCODE_SPACE +} */ diff --git a/vlib/sync/channels.c.v b/vlib/sync/channels.c.v index 1c5cefb031..8a91b46848 100644 --- a/vlib/sync/channels.c.v +++ b/vlib/sync/channels.c.v @@ -2,9 +2,6 @@ module sync import time import rand -import sync.stdatomic - -const aops_used = stdatomic.used // how often to try to get data without blocking before to wait for semaphore const spinloops = 750 diff --git a/vlib/sync/stdatomic/1.declarations.c.v b/vlib/sync/stdatomic/1.declarations.c.v index 37c9fd6e30..997bf0c042 100644 --- a/vlib/sync/stdatomic/1.declarations.c.v +++ b/vlib/sync/stdatomic/1.declarations.c.v @@ -86,5 +86,3 @@ fn C.atomic_compare_exchange_strong_u64(voidptr, voidptr, u64) bool fn C.atomic_exchange_u64(voidptr, u64) u64 fn C.atomic_fetch_add_u64(voidptr, u64) u64 fn C.atomic_fetch_sub_u64(voidptr, u64) u64 - -pub const used = 1 diff --git a/vlib/v/checker/tests/import_mod_as_duplicate_err.out b/vlib/v/checker/tests/import_mod_as_duplicate_err.out index 57e543a7b6..0ff7cfe192 100644 --- a/vlib/v/checker/tests/import_mod_as_duplicate_err.out +++ b/vlib/v/checker/tests/import_mod_as_duplicate_err.out @@ -4,7 +4,7 @@ vlib/v/checker/tests/import_mod_as_duplicate_err.vv:3:16: error: cannot import ` 3 | import json as json2 | ~~~~~ 4 | - 5 | const used = true + 5 | _ := json2.encode('foo') vlib/v/checker/tests/import_mod_as_duplicate_err.vv:1:1: error: project must include a `main` module or be a shared library (compile with `v -shared`) 1 | module json2 | ^ diff --git a/vlib/v/checker/tests/import_mod_as_duplicate_err.vv b/vlib/v/checker/tests/import_mod_as_duplicate_err.vv index 4bf7ab642c..5b169cbb4d 100644 --- a/vlib/v/checker/tests/import_mod_as_duplicate_err.vv +++ b/vlib/v/checker/tests/import_mod_as_duplicate_err.vv @@ -2,6 +2,4 @@ module json2 import json as json2 -const used = true - -println(json2.used) +_ := json2.encode('foo') diff --git a/vlib/v/checker/tests/modules/module_with_redeclaration/redeclare_time_structs.c.v b/vlib/v/checker/tests/modules/module_with_redeclaration/redeclare_time_structs.c.v index eed8106cd0..48b0968d4c 100644 --- a/vlib/v/checker/tests/modules/module_with_redeclaration/redeclare_time_structs.c.v +++ b/vlib/v/checker/tests/modules/module_with_redeclaration/redeclare_time_structs.c.v @@ -2,8 +2,6 @@ module module_with_redeclaration import sokol.memory -pub const used = 1 - @[typedef] pub struct C.saudio_allocator { pub mut: diff --git a/vlib/v/embed_file/embed_file.v b/vlib/v/embed_file/embed_file.v index 289e960d26..222383c447 100644 --- a/vlib/v/embed_file/embed_file.v +++ b/vlib/v/embed_file/embed_file.v @@ -1,7 +1,5 @@ module embed_file -pub const is_used = 1 - // EmbedFileData encapsulates functionality for the `$embed_file()` compile time call. pub struct EmbedFileData { apath string diff --git a/vlib/v/gen/c/testdata/gui_windows_program.vv b/vlib/v/gen/c/testdata/gui_windows_program.vv index de683ef269..0cc64e2fd1 100644 --- a/vlib/v/gen/c/testdata/gui_windows_program.vv +++ b/vlib/v/gen/c/testdata/gui_windows_program.vv @@ -1,7 +1,5 @@ // vtest vflags: -os windows -import sokol - -const used_import = sokol.used_import +import sokol as _ fn main() { println('hello world') diff --git a/vlib/v/gen/c/testdata/gui_windows_program_with_console_tag.vv b/vlib/v/gen/c/testdata/gui_windows_program_with_console_tag.vv index 603c4e25ff..000d037fdd 100644 --- a/vlib/v/gen/c/testdata/gui_windows_program_with_console_tag.vv +++ b/vlib/v/gen/c/testdata/gui_windows_program_with_console_tag.vv @@ -1,7 +1,5 @@ // vtest vflags: -os windows -import sokol - -const used_import = sokol.used_import +import sokol as _ @[console] fn main() { diff --git a/vlib/v/live/common.c.v b/vlib/v/live/common.c.v index 48becbb5dc..adffe7a244 100644 --- a/vlib/v/live/common.c.v +++ b/vlib/v/live/common.c.v @@ -1,7 +1,5 @@ module live -pub const is_used = 1 - pub type FNLinkLiveSymbols = fn (linkcb voidptr) pub type FNLiveReloadCB = fn (info &LiveReloadInfo) diff --git a/vlib/v/live/executable/reloader.c.v b/vlib/v/live/executable/reloader.c.v index 768fcad207..79104abeb0 100644 --- a/vlib/v/live/executable/reloader.c.v +++ b/vlib/v/live/executable/reloader.c.v @@ -5,8 +5,6 @@ import time import dl import v.live -pub const is_used = 1 - // The live reloader code is implemented here. // Note: new_live_reload_info will be called by generated C code inside main() @[markused] diff --git a/vlib/v/live/sharedlib/live_sharedlib.v b/vlib/v/live/sharedlib/live_sharedlib.v index b9a600ec6d..e19b418b82 100644 --- a/vlib/v/live/sharedlib/live_sharedlib.v +++ b/vlib/v/live/sharedlib/live_sharedlib.v @@ -1,5 +1,3 @@ module sharedlib -import v.live - -pub const is_used = live.is_used + 1 +import v.live as _ diff --git a/vlib/v/preludes/embed_file/embed_file.v b/vlib/v/preludes/embed_file/embed_file.v index 86042ed116..0c0f8abb32 100644 --- a/vlib/v/preludes/embed_file/embed_file.v +++ b/vlib/v/preludes/embed_file/embed_file.v @@ -1,7 +1,5 @@ -module embed_file - // This prelude is loaded in every v program that uses `$embed_file`, // in both the main executable, and in the shared library. -import v.embed_file +module embed_file -const no_warning_embed_file_is_used = embed_file.is_used +import v.embed_file as _ diff --git a/vlib/v/preludes/live.v b/vlib/v/preludes/live.v index 429aa6a989..e4b79dfb17 100644 --- a/vlib/v/preludes/live.v +++ b/vlib/v/preludes/live.v @@ -1,7 +1,5 @@ -module main - // This prelude is loaded in every v program compiled with -live, // in both the main executable, and in the shared library. -import v.live +module main -const no_warning_live_is_used = live.is_used +import v.live as _ diff --git a/vlib/v/preludes/live_main.v b/vlib/v/preludes/live_main.v index 22e13c667f..9b28c934c8 100644 --- a/vlib/v/preludes/live_main.v +++ b/vlib/v/preludes/live_main.v @@ -1,7 +1,5 @@ -module main - // This prelude is loaded in every v program compiled with -live, // but only for the main executable. -import v.live.executable +module main -const no_warning_live_executable_is_used = executable.is_used +import v.live.executable as _ diff --git a/vlib/v/preludes/live_shared.v b/vlib/v/preludes/live_shared.v index 266f2604d5..1c80879027 100644 --- a/vlib/v/preludes/live_shared.v +++ b/vlib/v/preludes/live_shared.v @@ -1,7 +1,5 @@ -module main - // This prelude is loaded in every v program compiled with -live, // but only for the shared library. -import v.live.sharedlib +module main -const no_warning_live_shared_is_used = sharedlib.is_used +import v.live.sharedlib as _ diff --git a/vlib/v/preludes/trace_calls.v b/vlib/v/preludes/trace_calls.v index 30555f204a..2fb5f5168b 100644 --- a/vlib/v/preludes/trace_calls.v +++ b/vlib/v/preludes/trace_calls.v @@ -1,5 +1,3 @@ module main -import v.trace_calls - -const trace_calls_used = trace_calls.is_used +import v.trace_calls as _ diff --git a/vlib/v/trace_calls/tracing_calls.c.v b/vlib/v/trace_calls/tracing_calls.c.v index 93fda5e958..f96aa2c4ab 100644 --- a/vlib/v/trace_calls/tracing_calls.c.v +++ b/vlib/v/trace_calls/tracing_calls.c.v @@ -5,8 +5,6 @@ module trace_calls __global g_stack_base = &u8(0) __global g_start_time = u64(0) -pub const is_used = 1 - @[markused] pub fn on_call(fname string) { mut volatile pfbase := unsafe { &u8(0) }