-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
make .stash(..)
work in macros without ICEing
#69537
Conversation
This comment has been minimized.
This comment has been minimized.
5c7ac95
to
461d798
Compare
😰 |
That bad, eh? 😂 |
@@ -729,6 +729,8 @@ pub enum ExpnKind { | |||
AstPass(AstPass), | |||
/// Desugaring done by the compiler during HIR lowering. | |||
Desugaring(DesugaringKind), | |||
/// AST fragements produced by parser recovery. |
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.
/// AST fragements produced by parser recovery. | |
/// AST fragments produced by parser recovery. |
I'd really like to avoid introducing new uses of |
The diagnostic stashing problem can be generalized as "Give me a unique ID at point A that can be retrieved later at point B". The both attempts at stashing API tried to use some existing data as dual purpose - their primary meaning and the unique ID. The first attempt was to use The second attempt is to create unique |
"Proper" solution would be using a separate ID, Another alternative is to hide these stash IDs in
|
I'd personally just nuke the whole diagnostic stashing and report everything in the traditional way :) |
One more alternative: remove the assertion in If we hit this case, then we will report at least one error (assuming all stashed diagnostics are errors), so it's acceptable to omit some further errors. This is perhaps the easiest way to fix #69396 without introducing more evil into the codebase. (Also the most backportable.) |
Some thoughts:
It might be a good idea to improve the docs on
Could you elaborate a bit regarding name resolution? I don't think I understand the problem right now.
Yeah it does sound overkill -- the reason I used
This does sound like a promising approach since
For what it's worth, I do have other cases in mind where I would like to use the stashing API but haven't gotten around to it yet. (I've mostly discussed these with @estebank in private.) I would be OK with nuking the API if the consensus is that it is too architecturally problematic, though the diagnostics regressions would be unfortunate and increase pressure for something like rust-lang/rfcs#2545. cc @rust-lang/wg-diagnostics
Alright; I'll create another PR with this fix while we continue to discuss the long term strategy here. |
stash API: remove panic to fix ICE. Implements the temporary solution suggested in rust-lang#69537 (comment). Fixes rust-lang#69396. r? @petrochenkov
☔ The latest upstream changes (presumably #69635) made this pull request unmergeable. Please resolve the merge conflicts. |
Closing this PR in favor of #70069 as this isn't a high priority item to work on for now. |
Fixes #69396, which was injected by #64698, by unique-ifying the
Span
part of the key used when stashing the diagnostic such that the key's slot isn't overwritten inhandler.stash_diagnostic(..)
.This is similar to the usage of
fresh_expansion
inmark_span_with_reason
(but that's not used for unique-ifying). Stashing is somewhat similar in the sense that it is sort of about compiler generated code as well.An alternative approach would be to store
Vec<Diagnostic>
instead ofDiagnostic
, but the disadvantage of such a solution is that it might handle non-determinism poorly when stealing diagnostics (e.g. if stealing order would be different than stashing order). The approach in this PR feels more robust in comparison.r? @petrochenkov