Skip to content

feat: lints for enum-name and constructor-name repetition#811

Merged
ivov merged 2 commits into
mainfrom
name-repetition-lints
Jun 21, 2026
Merged

feat: lints for enum-name and constructor-name repetition#811
ivov merged 2 commits into
mainfrom
name-repetition-lints

Conversation

@ivov

@ivov ivov commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Adds two diagnostics that flag a name repeating the type it is already qualified by.

  [info] Variant names repeat the enum name
   ╭─[test.lis:2:6]
 1 │ 
 2 │ enum Color { ColorRed, ColorGreen }
   ·      ──┬──
   ·        ╰── each variant repeats this name
 3 │ 
   ╰────
  help: Drop the `Color` prefix from each variant (`ColorRed` to `Red`). A variant is already written as `Color.Red`, so the prefix repeats the enum name · code: [lint.enum_variant_names]
  [info] Constructor named after its type
   ╭─[test.lis:5:6]
 4 │ impl Point {
 5 │   fn point(x: int) -> Point {
   ·      ──┬──
   ·        ╰── repeats the type name
 6 │     Point { x }
   ╰────
  help: Calling this as `Point.point()` repeats the type name. Rename it to `new`, the conventional constructor name · code: [lint.self_named_constructors]

@ivov ivov merged commit 2c20bc0 into main Jun 21, 2026
16 checks passed
@ivov ivov mentioned this pull request Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant