Created
May 28, 2019 13:18
-
-
Save Licenser/124a4394ef71100e112db8708999558c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn bad_fn<'script, 'event, 'run, Ctx>( | |
&'script self, | |
context: &'run Ctx, | |
event: &'run mut Value<'event>, | |
meta: &'run mut Value<'event>, | |
local: &'run mut Value<'event>, | |
path: &'run ast::Path, | |
value: &'run Value<'event>, | |
stack: &'run ValueStack<'event>, | |
) -> Result<Value<'event>, Error> | |
where | |
Ctx: Context + 'static, | |
'script: 'event, | |
'event: 'run, | |
{ | |
// ... | |
let e := expr.run(context, event, meta, local, stack)?; | |
// ... | |
} | |
/* | |
error[E0623]: lifetime mismatch | |
--> src/interpreter.rs:307:54 | |
| | |
282 | context: &'run Ctx, | |
| --------- these two types are declared with different lifetimes... | |
283 | event: &'run mut Value<'event>, | |
| ------------- | |
... | |
307 | 1 => match exprs[0].run(context, event, meta, local, stack)? { | |
| ^^^^^ ...but data from `context` flows into `event` here | |
*/ | |
// Solution: change the lifetime of 'path' to 'script' | |
fn bad_fn<'script, 'event, 'run, Ctx>( | |
&'script self, | |
context: &'run Ctx, | |
event: &'run mut Value<'event>, | |
meta: &'run mut Value<'event>, | |
local: &'run mut Value<'event>, | |
path: &'script ast::Path, | |
value: &'run Value<'event>, | |
stack: &'run ValueStack<'event>, | |
) -> Result<Value<'event>, Error> | |
where | |
Ctx: Context + 'static, | |
'script: 'event, | |
'event: 'run, | |
{ | |
// ... | |
let e := expr.run(context, event, meta, local, stack)?; | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment