Skip to content

Commit bd0e3c0

Browse files
committed
2024/12-monthly: Start writing technical blogpost-y bits
1 parent f0da5aa commit bd0e3c0

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

2024/2024-12-monthly-report.org

+58-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,61 @@ Thanks again to [[https://opensrcsec.com/][Open Source Security, inc]] and [[htt
88

99
*** Project update
1010

11-
We accomplished a lot of technical changes during the month of December on three major milestones for the compiler: Auto traits, for-loops, and built-in derives. Both for-loops and built-in derives required a major rework of our AST and HIR in order to handle lang-item paths, a special form of path expressions and path types used when refering directly to [[https://rustc-dev-guide.rust-lang.org/lang-items.html][lang-items]]. This had a big impact to most of the compiler pipeline, as we had to adapt most compiler passes to handle these new paths.
11+
This month of development was focused on three major milestones of compiler development: auto traits, built-in macros and for-loops, which are all important in order to compile ~core 1.49~ and later, the Rust-for-Linux project.
12+
13+
The most widely known auto traits in Rust may be [[https://doc.rust-lang.org/nomicon/send-and-sync.html][Send and Sync]], which are used all throughout the Rust standard library to indicate thread-safety. As such, these traits are often used in trait-bounds to restrict sharing behavior to thread-safe objects:
14+
15+
#+BEGIN_SRC rust
16+
trait Foo {
17+
fn foo(&self);
18+
}
19+
20+
struct Safe;
21+
22+
// We cannot send pointers safely between threads
23+
struct NonThreadSafe(*const i32);
24+
25+
impl Foo for Safe { fn foo(&self) { } }
26+
impl Foo for NonThreadSafe { fn foo(&self) { } }
27+
28+
fn take_foo(foo: &(dyn Foo)) {
29+
foo.foo();
30+
}
31+
32+
fn take_thread_safe_foo(foo: &(dyn Foo + Send + Sync)) {
33+
foo.foo();
34+
}
35+
36+
fn main() {
37+
let s = Safe;
38+
39+
let i = 15;
40+
let n_s = NonThreadSafe(&i as *const i32);
41+
42+
take_foo(&s);
43+
take_foo(&n_s);
44+
45+
take_thread_safe_foo(&s);
46+
take_thread_safe_foo(&n_s);
47+
}
48+
#+END_SRC
49+
50+
Part of our pipeline was missing proper handling for these automatic trait bounds, which now enables us to build this code properly. Two missing features remain for properly handling these special bounds:
51+
52+
1. Extra trait bounds can only be automatic traits
53+
54+
2. Implementing Send and Sync properly
55+
56+
We accomplished a lot of technical changes during the month of December on three major milestones for the compiler: Auto traits, for-loops, and built-in derives.
57+
58+
- Mention why they're important?
59+
- Mention how they're used throughout core and std?
60+
- Mention why we needed to do a rework of our lang items?
61+
- Explain what lang items are
62+
- why can't we use ::core::option::Option::Some?
63+
- How this differs from rustc?
64+
65+
Both for-loops and built-in derives required a major rework of our AST and HIR in order to handle lang-item paths, a special form of path expressions and path types used when refering directly to [[https://rustc-dev-guide.rust-lang.org/lang-items.html][lang-items]]. This had a big impact to most of the compiler pipeline, as we had to adapt most compiler passes to handle these new paths.
1266

1367
*TODO*: Explain why lang item paths are needed for for-loops, with examples.
1468

@@ -18,6 +72,9 @@ Path of the into_iter function:
1872

1973
Once the lang-item fixes were completed, we were able to finish implementing for-loops desugaring, which is currently under review. This then lead to continuing work on built-in derive macros, the last remaining block for macro expansion for core 1.49. These built-in macros often need to refer to other lang-items, such as the ~Clone~ or ~Copy~ trait in order to be expanded properly.
2074

75+
- Explain auto traits
76+
- Explain what remains and how we're going to implement it
77+
2178
We then focused on setting up the basis for the ~Sync~ and ~Send~ auto-traits, which are used throughout core 1.49 and required for many Rust programs. We are now figuring out the last few details of implementing these auto-traits and will add handling for them in the coming weeks.
2279

2380
*** Community call

0 commit comments

Comments
 (0)