Commit Graph

9393 Commits

Author SHA1 Message Date
Oli Scherer
e681d1a973 constify From and Into 2025-07-11 08:30:47 +00:00
Matthias Krüger
2ffaa1ec0d Rollup merge of #143611 - GrigorenkoPV:ParseIntError, r=tgross35
Mention more APIs in `ParseIntError` docs

Fixes rust-lang/rust#143602

r? `@lolbinarycat`

`@rustbot` label +A-docs
2025-07-11 07:35:20 +02:00
bors
855e0fe46e Auto merge of #142911 - mejrs:unsized, r=compiler-errors
Remove support for dynamic allocas

Followup to rust-lang/rust#141811
2025-07-11 05:27:32 +00:00
Matthias Krüger
b4089bf417 Rollup merge of #143640 - oli-obk:const-fn-traits, r=compiler-errors
Constify `Fn*` traits

r? `@compiler-errors` `@fee1-dead`

this should unlock a few things. A few `const_closures` tests have broken even more than before, but that feature is marked as incomplete anyway

cc rust-lang/rust#67792
2025-07-10 20:28:49 +02:00
Matthias Krüger
bdf1941c12 Rollup merge of #143652 - moulins:doc-unsize-trait-upcasting, r=compiler-errors
docs: document trait upcasting rules in `Unsize` trait

The trait upcasting feature stabilized in 1.86 added new `Unsize` implementation, but this wasn't reflected in the trait's documentation.
2025-07-10 15:19:30 +02:00
Matthias Krüger
a0c7887199 Rollup merge of #136906 - chenyukang:yukang-fix-136741-closure-body, r=oli-obk
Add checking for unnecessary delims in closure body

Fixes #136741
2025-07-10 15:19:29 +02:00
bors
119574f835 Auto merge of #143721 - tgross35:rollup-sjdfp6r, r=tgross35
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#141996 (Fix `proc_macro::Ident`'s handling of `$crate`)
 - rust-lang/rust#142950 (mbe: Rework diagnostics for metavariable expressions)
 - rust-lang/rust#143011 (Make lint `ambiguous_glob_imports` deny-by-default and report-in-deps)
 - rust-lang/rust#143265 (Mention as_chunks in the docs for chunks)
 - rust-lang/rust#143270 (tests/codegen/enum/enum-match.rs: accept negative range attribute)
 - rust-lang/rust#143298 (`tests/ui`: A New Order [23/N])
 - rust-lang/rust#143396 (Move NaN tests to floats/mod.rs)
 - rust-lang/rust#143398 (tidy: add support for `--extra-checks=auto:` feature)
 - rust-lang/rust#143644 (Add triagebot stdarch mention ping)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-10 10:08:08 +00:00
Trevor Gross
ebd3940454 Rollup merge of #143265 - scottmcm:mention-as-chunks, r=ibraheemdev
Mention as_chunks in the docs for chunks

and `as_rchunks_mut` from `rchunks_exact_mut`, and such.

As suggested in https://github.com/rust-lang/rust/issues/76354#issuecomment-3015376438 (but does not close that issue).
2025-07-10 03:23:54 -04:00
yukang
93db9e7ee0 Remove uncessary parens in closure body with unused lint 2025-07-10 09:25:56 +08:00
Josh Triplett
4c947984d6 random: Add comment on RandomSource::fill_bytes about multiple calls
This allows efficient implementations for random sources that generate a
word at a time.
2025-07-09 13:42:18 -07:00
Oli Scherer
486ffda9dc Add opaque TypeId handles for CTFE 2025-07-09 16:37:11 +00:00
Benoît du Garreau
65df66831f core: Change BorrowedCursor::written's origin
This enable removing the `start` field, so `BorrowedCursor` fits in a
single register. Because `written` is almost always used in difference
with another call, this changes nothing else in practice.
2025-07-09 18:11:27 +02:00
Benoît du Garreau
34555f1b0b core: Remove BorrowedCursor::uninit_mut
I assume that this method was there for completeness, but there is
hardly any useful use of it: the buffer it gave was not always connected
to the start of the cursor and its use required `unsafe` anyway to mark
the bytes as initialized.
2025-07-09 18:11:26 +02:00
Benoît du Garreau
803b4d2622 core: Remove BorrowedCursor::init_ref method
This method was not really useful: at no point one would only need to
read the initialized part of the cursor without mutating it.
2025-07-09 18:11:26 +02:00
Trevor Gross
0d99b5585b Rollup merge of #143426 - hkBst:clippy-fix-indent-1, r=jhpratt
clippy fix: indentation

