Commit Graph

16217 Commits

Author SHA1 Message Date
bors 6f7229c4da Auto merge of #129403 - scottmcm:only-array-simd, r=compiler-errors
Ban non-array SIMD

Nearing the end of https://github.com/rust-lang/compiler-team/issues/621 !

Currently blocked on ~~https://github.com/rust-lang/compiler-builtins/pull/673~~ ~~https://github.com/rust-lang/compiler-builtins/pull/674~~ ~~https://github.com/rust-lang/rust/pull/129400~~ ~~https://github.com/rust-lang/rust/pull/129481~~ for windows.
2024-09-10 22:47:40 +00:00
bors 33855f80d4 Auto merge of #130025 - Urgau:missing_docs-expect, r=petrochenkov
Also emit `missing_docs` lint with `--test` to fulfil expectations

This PR removes the "test harness" suppression of the `missing_docs` lint to be able to fulfil `#[expect]` (expectations) as it is now "relevant".

I think the goal was to maybe avoid false-positive while linting on public items under `#[cfg(test)]` but with effective visibility we should no longer have any false-positive.

Another possibility would be to query the lint level and only emit the lint if it's of expect level, but that is even more hacky.

Fixes https://github.com/rust-lang/rust/issues/130021

try-job: x86_64-gnu-aux
2024-09-10 14:54:09 +00:00
bors 26b2b8d162 Auto merge of #130179 - workingjubilee:rollup-l78cv44, r=workingjubilee
Rollup of 11 pull requests

Successful merges:

 - #128316 (Stabilize most of `io_error_more`)
 - #129473 (use  `download-ci-llvm=true` in the default compiler config)
 - #129529 (Add test to build crates used by r-a on stable)
 - #129981 (Remove `serialized_bitcode` from `LtoModuleCodegen`.)
 - #130094 (Inform the solver if evaluation is concurrent)
 - #130132 ([illumos] enable SIGSEGV handler to detect stack overflows)
 - #130146 (bootstrap `naked_asm!` for `compiler-builtins`)
 - #130149 (Helper function for formatting with `LifetimeSuggestionPosition`)
 - #130152 (adapt a test for llvm 20)
 - #130162 (bump download-ci-llvm-stamp)
 - #130164 (move some const fn out of the const_ptr_as_ref feature)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-10 07:26:27 +00:00
Scott McMurray d2309c2a9d Ban non-array SIMD 2024-09-09 19:39:43 -07:00
Jubilee 9749a9801c
Rollup merge of #130164 - RalfJung:const_ptr_as_ref, r=dtolnay
move some const fn out of the const_ptr_as_ref feature

When a `const fn` is still `#[unstable]`, it should generally use the same feature to track its regular stability and const-stability. Then when that feature moves towards stabilization we can decide whether the const-ness can be stabilized as well, or whether it should be moved into a new feature.

