std: sys: xous: clamp condvar wait_timeout instead of truncating
dur.as_millis() (u128) was cast straight to usize, so on 32-bit xous any timeout over ~49 days truncated, and an exact multiple of 2^32 ms became 0 and then 1ms via the "don't wait forever" guard. Saturate the conversion, matching sys/sync/thread_parking/xous.rs.
Add regression test for pclmulqdq inlining across target feature
Regression test for https://github.com/rust-lang/rust/issues/139029.
Checks that pclmulqdq intrinsics inline across target_feature.
std: move `PidFd` to `sys::process`
Part of https://github.com/rust-lang/rust/issues/117276.
I believe this is the last item in `sys::pal` that is used outside of `sys`, hence we should be able to get rid of the `use pal::*` import quite easily after this.
dur.as_millis() (u128) was cast straight to usize, so on 32-bit xous any
timeout over ~49 days truncated, and an exact multiple of 2^32 ms became
0 and then 1ms via the "don't wait forever" guard. Saturate the
conversion, matching sys/sync/thread_parking/xous.rs.
rustdoc: Don't strip hidden items in `AliasedNonLocalStripper`
`AliasedNonLocalStripper` currently strips non-local aliased items that are either non-public or `#[doc(hidden)]`.
The hidden items are subsequently processed by the `strip-hidden` pass. Because they have already been wrapped as stripped items, that pass removes them instead of retaining them as placeholders. As a result, cross-crate aliased types omit `/* private fields */` and `// some variants omitted`.
Handling `#[doc(hidden)]` in `AliasedNonLocalStripper` also means that `--document-hidden-items` cannot display those public fields and variants.
This PR leaves hidden-item handling to `strip-hidden`, while `AliasedNonLocalStripper` continues to unconditionally hide non-public items from external types.
Fixesrust-lang/rust#144969.
r? @GuillaumeGomez
Improve invalid cfg predicate error
I have improved the error that is emitted when a non-existant cfg attribute is used. I removed the InvalidPredicate diagnostic, which does not provide much information, and used the function `expected_specific_argument` instead. This provides a nice link to the documentation. I have also blessed and updated the ui tests that broke because of this change.
Before:
```
error[E0537]: invalid predicate `does_not_exist`
--> bad_error.rs:2:7
|
2 | #[cfg(does_not_exist())]
| ^^^^^^^^^^^^^^^^
error: aborting due to 1 previous error
```
After:
```
error[E0539]: malformed `cfg` attribute input
--> bad_error.rs:2:1
|
2 | #[cfg(does_not_exist())]
| ^^^^^^----------------^^
| |
| valid arguments are `any`, `all`, `not`, `target` or `version`
|
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
help: must be of the form
|
2 - #[cfg(does_not_exist())]
2 + #[cfg(predicate)]
|
```
r? @JonathanBrouwer
Move logic for emitting UNSAFE_CODE for unsafe attributes to attr parsing
Fixes https://github.com/rust-lang/rust/issues/131801
This moves the emitting of `UNSAFE_CODE` for unsafe attributes to attr parsing.
Because it is now implemented generically for all unsafe attributes, we don't have to manually list all attributes anymore, and we can't miss adding support for new unsafe attributes in the future.
This adds support for detecting `UNSAFE_CODE` for the following attributes:
* `#[naked]` **(stable attribute!)**
* `#[ffi_pure]`
* `#[ffi_const]`
* `#[force_target_feature]`
Rollup of 5 pull requests
Successful merges:
- rust-lang/rust#157518 (Add xdg_basedir API)
- rust-lang/rust#157752 (Rename `errors.rs` file to `diagnostics.rs` (6/N))
- rust-lang/rust#157769 (Match expressions had not been updated to also show the match_source,…)
- rust-lang/rust#157825 (Emit retags in codegen to support BorrowSanitizer (part 3))
- rust-lang/rust#157861 (Rename `errors.rs` file to `diagnostics.rs` (7/N))
Emit retags in codegen to support BorrowSanitizer (part 3)
Tracking issue: https://github.com/rust-lang/rust/issues/154760
[Zulip Thread](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Staging.20for.20emitting.20retags.20in.20codegen/with/593004012)
This is one of several PRs that will add experimental support for emitting retags as function calls in codegen.
This PR adds `RetagPlan`, which describes where the pointers that need to be retagged live within the layout of a type. We create a `RetagPlan` ahead of time because only a subset of the variants of a type might contain retagable values. We only want to branch to these variants, and ignore all of the others. If a type can generate a `RetagPlan`, then we will use it as a guide for inserting calls to our retag intrinsics. If a type does not generate a `RetagPlan`, then it does not need to be retagged, and we can skip it.
This does not emit a `RetagPlan::EmitRetag` yet. That will come in a subsequent PR.
Previous parts: rust-lang/rust#156208, rust-lang/rust#156210
cc: @RalfJung
r? @saethlin
Add xdg_basedir API
Implements an API providing easy access to the XDG Base Directories.
I chose to defer `runtime_dir` (`XDG_RUNTIME_DIR`) since the lack of a specified default (but specified expectation for applications to determine an alternative option somehow) makes the correct usage (and thus ideal API) less obvious.
- Accepted ACP: https://github.com/rust-lang/libs-team/issues/805
- Tracking issue: https://github.com/rust-lang/rust/issues/157515
update existing match tests as well
remove hashes from output
remove specific DefIds for core from output
remove additional specifics that can vary and which are not relevant to the test
alloc: clarify comment on ArcInner::weak lock sentinel
The comment on the `weak` field of `ArcInner` currently states that the `usize::MAX` sentinel locks "the ability to upgrade weak pointers or downgrade strong ones", and that this is used to avoid races in `make_mut` and `get_mut`. Both halves of that description are inaccurate.
`Weak::upgrade` never inspects the weak count, so the lock has no effect on it. The operation only CASes on the strong count and is happy to succeed while the weak count is locked. `Arc::make_mut` also does not participate in the locking protocol, and the function body already contains a comment noting that observing `usize::MAX` for the weak count there is impossible because only a thread holding a strong reference can take the lock.
The lock is actually only taken in `Arc::is_unique` (which backs `Arc::get_mut`), and the only operation that observes and waits on it is `Arc::downgrade`, which spins while `weak == usize::MAX` before attempting its CAS to create a new `Weak`.
This PR rewrites the comment to describe what the lock is and what it actually prevents.
Closesrust-lang/rust#144296
Refactor libproc_macro: remove * imports
This factors out (and goes a bit further) some of the work from https://github.com/rust-lang/rust/pull/157590 which I think can/should be merged independently of the wasm proc macros strategy, since it just makes it easier to read code in the bridge. It was confusing to get warnings/errors when commenting code that looked unused but was actually pulled in due to the `*` imports from other modules.
This also factors the panic message into a separate module since it's not really related to `rpc` in a direct sense.
Best reviewed by-commit.
r? bjorn3 since you've probably at least glanced at this code recently, but happy to re-roll if you'd prefer.
Rollup of 10 pull requests
Successful merges:
- rust-lang/rust#157714 (Improve polymorphization of raw pointer formatting)
- rust-lang/rust#157653 (remove AliasTerm::def_id())
- rust-lang/rust#157773 (Remove AnonConstKind::GCA and reject generic anon consts)
- rust-lang/rust#157846 (Avoid ICE in unconstrained generic parameter suggestion for enums)
- rust-lang/rust#157594 (note which target a missing target_feature belongs to)
- rust-lang/rust#157740 (rustdoc: correct doctest span for trailing semicolon after item)
- rust-lang/rust#157782 (Added `PhantomPinned` diagnostic item and prevented dead field warning on `PhantomPinned`)
- rust-lang/rust#157802 (Ensure that optimize attributes on closures are inherited by the shim.)
- rust-lang/rust#157812 (rustc_public: implement `ty::Alias` conversion)
- rust-lang/rust#157833 (Update wasm-component-ld to 0.5.25)
Added `PhantomPinned` diagnostic item and prevented dead field warning on `PhantomPinned`
This PR closesrust-lang/rust#154888. See rust-lang/rust#154978 and in [clippy#17056](https://github.com/rust-lang/rust-clippy/pull/17056) for prior history on working on this issue.
From discussing with clippy team, we thought it'd be appropriate to use a diagnostic item attribute to mark `PhantomPinned` and prevent dead field warnings from being emitted in `missing_fields_in_debug.rs` and `pub_underscore_fields.rs`.
If you want me to do the clippy changes separately within the clippy repository, I can do that.
rustdoc: correct doctest span for trailing semicolon after item
Fixesrust-lang/rust#157371.
When a doctest contains a trailing semicolon after an item, rustdoc can map the
resulting warning to unrelated source following the documentation block rather
than to the semicolon inside the doctest.
Changes only diagnostic span reporting.
Avoid ICE in unconstrained generic parameter suggestion for enums
Fixesrust-lang/rust#156701
`remove_or_use_generic` accepted structs, enums, and unions as ADT self types, but later used a local HIR lookup with `expect_struct()` when building the type-definition suggestion. That caused an ICE when the self type was an enum.