-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Rewrite for
loop desugaring to use language items
#1457
Conversation
This requires a good way for HIR lowering to refer to lang items (currently they are collected after lowering). cc rust-lang/rust#30809 @eddyb |
# Drawbacks | ||
[drawbacks]: #drawbacks | ||
|
||
Possible backward compatibility concerns with existing `#![no_core]` code. |
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.
I feel there might/are more backwards incompat vectors here. I’m pretty sure you can replace libstd and libcore in at least one way: by replacing libcore or libstd in their well known locations with another libraries. rustc --extern core=*.rlib
is also a viable way of “replacing” a libcore.
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.
@nagisa That counts as much as forking Rust does: we don't guarantee anything, nor could we.
Since lang items are an implementation detail of rustc, I do not see the need for a RFC. I personally prefer using lang items instead of hardcoding paths, and would like to see a proper discussion on rust-lang/rust#30809. cc @rust-lang/compiler |
@eddyb RFCs for implementation details of the compiler are allowed and encouraged! It's what we have a T-compiler label for. I also agree we should do this, in fact I filed rust-lang/rust#20541 about the same thing a year ago (back when the desugarings were in libsyntax). It's still not clear to me how that should work though, I'd like to see some ideas here or elsewhere for how this could be implemented |
@nrc Right, I want the discussion, but it felt that this RFC was dealing with language semantics and not implementation details (I see this change as a bugfix). Hopefully the tagging solves that. To expand on what was suggested in rust-lang/rust#30809: enum FrontLangItem {
IntoIteratorIntoIter,
IteratorNext,
Range,
OptionSome,
OptionNone
...
}
fn lower(krate: ast::Crate) -> (hir::Crate, NodeMap<FrontLangItem>) {...} Then resolve can take that map, look up HIR nodes in there, and if they are found, ignore the actual path, and convert the |
Hmm, a lazy approach to lang items, that sounds promising. The approach I had considered before was that we could just move the lang item machinery earlier in the compiler and allow resolving lang items to fully qualified paths as well as actual references. Not sure if that will actually work. |
I agree with @eddyb that this probably doesn't rise to the level of complexity that necessitates an RFC, but it does seem like a reasonably good idea to me, presuming we can rearrange the lang item business and make that work out. |
That said, I should note that I don't feel especially motivated to support |
Hear ye, hear ye. This RFC is now entering final comment period. The conclusion in the meeting was that while this may or may not have truly needed an RFC, there is one now and, since it generated some mild discussion and controversy, we might as well accept it like any other. |
Making |
There are two kinds of language items - on the one hand we have "normal" items like On the other hand we have strange beasts like Maybe they can be separated somehow? |
I am not sure about that. |
It only seems worthwhile to merge this RFC if we have a plan for how we'll handle lang items in the HIR lowering step. That seems to be the difficult part of implementing the RFC. Since it isn't part of the RFC, the FCP seems premature (unless we just close the PR). |
So the language team reviewed the situation here and came to the following conclusion:
So, we don't want to accept this RFC without having more discussion of the implementation details. But we also do not think that this RFC thread is the right place for such a discussion of hypothetical implementation details. There are two places that team members asserted would be better spots for such a discussion:
|
(closing; see previous comment for why.) |
Rendered