Skip to content

References to local variables are considered to need dropping if a local variable does #90193

Description

@tmiasko

For example, function f is rejected with an error that a needs dropping, while g succeeds even though it should use more conservative qualification because it uses an opaque function id:

pub const fn id<T>(t: T) -> T { t }

pub const fn f() -> String {
    let s = String::new();
    let mut a: (Option<String>, Option<&String>) = (None, None);
    a.1 = Some(&s);
    s
}

pub const fn g() -> String {
    let s = String::new();
    let mut a: (Option<String>, Option<&String>) = (None, None);
    a.1 = Some(id(&s));
    s
}

@rustbot label +A-const-eval +A-const-fn

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions