Skip to content

U0009 ui-debug-text

Rule: Text shown to a person never holds Rust's debug formatting.

Code U0009 (stable, never reused)
Id ui-debug-text
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 Rust's debug form is for developers; a person reads what happened and what to do
egui warn Rust's debug form is for developers; a person reads what happened and what to do
units-strict off
units-paranoid off

Parameters

Name Type Default Meaning
calls list of strings [] calls that show text to a person
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

{:?} prints a value the way Rust sees it: Os { code: 2, kind: NotFound, message: "No such file or directory" }, quotes and enum variants included. That is for developers. A person reads what happened and what to do next, in plain words.

The lint reports the format strings in the arguments of calls that show a value with :? or :#?. Findings are estimates: an id shown in its debug form on purpose is fine and gets a waiver.

How to fix

Show the value with Display, or the fields that matter. An error says what failed and what the person can do: "Cannot open the project: the file is gone; pick another one".

Configure

[lints.ui-debug-text]
level = "deny"
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-debug-text) <reason> (waivers); the code works there too, as in [lints.U0009].