@@ -12,24 +12,38 @@ LL | __rust_alloc(layout.size(), layout.align())
12
12
note: inside closure
13
13
--> $DIR/leak_in_tls.rs:LL:CC
14
14
|
15
- LL | let b = Box::new(a );
16
- | ^^^^^^^^^^^
15
+ LL | cell.set(Some( Box::leak(Box:: new(123))) );
16
+ | ^^ ^^^^^^^^^^^
17
17
= note: inside `std::thread::LocalKey::<std::cell::Cell<std::option::Option<&i32>>>::try_with::<[closure@$DIR/leak_in_tls.rs:LL:CC], ()>` at RUSTLIB/std/src/thread/local.rs:LL:CC
18
18
= note: inside `std::thread::LocalKey::<std::cell::Cell<std::option::Option<&i32>>>::with::<[closure@$DIR/leak_in_tls.rs:LL:CC], ()>` at RUSTLIB/std/src/thread/local.rs:LL:CC
19
19
note: inside closure
20
20
--> $DIR/leak_in_tls.rs:LL:CC
21
21
|
22
- LL | / REF.with(|cell| {
23
- LL | | let a = 123;
24
- LL | | let b = Box::new(a);
25
- LL | | let r = Box::leak(b);
26
- LL | | cell.set(Some(r));
27
- LL | | })
22
+ LL | / TLS_KEY.with(|cell| {
23
+ LL | | cell.set(Some(Box::leak(Box::new(123))));
24
+ LL | | });
28
25
| |__________^
29
26
27
+ error: memory leaked: ALLOC (Rust heap, size: 4, align: 4), allocated here:
28
+ --> RUSTLIB/alloc/src/alloc.rs:LL:CC
29
+ |
30
+ LL | __rust_alloc(layout.size(), layout.align())
31
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32
+ |
33
+ = note: inside `std::alloc::alloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
34
+ = note: inside `std::alloc::Global::alloc_impl` at RUSTLIB/alloc/src/alloc.rs:LL:CC
35
+ = note: inside `<std::alloc::Global as std::alloc::Allocator>::allocate` at RUSTLIB/alloc/src/alloc.rs:LL:CC
36
+ = note: inside `alloc::alloc::exchange_malloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
37
+ = note: inside `std::boxed::Box::<i32>::new` at RUSTLIB/alloc/src/boxed.rs:LL:CC
38
+ note: inside closure
39
+ --> $DIR/leak_in_tls.rs:LL:CC
40
+ |
41
+ LL | TLS.set(Some(Box::leak(Box::new(123))));
42
+ | ^^^^^^^^^^^^^
43
+
30
44
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
31
45
32
46
note: the evaluated program leaked memory, pass `-Zmiri-ignore-leaks` to disable this check
33
47
34
- error: aborting due to previous error
48
+ error: aborting due to 2 previous errors
35
49
0 commit comments