Fixes indentation of markdown comments.
2025-07-08 22:50:27 -05:00
Moulins
c9ff1609d4 docs: document trait upcasting rules in Unsize trait 2025-07-08 23:35:15 +02:00
Oli Scherer
b1d45f6b3e Remove const_eval_select hack 2025-07-08 15:49:00 +00:00
Oli Scherer
543c860ea6 Constify Fn* traits 2025-07-08 14:36:43 +00:00
bors
f838cbc06d Auto merge of #134628 - estebank:const-default, r=oli-obk
Make `Default` const and add some `const Default` impls

Full list of `impl const Default` types:

- ()
- bool
- char
- std::ascii::Char
- usize
- u8
- u16
- u32
- u64
- u128
- i8
- i16
- i32
- i64
- i128
- f16
- f32
- f64
- f128
- std::marker::PhantomData<T>
- Option<T>
- std::iter::Empty<T>
- std::ptr::Alignment
- &[T]
- &mut [T]
- &str
- &mut str
- String
- Vec<T>
2025-07-08 14:04:40 +00:00
Marijn Schouten
ca4a712b59 clippy fix: markdown indentation for indented items after line break 2025-07-08 11:48:15 +00:00
Marijn Schouten
f96d5d9602 collect.rs: remove empty line after doc comment 2025-07-08 11:48:15 +00:00
Marijn Schouten
004478a829 int_log10.rs: change top level doc comments to outer 2025-07-08 11:48:15 +00:00
bors
040e2f8b9f Auto merge of #143540 - yotamofek:pr/library/simplify-num-fmt, r=tgross35
Simplify num formatting helpers

Noticed `ilog10` was being open-coded when looking at this diff: 85d6768f4c..76d9775912 (diff-6be9b44b52d946ccac652ddb7c98146a01b22ea0fc5737bc10db245a24796a45)
That, and two other small cleanups 😁

