Commit Graph

18517 Commits

Author SHA1 Message Date
许杰友 Jieyou Xu (Joe)
a23a93cb4e
Rollup merge of #135080 - Enselic:debug-ptr-metadata, r=thomcc
core: Make `Debug` impl of raw pointers print metadata if present

Make Rust pointers appear less magic by including metadata information in their `Debug` output.

This does not break Rust stability guarantees because `Debug` impl are explicitly exempted from stability:
https://doc.rust-lang.org/std/fmt/trait.Debug.html#stability

> ## Stability
>
> Derived `Debug` formats are not stable, and so may change with future Rust versions. Additionally, `Debug` implementations of types provided by the standard library (`std`, `core`, `alloc`, etc.) are not stable, and may also change with future Rust versions.

Note that a regression test is added as a separate commit to make it clear what impact the last commit has on the output.

Closes #128684 because the output of that code now becomes:

```
thread 'main' panicked at src/main.rs:5:5:
assertion `left == right` failed
  left: Pointer { addr: 0x7ffd45c6fc6b, metadata: 5 }
 right: Pointer { addr: 0x7ffd45c6fc6b, metadata: 3 }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
2025-03-16 13:19:51 +08:00
许杰友 Jieyou Xu (Joe)
01bc95417c
Rollup merge of #138329 - scottmcm:assert-hint, r=Mark-Simulacrum
debug-assert that the size_hint is well-formed in `collect`

Closes #137919

In the hopes of helping to catch any future accidentally-incorrect rustc or stdlib iterators (like the ones #137908 accidentally found), this has `Iterator::collect` call `size_hint` and check its `low` doesn't exceed its `Some(high)`.

There's of course a bazillion more places this *could* be checked, but the hope is that this one is a good tradeoff of being likely to catch lots of things while having minimal maintenance cost (especially compared to putting it in *every* container's `from_iter`).
2025-03-16 09:40:07 +08:00
许杰友 Jieyou Xu (Joe)
5b9225070c
Rollup merge of #138323 - kpreid:offset-of-doc, r=Mark-Simulacrum
Expand and organize `offset_of!` documentation.

* Give example of how to get the offset of an unsized tail field (prompted by discussion <https://github.com/rust-lang/rust/pull/133055#discussion_r1986422206>).
* Specify the return type.
* Add section headings.
* Reduce “Visibility is respected…”, to a single sentence.
* Move `offset_of_enum` documentation to unstable book (with link to it).
* Add `offset_of_slice` documentation in unstable book.

r? Mark-Simulacrum
2025-03-16 09:40:07 +08:00
许杰友 Jieyou Xu (Joe)
413600c2de
Rollup merge of #138309 - DiuDiu777:intrinsic-doc-fix, r=thomcc
Add missing doc for intrinsic (Fix PR135334)

The previous [PR135334](https://github.com/rust-lang/rust/pull/135334) mentioned that some of the intrinsic APIs were missing safety descriptions.

Among intrinsic APIs that miss safety specifications, most are related to numerical operations. They might need to be discussed and then seen how to organize.

Apart from them, only a few intrinsics lack safety. So this PR deals with the APIs with non-numerical operations in priority.
2025-03-16 09:40:06 +08:00
许杰友 Jieyou Xu (Joe)
7112951caa
Rollup merge of #138303 - DiuDiu777:rc-fix, r=Mark-Simulacrum
Fix Ptr inconsistency in {Rc,Arc}

### PR Description
This pr aims to address the problem discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/Inconsistency.20in.20.7BRc.2CArc.7D's.20ptr.20requirements/with/504259637).

### Problem Clarification
As this post presents, the `{Rc, Arc}::{in/de-crement_strong_count_/in}` do not limit the layout of the memory that `ptr` points to, while internally `Rc::from_raw_in` is called directly.

UB doesn't just appear when the strong count is decremented to zero. Miri also detects the UB of `out-of-bounds pointer use` when increment strong count is called on a pointer with an incorrect layout(shown as below).

```rust
use std::rc::Rc;
#[repr(align(8))]
struct Aligned8(u64);

#[repr(align(16))]
struct Aligned16(u64);

