Skip to content

Commit 81134a4

Browse files
authored
Merge pull request #30 from pablocouto/output-update
Update compiler output in §3.9
2 parents eee5ffb + 85de648 commit 81134a4

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

src/dropck.md

+12-18
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,18 @@ fn main() {
8080
```
8181

8282
```text
83-
<anon>:12:28: 12:32 error: `days` does not live long enough
84-
<anon>:12 inspector = Inspector(&days);
85-
^~~~
86-
<anon>:9:11: 15:2 note: reference must be valid for the block at 9:10...
87-
<anon>:9 fn main() {
88-
<anon>:10 let (inspector, days);
89-
<anon>:11 days = Box::new(1);
90-
<anon>:12 inspector = Inspector(&days);
91-
<anon>:13 // Let's say `days` happens to get dropped first.
92-
<anon>:14 // Then when Inspector is dropped, it will try to read free'd memory!
93-
...
94-
<anon>:10:27: 15:2 note: ...but borrowed value is only valid for the block suffix following statement 0 at 10:26
95-
<anon>:10 let (inspector, days);
96-
<anon>:11 days = Box::new(1);
97-
<anon>:12 inspector = Inspector(&days);
98-
<anon>:13 // Let's say `days` happens to get dropped first.
99-
<anon>:14 // Then when Inspector is dropped, it will try to read free'd memory!
100-
<anon>:15 }
83+
error: `days` does not live long enough
84+
--> <anon>:15:1
85+
|
86+
12 | inspector = Inspector(&days);
87+
| ---- borrow occurs here
88+
...
89+
15 | }
90+
| ^ `days` dropped here while still borrowed
91+
|
92+
= note: values in a scope are dropped in the opposite order they are created
93+
94+
error: aborting due to previous error
10195
```
10296

10397
Implementing Drop lets the Inspector execute some arbitrary code during its

0 commit comments

Comments
 (0)