Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Rust update from 1.63 to 1.64 introduce lifetime problem on build #103141

Closed

Description

@Aboussejra

Code

This is an attempt to reproduce a minimal example of a regression problem (backwards compatibility not assured) from a closed-source company codebase.

I tried this code: -> https://github.com/Aboussejra/rust_compiler_1.64_update_problem

pub struct VecNumber<'s> {
    pub vec_number: Vec<Number<'s>>,
    pub auxiliary_object: &'s Vec<usize>,
}

#[derive(Clone)]
pub struct Number<'s> {
    pub number: &'s usize,
}

impl<'s> VecNumber<'s> {
    pub fn vec_number_iterable_per_item_in_auxiliary_object(
        &self,
    ) -> impl Iterator<Item = (&'s usize, impl Iterator<Item = &Number<'s>> + Clone)> {
        self.auxiliary_object.iter().map(move |n| {
            let iter_number = self.vec_number.iter();
            (n, iter_number)
        })
    }
}

I expected to see the code building (This code is old and was building for years on rust 1.54, and builds on rust 1.63. the code works as intended in the proprietary codebase)

Instead, this happened:

error: lifetime may not live long enough
  --> src/main.rs:15:9
   |
11 |   impl<'s> VecNumber<'s> {
   |        -- lifetime `'s` defined here
12 |       pub fn vec_number_iterable_per_item_in_auxiliary_object(
13 |           &self,
   |           - let's call the lifetime of this reference `'1`
14 |       ) -> impl Iterator<Item = (&'s usize, impl Iterator<Item = &Number<'s>> + Clone)> {
15 | /         self.auxiliary_object.iter().map(move |n| {
16 | |             let iter_number = self.vec_number.iter();
17 | |             (n, iter_number)
18 | |         })
   | |__________^ associated function was supposed to return data with lifetime `'s` but it is returning data with lifetime `'1`

Version it worked on

It most recently worked on: 1.63 (from my repo, commit : 4c37cdc458abdecd0baf018500bbc0611bad568f)

rustc 1.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: x86_64-unknown-linux-gnu
release: 1.63.0
LLVM version: 14.0.5

Version with regression

It does not work anymore on version 1.64: (from my repo, commit : 2728a5acdb645f93ef223a0bc15dd3545fd82c51)

rustc 1.64.0 (a55dd71d5 2022-09-19)
binary: rustc
commit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52
commit-date: 2022-09-19
host: x86_64-unknown-linux-gnu
release: 1.64.0
LLVM version: 14.0.6

Backtrace

Including the backtrace by setting RUST_BACKTRACE=1 does not change anything to the error message.

I do not know why this problem occured though.

@rustbot modify labels: +regression-from-stable-to-{channel} -regression-untriaged
-->

Activity

  1. added
    C-bug
    regression-untriaged
    on Oct 17, 2022
  2. added
    I-prioritize
    on Oct 17, 2022
  3. Noratrieb commented on Oct 17, 2022

    @Noratrieb
    Member

    searched nightlies: from nightly-2022-08-01 to nightly-2022-10-01
    regressed nightly: nightly-2022-08-11
    searched commit range: 34a6cae...29e4a9e
    regressed commit: 1603a70

    bisected with cargo-bisect-rustc v0.6.4

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

    cargo bisect-rustc --access github --timeout 30 --start 2022-08-01 --end 2022-10-01 --regress error 

    Out of the rollup, this was probably caused by #100340? @spastorino

  4. self-assigned this
    on Oct 18, 2022
  5. apiraino commented on Oct 18, 2022

    @apiraino
    Contributor

    WG-prioritization assigning priority (Zulip discussion).

    @rustbot label -I-prioritize +P-critical

  6. added
    P-critical
    and removed
    I-prioritize
    on Oct 18, 2022
  7. added
    regression-from-stable-to-stable
    T-compiler
    and removed
    regression-untriaged
    on Oct 19, 2022
  8. added a commit that references this issue on Oct 20, 2022
    ebdde35
  9. spastorino commented on Oct 20, 2022

    @spastorino
    Member

    Reopening to track backports.

  10. apiraino commented on Nov 9, 2022

    @apiraino
    Contributor

    can this be closed? was #103205 backported to stable, right?

    cc @spastorino @RalfJung (unsure who to ping)

  11. RalfJung commented on Nov 9, 2022

    @RalfJung
    Member

    I have no involvement with this whatsoever.^^
    @Mark-Simulacrum is usually doing backports.

  12. pnkfelix commented on Nov 10, 2022

    @pnkfelix
    Contributor

    #103205 was beta backported to 1.65, which is now released.

    We won't be having a 1.64.1 release.

    So this should be considered "fixed", since it is resolved on the current stable release of Rust.

  13. added a commit that references this issue on Jan 6, 2023
    1cc4e3c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugP-criticalT-compilerregression-from-stable-to-stable

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions