about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2017-07-22Add conversions from references to NonZero pointers, Unique, and SharedSimon Sapin-0/+47
2017-07-22Implement From<Unique<T>> for Shared<T>Simon Sapin-0/+8
2017-07-22Rename {NonZero,Shared,Unique}::new_checked to newSimon Sapin-5/+5
2017-07-22Rename {NonZero,Shared,Unique}::new to new_uncheckedSimon Sapin-11/+11
2017-07-22Add `new_checked(…) -> Option<Self>` to NonZero, Unique, and Shared.Simon Sapin-19/+65
2017-07-22Add generic example of std::ops::Sub in doc commentsmandeep-0/+36
2017-07-22Auto merge of #43367 - alexcrichton:remove-inline-always, r=sfacklerbors-50/+50
std: Cut down #[inline] annotations where not necessary This PR cuts down on a large number of `#[inline(always)]` and `#[inline]` annotations in libcore for various core functions. The `#[inline(always)]` annotation is almost never needed and is detrimental to debug build times as it forces LLVM to perform inlining when it otherwise wouldn't need to in debug builds. Additionally `#[inline]` is an unnecessary annoation on almost all generic functions because the function will already be monomorphized into other codegen units and otherwise rarely needs the extra "help" from us to tell LLVM to inline something. Overall this PR cut the compile time of a [microbenchmark][1] by 30% from 1s to 0.7s. [1]: https://gist.github.com/alexcrichton/a7d70319a45aa60cf36a6a7bf540dd3a
2017-07-22Add !: Clone implAndrew Cann-0/+1
2017-07-20std: Cut down #[inline] annotations where not necessaryAlex Crichton-50/+50
This PR cuts down on a large number of `#[inline(always)]` and `#[inline]` annotations in libcore for various core functions. The `#[inline(always)]` annotation is almost never needed and is detrimental to debug build times as it forces LLVM to perform inlining when it otherwise wouldn't need to in debug builds. Additionally `#[inline]` is an unnecessary annoation on almost all generic functions because the function will already be monomorphized into other codegen units and otherwise rarely needs the extra "help" from us to tell LLVM to inline something. Overall this PR cut the compile time of a [microbenchmark][1] by 30% from 1s to 0.7s. [1]: https://gist.github.com/alexcrichton/a7d70319a45aa60cf36a6a7bf540dd3a
2017-07-19Auto merge of #42859 - eddyb:const-size-and-align-of, r=nikomatsakisbors-0/+43
Implement const fn {size,align}_of. Fixes #34078. r? @nikomatsakis
2017-07-19Implement const fn {size,align}_of.Eduard-Mihai Burtescu-0/+43
2017-07-19Fix overflowing_literals lint for large f32sOliver Middleton-5/+1
Float literals need to be parsed as the correct type so they can be rounded correctly.
2017-07-18Rollup merge of #43292 - kennytm:fix-quasi-quoting-warning-in-rustbuild, ↵Mark Simulacrum-1/+1
r=alexcrichton Workaround "Quasi-quoting is inefficient" warning in incremental rustbuild introduced in #43252. After #43252 is merged, building stage0 libcore with `-i` (`--incremental`) flag will cause 17 "Quasi-quoting might make incremental compilation very inefficient: NtExpr(..)" warnings, as in #40946. ``` warning: Quasi-quoting might make incremental compilation very inefficient: NtExpr(..) --> src/libcore/default.rs:133:21 | 133 | #[doc = $doc] | ^^^^ ... 139 | default_impl! { (), (), "Returns the default value of `()`" } | ------------------------------------------------------------- in this macro invocation (× 17) ``` True fix for #40946 will take at least 12 weeks from now to make into the next stage0, so it is quicker to workaround it in libcore instead. cc @vbrandl @jseyfried
2017-07-18Rollup merge of #42837 - rthomas:29355-error, r=steveklabnikMark Simulacrum-0/+16
Update docs on Error struct. #29355 This adds a pretty contrived example of the usage of fmt::Error. I am very open to suggestions for a better one. I have also highlighted the fmt::Error vs std::error::Error. r? @steveklabnik
2017-07-18Fix "Quasi-quoting is inefficient" warning in incremental rustbuild.kennytm-1/+1
After #43252 is merged, building stage0 libcore with -i (--incremental) flag will cause 17 "Quasi-quoting might make incremental compilation very inefficient: NtExpr(..)" warnings, as in #40946. Fixing the warning in #40946 will take 12 weeks from now to make into the next stage0, so it is quicker to workaround it in libcore instead.
2017-07-16Auto merge of #43237 - ↵bors-1/+1
zackmdavis:missing_sum_and_product_for_128_bit_integers, r=nagisa add u128/i128 to sum/product implementors Resolves #43235.
2017-07-16Auto merge of #43252 - vbrandl:doc/default-values, r=GuillaumeGomezbors-18/+19
Document default values for primitive types All primitive types implement the `Default` trait but the documentation just says `Returns the "default value" for a type.` and doesn't give a hint about the actual default value. I think it would be good to document the default values in a proper way. I changed the `default_impl` macro to accept a doc string as a third parameter and use this string to overwrite the documentation of `default()` for each primitive type. The generated documentation now looks like this: ![Documentation of default() on the bool primitive](https://i.imgur.com/nK6TApo.png)
2017-07-15Rephrase the doc stringValentin Brandl-17/+17
2017-07-15Document default values for primitive typesValentin Brandl-18/+19
2017-07-14Rollup merge of #43159 - cuviper:ptr-swap-simd, r=arielb1Corey Farwell-1/+4
Disable big-endian simd in swap_nonoverlapping_bytes This is a workaround for #42778, which was git-bisected to #40454's optimizations to `mem::swap`, later moved to `ptr` in #42819. Natively compiled rustc couldn't even compile stage1 libcore on powerpc64 and s390x, but they work fine without this `repr(simd)`. Since powerpc64le works OK, it seems probably related to being big-endian. The underlying problem is not yet known, but this at least makes those architectures functional again in the meantime. cc @arielb1
2017-07-14add u128/i128 to sum/product implementorsZack M. Davis-1/+1
Resolves #43235.
2017-07-13Forward more Iterator methods for iter::RevSimon Sapin-0/+8
`position` could not be implemented because calling `rposition` on the inner iterator would require more trait bounds.
2017-07-13Forward more Iterator methods for str::BytesSimon Sapin-0/+38
These are overridden by slice::Iter
2017-07-13Update docs on Error struct. #29355Ryan Thomas-0/+16
This adds a pretty contrived example of the usage of fmt::Error. I am very open to suggestions for a better one. I have also highlighted the fmt::Error vs std::error::Error. r? @steveklabnik
2017-07-12Rollup merge of #43137 - ollie27:stab, r=aturonMark Simulacrum-5/+5
Correct some stability attributes These show up in rustdoc so need to be correct.
2017-07-12Rollup merge of #43011 - qnighy:unsized-tuple-impls, r=aturonMark Simulacrum-7/+23
Implement Eq/Hash/Debug etc. for unsized tuples. As I mentioned in [the comment in #18469](https://github.com/rust-lang/rust/issues/18469#issuecomment-306767422), the implementations of `PartialEq`, `Eq`, `PartialOrd`, `Ord`, `Debug`, `Hash` can be generalized to unsized tuples. This is consistent with the `derive` behavior for unsized structs. ```rust #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)] struct MyTuple<X, Y, Z: ?Sized>(X, Y, Z); fn f(x: &MyTuple<i32, i32, [i32]>) { x == x; x < x; println!("{:?}", x); } ``` Questions: - Need an RFC? - Need a feature gate? I don't think it does because the unsized tuple coercion #42527 is feature-gated. - I changed `builder.field($name);` into `builder.field(&$name);` in the `Debug` implementation to pass compilation. This won't affect the behavior because `Debug for &'a T` is a mere redirection to `Debug for T`. However, I don't know if it affects code size / performance.
2017-07-12Rollup merge of #42670 - dns2utf8:panic_return_code, r=steveklabnikMark Simulacrum-1/+1
Add hint about the return code of panic! I hope the link works on all cases, since the `unreachable` doc is copied to `std::` as well.
2017-07-10Disable big-endian simd in swap_nonoverlapping_bytesJosh Stone-1/+4
This is a workaround for #42778, which was git-bisected to #40454's optimizations to `mem::swap`, later moved to `ptr` in #42819. Natively compiled rustc couldn't even compile stage1 libcore on powerpc64 and s390x, but they work fine without this `repr(simd)`. Since powerpc64le works OK, it seems probably related to being big-endian. The underlying problem is not yet known, but this at least makes those architectures functional again in the meantime. cc @arielb1
2017-07-10Correct some stability attributesOliver Middleton-5/+5
These show up in rustdoc so need to be correct.
2017-07-08Add tests for reaching the end of RangeInclusive as an iteratorSimon Sapin-0/+20
2017-07-08Add tests for Range*::nthSimon Sapin-0/+51
2017-07-08Implement O(1)-time Iterator::nth for Range*Simon Sapin-5/+84
2017-07-08Factorize some macros in iter/range.rsSimon Sapin-57/+28
2017-07-08Remove Step::steps_between, rename steps_between_by_one to steps_betweenSimon Sapin-51/+10
2017-07-08Remove unused Step methodsSimon Sapin-34/+0
2017-07-08Remove unused Add bounds in iterator for ranges impls.Simon Sapin-23/+8
2017-07-06remove associated_consts feature gateSean McArthur-1/+2
2017-07-05Add `rustc_on_unimplemented` message to `std::ops::Try`Esteban Küber-0/+2
2017-07-05Insert current implementation headerStefan Schindler-1/+1
2017-07-04Rollup merge of #43043 - sfackler:reverse-stability, r=Mark-SimulacrumMark Simulacrum-1/+1
Add a stability marker for core::cmp::Reverse.0 Closes #43027
2017-07-04Rollup merge of #42836 - rthomas:29355-debug, r=GuillaumeGomezMark Simulacrum-10/+129
Update docs for Debug* structs. #29355 This adds docs for the Debug* structs as well as examples from the Formatter::debug_* methods, so that a user knows how to construct them. I added these examples as the builders module is not public and hence the debug_*_new() functions are not available to a user. r? @steveklabnik
2017-07-04Auto merge of #43012 - scottmcm:delete-range-step-by, r=alexcrichtonbors-246/+16
Delete deprecated & unstable range-specific `step_by` Using the new one is annoying while this one exists, since the inherent method hides the one on iterator. Tracking issue: #27741 Replacement: #41439 Deprecation: #42310 for 1.19 Fixes #41477
2017-07-03Add a stability marker for core::cmp::Reverse.0Steven Fackler-1/+1
Closes #43027
2017-07-02Auto merge of #43010 - stjepang:stabilize-sort-unstable, r=alexcrichtonbors-6/+5
Stabilize feature sort_unstable Closes #40585
2017-07-02Remove the remaining feature gatesStjepan Glavina-1/+0
2017-07-02Add docs for Debug* structs. #29355Ryan Thomas-10/+129
This adds docs for the Debug* structs as well as examples from the Formatter::debug_* methods, so that a user knows how to construct them. I added these examples as the builders module is not public and hence the debug_*_new() functions are not available to a user. r? @steveklabnik Review comments. Mainly adding in the links for all of the structs and functions. Remove rust tag on code blocks.
2017-07-02Style fixest31-1/+1
2017-07-02Documentationest31-2/+2
2017-07-02Fix the test failure, add comment, and refactor a little bitest31-102/+22
2017-07-02Output line column info when panickingest31-17/+120