about summary refs log tree commit diff
path: root/src/libstd/sync
AgeCommit message (Collapse)AuthorLines
2015-03-26Mass rename uint/int to usize/isizeAlex Crichton-8/+8
Now that support has been removed, all lingering use cases are renamed.
2015-03-24Reject specialized Drop impls.Felix S. Klock II-1/+1
See Issue 8142 for discussion. This makes it illegal for a Drop impl to be more specialized than the original item. So for example, all of the following are now rejected (when they would have been blindly accepted before): ```rust struct S<A> { ... }; impl Drop for S<i8> { ... } // error: specialized to concrete type struct T<'a> { ... }; impl Drop for T<'static> { ... } // error: specialized to concrete region struct U<A> { ... }; impl<A:Clone> Drop for U<A> { ... } // error: added extra type requirement struct V<'a,'b>; impl<'a,'b:a> Drop for V<'a,'b> { ... } // error: added extra region requirement ``` Due to examples like the above, this is a [breaking-change]. (The fix is to either remove the specialization from the `Drop` impl, or to transcribe the requirements into the struct/enum definition; examples of both are shown in the PR's fixed to `libstd`.) ---- This is likely to be the last thing blocking the removal of the `#[unsafe_destructor]` attribute. Includes two new error codes for the new dropck check. Update run-pass tests to accommodate new dropck pass. Update tests and docs to reflect new destructor restriction. ---- Implementation notes: We identify Drop impl specialization by not being as parametric as the struct/enum definition via unification. More specifically: 1. Attempt unification of a skolemized instance of the struct/enum with an instance of the Drop impl's type expression where all of the impl's generics (i.e. the free variables of the type expression) have been replaced with unification variables. 2. If unification fails, then reject Drop impl as specialized. 3. If unification succeeds, check if any of the skolemized variables "leaked" into the constraint set for the inference context; if so, then reject Drop impl as specialized. 4. Otherwise, unification succeeded without leaking skolemized variables: accept the Drop impl. We identify whether a Drop impl is injecting new predicates by simply looking whether the predicate, after an appropriate substitution, appears on the struct/enum definition.
2015-03-24Added `T:Send` bound to `Queue<T>` to avoid specialized `Drop` impl.Felix S. Klock II-1/+1
2015-03-24Added `T:Send` bound to `Packet<T>` to avoid specialized `Drop` impl.Felix S. Klock II-2/+2
2015-03-24added `T:Send` bound to `Mutex<T>` to avoid specialized Drop impl.Felix S. Klock II-1/+1
2015-03-24Added `T:Send` bound to `Queue<T>` to avoid specialized Drop impl.Felix S. Klock II-2/+2
2015-03-24Added `T:Send` bound to `sync::mpsc::Receiver` and `sync::mpsc::Sender`.Felix S. Klock II-16/+16
This was necessary to avoid specialized `Drop` impls for the two structs.
2015-03-23rollup merge of #23598: brson/gateAlex Crichton-0/+11
Conflicts: src/compiletest/compiletest.rs src/libcollections/lib.rs src/librustc_back/lib.rs src/libserialize/lib.rs src/libstd/lib.rs src/libtest/lib.rs src/test/run-make/rustdoc-default-impl/foo.rs src/test/run-pass/env-home-dir.rs
2015-03-23rollup merge of #23541: aturon/stab-errorAlex Crichton-6/+6
This small commit stabilizes the `Error` trait as-is, except that `Send` and `Debug` are added as constraints. The `Send` constraint is because most uses of `Error` will be for trait objects, and by default we would like these objects to be transferrable between threads. The `Debug` constraint is to ensure that e.g. `Box<Error>` is `Debug`, and because types that implement `Display` should certainly implement `Debug` in any case. In the near future we expect to add `Any`-like downcasting features to `Error`, but this is waiting on some additional mechanisms (`Reflect`). It will be added before 1.0 via default methods. [breaking-change] r? @alexcrichton Closes #21790
2015-03-23Add #![feature] attributes to doctestsBrian Anderson-0/+11
2015-03-23Stabilize the Error traitAaron Turon-6/+6
This small commit stabilizes the `Error` trait as-is, except that `Send` and `Debug` are added as constraints. The `Send` constraint is because most uses of `Error` will be for trait objects, and by default we would like these objects to be transferrable between threads. The `Debug` constraint is to ensure that e.g. `Box<Error>` is `Debug`, and because types that implement `Display` should certainly implement `Debug` in any case. In the near future we expect to add `Any`-like downcasting features to `Error`, but this is waiting on some additional mechanisms (`Reflect`). It will be added before 1.0 via default methods. [breaking-change]
2015-03-21Fix documentation for std::sync::mutex: into_guard -> into_innerBarosl Lee-2/+2
2015-03-20don't use Result::ok just to be able to use unwrap/unwrap_orOliver Schneider-1/+1
2015-03-13Remove explicit syntax highlight from docs.Joseph Crail-6/+6
2015-03-11Example -> ExamplesSteve Klabnik-11/+11
This brings comments in line with https://github.com/rust-lang/rfcs/blob/master/text/0505-api-comment-conventions.md#using-markdown
2015-03-10Rollup merge of #23125 - danburkert:master, r=brsonManish Goregaokar-0/+63
2015-03-09Rename #[should_fail] to #[should_panic]Steven Fackler-3/+3
2015-03-08Remove unneeded `Send` bounds from `std::sync::mpsc`.Huon Wilson-29/+29
The requirements `T: Send` only matter if the channel crosses thread boundaries i.e. the `Sender` or `Reciever` are sent across thread boundaries, and which is adequately controlled by the impls of `Send` for them. If `T` doesn't satisfy the bounds, then the types cannot cross thread boundaries and so everything is still safe (the pair of types collectively behave like a `Rc<RefCell<VecDeque>>`, or something of that nature).
2015-03-08Remove unneeded `Send`/`Sync` bounds from `Mutex`/`RwLock`.Huon Wilson-5/+7
The requirements `T: Send` and `T: Send + Sync` for `Mutex` and `RwLock` respectively only matter if those types are shared/sent across thread boundaries, and that is adequately controlled by the impls of `Send`/`Sync` for them. If `T` doesn't satisfy the bounds, then the types cannot cross thread boundaries and so everything is still safe (the two types just act like an expensive `RefCell`).
2015-03-06Implement std::error::Error for std::sync::mpsc error typesDan Burkert-0/+63
2015-03-03Add `: Box<_>` or `::Box<_>` type annotations to various places.Felix S. Klock II-6/+6
This is the kind of change that one is expected to need to make to accommodate overloaded-`box`. ---- Note that this is not *all* of the changes necessary to accommodate Issue 22181. It is merely the subset of those cases where there was already a let-binding in place that made it easy to add the necesasry type ascription. (For unnamed intermediate `Box` values, one must go down a different route; `Box::new` is the option that maximizes portability, but has potential inefficiency depending on whether the call is inlined.) ---- There is one place worth note, `run-pass/coerce-match.rs`, where I used an ugly form of `Box<_>` type ascription where I would have preferred to use `Box::new` to accommodate overloaded-`box`. I deliberately did not use `Box::new` here, because that is already done in coerce-match-calls.rs. ---- Precursor for overloaded-`box` and placement-`in`; see Issue 22181.
2015-03-02Use `const`s instead of `static`s where appropriateFlorian Zeitz-9/+9
This changes the type of some public constants/statics in libunicode. Notably some `&'static &'static [(char, char)]` have changed to `&'static [(char, char)]`. The regexp crate seems to be the sole user of these, yet this is technically a [breaking-change]
2015-02-27Rollup merge of #22803 - huonw:field-stability, r=alexcrichtonManish Goregaokar-1/+1
We were recording stability attributes applied to fields in the compiler, and even annotating it in the libs, but the compiler didn't actually do the checks to give errors/warnings in user crates. Details in the commit messages.
2015-02-27Auto merge of #22573 - nwin:impl-debug-rwlock-weak, r=Manishearthbors-0/+28
Implements `Debug` for `RwLock` and `arc::Weak` in the same way it is implemented for `rc::Weak` (basically copy & paste). The lack of this implementation prevents the automatic implementation of `Debug` for structs containing members of these types.
2015-02-27Add some missing stability attributes on struct fields.Huon Wilson-1/+1
2015-02-26Implement `Debug` for `RwLock`, `arc::Weak` and `Mutex`nwin-0/+28
2015-02-25allow(deprecated) for TaskPool (fixup #22783)Manish Goregaokar-0/+3
2015-02-25Rollup merge of #22596 - alexcrichton:fix-some-impls, r=huonwManish Goregaokar-16/+8
This commit removes many unnecessary `unsafe impl` blocks as well as pushing the needed implementations to the lowest level possible. I noticed that the bounds for `RwLock` are a little off when reviewing #22574 and wanted to ensure that we had our story straight on these implementations.
2015-02-25Rollup merge of #22783 - alexcrichton:deprecate-taskpool, r=alexcrichtonManish Goregaokar-5/+5
Rather than stabilize on the current API, we're going to punt this concern to crates.io, to allow for faster iteration. [breaking-change]
2015-02-24std: Recomend threadpool on crates.io for TaskPoolAlex Crichton-2/+2
2015-02-24Fix integers in tests (fixup #22700)Manish Goregaokar-4/+4
2015-02-24Rollup merge of #22700 - nick29581:ints_hash, r=alexcrichtonManish Goregaokar-177/+177
fmt and hash are pretty straightforward I think. sync is a bit more complex. I thought one or two of the `isize`s ought to be `i32`s, but that would require a bunch of casting (the root cause being the lack of atomics other than isize/usize). r? @alexcrichton
2015-02-23int audit - std::syncNick Cameron-177/+177
2015-02-23Use boxed functions instead of transmuteStepan Koltsov-8/+8
... to convert between Box and raw pointers. E. g. use ``` let b: Box<Foo> = Box::from_raw(p); ``` instead of ``` let b: Box<Foo> = mem::transmute(p); ``` Patch also changes closure release code in `src/libstd/sys/unix/thread.rs` when `pthread_create` failed. Raw pointer was transmuted to box of `FnOnce()` instead of `Thunk`. This code was probably never executed, because `pthread_create` rarely fails in practice.
2015-02-21Remove `'static` bound from sync::mpsc, Mutex and RwLock.Huon Wilson-45/+45
Adds some basic tests to check that the types still catch the most glaring errors that could occur. cc #22444.
2015-02-20std: Tidy up some `unsafe impl`s for `sync`Alex Crichton-16/+8
This commit removes many unnecessary `unsafe impl` blocks as well as pushing the needed implementations to the lowest level possible. I noticed that the bounds for `RwLock` are a little off when reviewing #22574 and wanted to ensure that we had our story straight on these implementations.
2015-02-18Remove `i`, `is`, `u`, or `us` suffixes that are not necessary.Niko Matsakis-39/+39
2015-02-17Test fixes and rebase conflictsAlex Crichton-6/+6
2015-02-17rollup merge of #22319: huonw/send-is-not-staticAlex Crichton-51/+51
Conflicts: src/libstd/sync/task_pool.rs src/libstd/thread.rs src/libtest/lib.rs src/test/bench/shootout-reverse-complement.rs src/test/bench/shootout-spectralnorm.rs
2015-02-17Fallout from stabilizationAaron Turon-163/+163
2015-02-18Update the libraries to reflect Send loosing the 'static bound.Huon Wilson-51/+51
In most places this preserves the current API by adding an explicit `'static` bound. Notably absent are some impls like `unsafe impl<T: Send> Send for Foo<T>` and the `std::thread` module. It is likely that it will be possible to remove these after auditing the code to ensure restricted lifetimes are safe. More progress on #22251.
2015-02-16Deprecate std::sync::TaskPoolAaron Turon-5/+5
Rather than stabilize on the current API, we're going to punt this concern to crates.io, to allow for faster iteration. If you need this functionality, you might look at https://github.com/carllerche/syncbox [breaking-change]
2015-02-15Rollup merge of #22297 - nagisa:spring-cleanup, r=alexcrichtonManish Goregaokar-8/+8
This PR replaces uses of `os::getenv` with newly introduced `env::var{,_os}`. Mostly did this as a background activity to procrastinate from procrastinating. Tests appear to build and run fine. This includes benchmarks from test/bench directory.
2015-02-13Remove a few uses of deprecated getenvSimonas Kazlauskas-8/+8
2015-02-13Improve documentation for `Select::new()`.Steve Klabnik-4/+11
Remove incorrect claim, add example, reformat and re-word. Fixes #22266
2015-02-11rustc: Fix a number of stability lint holesAlex Crichton-17/+17
There are a number of holes that the stability lint did not previously cover, including: * Types * Bounds on type parameters on functions and impls * Where clauses * Imports * Patterns (structs and enums) These holes have all been fixed by overriding the `visit_path` function on the AST visitor instead of a few specialized cases. This change also necessitated a few stability changes: * The `collections::fmt` module is now stable (it was already supposed to be). * The `thread_local::imp::Key` type is now stable (it was already supposed to be). * The `std::rt::{begin_unwind, begin_unwind_fmt}` functions are now stable. These are required via the `panic!` macro. * The `std::old_io::stdio::{println, println_args}` functions are now stable. These are required by the `print!` and `println!` macros. * The `ops::{FnOnce, FnMut, Fn}` traits are now `#[stable]`. This is required to make bounds with these traits stable. Note that manual implementations of these traits are still gated by default, this stability only allows bounds such as `F: FnOnce()`. Additionally, the compiler now has special logic to ignore its own generated `__test` module for the `--test` harness in terms of stability. Closes #8962 Closes #16360 Closes #20327 [breaking-change]
2015-02-06sync: Expose PoisonError::newKeegan McAllister-12/+14
2015-02-06sync: Add is_poisoned to Mutex and RwLockKeegan McAllister-0/+26
2015-02-06Rollup merge of #21991 - steveklabnik:gh21915, r=huonwManish Goregaokar-1/+1
Fixes #21915
2015-02-06Rollup merge of #21925 - sfackler:allow-missing-copy, r=alexcrichtonManish Goregaokar-2/+0
This was particularly helpful in the time just after OIBIT's implementation to make sure things that were supposed to be Copy continued to be, but it's now creates a lot of noise for types that intentionally don't want to be Copy. r? @alexcrichton