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

assoc const equality anon consts have elided lifetimes set to 'static #110933

Closed
BoxyUwU opened this issue Apr 28, 2023 · 1 comment · Fixed by #113031
Closed

assoc const equality anon consts have elided lifetimes set to 'static #110933

BoxyUwU opened this issue Apr 28, 2023 · 1 comment · Fixed by #113031
Labels
A-const-generics Area: const generics (parameters and arguments) A-lifetimes Area: lifetime related A-resolve Area: Path resolution C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-associated_const_equality `#![feature(associated_const_equality)]`

Comments

@BoxyUwU
Copy link
Member

BoxyUwU commented Apr 28, 2023

I tried this code:

#![feature(associated_const_equality)]

trait Trait {
    const ASSOC: usize;
}

fn foo<T: Trait<ASSOC = {
    let a = 10_usize;
    let b: &'_ usize = &a;
    *b
}>>() {
    
}

I expected to see this happen: it compile

Instead, this happened: it errored

error[[E0597]](https://doc.rust-lang.org/nightly/error_codes/E0597.html): `a` does not live long enough
  --> src/lib.rs:9:24
   |
9  |     let b: &'_ usize = &a;
   |            ---------   ^^ borrowed value does not live long enough
   |            |
   |            type annotation requires that `a` is borrowed for `'static`
10 |     *b
11 | }>>() {
   | - `a` dropped here while still borrowed

For more information about this error, try `rustc --explain E0597`.
error: could not compile `playground` (lib) due to previous error

related issue: #110931

Meta

playground version:

Nightly channel

Build using the Nightly version: 1.71.0-nightly

(2023-04-27 1a6ae3d692cfb52b21d0)
Backtrace

<backtrace>

@BoxyUwU BoxyUwU added A-resolve Area: Path resolution A-lifetimes Area: lifetime related C-bug Category: This is a bug. A-const-generics Area: const generics (parameters and arguments) F-associated_const_equality `#![feature(associated_const_equality)]` labels Apr 28, 2023
@cjgillot cjgillot added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 1, 2023
@cjgillot
Copy link
Contributor

cjgillot commented May 1, 2023

Fixed by #110984

JohnTitor added a commit to JohnTitor/rust that referenced this issue Jun 25, 2023
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 25, 2023
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#112976 (Add test for futures with HRTB)
 - rust-lang#113013 (rustdoc: get rid of extra line when line-wrapping fn decls with empty arg list)
 - rust-lang#113030 (Add a regression test for rust-lang#109071)
 - rust-lang#113031 (Add a regression test for rust-lang#110933)
 - rust-lang#113036 (Accept `ReStatic` for RPITIT)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in d7723f4 Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) A-lifetimes Area: lifetime related A-resolve Area: Path resolution C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-associated_const_equality `#![feature(associated_const_equality)]`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants