Devin Jeanpierre
3abf036ebf
Document lifetime elision for fn types, Fn*, impl
...
Currently, the lifetime elision doc only documents function definitions, but lifetime elision is also allowed in the following other locations:
* `fn` types, such as `fn(&T)`
* `Fn`/`FnMut`/`FnOnce`, such as `Fn(&T)`
* `impl` headers
To demo this up, I made some type aliases for `fn`/`Fn` which you can pass `&T` as a parameter to (to follow the lifetime rules of the surrounding context), and compared what you get with that instead of using `fn`/`Fn` directly, where lifetime elision takes on the rules from `fn`/`Fn`/etc.
I also demoed up an `impl` header that used lifetime elision twice, although the error message in that case is broken (filed https://github.com/rust-lang/rust/issues/87763 )
The demo was half for this change description, and half just to make sure I understand Rust -- in particular, I really had to reverse engineer it for `impl` because I wasn't sure, and it didn't seem to be documented anywhere (at least not here!)
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f82b280de4b992f225bc32121f333e96
3 years ago
Yuki Okushi
3e8f80c6cc
Note that this book is edition 2018
3 years ago
Yuki Okushi
c42314b09b
Remove unnecessary `extern crate`s
3 years ago
Yuki Okushi
e43b81128f
Clarify the Safe vs. Unsafe Rust relationship
3 years ago
Thirds
f51734eb55
Add cloning example for dot operator behaviour ( #292 )
...
Co-authored-by: Yuki Okushi <yuki.okushi@huawei.com>
3 years ago
Yuki Okushi
7a13537f96
Apply review comments
3 years ago
Yuki Okushi
b0ec7251db
Fix some style issues
3 years ago
Yuki Okushi
c162bb71e9
Move the list of coercions to the reference
3 years ago
Yuki Okushi
ff25fa253d
Add an example that shows the null-pointer opt does not happen
3 years ago
Eric Huss
ca4aa393d7
Merge pull request #287 from JohnTitor/casting
...
Remove casting list from the nomicon
3 years ago
Yuki Okushi
5e789618d9
Audit `ignore` annotations
3 years ago
Yuki Okushi
b12f36805c
Re-organize casting section
3 years ago
Yuki Okushi
f2e228e8eb
Remove casting list from the nomicon
3 years ago
Evan Lu
5de61f9784
rename typo "lifetime" to "reference" ( #286 )
...
Co-authored-by: evan l00 <evan_l00@qq.com>
3 years ago
Yuki Okushi
3bdccf4402
Add an incomplete warning to the top page ( #274 )
3 years ago
Jason Heeris
b9ca313e68
The #[repr(C)] attribute on the callback example is not necessary, since the type is not used in C.
3 years ago
Yuki Okushi
edd83c5d7e
Fix linkcheck failures
3 years ago
Yuki Okushi
1ff9110134
Refine the introduction chapter
3 years ago
Yuki Okushi
edf0d9001d
Move Arc-Mutex chapters into the subdir
3 years ago
Yuki Okushi
04616a672b
Move Vec chapters into the subdir
3 years ago
Eric Huss
2e159b0d30
Merge pull request #273 from JohnTitor/mention-extern-types
...
Mention "extern types" on the opaque structs section
3 years ago
Eric Huss
b44af9d964
Merge pull request #272 from JohnTitor/clarify-aliasing
...
Clarify the conditions on the aliasing section
3 years ago
Yuki Okushi
538345ab83
Turn explanation into a sidenote
3 years ago
Yuki Okushi
c996703c28
Clarify the conditions on the aliasing section
3 years ago
Yuki Okushi
35f420981b
Upgrade to edition 2018
3 years ago
Eric Huss
f30bc440db
Merge pull request #271 from JohnTitor/clean-up
...
Update some wording making reference to issues/RFCs
3 years ago
Eric Huss
484c6104db
Merge pull request #278 from JohnTitor/compile-fail-subtyping
...
Some improvements on the "subtyping" chapter
3 years ago
Eric Huss
19f63118e3
Merge pull request #277 from JohnTitor/note-fixed-int-2s-complement
...
Clarify casting between the same size fixed ints
3 years ago
Yuki Okushi
ae5ad9b7ad
Add a link for the variance table on the reference
3 years ago
Yuki Okushi
bcfb3b58a1
Mark on example `compile_fail`
3 years ago
Yuki Okushi
2df3009309
Clarify casting between the same size fixed ints
3 years ago
Yuki Okushi
0d8cefe8dd
Add a link to show why unused lifetimes on structs are forbidden
3 years ago
Vlad Ion
b825a46d15
Fix small typo in the Drop Check chapter
3 years ago
Yuki Okushi
9387d35984
Mention "extern types" on the opaque structs section
3 years ago
Yuki Okushi
4b6eb0ff96
Update some wording making reference to issues/RFCs
3 years ago
Yuki Okushi
1fe5457479
Fix minor style issues
3 years ago
mukund
55de6fa3c1
Clarify some of the language around marking traits safe/unsafe. ( #268 )
4 years ago
Brent Kerby
a462a3ae5c
Use pointer 'add' instead of 'offset' ( #265 )
4 years ago
Brent Kerby
951371fb74
Adjust Vec to build on stable Rust ( #223 )
...
Co-authored-by: Yuki Okushi <jtitor@2k36.org>
4 years ago
Mark Lodato
132a746984
Update link to c++ atomic ordering docs ( #264 )
...
I'm not sure if this is actually desirable. For one thing, the link I used isn't
locked to c++20 exactly. But it is the same page the [std lib](https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html ) links to
so that may be good for something.
I'm also not sure if other references to `C++11` should be updated or removed.
Basically, I feel like _something_ should change here but I'm not really sure what :-\
4 years ago
Daniel Franklin
8551afbb2c
Add example of thinking about Send/Sync's soundness ( #259 )
...
Co-authored-by: Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com>
Co-authored-by: Yuki Okushi <jtitor@2k36.org>
4 years ago
Yuki Okushi
6fe476943a
Merge pull request #257 from skade/opaque-types-fix
4 years ago
Florian Gilcher
90811705ca
Fix opaque type representation.
...
Co-authored-by: Nikolai Vazquez <github@nikolaivazquez.com>
4 years ago
Yuki Okushi
adca786547
Merge pull request #254 from mdaverde/ml/adds-compiler-err-lifetimes
4 years ago
cherryblossom000
7278a42dd5
Fix alloc link in exotic-sizes for local docs
...
This changes `https://doc.rust-lang.org/std/alloc/trait.GlobalAlloc.html#tymethod.alloc ` to `../std/alloc/trait.GlobalAlloc.html#tymethod.alloc` so that it uses the local docs installation if the page is viewed with the local docs.
4 years ago
Milan
856595872a
Adds compile error for example in improperly reduced borrows
4 years ago
Milan
cba5941207
Changes wording under improperly reduced borrows
4 years ago
ThePuzzlemaker
1713e9fe80
Remove TODO
4 years ago
James [Undefined]
6b6c0a6bf1
Fix small punctuation error
...
Co-authored-by: Alexis Beingessner <a.beingessner@gmail.com>
4 years ago
ThePuzzlemaker
c2919c685f
Arc revisions (Clone atomic explanation) (pt2/3(+?))
4 years ago
ThePuzzlemaker
e16ed7f336
Fix Arc Clone
4 years ago
ThePuzzlemaker
57fd6cf32b
Arc revisions (pt1/2(+?))
4 years ago
ThePuzzlemaker
9da6fbf6cd
Simple Arc implementation (without Weak refs)
...
This is a squash of the following commits:
- Fix code, remove WIP message as that was while writing this, and link to stable @ fixed 1.49 rather than latest nightly
- Improve wording on deref and ignore some code blocks
- Improve wording and formatting a bit cause I'm insane
- Fix links
- Fix links again because we all love relative links
- Remove unnecessary Drop import
- Use Box::from_raw instead of ptr::drop_in_place as that actually dealloc's the Box (i'm dumb and misinterpreted the std code :/); fix some desync between code in between sections
- Fix tests
4 years ago
Lukas Hettwer
a8584998ea
Update vector code examples
...
The code samples were different from the final code and included
deprecated API calls.
4 years ago
Yuki Okushi
a3180eb461
Remove outdated information about `jemalloc`
4 years ago
Yuki Okushi
a5a48441d4
Merge pull request #249 from jflatow/patch-1
...
Update atomics.md
4 years ago
Jared Flatow
bdb189862a
Update atomics.md
4 years ago
Yuki Okushi
3fd89d64e7
Rename `AllocRef` to `Allocator` and `(de)alloc` to `(de)allocate`
4 years ago
unknown
d8383b65f7
Clarify that any alignment is valid for ZSTs
4 years ago
Yuki Okushi
23c49f1d5c
Merge pull request #238 from mexus/master
4 years ago
Yuki Okushi
cb88439ac9
Update src/coercions.md
4 years ago
Eric Huss
ea054bb935
Merge pull request #244 from JohnTitor/some-tweaks
...
Some tweaks
4 years ago
Camelid
038a7e6238
Uppercase `repr(Rust)`
...
There were two spots where it referred to `repr(rust)` when it is
usually referred to as `repr(Rust)` in accordance with `repr(C)`.
I updated those to use the uppercase form.
4 years ago
Yuki Okushi
e948943445
Remove unnecessary chapter
4 years ago
Yuki Okushi
ee0d4be726
Replace hard tabs with whitespaces
4 years ago
Yuki Okushi
0cfd181886
Merge pull request #224 from updogliu/patch-1
...
Update atomics.md
4 years ago
Yuki Okushi
8d3237ffd4
Merge pull request #187 from ChrisGreenaway/patch-2
...
Update send-and-sync.md
4 years ago
Yuki Okushi
45b640d76a
Merge pull request #231 from lwintermelon/patch-1
...
fix a typo
4 years ago
Camelid
ebe16b1455
Improve formatting of "Transmutes" chapter
...
* Use inline code style for `&` and `&mut`
* Add blank lines between list items to make source easier to read
* Use new-style mdBook link
4 years ago
Simon Lammes
52b55e0db0
fix minor grammar mistake
4 years ago
Yuki Okushi
f8b9921a77
Fix link for `[T]`
4 years ago
Yuki Okushi
c2ffc216d5
Merge pull request #232 from turtleslow/saturating-cast-patch-1
...
Update casts.md
4 years ago
Yuki Okushi
8641e70955
Merge pull request #180 from jyn514/master
...
[WIP] Add more links
4 years ago
Yuki Okushi
737029d362
Merge pull request #219 from isakcodes/patch-1
...
Data Race definition should be more precise
4 years ago
Yuki Okushi
d7cb40b29f
Merge pull request #157 from chansuke/update-error-diagnostic
...
Update the diagnostic of `error[E0597]` in dropck.md
4 years ago
Yuki Okushi
9c912bf812
Merge pull request #225 from mxxo/typo
...
fix typo in Lifetimes mutable reference aliasing section
4 years ago
mexus
393e54b749
coercions.md: non-capturing closures to function pointers
4 years ago
Eric Huss
ee45186b37
Fix API change to alloc::Global::grow.
4 years ago
Yuki Okushi
81797cf059
Follow-up of rust-lang/rust#75152
4 years ago
Yuki Okushi
be0687ab1d
Follow-up for rust-lang/rust#74850
4 years ago
turtleslow
5b26dfbf4d
Update casts.md
...
Float to integer cast unsoundness was fixed in Rust 1.45.0.
4 years ago
Max Orok
d052363c6a
fix typo in Lifetimes mutable reference aliasing section
4 years ago
Hu Shuai
b5d7df3c9a
fix a typo
4 years ago
Zihan Liu
4de216c82c
Update atomics.md
...
add "including non-atomic and relaxed atomic writes" for clarity
4 years ago
Konrad Borowski
bfe1ab96d7
Clarify that str data must still be initialized
5 years ago
Konrad Borowski
b8344ef88f
Remove language-level UB for non-UTF-8 str
5 years ago
Isak
45a997aabd
Data Race definition should be more precise
...
"one of them is a write" did not seem right to me. Doesn't generalise to the case with two concurrent threads writing to shared memory. [Related Wikipedia article](https://en.wikipedia.org/wiki/Race_condition#Example_definitions_of_data_races_in_particular_concurrency_models )
5 years ago
Ralf Jung
c94172314b
fix Nomicon transmute UB
5 years ago
Eric Huss
d1517d4e3f
Rename Unique::empty to Unique::dangling
5 years ago
dbdr
91dd12be34
Use simpler link syntax
...
Thanks @lzutao
Co-authored-by: lzutao <taolzu@gmail.com>
5 years ago
Daniel Bonniot de Ruisselet
76d0799a8d
Replace catch_panic by catch_unwind
5 years ago
amosonn
4d2d275997
Fix example in FFI, section NPO
5 years ago
Youngsuk Kim
1e1dd962c7
Update implementation code of `split_at_mut`
5 years ago
Linus Färnstrand
9f131b5b9c
Use just `std::_` instead of `::std::_`
...
Accessing std this way has been stable since Rust 1.30.0
5 years ago
WarmongeringBeaver
8413980b07
Remove illegal space.
...
Sorry, I'm the useless-details sheriff.
5 years ago
Linus Färnstrand
1d517f87dc
Fix Global.realloc by changing to Global.grow
5 years ago
Linus Färnstrand
6cceae61c9
Fix usage of Global.alloc
5 years ago
Linus Färnstrand
a2d606f49c
Use isize::MAX directly on type instead of module
5 years ago
Eric Huss
218da782b8
Fix negative_impls feature.
5 years ago
Yuki Okushi
d2ed4ebed9
Rustup to latest rustc
5 years ago