Skip to content

[NLL] loss of span for type outlives errors in closures/async blocks #99245

Closed

Description

@aliemjay

Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=aaf294b9353da9ea4ef76206ed0c0a76

fn test<'a, T>() {
    || {
        None::<&'a T>;
    };
}

The current output is:

error[E0309]: the parameter type `T` may not live long enough
 --> src/lib.rs:2:5
  |
2 | /     || {
3 | |         None::<&'a T>;
4 | |     };
  | |_____^ ...so that the type `T` will meet its required lifetime bounds
  |
help: consider adding an explicit lifetime bound...
  |
1 | fn test<'a, T: 'a>() {
  |              ++++

Ideally the output should look similar to when constraint is generated in the main fn body:

error[E0309]: the parameter type `T` may not live long enough
 --> src/lib.rs:3:9
  |
3 |         None::<&'a T>;
  |         ^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
  |
help: consider adding an explicit lifetime bound...
  |
1 | fn test<'a, T: 'a>() {
  |              ++++

@rustbot label A-NLL NLL-diagnostics D-terse regression-from-stable-to-beta

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.
    on Jul 14, 2022
  2. added
    A-NLLArea: Non-lexical lifetimes (NLL)
    D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.
    NLL-diagnosticsWorking towards the "diagnostic parity" goal
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Jul 14, 2022
  3. apiraino commented on Jul 20, 2022

    @apiraino
    Contributor

    Regressed in #95565 cc @jackh726

    searched nightlies: from nightly-2022-01-01 to nightly-2022-07-20
    regressed nightly: nightly-2022-06-08
    searched commit range: 50b0025...5435ed6
    regressed commit: bb55bd4

    bisected with cargo-bisect-rustc v0.6.3

    Host triple: x86_64-unknown-linux-gnu
    Reproduce with:

    cargo bisect-rustc --start=2022-01-01 --script=./script.sh 
    
    cat script.sh
    #!/bin/sh
    cargo check 2>&1 | grep "does not outlive the data it points at"
  4. apiraino commented on Jul 20, 2022

    @apiraino
    Contributor

    WG-prioritization assigning priority (Zulip discussion).

    @rustbot label -I-prioritize +P-medium

  5. added and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Jul 20, 2022
  6. added this to the 1.63.0 milestone on Aug 9, 2022
  7. mqudsi commented on Aug 12, 2022

    @mqudsi
    Contributor

    @rustbot label -regression-from-stable-to-beta +regression-from-stable-to-stable

  8. added
    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
    and removed on Aug 12, 2022
  9. added a commit that references this issue on Nov 6, 2022
    e30fb6a
  10. added a commit that references this issue on Jan 6, 2023
    a1891bf
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-NLLArea: Non-lexical lifetimes (NLL)A-diagnosticsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.NLL-diagnosticsWorking towards the "diagnostic parity" goalP-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions