Make small contributions to Rust

Original link: http://catcoding.me/p/contribute-to-rust/

I haven’t written an article for a while, and I’ve been addicted to contributing to Rust Compiler recently. I’ll share my gains and feelings here.

The opportunity was that the Rust Issue reached the milestone of 10,000 that day, so I clicked in and took a look. I remembered that I spent a week of spare time doing a diagnostic PR to de-duplicate last year, and I took a look at some recent issues. I found an issue that seemed more suitable, and assigned it to myself.

Two days later, I actually received a message from a colleague of the company in Teams. He asked me when this issue would be resolved, because the raw-dylib function is going to be stable, and he is still waiting for this issue. I usually don’t get called for work, but I didn’t expect that I would be called upon to pick up an open source issue, haha. So I quickly sent a PR and took a look at the raw-dylib function , which is related to Rust linking dlls. Many Rust issues on Windows depend on this RFC.

Later, I went on to do a few diagnostics issues. This kind of problem is most suitable for novice compiler developers, because it is usually not complicated to fix. I basically read the Rust Parser part of the code in the process.

A very important skill for beginners to learn Rust is to understand Rust’s error messages, many of which are suitable for the compiler to prompt us to write programs. The compiler’s error message is very important. Too little information will not explain the problem, and too detailed will make people crazy. The Rust compiler is really good at reporting errors, basically because developers found a better way to report errors and added them by themselves.

In the process of doing this, I found that the Rust compiler’s prompts are very user-friendly. For example, if Parser finds that you have written a public in the place where you should write pub , it will prompt you whether you should write pub . For example, if you write an import mod , then It will prompt you whether you should write use , and even if you find Unicode chars that are not easy to display, you will be prompted to pay attention here. Some of the tips about the life cycle will also add various good-looking graph marks.

Even, they recently started doing diagnostics language localization Diagnostic Translation

In addition, Rust’s hints can also add more useful information after type deduction. If we are sure that the hints here are the only fix, it can be automatically repaired by rust-fix, so you can see the unit test of the Rust compiler repo There are many comparison files with the .fix suffix.

Another bug I recently fixed was found in the Tikv project. When there is Arc::default() in the function parameter, from the results of the type analysis, this parameter can satisfy multiple other parameters, so that when analyzing the missing There is a problem when the parameters give proper hints, that algorithm leads to an infinite loop. I spent a lot of time writing minimal test cases and finally came up with a fix. I also like to analyze these kinds of bugs, which are full of suspense like a novel.

During this time, I also chatted with colleagues in some companies who are working full-time on Rust, and found that Microsoft already has several groups working full-time, mainly focusing on Rust, Windows, and development tools. In addition, I communicated with several other developers in the community, and there are some from Huawei.

Rust is purely a language that grows freely on the Internet. The founder has long since withdrawn from dominance. The main core members are freely formed by the community. There is no absolute dictator here. Almost all of the people I encounter are contributing with passion. For example, the developer compiler-errors , who has been very active in the past year, once I urged him to review the PR. He said that I am not working on Rust full-time, so I need to arrange the time myself. Don’t rush. I then chatted with him, his day job has absolutely nothing to do with Rust, spending so much time is just a hobby.

It’s open enough here. Basically, if you want to participate in Rust development, the threshold is not high.

I am not advocating how good Rust is, Rust naturally has many problems, the learning cost is relatively steep, and it is not suitable for many daily projects. From a utilitarian point of view, the input-output ratio is not high.

I just think Rust is fun and open enough. It has absorbed many years of programming language theories. It comes entirely from the open source community and first-line developers. Everything is practical, so it is not as pedantic as OCaml and Hashkell, and is interested in programming languages. Friends can pay more attention.

Here are a few aspects of why I can sink in and do some seemingly tedious open source work:

First, I am very interested in the implementation of programming languages. I basically finished reading the EOPL book a few years ago, and I also made a lot of small interpreters in it. It can be said that compiling is a little romance for programmers. It is easier to look at the code with questions. After reading the Parser section, I plan to look at type analysis.

Second, the tool chain of Rust has been greatly improved in recent years. For example, for large projects such as the Rust compiler, VSCode + Rust Analyzer can handle it well, and can do almost all variable jumps, function call jumps and call relationship analysis. , type hints, etc. Rust can show its advantages in such large-scale projects and projects that are maintained by many people. With the help of the compiler and type system, the experience and efficiency of looking up and writing code is much better, which is different from my daily work. Tossing and turning in old PowerShell is so much better.

Third, in my daily work in the past two years, I have been exposed to a lot of old code, which is actually ugly, but can make a lot of money for the company every year. We often say that improving programming skills requires learning from good code, but I find that being forced to touch some ugly historical code is very beneficial to the heart of programming, because in the future you will see a lot of beautiful code, and be patient when programming and debugging a lot.

Interested can communicate ?

This article is reproduced from: http://catcoding.me/p/contribute-to-rust/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment