Skip to content

DestructionScopeData can leak into error messages #27942

Closed
@arielb1

Description

@arielb1
pub trait Resources<'a> {}

pub trait Buffer<'a, R: Resources<'a>> {
    fn select(&self) -> BufferViewHandle<R>; // should be BufferViewHandle<'a, R>
}

pub struct BufferViewHandle<'a, R: 'a+Resources<'a>>(&'a R);

fn main() {}

Post-RFC1214, this gives the not-particularly-comprehensible error message

<anon>:6:5: 6:45 error: mismatched types:
 expected `Resources<'_>`,
    found `Resources<'a>`
(lifetime mismatch) [E0308]
<anon>:6     fn select(&self) -> BufferViewHandle<R>;
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<anon>:6:5: 6:45 help: see the detailed explanation for E0308
note: the anonymous lifetime #1 defined on unknown free region bounded by scope DestructionScopeData { node_id: 9 }...
note: ...does not necessarily outlive the lifetime 'a as defined on unknown free region bounded by scope DestructionScopeData { node_id: 9 }
<anon>:6:5: 6:45 error: mismatched types:
 expected `Resources<'_>`,
    found `Resources<'a>`
(lifetime mismatch) [E0308]
<anon>:6     fn select(&self) -> BufferViewHandle<R>;
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<anon>:6:5: 6:45 help: see the detailed explanation for E0308
note: the lifetime 'a as defined on unknown free region bounded by scope DestructionScopeData { node_id: 9 }...
note: ...does not necessarily outlive the anonymous lifetime #1 defined on unknown free region bounded by scope DestructionScopeData { node_id: 9 }
error: aborting due to 2 previous errors

In general, debug output of compiler structs shouldn't leak into error messages (also see #13998).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions