Commit graph

306 commits

Author SHA1 Message Date
Oleg Nosov
6a5931921c
Fixed libcore/cell.rs example 2019-11-06 01:03:31 +03:00
Oleg Nosov
45f281d461
Reverted PhantomData in LinkedList, fixed PhantomData markers in Rc and Arc 2019-11-05 23:36:54 +03:00
Shotaro Yamada
375469149c Reorder methods of Cell
To make `new` method appear first in documentation.
2019-10-03 15:24:00 +09:00
bors
0e9b465d72 Auto merge of #62748 - luca-barbieri:optimize-refcell-borrow, r=RalfJung
Optimize RefCell read borrowing

Instead of doing two comparisons we can do only one with a bit of cleverness.

LLVM currently can't do this optimization itself on x86-64.
2019-07-27 09:32:44 +00:00
Luca Barbieri
44c165074b fix comment 2019-07-21 12:50:16 +02:00
Luca Barbieri
c7928f5af0 Expand comment on BorrowRef::new 2019-07-21 11:49:36 +02:00
Luca Barbieri
f0b3c02d81 Optimize RefCell read borrowing
Instead of doing two comparisons we can do only one with a bit of
cleverness.

LLVM currently can't do this optimization itself on x86-64.
2019-07-17 13:25:34 +02:00
Ralf Jung
d30b36efc5 state also in the intro that UnsafeCell has no effect on &mut 2019-07-16 14:47:51 +02:00
Dodo
4e1d467700 add spaces in front of trait requirements 2019-07-13 17:15:16 +02:00
Simon Sapin
2ce9440368 Stabilize Cell::from_mut and as_slice_of_cells
FCP: https://github.com/rust-lang/rust/issues/43038#issuecomment-499900463
2019-06-07 16:25:41 +02:00
Alexander Regueiro
35585c499f Aggregation of drive-by cosmetic changes. 2019-06-05 21:09:26 +01:00
Mazdak Farrokhzad
74b359373c
Rollup merge of #60850 - SimonSapin:unguarded, r=alexcrichton
Stabilize RefCell::try_borrow_unguarded

Servo has been using this since https://github.com/servo/servo/pull/23196 to add a runtime check to some unsafe code, as discussed in PR https://github.com/rust-lang/rust/pull/59211. Stabilizing would help do more of the same in libraries that also have users on Stable.
2019-05-30 10:52:51 +02:00
Brent Kerby
d3c73ddec9 typo 2019-05-23 19:36:06 -06:00
Brent Kerby
e641fb47c4 Simplify RefCell minimum_spanning_tree example 2019-05-21 21:52:21 -06:00
Simon Sapin
9fd4d48b5e Stabilize RefCell::try_borrow_unguarded
Servo has been using this since https://github.com/servo/servo/pull/23196 to add a runtime check to some unsafe code, as discussed in PR https://github.com/rust-lang/rust/pull/59211. Stabilizing would help do more of the same in libraries that also have users on Stable.
2019-05-15 11:54:16 +02:00
Mazdak Farrokhzad
dbfbadeac4 libcore: deny more... 2019-04-19 01:37:12 +02:00
Taiki Endo
360432f1e8 libcore => 2018 2019-04-18 14:47:35 +09:00
bors
850912704e Auto merge of #59211 - nox:refcell-borrow-state, r=KodrAus
Introduce RefCell::try_borrow_unguarded

*Come sit next to the fireplace with me, this is going to be a long story.*

So, you may already be aware that Servo has weird design constraints that forces us developers working on it to do weird things. The thing that interests us today is that we do layout on a separate thread with its own thread pool to do some things in parallel, whereas the data it uses comes from the script thread, which implements the entire DOM and related pieces, with `!Sync` data types such as `RefCell<T>`.

The invariant we maintain is that script does not do anything ever with the DOM data as long as layout is doing its job. That's all nice and all, but one thing we don't ensure is that we don't actually know if script was currently mutably borrowing some `RefCell<T>` prior to starting layout, which may lead to aliasing mutable memory and obviously undefined behaviour.

