Skip to content

U0015 egui-panel-api

Rule: Egui panel and App code uses the API the version in use ships, never one it replaced.

Code U0015 (stable, never reused)
Id egui-panel-api
Category egui
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 off
egui warn panel and App code written for an older egui keeps compiling under a deprecation warning, then breaks on the next bump; an estimate, without type information
units-strict off
units-paranoid off

Parameters

Name Type Default Meaning
constructors list of strings ["SidePanel::*", "TopBottomPanel::*"] constructors of panel types the egui version in use replaced with a single Panel; any call on their chain is flagged, * matches within a segment
context-types list of strings ["CentralPanel::*"] constructors whose context-method directly on a Context the egui version in use replaced with show_inside on a Ui
context-method string "show" the method that shows a panel directly on a Context
app-traits list of strings ["App", "eframe::App"] traits whose impl is an app's entry point
app-method string "update" the trait method the egui version in use replaced
replacement string "Panel,.show_insideon the Ui (not.showon the Context), andApp::ui(notApp::update)" what replaces the flagged API, named in the help
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

egui's panel and app entry-point API moves: SidePanel and TopBottomPanel are replaced by a single Panel, showing a panel directly on a Context (.show) is replaced by .show_inside on a Ui, and eframe::App::update(&mut self, ctx, frame) is replaced by App::ui, which takes a &mut Ui. Code written against an older egui keeps compiling for a while under a deprecation warning, then breaks on the next bump; this lint catches it at review time, project by project.

The lint reports, in UI crates:

  • a constructor matching constructors (SidePanel::*, TopBottomPanel::*), resolved through the file's use items, and any method later in its chain: the whole type is replaced, not one method of it;
  • a context-method call (show) whose chain is rooted in a context-types constructor (CentralPanel::*): showing it directly on a Context instead of .show_inside on a Ui;
  • an impl of one of app-traits (App, eframe::App) whose method is named app-method (update).

Because constructors, context-types, app-traits and app-method are parameters, a later egui release that replaces another piece of the panel or app API needs a tier change, not a new lint. Findings are estimates: the lint has no type information, so a chain stored in a variable before its .show call is not seen.

How to fix

Follow egui's own migration notes for the version in use: build panels from Panel, show them with .show_inside on the Ui that holds them, and move an app's per-frame code from App::update to App::ui. Where a dependency still pins an egui version that lacks the replacement, waive the finding with that reason.

Configure

[lints.egui-panel-api]
level = "deny"
constructors = ["SidePanel::*", "TopBottomPanel::*"]
context-types = ["CentralPanel::*"]
context-method = "show"
app-traits = ["App", "eframe::App"]
app-method = "update"
replacement = "Panel, `.show_inside` on the Ui (not `.show` on the Context), and `App::ui` (not `App::update`)"
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(egui-panel-api) <reason> (waivers); the code works there too, as in [lints.U0015].