Also, functions like `ptr::as_ref` (which returns an `Option<&mut T>`) require `is_null`, which is tricky and blocked on some design concerns (see #74939). So move those to the is_null feature gate, as they should be stabilized together with `ptr.is_null()`.

Affects #91822, #122034, #75402, https://github.com/rust-lang/rust/issues/74939
2024-09-09 19:20:39 -07:00
Jubilee 57273d82a8
Rollup merge of #130146 - folkertdev:bootstrap-naked-asm, r=Amanieu
bootstrap `naked_asm!` for `compiler-builtins`

tracking issue: https://github.com/rust-lang/rust/issues/90957
parent PR: https://github.com/rust-lang/rust/pull/128651

in this PR, `naked_asm!` is added as an alias for `asm!` with one difference: `options(noreturn)` is always enabled by `naked_asm!`. That makes it future-compatible for when `naked_asm!` starts disallowing `options(noreturn)` later.

The `naked_asm!` macro must be introduced first so that we can upgrade `compiler-builtins` to use it, and can then change the implementation of `naked_asm!` in https://github.com/rust-lang/rust/pull/128651

I've added some usages for `naked_asm!` in the tests, so we can be confident that it works, but I've left upgrading the whole test suite to the parent PR.

r? ``@Amanieu``
2024-09-09 19:20:38 -07:00
Jubilee 468089210c
Rollup merge of #130132 - sunshowers:illumos-sigsegv, r=Noratrieb
[illumos] enable SIGSEGV handler to detect stack overflows

Use the same code as Solaris. I couldn't find any tests regarding this, but I did test a stage0 build against my stack-exhaust-test binary [1]. Before:

```
running with use_stacker = No, new_thread = false, make_large_local = false
zsh: segmentation fault (core dumped)  cargo run
```

After:

```
running with use_stacker = No, new_thread = false, make_large_local = false

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
zsh: IOT instruction (core dumped)  cargo +stage0 run
```

Fixes #128568.

[1] https://github.com/sunshowers/stack-exhaust-test/
2024-09-09 19:20:37 -07:00
Jubilee 1392965e05
Rollup merge of #128316 - GrigorenkoPV:io_error_a_bit_more, r=dtolnay
Stabilize most of `io_error_more`

Sadly, venting my frustration with t-libs-api is not a constructive way to solve problems and get things done, so I will try to stick to stuff that actually matters here.

- Tracking issue for this feature was opened 3 years ago: #86442
- FCP to stabilize it was completed 19(!!) months ago: https://github.com/rust-lang/rust/issues/86442#issuecomment-1368082102
- A PR with stabilization was similarly open for 19 months: #106375, but nothing ever came out of it. Presumably (it is hard to judge given the lack of communication) because a few of the variants still had some concerns voiced about them, even after the FCP.

So, to highlight a common sentiment:

> Maybe uncontroversial variants can be stabilised first and other variants (such as `QuotaExceeded` or `FilesystemLoop`) later? [^1]

[^1]: https://github.com/rust-lang/rust/issues/106375#issuecomment-1435762236

> I would like to voice support stabilization of the uncontroversial variants. This would get those variants to stable and focus the discussion around the more controversial ones. I don't see any particular reason that all of these must be stabilized at the same time. [...] [^2]

[^2]: https://github.com/rust-lang/rust/pull/106375#issuecomment-1742661555

> Maybe some less-controversial subset could be stabilized sooner? What’s blocking this issue from making progress? [^3]

[^3]: https://github.com/rust-lang/rust/issues/86442#issuecomment-1691187483 (got 30 upvotes btw) (and no response)

So this is exactly what this PR does. It stabilizes the non-controversial variants now, leaving just a few of them behind.

Namely, this PR stabilizes:

- `HostUnreachable`
- `NetworkUnreachable`
- `NetworkDown`
- `NotADirectory`
- `IsADirectory`
- `DirectoryNotEmpty`
- `ReadOnlyFilesystem`
- `StaleNetworkFileHandle`
- `StorageFull`
- `NotSeekable`
- `FileTooLarge`
- `ResourceBusy`
- `ExecutableFileBusy`
- `Deadlock`
- `TooManyLinks`
- `ArgumentListTooLong`
- `Unsupported`

This PR does not stabilize:
- `FilesystemLoop`
- `FilesystemQuotaExceeded`
- `CrossesDevices`
- `InvalidFilename`

Hopefully, this will allow us to move forward with this highly and long awaited addition to std, both allowing to still polish the less clear parts of it and not leading to stagnation.

r? joshtriplett
because they seem to be listed as a part of t-libs-api and were one of the most responsive persons previously
2024-09-09 19:20:34 -07:00
bors 304b7f801b Auto merge of #129778 - RalfJung:interp-lossy-typed-copy, r=saethlin
interpret: make typed copies lossy wrt provenance and padding

A "typed copy" in Rust can be a lossy process: when copying at type `usize` (or any other non-pointer type), if the original memory had any provenance, that provenance is lost. When copying at pointer type, if the original memory had partial provenance (i.e., not the same provenance for all bytes), that provenance is lost. When copying any type with padding, the contents of padding are lost.

This PR equips our validity-checking pass with the ability to reset provenance and padding according to those rules. Can be reviewed commit-by-commit. The first three commits are just preparation without any functional change.

Fixes https://github.com/rust-lang/miri/issues/845
Fixes https://github.com/rust-lang/miri/issues/2182
2024-09-10 02:18:51 +00:00
Matthias Krüger 72b0f5b8d2
Rollup merge of #130154 - okaneco:stabilize_char_min, r=cuviper
Stabilize `char::MIN`

FCP completed https://github.com/rust-lang/rust/issues/114298#issuecomment-2335250508
Closes #114298
2024-09-09 20:20:21 +02:00
Matthias Krüger 2d26ebe3f9
Rollup merge of #130067 - madsmtm:clean-up-fs-test, r=ChrisDenton
Remove redundant check in `symlink_hard_link` test

We support macOS 10.12 and above, so it now always uses `linkat`, and so the check is redundant.

This was missed in #126351.

``@rustbot`` label O-macos
2024-09-09 20:20:19 +02:00
Ralf Jung e10224a7c3 move const fn with a null check into const_ptr_is_null gate 2024-09-09 20:09:13 +02:00
Ralf Jung 720bd0dd6c move some const fn out of the const_ptr_as_ref feature 2024-09-09 19:59:16 +02:00
okaneco bc70fa2f22 Stabilize `char::MIN` 2024-09-09 11:48:12 -04:00
Ralf Jung 0a70924c21 fix UB in a test
also add an explicit test for the fact that a Option<WidePtr> has padding when it is None
2024-09-09 16:17:34 +02:00
Urgau 843708a32e Add missing `#[allow(missing_docs)]` on hack functions in alloc 2024-09-09 13:44:09 +02:00
Folkert de Vries 02378997ea bootstrap `naked_asm!` for `compiler-builtins`
in this commit, `naked_asm!` is an alias for `asm!` with one difference: `options(noreturn)` is always enabled by `naked_asm!`. That makes it future-compatible for when `naked_asm!` starts disallowing `options(noreturn)` later.
2024-09-09 12:47:40 +02:00
Jubilee 2f1cf6feb0
Rollup merge of #130115 - eduardosm:needless-returns-libs, r=workingjubilee
Remove needless returns detected by clippy in libraries
2024-09-09 00:17:52 -07:00
Jubilee fad44c424f
Rollup merge of #130107 - RalfJung:const-ptr-is-null, r=oli-obk
const: make ptr.is_null() stop execution on ambiguity

This seems better than saying `false` -- saying `false` is in fact actively unsound if `NonNull` then uses this to permit putting this pointer inside of it, but at runtime it turns out to be null.

Part of https://github.com/rust-lang/rust/issues/74939
Cc ```@rust-lang/wg-const-eval```
2024-09-09 00:17:51 -07:00
Jubilee 4a26f3b0ba
Rollup merge of #130090 - RalfJung:result-copied, r=Noratrieb
make Result::copied unstably const

The corresponding `Option::copied` is unstably const, so seems reasonable to do the same here.
2024-09-09 00:17:50 -07:00
Jubilee 38520aed18
Rollup merge of #130087 - RalfJung:option-const-iter, r=workingjubilee
remove 'const' from 'Option::iter'

This is kind of pointless to be a `const fn` since you can't do anything with the iterator. It is also the only `const fn iter*` in the entire standard library. It probably got constified when `~const` traits got added everywhere, and then was forgotten to be de-constified when that was undone.

The rest of the const_option feature seems like it can reasonably be stabilized, but this one IMO should not be stabilized, and it's not worth creating a new tracking issue.

Cc https://github.com/rust-lang/rust/issues/67441
2024-09-09 00:17:50 -07:00
Rain 54672ac392 [illumos] enable SIGSEGV handler to detect stack overflows
Use the same code as Solaris. I couldn't find any tests regarding this, but I
did test a stage0 build against my stack-exhaust-test binary [1]. Before:

```
running with use_stacker = No, new_thread = false, make_large_local = false
zsh: segmentation fault (core dumped)  cargo run
```

After:

```
running with use_stacker = No, new_thread = false, make_large_local = false

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
zsh: IOT instruction (core dumped)  cargo +stage0 run
```

Fixes #128568.

[1] https://github.com/sunshowers/stack-exhaust-test/
2024-09-09 07:00:05 +00:00
Eduardo Sánchez Muñoz 5f3fdd14df Remove needless returns detected by clippy in libraries 2024-09-08 21:51:00 +02:00
Ralf Jung 11d51aae86 const: make ptr.is_null() stop execution on ambiguity 2024-09-08 19:07:46 +02:00
Ralf Jung f7b4f4a73b Option, Result: put the &mut variants of 'copied' under the same feature as the '&' variants 2024-09-08 16:52:40 +02:00
bors adf8d168af Auto merge of #130002 - orlp:better-div-floor-ceil, r=thomcc
better implementation of signed div_floor/ceil

Tracking issue for signed `div_floor`/`div_ceil`: https://github.com/rust-lang/rust/issues/88581.

This PR improves the implementation of those two functions by adding a better branchless algorithm. Side-by-side comparison of `i32::div_floor` on x86-64:

```asm
div_floor_new:                               div_floor_old:
        push    rax                                  push    rax
        test    esi, esi                             test    esi, esi
        je      .LBB0_3                              je      .LBB1_6
        mov     eax, esi                             mov     eax, esi
        not     eax                                  not     eax
        lea     ecx, [rdi - 2147483648]              lea     ecx, [rdi - 2147483648]
        or      ecx, eax                             or      ecx, eax
        je      .LBB0_2                              je      .LBB1_7
        mov     eax, edi                             mov     eax, edi
        cdq                                          cdq
        idiv    esi                                  idiv    esi
        xor     esi, edi                             test    edx, edx
        sar     esi, 31                              setg    cl
        test    edx, edx                             test    esi, esi
        cmove   esi, edx                             sets    dil
        add     eax, esi                             test    dil, cl
        pop     rcx                                  jne     .LBB1_4
        ret                                          test    edx, edx
.LBB0_3:                                             setns   cl
        lea     rdi, [rip + .L__unnamed_1]           test    esi, esi
        call    qword ptr [rip + panic...]          setle   dl
.LBB0_2:                                             or      dl, cl
        lea     rdi, [rip + .L__unnamed_1]           jne     .LBB1_5
        call    qword ptr [rip + panic...]   .LBB1_4:
                                                     dec     eax
                                             .LBB1_5:
                                                     pop     rcx
                                                     ret
                                             .LBB1_6:
                                                     lea     rdi, [rip + .L__unnamed_2]
                                                     call    qword ptr [rip + panic...]
                                             .LBB1_7:
                                                     lea     rdi, [rip + .L__unnamed_2]
                                                     call    qword ptr [rip + panic...]
```

And on Aarch64:

```asm
_div_floor_new:                                   _div_floor_old:
        stp     x29, x30, [sp, #-16]!                     stp     x29, x30, [sp, #-16]!
        mov     x29, sp                                   mov     x29, sp
        cbz     w1, LBB0_4                                cbz     w1, LBB1_9
        mov     w8, #-2147483648                          mov     x8, x0
        cmp     w0, w8                                    mov     w9, #-2147483648
        b.ne    LBB0_3                                    cmp     w0, w9
        cmn     w1, #1                                    b.ne    LBB1_3
        b.eq    LBB0_5                                    cmn     w1, #1
LBB0_3:                                                   b.eq    LBB1_10
        sdiv    w8, w0, w1                        LBB1_3:
        msub    w9, w8, w1, w0                            sdiv    w0, w8, w1
        eor     w10, w1, w0                               msub    w8, w0, w1, w8
        asr     w10, w10, #31                             tbz     w1, #31, LBB1_5
        cmp     w9, #0                                    cmp     w8, #0
        csel    w9, wzr, w10, eq                          b.gt    LBB1_7
        add     w0, w9, w8                        LBB1_5:
        ldp     x29, x30, [sp], #16                       cmp     w1, #1
        ret                                               b.lt    LBB1_8
LBB0_4:                                                   tbz     w8, #31, LBB1_8
        adrp    x0, l___unnamed_1@PAGE            LBB1_7:
        add     x0, x0, l___unnamed_1@PAGEOFF             sub     w0, w0, #1
        bl      panic...                          LBB1_8:
LBB0_5:                                                   ldp     x29, x30, [sp], #16
        adrp    x0, l___unnamed_1@PAGE                    ret
        add     x0, x0, l___unnamed_1@PAGEOFF     LBB1_9:
        bl      panic...                                  adrp    x0, l___unnamed_2@PAGE
                                                          add     x0, x0, l___unnamed_2@PAGEOFF
                                                          bl      panic...
                                                  LBB1_10:
                                                          adrp    x0, l___unnamed_2@PAGE
                                                          add     x0, x0, l___unnamed_2@PAGEOFF
                                                          bl      panic...
```
2024-09-08 13:54:02 +00:00
bors 7b18b3eb6d Auto merge of #129019 - kromych:master, r=workingjubilee
Break into the debugger (if attached) on panics (Windows, Linux, macOS, FreeBSD)

The developer experience for panics is to provide the backtrace and
exit the program. When running under debugger, that might be improved
by breaking into the debugger once the code panics thus enabling
the developer to examine the program state at the exact time when
the code panicked.

Let the developer catch the panic in the debugger if it is attached.
If the debugger is not attached, nothing changes. Providing this feature
inside the standard library facilitates better debugging experience.

Validated under Windows, Linux, macOS 14.6, and FreeBSD 13.3..14.1.
2024-09-08 10:28:26 +00:00
Ralf Jung 3de6838238 add some FIXME(const-hack) 2024-09-08 08:30:28 +02:00
bors 878f49f5ff Auto merge of #130091 - matthiaskrgr:rollup-kalu1cs, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #126452 (Implement raw lifetimes and labels (`'r#ident`))
 - #129555 (stabilize const_float_bits_conv)
 - #129594 (explain the options bootstrap passes to curl)
 - #129677 (Don't build by-move body when async closure is tainted)
 - #129847 (Do not call query to compute coroutine layout for synthetic body of async closure)
 - #129869 (add a few more crashtests)
 - #130009 (rustdoc-search: allow trailing `Foo ->` arg search)
 - #130046 (str: make as_mut_ptr and as_bytes_mut unstably const)
 - #130047 (Win: Add dbghelp to the list of import libraries)
 - #130059 (Remove the unused  `llvm-skip-rebuild` option from x.py)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-07 23:02:03 +00:00
Matthias Krüger 0dc9f1ac90
Rollup merge of #130047 - ChrisDenton:win-dbghelp, r=wesleywiser
Win: Add dbghelp to the list of import libraries

This is used by the backtrace crate. But we use a submodule to include backtrace in std (rather than being a real crate) so we need to add the dependency here.
2024-09-07 23:30:15 +02:00
Matthias Krüger c139dc6281
Rollup merge of #130046 - RalfJung:const_str_as_mut, r=dtolnay
str: make as_mut_ptr and as_bytes_mut unstably const

`@rust-lang/libs-api` the corresponding non-mutable methods are already const fn, so this seems pretty trivial. I hope this is small enough that it does not need an ACP? :)

