const_eval: we allow references to statics and promoteds #1858
+3
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The docs currently seem to imply that we would reject these, but we do not:
Arguably, the second example with a promoted is a bit of a stretch. It's also a bit unclear what "are only allowed to refer" means, i.e. what exactly gets checked when exactly.
What actually happens is that we allow mutable and interior mutable borrows when
We allow the 2nd point because that means the new borrow is pointing to something that was already borrowed before, so we already checked transience at that point. But also, the internal representation of a static item as an expression is a deref, so this also allows
&INTERIOR_MUTABLE_STATIC
or&mut MUT_STATIC
, and something similar happens with promoteds.Should we mention the point about indirect places? It makes the description more algorithmic, which seems like a good thing, if that's the style you are going for. Basically, the question is, when this clause talks about "places", does it mean places expressions or evaluated places? Is it talking about a static property of the source code, or a dynamic property of the runtime data? If it is the former, indirect places have to be mentioned, if it is the latter, then not.