Commit graph

6959 commits

Author SHA1 Message Date
Matthias Krüger f2c287f744
Rollup merge of #127134 - tgross35:typeid-debug, r=Nilstrieb
Print `TypeId` as a `u128` for `Debug`

Since <https://github.com/rust-lang/rust/pull/121358>, `TypeId` is represented as a `(u64, u64)`. This also made the debug implementation a lot larger, which is especially apparent with pretty formatting.

Change this to convert the inner value back to a `u128` and then print as a tuple struct to make this less noisy.

Current:

    TypeId { t: (1403077013027291752, 4518903163082958039) }
    TypeId {
        t: (
            1403077013027291752,
            4518903163082958039,
        ),
    }

New:

    TypeId(25882202575019293479932656973818029271)
    TypeId(
        25882202575019293479932656973818029271,
    )
2024-06-30 10:39:48 +02:00
Matthias Krüger fe1f83ccd7
Rollup merge of #126906 - GrigorenkoPV:fixme-split_at_first, r=Mark-Simulacrum
Small fixme in core now that split_first has no codegen issues

https://github.com/rust-lang/rust/issues/109328#issuecomment-1677366881

BTW, I have a crate implementing exactly this kind of an iterator: https://github.com/GrigorenkoPV/head-tail-iter and I was wondering if it would be worthwhile to try and make an ACP for it to get it included in std (or maybe itertools). My only doubt is that it kinda incentives writing O(n^2) algorithms and is not the hard to replace with a `while let` loop (just as in this PR).
2024-06-30 10:39:47 +02:00
Matthias Krüger b2d46036c5
Rollup merge of #126705 - safinaskar:panic, r=Mark-Simulacrum
Updated docs on `#[panic_handler]` in `library/core/src/lib.rs`
2024-06-30 10:39:46 +02:00
bors 716752ebe6 Auto merge of #127133 - matthiaskrgr:rollup-jxkp3yf, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #123237 (Various rustc_codegen_ssa cleanups)
 - #126960 (Improve error message in tidy)
 - #127002 (Implement `x perf` as a separate tool)
 - #127081 (Add a run-make test that LLD is not being used by default on the x64 beta/stable channel)
 - #127106 (Improve unsafe extern blocks diagnostics)
 - #127110 (Fix a error suggestion for E0121 when using placeholder _ as return types on function signature.)
 - #127114 (fix: prefer `(*p).clone` to `p.clone` if the `p` is a raw pointer)
 - #127118 (Show `used attribute`'s kind for user when find it isn't applied to a `static` variable.)
 - #127122 (Remove uneccessary condition in `div_ceil`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-30 02:20:01 +00:00
Trevor Gross 682e7c1174 Print TypeId as a u128 for Debug
Since <https://github.com/rust-lang/rust/pull/121358>, `TypeId` is
represented as a `(u64, u64)`. This also made the debug implementation a
lot larger, which is especially apparent with pretty formatting.

Make this less noisy by converting the inner value back to a `u128` then
printing as a tuple struct.

Current:

    TypeId { t: (1403077013027291752, 4518903163082958039) }
    TypeId {
        t: (
            1403077013027291752,
            4518903163082958039,
        ),
    }

New:

    TypeId(25882202575019293479932656973818029271)
    TypeId(
        25882202575019293479932656973818029271,
    )
2024-06-29 16:39:48 -04:00
Matthias Krüger c79e08d3a6
Rollup merge of #127122 - TDecking:div_ceil, r=Nilstrieb
Remove uneccessary condition in `div_ceil`

Previously, `div_ceil` for unsigned integers had a `rhs > 0` for rounding. That condition however is always fulfilled, since `rhs == 0` would mean a division by zero earlier.
2024-06-29 22:10:59 +02:00
bors ba1d7f4a08 Auto merge of #120639 - fee1-dead-contrib:new-effects-desugaring, r=oli-obk
Implement new effects desugaring

cc `@rust-lang/project-const-traits.` Will write down notes once I have finished.

* [x] See if we want `T: Tr` to desugar into `T: Tr, T::Effects: Compat<true>`
* [x] Fix ICEs on `type Assoc: ~const Tr` and `type Assoc<T: ~const Tr>`
* [ ] add types and traits to minicore test
* [ ] update rustc-dev-guide

Fixes #119717
Fixes #123664
Fixes #124857
Fixes #126148
2024-06-29 20:08:10 +00:00
Tobias Decking 5dece2b2bd
Remove uneccessary condition in div_ceil 2024-06-29 15:08:59 +02:00
Askar Safin 28ba5e4124 Updated docs on #[panic_handler] in library/core/src/lib.rs 2024-06-29 15:59:52 +03:00
Guillaume Gomez 0886faaeea
Rollup merge of #127073 - Sky9x:unnecessary-seqcst, r=Nilstrieb
Remove unnecessary SeqCst in `impl fmt::Pointer for AtomicPtr`

Unnecessarily strict ordering.
2024-06-29 14:07:22 +02:00
Guillaume Gomez e9594b504d
Rollup merge of #127072 - Sky9x:docs-includes-vs-does-include, r=scottmcm
docs: say "includes" instead of "does include"

Provides more visual difference between the negative ("does not include") and the positive ("includes"). Both phrases have the same meaning.
2024-06-29 14:07:22 +02:00
Matthias Krüger 69996b5ac7
Rollup merge of #127071 - Sky9x:remove-ptr-to-from-bits, r=scottmcm
Remove (deprecated & unstable) {to,from}_bits pointer methods

These unstable methods have been deprecated for more than a year (since #95583). Remove them.

See https://github.com/rust-lang/rust/issues/91126#issuecomment-1835796457 and https://github.com/rust-lang/rust/pull/110441/files#r1169574509.

Closes #91126.

r? `@scottmcm`
2024-06-28 22:04:20 +02:00
Matthias Krüger 6499b9c340
Rollup merge of #127070 - Sky9x:unit-const-param-ty, r=BoxyUwU
add () to the marker_impls macro for ConstParamTy

Seems to have escaped bootstrap
2024-06-28 22:04:19 +02:00
Matthias Krüger afde8485df
Rollup merge of #127055 - shepmaster:hash-finish-must-use, r=dtolnay
Mark Hasher::finish as #[must_use]
2024-06-28 22:04:18 +02:00
Deadbeef 65a0bee0b7 address review comments 2024-06-28 15:44:20 +00:00
Deadbeef 0a2330630d general fixups and turn TODOs into FIXMEs 2024-06-28 10:57:35 +00:00
Deadbeef c7d27a15d0 Implement Min trait in new solver 2024-06-28 10:57:35 +00:00
Deadbeef 72e8244e64 implement new effects desugaring 2024-06-28 10:57:35 +00:00
Matthias Krüger c4d0c08925
Rollup merge of #126956 - joboet:fmt_no_extern_ty, r=RalfJung
core: avoid `extern type`s in formatting infrastructure

```@RalfJung``` [said](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Use.20of.20.60extern.20type.60.20in.20formatting.20machinery/near/446552837):

>How attached are y'all to using `extern type` in the formatting machinery?
Seems like this was introduced a [long time ago](34ef8f5441). However, it's also [not really compatible with Stacked Borrows](https://github.com/rust-lang/unsafe-code-guidelines/issues/256), and only works currently because we effectively treat references-to-extern-type almost like raw pointers in Stacked Borrows -- which of course is unsound, it's not how LLVM works. I was planning to make Miri emit a warning when this happens to avoid cases like [this](https://github.com/rust-lang/rust/issues/126814#issuecomment-2183816373) where people use extern type specifically to silence Miri without realizing what happens. but with the formatting machinery using  extern type, this warning would just show up everywhere...
>
> The "proper" way to do this in Stacked Borrows is to use raw pointers (or `NonNull`).

This PR does just that.

r? ```@RalfJung```
2024-06-28 08:34:08 +02:00
Sky df7331fcd2
Remove unnecessary SeqCst in impl fmt::Pointer for AtomicPtr 2024-06-28 00:20:35 -04:00
Sky 9bbf3d9805
docs: say "includes" instead of "does include" 2024-06-28 00:01:32 -04:00
Sky 264e8093aa
Remove (deprecated & unstable) {to,from}_bits pointer methods 2024-06-27 23:32:20 -04:00
Sky 8bcd1dede6
add () to the marker_impls macro for ConstParamTy
seems to have escaped bootstrap
2024-06-27 22:37:29 -04:00
Jake Goulding 448dd30ed4 Mark Hasher::finish as #[must_use] 2024-06-27 14:16:27 -04:00
joboet 7e7d0a959d
core: improve comment
Co-authored-by: Ralf Jung <post@ralfj.de>
2024-06-27 12:16:46 +02:00
bors 4bdf8d2d58 Auto merge of #126608 - tgross35:f16-f128-library, r=Mark-Simulacrum
Add more constants, functions, and tests for `f16` and `f128`

This adds everything that was in some way blocked on const eval, since https://github.com/rust-lang/rust/pull/126429 landed. There is a lot of `cfg(bootstrap)` since that is a fairly recent change.

`f128` tests are disabled on everything except x86_64 and Linux aarch64, which are two platforms I know have "good" support for these types - meaning basic math symbols are available and LLVM doesn't hit selection crashes. `f16` tests are enabled on almost everything except for known LLVM crashes. Doctests are only enabled on x86_64.

Tracking issue: https://github.com/rust-lang/rust/issues/116909
2024-06-26 12:06:05 +00:00
Matthias Krüger cf22be186c
Rollup merge of #126879 - the8472:next-chunk-filter-drop, r=cuviper
fix Drop items getting leaked in Filter::next_chunk

The optimization only makes sense for non-drop elements anyway. Use the default implementation for items that are Drop instead.

It also simplifies the implementation.

fixes #126872
tracking issue #98326
2024-06-26 07:50:18 +02:00
joboet 23d1cc4b84
core: avoid extern types in formatting infrastructure 2024-06-26 00:06:16 +02:00
joboet 2c9556d28a
fix UI test, simplify error message 2024-06-25 23:43:19 +02:00
The 8472 0d7aef9738 regression test for leaks in the the Filter::next_chunk implementation
previously next_chunk would forget items rejected by the filter
2024-06-25 23:22:27 +02:00
The 8472 2be2d77c50 add comments explaining optimizations for Filter::next_chunk 2024-06-25 23:20:00 +02:00
The 8472 133e7b10a4 fix Drop items getting leaked in Filter::next_chunk
The optimization only makes sense for non-drop elements anyway.
Use the default implementation for items that are Drop instead.

It also simplifies the implementation.
2024-06-25 23:19:58 +02:00
Matthias Krüger e9700179bb
Rollup merge of #126946 - cyrgani:patch-1, r=compiler-errors
Add missing slash in `const_eval_select` doc comment

In the middle of the doc comment, one line has only two slashes instead of three and isn't included in the [rendered documentation](https://doc.rust-lang.org/std/intrinsics/fn.const_eval_select.html#stability-concerns). This PR adds the missing slash.
2024-06-25 21:33:44 +02:00
Matthias Krüger 3795c56bd1
Rollup merge of #126927 - workingjubilee:vaargsafe-is-unsafe, r=joboet
core: VaArgSafe is an unsafe trait

`T: VaArgSafe` is relied on for soundness. Safe impls promise nothing. Therefore this must be an unsafe trait. Slightly pedantic, as only core can impl this, but we *could* choose to unseal the trait. That would allow soundly (but unsafely) implementing this for e.g. a `#[repr(C)] struct` that should be passable by varargs.

Relates to https://github.com/rust-lang/rust/issues/44930
2024-06-25 21:33:43 +02:00
Matthias Krüger 58bbade921
Rollup merge of #126302 - mu001999-contrib:ignore/default, r=michaelwoerister
Detect unused structs which derived Default

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->

Fixes #98871
2024-06-25 21:33:41 +02:00
mu001999 6997b6876d Detect unused structs which derived Default 2024-06-25 23:29:44 +08:00
cyrgani c7b579a7cb
Add missing slash in const_eval_select doc comment 2024-06-25 13:37:22 +02:00
Trevor Gross 6e2d934a88 Add more f16 and f128 library functions and constants
This adds everything that was directly or transitively blocked on const
arithmetic for these types, which was recently merged.

Since const arithmetic is recent, most of these need to be gated by
`bootstrap`.

Anything that relies on intrinsics that are still missing is excluded.
2024-06-25 01:32:36 -04:00
Trevor Gross 0eee0557d0 Add doctests to existing f16 and f128 functions
The symbols that these tests rely on are not available on all platforms
and some ABIs are buggy, tests that rely on external functions are
configured to only run on x86 (`f128`) or aarch64 (`f16`).
2024-06-25 01:32:36 -04:00
Jubilee Young 050595a826 core: VaArgSafe is an unsafe trait
`T: VaArgSafe` is relied on for soundness. Safe impls promise nothing.
Therefore this must be an unsafe trait. Slightly pedantic, as
only core can impl this, but we could choose to unseal the trait.
That would allow soundly (but unsafely) implementing this for e.g.
a `#[repr(C)] struct` that should be passable by varargs.
2024-06-24 20:40:33 -07:00
bors fc555cd832 Auto merge of #126852 - scottmcm:more-checked-math-tweaks, r=Amanieu
Also get `add nuw` from `uN::checked_add`

When I was doing this for `checked_{sub,shl,shr}`, it was mentioned https://github.com/rust-lang/rust/pull/124114#issuecomment-2066173305 that it'd be worth trying for `checked_add` too.

It makes a particularly-big difference for `x.checked_add(C)`, as doing this means that LLVM removes the intrinsic and does it as a normal `x <= MAX - C` instead.

cc `@DianQK` who had commented about `checked_add` related to https://github.com/rust-lang/hashbrown/issues/509 before

cc https://github.com/llvm/llvm-project/issues/80637 for how LLVM is unlikely to do this itself
2024-06-25 02:50:37 +00:00
Michael Goulet 85eb835a14
Rollup merge of #126904 - GrigorenkoPV:nonzero-fixme, r=joboet
Small fixme in core now that NonZero is generic

I doubt I have the rights to, but
`@bors` rollup=always
2024-06-24 15:51:05 -04:00
Michael Goulet ed460d2eaa
Rollup merge of #125575 - dingxiangfei2009:derive-smart-ptr, r=davidtwco
SmartPointer derive-macro

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->

Possibly replacing #123472 for continued upkeep of the proposal rust-lang/rfcs#3621 and implementation of the tracking issue #123430.

cc `@Darksonn` `@wedsonaf`
2024-06-24 15:51:01 -04:00
Kevin Reid 13fca73f49 Replace MaybeUninit::uninit_array() with array repeat expression.
This is possible now that inline const blocks are stable; the idea was
even mentioned as an alternative when `uninit_array()` was added:
<https://github.com/rust-lang/rust/pull/65580#issuecomment-544200681>

> if it’s stabilized soon enough maybe it’s not worth having a
> standard library method that will be replaceable with
> `let buffer = [MaybeUninit::<T>::uninit(); $N];`

Const array repetition and inline const blocks are now stable (in the
next release), so that circumstance has come to pass, and we no longer
have reason to want `uninit_array()` other than convenience. Therefore,
let’s evaluate the inconvenience by not using `uninit_array()` in
the standard library, before potentially deleting it entirely.
2024-06-24 10:23:50 -07:00
Pavel Grigorenko 39bf1dcce5 Small fixme in core now that split_first has no codegen issues 2024-06-24 17:57:58 +03:00
Pavel Grigorenko 84474a25a4 Small fixme in core now that NonZero is generic 2024-06-24 17:42:08 +03:00
Matthias Krüger 94b9ea417d
Rollup merge of #126213 - zachs18:atomicbool-u8-i8-from-ptr-alignment, r=Nilstrieb
Update docs for AtomicBool/U8/I8 with regard to alignment

Fixes #126084.

Since `AtomicBool`/`AtomicU8`/`AtomicI8` are guaranteed to have size == 1, and Rust guarantees that `size % align == 0`, they also must have alignment equal to 1, so some current docs are contradictory/confusing when describing their alignment requirements.

Specifically:

* Fix `AtomicBool::from_ptr` claiming that `align_of::<AtomicBool>() > align_of::<bool>()` on some platforms. (same for `AtomicU8::from_ptr`/`AtomicI8::from_ptr`)
* Explicitly state that `AtomicU8`/`AtomicI8` have the same alignment as `u8`/`i8` (in addition to size and bit validity)
* (internal) Change the `if_not_8_bit` macro to be `if_8_bit` and to allow an "if-else"-like structure, instead of just "if"-like.

---

I opted to leave the "`ptr` must be aligned" wording in `from_ptr`'s docs and just clarify that it is always satsified, instead of just removing the wording entirely. If that is instead preferred I can do that.
2024-06-24 15:06:21 +02:00
Trevor Gross 0314fe62bd Reword docs for f32 and f64
Better explain the reasoning for the `next_up`/`next_down` integer
implementation, as requested by Ralf.
2024-06-24 00:42:21 -05:00
Trevor Gross fce07a82c6 Extract repeated constants from f32 and f64 source
This will make it easier to keep `f16` and `f128` consistent as their
implementations get added.
2024-06-24 00:42:21 -05:00
Scott McMurray ec9e35618d Also get add nuw from uN::checked_add 2024-06-23 13:29:06 -07:00