fn main() {
    let rc: Rc<Aligned8> = Rc::new(Aligned8(42));
    let raw_ptr = Rc::into_raw(rc);

    unsafe {
        Rc::increment_strong_count(raw_ptr as *const Aligned16);
    }
}
```

Miri output:
```
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to 32 bytes of memory, but got alloc954 which is only 24 bytes from the end of the allocation
```
2025-03-16 09:40:06 +08:00
许杰友 Jieyou Xu (Joe)
8210b84aaf
Rollup merge of #138275 - folkertdev:expose-is-s390x-feature-detected, r=Mark-Simulacrum
expose `is_s390x_feature_detected!` from `std::arch`

tracking issue: https://github.com/rust-lang/rust/issues/135413
implementation: https://github.com/rust-lang/stdarch/pull/1699 (more features added in https://github.com/rust-lang/stdarch/pull/1720)

This macro was part of the recent `stdarch` synchronization, but not yet exposed via `std::arch`.

r? libs
2025-03-16 09:40:05 +08:00
许杰友 Jieyou Xu (Joe)
e0846806db
Rollup merge of #138082 - thaliaarchi:slice-cfg-not-test, r=thomcc
Remove `#[cfg(not(test))]` gates in `core`

These gates are unnecessary now that unit tests for `core` are in a separate package, `coretests`, instead of in the same files as the source code. They previously prevented the two `core` versions from conflicting with each other.
2025-03-16 09:40:05 +08:00
许杰友 Jieyou Xu (Joe)
f16ce2ae6c
Rollup merge of #137890 - lolbinarycat:docs-bufreader-peek-consume, r=Mark-Simulacrum
doc: clarify that consume can be called after BufReader::peek

tracking issue #128405
2025-03-16 09:40:03 +08:00
许杰友 Jieyou Xu (Joe)
4946818306
Rollup merge of #133055 - kpreid:clone-uninit-doc, r=Mark-Simulacrum
Expand `CloneToUninit` documentation.

* Clarify relationship to `dyn` after #133003.
* Add an example of using it with `dyn` as #133003 enabled.
* Replace parameter name `dst` with `dest` to avoid confusion between abbreviations for “DeSTination” and “Dynamically-Sized Type”.
* Add an example of implementing it.
* Add links to Rust Reference for the mentioned concepts.
* Mention that its method should rarely be called.
* Various small corrections.

Please review the `unsafe` code closely, as I am not an expert in the best possible ways to express these operations. (It might also be better to omit the implementation example entirely.)

cc `@zachs18` #126799
2025-03-16 09:40:01 +08:00
bors
ecade534c6 Auto merge of #138506 - fmease:rollup-ve4h2eq, r=fmease
Rollup of 9 pull requests

Successful merges:

 - #134720 (Display valid crate types in error message for --crate-type flag)
 - #137619 (Provide helpful diagnostics for shebang lookalikes)
 - #138353 (remove must_use from <*const T>::expose_provenance)
 - #138452 (Remove `RUN_CHECK_WITH_PARALLEL_QUERIES`)
 - #138469 (remove comment regarding a removed test directive)
 - #138477 (Deny impls for `BikeshedGuaranteedNoDrop`)
 - #138485 (Rustc dev guide subtree update)
 - #138487 (Pass `CI_JOB_DOC_URL` to Docker)
 - #138495 (Take a break from reviews)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-14 17:00:17 +00:00
León Orell Valerian Liehr
c42866f89d
Rollup merge of #138477 - compiler-errors:deny-bikeshed-guaranteed-no-drop, r=lcnr
Deny impls for `BikeshedGuaranteedNoDrop`

r? lcnr
2025-03-14 17:26:36 +01:00
León Orell Valerian Liehr
ffa96fe451
Rollup merge of #138353 - RalfJung:expose-provenance-must-use, r=ibraheemdev
remove must_use from <*const T>::expose_provenance

`<*mut T>::expose_provenance` does not have this attribute, and in fact the function is documented to have a side-effect, so there are perfectly legitimate use-cases where the return value would be ignored.
2025-03-14 17:26:20 +01:00
bors
cb50d4d856 Auto merge of #137424 - Ayush1325:uefi-path-node, r=nicholasbishop,cuviper
uefi: helpers: Add DevicePathNode abstractions

- UEFI device path is a series of nodes layed out in a contiguous memory region. So it makes sense to use Iterator abstraction for modeling DevicePaths
- This PR has been split off from #135368 for easier review. The allow dead_code will be removed in #135368

cc `@nicholasbishop`
2025-03-14 13:55:32 +00:00
bors
f7b4354283 Auto merge of #138480 - jhpratt:rollup-y3b8wu5, r=jhpratt
Rollup of 16 pull requests

