mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-12-24 08:09:16 -05:00
Add compile_fail test for boxed Local (#275)
This commit is contained in:
parent
d893a050c0
commit
47aafbc62e
3 changed files with 30 additions and 0 deletions
18
tests/compile_fail/boxed_local.rs
Normal file
18
tests/compile_fail/boxed_local.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Copyright 2019-2020 the Deno authors. All rights reserved. MIT license.
|
||||
use rusty_v8 as v8;
|
||||
|
||||
pub fn main() {
|
||||
let mut isolate = v8::Isolate::new(mock());
|
||||
let mut root_hs = v8::HandleScope::new(&mut isolate);
|
||||
let root_hs = root_hs.enter();
|
||||
|
||||
let _boxed = {
|
||||
let mut hs = v8::HandleScope::new(root_hs);
|
||||
let hs = hs.enter();
|
||||
Box::new(v8::Integer::new(hs, 123))
|
||||
};
|
||||
}
|
||||
|
||||
fn mock<T>() -> T {
|
||||
unimplemented!()
|
||||
}
|
11
tests/compile_fail/boxed_local.stderr
Normal file
11
tests/compile_fail/boxed_local.stderr
Normal file
|
@ -0,0 +1,11 @@
|
|||
error[E0597]: `hs` does not live long enough
|
||||
--> $DIR/boxed_local.rs:11:14
|
||||
|
|
||||
9 | let _boxed = {
|
||||
| ------ borrow later stored here
|
||||
10 | let mut hs = v8::HandleScope::new(root_hs);
|
||||
11 | let hs = hs.enter();
|
||||
| ^^ borrowed value does not live long enough
|
||||
12 | Box::new(v8::Integer::new(hs, 123))
|
||||
13 | };
|
||||
| - `hs` dropped here while still borrowed
|
|
@ -8,6 +8,7 @@ fn ui() {
|
|||
env::set_var("DENO_TRYBUILD", "1");
|
||||
|
||||
let t = trybuild::TestCases::new();
|
||||
t.compile_fail("tests/compile_fail/boxed_local.rs");
|
||||
t.compile_fail("tests/compile_fail/handle_scope_escape_lifetime.rs");
|
||||
t.compile_fail("tests/compile_fail/handle_scope_lifetimes.rs");
|
||||
t.compile_fail("tests/compile_fail/try_catch_lifetimes.rs");
|
||||
|
|
Loading…
Reference in a new issue