Files
lucisv/crates/vlog_linter/src/rules/mod.rs
T
lucioandClaude Fable 5.1 e6eaf53c35
ci / checks (push) Successful in 1m2s
ci / corpus (push) Successful in 47s
Organize imports: unused imports removed, duplicates merged, the run sorted; the unused-import rule; source.organizeImports
TODO §52 (docs/features/organize-imports), the third §8 refactoring.

The judgement lives in `vlog_semantic::imports` (one implementation for
the refactoring and the rule): an import is used when a reference in its
scope, or one nested in it, resolves to a member of the package through
it — `resolve::lexical`'s walk stopped at the scope, every import whose
path admits the name and whose package exports it (binder tables
same-file, `members_of_chain` with re-exports otherwise) marked used, a
deliberate superset; a qualified `p::y` and an import's own package name
never count; an `export p::x` / `export p::*` / `export *::*` in the
scope marks the import it re-exports through as used (IEEE 1800 §26.6 —
the review rework of QA's HIGH, pinned four ways). Refuse to judge: an
unknown or twice-declared package, a macro call or conditional directive
anywhere in the scope, a class with an out-of-file base, a parse
diagnostic, two imports on one line. `vlog_refactor::organize_imports`
deletes the unused lines, merges exact duplicates, sorts the run at the
scope's top (package, item, `*` first), keeps every comment; the
verifier's resolution check refuses a removal a reference needs (attack
pair). `unused-import` (Style, off; safe fix) through
`MentionOracle::package_exports`, silent without a project. Server:
`lucisv: organize imports (removes N, sorts M)` under
`source.organizeImports`, `lucisv.organizeImports`.

Corpus: 40 scopes with ≥ 2 imports, 1 organized, 32 refused for macros;
the rule finds 2, both substantiated. opentitan: 33 of 33 UVM env
packages refused (`` `include "uvm_macros.svh" ``). 0 of 860 corpus
files differ from 0.46.0.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-05 20:00:31 -05:00

84 lines
2.6 KiB
Rust

//! The rules themselves, one module each.
//!
//! Most rules are **syntactic** — text, tokens or tree shape. The ones that
//! are not read the symbol table: `unused-signal`, `undriven-net` and
//! `multiply-driven` through `crate::signals` (see
//! `docs/features/semantic-lints/README.md`), and `duplicate-declaration` and
//! `instance-shadowing` through `vlog_semantic::Semantics` directly (see
//! `docs/features/linter-expansion-1/README.md`).
pub mod always_comb;
pub mod always_comb_blocking;
pub mod always_ff_non_blocking;
pub mod banned_declared_name_patterns;
pub mod case_missing_default;
pub mod constraint_name_style;
pub mod create_object_name_match;
pub mod dff_name_style;
pub mod disable_statement;
pub mod duplicate_declaration;
pub mod empty_item;
pub mod endif_comment;
pub mod enum_name_style;
pub mod explicit_begin;
pub mod explicit_function_lifetime;
pub mod explicit_function_task_parameter_type;
pub mod explicit_parameter_storage_type;
pub mod explicit_task_lifetime;
pub mod forbid_consecutive_null_statements;
pub mod forbid_defparam;
pub mod forbid_line_continuations;
pub mod forbid_negative_array_dim;
pub mod forbidden_macro;
pub mod generate_label;
pub mod generate_label_prefix;
pub mod incomplete_assignment;
pub mod instance_shadowing;
pub mod interface_name_style;
pub mod invalid_system_task_function;
pub mod legacy_generate_region;
pub mod legacy_genvar_declaration;
pub mod line_length;
pub mod macro_name_style;
pub mod macro_string_concatenation;
pub mod mismatched_labels;
pub mod module_begin_block;
pub mod module_filename;
pub mod module_name_style;
pub mod module_parameter;
pub mod module_port;
pub mod multiply_driven;
pub mod no_tabs;
pub mod no_trailing_whitespace;
pub mod numeric_format_string_style;
pub mod one_module_per_file;
pub mod package_filename;
pub mod packed_dimensions_range_ordering;
pub mod parameter_name_style;
pub mod parameter_type_name_style;
pub mod plusarg_assignment;
pub mod port_name_suffix;
pub mod positive_meaning_parameter_name;
pub mod posix_eof;
pub mod proper_parameter_declaration;
pub mod signal_name_style;
pub mod struct_union_name_style;
pub mod suggest_parentheses;
pub mod suspicious_semicolon;
pub mod truncated_numeric_literal;
pub mod typedef_enums;
pub mod typedef_structs_unions;
pub mod undeclared_identifier;
pub mod undersized_binary_literal;
pub mod undriven_net;
pub mod unknown_parameter;
pub mod unknown_port;
pub mod unpacked_dimensions_range_ordering;
pub mod unused_import;
pub mod unused_signal;
pub mod unused_waiver;
pub mod uvm_macro_semicolon;
pub mod v2001_generate_begin;
pub mod void_cast;
pub mod wire_reg_mixup;