Commit Graph

45 Commits

Author SHA1 Message Date
xizheyin
cea87ecad6 std: clarify Clone trait documentation about duplication semantics
This commit improves the Clone trait documentation to address confusion
around what "duplication" means for different types, especially for smart
pointers like Arc<Mutex<T>>.

Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-31 12:01:57 +08:00
bors
6813f955a6 Auto merge of #139279 - BoxyUwU:bump-boostrap, r=jieyouxu
Bump boostrap compiler to new beta

try-job: `*msvc*`
2025-04-10 00:43:25 +00:00
Boxy
c93005ee65 update cfgs 2025-04-09 12:29:59 +01:00
timesince
069fd02588 Remove redundant words 2025-04-09 18:46:50 +08:00
Kevin Reid
96814ae55f Rewrite example to not deal with Copy at all.
It also now demonstrates how to avoid memory leaks.
2025-03-10 15:03:36 -07:00
Kevin Reid
2cc999d0d4 Rewrite comments about dropping and leaking. 2025-03-10 13:54:07 -07:00
Kevin Reid
769425a4ea Expand CloneToUninit documentation.
* Clarify relationship to `dyn` after #133003.
* Add an example of using it with `dyn` as #133003 enabled.
* Add an example of implementing it.
* Add links to Rust Reference for the mentioned concepts.
* Mention that its method should rarely be called.
* Replace parameter name `dst` with `dest` to avoids confusion between
  “DeSTination” and “Dynamically-Sized Type”.
* Various small corrections.
2025-03-07 19:46:23 -08:00
Matthias Krüger
f5a143f796 Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakis
Ergonomic ref counting

This is an experimental first version of ergonomic ref counting.

This first version implements most of the RFC but doesn't implement any of the optimizations. This was left for following iterations.

RFC: https://github.com/rust-lang/rfcs/pull/3680
Tracking issue: https://github.com/rust-lang/rust/issues/132290
Project goal: https://github.com/rust-lang/rust-project-goals/issues/107

r? ```@nikomatsakis```
2025-03-07 19:15:33 +01:00
Thalia Archibald
988eb19970 library: Use size_of from the prelude instead of imported
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the
prelude instead of importing or qualifying them.

These functions were added to all preludes in Rust 1.80.
2025-03-06 20:20:38 -08:00
Santiago Pastorino
a68db7e3a8 Add examples in stdlib demonstrating the use syntax 2025-03-06 17:58:34 -03:00
Santiago Pastorino
dcdfd551f0 Add UseCloned trait related code 2025-03-06 17:58:32 -03:00
Josh Triplett
865471f99b Implement CloneToUninit for ByteStr 2025-01-22 17:53:39 +02:00
Zachary S
e0c1c8bc50 Make CloneToUninit dyn-compatible 2024-11-12 15:08:41 -06:00
Boxy
0091b8ab2a update cfgs 2024-09-05 17:24:01 +01:00
Pavel Grigorenko
110c273f4f CloneToUninit: use a private specialization trait
and move implementation details into a submodule
2024-07-29 20:44:43 +03:00
Pavel Grigorenko
dbc13fb309 Sparkle some attributes over CloneToUninit stuff 2024-07-29 20:44:42 +03:00
Pavel Grigorenko
ec921db289 impl CloneToUninit for str and CStr 2024-07-29 20:33:11 +03:00
Ben Kimock
f4f57bfccb Make Clone::clone a lang item 2024-07-25 18:46:07 -04:00
hattizai
ada9fda7c3 chore: remove duplicate words 2024-07-02 11:25:31 +08:00
Kevin Reid
ec201b8650 Add core::clone::CloneToUninit.
This trait allows cloning DSTs, but is unsafe to implement and use
because it writes to possibly-uninitialized memory which must be of the
correct size, and must initialize that memory.

It is only implemented for `T: Clone` and `[T] where T: Clone`, but
additional implementations could be provided for specific `dyn Trait`
or custom-DST types.
2024-06-22 08:08:00 -07:00
Trevor Gross
88bcc79f31 Revert "Put basic impls for f16 and f128 behind cfg(not(bootstrap))"
This reverts commit 049a917535.

