Skip to content

impl Trait lifetimes regression 1.67 #108591

Closed

Description

@aliemjay

Some regressions of #103491 that I previously reported in #105826 (comment), but they were missed:

struct MyTy<'a>(Vec<u8>, &'a ());

impl MyTy<'_> {
    fn one(&mut self) -> &mut impl Sized {
        &mut self.0
    }
    fn two(&mut self) -> &mut (impl Sized + 'static) {
        self.one()
        //~^ ERROR lifetime may not live long enough
    }
}
#![feature(type_alias_impl_trait)]
type Opaque<'a> = impl Sized;
fn define<'a>() -> Opaque<'a> {}

fn test<'a>() {
    None::<&'static Opaque<'a>>;
    //~^ ERROR lifetime may not live long enough
}
fn one<'a, 'b: 'b>() -> &'a impl Sized {
    &()
}
fn two<'a, 'b>() {
    one::<'a, 'b>();
    //~^ ERROR lifetime may not live long enough
}

I guess the way to fix this is to ignore non-captured lifetimes of opaque types here

cc @cjgillot

@rustbot label C-bug regression-from-stable-to-stable T-types T-compiler A-impl-trait

Activity

  1. added
    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.
    C-bugCategory: This is a bug.
    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    T-typesRelevant to the types team, which will review and decide on the PR/issue.
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Mar 1, 2023
  2. apiraino commented on Mar 1, 2023

    @apiraino
    Contributor

    WG-prioritization assigning priority (Zulip discussion).

    @rustbot label -I-prioritize +P-high

  3. added
    P-highHigh priority
    and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Mar 1, 2023
  4. added a commit that references this issue on Apr 20, 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.C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types 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