This PR reinstates `RefCell::borrow_state` so that [this method](https://github.com/servo/servo/blob/master/components/script/dom/bindings/cell.rs#L23-L30) can make use of it and return `None` if the cell was mutably borrowed.

Cc @SimonSapin
2019-04-11 12:49:49 +00:00
Mazdak Farrokhzad
9d198db339
Rollup merge of #59581 - jmcomets:stabilize-refcell_replace_swap, r=Centril
Stabilize refcell_replace_swap feature

Please be kind, this is my first time contributing. 😄

I noticed #43570 only needs stabilizing (and I need it for a side project I'm working on), so I followed the [guide](https://rust-lang.github.io/rustc-guide/stabilization_guide.html#stabilization-pr) to move things forward.

I'm happy to amend things if needed, let me know!
2019-03-31 19:19:53 +02:00
Jean-Marie Comets
c789a539a2 refcell_replace_swap: remove feature gate & obsolete documentation item 2019-03-31 14:50:06 +02:00
Jean-Marie Comets
70fa616a23 Stabilize refcell_replace_swap feature, closes #43570 2019-03-31 10:54:14 +02:00
Fabian Drinck
8fb0549151 Fix doc tests 2019-03-30 22:37:02 +01:00
Anthony Ramine
38811a1d31 Introduce RefCell::try_borrow_unguarded
This replaces RefCell::borrow_state to something that encodes the use
case of Servo better.
2019-03-19 12:24:38 +01:00
Joshua Liebow-Feeser
de4be2cd85 Stabilize refcell_map_split feature
- Closes #51476
2019-03-18 15:06:34 -07:00
Anthony Ramine
a9388c28c2 Tweak documentation of RefCell::borrow_state 2019-03-16 12:16:25 +01:00
Anthony Ramine
fab71dd046 Revert "Deprecate std::cell::RefCell::borrow_state"
This reverts commit dc2d5058e9.
2019-03-15 15:01:48 +01:00
Anthony Ramine
1c365cedf8 Revert "Remove RefCell::borrow_state"
This reverts commit 313aab8fbe.
2019-03-15 15:01:48 +01:00
Alexander Regueiro
99ed06eb88 libs: doc comments 2019-02-10 23:57:25 +00:00
Alexander Regueiro
b87363e763 tests: doc comments 2019-02-10 23:42:32 +00:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Alexander Regueiro
ee89c088b0 Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
Ralf Jung
25d46f3091 add comment explaining why what we do is legal 2018-11-17 10:20:28 +01:00
Ralf Jung
41434e001b avoid shared ref in UnsafeCell::get 2018-11-16 22:17:26 +01:00
Mazdak Farrokhzad
e15c62d61f revert making internal APIs const fn. 2018-11-10 01:10:07 +01:00
Mazdak Farrokhzad
5b89877dda constify parts of libcore. 2018-11-10 01:07:32 +01:00
Geoffry Song
6df57a7d68 Slight copy-editing for std::cell::Cell docs
Hopefully this is a bit more precise and also more correct English.
2018-10-26 12:09:41 -07:00
Scott McMurray
0a3bd9b6ab Use impl_header_lifetime_elision in libcore 2018-09-29 21:33:35 -07:00
ljedrz
d46dca66c9 Remove redundant field names in structs 2018-08-04 14:58:20 +02:00
ljedrz
8646a17143 Enforce #![deny(bare_trait_objects)] in src/libcore 2018-07-25 10:21:41 +09:00
F001
489101cc45 use inherent method instead 2018-07-23 20:58:40 +08:00
F001
8812c6bae9 revert Deref 2018-07-18 12:30:20 +08:00
F001
3eee486e27 impl DerefMut for Cell<[T]> 2018-07-17 11:34:19 +08:00
F001
b1344abc58 code style fixes 2018-07-17 11:34:19 +08:00
F001
bdf86300b4 impl Deref instead of Index 2018-07-17 11:34:19 +08:00
F001
4d99957ce3 use lifetime elision for consistency 2018-07-17 11:34:19 +08:00
F001
4bf8b57950 remove "get_with" method 2018-07-17 11:34:19 +08:00
F001
9928baa786 implement rfc 1789 2018-07-17 11:34:19 +08:00
bors
0ad8f9e5b1 Auto merge of #51395 - SimonSapin:repr-transparent, r=SimonSapin
Add #[repr(transparent)] to some libcore types

* `UnsafeCell`
* `Cell`
* `NonZero*`
* `NonNull`
* `Unique`

CC https://github.com/rust-lang/rust/issues/43036
2018-07-04 16:21:42 +00:00
Joshua Liebow-Feeser
851cc39503 Optimize RefCell refcount tracking 2018-06-27 00:07:18 -07:00
Simon Sapin
530d7bc517 Add #[repr(transparent)] to some libcore types
* `UnsafeCell`
* `Cell`
* `NonZero*`
* `NonNull`
* `Unique`
2018-06-16 18:25:15 +02:00