Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAllow and implement recursive static variables. #26630
Conversation
rust-highfive
assigned
pnkfelix
Jun 28, 2015
This comment has been minimized.
This comment has been minimized.
|
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
|
This would be really neat for |
eefriedman
force-pushed the
eefriedman:recursive-static
branch
from
e0349a3
to
6280c36
Jun 28, 2015
eefriedman
changed the title
[WIP] Allow and implement recursive static variables.
Allow and implement recursive static variables.
Jun 28, 2015
This comment has been minimized.
This comment has been minimized.
|
Updated; should be safe now. Also added an extra commit to remove the restriction on types which can't be instantiated, to allow implementing a static doubly-linked list. |
This comment has been minimized.
This comment has been minimized.
|
cc @rust-lang/lang, not sure if this is a large enough change to warrant an RFC, it'd probably be nice to have a "static specification" but that may be a bit of a pipe dream. |
This comment has been minimized.
This comment has been minimized.
|
I don't think it needs an RFC and I think it is a good idea. I do think it probably deserves some eyes on it, so I created an announcement in our internals discourse: https://internals.rust-lang.org/t/heads-up-allowing-recursive-static-variables/2309 |
This comment has been minimized.
This comment has been minimized.
|
Are nonsensical cycles like Also, perhaps the tests that are deleted in this PR should instead just be moved to |
This comment has been minimized.
This comment has been minimized.
|
@P1start The initializer for a static item can't read the contents of any static item, so Not sure the tests are particularly useful, but I guess I could move them. |
eefriedman
force-pushed the
eefriedman:recursive-static
branch
from
6280c36
to
a0055ef
Jul 2, 2015
This comment has been minimized.
This comment has been minimized.
|
Tests re-added. |
This comment has been minimized.
This comment has been minimized.
|
Surely this should at least be feature gated? |
This comment has been minimized.
This comment has been minimized.
|
(that is, I can understand side-stepping the RFC process, though I'm not 100% sure I agree with doing so, even for a feature like this. But with or without an RFC, it still seems prudent to feature-gate new functionality in the language, just so that we can kick the tires on it in nightly without worry about whether it could inadvertantly leak out into the other distribution channels.) |
eefriedman
force-pushed the
eefriedman:recursive-static
branch
from
a0055ef
to
3d8cae2
Jul 3, 2015
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
AFAICT you had to revert the removal of |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@eefriedman sorry I have not reviewed this yet. I hope I will get to it this week but I am not sure if I will. |
This comment has been minimized.
This comment has been minimized.
|
@pnkfelix Ping. |
This comment has been minimized.
This comment has been minimized.
|
@eefriedman sorry for the delay |
pnkfelix
reviewed
Jul 24, 2015
| @@ -131,6 +128,11 @@ pub struct LocalCrateContext<'tcx> { | |||
| /// Cache of closure wrappers for bare fn's. | |||
| closure_bare_wrapper_cache: RefCell<FnvHashMap<ValueRef, ValueRef>>, | |||
|
|
|||
| /// List of globals for static variables which need to be RAUW'ed when | |||
This comment has been minimized.
This comment has been minimized.
pnkfelix
Jul 24, 2015
Member
nit: as far as I can tell the acronym "RAUW" does not occur elsewhere in our code.
So, please expand this occurrence and then include the acronym afterwards in parentheses, effectively defining the acronym. Like so: "static variables which need to be passed through the LLVM Replace All Uses With (RAUW) functionality"
This comment has been minimized.
This comment has been minimized.
|
okay looks good as far as my knowledge of LLVM goes. r=me after next rebase (and hopefully the noted nit is addressed). |
eefriedman
added some commits
Jun 28, 2015
eefriedman
force-pushed the
eefriedman:recursive-static
branch
from
3d8cae2
to
0eea0f6
Jul 25, 2015
This comment has been minimized.
This comment has been minimized.
|
@pnkfelix Rebased. |
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
eefriedman commentedJun 28, 2015
_Edit: Fixed now._ I'm pretty sure the way I'm using LLVMReplaceAllUsesWith here is
unsafe... but before I figure out how to fix that, I'd like a
reality-check: is this actually useful?