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

erroneous constant used note makes error really large #110891

Closed
BoxyUwU opened this issue Apr 27, 2023 · 0 comments · Fixed by #111602
Closed

erroneous constant used note makes error really large #110891

BoxyUwU opened this issue Apr 27, 2023 · 0 comments · Fixed by #111602
Labels
A-diagnostics Area: Messages for errors, warnings, and lints F-closure_lifetime_binder `#![feature(closure_lifetime_binder)]` F-inline_const Inline constants (aka: const blocks, const expressions, anonymous constants) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@BoxyUwU
Copy link
Member

BoxyUwU commented Apr 27, 2023

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

@BoxyUwU BoxyUwU added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. F-inline_const Inline constants (aka: const blocks, const expressions, anonymous constants) F-closure_lifetime_binder `#![feature(closure_lifetime_binder)]` labels Apr 27, 2023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue May 16, 2023
…=oli-obk

Suppress "erroneous constant used" for constants tainted by errors

When constant evaluation fails because its MIR is tainted by errors,
suppress note indicating that erroneous constant was used, since those
errors have to be fixed regardless of the constant being used or not.

Fixes rust-lang#110891.
Noratrieb added a commit to Noratrieb/rust that referenced this issue May 16, 2023
…=oli-obk

Suppress "erroneous constant used" for constants tainted by errors

When constant evaluation fails because its MIR is tainted by errors,
suppress note indicating that erroneous constant was used, since those
errors have to be fixed regardless of the constant being used or not.

Fixes rust-lang#110891.
Noratrieb added a commit to Noratrieb/rust that referenced this issue May 16, 2023
…=oli-obk

Suppress "erroneous constant used" for constants tainted by errors

When constant evaluation fails because its MIR is tainted by errors,
suppress note indicating that erroneous constant was used, since those
errors have to be fixed regardless of the constant being used or not.

Fixes rust-lang#110891.
@bors bors closed this as completed in 3e34be0 May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints F-closure_lifetime_binder `#![feature(closure_lifetime_binder)]` F-inline_const Inline constants (aka: const blocks, const expressions, anonymous constants) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant