philberty
Joined 5 years ago
Joined 5 years ago
1. Type inference taking into account higher ranked trait bounds
- Slices in libcore work via the Index lang item so its like taking an index operator overload to a range lang item but the generic types in the range need to be unified with the higher ranked trait bound to eventually figure out that they are meant to be of usize.
2. Method resolution its almost a joke at this point how complicated it is in Rust. - The autoderef cycle sounds simple when you read this: https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/book/first-edition/deref-coercions.html
- But this misses so much extra context information
3. Macro invocations there are really subtle rules on how you treat macro invocations such as this which is not documented at all https://github.com/Rust-GCC/gccrs/blob/master/gcc/rust/expan...</rant>
Some day I personally want to write a blog post about how complicated and under spec'd Rust is, then write one about the stuff i do like it such as iterators being part of libcore so i don't need reactive extensions.
Many things in Rust are syntactic sugar and can be handled by desugaring the AST into another IR so you dont even have to think about it in other passes. The main issue for me is how complicate the type inference is.
So if i wanted to use GCC GENERIC for type resolution for this example:
``` let a; a = 123; let b:u32 = 1; a += b; ```
How do you resolve the type of 'a' you must use inference variables and then update the TREE_TYPE as you go so this means walking the tree's over and over again as type information is gathered over time on the inference variable. Using a separate IR and using id's and side tables makes all of this much much more simple for Rust.
1. AST 2. HIR 3. THIR (side-table lookups) 4. GCC Generic
We basically skip MIR in gccrs.
Its pretty sensible to have other IR's, we have many passes in gccrs simplifying things so the graph of what your working with is simpler and simpler each time.
I mean in GCC for C++ for example they use GENERIC and add a bunch of custom tree-codes such as LAMBDA_EXPR or TEMPLATE stuff for example then they keep substituting etc and finally as part of handing off to GCC middle-end it triggers the gimplification of all of these custom tree codes. So even the C++ front-end you could argue has two IR's.
1. Method resolution
2. Unstable?
In particular is it going to define lang items?
3. DST's
Rust has strange things like:
```
let a:&str = "str";
let b:&str = &"str";
```
Which is valid since str is a DST. Although slices and dyn trait are DST they have more strict rules there.
4. Qualified paths
There are more subtle things like qualified paths such as this testcase which could be argued is valid https://github.com/rust-lang/rust/blob/master/src/test/ui/qu... but there was some discussion on zulip which clarifies it: https://rust-lang.zulipchat.com/#narrow/stream/122651-genera...
5. Never type
TLDR: Overall I think its important at some point to start isolating what is the language outside of what version of libcore your running.
So we have AST->HIR->GCC-Generic->GCC
where as rustc is: AST->HIR->THIR->MIR->LLVM-IR->LLVM
I wrote part of the reasons for why I am working on gccrs here: https://news.ycombinator.com/item?id=28368924
Overall I feel sad that this effort has been perceived as some kind of attack against Rustc and its community by some. This effort of mine dates back to 2014 and then I was able to get quite alot of rust working in a short time but the language changed far too much to keep up as a solo effort. Since late 2018 I restarted the effort and seriously almost started the track to develop the a gcc backend using libgccjit, it is 100% something i have considered and thought through.
I will be giving a talk on this project at LPC if you wish to hear more about my reasons please listen then https://linuxplumbersconf.org/event/11/contributions/911/
Libcore just gets compiled like any other rust crate just it does not have access to abstractions.
For example, you can still write C code without libc because C is a language libc is just a library libcore is pretty much the same. Though Rust makes alot of assumptions that libcore _should_ be there but its possible for it not to be.