Skip to content

The deallocation span of locals that are deallocated by a tail call become is nonsense #4863

@RalfJung

Description

@RalfJung

Test code:

#![feature(explicit_tail_calls)]
#![allow(incomplete_features)]

fn g(x: *const i32) {
    let _val = unsafe { *x }; //~ERROR: has been freed, so this pointer is dangling
}

fn f(_x: *const i32) {
    let local = 0;
    let ptr = &local as *const i32;
    become g(ptr)
}

fn main() {
    f(std::ptr::null());
}

The deallocation span used to be

help: ALLOC was deallocated here:
  --> tests/fail/tail_calls/dangling-local-var.rs:LL:CC
   |
LL |     f(std::ptr::null());
   |     ^^^^^^^^^^^^^^^^^^^

now it is

help: ALLOC was deallocated here:
  --> tests/fail/tail_calls/dangling-local-var.rs:LL:CC
   |
LL |     let _val = unsafe { *x };
   |         ^^^^

Both of these make no sense. I think the ideal span would be to point at the become.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions