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

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

Closed
aliemjay opened this issue Jul 14, 2022 · 3 comments · Fixed by #102618
Closed

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

aliemjay opened this issue Jul 14, 2022 · 3 comments · Fixed by #102618
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-NLL Area: Non-lexical lifetimes (NLL) D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. NLL-diagnostics Working towards the "diagnostic parity" goal P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone

Comments

@aliemjay
Copy link
Member

aliemjay commented Jul 14, 2022

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

@aliemjay aliemjay 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. labels Jul 14, 2022
@rustbot rustbot added A-NLL Area: Non-lexical lifetimes (NLL) D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. NLL-diagnostics Working towards the "diagnostic parity" goal regression-from-stable-to-beta Performance or correctness regression from stable to beta. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jul 14, 2022
@apiraino
Copy link
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"

@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jul 20, 2022
@Mark-Simulacrum Mark-Simulacrum added this to the 1.63.0 milestone Aug 9, 2022
@mqudsi
Copy link
Contributor

mqudsi commented Aug 12, 2022

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

@rustbot rustbot added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Aug 12, 2022
@bors bors closed this as completed in e30fb6a Nov 6, 2022
Aaron1011 pushed a commit to Aaron1011/rust that referenced this issue Jan 6, 2023
…=compiler-errors

rework applying closure requirements in borrowck

Previously the promoted closure constraints were registered under the category `ConstraintCategory::ClosureBounds` in `type_check::prove_closure_bounds()` and then mapped back their original category in `regions_infer::best_blame_constraint` using the complicated map `closure_bounds_mapping`.

Now we're registering promoted constraints under their original category and span earlier in `type_check::prove_closure_bounds`.

See commit messages.

Fixes rust-lang#99245
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 A-NLL Area: Non-lexical lifetimes (NLL) D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. NLL-diagnostics Working towards the "diagnostic parity" goal P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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.

5 participants