Successful merges:

 - #136001 (Overhaul examples for PermissionsExt)
 - #136230 (Reword incorrect documentation about SocketAddr having varying layout)
 - #136892 (Sync Fuchsia target spec with clang Fuchsia driver)
 - #136911 (Add documentation URL to selected jobs)
 - #137870 ( Improve HashMap docs for const and static initializers)
 - #138179 (Add `src/tools/x` to the main workspace)
 - #138389 (use `expect` instead of `allow`)
 - #138396 (Enable metrics and verbose tests in PR CI)
 - #138398 (atomic intrinsics: clarify which types are supported and (if applicable) what happens with provenance)
 - #138432 (fix: remove the check of lld not supporting `@response-file)`
 - #138434 (Visit `PatField` when collecting lint levels)
 - #138441 (update error message)
 - #138442 (EUV: fix place of deref pattern's interior's scrutinee)
 - #138457 (Remove usage of legacy scheme paths on RedoxOS)
 - #138461 (Remove an outdated line from a test comment)
 - #138466 (Remove myself from libs review)

Failed merges:

 - #138452 (Remove `RUN_CHECK_WITH_PARALLEL_QUERIES`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-14 07:02:26 +00:00
Jacob Pratt
f6fcae0015
Rollup merge of #138457 - bjorn3:redox_scheme_paths, r=Noratrieb
Remove usage of legacy scheme paths on RedoxOS

The `name:/path` path syntax is getting phased out[^1] in favor of `/scheme/name/path`. Also using `null:` is no longer necessary as `/dev/null` is available on Redox OS too.

[^1]: https://gitlab.redox-os.org/redox-os/rfcs/-/blob/master/text/0006-scheme-path.md

cc `@jackpot51`
2025-03-14 01:37:36 -04:00
Jacob Pratt
91e4bab25f
Rollup merge of #138398 - RalfJung:atomic-intrinsics-provenance, r=nnethercote
atomic intrinsics: clarify which types are supported and (if applicable) what happens with provenance

The provenance semantics match what Miri implements and what the `AtomicPtr` API expects.
2025-03-14 01:37:32 -04:00
Jacob Pratt
936e51ee12
Rollup merge of #137870 - karolzwolak:lazylock-const-hashmaps-137566, r=cuviper
Improve HashMap docs for const and static initializers

Closes #137566.
I clarified the HashMap usage in const and static initializers.
I also added examples of how to construct such HashMaps wrapped in LazyLock.
2025-03-14 01:37:30 -04:00
Jacob Pratt
595c624fbe
Rollup merge of #136230 - clarfonthey:net-memory-layout-assumptions, r=cuviper
Reword incorrect documentation about SocketAddr having varying layout

This has no longer been the case since these types were moved to `core`. The note on portability remains, but it is reworded to not imply that the size varies by target.
2025-03-14 01:37:28 -04:00
Jacob Pratt
c62707eb74
Rollup merge of #136001 - hkBst:patch-21, r=cuviper
Overhaul examples for PermissionsExt

This fixes #91707 by including one overarching example, instead of the small examples that can be misleading.
2025-03-14 01:37:28 -04:00
bors
523c507d26 Auto merge of #138157 - scottmcm:inline-more-tiny-things, r=oli-obk
Allow more top-down inlining for single-BB callees

This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if
we've already done a bunch of inlining to find the calls to them.

Fixes #138136

~~Draft as it's built atop #138135, which adds a mir-opt test that's a nice demonstration of this.  To see just this change, look at <48f63e3be5>~~ Rebased to be just the inlining change, as the other existing tests show it great.
2025-03-14 03:51:19 +00:00
Michael Goulet
4c32adbadb Deny impls for BikeshedGuaranteedNoDrop 2025-03-14 03:11:43 +00:00
bjorn3
43499bfe2e Remove has_redox_scheme
Redox OS is moving away from name:/path style paths to /scheme/name/path
style paths which are already handled correctly without has_redox_scheme.
2025-03-13 20:09:07 +00:00
Matthias Krüger
883f00ce34
Rollup merge of #138425 - cuviper:remove-hash_raw_entry, r=jhpratt
Remove `feature = "hash_raw_entry"`