The resolution to <https://github.com/rust-lang/rust/issues/123282> is
that the `f16`/`f128` regression in the beta compiler was fixable
without a revert, so the commit adding `#[cfg(not(bootstrap))]` is no
longer useful (added in
<https://github.com/rust-lang/rust/pull/123390>).

Revert this commit because not having these basic impls bootstrap-gated
simplifies everything else that uses them.
2024-04-10 13:50:27 -04:00
Trevor Gross
049a917535 Put basic impls for f16 and f128 behind cfg(not(bootstrap))
We will lose `f16` and `f128` in the beta compiler after the revert for
<https://github.com/rust-lang/rust/issues/123282> lands. Change what was
added in <https://github.com/rust-lang/rust/pull/123085> to be behind
`#[cfg(not(bootstrap))]` to account for this.
2024-04-02 16:19:55 -04:00
Trevor Gross
d7d5fc9734 Add basic trait impls for f16 and f128
Split off part of <https://github.com/rust-lang/rust/pull/122470> so the
compiler doesn't ICE because it expects primitives to have some minimal
traits.

Fixes <https://github.com/rust-lang/rust/issues/123074>
2024-03-28 15:02:51 -04:00
surechen
40ae34194c remove redundant imports
detects redundant imports that can be eliminated.

for #117772 :

In order to facilitate review and modification, split the checking code and
removing redundant imports code into two PR.
2023-12-10 10:56:22 +08:00
Martin Nordholts
c6566a8037 Explain more clearly why fn() -> T can't be #[derive(Clone)] 2023-07-30 18:04:38 +02:00
Deadbeef
63e0ddbf1d core is now compilable 2023-04-16 07:20:26 +00:00
Deadbeef
76dbe29104 rm const traits in libcore 2023-04-16 06:49:27 +00:00
Eduardo Sánchez Muñoz
00e7b54d46 Make some trivial functions #[inline(always)] 2022-12-07 17:11:17 +01:00
Pietro Albini
6b2d3d5f3c update cfg(bootstrap)s 2022-07-01 15:48:23 +02:00
Michael Howell
7a93567005 docs: show Clone and Copy on () doc pages 2022-06-07 12:12:49 -07:00
Deadbeef
257f06587c Remove #[default..] and add #[const_trait] 2022-05-30 08:52:24 +00:00
Pietro Albini
181d28bb61 trivial cfg(bootstrap) changes 2022-04-05 23:18:40 +02:00
Deadbeef
1f3ee7f32e Rename ~const Drop to ~const Destruct 2022-03-21 17:04:03 +11:00
woppopo
662024478d Make some Clone impls const 2021-12-12 04:19:23 +09:00
bstrie
3024efff59 Update Copy/Clone documentation WRT arrays 2021-11-08 13:11:59 -05:00
Pietro Albini
b63ab8005a update cfg(bootstrap) 2021-10-23 21:55:57 -04:00
Fabian Wolff
79adda930f Ignore automatically derived impls of Clone and Debug in dead code analysis 2021-09-09 19:49:07 +02:00
qwerty01
2788c71dd4 Updates Clone docs for Copy comparison. 2021-06-10 11:28:26 -04:00
Ryan Levick
ee65416f0d Fix core tests 2021-03-03 11:22:49 +01:00
Ryan Levick
a6d926d80d Fix tests 2021-03-03 11:22:44 +01:00
Ryan Levick
f49ed7a6b7 Add tests and support two more noop methods 2021-03-03 11:22:17 +01:00
Ryan Levick
040735c110 First version of noop-lint 2021-03-03 11:22:16 +01:00
Denis Vasilik
3510c56887 Improve readability 2020-09-01 19:56:32 +02:00
Denis Vasilik
e7d074392e Use intra-doc links 2020-09-01 19:20:15 +02:00
mark
2c31b45ae8 mv std libs to library/ 2020-07-27 19:51:13 -05:00