Skip to content

feat(lint)!: exempt From<_> for Element, the widget idiom - #5

Merged
rsansores merged 1 commit into
mainfrom
lint_widget_element_exemption
Oct 25, 2026
Merged

rsansores merged 1 commit into
mainfrom
lint_widget_element_exemption

Conversation

@rsansores

Copy link
Copy Markdown
Owner

magic-map-lint flags every hand-written From/Into/TryFrom/TryInto, with an exemption for error conversions and an allowlist that only shrinks. A UI built on iced has one impl From<Component> for Element per design-system component — the toolkit's idiom for column![Button::new(..)] — so the allowlist of a project with a design system (quickedge: 33 lines today) grows with every component, and a bare type name on that list would also let the same impl through anywhere else.

This adds a third exemption beside the *Error rule: From into a type named Element is a widget becoming what a view returns, not a data mapping. Into<Element> and From<Element> are still flagged.

  • Tests for the new rule and the old ones (cargo test -p magic_map_lint: 4 pass; clippy clean).
  • Run against quickedge: with its current allowlist the 33 … for Element lines come out stale and nothing else changes; without them the run passes.
  • Breaking for an allowlist that lists these impls (they go stale and fail the run), so magic_map_lint goes to 0.5.0. The README's exemption list is updated.

Not published: after merge, cargo publish -p magic_map_lint, then quickedge bumps magic_map_lint_version and drops the 33 lines.

🤖 Generated with Claude Code

A UI toolkit such as iced lets a component sit in a layout through
`impl From<Component> for Element`, so a design system has one per
component and an allowlist had to grow with every new one. From into a
type named Element is a widget becoming what a view returns, not a data
mapping: it is exempt, like the *Error conversions. Into<Element> and
From<Element> are still flagged.

Breaking for an allowlist that listed these impls: its entries are now
stale and fail the run until removed. magic_map_lint 0.5.0.
@rsansores
rsansores merged commit 5e0a683 into main Oct 25, 2026
1 check passed
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