Open
Description
Summary
I'm not quite sure how to report this, since this appears to be a false positive in a rustc
lint when using Clippy. Maybe it doesn't fully respect the lifetime changes in Edition 2024?
Under Edition 2021 I had the following code:
let mut messages = MessageStack::new();
let widget = self.widget.as_node(&state.data);
if Some(requested_resume) == self.ev_state.next_resume() {
self.ev_state
.with(&mut state.shared, window, &mut messages, |cx| {
cx.update_timer(widget);
});
} else {
drop(widget); // make the borrow checker happy
}
With Edition 2024, the explicit drop(widget)
is no longer necessary (cargo check
passses), yet Clippy still complains:
error[E0502]: cannot borrow `*state` as mutable because it is also borrowed as immutable
--> crates/kas-core/src/runner/window.rs:392:9
|
383 | let widget = self.widget.as_node(&state.data);
| ----------- immutable borrow occurs here
...
392 | state.handle_messages(&mut messages);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
393 | }
| - immutable borrow might be used here, when `widget` is dropped and runs the destructor for type `core::node::Node<'_>`
See kas-gui/kas#514
Using: rustc 1.90.0-nightly (b03b3a7ec 2025-06-26)
Using: clippy 0.1.89 (b03b3a7ec9 2025-06-26)