(should probably go through perf just to make sure it doesn't regress formatting)
2025-07-08 10:54:22 +00:00
Matthias Krüger
d41f046de5 Rollup merge of #142098 - GuillaumeGomez:int_format_into, r=Amanieu
Implement `int_format_into` feature

I took over rust-lang/rust#138338 with `@madhav-madhusoodanan's` approval.

Since https://github.com/rust-lang/rust/pull/136264, a lot of changes happened so I made use of them to reduce the number of changes.

ACP approval: https://github.com/rust-lang/libs-team/issues/546#issuecomment-2707244569

## Associated Issue
- https://github.com/rust-lang/rust/issues/138215

r? `@hanna-kruppe`
2025-07-08 03:09:56 +02:00
Esteban Küber
c3301503b9 Make Default const and add some const Default impls
Full list of `impl const Default` types:

- ()
- bool
- char
- Cell
- std::ascii::Char
- usize
- u8
- u16
- u32
- u64
- u128
- i8
- i16
- i32
- i64
- i128
- f16
- f32
- f64
- f128
- std::marker::PhantomData<T>
- Option<T>
- std::iter::Empty<T>
- std::ptr::Alignment
- &[T]
- &mut [T]
- &str
- &mut str
- String
- Vec<T>
2025-07-07 22:09:37 +00:00
Pavel Grigorenko
ae5cb5f66d Mention more APIs in ParseIntError docs 2025-07-08 01:05:14 +03:00
mejrs
49421d1fa3 Remove support for dynamic allocas 2025-07-07 23:04:06 +02:00
许杰友 Jieyou Xu (Joe)
074256988f Rollup merge of #143130 - xizheyin:142966, r=ibraheemdev
doc(std): clarify `NonZero<T>` usage limitation in doc comment

Closes rust-lang/rust#142966

This PR clarifies `NonZero<T>` usage limitation in doc comment and fixes a typo.

r? libs
2025-07-07 19:45:38 +08:00
xizheyin
22342b0959 doc(std): clarify NonZero<T> usage limitation in doc comment
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-07 14:47:35 +08:00
Jacob Pratt
2992997f6f Rollup merge of #143552 - nagisa:makes-ceil-char-boundary-go-zoom, r=jhpratt
lib: more eagerly return `self.len()` from `ceil_char_boundary`

There is no reason to go through the complicated branch as it would
always return `self.len()` in this case. Also helps debug code somewhat
and I guess might make optimizations easier (although I haven't really a
sample to demonstrate this.)

ref. https://github.com/rust-lang/rust/issues/93743
Suggested by `@chrisduerr`
2025-07-07 03:26:09 +02:00
Jacob Pratt
11d8667f21 Rollup merge of #143359 - clubby789:fallback-2024-doc, r=ibraheemdev
Link to 2024 edition page for `!` fallback changes

Closes rust-lang/rust#143207
2025-07-07 03:26:07 +02:00
Jacob Pratt
00c67d1a12 Rollup merge of #143236 - nxsaken:mixed_integer_ops_unsigned_sub, r=ibraheemdev
Stabilize `mixed_integer_ops_unsigned_sub`

Closes rust-lang/rust#126043.
2025-07-07 03:26:06 +02:00
Simonas Kazlauskas
49806a5486 lib: more eagerly return self.len() from ceil_char_boundary
There is no reason to go through the complicated branch as it would
always return `self.len()` in this case. Also helps debug code somewhat
and I guess might make optimizations easier (although I haven't really a
sample to demonstrate this.)

ref. #93743
Suggested by @chrisduerr
2025-07-07 02:14:58 +03:00
Yotam Ofek
09cf02c8af Simplify num formatting helpers 2025-07-06 20:26:04 +00:00
Matthias Krüger
6fb00b1514 Rollup merge of #143477 - folkertdev:use-is-multiple-of, r=joshtriplett
use `is_multiple_of` and `div_ceil`

In tricky logic, these functions are much more informative than the manual implementations. They also catch subtle bugs:

- the manual `is_multiple_of` often does not handle division by zero
- manual `div_ceil` often does not consider overflow

The transformation is free for `is_multiple_of` if the divisor is compile-time known to be non-zero. For `div_ceil` there is a small cost to considering overflow. Here is some assembly https://godbolt.org/z/5zP8KaE1d.
2025-07-06 10:03:23 +02:00
Ben Kimock
7245febecd Rollup merge of #143445 - folkertdev:va-list-intrinsics, r=RalfJung
move `va_copy`, `va_arg` and `va_end` to `core::intrinsics`

some questions:

- should these functions be `pub`?
- is a separate module justified?

r? `@RalfJung`
2025-07-05 12:32:53 -04:00
Folkert de Vries
ed3711ea29 use div_ceil instead of manual logic 2025-07-05 10:55:42 +02:00
Folkert de Vries
226b0fbe11 use is_multiple_of instead of manual modulo 2025-07-05 10:55:35 +02:00
Folkert de Vries
4ae22fba5b move the va_copy, va_arg and va_end to core::intrinsics 2025-07-05 09:18:49 +02:00
Jubilee
3b522384e4 Rollup merge of #143040 - SciMind2460:patch-1, r=workingjubilee
Add `const Rem`
2025-07-04 23:26:20 -07:00
Kurt Heiritz (pseudo)
2d1aa58225 Make Rem const for floats 2025-07-04 16:40:45 -07:00
Matthias Krüger
18b374d5a7 Rollup merge of #143308 - compiler-errors:no-pointer-like, r=oli-obk
Remove `PointerLike` trait

r? oli-obk
2025-07-04 16:22:35 +02:00
Marijn Schouten
1a1b52acbf clippy fix: indentation 2025-07-04 11:52:17 +00:00
Marijn Schouten
b315e9a2ce clippy fix: rely on autoderef 2025-07-04 11:35:00 +00:00
Jacob Pratt
e4e26d2acb Rollup merge of #143395 - Urgau:llvm-fallback-minimum-maximum, r=tgross35
Always use the pure Rust fallback instead of `llvm.{maximum,minimum}`

While https://github.com/llvm/llvm-project/pull/142170 was merged, it was reverted and next attempt (https://github.com/llvm/llvm-project/pull/140193) at fixing the LLVM implementation seems to have stall, so let's reverted back to pure Rust with the LLVM codegen.

cc [#t-compiler/llvm > &#96;llvm.minimum&#96;/&#96;llvm.maximum&#96; issues @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/187780-t-compiler.2Fllvm/topic/.60llvm.2Eminimum.60.2F.60llvm.2Emaximum.60.20issues/near/527044712)

Fixes https://github.com/rust-lang/rust/issues/141087
r? `@tgross35`
2025-07-04 05:47:29 +02:00
Jacob Pratt
e55514bbbe Rollup merge of #143378 - hkBst:clippy-fix-6, r=tgross35
simplify receivers for some array method calls
2025-07-04 05:47:26 +02:00
Jacob Pratt
5adf3ef339 Rollup merge of #143370 - hkBst:clippy-fix-4, r=tgross35
remove redundant #[must_use]

Fixes these clippy warnings:
```
warning: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`
    --> library/core/src/cmp.rs:1456:5
     |
1456 |     fn __chaining_lt(&self, other: &Rhs) -> ControlFlow<bool> {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: either add some descriptive message or remove the attribute
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_must_use
     = note: `-D clippy::double-must-use` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(clippy::double_must_use)]`

warning: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`
    --> library/core/src/cmp.rs:1465:5
     |
1465 |     fn __chaining_le(&self, other: &Rhs) -> ControlFlow<bool> {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: either add some descriptive message or remove the attribute
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_must_use

warning: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`
    --> library/core/src/cmp.rs:1474:5
     |
1474 |     fn __chaining_gt(&self, other: &Rhs) -> ControlFlow<bool> {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: either add some descriptive message or remove the attribute
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_must_use

warning: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`
    --> library/core/src/cmp.rs:1483:5
     |
1483 |     fn __chaining_ge(&self, other: &Rhs) -> ControlFlow<bool> {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: either add some descriptive message or remove the attribute
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_must_use
```
2025-07-04 05:47:26 +02:00
Jacob Pratt
7c68a8db3e Rollup merge of #143356 - hkBst:clippy-fix-2, r=scottmcm
use unsigned_abs instead of `abs` on signed int to silence clippy

Use `unsigned_abs` instead of `abs` on signed int to silence clippy. Alternatively we could allow the lint, but if codegen is not affected, then this seems preferable.
2025-07-04 05:47:25 +02:00
Jacob Pratt
e080bc8751 Rollup merge of #142749 - LimpSquid:bool_to_result, r=scottmcm
Add methods for converting bool to `Result<(), E>`

## Tracking Issue

https://github.com/rust-lang/rust/issues/142748

## ACP

https://github.com/rust-lang/libs-team/issues/606
2025-07-04 05:47:22 +02:00
Michael Goulet
e2e3f5809b Remove PointerLike trait 2025-07-03 20:03:49 +00:00