Commit Graph

488 Commits

Author SHA1 Message Date
Malo Jaffré 679457ad2a Refactor to use debug_struct in several Debug impls
Fixes #44771.
2017-10-09 20:09:08 +02:00
Lucas Morales f283875a78 std::sync::RwLock docs improvement 2017-09-22 22:12:21 -04:00
Alex Burka 681e5da61e change #![feature(const_fn)] to specific gates 2017-09-16 15:53:02 +00:00
Corey Farwell a4387d54dc Rollup merge of #43891 - Fourchaux:master, r=steveklabnik
Fix typos & us spellings

Fixing some typos and non en-US spellings.

(Update of PR https://github.com/rust-lang/rust/pull/42812 )
2017-08-17 10:44:07 -04:00
Zack M. Davis 1b6c9605e4 use field init shorthand EVERYWHERE
Like #43008 (f668999), but _much more aggressive_.
2017-08-15 15:29:17 -07:00
Fourchaux c7104be1a3 Fix typos & us spellings 2017-08-15 21:56:30 +02:00
bors d21ec9b4ef Auto merge of #43582 - ivanbakel:unused_mut_ref, r=arielb1
Fixed mutable vars being marked used when they weren't

#### NB : bootstrapping is slow on my machine, even with `keep-stage` - fixes for occurances in the current codebase are <s>in the pipeline</s> done. This PR is being put up for review of the fix of the issue.

Fixes #43526, Fixes #30280, Fixes #25049

### Issue
Whenever the compiler detected a mutable deref being used mutably, it marked an associated value as being used mutably as well. In the case of derefencing local variables which were mutable references, this incorrectly marked the reference itself being used mutably, instead of its contents - with the consequence of making the following code emit no warnings
```
fn do_thing<T>(mut arg : &mut T) {
    ... // don't touch arg - just deref it to access the T
}
```

### Fix
Make dereferences not be counted as a mutable use, but only when they're on borrows on local variables.
#### Why not on things other than local variables?
  * Whenever you capture a variable in a closure, it gets turned into a hidden reference - when you use it in the closure, it gets dereferenced. If the closure uses the variable mutably, that is actually a mutable use of the thing being dereffed to, so it has to be counted.
  * If you deref a mutable `Box` to access the contents mutably, you are using the `Box` mutably - so it has to be counted.
2017-08-10 08:53:22 +00:00
Stefan Schindler 702750c538 Use explicit wrapping_add to prevent potential unexpected behavior on debug builds 2017-08-08 22:58:09 +02:00
Isaac van Bakel 400075d9d9 Fixed all unnecessary muts in language core 2017-08-01 23:01:24 +01:00
Oliver Middleton f2566bbaeb Correct some stability attributes
These show up in rustdoc so need to be correct.
2017-07-10 02:07:29 +01:00
Chris MacNaughton 14df54989a Ensure Guard types impl Display & Debug
Fixes #24372
2017-06-22 16:54:32 +02:00
Corey Farwell 292fcc880f Rollup merge of #42397 - sfackler:syncsender-sync, r=alexcrichton
Implement Sync for SyncSender

r? @alexcrichton
2017-06-21 10:40:14 -04:00
Stepan Koltsov 0c26b5998d Fix condvar.wait(distant future) return immediately on OSX
Fixes issue #37440: `pthread_cond_timedwait` on macOS Sierra seems
to overflow `ts_sec` parameter and returns immediately. To work
around this problem patch rounds timeout down to approximately 1000
years.

Patch also fixes overflow when converting `u64` to `time_t`.
2017-06-15 21:20:02 +01:00
Steven Fackler 0f6c01ddb6 Implement Sync for SyncSender 2017-06-02 21:09:09 -07:00
Corey Farwell eb48ee72db Rewrite Receiver::try_iter doc example to show resulting values. 2017-06-02 00:21:32 -04:00
Corey Farwell d3f3e26db0 Rewrite Receiver::iter doc example to show resulting values. 2017-06-02 00:21:27 -04:00
bors 4ed2edaafe Auto merge of #42281 - eddyb:well-adjusted, r=nikomatsakis
Decompose Adjustment into smaller steps and remove the method map.

The method map held method callee information for:
* actual method calls (`x.f(...)`)
* overloaded unary, binary, indexing and call operators
* *every overloaded deref adjustment* (many can exist for each expression)

That last one was a historical ~~accident~~ hack, and part of the motivation for this PR, along with:
* a desire to compose adjustments more freely
* containing the autoderef logic better to avoid mutation within an inference snapshot
* not creating `TyFnDef` types which are incompatible with the original one
  * i.e. we used to take a`TyFnDef`'s `for<'a> &'a T -> &'a U` signature and instantiate `'a` using a region inference variable, *then* package the resulting `&'b T -> &'b U` signature in another `TyFnDef`, while keeping *the same* `DefId` and `Substs`
* to fix #3548 by explicitly writing autorefs for the RHS of comparison operators

Individual commits tell their own story, of "atomic" changes avoiding breaking semantics.

Future work based on this PR could include:
* removing the signature from `TyFnDef`, now that it's always "canonical"
  * some questions of variance remain, as subtyping *still* treats the signature differently
* moving part of the typeck logic for methods, autoderef and coercion into `rustc::traits`
* allowing LUB coercions (joining multiple expressions) to "stack up" many adjustments
* transitive coercions (e.g. reify or unsize after multiple steps of autoderef)

r? @nikomatsakis
2017-06-01 11:34:13 +00:00
Eduard-Mihai Burtescu 58632f3c1c tests: fix fallout from empowering unused_allocation in comparisons. 2017-06-01 08:59:47 +03:00
Corey Farwell bcd1fe56c7 Rewrite doc examples for Receiver::recv_timeout. 2017-05-31 23:01:55 -04:00
Dmitry Vyukov 0b85b64d6b libstd/sync/mpsc: relicense under rust license
These files are licensed under a different license
than the rest of the codebase. This causes potential
issues and inconveniences.
Relicense these files under the standard license.
I hold original copyright on that code.

Fixes #36556
2017-05-22 09:27:39 +02:00
bors 272e77f035 Auto merge of #42111 - ollie27:stab, r=Mark-Simulacrum
Correct some stability versions

These were found by running tidy on stable versions of rust and finding
features stabilised with the wrong version numbers.
2017-05-20 15:42:43 +00:00
Oliver Middleton 2f703e4304 Correct some stability versions
These were found by running tidy on stable versions of rust and finding
features stabilised with the wrong version numbers.
2017-05-20 08:38:39 +01:00
Denis Andrejew f4e33a011e fix typo in libstd/sync/mpsc/mod.rs docs 2017-05-18 08:45:18 +02:00
Ralf Jung 23522f6cab need to pick a new feature name 2017-04-29 19:15:59 +02:00
Ralf Jung 998a877737 MutexGuard<T> may be Sync only if T is Sync
Also remove some unnecessary unsafe impl from the tests.
2017-04-29 09:44:09 +02:00
projektir c59b188aae Adding links and examples for various mspc pages #29377 2017-04-26 23:11:57 -04:00
Guillaume Gomez d79b511f5c Fix invalid linkage 2017-04-22 13:25:14 +02:00
bors 2bdf368bde Auto merge of #41103 - projektir:channel_error_docs, r=GuillaumeGomez
Channel error docs

r? @steveklabnik

I'm going to need some help on this one, a few ambiguities.
2017-04-10 09:45:16 +00:00
Geoffry Song 3d60bf45f4 Minor fix to mutex example
Presumably `N` was supposed to be used in both places.
2017-04-09 19:42:01 -04:00
projektir 28a232a59a Adding links around Sender/SyncSender/Receiver errors; Adding more documentation to channel() and sync_channel(); adding more links #29377 2017-04-08 15:33:21 -04:00
Corey Farwell b0aefe31f4 Rollup merge of #40981 - Technius:master, r=steveklabnik
Add links and some examples to std::sync::mpsc docs

Addresses part of #29377
r? @steveklabnik

I took a stab at adding links to the `std::sync::mpsc` docs, and I also wrote a few examples.

Edit: Whoops, typed in `?r` instead of `r?`.
2017-04-05 12:44:27 -04:00
Corey Farwell 1a9f415bfb Rollup merge of #40977 - projektir:BarrierWaitResult_doc, r=steveklabnik
Updating the description for BarrierWaitResult #29377

Referencing `Barrier`, removing reference to `is_leader`.
2017-04-05 12:44:26 -04:00
Corey Farwell ca37f1ad17 Rollup merge of #40608 - GuillaumeGomez:mutex-doc-inconsistency, r=steveklabnik
Fix mutex's docs inconsistency

Fixes #40176.

r? @steveklabnik
cc @rust-lang/docs
2017-04-05 12:44:24 -04:00
Bryan Tan ab4f4428e7 Fix styling issues 2017-04-03 16:09:19 -07:00
Guillaume Gomez e7c2160f8a Fix mutex's docs inconsistency 2017-04-03 18:57:13 +02:00
Bryan Tan dab8e8121f Fix warnings in examples 2017-03-31 23:22:59 -07:00
Bryan Tan ae8ba78e9d Fix broken links to std::iter::Iterator::next 2017-03-31 18:51:37 -07:00
Bryan Tan 89c35ae764 Add links and examples to std::sync::mpsc docs (#29377)
This change adds links to to `Receiver`, `Iter`, `TryIter`, `IntoIter`,
`Sender`, `SyncSender`, `SendError`, `RecvError`, `TryRecvError`,
`RecvTimeoutError`, `TrySendError`, `Sender::send`, `SyncSender::send`,
`SyncSender::try_send`, `Receiver::recv`, `Receiver::recv_timeout`,
`Receiver::iter`, and `Receiver::try_iter`.

Examples added to `Receiver`, `Sender`, `Receiver::iter`.
2017-03-31 17:07:01 -07:00
projektir 44d8b236f4 Updating the description for BarrierWaitResult #29377 2017-03-31 18:58:32 -04:00
Bryan Tan 5a6ebdfcda Add links to std::sync::mpsc docs #29377 2017-03-30 23:28:15 -07:00
projektir 3207657d12 Adding linking for Once docs #29377 2017-03-29 00:21:55 -04:00
Corey Farwell d8c8e01038 Rollup merge of #40611 - ScottAbbey:patch-1, r=GuillaumeGomez
Fix typo in mutex.rs docs

This seems to match other uses of "be accessed" in the document.
2017-03-19 10:18:20 -04:00
ScottAbbey ec8ecf4f9d Fix typo in mutex.rs docs
This seems to match other uses of "be accessed" in the document.
2017-03-17 13:27:13 -05:00
Corey Farwell e7b0f2badf Remove function invokation parens from documentation links.
This was never established as a convention we should follow in the 'More
API Documentation Conventions' RFC:

https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2017-03-13 21:43:18 -04:00
Corey Farwell 5be0d9ff04 Rollup merge of #40033 - GuillaumeGomez:condvar-docs, r=frewsxcv
Add missing urls and examples for Condvar docs

r? @frewsxcv
2017-02-28 08:33:01 -05:00
Guillaume Gomez 802a502ebd Rollup merge of #40052 - GuillaumeGomez:sunc_docs, r=frewsxcv
Add missing urls in MutexGuard docs

r? @frewsxcv
2017-02-24 13:23:00 +01:00
Guillaume Gomez 088b727456 Add missing urls in MutexGuard docs 2017-02-23 11:43:30 +01:00
Guillaume Gomez d3b8f56ae7 Add missing urls and examples for Condvar docs 2017-02-23 11:38:05 +01:00
Guillaume Gomez 58a9dd3f7e Add missing urls and examples into Barrier structs 2017-02-21 21:12:35 +01:00
Stjepan Glavina 1fbbe79bcb Fix wording in LocalKey documentation 2017-02-15 23:31:51 +01:00