/
index.html
193 lines (172 loc) · 4.57 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Writing your own Rust linter</title>
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/black.css">
<link rel="stylesheet" href="css/style.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1>Writing your own Rust linter</h1>
<p>by <span style="color:#cea116;">Guillaume Gomez</span></p>
</section>
<section>
<h2>Who am I?</h2>
Rust language reviewer and contributor.
<span style="padding: 0.9em 0;display: block;">Member of:</span>
<ul>
<li>rustdoc team (team leader)</li>
<li>docs.rs team</li>
<li>dev-tools team</li>
</ul>
<br>
<br>
I am an engineer at Huawei.
</section>
<section data-markdown>
## What is a linter?
</section>
<section data-markdown>
## How a rust linter is actually working?
</section>
<section data-markdown>
## Why does it need to be a rust compiler extension?
</section>
<section data-markdown>
## Limitations
* Can only work on crates compiled with the same rustc version
* rustc API is not stable
* Tied to a specified rustc version
* Annoying to wrap in a cargo command
</section>
<section data-markdown>
## Lint passes
Early vs Late
</section>
<section data-markdown>
## `rustc-tools`
Provides many helpers for setting up lints and cargo integration (and other things...)
```toml
[dependencies]
rustc-tools = "0.3"
```
</section>
<section data-markdown>
## Setup
`Cargo.toml`
```toml
rustc-workspace-hack = "1.0.0"
```
`rust-toolchain`
```toml
[toolchain]
channel = "nightly-2023-10-06"
components = ["rustc-dev", "rustfmt", "llvm-tools-preview"]
```
</section>
<section>
<h2>Declaring a lint</h2>
<br>
<img src="./images/decl-lint.png">
</section>
<section>
<h2>Implementing a lint</h2>
<br>
<img src="./images/impl-lint.png">
</section>
<section>
<h2>main.rs</h2>
<br>
<img src="./images/main.png">
</section>
<section data-markdown>
## Installing our linter
```console
$ cargo install --path [project path]
```
</section>
<section data-transition="slide-in none">
<h2>Running our linter</h2>
<br>
<img src="./images/console.png">
</section>
<section data-transition="none slide-out">
<h2>Running our linter</h2>
<br>
<img src="./images/console-2.png">
</section>
<section>
<img src="./images/cat.jpg">
</section>
<section data-markdown>
## Running our linter (but better)
```console
$ cargo +nightly-2023-10-06 tools-inner
```
</section>
<section>
<h2>Wrapping the wrapper</h2>
<img src="./images/cargo.png">
</section>
<section data-markdown>
## Running our linter (but better better)
```console
$ cargo install --path [project path]
$ cargo tools
```
</section>
<section>
<h2>Blog post version</h2>
<br>
<span style="color:#cea116;">blog.guillaume-gomez.fr/articles/2024-01-18+Writing+your+own+Rust+linter</span>
</section>
<section>
<h2>Thank you for listening!</h2>
More Rust things on <br>< <span style="color:#cea116;">blog.guillaume-gomez.fr</span> >
<br>
<br>
< <span style="color:#cea116;">guillaume1.gomez@gmail.com</span> >
<br>
<br>
<img src="github.svg" class="inline-img" style="background: #ddd;border-radius: 50%;"> @GuillaumeGomez
<br>
<img src="twitter.svg" class="inline-img"> @imperioworld_
<br>
<img src="mastodon.svg" class="inline-img"> @imperio@toot.cat
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
Reveal.initialize({
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
],
autoAnimate: false,
progress: true,
});
</script>
</body>
</html>