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 upRewrite `for` loop desugaring to use language items #1457
Conversation
apasel422
referenced this pull request
Jan 10, 2016
Closed
Iterator is needlessly a language item #30803
This comment has been minimized.
This comment has been minimized.
|
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 |
nagisa
reviewed
Jan 10, 2016
| # Drawbacks | ||
| [drawbacks]: #drawbacks | ||
|
|
||
| Possible backward compatibility concerns with existing `#![no_core]` code. |
This comment has been minimized.
This comment has been minimized.
nagisa
Jan 10, 2016
Contributor
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.
This comment has been minimized.
This comment has been minimized.
eddyb
Jan 10, 2016
Member
@nagisa That counts as much as forking Rust does: we don't guarantee anything, nor could we.
mahkoh
reviewed
Jan 10, 2016
| `IntoIterator` trait, removing the `iterator` language item. As a result, `for` loops are the only | ||
| syntax that involves desugaring based on hardcoded paths to items instead of language items. In | ||
| particular, the desugaring references `core::iter::IntoIterator`, `core::iter::Iterator`, and | ||
| `core::option::Option`. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
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. |
nrc
added
the
T-compiler
label
Jan 10, 2016
This comment has been minimized.
This comment has been minimized.
|
@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 |
This comment has been minimized.
This comment has been minimized.
|
@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 |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
That said, I should note that I don't feel especially motivated to support |
This comment has been minimized.
This comment has been minimized.
|
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. |
nikomatsakis
added
the
final-comment-period
label
Jan 14, 2016
This comment has been minimized.
This comment has been minimized.
|
Making |
This comment has been minimized.
This comment has been minimized.
|
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? |
This comment has been minimized.
This comment has been minimized.
|
I am not sure about that. |
This comment has been minimized.
This comment has been minimized.
|
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). |
This comment has been minimized.
This comment has been minimized.
|
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:
|
This comment has been minimized.
This comment has been minimized.
|
(closing; see previous comment for why.) |
apasel422 commentedJan 10, 2016
Rendered