Commit Graph

176 Commits

Author SHA1 Message Date
León Orell Valerian Liehr
b9fd2bccfa Rollup merge of #143829 - a1phyr:trim_borrowed_buf, r=ChrisDenton
Trim `BorrowedCursor` API

This PR removes some method from the unstable `BorrowedCursor` type. A rational for each change can be found in the message of each commit.

I don't think that an ACP is required for this, please tell me if it is not the case.

Cc rust-lang/rust#78485 rust-lang/rust#117693
2025-07-17 03:58:32 +02:00
Samuel Tardieu
096a66d8d8 Rollup merge of #143738 - rocurley:float_tests_refactor_2, r=tgross35
Move several float tests to floats/mod.rs

This PR moves several tests to `floats/mod.rs`, as discussed in https://github.com/rust-lang/rust/issues/141726. The tests moved are:

- `test_num_f*`
- `test_infinity`
- `test_neg_infinity`
- `test_zero`
- `test_neg_zero`
- `test_one`
- `test_is_nan`
- `test_is_infinite`
- `test_is_finite`
- `test_is_normal`
- `test_classify`

Each test is its own commit, so it may be easiest to review each commit individually.

r? tgross35
2025-07-16 17:06:40 +02:00
bors
7f2065a4ba Auto merge of #142885 - a1phyr:borrowed_cursor_to_buf, r=Mark-Simulacrum
core: Add `BorrowedCursor::with_unfilled_buf`

Implementation of https://github.com/rust-lang/libs-team/issues/367.

This mainly adds `BorrowedCursor::with_unfilled_buf`, with enables using the unfilled part of a cursor as a `BorrowedBuf`.

Note that unlike the ACP, `BorrowedCursor::unfilled_buf` was moved to a `From` conversion. This is more consistent with other ways of creating a `BorrowedBuf` and hides a bit this conversion that requires unsafe code to be used correctly.

Cc rust-lang/rust#78485 rust-lang/rust#117693
2025-07-14 23:45:18 +00:00
bors
e9182f195b Auto merge of #143461 - folkertdev:cfg-select-builtin-macro, r=petrochenkov
make `cfg_select` a builtin macro

tracking issue: https://github.com/rust-lang/rust/issues/115585

This parses mostly the same as the `macro cfg_select` version, except:

1. wrapping in double brackets is no longer supported (or needed): `cfg_select {{ /* ... */ }}` is now rejected.
2. in an expression context, the rhs is no longer wrapped in a block, so that this now works:
  ```rust
  fn main() {
      println!(cfg_select! {
          unix => { "foo" }
          _ => { "bar" }
      });
  }
  ```
3. a single wildcard rule is now supported: `cfg_select { _ => 1 }` now works

I've also added an error if none of the rules evaluate to true, and warnings for any arms that follow the `_` wildcard rule.

cc `@traviscross` if I'm missing any feature that should/should not be included
r? `@petrochenkov` for the macro logic details
2025-07-13 18:34:13 +00:00
Folkert de Vries
3689b80b75 make cfg_select a builtin macro 2025-07-13 14:34:40 +02:00
Roger Curley
79769f2d5b Consolidate classify tests 2025-07-11 10:41:24 -04:00
Roger Curley
d2c1900086 Consolidate is_normal tests 2025-07-11 10:41:24 -04:00
Roger Curley
7dd2811b2a Consolidate is_finite tests 2025-07-11 10:41:24 -04:00
Roger Curley
e3d83679cb Consolidate is_infinite tests 2025-07-11 10:41:24 -04:00
Roger Curley
1b8904c0c5 Consolidate is_nan 2025-07-11 10:41:23 -04:00
Roger Curley
868020e059 Consolidate one tests 2025-07-11 10:31:26 -04:00
Roger Curley
fc01eed024 Consolidate negative zero tests 2025-07-11 10:31:25 -04:00
Roger Curley
0c01322ec6 Consolidate zero tests 2025-07-11 10:31:25 -04:00
Roger Curley
c2e6b39474 Consolidate neg_infinity tests 2025-07-11 10:31:25 -04:00
Roger Curley
c5e67b48ef Consolidate test_num tests 2025-07-11 10:31:25 -04:00
Roger Curley
cfb66e5e88 Consolidate infinity tests 2025-07-11 10:31:25 -04: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
Roger Curley
bc2001f158 Refactor nan tests 2025-07-09 23:24:47 -04: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
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
klensy
c76d032f01 setup CI and tidy to use typos for spellchecking and fix few typos 2025-07-03 10:51:06 +03:00
Benoît du Garreau
136d24fd7f core: Add BorrowedCursor::with_unfilled_buf
Implementation of https://github.com/rust-lang/libs-team/issues/367.

This mainly adds `BorrowedCursor::with_unfilled_buf`, with enables using
the unfilled part of a cursor as a `BorrowedBuf`.

Note that unlike the ACP, `BorrowedCursor::unfilled_buf` was moved to a
`From` conversion. This is more consistent with other ways of creating a
`BorrowedBuf` and hides a bit this conversion that requires unsafe code
to be used correctly.
2025-07-01 14:03:54 +02:00
bors
e61dd437f3 Auto merge of #143074 - compiler-errors:rollup-cv64hdh, r=compiler-errors
Rollup of 18 pull requests

Successful merges:

 - rust-lang/rust#137843 (make RefCell unstably const)
 - rust-lang/rust#140942 (const-eval: allow constants to refer to mutable/external memory, but reject such constants as patterns)
 - rust-lang/rust#142549 (small iter.intersperse.fold() optimization)
 - rust-lang/rust#142637 (Remove some glob imports from the type system)
 - rust-lang/rust#142647 ([perf] Compute hard errors without diagnostics in impl_intersection_has_impossible_obligation)
 - rust-lang/rust#142700 (Remove incorrect comments in `Weak`)
 - rust-lang/rust#142927 (Add note to `find_const_ty_from_env`)
 - rust-lang/rust#142967 (Fix RwLock::try_write documentation for WouldBlock condition)
 - rust-lang/rust#142986 (Port `#[export_name]` to the new attribute parsing infrastructure)
 - rust-lang/rust#143001 (Rename run always )
 - rust-lang/rust#143010 (Update `browser-ui-test` version to `0.20.7`)
 - rust-lang/rust#143015 (Add `sym::macro_pin` diagnostic item for `core::pin::pin!()`)
 - rust-lang/rust#143033 (Expand const-stabilized API links in relnotes)
 - rust-lang/rust#143041 (Remove cache for citool)
 - rust-lang/rust#143056 (Move an ACE test out of the GCI directory)
 - rust-lang/rust#143059 (Fix 1.88 relnotes)
 - rust-lang/rust#143067 (Tracking issue number for `iter_macro`)
 - rust-lang/rust#143073 (Fix some fixmes that were waiting for let chains)

Failed merges:

 - rust-lang/rust#143020 (codegen_fn_attrs: make comment more precise)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-27 00:44:20 +00:00
Daniel Bloom
1f1000f4b8 make RefCell unstably const 2025-06-25 17:06:49 -07:00
Folkert de Vries
1dfc8406dc make tidy-alphabetical use a natural sort 2025-06-25 22:52:38 +02:00
Trevor Gross
52758b7329 Rollup merge of #142668 - hkBst:less-static-mut, r=tgross35
vec_deque/fmt/vec tests: remove static mut

More rust-lang/rust#125035.

r? ```@tgross35```
2025-06-20 02:50:39 -04:00
LimpSquid
19352e9d93 Add methods for converting bool to Result<(), E> 2025-06-19 23:20:06 +02:00
Marijn Schouten
9c22768183 atomic tests: remove static mut 2025-06-19 12:08:24 +00:00
Mara Bos
5b763fb1b7 Add test for new format_args!() temporary lifetimes. 2025-06-18 10:20:20 +02:00
Jakub Beránek
d9c83bb033 Rollup merge of #142373 - m-ou-se:debug-for-location, r=tgross35
Fix Debug for Location

Fixes https://github.com/rust-lang/rust/issues/142279
2025-06-16 14:31:11 +02:00
Mara Bos
5ac1cd9c7d Test Debug for Location. 2025-06-16 03:14:44 +00:00
Matthias Krüger
4cf4473b85 Rollup merge of #142243 - RalfJung:float-test-dedup, r=tgross35
float tests: deduplicate min, max, and rounding tests

Part of https://github.com/rust-lang/rust/issues/141726

Best reviewed commit-by-commit.

- Use `assert_biteq!` in the `mod.rs` tests. This requires some trickery to make shadowing macros with imports work.
- The min, max, minimum, maximum tests in `tests/floats/f*.rs` are entirely subsumed by what we already have in `tests/float/mod.rs`, so I just removed them.
- The rounding tests (floor etc) in `f*.rs` had more test points, so I copied them over. They didn't have `0.5` and `-0.5` though which seem like interesting points in particular regarding the sign of the resulting zero if that's what it sounds to, and they didn't max min/max/inf/nan tests, so this was really a merger of both tests.

r? ``@tgross35``
2025-06-14 11:27:11 +02:00
Matthias Krüger
db23a76217 Rollup merge of #141811 - mejrs:bye_locals, r=compiler-errors
Unimplement unsized_locals

Implements https://github.com/rust-lang/compiler-team/issues/630