The `hash_raw_entry` feature finished [fcp-close](https://github.com/rust-lang/rust/issues/56167#issuecomment-2293805510) back in August, and its remaining uses in the compiler have now been removed, so we should be all clear to remove it from `std`.

Closes #56167
2025-03-13 17:44:11 +01:00
bjorn3
83ee034d03 Remove usage of legacy scheme paths on RedoxOS
The name:/path path syntax is getting phased out in favor of
/scheme/name/path. Also using null: is no longer necessary as /dev/null
is available on Redox OS too.
2025-03-13 16:17:50 +00:00
bors
93257e2d20 Auto merge of #138450 - matthiaskrgr:rollup-4im25vf, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #137816 (attempt to support `BinaryFormat::Xcoff` in `naked_asm!`)
 - #138109 (make precise capturing args in rustdoc Json typed)
 - #138343 (Enable `f16` tests for `powf`)
 - #138356 (bump libc to 0.2.171 to fix xous)
 - #138371 (Update compiletest's `has_asm_support` to match rustc)
 - #138404 (Cleanup sysroot locating a bit)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-13 13:34:28 +00:00
Matthias Krüger
10be9735c7
Rollup merge of #138356 - betrusted-io:bump-libc-0.2.171, r=jhpratt
bump libc to 0.2.171 to fix xous

Due to a reorganization in the `libc` crate, the `xous` target broke with version `0.2.170`. Bump libc to `0.2.171` to fix nightly.
2025-03-13 11:28:33 +01:00
Matthias Krüger
419d913736
Rollup merge of #138343 - tgross35:f16-powf, r=joboet
Enable `f16` tests for `powf`

The LLVM issue [1] was fixed with [2], which is included in the LLVM20 upgrade. Tests no longer fail, so enable them here.

[1]: https://github.com/llvm/llvm-project/pull/98681
[2]: https://github.com/llvm/llvm-project/pull/98681

try-job: aarch64-gnu
try-job: x86_64-gnu-aux
2025-03-13 11:28:31 +01:00
Matthias Krüger
3bfce83cb2
Rollup merge of #138370 - cuviper:try_oom_error, r=jhpratt
Simulate OOM for the `try_oom_error` test

We can create the expected error manually, rather than trying to produce
a real one, so the error conversion test can run on all targets. Before,
it was only running on 64-bit and not miri.

In Fedora, we also found that s390x was not getting the expected error,
"successfully" allocating the huge size because it was optimizing the
real `malloc` call away. It's possible to counter that by looking at the
pointer in any way, like a debug print, but it's more robust to just
deal with errors directly, since this test is only about conversion.

Related: #133806
2025-03-13 10:58:24 +01:00
Matthias Krüger
448aa30b5a
Rollup merge of #138162 - ehuss:library-2024, r=cuviper
Update the standard library to Rust 2024

This updates the standard library to Rust 2024. This includes the following notable changes:

- Macros are updated to use new expression fragment specifiers. This PR includes a test to illustrate the changes, primarily allowing `const {...}` expressions now.
- Some tests show a change in MIR drop order. We do not believe this will be an observable change ([see zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/268952-edition/topic/standard.20library.20migration/near/500972873)).

Fixes https://github.com/rust-lang/rust/issues/133081
2025-03-13 10:58:21 +01:00
Matthias Krüger
9527572460
Rollup merge of #137355 - thaliaarchi:io-optional-methods/sgx, r=ChrisDenton
Implement `read_buf` and vectored read/write for SGX stdio

Implement `read_buf`, `read_vectored`, and `write_vectored` for the SGX stdio types.

Additionally, extend `User<T>::copy_to_enclave` to work for copying to uninitialized values and fix unsoundness in `UserRef<[T]>::copy_to_enclave_vec`.

cc ``@jethrogb``

Tracked in https://github.com/rust-lang/rust/issues/136756
2025-03-13 10:58:19 +01:00
Matthias Krüger
a488cf8a70
Rollup merge of #136842 - randomPoison:trusty-libstd-v3, r=ChrisDenton
Add libstd support for Trusty targets

This PR adds support for `alloc` and `std` for the Trusty targets based on the internal patches used in Android. The original patches can be seen [here](https://android.googlesource.com/toolchain/android_rust/+/refs/heads/main/patches/development/rustc-0023-Add-Trusty-OS-support-to-Rust-std.patch) and [here](https://android.googlesource.com/toolchain/android_rust/+/refs/heads/main/patches/development/rustc-0054-Add-std-os-fd-support-for-Trusty.patch). Please let me know if there's any additional context I need to add.
2025-03-13 10:58:17 +01:00
Ralf Jung
88b206d582 atomic intrinsics: clarify which types are supported and (if applicable) what happens with provenance 2025-03-13 08:14:34 +01:00
Scott McMurray
91af4aa2e2 Allow more top-down inlining for single-BB callees
This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if we've already done a bunch of inlining to find the calls to them.
2025-03-12 22:39:43 -07:00
ClearLove
2f824ea429
Update library/core/src/intrinsics/mod.rs
Co-authored-by: Thom Chiovoloni <thom@shift.click>
2025-03-13 11:34:18 +08:00
ClearLove
6a01990215
Update library/core/src/intrinsics/mod.rs
Co-authored-by: Thom Chiovoloni <thom@shift.click>
2025-03-13 11:34:06 +08:00
ClearLove
d2ff65807c
Update library/core/src/intrinsics/mod.rs
Co-authored-by: Thom Chiovoloni <thom@shift.click>
2025-03-13 11:33:55 +08:00
bors
8536f201ff Auto merge of #138416 - Manishearth:rollup-fejor9p, r=Manishearth
Rollup of 12 pull requests

Successful merges:

 - #134076 (Stabilize `std::io::ErrorKind::InvalidFilename`)
 - #137504 (Move methods from Map to TyCtxt, part 4.)
 - #138175 (Support rmeta inputs for --crate-type=bin --emit=obj)
 - #138259 (Disentangle `ForwardGenericParamBan` and `ConstParamTy` ribs)
 - #138280 (fix ICE in pretty-printing `global_asm!`)
 - #138318 (Rustdoc: remove a bunch of `@ts-expect-error` from main.js)
 - #138331 (Use `RUSTC_LINT_FLAGS` more)
 - #138357 (merge `TypeChecker` and `TypeVerifier`)
 - #138394 (remove unnecessary variant)
 - #138403 (Delegation: one more ICE fix for `MethodCall` generation)
 - #138407 (Delegation: reject C-variadics)
 - #138409 (Use sa_sigaction instead of sa_union.__su_sigaction for AIX)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-13 01:37:26 +00:00
Josh Stone
2c0ad9d967 Remove feature = "hash_raw_entry" 2025-03-12 13:32:50 -07:00
Manish Goregaokar
185dd2d01b
Rollup merge of #134076 - GrigorenkoPV:InvalidFilename, r=joboet
Stabilize `std::io::ErrorKind::InvalidFilename`

FCP complete: https://github.com/rust-lang/rust/issues/130192#issuecomment-2674989358

Tracking issues: #86442 & #130192

This PR:
- Stabilizes `InvalidFilename` without changing its name to `InvalidFileName`.
- Fixes the doc comment (https://github.com/rust-lang/rust/issues/130192#issuecomment-2429534640)
- Does not separate "the name is too long" case into a separate `ErrorKind`. That case is currently documented to be covered by `InvalidFilename` in the doc. I'm not sure if it would be possible to change this later or if that would be an unacceptable breaking change.
- Does not map more raw OS errors to this `ErrorKind` (as suggested in https://github.com/rust-lang/rust/issues/86442#issuecomment-1441709738). This can presumably be addressed later.
2025-03-12 10:19:25 -07:00
Matthias Krüger
0c4415cdd6
Rollup merge of #138387 - RalfJung:intrinsic-arg-names, r=oli-obk
intrinsics: remove unnecessary leading underscore from argument names

This is unnecessary since https://github.com/rust-lang/rust/pull/135840.
2025-03-12 17:59:10 +01:00
Matthias Krüger
a21d41a22d
Rollup merge of #138269 - Ayush1325:uefi-fs-permission, r=joboet
uefi: fs: Implement FileType, FilePermissions and FileAttr

- In UEFI, both FileType and FilePermissions are represented by the attr bitfield.
- Using simple bools here since both are represented by a single bit.
- Add `FILE_PERMISSION` mask for constructing attribute while change permissions.

cc ````@nicholasbishop````
2025-03-12 17:59:07 +01:00
Matthias Krüger
4198902e9a
Rollup merge of #138161 - HeroicKatora:heap-peek-mut-refresh, r=dtolnay
Add PeekMut::refresh

I'm not sure if this should go through ACP or not. BinaryHeap is not the most critical data structure in the standard library and it would be understandable if maintainer throughput is thus too limited to accept this PR without a proper design phase that ensures the required understanding of consequence over a longer time period.

This aims to improve the useability of heaps for priority-based work queues. In certain scenarios, modifications on the most relevant or critical items are performed until a condition that determines the work items have been sufficiently addressed. For instance the criticality could be a deadline that is relaxed whenever some part of a work item is completed. Such a loop will repeatedly access the most critical item and put it back in a sorted position when it is complete. Crucially, due to the ordering invariant we know that all necessary work was performed when the completed item remains the most critical. Getting this information from the heap position avoids a (potentially more costly) check on the item state itself.

A customized `drop` with boolean result would avoid up to two more comparisons performed in both the last no-op refresh and Drop code but this occurs once in each execution of the above scenario whereas refresh occurs any number of times. Also note that the comparison overhead of Drop is only taken if the element is mutably inspected to determine the end condition, i.e. not when refresh itself is the break condition.
2025-03-12 08:06:46 +01:00
Ralf Jung
cf318a79d6 intrinsics: remove unnecessary leading underscore from argument names 2025-03-12 08:04:09 +01:00
Thalia Archibald
c62aa0baa1 Fix UserRef<[T]>::copy_to_enclave_vec
It reinterprets uninitialized memory as initialized and does not drop
existing elements of the Vec. Fix that.

Additionally, make it more general by appending, instead of overwriting
existing elements, and rename it to `append_to_enclave_vec`. A caller
can simply call `.clear()` before, for the old behavior.
2025-03-11 20:16:31 -07:00
bors
c625102320 Auto merge of #138366 - matthiaskrgr:rollup-cn16m7q, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #137715 (Allow int literals for pattern types with int base types)
 - #138002 (Disable CFI for weakly linked syscalls)
 - #138051 (Add support for downloading GCC from CI)
 - #138231 (Prevent ICE in autodiff validation by emitting user-friendly errors)
 - #138245 (stabilize `ci_rustc_if_unchanged_logic` test for local environments)
 - #138256 (Do not feed anon const a type that references generics that it does not have)
 - #138284 (Do not write user type annotation for const param value path)
 - #138296 (Remove `AdtFlags::IS_ANONYMOUS` and `Copy`/`Clone` condition for anonymous ADT)
 - #138352 (miri native_calls: ensure we actually expose *mutable* provenance to the memory FFI can access)
 - #138354 (remove redundant `body`  arguments)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-11 21:17:18 +00:00
Josh Stone
53f488aa4b Simulate OOM for the try_oom_error test
We can create the expected error manually, rather than trying to produce
a real one, so the error conversion test can run on all targets. Before,
it was only running on 64-bit and not miri.

In Fedora, we also found that s390x was not getting the expected error,
"successfully" allocating the huge size because it was optimizing the
real `malloc` call away. It's possible to counter that by looking at the
pointer in any way, like a debug print, but it's more robust to just
deal with errors directly, since this test is only about conversion.
2025-03-11 13:27:15 -07:00
Matthias Krüger
9746ac5c2f
Rollup merge of #138002 - 1c3t3a:fix-std-cfi-violation, r=rcvalle
Disable CFI for weakly linked syscalls

Currently, when enabling CFI via -Zsanitizer=cfi and executing e.g. std::sys::random::getrandom, we can observe a CFI violation. This is the case for all consumers of the std::sys::pal::weak::syscall macro, as it is defining weak functions which don't show up in LLVM IR metadata. CFI fails for all these functions.

Similar to other such cases in
https://github.com/rust-lang/rust/issues/115199, this change stops emitting the CFI typecheck for consumers of the macro via the `#[no_sanitize(cfi)]` attribute.

r? ``````@rcvalle``````
2025-03-11 19:35:28 +01:00
Nicole L
d3c55cd52b
Remove unnecessary parens
Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2025-03-11 11:16:10 -07:00
bors
6650252439 Auto merge of #128440 - oli-obk:defines, r=lcnr
Add `#[define_opaques]` attribute and require it for all type-alias-impl-trait sites that register a hidden type

Instead of relying on the signature of items to decide whether they are constraining an opaque type, the opaque types that the item constrains must be explicitly listed.

A previous version of this PR used an actual attribute, but had to keep the resolved `DefId`s in a side table.

Now we just lower to fields in the AST that have no surface syntax, instead a builtin attribute macro fills in those fields where applicable.

Note that for convenience referencing opaque types in associated types from associated methods on the same impl will not require an attribute. If that causes problems `#[defines()]` can be used to overwrite the default of searching for opaques in the signature.

One wart of this design is that closures and static items do not have generics. So since I stored the opaques in the generics of functions, consts and methods, I would need to add a custom field to closures and statics to track this information. During a T-types discussion we decided to just not do this for now.

fixes #131298
2025-03-11 18:13:31 +00:00
Eric Huss
b130747e92 Migrate windows-targets to Rust 2024 2025-03-11 09:46:35 -07:00