Skip to content

Commit c385e94

Browse files
committed
---
yaml --- r: 229032 b: refs/heads/try c: 99043dd h: refs/heads/master v: v3
1 parent bf81b12 commit c385e94

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 5f6e0abe27aa6632f95492ad8864d8084c1bacef
4+
refs/heads/try: 99043dde9dd2d0507ad2e3cda65b9d3e9244f13f
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/doc/tarpl/exotic-sizes.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,9 @@ actually possible to communicate this at the type level by returning a
9595
knowing that it's *statically impossible* for this value to be an `Err`, as
9696
this would require providing a value of type Void.
9797

98-
In principle, Rust can do some interesting analysees and optimizations based
98+
In principle, Rust can do some interesting analyses and optimizations based
9999
on this fact. For instance, `Result<T, Void>` could be represented as just `T`,
100-
because the Err case doesn't actually exist. Also in principle the following
101-
could compile:
100+
because the Err case doesn't actually exist. The following *could* also compile:
102101

103102
```rust,ignore
104103
enum Void {}
@@ -111,3 +110,9 @@ let Ok(num) = res;
111110

112111
But neither of these tricks work today, so all Void types get you today is
113112
the ability to be confident that certain situations are statically impossible.
113+
114+
One final subtle detail about empty types is that raw pointers to them are
115+
actually valid to construct, but dereferencing them is Undefined Behaviour
116+
because that doesn't actually make sense. That is, you could model C's `void *`
117+
type with `*const Void`, but this doesn't necessarily gain anything over using
118+
e.g. `*const ()`, which *is* safe to randomly dereference.

0 commit comments

Comments
 (0)