0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-12-25 00:29:14 -05:00

Add compile_fail test for boxed Local (#275)

This commit is contained in:
Ryan Dahl 2020-02-12 17:45:14 -05:00 committed by GitHub
parent d893a050c0
commit 47aafbc62e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 0 deletions

View 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!()
}

View 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

View file

@ -8,6 +8,7 @@ fn ui() {
env::set_var("DENO_TRYBUILD", "1"); env::set_var("DENO_TRYBUILD", "1");
let t = trybuild::TestCases::new(); 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_escape_lifetime.rs");
t.compile_fail("tests/compile_fail/handle_scope_lifetimes.rs"); t.compile_fail("tests/compile_fail/handle_scope_lifetimes.rs");
t.compile_fail("tests/compile_fail/try_catch_lifetimes.rs"); t.compile_fail("tests/compile_fail/try_catch_lifetimes.rs");