Skip to content

erroneous constant used note makes error really large #110891

Closed

Description

@BoxyUwU

Code

#![feature(closure_lifetime_binder, inline_const)]

fn foo() {
    let a = for<'a> |b: &'a ()| -> &'a () {
        const {
            let awd = ();
            let _: &'a () = &awd;
        };
        b
    };
}

Current output

error[E0597]: `awd` does not live long enough
 --> src/lib.rs:7:29
  |
4 |     let a = for<'a> |b: &'a ()| -> &'a () {
  |                 -- lifetime `'a` defined here
...
7 |             let _: &'a () = &awd;
  |                    ------   ^^^^ borrowed value does not live long enough
  |                    |
  |                    type annotation requires that `awd` is borrowed for `'a`
8 |         };
  |         - `awd` dropped here while still borrowed

note: erroneous constant used
 --> src/lib.rs:5:9
  |
5 | /         const {
6 | |             let awd = ();
7 | |             let _: &'a () = &awd;
8 | |         };
  | |_________^

Desired output

error[E0597]: `awd` does not live long enough
 --> src/lib.rs:7:29
  |
4 |     let a = for<'a> |b: &'a ()| -> &'a () {
  |                 -- lifetime `'a` defined here
...
7 |             let _: &'a () = &awd;
  |                    ------   ^^^^ borrowed value does not live long enough
  |                    |
  |                    type annotation requires that `awd` is borrowed for `'a`
8 |         };
  |         - `awd` dropped here while still borrowed

Rationale and extra context

No response

Other cases

No response

Anything else?

No response

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    F-inline_constInline constants (aka: const blocks, const expressions, anonymous constants)
    on Apr 27, 2023
  2. added a commit that references this issue on May 16, 2023
    8809a92
  3. added 3 commits that reference this issue on May 16, 2023
    61c4801
    0ae644d
    3e34be0
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-diagnosticsArea: Messages for errors, warnings, and lintsF-closure_lifetime_binder`#![feature(closure_lifetime_binder)]`F-inline_constInline constants (aka: const blocks, const expressions, anonymous constants)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions