Uh oh!
There was an error while loading. Please reload this page.
[WIP] Allow global_allocators in submodules - #49320
Conversation
rust-highfive
commented
Mar 24, 2018
(rust_highfive has picked a reviewer for you, use r? to override) |
bors
commented
Mar 27, 2018
☔ The latest upstream changes (presumably #49279) made this pull request unmergeable. Please resolve the merge conflicts. |
nikomatsakis
commented
Apr 4, 2018
I could review this if forced, but I'm not super familiar with what's going on here. @alexcrichton -- are you the right person? |
alexcrichton
commented
Apr 5, 2018
Sure yeah I don't mind reviewing this. @mark-i-m mind explaning a bit what the change here is doing? |
mark-i-m
commented
Apr 5, 2018
@alexcrichton Thanks! The problem: Proposed solution: Rather than hard-coding |
alexcrichton
commented
Apr 5, 2018
Ok thanks! I was actually the original author of all this code so I'm mostly curious in the delta from the previous instantiation :) I think, though that |
mark-i-m
commented
Apr 5, 2018
TBH, I don't really know that much about how hygiene works in macro expansion (the rustc-guide chapter has yet to be written). Do you have any hints of how to get started? |
alexcrichton
commented
Apr 5, 2018
I'm not so sure myself (hence why this has never been fixed), but AFAIK it's all tied to identifiers/spans. It may not be necessary at all to even use |
mark-i-m
commented
Apr 7, 2018
I get the following error: |
alexcrichton
commented
Apr 9, 2018
Ah if that doesn't work then it may mean that a special span needs to be used for |
mark-i-m
commented
Apr 11, 2018
Unfortunately, I don't know enough about name resolution or hygiene to know how to do that. Do you have any suggested resources for learning more? Unfortunately, the rustc-guide section is a bit incomplete. |
alexcrichton
commented
Apr 11, 2018
Hm ok, an alternative is to change how things are expanded. Currently a |
mark-i-m
commented
Apr 13, 2018
Thanks @alexcrichton! I will give that a try. Quick question: What does the following line (112) do exactly? let module = f.cx.monotonic_expander().fold_item(module).pop().unwrap(); |
alexcrichton
commented
Apr 13, 2018
A good question! I'm... not actually sure. I may have copy/pasted that from somewhere else originally, and it may be safe to remove. |
mark-i-m
commented
Apr 14, 2018
It seems that we have the same hygiene problems with
I feel like (2) already exists but we are doing it wrong? |
mark-i-m
commented
Apr 14, 2018
Ok, I think I'm onto something: when we create the new I also set the I am now getting "no |
alexcrichton
commented
Apr 14, 2018
Sorry I'm getting pretty mixed up in the diff right now, call the rustfmt changes get backed out for a future run later? |
alexcrichton
commented
Apr 14, 2018
This in general sounds plausible though! Want to add a test to make sure if it passes CI it's good to go? |
mark-i-m
commented
Apr 14, 2018
Sorry, I will pull out rustfmt and comments to another PR... It doesn't work yet, but if I'm right, then it might make like easier. I have a UI test I've been using locally. I will add it too... I'm on mobile at the moment, but when I get to my computer, I will do this... |
mark-i-m
commented
Apr 14, 2018
Also, I believe that last commit is the only one with any actual changes (for the moment)... Will update a bit later... |
mark-i-m
commented
Apr 14, 2018
@alexcrichton I have factored out the formatting and commenting into PR #49969. There are now two commits in this PR. The first makes the change to use the call-site for hygiene. The second adds a test for allocators in submodules (it should fail). |
rust-highfive
commented
Apr 14, 2018
Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
rust-highfive
commented
Apr 14, 2018
Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
mark-i-m
commented
May 10, 2018
@alexcrichton Sorry for the delay, I was in a bit of a time crunch. Let me check. (also, I rebased so the branch doesn't fall too far behind, but there are no changes, and it still doesn't work) |
rust-highfive
commented
May 10, 2018
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
mark-i-m
commented
May 10, 2018
@alexcrichton Ok, so here's what I have. If I don't generate an If I generate an $ cargo +stage1 expand Compiling my_test v0.1.0 (file:///tmp/my_test)warning: ignoring --out-dir flag due to -o flagwarning: ignoring -C extra-filename flag due to -o flagerror[E0463]: can't find crate for `core` --> src/main.rs:21:5 |21 | static MY_HEAP: MyAlloc = MyAlloc; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crateerror: aborting due to previous errorFor more information about this error, try `rustc --explain E0463`.error: Could not compile `my_test`.To learn more, run the command again with --verbose.cat: /tmp/cargo-expand.UUz20ChlwC2T/expanded: No such file or directory |
TimNN
commented
May 15, 2018
@alexcrichton: Do you have any ideas about the error above? |
alexcrichton
commented
May 16, 2018
Ah unfortunately I don't recognize the error nor know the best way to fix it :( |
mark-i-m
commented
May 17, 2018
Hmm... ok so what would be the best path to take? I'm not really sure that I have the knowledge to proceed productively on this issue, so it might be best to leave this for someone else? IMHO, we should disallow allocators in submodules for now, making it a hard error. That would unblock stabilization, right? Then, we should leave notes in #44113 for the next intrepid explorer? |
alexcrichton
commented
May 18, 2018
Yes until this is fixed I think it's fine to just disallow this with a hard error |
mark-i-m
commented
May 19, 2018
Ok, I will try to implement that this week. Would that be done by just keep track in the Folder if we ever try to fold a submodule? I will also leaves some comments on the issue about some of the things we tried. |
alexcrichton
commented
May 20, 2018
I believe so yeah that should work out well enough |
shepmaster
commented
Jun 2, 2018
Ping from triage, @mark-i-m ! Will you have time to revisit this soon? |
mark-i-m
commented
Jun 2, 2018
@shepmaster Sorry, I'm without a computer for the next few days. If you want to close this to keep the issue tracker clean, feel free. I will try to do it soon. |
mark-i-m
commented
Jun 2, 2018
Hmm... I actually did get a chance to revisit this (unexpectedly). I pushed what I have so far. I'm getting the following errors: I haven't really gotten to investigate further but my guess is that imported crates are treated like submodules? @alexcrichton Any ideas? |
emilyalbini
commented
Jun 3, 2018
Ugh, you have to open a new PR since you force-pushed the branch... |
mark-i-m
commented
Jun 3, 2018
Really? Why? I do that every time I rebase |
TimNN
commented
Jun 3, 2018
GitHub oddities. Once a PR is closed (which happened above) it cannot be re-opened once there has been a force push to the underlying branch. |
mark-i-m
commented
Jun 3, 2018
Oh, good to know... |
Prohibit `global_allocator` in submodules Background: #44113 is caused by weird interactions with hygiene. Hygiene is hard. After a lot of playing around, we decided that the best path forward would be to prohibit `global_allocator`s from being in submodules for now. When somebody gets it working, we can re-enable it. This PR contains the following - Some hygiene "fixes" -- things I suspect are the correct thing to do that will make life easier in the future. This includes using call_site hygiene for the generated module and passing the correct crate name to the expansion config. - Comments and minor formatting fixes - Some debugging code - Code to prohibit `global_allocator` in submodules - Test checking that the proper error occurs. cc #44113#49320#51241 r? @alexcrichton
First commit is rustfmt.
Is this even the right approach? Right now it's just breaking everything...
Fix#44113