I would like to get these stabilized ASAP because I want to avoid people doing `s.as_ptr().cast_mut()`, which is UB if they ever write to it, but is already const-stable.

TODO: create a tracking issue.
2024-09-07 23:30:14 +02:00
Matthias Krüger 3b2139bdb1
Rollup merge of #129555 - RalfJung:const_float_bits_conv, r=dtolnay
stabilize const_float_bits_conv

This stabilizes `const_float_bits_conv`, and thus fixes https://github.com/rust-lang/rust/issues/72447. With https://github.com/rust-lang/rust/pull/128596 having landed, this is entirely a libs-only question now.

```rust
impl f32 {
    pub const fn to_bits(self) -> u32;
    pub const fn from_bits(v: u32) -> Self;
    pub const fn to_be_bytes(self) -> [u8; 4];
    pub const fn to_le_bytes(self) -> [u8; 4]
    pub const fn to_ne_bytes(self) -> [u8; 4];
    pub const fn from_be_bytes(bytes: [u8; 4]) -> Self;
    pub const fn from_le_bytes(bytes: [u8; 4]) -> Self;
    pub const fn from_ne_bytes(bytes: [u8; 4]) -> Self;
}

impl f64 {
    pub const fn to_bits(self) -> u64;
    pub const fn from_bits(v: u64) -> Self;
    pub const fn to_be_bytes(self) -> [u8; 8];
    pub const fn to_le_bytes(self) -> [u8; 8]
    pub const fn to_ne_bytes(self) -> [u8; 8];
    pub const fn from_be_bytes(bytes: [u8; 8]) -> Self;
    pub const fn from_le_bytes(bytes: [u8; 8]) -> Self;
    pub const fn from_ne_bytes(bytes: [u8; 8]) -> Self;
}
````

Cc `@rust-lang/wg-const-eval` `@rust-lang/libs-api`
2024-09-07 23:30:11 +02:00
bors 12b26c13fb Auto merge of #129941 - BoxyUwU:bump-boostrap, r=albertlarsan68
Bump boostrap compiler to new beta

Accidentally left some comments on the update cfgs commit directly xd
2024-09-07 20:37:30 +00:00
Ralf Jung 03e0c8edb2 make Result::copied unstably const 2024-09-07 22:23:12 +02:00
Ralf Jung f7d4da65c7 remove 'const' from 'Option::iter' 2024-09-07 21:41:28 +02:00
Ralf Jung a8a7fd418e str: make as_mut_ptr and as_bytes_mut unstably const 2024-09-07 21:00:10 +02:00
Mads Marquart a6c6eda61d Remove now redundant check in symlink_hard_link test
We support macOS 10.12 and above, so it now always uses linkat, so the
check is redundant.

This was missed in #126351.
2024-09-07 13:24:16 +02:00
Chris Denton 8966207afd
Win: Add dbghelp to the list of import libraries 2024-09-06 21:21:49 +00:00
Ulrik Mikaelsson 96837dcade Adjust doc comment of Condvar::wait_while
The existing phrasing implies that a notification must be received for `wait_while` to return. The phrasing is changed to better reflect the behavior.
2024-09-06 13:36:09 +02:00
Matthias Krüger 45d6957f24
Rollup merge of #129963 - rjooske:fix/inaccurate_to_string_lossy_doc, r=workingjubilee
Inaccurate `{Path,OsStr}::to_string_lossy()` documentation

The documentation of `Path::to_string_lossy()` and `OsStr::to_string_lossy()` says the following:
> Any non-Unicode sequences are replaced with `U+FFFD REPLACEMENT CHARACTER`

which didn't immediately make sense to me. ("non-Unicode sequences"?)
Since both `to_string_lossy` functions eventually become just a call to `String::from_utf8_lossy`, I believe the documentation meant to say:
> Any *non-UTF-8* sequences are replaced with `U+FFFD REPLACEMENT CHARACTER`

This PR corrects this mistake in the documentation.

For the record, a similar quote can be found in the documentation of `String::from_utf8_lossy`:
> ... During this conversion, `from_utf8_lossy()` will replace any invalid UTF-8 sequences with `U+FFFD REPLACEMENT CHARACTER`, ...
2024-09-06 07:33:57 +02:00
bors d678b81485 Auto merge of #129999 - matthiaskrgr:rollup-pzr9c8p, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #128919 (Add an internal lint that warns when accessing untracked data)
 - #129472 (fix ICE when `asm_const` and `const_refs_to_static` are combined)
 - #129653 (clarify that addr_of creates read-only pointers)
 - #129775 (bootstrap: Try to track down why `initial_libdir` sometimes fails)
 - #129939 (explain why Rvalue::Len still exists)
 - #129942 (copy rustc rustlib artifacts from ci-rustc)
 - #129943 (use the bootstrapped compiler for `test-float-parse` test)
 - #129944 (Add compat note for trait solver change)
 - #129947 (Add digit separators in `Duration` examples)
 - #129955 (Temporarily remove fmease from the review rotation)
 - #129957 (forward linker option to lint-docs)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-06 03:06:52 +00:00
kromych fc28a2a506 Break into the debugger (if attached) on panics (Windows, macOS, Linux, FreeBSD)
The developer experience for panics is to provide the backtrace and
exit the program. When running under debugger, that might be improved
by breaking into the debugger once the code panics thus enabling
the developer to examine the program state at the exact time when
the code panicked.
Let the developer catch the panic in the debugger if it is attached.
If the debugger is not attached, nothing changes. Providing this feature
inside the standard library facilitates better debugging experience.

Validated under Windows, Linux, macOS 14.6, and FreeBSD 13.3..14.1.
2024-09-05 15:26:34 -07:00
Orson Peters 6b4ff514d9 better implementation of signed div_floor/ceil 2024-09-05 22:50:41 +02:00
Matthias Krüger 96719dbe32
Rollup merge of #129947 - LiterallyVoid:duration-docs-digit-separators, r=tgross35
Add digit separators in `Duration` examples

``@rustbot`` label A-docs
2024-09-05 19:43:50 +02:00
Matthias Krüger 85d15d292d
Rollup merge of #129653 - RalfJung:addr-of-read-only, r=scottmcm
clarify that addr_of creates read-only pointers

Stacked Borrows does make this UB, but Tree Borrows does not. This is tied up with https://github.com/rust-lang/rust/issues/56604 and other UCG discussions. Also see [this collection of links](https://github.com/Rust-for-Linux/linux/pull/950#discussion_r1104759431) where rustc treats `addr_of!` as a "non-mutating use".

So, let's better be careful for now.
2024-09-05 19:43:47 +02:00
Matthias Krüger 0db3932433
Rollup merge of #129938 - chancancode:patch-1, r=thomcc
Elaborate on deriving vs implementing `Copy`

I was reading this documentation and this wasn't immediately clear to me.

In my mind, it seemed obvious that a type can only claim to be `Copy` if the bits it is storing can be `Copy`, and in the case of a generic struct that can only be the case if `T: Copy`. So the bound added by the derive seemed necessary at all times, and I thought what the documentation was trying to say is that the custom implementation allows you to add _additional bounds_.

Of course what it was actually trying to point out is that just because you have a generic parameter `T`, it doesn't necessarily mean you are storing the bits of `T`. And if you aren't, it may be the case that your own bits can be copied regardless of whether the bits of `T` can be safely copied.

Thought it may be worth elaborating to make that a bit more clear. Haven't tested/didn't try to figure out how to render this locally. Mainly not sure if the `PhantomData` back link is going to just work or need some extra stuff, but I figured someone else probably could just tell.
2024-09-05 18:58:56 +02:00
Boxy 0091b8ab2a update cfgs 2024-09-05 17:24:01 +01:00
Matthias Krüger c7c3ada95a
Rollup merge of #129919 - kevinmehall:waker-getters, r=dtolnay
Stabilize `waker_getters`

Tracking issue: #96992

FCP completed on the tracking issue a while ago. It's not clear whether the libs-api team wanted the `RawWaker` methods moved to `Waker` or went back to the current API after further discussion. `@Amanieu` [wrote "This is just waiting for someone to submit a stabilization PR."](https://github.com/rust-lang/rust/issues/96992#issuecomment-2213685218) so I'm doing just that in hopes of nudging this along.

Edit: Moved the `data` and `vtable` methods from `RawWaker` to `Waker` and added `Waker::new` per https://github.com/rust-lang/rust/issues/96992#issuecomment-1941998046

```rs
impl Waker {
  pub const unsafe fn new(data: *const (), vtable: &'static RawWakerVTable) -> Self;
  pub fn data(&self) -> *const ();
  pub fn vtable(&self) -> &'static RawWakerVTable;
}
```

Closes #96992
2024-09-05 03:47:44 +02:00
Matthias Krüger 3775e6bd9f
Rollup merge of #127021 - thesummer:1-add-target-support-for-rtems-arm-xilinx-zedboard, r=tgross35
Add target support for RTEMS Arm

# `armv7-rtems-eabihf`

This PR adds a new target for the RTEMS RTOS. To get things started it focuses on Xilinx/AMD Zynq-based targets, but in theory it should also support other armv7-based board support packages in the future.
Given that RTEMS has support for many POSIX functions it is mostly enabling corresponding unix features for the new target.
I also previously started a PR in libc (https://github.com/rust-lang/libc/pull/3561) to add the needed OS specific C-bindings and was told that a PR in this repo is needed first. I will update the PR to the newest version after approval here.
I will probably also need to change one line in the backtrace repo.

Current status is that I could compile rustc for the new target locally (with the updated libc and backtrace) and could compile binaries, link, and execute a simple "Hello World" RTEMS application for the target hardware.

> A proposed target or target-specific patch that substantially changes code shared with other targets (not just target-specific code) must be reviewed and approved by the appropriate team for that shared code before acceptance.

There should be no breaking changes for existing targets. Main changes are adding corresponding `cfg` switches for the RTEMS OS and adding the C binding in libc.

# Tier 3 target policy

> - A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

I will do the maintenance (for now) further members of the RTEMS community will most likely join once the first steps have been done.

> - Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.
>     - Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.
>     - If possible, use only letters, numbers, dashes and underscores for the name. Periods (`.`) are known to cause issues in Cargo.

The proposed triple is `armv7-rtems-eabihf`

> - Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.
>     - The target must not introduce license incompatibilities.
>     - Anything added to the Rust repository must be under the standard Rust license (`MIT OR Apache-2.0`).
>     - The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the `tidy` tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements.
>     - Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, `rustc` built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3.
>     - "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are _not_ limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users.

The tools consists of the cross-compiler toolchain (gcc-based). The RTEMS kernel (BSD license) and parts of the driver stack of FreeBSD (BSD license). All tools are FOSS and publicly available here: https://gitlab.rtems.org/rtems
There are also no new features or dependencies introduced to the Rust code.

> - Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.

N/A to me. I am not a reviewer nor Rust team member.

> - Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (`core` for most targets, `alloc` for targets that can support dynamic memory allocation, `std` for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

`core` and `std` compile. Some advanced features of the `std` lib might not work yet. However, the goal of this tier 3 target it to make it easier for other people to build and run test applications to better identify the unsupported features and work towards enabling them.

> - The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.

Building is described in platform support doc. Running simple unit tests works. Running the test suite of the stdlib is currently not that easy. Trying to work towards that after the this target has been added to the nightly.

> - Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via ````@`)``` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.

Understood.

>     - Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications.

Ok

> - Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.
>     - In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target.

I think, I didn't add any breaking changes for any existing targets (see the comment regarding features above).

> - Tier 3 targets must be able to produce assembly using at least one of rustc's supported backends from any host target.

Can produce assembly code via the llvm backend (tested on Linux).

>
> If a tier 3 target stops meeting these requirements, or the target maintainers no longer have interest or time, or the target shows no signs of activity and has not built for some time, or removing the target would improve the quality of the Rust codebase, we may post a PR to remove it; any such PR will be CCed to the target maintainers (and potentially other people who have previously worked on the target), to check potential interest in improving the situation.GIAt this tier, the Rust project provides no official support for a target, so we place minimal requirements on the introduction of targets.

Understood.

r? compiler-team
2024-09-05 03:47:40 +02:00
Matthias Krüger 8a60d0a5ec
Rollup merge of #101339 - the8472:ci-randomize-debug, r=Mark-Simulacrum
enable -Zrandomize-layout in debug CI builds

This builds rustc/libs/tools with `-Zrandomize-layout` on *-debug CI runners.

Only a handful of tests and asserts break with that enabled, which is promising. One test was fixable, the rest is dealt with by disabling them through new cargo features or compiletest directives.

The config.toml flag `rust.randomize-layout` defaults to false, so it has to be explicitly enabled for now.
2024-09-05 03:47:39 +02:00