49 Commits

Author SHA1 Message Date
Jeremy Smart
08b4641f50
add CloneFromCell and Cell::get_cloned 2025-10-01 18:47:09 -04:00
tiif
b919a5f518 Remove UnsizedConstParamTy trait and make it into an unstable impl 2025-09-15 08:57:22 +00:00
Evgenii Zheltonozhskii
ff9b1c1d28 Constify Eq, Ord, PartialOrd 2025-09-12 12:39:31 +03:00
ltdk
1c64d3e6d1 Constify conversion traits 2025-09-01 21:38:26 -04:00
Josh Triplett
5e203851f7 random: Provide a Distribution<T> trait
This will let people make calls like random(1..=6), and allows for
future expansion to non-uniform distributions, as well as
floating-point.

For now, this is only implemented for `RangeFull`, to get the interface
in place. Subsequent commits will implement it for other range types.
2025-07-11 10:21:34 -07:00
Oli Scherer
845d9ff963 Remove some unsized tuple impls now that we don't support unsizing tuples anymore 2025-07-02 14:17:54 +00:00
Guillaume Gomez
ad6503983d
Rollup merge of #136801 - sorairolake:add-random-for-tuple, r=joshtriplett
Implement `Random` for tuple

Implement `Random` for tuples of arity 12 or less. Each element is expected to implement `Random`.

I think it's OK to implement this trait for the following types:

- Primitive integer types and `bool`
- Arrays and tuples of the above values
- ~~`NonZero<T>`~~, `Saturating<T>` and `Wrapping<T>`