Tracking issue here: https://github.com/rust-lang/rust/issues/111942

Note that this just removes the feature, not the implementation, and does not touch `unsized_fn_params`. This is because it is required to support `Box<dyn FnOnce()>: FnOnce()`.

There may be more that should be removed (possibly in follow up prs)
- the `forget_unsized` function and `forget` intrinsic.
- the `unsized_locals` test directory; I've just fixed up the tests for now
- various codegen support for unsized values and allocas

cc ``@JakobDegen`` ``@oli-obk`` ``@Noratrieb`` ``@programmerjake`` ``@bjorn3``

``@rustbot`` label F-unsized_locals

Fixes rust-lang/rust#79409
2025-06-14 11:27:10 +02:00
Ralf Jung
25ec235b86 tweak runtime/const macro management 2025-06-13 10:22:56 +02:00
mejrs
c0e02e26b3 Unimplement unsized_locals 2025-06-13 01:16:36 +02:00
Tamir Duberstein
a82062055a Delegate <CStr as Debug> to ByteStr
This allows UTF-8 characters to be printed without escapes, rather than
just ASCII.
2025-06-12 12:53:14 -04:00
bors
14346303d7 Auto merge of #136594 - pascaldekloe:fmt-int128, r=tgross35
Faster fmt::Display of 128-bit integers, without unsafe pointer

In followup of #135265, hereby the 128-bit part.

* Batches per 16 instead of 19 digits
* Buffer access as array insteaf of unsafe pointer
* Added test coverage for i128 and u128

r? tgross35 ChrisDenton
2025-06-12 01:02:55 +00:00
Shun Sakai
199b808870 feat: Add bit_width for unsigned integer types 2025-06-11 11:15:37 +09:00
Pascal S. de Kloe
e9ebe25c66 format integer tests regrouped, min/max coverage and 128-bit coverage 2025-06-10 17:46:35 +02:00
bors
c6768de2d6 Auto merge of #138062 - LorrensP-2158466:miri-enable-float-nondet, r=RalfJung
Enable Non-determinism of float operations in Miri and change std tests

Links to [#4208](https://github.com/rust-lang/miri/issues/4208) and [#3555](https://github.com/rust-lang/miri/issues/3555) in Miri.

Non-determinism of floating point operations was disabled in rust-lang/rust#137594 because it breaks the tests and doc-tests in core/coretests and std. This PR enables some of them.

This pr includes the following changes:

- Enables the float non-determinism but with a lower relative error of 4ULP instead of 16ULP
- These operations now have a fixed output based on the C23 standard, except the pow operations, this is tracked in [#4286](https://github.com/rust-lang/miri/issues/4286#issue-3010677983)
- Changes tests that made incorrect assumptions about the operations, not to make that assumption anymore (from `assert_eq!` to `assert_approx_eq!`.
- Changed the doctests of the stdlib of these operations to compare against fixed constants instead of `f*::EPSILON`, which now succeed with Miri and `-Zmiri-many-seeds`
- Added a constant `APPROX_DELTA` in `std/tests/floats/f32.rs` which is used for approximation tests, but with a different value when run in Miri. This is to make these tests succeed.
- Added tests in the float tests of Miri to test the C23 behaviour.

Fixes https://github.com/rust-lang/miri/issues/4208
2025-06-09 21:21:58 +00:00
Ralf Jung
1b6bb4566d float midpoint tests: add missing NAN cases 2025-06-09 14:24:24 +02:00
Ralf Jung
2766b77f1e make the default float comparison tolerance type-dependent 2025-06-09 14:24:24 +02:00
Ralf Jung
79cb013b55 float tests: deduplicate min, max, and rounding tests 2025-06-09 14:24:12 +02:00
Ralf Jung
20cf8ca3f7 float tests: use assert_biteq in more places 2025-06-09 14:17:28 +02:00
Marijn Schouten
a87cd55f8e Make NonZero<char> possible 2025-06-07 11:40:49 +00:00
Jacob Pratt
0d2bf86284 Rollup merge of #141857 - RalfJung:coretests-floats, r=tgross35
coretests: move float tests from num to floats module and use a more flexible macro to generate them

This makes some progress on https://github.com/rust-lang/rust/issues/141726 by moving the float tests in `num` to `floats` and using a newer, more flexible macro to generate them. We also newly run these tests on f16 and f128 in const, and at runtime in Miri and for hosts where that works well enough.

I didn't yet deduplicate any tests or port the existing `floats::f*` tests to the macro, that can happen in a future PR.

try-job: x86_64-gnu-aux
2025-06-07 07:05:46 +02:00
LorrensP-2158466
00452bd783 change tests to use fixed constants to let them pass with miri 2025-06-05 16:22:13 +02:00