This is built on top of https://github.com/rust-lang/rust/pull/15162 . cccae83d92 is the only new commit, you may want to look at that rather than the whole diff.
Writing our first Rust program together. This is the most crucial step, so I go to a fairly deep level of detail. Future sections will move more quickly.
This has my voice *very strongly*. I'm not sure if it's too much. I'd find it okay if I had to tone it back, and I don't want it to be _too strong_, but clinical docs are boring.
It turns out that bindings introduced by 'for' loops were not treated hygienically. The fix for this is to make the 'for' expansion more like a macro; rather than expanding sub-pieces and then assembling them, we need to rewrite the for and then call expand again on the whole thing.
This PR includes a test and the fix.
It also contains a number of other things:
- unit tests for other forms of hygiene (currently ignored)
- a fix for the isaac.rs macro that (it turned out) was relying on capturing
- other miscellaneous cleanup and comments
The JSON spec requires that these special values be serialized as null; the current serialization breaks any conformant JSON parser. So encoding needs to output "null", to_json on floating-point types can return Null as well as Number, and reading null when specifically expecting a number should be interpreted as NaN. There's no way to round-trip Infinity.
This change starts denying `*T` in the parser. All code using `*T` should ensure
that the FFI call does indeed take `const T*` on the other side before renaming
the type to `*const T`.
Otherwise, all code can rename `*T` to `*const T`.
[breaking-change]
This will break code like:
fn f(x: &mut int) {}
let mut a = box 1i;
f(a);
Change it to:
fn f(x: &mut int) {}
let mut a = box 1i;
f(&mut *a);
RFC 33; issue #10504.
[breaking-change]
r? @brson
vector-reference-to-unsafe-pointer-to-element cast if the type to be
casted to is not fully specified.
This is a conservative change to fix the user-visible symptoms of the
issue. A more flexible treatment would delay cast checks to after
function typechecking.
This can break code that did:
let x: *u8 = &([0, 0]) as *_;
Change this code to:
let x: *u8 = &([0, 0]) as *u8;
Closes#14893.
[breaking-change]
r? @alexcrichton
vector-reference-to-unsafe-pointer-to-element cast if the type to be
casted to is not fully specified.
This is a conservative change to fix the user-visible symptoms of the
issue. A more flexible treatment would delay cast checks to after
function typechecking.
This can break code that did:
let x: *u8 = &([0, 0]) as *_;
Change this code to:
let x: *u8 = &([0, 0]) as *u8;
Closes#14893.
[breaking-change]
Yes, it is important to be careful, but repeated emphasis about it is probably
not helpful — it starts to sound like you came for a tutorial but found a
finger-wagging lecture.
Even after I removed a few of these comments, there are still several left in
the text. That's probably fine! A couple of mentions of how this is dangerous
and you ought to be careful may be a good reminder to the reader.
After making the edits, I reflowed the paragraphs that I had touched, using
emacs's "M-x fill-paragraph", with fill-column equal to 70.
This will break code like:
fn f(x: &mut int) {}
let mut a = box 1i;
f(a);
Change it to:
fn f(x: &mut int) {}
let mut a = box 1i;
f(&mut *a);
RFC 33; issue #10504.
[breaking-change]
The f128 type has very little support in the compiler and the feature is
basically unusable today. Supporting half-baked features in the compiler can be
detrimental to the long-term development of the compiler, and hence this feature
is being removed.
Closes#14482 (std: Bring back half of Add on String)
Closes#15026 (librustc: Remove the fallback to `int` from typechecking.)
Closes#15119 (Add more description to c_str::unwrap().)
Closes#15120 (Add tests for #12470 and #14285)
Closes#15122 (Remove the cheat sheet.)
Closes#15126 (rustc: Always include the morestack library)
Closes#15127 (Improve ambiguous pronoun.)
Closes#15130 (Fix#15129)
Closes#15131 (Add the Guide, add warning to tutorial.)
Closes#15134 (Xfailed tests for hygiene, etc.)
Closes#15135 (core: Add stability attributes to Clone)
Closes#15136 (Some minor improvements to core::bool)
Closes#15137 (std: Add stability attributes to primitive numeric modules)
Closes#15141 (Fix grammar in tutorial)
Closes#15143 (Remove few FIXMEs)
Closes#15145 (Avoid unnecessary temporary on assignments)
Closes#15147 (Small improvements for metaprogramming)
Closes#15153 (librustc: Check function argument patterns for legality of by-move)
Closes#15154 (test: Add a test for regions, traits, and variance.)
Closes#15159 (rustc: Don't register syntax crates twice)
Closes#13816 (Stabilize version output for rustc and rustdoc)
This is because I observed someone reading the tutorial who thought they'd
missed something when they got to the mention of variable bindings.
This patch doesn't reflow the paragraphs so that you can see the semantic
change that I made, and a subsequent patch will reflow this paragraph.
Fixes https://github.com/rust-lang/rust/issues/13570.
Yes, it is important to be careful, but repeated emphasis about it is probably
not helpful — it starts to sound like you came for a tutorial but found a
finger-wagging lecture.
Even after I removed a few of these comments, there are still several left in
the text. That's probably fine! A couple of mentions of how this is dangerous
and you ought to be careful may be a good reminder to the reader.
After making the edits, I reflowed the paragraphs that I had touched, using
emacs's "M-x fill-paragraph", with fill-column equal to 70.
bindings.
This will break code that incorrectly did things like:
fn f(a @ box b: Box<String>) {}
Fix such code to not rely on undefined behavior.
Closes#12534.
[breaking-change]