Skip to content

U0017 ui-tooltip-repeats-label

Rule: A tooltip says more than the label it is attached to.

Code U0017 (stable, never reused)
Id ui-tooltip-repeats-label
Category ui
Source spirit_level
Fix by hand

Level per tier

Tier Level Reason
small off
small-workspace off
medium off
big off
ai off
embedded off
ui warn a tooltip that only repeats the label cost the person a hover for nothing; certain, since the match is exact
egui warn a tooltip that only repeats the label cost the person a hover for nothing; certain, since the match is exact
units-strict off
units-paranoid off

Parameters

Name Type Default Meaning
label-calls list of strings [] calls that give a control its label
hover-calls list of strings [] calls that attach a tooltip
toolkits list of strings ["egui", "eframe", "iced", "slint", "gtk4", "relm4", "dioxus", "leptos", "yew", "floem", "xilem", "makepad-widgets"] UI toolkits: a crate that depends on one directly is a UI crate, unless the crate map says ui = false

Why

A tooltip earns its place by saying what the label cannot: what a control does, a shortcut, a constraint, or what happens next. A tooltip that repeats the label word for word gives the person reading it nothing new, and costs the same hover they already paid for the label.

The lint reports a call of hover-calls whose text is exactly the text of the label-calls call it is attached to, reached through its receiver chain.

ui.button("Save").on_hover_text("Save");          // reported: the tooltip adds nothing
ui.button("Save").on_hover_text("Ctrl+S");         // passes: it adds the shortcut
ui.add(Button::new("Save")).on_hover_text("Save"); // reported: the label is found through `add`

How to fix

Say what the label cannot, or remove the tooltip.

Configure

[lints.ui-tooltip-repeats-label]
level = "deny"
label-calls = []
hover-calls = []
toolkits = ["egui", "eframe", "iced", "slint", "gtk4", "relm4", "dioxus", "leptos", "yew", "floem", "xilem", "makepad-widgets"]
reason = "why this project wants it at this level"

Allow one finding in the code with // spirit-level: allow(ui-tooltip-repeats-label) <reason> (waivers); the code works there too, as in [lints.U0017].