on master help sign in
Merge pull request #11 from fitzgen/fix-cached-uaf
d3a735fNick Fitzgerald
.travis.yml+6−2
@@ -29,13 +29,17 @@ matrix:
29 - name: "build (nightly)"
29 - name: "build (nightly)"
30 rust: nightly
30 rust: nightly
31 script: INSTALL=1 ./build.sh
31 script: INSTALL=1 ./build.sh
32− - name: "test (firefox)"
32+ - name: "headless browser tests (firefox)"
33 rust: stable
33 rust: stable
34 addons:
34 addons:
35 firefox: latest
35 firefox: latest
36 script: wasm-pack test --firefox --headless
36 script: wasm-pack test --firefox --headless
37− - name: "test (chrome)"
37+ - name: "headless browser tests (chrome)"
38 rust: stable
38 rust: stable
39 addons:
39 addons:
40 chrome: stable
40 chrome: stable
41 script: wasm-pack test --chrome --headless
41 script: wasm-pack test --chrome --headless
42+ - name: "native tests"
43+ rust: stable
44+ install: echo "no install"
45+ script: cargo test --all
Cargo.lock+202−16
@@ -11,7 +11,7 @@ name = "atty"
11version = "0.2.11"
11version = "0.2.11"
12source = "registry+https://github.com/rust-lang/crates.io-index"
12source = "registry+https://github.com/rust-lang/crates.io-index"
13dependencies = [
13dependencies = [
14− "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)",
14+ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
15 "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
15 "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
16 "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
16 "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
17]
17]
@@ -29,7 +29,7 @@ dependencies = [
29 "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
29 "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
30 "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
30 "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
31 "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
31 "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
32− "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)",
32+ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
33 "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
33 "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
34 "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
34 "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
35]
35]
@@ -40,7 +40,7 @@ version = "0.1.28"
40source = "registry+https://github.com/rust-lang/crates.io-index"
40source = "registry+https://github.com/rust-lang/crates.io-index"
41dependencies = [
41dependencies = [
42 "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
42 "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
43− "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)",
43+ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
44]
44]
45
45
46[[package]]
46[[package]]
@@ -58,6 +58,34 @@ name = "cfg-if"
58version = "0.1.6"
58version = "0.1.6"
59source = "registry+https://github.com/rust-lang/crates.io-index"
59source = "registry+https://github.com/rust-lang/crates.io-index"
60
60
61+[[package]]
62+name = "compile-tests"
63+version = "0.1.0"
64+dependencies = [
65+ "compiletest_rs 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
66+ "dodrio 0.1.0",
67+]
68+
69+[[package]]
70+name = "compiletest_rs"
71+version = "0.3.18"
72+source = "registry+https://github.com/rust-lang/crates.io-index"
73+dependencies = [
74+ "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
75+ "filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
76+ "getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
77+ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
78+ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
79+ "miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
80+ "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
81+ "rustfix 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
82+ "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)",
83+ "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)",
84+ "serde_json 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
85+ "tester 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
86+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
87+]
88+
61[[package]]
89[[package]]
62name = "console_error_panic_hook"
90name = "console_error_panic_hook"
63version = "0.1.5"
91version = "0.1.5"
@@ -76,6 +104,11 @@ dependencies = [
76 "web-sys 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
104 "web-sys 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
77]
105]
78
106
107+[[package]]
108+name = "diff"
109+version = "0.1.11"
110+source = "registry+https://github.com/rust-lang/crates.io-index"
111+
79[[package]]
112[[package]]
80name = "dodrio"
113name = "dodrio"
81version = "0.1.0"
114version = "0.1.0"
@@ -157,11 +190,29 @@ dependencies = [
157 "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
190 "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
158]
191]
159
192
193+[[package]]
194+name = "filetime"
195+version = "0.2.4"
196+source = "registry+https://github.com/rust-lang/crates.io-index"
197+dependencies = [
198+ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
199+ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
200+ "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
201+]
202+
160[[package]]
203[[package]]
161name = "futures"
204name = "futures"
162version = "0.1.25"
205version = "0.1.25"
163source = "registry+https://github.com/rust-lang/crates.io-index"
206source = "registry+https://github.com/rust-lang/crates.io-index"
164
207
208+[[package]]
209+name = "getopts"
210+version = "0.2.18"
211+source = "registry+https://github.com/rust-lang/crates.io-index"
212+dependencies = [
213+ "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
214+]
215+
165[[package]]
216[[package]]
166name = "heck"
217name = "heck"
167version = "0.3.1"
218version = "0.3.1"
@@ -178,6 +229,11 @@ dependencies = [
178 "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
229 "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
179]
230]
180
231
232+[[package]]
233+name = "itoa"
234+version = "0.4.3"
235+source = "registry+https://github.com/rust-lang/crates.io-index"
236+
181[[package]]
237[[package]]
182name = "js-sys"
238name = "js-sys"
183version = "0.3.10"
239version = "0.3.10"
@@ -186,6 +242,15 @@ dependencies = [
186 "wasm-bindgen 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
242 "wasm-bindgen 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
187]
243]
188
244
245+[[package]]
246+name = "kernel32-sys"
247+version = "0.2.2"
248+source = "registry+https://github.com/rust-lang/crates.io-index"
249+dependencies = [
250+ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
251+ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
252+]
253+
189[[package]]
254[[package]]
190name = "lazy_static"
255name = "lazy_static"
191version = "1.2.0"
256version = "1.2.0"
@@ -193,7 +258,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
193
258
194[[package]]
259[[package]]
195name = "libc"
260name = "libc"
196−version = "0.2.47"
261+version = "0.2.48"
197source = "registry+https://github.com/rust-lang/crates.io-index"
262source = "registry+https://github.com/rust-lang/crates.io-index"
198
263
199[[package]]
264[[package]]
@@ -210,15 +275,25 @@ version = "2.1.3"
210source = "registry+https://github.com/rust-lang/crates.io-index"
275source = "registry+https://github.com/rust-lang/crates.io-index"
211dependencies = [
276dependencies = [
212 "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
277 "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
278+ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
279+]
280+
281+[[package]]
282+name = "miow"
283+version = "0.3.3"
284+source = "registry+https://github.com/rust-lang/crates.io-index"
285+dependencies = [
286+ "socket2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
213− "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)",
287+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
214]
288]
215
289
216[[package]]
290[[package]]
217name = "nom"
291name = "nom"
218−version = "4.1.1"
292+version = "4.2.0"
219source = "registry+https://github.com/rust-lang/crates.io-index"
293source = "registry+https://github.com/rust-lang/crates.io-index"
220dependencies = [
294dependencies = [
221 "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
295 "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
296+ "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
222]
297]
223
298
224[[package]]
299[[package]]
@@ -262,14 +337,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
262dependencies = [
337dependencies = [
263 "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
338 "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
264 "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
339 "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
265− "regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
340+ "regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
266 "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
341 "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
267 "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
342 "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
268]
343]
269
344
270[[package]]
345[[package]]
271name = "regex-syntax"
346name = "regex-syntax"
272−version = "0.6.4"
347+version = "0.6.5"
273source = "registry+https://github.com/rust-lang/crates.io-index"
348source = "registry+https://github.com/rust-lang/crates.io-index"
274dependencies = [
349dependencies = [
275 "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
350 "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -280,11 +355,64 @@ name = "rustc-demangle"
280version = "0.1.13"
355version = "0.1.13"
281source = "registry+https://github.com/rust-lang/crates.io-index"
356source = "registry+https://github.com/rust-lang/crates.io-index"
282
357
358+[[package]]
359+name = "rustfix"
360+version = "0.4.4"
361+source = "registry+https://github.com/rust-lang/crates.io-index"
362+dependencies = [
363+ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
364+ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
365+ "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)",
366+ "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)",
367+ "serde_json 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
368+]
369+
370+[[package]]
371+name = "ryu"
372+version = "0.2.7"
373+source = "registry+https://github.com/rust-lang/crates.io-index"
374+
283[[package]]
375[[package]]
284name = "scoped-tls"
376name = "scoped-tls"
285version = "0.1.2"
377version = "0.1.2"
286source = "registry+https://github.com/rust-lang/crates.io-index"
378source = "registry+https://github.com/rust-lang/crates.io-index"
287
379
380+[[package]]
381+name = "serde"
382+version = "1.0.85"
383+source = "registry+https://github.com/rust-lang/crates.io-index"
384+
385+[[package]]
386+name = "serde_derive"
387+version = "1.0.85"
388+source = "registry+https://github.com/rust-lang/crates.io-index"
389+dependencies = [
390+ "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)",
391+ "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
392+ "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)",
393+]
394+
395+[[package]]
396+name = "serde_json"
397+version = "1.0.37"
398+source = "registry+https://github.com/rust-lang/crates.io-index"
399+dependencies = [
400+ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
401+ "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
402+ "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)",
403+]
404+
405+[[package]]
406+name = "socket2"
407+version = "0.3.8"
408+source = "registry+https://github.com/rust-lang/crates.io-index"
409+dependencies = [
410+ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
411+ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
412+ "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
413+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
414+]
415+
288[[package]]
416[[package]]
289name = "sourcefile"
417name = "sourcefile"
290version = "0.1.4"
418version = "0.1.4"
@@ -311,6 +439,15 @@ dependencies = [
311 "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
439 "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
312]
440]
313
441
442+[[package]]
443+name = "term"
444+version = "0.4.6"
445+source = "registry+https://github.com/rust-lang/crates.io-index"
446+dependencies = [
447+ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
448+ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
449+]
450+
314[[package]]
451[[package]]
315name = "termcolor"
452name = "termcolor"
316version = "1.0.4"
453version = "1.0.4"
@@ -324,11 +461,21 @@ name = "termion"
324version = "1.5.1"
461version = "1.5.1"
325source = "registry+https://github.com/rust-lang/crates.io-index"
462source = "registry+https://github.com/rust-lang/crates.io-index"
326dependencies = [
463dependencies = [
327− "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)",
464+ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
328 "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
465 "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
329 "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
466 "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
330]
467]
331
468
469+[[package]]
470+name = "tester"
471+version = "0.5.0"
472+source = "registry+https://github.com/rust-lang/crates.io-index"
473+dependencies = [
474+ "getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
475+ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
476+ "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
477+]
478+
332[[package]]
479[[package]]
333name = "thread_local"
480name = "thread_local"
334version = "0.3.6"
481version = "0.3.6"
@@ -347,6 +494,11 @@ name = "unicode-segmentation"
347version = "1.2.1"
494version = "1.2.1"
348source = "registry+https://github.com/rust-lang/crates.io-index"
495source = "registry+https://github.com/rust-lang/crates.io-index"
349
496
497+[[package]]
498+name = "unicode-width"
499+version = "0.1.5"
500+source = "registry+https://github.com/rust-lang/crates.io-index"
501+
350[[package]]
502[[package]]
351name = "unicode-xid"
503name = "unicode-xid"
352version = "0.1.0"
504version = "0.1.0"
@@ -357,6 +509,11 @@ name = "utf8-ranges"
357version = "1.0.2"
509version = "1.0.2"
358source = "registry+https://github.com/rust-lang/crates.io-index"
510source = "registry+https://github.com/rust-lang/crates.io-index"
359
511
512+[[package]]
513+name = "version_check"
514+version = "0.1.5"
515+source = "registry+https://github.com/rust-lang/crates.io-index"
516+
360[[package]]
517[[package]]
361name = "wasm-bindgen"
518name = "wasm-bindgen"
362version = "0.2.33"
519version = "0.2.33"
@@ -470,9 +627,14 @@ name = "weedle"
470version = "0.8.0"
627version = "0.8.0"
471source = "registry+https://github.com/rust-lang/crates.io-index"
628source = "registry+https://github.com/rust-lang/crates.io-index"
472dependencies = [
629dependencies = [
473− "nom 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
630+ "nom 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
474]
631]
475
632
633+[[package]]
634+name = "winapi"
635+version = "0.2.8"
636+source = "registry+https://github.com/rust-lang/crates.io-index"
637+
476[[package]]
638[[package]]
477name = "winapi"
639name = "winapi"
478version = "0.3.6"
640version = "0.3.6"
@@ -482,6 +644,11 @@ dependencies = [
482 "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
644 "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
483]
645]
484
646
647+[[package]]
648+name = "winapi-build"
649+version = "0.1.1"
650+source = "registry+https://github.com/rust-lang/crates.io-index"
651+
485[[package]]
652[[package]]
486name = "winapi-i686-pc-windows-gnu"
653name = "winapi-i686-pc-windows-gnu"
487version = "0.4.0"
654version = "0.4.0"
@@ -489,7 +656,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
489
656
490[[package]]
657[[package]]
491name = "winapi-util"
658name = "winapi-util"
492−version = "0.1.1"
659+version = "0.1.2"
493source = "registry+https://github.com/rust-lang/crates.io-index"
660source = "registry+https://github.com/rust-lang/crates.io-index"
494dependencies = [
661dependencies = [
495 "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
662 "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -506,7 +673,7 @@ version = "1.0.1"
506source = "registry+https://github.com/rust-lang/crates.io-index"
673source = "registry+https://github.com/rust-lang/crates.io-index"
507dependencies = [
674dependencies = [
508 "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
675 "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
509− "winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
676+ "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
510]
677]
511
678
512[metadata]
679[metadata]
@@ -518,39 +685,56 @@ dependencies = [
518"checksum bumpalo 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "38da2bd7a4195f03c07e3cb21d7963729722541c6b94ec245ac818eab48b2ff7"
685"checksum bumpalo 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "38da2bd7a4195f03c07e3cb21d7963729722541c6b94ec245ac818eab48b2ff7"
519"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749"
686"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749"
520"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
687"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
688+"checksum compiletest_rs 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0d76d4322a40f6b0db7259d4f2c8a65ed8b0d84fce0bbc61b98cf47f8ec6eec3"
521"checksum console_error_panic_hook 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6c5dd2c094474ec60a6acaf31780af270275e3153bafff2db5995b715295762e"
689"checksum console_error_panic_hook 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6c5dd2c094474ec60a6acaf31780af270275e3153bafff2db5995b715295762e"
522"checksum console_log 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1e7871d2947441b0fdd8e2bd1ce2a2f75304f896582c0d572162d48290683c48"
690"checksum console_log 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1e7871d2947441b0fdd8e2bd1ce2a2f75304f896582c0d572162d48290683c48"
691+"checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a"
523"checksum env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e"
692"checksum env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e"
524"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
693"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
525"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
694"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
695+"checksum filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a2df5c1a8c4be27e7707789dc42ae65976e60b394afd293d1419ab915833e646"
526"checksum futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "49e7653e374fe0d0c12de4250f0bdb60680b8c80eed558c5c7538eec9c89e21b"
696"checksum futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "49e7653e374fe0d0c12de4250f0bdb60680b8c80eed558c5c7538eec9c89e21b"
697+"checksum getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0a7292d30132fb5424b354f5dc02512a86e4c516fe544bb7a25e7f266951b797"
527"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
698"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
528"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114"
699"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114"
700+"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
529"checksum js-sys 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)" = "f0edfcbe54ba2071053f2e67f5dfbcea344b69aedfb371b76e27392427a5750f"
701"checksum js-sys 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)" = "f0edfcbe54ba2071053f2e67f5dfbcea344b69aedfb371b76e27392427a5750f"
702+"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
530"checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1"
703"checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1"
531−"checksum libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "48450664a984b25d5b479554c29cc04e3150c97aa4c01da5604a2d4ed9151476"
704+"checksum libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "e962c7641008ac010fa60a7dfdc1712449f29c44ef2d4702394aea943ee75047"
532"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
705"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
533"checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8"
706"checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8"
534−"checksum nom 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9c349f68f25f596b9f44cf0e7c69752a5c633b0550c3ff849518bfba0233774a"
707+"checksum miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "396aa0f2003d7df8395cb93e09871561ccc3e785f0acb369170e8cc74ddf9226"
708+"checksum nom 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b30adc557058ce00c9d0d7cb3c6e0b5bc6f36e2e2eabe74b0ba726d194abd588"
535"checksum proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)" = "38fddd23d98b2144d197c0eca5705632d4fe2667d14a6be5df8934f8d74f1978"
709"checksum proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)" = "38fddd23d98b2144d197c0eca5705632d4fe2667d14a6be5df8934f8d74f1978"
536"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
710"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
537"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1"
711"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1"
538"checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85"
712"checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85"
539"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
713"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
540"checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f"
714"checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f"
541−"checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1"
715+"checksum regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8c2f35eedad5295fdf00a63d7d4b238135723f92b434ec06774dad15c7ab0861"
542"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619"
716"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619"
717+"checksum rustfix 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "af7c21531a91512a4a51b490be6ba1c8eff34fdda0dc5bf87dc28d86748aac56"
718+"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7"
543"checksum scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "332ffa32bf586782a3efaeb58f127980944bbc8c4d6913a86107ac2a5ab24b28"
719"checksum scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "332ffa32bf586782a3efaeb58f127980944bbc8c4d6913a86107ac2a5ab24b28"
720+"checksum serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "534b8b91a95e0f71bca3ed5824752d558da048d4248c91af873b63bd60519752"
721+"checksum serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "a915306b0f1ac5607797697148c223bedeaa36bcc2e28a01441cd638cc6567b4"
722+"checksum serde_json 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "4b90a9fbe1211e57d3e1c15670f1cb00802988fb23a1a4aad7a2b63544f1920e"
723+"checksum socket2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d11a52082057d87cb5caa31ad812f4504b97ab44732cd8359df2e9ff9f48e7"
544"checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3"
724"checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3"
545"checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9"
725"checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9"
546"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015"
726"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015"
727+"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1"
547"checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f"
728"checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f"
548"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
729"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
730+"checksum tester 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5e812cb26c597f86a49b26dbb58b878bd2a2b4b93fc069dc39499228fe556ff6"
549"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
731"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
550"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
732"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
551"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1"
733"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1"
734+"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
552"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
735"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
553"checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737"
736"checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737"
737+"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
554"checksum wasm-bindgen 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "2d8c1eb210a0e91e24feb8ccd6f7484a5d442bfdf2ff179204b3a1d16e1029cc"
738"checksum wasm-bindgen 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "2d8c1eb210a0e91e24feb8ccd6f7484a5d442bfdf2ff179204b3a1d16e1029cc"
555"checksum wasm-bindgen-backend 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "57ab9a5e88bf5dea5be82bb5f8b68c0f8e550675796ac88570ea4c4e89923413"
739"checksum wasm-bindgen-backend 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "57ab9a5e88bf5dea5be82bb5f8b68c0f8e550675796ac88570ea4c4e89923413"
556"checksum wasm-bindgen-futures 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d35a917b7c857bf8bce3e47d51d7d74a074d467aa2b750857fc7d9f878483124"
740"checksum wasm-bindgen-futures 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d35a917b7c857bf8bce3e47d51d7d74a074d467aa2b750857fc7d9f878483124"
@@ -562,8 +746,10 @@ dependencies = [
562"checksum wasm-bindgen-webidl 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)" = "068ab8c6b5682c5ac2aa7c2178ecdfc91143e3d62da458997ee1299c3fbf0e85"
746"checksum wasm-bindgen-webidl 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)" = "068ab8c6b5682c5ac2aa7c2178ecdfc91143e3d62da458997ee1299c3fbf0e85"
563"checksum web-sys 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53890ae11f09f4f08f8dc0d76d03cedfb4aa1f667b17ee1b9d6aa23b314cb940"
747"checksum web-sys 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53890ae11f09f4f08f8dc0d76d03cedfb4aa1f667b17ee1b9d6aa23b314cb940"
564"checksum weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "26a4c67f132386d965390b8a734d5d10adbcd30eb5cc74bd9229af8b83f10044"
748"checksum weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "26a4c67f132386d965390b8a734d5d10adbcd30eb5cc74bd9229af8b83f10044"
749+"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
565"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
750"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
751+"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
566"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
752"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
567−"checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab"
753+"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9"
568"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
754"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
569"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba"
755"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba"
Cargo.toml+1
@@ -41,6 +41,7 @@ opt-level = "s"
41
41
42[workspace]
42[workspace]
43members = [
43members = [
44+ "./compile-tests",
44 "./examples/counter/crate",
45 "./examples/counter/crate",
45 "./examples/hello-world/crate",
46 "./examples/hello-world/crate",
46 "./examples/input-form/crate",
47 "./examples/input-form/crate",
compile-tests/Cargo.tomlnew file+11
@@ -0,0 +1,11 @@
1+[package]
2+name = "compile-tests"
3+version = "0.1.0"
4+authors = ["Nick Fitzgerald <fitzgen@gmail.com>"]
5+publish = false
6+
7+[dependencies]
8+dodrio = { path = ".." }
9+
10+[dev-dependencies]
11+compiletest_rs = { version = "0.3.18", features = ["norustc", "stable"] }
compile-tests/compile-fail/cached_uaf.rsnew file+58
@@ -0,0 +1,58 @@
1+extern crate bumpalo;
2+extern crate dodrio;
3+extern crate web_sys;
4+
5+use bumpalo::Bump;
6+use dodrio::{Cached, Node, Render, Vdom};
7+use std::cell::Cell;
8+
9+pub struct CountRenders {
10+ render_count: Cell<usize>,
11+}
12+
13+impl CountRenders {
14+ pub fn new() -> CountRenders {
15+ CountRenders {
16+ render_count: Cell::new(0),
17+ }
18+ }
19+}
20+
21+impl Render for CountRenders {
22+ fn render<'a, 'bump>(&'a self, bump: &'bump Bump) -> Node<'bump>
23+ where
24+ 'a: 'bump,
25+ {
26+ let count = self.render_count.get() + 1;
27+ self.render_count.set(count);
28+
29+ let s = bumpalo::format!(in bump, "{}", count);
30+ Node::text(s.into_bump_str())
31+ }
32+}
33+
34+fn use_after_free_with_cached_components() {
35+ let container = web_sys::window()
36+ .unwrap()
37+ .document()
38+ .unwrap()
39+ .create_element("div")
40+ .unwrap();
41+
42+ // Create a component that caches its own rendered results.
43+ let mut cached = Cached::new(CountRenders::new());
44+
45+ // The vdom's current root is pointing into cached's bump memory.
46+ let mut vdom = Vdom::new(&container, &cached);
47+
48+ // Drop the cached component and its bump memory.
49+ drop(cached);
50+ //~^ ERROR
51+
52+ // Rendering a new component will diff against the current component's last
53+ // render, which will be stored in the (now freed) bump inside
54+ // `Cached`. Yikes!
55+ vdom.render_component(&CountRenders::new());
56+}
57+
58+fn main() {}
compile-tests/src/main.rsnew file+26
@@ -0,0 +1,26 @@
1+fn main() {}
2+
3+#[cfg(test)]
4+mod tests {
5+ extern crate compiletest_rs as compiletest;
6+ use std::path::PathBuf;
7+
8+ fn run_mode(mode: &'static str) {
9+ let mut config = self::compiletest::Config::default();
10+
11+ config.mode = mode.parse().expect("Invalid mode");
12+ config.src_base = PathBuf::from(format!("{}", mode));
13+
14+ // Populate config.target_rustcflags with dependencies on the path.
15+ config.link_deps();
16+ // If your tests import the parent crate, this helps with E0464
17+ config.clean_rmeta();
18+
19+ compiletest::run_tests(&config);
20+ }
21+
22+ #[test]
23+ fn compile_test() {
24+ run_mode("compile-fail");
25+ }
26+}
examples/counter/crate/src/lib.rs+5−5
@@ -65,8 +65,8 @@ pub fn run() {
65 let document = window.document().unwrap();
65 let document = window.document().unwrap();
66 let body = document.body().unwrap();
66 let body = document.body().unwrap();
67
67
68− let mut counter = Counter::new();
68+ let counter = Counter::new();
69− let mut vdom = dodrio::Vdom::new(&body, &counter);
69+ let mut vdom = dodrio::Vdom::new(&body, counter);
70
70
71 let on_click = Closure::wrap(Box::new(move |event: web_sys::MouseEvent| {
71 let on_click = Closure::wrap(Box::new(move |event: web_sys::MouseEvent| {
72 match event
72 match event
@@ -74,11 +74,11 @@ pub fn run() {
74 .and_then(|t| t.dyn_into::<web_sys::Element>().ok())
74 .and_then(|t| t.dyn_into::<web_sys::Element>().ok())
75 .and_then(|e| e.get_attribute("data-action"))
75 .and_then(|e| e.get_attribute("data-action"))
76 {
76 {
77− Some(ref s) if s == "increment" => counter.increment(),
77+ Some(ref s) if s == "increment" => vdom.component_mut().increment(),
78− Some(ref s) if s == "decrement" => counter.decrement(),
78+ Some(ref s) if s == "decrement" => vdom.component_mut().decrement(),
79 _ => {}
79 _ => {}
80 }
80 }
81− vdom.render(&counter);
81+ vdom.render();
82 }) as Box<FnMut(_)>);
82 }) as Box<FnMut(_)>);
83
83
84 let _ = body.add_event_listener_with_callback("click", on_click.as_ref().unchecked_ref());
84 let _ = body.add_event_listener_with_callback("click", on_click.as_ref().unchecked_ref());
examples/hello-world/crate/src/lib.rs+2−2
@@ -34,8 +34,8 @@ pub fn run() {
34
34
35 // Create a new dodrio vdom contained in the body, with an initial virtual
35 // Create a new dodrio vdom contained in the body, with an initial virtual
36 // dom.
36 // dom.
37− let mut vdom = dodrio::Vdom::new(body.as_ref(), &HelloWorld::new("World"));
37+ let vdom = dodrio::Vdom::new(body.as_ref(), HelloWorld::new("World"));
38
38
39 // Render a new node tree into the virtual dom.
39 // Render a new node tree into the virtual dom.
40− vdom.render(&HelloWorld::new("Dodrio"));
40+ vdom.render_component(HelloWorld::new("Dodrio"));
41}
41}
examples/input-form/crate/src/lib.rs+4−4
@@ -54,8 +54,8 @@ pub fn run() {
54 let document = window.document().unwrap();
54 let document = window.document().unwrap();
55 let body = document.body().unwrap();
55 let body = document.body().unwrap();
56
56
57− let mut say_hello = SayHelloTo::new("World");
57+ let say_hello = SayHelloTo::new("World");
58− let mut vdom = dodrio::Vdom::new(&body, &say_hello);
58+ let mut vdom = dodrio::Vdom::new(&body, say_hello);
59
59
60 let on_input = Closure::wrap(Box::new(move |event: web_sys::MouseEvent| {
60 let on_input = Closure::wrap(Box::new(move |event: web_sys::MouseEvent| {
61 let input = match event
61 let input = match event
@@ -66,8 +66,8 @@ pub fn run() {
66 None => return,
66 None => return,
67 };
67 };
68
68
69− say_hello.set_who(input.value());
69+ vdom.component_mut().set_who(input.value());
70− vdom.render(&say_hello);
70+ vdom.render();
71 }) as Box<FnMut(_)>);
71 }) as Box<FnMut(_)>);
72
72
73 let _ = body.add_event_listener_with_callback("input", on_input.as_ref().unchecked_ref());
73 let _ = body.add_event_listener_with_callback("input", on_input.as_ref().unchecked_ref());
src/cached.rs+2
@@ -28,6 +28,7 @@ impl<R> Cached<R> {
28 /// # Example
28 /// # Example
29 ///
29 ///
30 /// ```
30 /// ```
31+ /// use bumpalo::Bump;
31 /// use dodrio::{Cached, Node, Render};
32 /// use dodrio::{Cached, Node, Render};
32 ///
33 ///
33 /// pub struct Counter {
34 /// pub struct Counter {
@@ -74,6 +75,7 @@ impl<R> Cached<R> {
74 /// displaying greetings to old `who`s.
75 /// displaying greetings to old `who`s.
75 ///
76 ///
76 /// ```
77 /// ```
78+ /// use bumpalo::Bump;
77 /// use dodrio::{Cached, Node, Render};
79 /// use dodrio::{Cached, Node, Render};
78 ///
80 ///
79 /// /// A component that renders to "<p>Hello, {who}!</p>"
81 /// /// A component that renders to "<p>Hello, {who}!</p>"
src/lib.rs+12
@@ -18,3 +18,15 @@ pub trait Render {
18 where
18 where
19 'a: 'bump;
19 'a: 'bump;
20}
20}
21+
22+impl<'r, R> Render for &'r R
23+where
24+ R: Render,
25+{
26+ fn render<'a, 'bump>(&'a self, bump: &'bump Bump) -> Node<'bump>
27+ where
28+ 'a: 'bump,
29+ {
30+ (**self).render(bump)
31+ }
32+}
src/vdom.rs+50−13
@@ -6,12 +6,14 @@ use log::*;
6use std::cmp;
6use std::cmp;
7use std::mem;
7use std::mem;
8
8
9−pub struct Vdom {
9+pub struct Vdom<R> {
10+ component: R,
10 dom_buffers: [Bump; 2],
11 dom_buffers: [Bump; 2],
11 change_list: ChangeList,
12 change_list: ChangeList,
12 container: web_sys::Element,
13 container: web_sys::Element,
13
14
14− // Actually a reference into `self.dom_buffers[0]`.
15+ // Actually a reference into `self.dom_buffers[0]` or if `self.component` is
16+ // caching renders, into `self.component`'s bump.
15 current_root: Option<Node<'static>>,
17 current_root: Option<Node<'static>>,
16}
18}
17
19
@@ -19,11 +21,11 @@ unsafe fn extend_node_lifetime<'a>(node: Node<'a>) -> Node<'static> {
19 mem::transmute(node)
21 mem::transmute(node)
20}
22}
21
23
22−impl Vdom {
24+impl<R> Vdom<R>
25+where
26+ R: Render,
27+{
23− pub fn new<R>(container: &web_sys::Element, contents: &R) -> Vdom
28+ pub fn new(container: &web_sys::Element, component: R) -> Vdom<R> {
24− where
25− R: Render,
26− {
27 let dom_buffers = [Bump::new(), Bump::new()];
29 let dom_buffers = [Bump::new(), Bump::new()];
28 let change_list = ChangeList::new(container);
30 let change_list = ChangeList::new(container);
29
31
@@ -49,26 +51,45 @@ impl Vdom {
49 // Diff and apply the `contents` against our dummy `<div/>`.
51 // Diff and apply the `contents` against our dummy `<div/>`.
50 let container = container.clone();
52 let container = container.clone();
51 let mut vdom = Vdom {
53 let mut vdom = Vdom {
54+ component,
52 dom_buffers,
55 dom_buffers,
53 change_list,
56 change_list,
54 container,
57 container,
55 current_root,
58 current_root,
56 };
59 };
57− vdom.render(contents);
60+ vdom.render();
58 vdom
61 vdom
59 }
62 }
60
63
64+ /// Get a shared reference to the underlying render component.
65+ #[inline]
66+ pub fn component(&self) -> &R {
67+ &self.component
68+ }
69+
70+ /// Get an exclusive reference to the underlying render component.
71+ #[inline]
72+ pub fn component_mut(&mut self) -> &mut R {
73+ &mut self.component
74+ }
75+
76+ /// Take the render component out of this virtual DOM.
77+ #[inline]
78+ pub fn into_component(self) -> R {
79+ self.component
80+ }
81+
82+ /// Get a reference to the physical DOM node that reflects this virtual DOM
83+ /// tree.
61 pub fn container(&self) -> &web_sys::Element {
84 pub fn container(&self) -> &web_sys::Element {
62 &self.container
85 &self.container
63 }
86 }
64
87
88+ /// Re-render this virtual dom's current component.
65− pub fn render<R>(&mut self, contents: &R)
89+ pub fn render(&mut self) {
66− where
67− R: Render,
68− {
69 unsafe {
90 unsafe {
70 self.dom_buffers[1].reset();
91 self.dom_buffers[1].reset();
71− let new_contents = contents.render(&self.dom_buffers[1]);
92+ let new_contents = self.component.render(&self.dom_buffers[1]);
72 let new_contents = extend_node_lifetime(new_contents);
93 let new_contents = extend_node_lifetime(new_contents);
73
94
74 let old_contents = self.current_root.take().unwrap();
95 let old_contents = self.current_root.take().unwrap();
@@ -81,6 +102,22 @@ impl Vdom {
81 }
102 }
82 }
103 }
83
104
105+ /// Render a new component.
106+ pub fn render_component<S>(self, component: S) -> Vdom<S>
107+ where
108+ S: Render,
109+ {
110+ let mut vdom = Vdom {
111+ component,
112+ dom_buffers: self.dom_buffers,
113+ change_list: self.change_list,
114+ container: self.container,
115+ current_root: self.current_root,
116+ };
117+ vdom.render();
118+ vdom
119+ }
120+
84 fn swap_buffers(&mut self) {
121 fn swap_buffers(&mut self) {
85 let (first, second) = self.dom_buffers.as_mut().split_at_mut(1);
122 let (first, second) = self.dom_buffers.as_mut().split_at_mut(1);
86 mem::swap(&mut first[0], &mut second[0]);
123 mem::swap(&mut first[0], &mut second[0]);
tests/web/cached.rs+7−7
@@ -32,20 +32,20 @@ impl Render for CountRenders {
32#[wasm_bindgen_test]
32#[wasm_bindgen_test]
33fn uses_cached_render() {
33fn uses_cached_render() {
34 let container = create_element("div");
34 let container = create_element("div");
35− let mut cached = Cached::new(CountRenders::new());
35+ let cached = Cached::new(CountRenders::new());
36− let mut vdom = Vdom::new(&container, &cached);
36+ let mut vdom = Vdom::new(&container, cached);
37
37
38 for _ in 0..10 {
38 for _ in 0..10 {
39− vdom.render(&cached);
39+ vdom.render();
40− assert_eq!(cached.render_count.get(), 1);
40+ assert_eq!(vdom.component().render_count.get(), 1);
41 assert_rendered(&container, &RenderFn(|_| Node::text("1")))
41 assert_rendered(&container, &RenderFn(|_| Node::text("1")))
42 }
42 }
43
43
44− Cached::invalidate(&mut cached);
44+ Cached::invalidate(vdom.component_mut());
45
45
46 for _ in 0..10 {
46 for _ in 0..10 {
47− vdom.render(&cached);
47+ vdom.render();
48− assert_eq!(cached.render_count.get(), 2);
48+ assert_eq!(vdom.component().render_count.get(), 2);
49 assert_rendered(&container, &RenderFn(|_| Node::text("2")))
49 assert_rendered(&container, &RenderFn(|_| Node::text("2")))
50 }
50 }
51}
51}
tests/web/main.rs+2−2
@@ -150,12 +150,12 @@ where
150 let container = create_element("div");
150 let container = create_element("div");
151
151
152 debug!("====== Rendering the *before* DOM into the physical DOM ======");
152 debug!("====== Rendering the *before* DOM into the physical DOM ======");
153− let mut vdom = Vdom::new(&container, &before);
153+ let vdom = Vdom::new(&container, &before);
154 debug!("====== Checking the *before* DOM against the physical DOM ======");
154 debug!("====== Checking the *before* DOM against the physical DOM ======");
155 assert_rendered(&container, &before);
155 assert_rendered(&container, &before);
156
156
157 debug!("====== Rendering the *after* DOM into the physical DOM ======");
157 debug!("====== Rendering the *after* DOM into the physical DOM ======");
158− vdom.render(&after);
158+ vdom.render_component(&after);
159 debug!("====== Checking the *after* DOM against the physical DOM ======");
159 debug!("====== Checking the *after* DOM against the physical DOM ======");
160 assert_rendered(&container, &after);
160 assert_rendered(&container, &after);
161}
161}