File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed
branches/try/src/doc/tarpl Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 1
1
---
2
2
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
3
3
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4
- refs/heads/try: c97673c7b0fffe131822f2a5be520cf408c68319
4
+ refs/heads/try: 13b2605ed985a37481dc497357dc6dcdf37ba6ff
5
5
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
6
6
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
7
7
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Original file line number Diff line number Diff line change @@ -68,6 +68,29 @@ fn main() {
68
68
}
69
69
```
70
70
71
+ Of course, while the analysis doesn't consider actual values, it does
72
+ have a relatively sophisticated understanding of dependencies and control
73
+ flow. For instance, this works:
74
+
75
+ ``` rust
76
+ let x : i32 ;
77
+
78
+ loop {
79
+ // Rust doesn't understand that this branch will be taken unconditionally,
80
+ // because it relies on actual values.
81
+ if true {
82
+ // But it does understand that it will only be taken once because
83
+ // we *do* unconditionally break out of it. Therefore `x` doesn't
84
+ // need to be marked as mutable.
85
+ x = 0 ;
86
+ break ;
87
+ }
88
+ }
89
+ // It also knows that it's impossible to get here without reaching the break.
90
+ // And therefore that `x` must be initialized here!
91
+ println! (" {}" , x );
92
+ ```
93
+
71
94
If a value is moved out of a variable, that variable becomes logically
72
95
uninitialized if the type of the value isn't Copy. That is:
73
96
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ discriminant.
47
47
On non-C-like enums, this will inhibit certain optimizations like the null-
48
48
pointer optimization.
49
49
50
- These reprs have no affect on a struct.
50
+ These reprs have no effect on a struct.
51
51
52
52
53
53
You can’t perform that action at this time.
0 commit comments