The necessity of this trait is debated (<https://github.com/rust-lang/rust/issues/130703#issuecomment-2508889577>), but if we decide to keep it in the future when the `random` module is stabilized, I think it would be useful to have this trait implemented for tuples.

Tracking issue: #130703

r? `@joboet`
2025-07-01 17:46:59 +02:00
David Wood
884d0e031a
library/compiler: add PointeeSized bounds
As core uses an extern type (`ptr::VTable`), the default `?Sized` to
`MetaSized` migration isn't sufficient, and some code that previously
accepted `VTable` needs relaxed to continue to accept extern types.

Similarly, the compiler uses many extern types in `rustc_codegen_llvm`
and in the `rustc_middle::ty::List` implementation (`OpaqueListContents`)
some bounds must be relaxed to continue to accept these types.

Unfortunately, due to the current inability to relax `Deref::Target`,
some of the bounds in the standard library are forced to be stricter than
they ideally would be.
2025-06-16 23:04:33 +00:00
Shun Sakai
07e8b2866d Implement Random for tuple
Implement `Random` for tuples of arity 12 or less. Each element is
expected to implement `Random`.
2025-04-14 00:56:06 +09:00
Scott McMurray
756670f40e Extend the chaining logic to slices too 2025-04-12 22:10:17 -07:00
Scott McMurray
7781346243 Stop using specialization for this
Uses `__`-named `doc(hidden)` methods instead.
2025-03-23 15:27:31 -07:00
Scott McMurray
35248c6830 Add chaining versions of lt/le/gt/ge and use them in tuple PartialOrd 2025-03-19 09:27:02 -07:00
Boxy
0091b8ab2a update cfgs 2024-09-05 17:24:01 +01:00
Michael Howell
6df0ccf49e rustdoc: clean up tuple <-> primitive conversion docs
This adds a minor missing feature to `fake_variadic`,
so that it can render `impl From<(T,)> for [T; 1]` correctly.
2024-08-24 14:06:57 -07:00
Nicholas Nethercote
84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
Boxy
d0c11bf6e3 Split part of adt_const_params into unsized_const_params 2024-07-17 11:01:29 +01:00
Matthias Krüger
1843dfd0d5
Rollup merge of #118307 - scottmcm:tuple-eq-simpler, r=joshtriplett
Remove an unneeded helper from the tuple library code

Thanks to https://github.com/rust-lang/rust/pull/107022, this is just what `==` does, so we don't need the helper here anymore.
2024-02-11 08:25:41 +01:00
Mark Rousskov
9a5034a20e Step all bootstrap cfgs forward
This also takes care of other bootstrap-related changes.
2024-02-08 07:44:34 -05:00
Ralf Jung
0df7810734 remove StructuralEq trait 2024-01-24 07:56:23 +01:00
Pietro Albini
f9f5840eb4
update cfg(bootstrap)s 2023-12-22 11:14:11 +01:00
bors
f651b436ce Auto merge of #117050 - c410-f3r:here-we-go-again, r=petrochenkov
[`RFC 3086`] Attempt to try to resolve blocking concerns

Implements what is described at https://github.com/rust-lang/rust/issues/83527#issuecomment-1744822345 to hopefully make some progress.

It is unknown if such approach is or isn't desired due to the lack of further feedback, as such, it is probably best to nominate this PR to the official entities.

`@rustbot` labels +I-compiler-nominated
2023-12-13 06:37:08 +00:00
Caio
0278505691 Attempt to try to resolve blocking concerns 2023-12-01 21:19:22 -03:00
DaniPopes
9ae3213fcb
Simplify Default for tuples 2023-11-27 06:11:25 +01:00
Scott McMurray
4b3f11523d Remove an unneeded helper from the tuple library code 2023-11-25 22:25:00 -08:00
Ralf Jung
7b7caae30e get rid of duplicate primitive_docs 2023-09-18 08:17:36 +02:00
Mark Rousskov
67b0cfc761 Flip cfg's for bootstrap bump 2023-07-12 21:38:55 -04:00
Michael Goulet
a9fcb524ff Impl ConstParamTy for tuples, make PartialStructuralEq a supertrait too 2023-06-01 18:21:42 +00:00
Mark Rousskov
4f9b394c8a Swap out CURRENT_RUSTC_VERSION to 1.71.0 2023-05-30 07:54:29 -04:00
Lukas Markeffsky
7e3b93417c clean up transmutes in core 2023-05-06 13:28:38 +02:00
Maybe Waffle
ad0388df5e Fixup "since" dates for array_tuple_conv feature 2023-05-04 18:25:21 +00:00
Maybe Waffle
04305c05d3 Remove [] <-> () From convertions
... with this convertions some tests fail :(
2023-05-02 14:37:40 +00:00
Maybe Waffle
4d04a062c8 Use metavar ${count(x)} instead of reimplementing it 2023-05-02 14:37:40 +00:00
Maybe Waffle
9fba2622a0 implement tuple<->array convertions via From 2023-05-02 14:37:40 +00:00
Deadbeef
76dbe29104 rm const traits in libcore 2023-04-16 06:49:27 +00:00
Scott McMurray
680e21687d Use partial_cmp to implement tuple lt/le/ge/gt 2023-02-16 23:59:13 -08:00
onestacked
f6658479a8 const Compare Tuples 2022-11-09 09:52:04 +01:00
onestacked
449326aaad Added const Default impls for Arrays and Tuples. 2022-09-23 17:53:59 +02:00
Mark Rousskov
154a09dd91 Adjust cfgs 2022-08-12 16:28:15 -04:00
Michael Howell
1169832f2f rustdoc: extend #[doc(tuple_variadic)] to fn pointers
The attribute is also renamed `fake_variadic`.
2022-07-17 16:32:06 -07:00
Pietro Albini
6b2d3d5f3c
update cfg(bootstrap)s 2022-07-01 15:48:23 +02:00
Michael Howell
36fb094d25 Add docs to maybe_tuple_doc! 2022-06-11 21:47:03 -07:00
Michael Howell
28bd1a4847 docs: make all the variadic impls use (T, ...) exactly 2022-06-11 10:32:39 -07:00
Michael Howell
9b31323b8f Fix incorrectly spelled "variadic" 2022-06-11 09:54:20 -07:00
Michael Howell
6950f144cf rustdoc: show tuple impls as impl Trait for (T, ...)
This commit adds a new unstable attribute, `#[doc(tuple_varadic)]`, that
shows a 1-tuple as `(T, ...)` instead of just `(T,)`, and links to a section
in the tuple primitive docs that talks about these.
2022-06-08 19:26:51 -07:00
Michael Howell
9940ed0805 docs: clean up trait docs for tuples 2022-06-07 11:24:57 -07:00
Caio
23bf977758 Implement tuples using recursion 2022-04-12 16:23:36 -03:00
Caio
e946aa3a74 Left overs of #95761 2022-04-08 10:30:24 -03:00
Caio
3191d27f48 Kickstart the inner usage of macro_metavar_expr 2022-04-07 08:13:41 -03:00
mark
2c31b45ae8 mv std libs to library/ 2020-07-27 19:51:13 -05:00