Skip to content

Regression 1.66 "some_fn::{opaque#0}<'_> does not live long enough" #107426

Closed

Description

@Dav1dde

Code

Unfortunately I couldn't minimize it further without using a dependency (code can be executed online here):

/*
[dependencies]
sycamore = "0.8.2"
web-sys = "0.3"

*/

use sycamore::prelude::{Scope, View, Html, DomNode, ReadSignal, GenericNode};

pub fn create_toggle_bool<'a>(cx: Scope<'a>, initial: bool) -> (&'a ReadSignal<bool>, impl Fn() + Copy + 'a) {
    // let open = sycamore::prelude::create_signal(cx, false);
    // let open_toggle = || open.set(!*open.get());
    // (open, open_toggle)
    (todo!(), || {})
}

pub fn Foo<G: Html>(cx: Scope) -> View<G> {
    let (open, open_toggle) = create_toggle_bool(cx, false);

    // Uncomment these 2 lines to make it compile (moved out of the function)
    // let open = sycamore::prelude::create_signal(cx, false);
    // let open_toggle = || open.set(!*open.get());

    let a = move |_: web_sys::Event| open_toggle();

    move || {
        let __el = DomNode::text_node("test");
        ::sycamore::generic_node::GenericNode::event(&__el, cx, "click", a);
        __el;
    };

    todo!()
}

fn main() {
}

The code compiles and runs with 1.66 but fails with 1.67:

error: `create_toggle_bool::{opaque#0}<'_>` does not live long enough
  --> src/main.rs:28:9
   |
28 |         ::sycamore::generic_node::GenericNode::event(&__el, cx, "click", a);
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I expect this code to still compile on 1.67

Version it worked on

1.66

Version with regression

1.67

rustc 1.67.0 (fc594f156 2023-01-24)
binary: rustc
commit-hash: fc594f15669680fa70d255faec3ca3fb507c3405
commit-date: 2023-01-24
host: x86_64-unknown-linux-gnu
release: 1.67.0
LLVM version: 15.0.6

Activity

  1. added
    C-bugCategory: This is a bug.
    regression-untriagedUntriaged performance or correctness regression.
    on Jan 28, 2023
  2. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Jan 28, 2023
  3. added
    E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
    E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
    on Jan 28, 2023
  4. Teapot4195 commented on Jan 28, 2023

    @Teapot4195
    Contributor

    searched nightlies: from nightly-2022-09-15 to nightly-2022-10-15
    regressed nightly: nightly-2022-09-26
    searched commit range: 3f83906...f5193a9
    regressed commit: f5193a9

    bisected with cargo-bisect-rustc v0.6.5

    Host triple: x86_64-unknown-linux-gnu
    Reproduce with:

    cargo bisect-rustc --end=2022-10-15 

    @rustbot label -E-needs-bisection

  5. removed
    E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
    on Jan 28, 2023
  6. clubby789 commented on Jan 28, 2023

    @clubby789
    Contributor

    Minimized to:

    use std::marker::PhantomData;
    #[derive(Clone, Copy)]
    pub struct Scope<'a>(&'a PhantomData<&'a mut &'a ()>);
    fn event<'a, F: FnMut() + 'a>(_: Scope<'a>, _: F) {}
    fn make_fn<'a>(_: Scope<'a>) -> impl Fn() + Copy + 'a {
        || {}
    }
    
    fn foo(cx: Scope) {
        let open_toggle = make_fn(cx);
    
        || event(cx, open_toggle);
    }
    
    fn main() {}

    @rustbot label -E-needs-mcve

  7. removed
    E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
    on Jan 28, 2023
  8. clubby789 commented on Jan 28, 2023

    @clubby789
    Contributor

    This is a breaking change but it is a necessary soundness fix

    #95474

  9. Noratrieb commented on Jan 29, 2023

    @Noratrieb
    Member

    Since the crater run there found no regressions I'm gonna @oli-obk anyways but I don't think there's anything to do here.

  10. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    and removed
    C-bugCategory: This is a bug.
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    regression-untriagedUntriaged performance or correctness regression.
    on Jan 29, 2023
  11. 8 remaining items

  12. steffahn commented on Jan 31, 2023

    @steffahn
    Member

    I only looked at this issue, because there’s been a thread on URLO on a similarly-looking issue that appears to actually regress on 1.67: #107516

    Mentioning it here, because it might be of interest to readers of this thread :-)

  13. Dav1dde commented on Jan 31, 2023

    @Dav1dde
    ContributorAuthor

    This is weird, this only broke on my CI because it was pinned to stable (-> 1.67), my local machine was still compiling and running the code fine on 1.66. Maybe the reduced example already regressed in 1.66 but my corner case only regresses in 1.67?

  14. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Feb 24, 2023
  15. aliemjay commented on Mar 3, 2023

    @aliemjay
    Contributor

    This regression can indeed be mitigated (cc #108691), at least for the MCVE we have.
    @rustbot label -A-diagonstics regression-from-stable-to-stable

  16. added
    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Mar 3, 2023
  17. apiraino commented on Mar 7, 2023

    @apiraino
    Contributor

    WG-prioritization assigning priority (Zulip discussion).

    @rustbot label -I-prioritize +P-medium

  18. added and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Mar 7, 2023
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-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions