about summary refs log tree commit diff
path: root/src/libcore/clone.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-235/+0
2020-04-25Bump bootstrap compilerMark Rousskov-1/+0
2020-04-03Minor follow-up after renaming librustc(_middle)Yuki Okushi-1/+2
2020-03-30rustc -> rustc_middle part 1Mazdak Farrokhzad-1/+1
2020-03-26convert to doc commentsNiko Matsakis-2/+2
2020-03-26permit negative impls for non-auto traitsNiko Matsakis-0/+5
2019-12-21Require issue = "none" over issue = "0" in unstable attributesRoss MacArthur-2/+2
2019-12-14Revert "Stabilize the `never_type`, written `!`."Niko Matsakis-1/+1
This reverts commit 15c30ddd69d6cc3fffe6d304c6dc968a5ed046f1.
2019-11-26Format libcore with rustfmtDavid Tolnay-11/+20
This commit applies rustfmt with default settings to files in src/libcore *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/libcore -name '*.rs' | xargs rustfmt --edition=2018 $ rg libcore outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of libcore.
2019-11-21Stabilize the `never_type`, written `!`.Mazdak Farrokhzad-1/+1
2019-09-25Snap cfgs to new betaMark Rousskov-1/+0
2019-09-23Move `--cfg bootstrap` out of `rustc.rs`Alex Crichton-1/+1
Instead let's do this via `RUSTFLAGS` in `builder.rs`. Currently requires a submodule update of `stdarch` to fix a problem with previous compilers.
2019-08-17Make built-in derives opaque macrosMatthew Jasper-1/+1
2019-08-14Handle cfg(bootstrap) throughoutMark Rousskov-1/+0
2019-08-10Give built-in macros stable addresses in the standard libraryVadim Petrochenkov-0/+8
2019-04-18libcore => 2018Taiki Endo-2/+2
2019-01-01Auto merge of #57125 - doitian:inconsistent-clone-doc, r=blussbors-9/+20
Fix inconsistent Clone documentation. Now, arrays of any size Clone if the element type is Clone. So remove the the document that uses this as an example. refs #57123
2018-12-31Fix inconsistent Clone documentation.ian-9/+20
Use function pointer as the example to demonstrate how to implement Clone for Copy types. refs #57123
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-5/+5
2018-09-29Use impl_header_lifetime_elision in libcoreScott McMurray-1/+1
2018-05-17Switch to 1.26 bootstrap compilerMark Simulacrum-1/+0
2018-04-20Revert stabilization of `feature(never_type)`.Felix S. Klock II-1/+1
This commit is just covering the feature gate itself and the tests that made direct use of `!` and thus need to opt back into the feature. A follow on commit brings back the other change that motivates the revert: Namely, going back to the old rules for falling back to `()`.
2018-04-04Auto merge of #49642 - kennytm:rollup, r=kennytmbors-0/+1
Rollup of 25 pull requests Successful merges: - #49179 (Handle future deprecation annotations ) - #49512 (Add support for variant and types fields for intra links) - #49515 (fix targetted value background) - #49516 (Add missing anchor for union type fields) - #49532 (Add test for rustdoc ignore test) - #49533 (Add #[must_use] to a few standard library methods) - #49540 (Fix miri Discriminant() for non-ADT) - #49559 (Introduce Vec::resize_with method (see #41758)) - #49570 (avoid IdxSets containing garbage above the universe length) - #49577 (Stabilize String::replace_range) - #49599 (Fix typo) - #49603 (Fix url for intra link provided method) - #49607 (Stabilize iterator methods in 1.27) - #49609 (run-pass/attr-stmt-expr: expand test cases) - #49612 (Fix "since" version for getpid feature.) - #49618 (Fix build error when compiling libcore for 16bit targets) - #49619 (tweak core::fmt docs) - #49637 (Stabilize parent_id()) - #49639 (Update Cargo) - #49628 (Re-write the documentation index) - #49594 (Add some performance guidance to std::fs and std::io docs) - #49625 (miri: add public alloc_kind accessor) - #49634 (Add a test for the fix to issue #43058) - #49641 (Regression test for #46314) - #49547 (Unignore borrowck test) Failed merges:
2018-03-30Add #[must_use] to a few standard library methodsScott McMurray-0/+1
Chosen to start a precedent of using it on ones that are potentially-expensive and where using it for side effects is particularly discouraged. Discuss :)
2018-03-26Add #[inline] to Clone impls for primitive typesFrancis Gagné-0/+5
2018-03-26Document builtin implementations of Clone and CopyFrancis Gagné-5/+17
There are types that implement `Clone` and `Copy` but are not mentioned in the documentation, because the implementations are provided by the compiler. They are types of variants that cannot be fully covered by trait implementations in Rust code, because the language is not expressive enough.
2018-03-26Move some implementations of Clone and Copy to libcoreFrancis Gagné-0/+60
Add implementations of `Clone` and `Copy` for some primitive types to libcore so that they show up in the documentation. The concerned types are the following: * All primitive signed and unsigned integer types (`usize`, `u8`, `u16`, `u32`, `u64`, `u128`, `isize`, `i8`, `i16`, `i32`, `i64`, `i128`); * All primitive floating point types (`f32`, `f64`) * `bool` * `char` * `!` * Raw pointers (`*const T` and `*mut T`) * Shared references (`&'a T`) These types already implemented `Clone` and `Copy`, but the implementation was provided by the compiler. The compiler no longer provides these implementations and instead tries to look them up as normal trait implementations. The goal of this change is to make the implementations appear in the generated documentation. For `Copy` specifically, the compiler would reject an attempt to write an `impl` for the primitive types listed above with error `E0206`; this error no longer occurs for these types, but it will still occur for the other types that used to raise that error. The trait implementations are guarded with `#[cfg(not(stage0))]` because they are invalid according to the stage0 compiler. When the stage0 compiler is updated to a revision that includes this change, the attribute will have to be removed, otherwise the stage0 build will fail because the types mentioned above no longer implement `Clone` or `Copy`. For type variants that are variadic, such as tuples and function pointers, and for array types, the `Clone` and `Copy` implementations are still provided by the compiler, because the language is not expressive enough yet to be able to write the appropriate implementations in Rust. The initial plan was to add `impl` blocks guarded by `#[cfg(dox)]` to make them apply only when generating documentation, without having to touch the compiler. However, rustdoc's usage of the compiler still rejected those `impl` blocks. This is a [breaking-change] for users of `#![no_core]`, because they will now have to supply their own implementations of `Clone` and `Copy` for the primitive types listed above. The easiest way to do that is to simply copy the implementations from `src/libcore/clone.rs` and `src/libcore/marker.rs`. Fixes #25893
2018-03-23Mention closures in docs for Clone and CopySimon Sapin-0/+5
2017-08-31Update bootstrap compilerAlex Crichton-43/+1
This commit updates the bootstrap compiler and clears out a number of #[cfg(stage0)] annotations and related business
2017-08-14Make `Clone` a lang item and generate builtin impls.scalexm-0/+3
Fixes #28229. Fixes #24000.
2017-07-23Auto merge of #43406 - canndrew:never-impl-clone, r=alexcrichtonbors-0/+1
Add missing `!: Clone` impl Fixes #43296 (untested because I'm having computer troubles, but a one-liner can't break anything right?)
2017-07-22Add !: Clone implAndrew Cann-0/+1
2017-07-20std: Cut down #[inline] annotations where not necessaryAlex Crichton-1/+1
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-03-13Remove function invokation parens from documentation links.Corey Farwell-2/+2
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-02-03Bump version, upgrade bootstrapAlex Crichton-2/+0
This commit updates the version number to 1.17.0 as we're not on that version of the nightly compiler, and at the same time this updates src/stage0.txt to bootstrap from freshly minted beta compiler and beta Cargo.
2016-12-30Such large. Very 128. Much bits.Simonas Kazlauskas-0/+4
This commit introduces 128-bit integers. Stage 2 builds and produces a working compiler which understands and supports 128-bit integers throughout. The general strategy used is to have rustc_i128 module which provides aliases for iu128, equal to iu64 in stage9 and iu128 later. Since nowhere in rustc we rely on large numbers being supported, this strategy is good enough to get past the first bootstrap stages to end up with a fully working 128-bit capable compiler. In order for this strategy to work, number of locations had to be changed to use associated max_value/min_value instead of MAX/MIN constants as well as the min_value (or was it max_value?) had to be changed to use xor instead of shift so both 64-bit and 128-bit based consteval works (former not necessarily producing the right results in stage1). This commit includes manual merge conflict resolution changes from a rebase by @est31.
2016-09-28Remove stage0 hacksBrian Anderson-7/+0
2016-09-15Rollup merge of #36384 - petrochenkov:derclone, r=alexcrichtonManish Goregaokar-3/+16
Improve shallow `Clone` deriving `Copy` unions now support `#[derive(Clone)]`. Less code is generated for `#[derive(Clone, Copy)]`. + Unions now support `#[derive(Eq)]`. Less code is generated for `#[derive(Eq)]`. --- Example of code reduction: ``` enum E { A { a: u8, b: u16 }, B { c: [u8; 100] }, } ``` Before: ``` fn clone(&self) -> E { match (&*self,) { (&E::A { a: ref __self_0, b: ref __self_1 },) => { ::std::clone::assert_receiver_is_clone(&(*__self_0)); ::std::clone::assert_receiver_is_clone(&(*__self_1)); *self } (&E::B { c: ref __self_0 },) => { ::std::clone::assert_receiver_is_clone(&(*__self_0)); *self } } } ``` After: ``` fn clone(&self) -> E { { let _: ::std::clone::AssertParamIsClone<u8>; let _: ::std::clone::AssertParamIsClone<u16>; let _: ::std::clone::AssertParamIsClone<[u8; 100]>; *self } } ``` All the matches are removed, bound assertions are more lightweight. `let _: Checker<CheckMe>;`, unlike `checker(&check_me);`, doesn't have to be translated by rustc_trans and then inlined by LLVM, it doesn't even exist in MIR, this means faster compilation. --- Union impls are generated like this: ``` union U { a: u8, b: u16, c: [u8; 100], } ``` ``` fn clone(&self) -> U { { let _: ::std::clone::AssertParamIsCopy<Self>; *self } } ``` Fixes https://github.com/rust-lang/rust/issues/36043 cc @durka r? @alexcrichton
2016-09-11Improve Clone docggomez-9/+16
2016-09-10Improve shallow `Clone` derivingVadim Petrochenkov-3/+16
2016-08-24Use `#[prelude_import]` in `libcore`.Jeffrey Seyfried-2/+0
2016-05-23Prefer `ClassName` over `Self` in example trait implementationsCarol (Nichols || Goulding)-1/+1
2016-05-23"more than 32" => "more than 32 elements"Carol (Nichols || Goulding)-2/+2
2016-05-23Emphasize semantic differences of Copy/Clone rather than implCarol (Nichols || Goulding)-3/+4
2016-05-23Shorten, yet clarify, initial summary sentencesCarol (Nichols || Goulding)-1/+3
2016-05-23Add more detail to `Clone`'s documentationCarol (Nichols || Goulding)-1/+25
Used as resources: - https://users.rust-lang.org/t/whats-the-difference-between-trait-copy-and-clone/2609/2?u=carols10cents
2016-05-23Add explanations about what derived trait implementations doCarol (Nichols || Goulding)-1/+2
2016-05-04implement RFC 1521Alex Burka-0/+5
Adds documentation to Clone, specifying that Copy types should have a trivial Clone impl. Fixes #33416.
2016-04-26shallow Clone for #[derive(Copy,Clone)]Alex Burka-0/+11
Changes #[derive(Copy, Clone)] to use a faster impl of Clone when both derives are present, and there are no generics in the type. The faster impl is simply returning *self (which works because the type is also Copy). See the comments in libsyntax_ext/deriving/clone.rs for more details. There are a few types which are Copy but not Clone, in violation of the definition of Copy. These include large arrays and tuples. The very existence of these types is arguably a bug, but in order for this optimization not to change the applicability of #[derive(Copy, Clone)], the faster Clone impl also injects calls to a new function, core::clone::assert_receiver_is_clone, to verify that all members are actually Clone. This is not a breaking change, because pursuant to RFC 1521, any type that implements Copy should not do any observable work in its Clone impl.