Skip to content

1.96 beta regression: "lua does not live long enough" #154988

@theemathas

Description

@theemathas

Regression found by the 1.95 beta crater "rerun", done to check whether #154074 (which got backported to beta in #154725) causes any regressions. (This PR was initially done to fix #153850.)

[INFO] [stdout] error[E0597]: `lua` does not live long enough
[INFO] [stdout]   --> /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/shulkerscript-0.1.0/src/transpile/lua.rs:51:30
[INFO] [stdout]    |
[INFO] [stdout] 18 |         #[tracing::instrument(level = "debug", name = "eval_lua", skip_all, ret)]
[INFO] [stdout]    |                                                                                 - ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `(LuaValue<'_>,)`
[INFO] [stdout] ...
[INFO] [stdout] 25 |             let lua = Lua::new();
[INFO] [stdout]    |                 --- binding `lua` declared here
[INFO] [stdout] ...
[INFO] [stdout] 51 |             let lua_result = lua
[INFO] [stdout]    |                              ^^^ borrowed value does not live long enough
[INFO] [stdout] ...
[INFO] [stdout] 62 |             self.handle_lua_result(dbg!(lua_result)).map_err(|err| {
[INFO] [stdout]    |                                    ---------------- a temporary with access to the borrow is created here ...
[INFO] [stdout] ...
[INFO] [stdout] 66 |         }
[INFO] [stdout]    |         - `lua` dropped here while still borrowed
[INFO] [stdout]    |
[INFO] [stdout]    = note: the temporary is part of an expression at the end of a block;
[INFO] [stdout]            consider forcing this temporary to be dropped sooner, before the block's local variables are dropped
[INFO] [stdout] help: for example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block
[INFO] [stdout]    |
[INFO] [stdout] 62 ~             let x = self.handle_lua_result(dbg!(lua_result)).map_err(|err| {
[INFO] [stdout] 63 |                 handler.receive(err.clone());
[INFO] [stdout] 64 |                 err
[INFO] [stdout] 65 ~             }); x
[INFO] [stdout]    |

cc @dianne

Metadata

Metadata

Assignees

Labels

A-destructorsArea: Destructors (`Drop`, …)A-fmtArea: `core::fmt`A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.P-criticalCritical priorityS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-libsRelevant to the library team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions