about summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2015-03-24Test fixes and rebase conflicts, round 2Alex Crichton-11/+17
2015-03-24rollup merge of #23674: nagisa/fallout-1Alex Crichton-7/+7
2015-03-24Test fixes and rebase conflicts, round 1Alex Crichton-0/+2
2015-03-25Fix some fallout in librustdocSimonas Kazlauskas-7/+7
2015-03-24rollup merge of #23671: steveklabnik/doc_std_cloneAlex Crichton-0/+8
2015-03-24rollup merge of #23638: pnkfelix/fsk-reject-specialized-dropsAlex Crichton-63/+465
Reject specialized Drop impls. 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. Fix #8142 Fix #23584
2015-03-24rollup merge of #23546: alexcrichton/hyphensAlex Crichton-145/+144
The compiler will now issue a warning for crates that have syntax of the form `extern crate "foo" as bar`, but it will still continue to accept this syntax. Additionally, the string `foo-bar` will match the crate name `foo_bar` to assist in the transition period as well. This patch will land hopefully in tandem with a Cargo patch that will start translating all crate names to have underscores instead of hyphens. cc #23533
2015-03-24rustc: Add support for `extern crate foo as bar`Alex Crichton-145/+144
The compiler will now issue a warning for crates that have syntax of the form `extern crate "foo" as bar`, but it will still continue to accept this syntax. Additionally, the string `foo-bar` will match the crate name `foo_bar` to assist in the transition period as well. This patch will land hopefully in tandem with a Cargo patch that will start translating all crate names to have underscores instead of hyphens. cc #23533
2015-03-24rollup merge of #23668: alexcrichton/io-zeroAlex Crichton-30/+14
This commit alters the behavior of the `Read::read_to_end()` method to zero all memory instead of passing an uninitialized buffer to `read`. This change is motivated by the [discussion on the internals forum][discuss] where the conclusion has been that the standard library will not expose uninitialized memory. [discuss]: http://internals.rust-lang.org/t/uninitialized-memory/1652 Closes #20314
2015-03-24rollup merge of #23662: steveklabnik/gh23421Alex Crichton-3/+3
I assume since both shifts say the same thing, I should fix both of them, but then I realized I don't strictly know about left shift. Fixes #23421 r? @pnkfelix
2015-03-24rollup merge of #23661: steveklabnik/any_docsAlex Crichton-4/+4
http://www.reddit.com/r/rust/comments/304q00/type_information_in_rust/cpp43lu
2015-03-24rollup merge of #23659: GBGamer/masterAlex Crichton-0/+58
For other permissions beside USR permissions, we need these constants. fixes #23658
2015-03-24rollup merge of #23646: steveklabnik/doc_fileAlex Crichton-0/+74
This is pretty basic, but it's nice to have something. r? @alexcrichton
2015-03-24rollup merge of #23630: nrc/coerce-tidyAlex Crichton-621/+593
See notes on the first commit Closes #18601 r? @nikomatsakis cc @eddyb
2015-03-24rollup merge of #23629: liammonahan/masterAlex Crichton-2/+2
Found a small typo on the Rust book "ownership" page. Best, Liam r? @steveklabnik
2015-03-24rollup merge of #23592: alexcrichton/tweak-at-exitAlex Crichton-46/+65
There have been some recent panics on the bots and this commit is an attempt to appease them. Previously it was considered invalid to run `rt::at_exit` after the handlers had already started running. Due to the multithreaded nature of applications, however, it is not always possible to guarantee this. For example [this program][ex] will show off the abort. [ex]: https://gist.github.com/alexcrichton/56300b87af6fa554e52d The semantics of the `rt::at_exit` function have been modified as such: * It is now legal to call `rt::at_exit` at any time. The return value now indicates whether the closure was successfully registered or not. Callers must now decide what to do with this information. * The `rt::at_exit` handlers will now be run for a fixed number of iterations. Common cases (such as the example shown) may end up registering a new handler while others are running perhaps once or twice, so this common condition is covered by re-running the handlers a fixed number of times, after which new registrations are forbidden. Some usage of `rt::at_exit` was updated to handle these new semantics, but deprecated or unstable libraries calling `rt::at_exit` were not updated.
2015-03-24rollup merge of #23573: steveklabnik/doc_associated_typesAlex Crichton-0/+203
2015-03-24rollup merge of #23282: nikomatsakis/fn-trait-inheritanceAlex Crichton-261/+711
The primary motivation here is to sidestep #19032 -- for a time, I thought that we should improve coherence or otherwise extend the language, but I now think that any such changes will require more time to bake. In the meantime, inheritance amongst the fn traits is both logically correct *and* a simple solution to that obstacle. This change introduces inheritance and modifies the compiler so that it can properly generate impls for closures and fns. Things enabled by this PR (but not included in this PR): 1. An impl of `FnMut` for `&mut F` where `F : FnMut` (https://github.com/rust-lang/rust/issues/23015). 2. A better version of `Thunk` I've been calling `FnBox`. I did not include either of these in the PR because: 1. Adding the impls in 1 currently induces a coherence conflict with the pattern trait. This is interesting and merits some discussion. 2. `FnBox` deserves to be a PR of its own. The main downside to this design is (a) the need to write impls by hand; (b) the possibility of implementing `FnMut` with different semantics from `Fn`, etc. Point (a) is minor -- in particular, it does not affect normal closure usage -- and could be addressed in the future in many ways (better defaults; convenient macros; specialization; etc). Point (b) is unfortunate but "just a bug" from my POV, and certainly not unique to these traits (c.f. Copy/Clone, PartialEq/Eq, etc). (Until we lift the feature-gate on implementing the Fn traits, in any case, there is room to correct both of these if we find a nice way.) Note that I believe this change is reversible in the future if we decide on another course of action, due to the feature gate on implementing the `Fn` traits, though I do not (currently) think we should reverse it. Fixes #18835. r? @nrc
2015-03-25Bug fixesNick Cameron-25/+3
2015-03-24Unit tests for Issue 8142, collected into one file.Felix S. Klock II-0/+79
2015-03-24Reject specialized Drop impls.Felix S. Klock II-18/+341
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 `JoinGuard<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-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 `W: Writer` bound to `BufferedWriter<W>` to avoid specialized `Drop` impl.Felix S. Klock II-9/+9
2015-03-24Added `T:Send` bound to `Queue<T>` to avoid specialized Drop impl.Felix S. Klock II-2/+2
2015-03-24Added `Write` bounds to avoid a specialized Drop impl for `BufWriter`.Felix S. Klock II-9/+9
2015-03-24Added `T:Send` bound to `sync::mpsc::Receiver` and `sync::mpsc::Sender`.Felix S. Klock II-17/+17
This was necessary to avoid specialized `Drop` impls for the two structs.
2015-03-24Remove unnecessary bounds from Drop impl for `Arc` and `arc::Weak` andFelix S. Klock II-3/+3
one of the helper method impls.
2015-03-25Change lint names to pluralsNick Cameron-49/+49
2015-03-25Add testsNick Cameron-2/+167
2015-03-25Remove the UnusedCasts lintNick Cameron-25/+0
2015-03-25Minor refactoring in coercion.rsNick Cameron-147/+163
2015-03-25Add trivial cast lints.Nick Cameron-449/+287
This permits all coercions to be performed in casts, but adds lints to warn in those cases. Part of this patch moves cast checking to a later stage of type checking. We acquire obligations to check casts as part of type checking where we previously checked them. Once we have type checked a function or module, then we check any cast obligations which have been acquired. That means we have more type information available to check casts (this was crucial to making coercions work properly in place of some casts), but it means that casts cannot feed input into type inference. [breaking change] * Adds two new lints for trivial casts and trivial numeric casts, these are warn by default, but can cause errors if you build with warnings as errors. Previously, trivial numeric casts and casts to trait objects were allowed. * The unused casts lint has gone. * Interactions between casting and type inference have changed in subtle ways. Two ways this might manifest are: - You may need to 'direct' casts more with extra type information, for example, in some cases where `foo as _ as T` succeeded, you may now need to specify the type for `_` - Casts do not influence inference of integer types. E.g., the following used to type check: ``` let x = 42; let y = &x as *const u32; ``` Because the cast would inform inference that `x` must have type `u32`. This no longer applies and the compiler will fallback to `i32` for `x` and thus there will be a type error in the cast. The solution is to add more type information: ``` let x: u32 = 42; let y = &x as *const u32; ```
2015-03-24An example for cloneSteve Klabnik-0/+8
2015-03-24std: Zero memory when calling `read_to_end()`Alex Crichton-30/+14
This commit alters the behavior of the `Read::read_to_end()` method to zero all memory instead of passing an uninitialized buffer to `read`. This change is motivated by the [discussion on the internals forum][discuss] where the conclusion has been that the standard library will not expose uninitialized memory. [discuss]: http://internals.rust-lang.org/t/uninitialized-memory/1652 Closes #20314
2015-03-24Test fixes and rebase conflicts, round 4Alex Crichton-2/+0
2015-03-24correct reference wrt shiftsSteve Klabnik-3/+3
Fixes #23421
2015-03-24Clean up Any's title lineSteve Klabnik-4/+4
http://www.reddit.com/r/rust/comments/304q00/type_information_in_rust/cpp43lu
2015-03-24Add basic information about associated typesSteve Klabnik-0/+203
2015-03-24Add Examples for FileSteve Klabnik-0/+74
This is pretty basic, but it's nice to have something.
2015-03-24Add the other S_I(RWX)(GRP/OTH) for posix `creat`Nicholas Mazzuca-0/+58
2015-03-23Test fixes and rebase conflicts, round 3Alex Crichton-6/+3
2015-03-23Improve the wording of the example section description on the ownership pageLiam Monahan-2/+2
to make it more clear.
2015-03-23rollup merge of #23653: dhuseby/bitrig-stage0-c64d671Alex Crichton-1/+1
@alexcrichton this adds the latest Bitrig snapshot. Please upload the corresponding snapshot: https://github.com/dhuseby/rust-cross-bitrig/blob/master/snapshots/rust-stage0-2015-03-17-c64d671-bitrig-x86_64-41de2c7a69a1ac648d3fa3b65e96a29bdc122163.tar.bz2
2015-03-23rollup merge of #23652: alexcrichton/stabilize-hasher-finishAlex Crichton-1/+1
This commit enables writing a stable implementation of the `Hasher` trait as well as actually calculating the hash of a vlaue in a stable fashion. The signature is stabilized as-is.
2015-03-23rollup merge of #23645: steveklabnik/gh23642Alex Crichton-6/+3
Fixes #23642
2015-03-23rollup merge of #23644: mbrubeck/doc-editAlex Crichton-6/+3
PR #23104 moved `is_null` and `offset` to an inherent impl on the raw pointer type. I'm not sure whether or how it's possible to link to docs for that impl. r? @steveklabnik
2015-03-23Test fixes and rebase conflicts, round 2Alex Crichton-149/+179