Skip to content

Commit 4269412

Browse files
committed
note error codez
1 parent d15a0b5 commit 4269412

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/sixth-send-sync.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,18 @@ test src\lib.rs - assert_properties::iter_mut_invariant (line 458) - compile fai
153153
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.12s
154154
```
155155

156-
Yay! I recommend always making the test without compile_fail so that you can confirm that it fails to compile *for the right reason*. For instance, this test will also fail if you fail to include the `use` at the start, which, is not what we want!
156+
Yay! I recommend always making the test without compile_fail so that you can confirm that it fails to compile *for the right reason*. For instance, this test will also fail if you fail to include the `use` at the start, which, is not what we want! Oh wait, we can actually just specify the error code we want next to the compile_fail:
157+
158+
```rust ,ignore
159+
/// ```compile_fail,E0308
160+
/// use linked_list::IterMut;
161+
///
162+
/// fn iter_mut_covariant<'i, 'a, T>(x: IterMut<'i, &'static T>) -> IterMut<'i, &'a T> { x }
163+
/// ```
164+
fn iter_mut_invariant() {}
165+
```
166+
167+
Hopefully the compiler won't change that... it's *probably* fine. 🙃
157168

158169
...also, did you notice the part where we actually made IterMut invariant? It was easy to miss, since I "just" copy-pasted Iter and dumped it at the end. It's the last line here:
159170

@@ -215,4 +226,5 @@ failures:
215226
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.15s
216227
```
217228

218-
Eyyy!!! The system works! I love having tests that actually do their job, so that I don't have to be quite so horrified of looming mistakes!
229+
Eyyy!!! The system works! I love having tests that actually do their job, so that I don't have to be quite so horrified of looming mistakes!
230+

0 commit comments

Comments
 (0)