-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
fix: break inside async closure has incorrect span for enclosing closure #125078
Conversation
r? @davidtwco rustbot has assigned @davidtwco. Use |
compiler/rustc_passes/src/loops.rs
Outdated
@@ -91,6 +91,10 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> { | |||
}) => { | |||
let cx = match kind { | |||
hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(kind, source)) => { | |||
let fn_decl_span = match self.cx { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a bit too specific of a case here. I think we should just fix the fn_decl_span
for the hir::Closure
from an async closure.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls look into fixing this in a more general way
This comment was marked as resolved.
This comment was marked as resolved.
@rustbot ready |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I wasn't clear when I meant that this should be made more general. I think this needs to be fixed when the hir::Closure
is constructed, somewhere in rustc_ast_lowering
.
See https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_ast_lowering/expr.rs.html#1056-1122 or somewhere nearby.
This comment has been minimized.
This comment has been minimized.
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
I think it's ready to review. Would you @compiler-errors leave some feadback? I will be very appreciate for it |
@bors r+ |
…errors fix: break inside async closure has incorrect span for enclosing closure Fixes rust-lang#124496
Rollup of 10 pull requests Successful merges: - rust-lang#124135 (delegation: Implement glob delegation) - rust-lang#125078 (fix: break inside async closure has incorrect span for enclosing closure) - rust-lang#125293 (Place tail expression behind terminating scope) - rust-lang#126422 (Suggest using a standalone doctest for non-local impl defs) - rust-lang#126493 (safe transmute: support non-ZST, variantful, uninhabited enums) - rust-lang#126504 (Sync fuchsia test runner with clang test runner) - rust-lang#126558 (hir_typeck: be more conservative in making "note caller chooses ty param" note) - rust-lang#126586 (Add `@badboy` and `@BlackHoleFox` as Mac Catalyst maintainers) - rust-lang#126615 (Add `rustc-ice*` to `.gitignore`) - rust-lang#126632 (Replace `move||` with `move ||`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#125078 - linyihai:issue-124496, r=compiler-errors fix: break inside async closure has incorrect span for enclosing closure Fixes rust-lang#124496
…s, r=oli-obk Tighten `fn_decl_span` for async blocks Tightens the span of `async {}` blocks in diagnostics, and subsequently async closures and async fns, by actually setting the `fn_decl_span` correctly. This is kinda a follow-up on rust-lang#125078, but it fixes the problem in a more general way. I think the diagnostics are significantly improved, since we no longer have a bunch of overlapping spans. I'll point out one caveat where I think the diagnostic may get a bit more confusing, but where I don't think it matters. r? `@estebank` or `@oli-obk` or someone else on wg-diag or compiler i dont really care lol
…s, r=oli-obk Tighten `fn_decl_span` for async blocks Tightens the span of `async {}` blocks in diagnostics, and subsequently async closures and async fns, by actually setting the `fn_decl_span` correctly. This is kinda a follow-up on rust-lang#125078, but it fixes the problem in a more general way. I think the diagnostics are significantly improved, since we no longer have a bunch of overlapping spans. I'll point out one caveat where I think the diagnostic may get a bit more confusing, but where I don't think it matters. r? ``@estebank`` or ``@oli-obk`` or someone else on wg-diag or compiler i dont really care lol
…s, r=oli-obk Tighten `fn_decl_span` for async blocks Tightens the span of `async {}` blocks in diagnostics, and subsequently async closures and async fns, by actually setting the `fn_decl_span` correctly. This is kinda a follow-up on rust-lang#125078, but it fixes the problem in a more general way. I think the diagnostics are significantly improved, since we no longer have a bunch of overlapping spans. I'll point out one caveat where I think the diagnostic may get a bit more confusing, but where I don't think it matters. r? ```@estebank``` or ```@oli-obk``` or someone else on wg-diag or compiler i dont really care lol
…s, r=oli-obk Tighten `fn_decl_span` for async blocks Tightens the span of `async {}` blocks in diagnostics, and subsequently async closures and async fns, by actually setting the `fn_decl_span` correctly. This is kinda a follow-up on rust-lang#125078, but it fixes the problem in a more general way. I think the diagnostics are significantly improved, since we no longer have a bunch of overlapping spans. I'll point out one caveat where I think the diagnostic may get a bit more confusing, but where I don't think it matters. r? ````@estebank```` or ````@oli-obk```` or someone else on wg-diag or compiler i dont really care lol
Rollup merge of rust-lang#127058 - compiler-errors:tighten-async-spans, r=oli-obk Tighten `fn_decl_span` for async blocks Tightens the span of `async {}` blocks in diagnostics, and subsequently async closures and async fns, by actually setting the `fn_decl_span` correctly. This is kinda a follow-up on rust-lang#125078, but it fixes the problem in a more general way. I think the diagnostics are significantly improved, since we no longer have a bunch of overlapping spans. I'll point out one caveat where I think the diagnostic may get a bit more confusing, but where I don't think it matters. r? ````@estebank```` or ````@oli-obk```` or someone else on wg-diag or compiler i dont really care lol
…s, r=oli-obk Tighten `fn_decl_span` for async blocks Tightens the span of `async {}` blocks in diagnostics, and subsequently async closures and async fns, by actually setting the `fn_decl_span` correctly. This is kinda a follow-up on rust-lang#125078, but it fixes the problem in a more general way. I think the diagnostics are significantly improved, since we no longer have a bunch of overlapping spans. I'll point out one caveat where I think the diagnostic may get a bit more confusing, but where I don't think it matters. r? ````@estebank```` or ````@oli-obk```` or someone else on wg-diag or compiler i dont really care lol
Fixes #124496