You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For bootstrapping purposes, this commit does not remove all uses of
the keyword "pure" -- doing so would cause the compiler to no longer
bootstrap due to some syntax extensions ("deriving" in particular).
Instead, it makes the compiler ignore "pure". Post-snapshot, we can
remove "pure" from the language.
There are quite a few (~100) borrow check errors that were essentially
all the result of mutable fields or partial borrows of `@mut`. Per
discussions with Niko I think we want to allow partial borrows of
`@mut` but detect obvious footguns. We should also improve the error
message when `@mut` is erroneously reborrowed.
Copy file name to clipboardexpand all lines: doc/rust.md
+4-41
Original file line number
Diff line number
Diff line change
@@ -214,7 +214,7 @@ false fn for
214
214
if impl
215
215
let loop
216
216
match mod mut
217
-
priv pub pure
217
+
priv pub
218
218
ref return
219
219
self static struct super
220
220
true trait type
@@ -936,7 +936,6 @@ Specifically, the following operations are considered unsafe:
936
936
937
937
- Dereferencing a [raw pointer](#pointer-types).
938
938
- Casting a [raw pointer](#pointer-types) to a safe pointer type.
939
-
- Breaking the [purity-checking rules](#pure-functions) in a `pure` function.
940
939
- Calling an unsafe function.
941
940
942
941
##### Unsafe blocks
@@ -946,42 +945,6 @@ This facility exists because the static semantics of Rust are a necessary approx
946
945
When a programmer has sufficient conviction that a sequence of unsafe operations is actually safe, they can encapsulate that sequence (taken as a whole) within an `unsafe` block. The compiler will consider uses of such code "safe", to the surrounding context.
947
946
948
947
949
-
#### Pure functions
950
-
951
-
A pure function declaration is identical to a function declaration, except that
952
-
it is declared with the additional keyword `pure`. In addition, the typechecker
953
-
checks the body of a pure function with a restricted set of typechecking rules.
954
-
A pure function may only modify data owned by its own stack frame.
955
-
So, a pure function may modify a local variable allocated on the stack, but not a mutable reference that it takes as an argument.
956
-
A pure function may only call other pure functions, not general functions.
957
-
958
-
An example of a pure function:
959
-
960
-
~~~~
961
-
pure fn lt_42(x: int) -> bool {
962
-
return (x < 42);
963
-
}
964
-
~~~~
965
-
966
-
Pure functions may call other pure functions:
967
-
968
-
~~~~{.xfail-test}
969
-
pure fn pure_length<T>(ls: List<T>) -> uint { ... }
0 commit comments