Skip to content

opaques in dead code and choosing 'static #170

Open
@lcnr

Description

@lcnr

after rust-lang/rust#138785:

#![feature(rustc_attrs)]
#![rustc_hidden_type_of_opaques]

use std::ops::Deref;
fn foo<'a, 'b>() -> impl Deref<Target = u32> + use<'a, 'b> {
    unimplemented!() as &'a u32
}

results in

error: &'static u32
 --> src/main.rs:5:21
  |
5 | fn foo<'a, 'b>() -> impl Deref<Target = u32> + use<'a, 'b> {
  |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

We never do anything withthe user type annotation mentioning 'a as its in dead code, so we end up with opaque<'a, 'b> = &'unconstrained u32 in the storage. The member constraint 'unconstrained member ['a, 'b, 'static] just picks 'static at this point as it's the smallest region related to all other choice regions.

This should be moved as an issue to the rust-lang/rust repo once this behavior is happening on stable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions