Skip to content

1.96 beta regression: "lua does not live long enough", take 2 #155902

@theemathas

Description

@theemathas

Turns out that the #154988 regression wasn't completely fixed by the #154994 PR. (That regression was in turn caused by #154074, which fixes the #153850 regression).

Regression found by the 1.96 beta crater run.

[INFO] [stdout] error[E0597]: `lua` does not live long enough
[INFO] [stdout]   --> src/transpile/lua.rs:51:30
[INFO] [stdout]    |
[INFO] [stdout] 18 |         #[tracing::instrument(level = "debug", name = "eval_lua", skip_all, ret)]
[INFO] [stdout]    |                                                                                 -
[INFO] [stdout]    |                                                                                 |
[INFO] [stdout]    |                                                                                 `lua` dropped here while still borrowed
[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]    = 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]    |
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] For more information about this error, try `rustc --explain E0597`.

cc @dianne

Metadata

Metadata

Assignees

Labels

A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-borrow-checkerArea: The borrow checkerA-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-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-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

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions