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

opaques in dead code and choosing 'static #170

Open
lcnr opened this issue Apr 3, 2025 · 0 comments
Open

opaques in dead code and choosing 'static #170

lcnr opened this issue Apr 3, 2025 · 0 comments

Comments

@lcnr
Copy link
Contributor

lcnr commented Apr 3, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant