Commit graph

656 commits

Author SHA1 Message Date
Ralf Jung
7c8b9413b8
Rollup merge of #73104 - poliorcetics:explicit-mutex-drop-example, r=dtolnay
Example about explicit mutex dropping

Fixes #67457.

Following the remarks made in #73074, I added an example on the main `Mutex` type, with a situation where there is mutable data and a computation result.

In my testing it is effectively needed to explicitly drop the lock, else it deadlocks.

r? @dtolnay because you were the one to review the previous PR.
2020-06-15 12:01:07 +02:00
David Tolnay
c010e711ca
Rewrap comments in Mutex example 2020-06-13 10:11:02 -07:00
Poliorcetics
34b3ff06e1
Clarify the scope-related explanation
Based on the review made by dtolnay.
2020-06-13 18:43:37 +02:00
Poliorcetics
f747073fc1
Apply suggestions from code review
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2020-06-13 18:41:01 +02:00
Lzu Tao
fff822fead Migrate to numeric associated consts 2020-06-10 01:35:47 +00:00
Alexis Bourget
1312d30a6a Remove a lot of unecessary/duplicated comments 2020-06-09 22:40:30 +02:00
Poliorcetics
fdef1a5915
Simply use drop instead of std::mem::drop
Co-authored-by: LeSeulArtichaut <leseulartichaut@gmail.com>
2020-06-08 16:29:47 +02:00
Alexis Bourget
9c8f881ccd Improved the example to work with mutable data, providing a reason for the mutex holding it 2020-06-07 23:42:55 +02:00
Alexis Bourget
95c4899e55 Added an example where explicitly dropping a lock is necessary/a good idea. 2020-06-07 23:36:07 +02:00
Mark Rousskov
7139342249 Bump to 1.46 2020-06-03 15:27:51 -04:00
Eitan Mosenkis
806f5815d4
Fix typo in doc comment.
call_one_force -> call_once_force
2020-05-24 11:59:07 +03:00
Ralf Jung
5980d972d1 make abort intrinsic safe, and correct its documentation 2020-05-17 11:23:42 +02:00
Dylan DPC
6f5de87d3f
Rollup merge of #71398 - ThinkChaos:feat_refcell_take, r=LukasKalbertodt
Add `RefCell::take`

Add `RefCell::take` to match `Cell` and `Option`.
I also changed a couple of calls to `.replace` to `.take`.

Tracking issue is #71395.

This is my first contribution, please tell me if there's anything I could improve, thanks!
2020-05-03 18:34:34 +02:00
ThinkChaos
4ea83bfb3d Use Cell::take in a couple places 2020-04-26 11:50:53 +02:00
Matthias Krüger
8862f829bb fix more clippy warnings
clippy::{redundant_pattern_matching, clone_on_copy, iter_cloned_collect, option_as_ref_deref, match_ref_pats}
2020-04-26 02:24:01 +02:00
Josh Stone
2325c20925 Avoid unused Option::map results
These are changes that would be needed if we add `#[must_use]` to
`Option::map`, per #71484.
2020-04-24 13:58:41 -07:00
Philipp Hansch
23b9f46fff
More diagnostic items for Clippy usage
This adds a couple of more diagnostic items to be used in Clippy.
I chose these particular ones because they were the types which we seem
to check for the most in Clippy. I'm not sure if the
`cfg_attr(not(test))` is needed, but it was also used for `Vec` and a
few other types.
2020-04-22 07:57:56 +02:00
Josh Stone
2edd123a23 Dogfood or_patterns in the standard library 2020-04-16 12:44:57 -07:00
Linus Färnstrand
101085ad9f Stop importing integer modules in libstd 2020-04-05 11:22:01 +02:00
Lukas Kalbertodt
401a3f3762
Fix "since" field for Once::is_complete's #[stable] attribute
It was accidentally merged with the wrong version.
2020-03-15 10:19:26 +01:00
Mazdak Farrokhzad
10f999b72d
Rollup merge of #69773 - matthiaskrgr:typos, r=petrochenkov
fix various typos
2020-03-07 17:27:32 +01:00
Matthias Krüger
83980aca20 Don't redundantly repeat field names (clippy::redundant_field_names) 2020-03-06 19:42:18 +01:00
Matthias Krüger
136ad015b6 fix various typos 2020-03-06 15:19:31 +01:00
Michael Bradshaw
348278a7fd Stabilize Once::is_completed 2020-02-07 21:53:22 -08:00
bors
cb6122db3f Auto merge of #67076 - mbrubeck:condvar, r=dtolnay
Stabilize Condvar::wait_while and wait_timeout_while (previously wait_until, wait_timeout_until)

Closes #47960.
2020-01-14 10:34:43 +00:00
Igor Aleksanov
f720469fd0 Use matches macro in libcore and libstd 2020-01-08 07:10:28 +03:00
Oliver Scherer
48efc1e6c2
Rollup merge of #67632 - kraai:remove-collapsed-reference-links, r=steveklabnik
Convert collapsed to shortcut reference links
2019-12-28 00:36:11 +01:00
Matt Brubeck
98d054af08 Rename wait_until/wait_timeout_until to wait_while/white_timeout_while 2019-12-26 14:15:05 -08:00
Matt Brubeck
207e60a364 Stabilize Condvar::wait_until and wait_timeout_until 2019-12-26 14:15:05 -08:00
Matthew Kraai
2f43313834 Convert collapsed to shortcut reference links 2019-12-26 05:27:55 -08:00
Matthew Kraai
21e636f188 Remove redundant link texts 2019-12-26 05:04:46 -08:00
David Tolnay
4646a88b7a
Deprecate Error::description for real
`description` has been documented as soft-deprecated since 1.27.0 (17
months ago). There is no longer any reason to call it or implement it.

This commit:

- adds #[rustc_deprecated(since = "1.41.0")] to Error::description;

- moves description (and cause, which is also deprecated) below the
  source and backtrace methods in the Error trait;

- reduces documentation of description and cause to take up much less
  vertical real estate in rustdocs, while preserving the example that
  shows how to render errors without needing to call description;

- removes the description function of all *currently unstable* Error
  impls in the standard library;

- marks #[allow(deprecated)] the description function of all *stable*
  Error impls in the standard library;

- replaces miscellaneous uses of description in example code and the
  compiler.
2019-12-24 22:39:49 -08:00
Mark Rousskov
a06baa56b9 Format the world 2019-12-22 17:42:47 -05:00
Mark Rousskov
82184440ec Propagate cfg bootstrap 2019-12-18 12:16:19 -05:00
Oliver Scherer
5e17e39881 Require stable/unstable annotations for the constness of all stable functions with a const modifier 2019-12-13 11:27:02 +01:00
Ralf Jung
49697ae38b get rid of __ in field names 2019-12-06 17:28:04 +01:00
David Tolnay
4436c9d354
Format libstd with rustfmt
This commit applies rustfmt with rust-lang/rust's default settings to
files in src/libstd *that are not involved in any currently open PR* to
minimize merge conflicts. THe list of files involved in open PRs was
determined by querying GitHub's GraphQL API with this script:
https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8

With the list of files from the script in outstanding_files, the
relevant commands were:

    $ find src/libstd -name '*.rs' \
        | xargs rustfmt --edition=2018 --unstable-features --skip-children
    $ rg libstd outstanding_files | xargs git checkout --

Repeating this process several months apart should get us coverage of
most of the rest of libstd.

To confirm no funny business:

    $ git checkout $THIS_COMMIT^
    $ git show --pretty= --name-only $THIS_COMMIT \
        | xargs rustfmt --edition=2018 --unstable-features --skip-children
    $ git diff $THIS_COMMIT  # there should be no difference
2019-11-29 18:43:27 -08:00
Paul Dicker
b05e200867 Run rustfmt on libstd/sync/once.rs 2019-11-09 12:46:17 +01:00
Paul Dicker
4c66658f2c Don't mutate node.next 2019-11-05 07:15:35 +01:00
Paul Dicker
3712bb68c4 Mention park guarantee 2019-10-25 10:01:27 +02:00
Paul Dicker
c2bbfeadcc Always align Waiter to 4 bytes 2019-10-24 17:57:07 +02:00
Paul Dicker
c11a44ab6c Use more precise atomic orderings 2019-10-24 17:57:07 +02:00
Paul Dicker
88c70edef6 In Waiter use interior mutability for thread 2019-10-24 17:57:05 +02:00
Paul Dicker
4b8da9ccd5 Reduce the amount of comments in call_inner 2019-10-24 17:28:08 +02:00
Paul Dicker
2e8eb5f33d Move thread parking to a seperate function 2019-10-24 17:28:08 +02:00
Paul Dicker
fbc242f1ef Turn Finish into WaiterQueue 2019-10-24 17:28:04 +02:00
Paul Dicker
1479c22a39 Don't mutate waiter nodes 2019-10-23 16:38:50 +02:00
Paul Dicker
7f1e166899 Simplify loop conditions in RUNNING and add comments 2019-10-23 12:09:54 +02:00
Paul Dicker
2ab812c181 Rename state to state_and_queue 2019-10-23 12:09:53 +02:00
boyned//Kampfkarren
247df6e134
Don't recommend ONCE_INIT in std::sync::Once
ONCE_INIT is deprecated, and so suggesting it as not only being on par with, but before `Once::new` is a bad idea.
2019-10-16 00:06:01 -07:00