Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tmiasko opened this issue Oct 23, 2021 · 1 comment
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. C-bug Category: This is a bug.

Comments

@tmiasko
Copy link
Contributor

tmiasko commented Oct 23, 2021

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

@tmiasko tmiasko added the C-bug Category: This is a bug. label Oct 23, 2021
@rustbot rustbot added A-const-eval Area: Constant evaluation (MIR interpretation) A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. labels Oct 23, 2021
@oli-obk
Copy link
Contributor

oli-obk commented Oct 24, 2021

I guess the needs drop flag should not be carried through Rvalue::Ref?

tmiasko added a commit to tmiasko/rust that referenced this issue Oct 31, 2021
Noticed that this wasn't covered by any of existing tests.

The const checking and const qualification, which currently shares the
implementation with promotion, will likely need a different behaviour
here (see issue rust-lang#90193).
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 1, 2021
…r=Mark-Simulacrum

Test that promotion follows references when looking for drop

Noticed that this wasn't covered by any of existing tests.

The const checking and const qualification, which currently shares the
implementation with promotion, will likely need a different behaviour
here (see issue rust-lang#90193).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants