Commit Graph

268391 Commits

Author SHA1 Message Date
许杰友 Jieyou Xu (Joe)
5f74fde853 linkchecker: add a reminder on broken links to add new/renamed pages to SUMMARY.md for mdBooks 2024-10-15 20:46:16 +08:00
bors
00367d523e Auto merge of #131727 - RalfJung:miri-sync, r=RalfJung
Miri subtree update

r? `@ghost`
2024-10-15 08:42:24 +00:00
Ralf Jung
1f501a7f09 update lockfile 2024-10-15 07:51:50 +02:00
bors
88f311479d Auto merge of #131724 - matthiaskrgr:rollup-ntgkkk8, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #130608 (Implemented `FromStr` for `CString` and `TryFrom<CString>` for `String`)
 - #130635 (Add `&pin (mut|const) T` type position sugar)
 - #130747 (improve error messages for `C-cmse-nonsecure-entry` functions)
 - #131137 (Add 1.82 release notes)
 - #131328 (Remove unnecessary sorts in `rustc_hir_analysis`)
 - #131496 (Stabilise `const_make_ascii`.)
 - #131706 (Fix two const-hacks)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-15 05:02:38 +00:00
Matthias Krüger
83252bd780
Rollup merge of #131706 - GKFX:fix-const-hacks, r=tgross35
Fix two const-hacks

Fix two pieces of code marked `FIXME(const-hack)` related to const_option #67441.
2024-10-15 05:12:37 +02:00
Matthias Krüger
9716a42389
Rollup merge of #131496 - bjoernager:const-make-ascii, r=dtolnay
Stabilise `const_make_ascii`.

Closes: #130698

This PR stabilises the `const_make_ascii` feature gate (i.e. marking the `make_ascii_uppercase` and `make_ascii_lowercase` methods in `char`, `u8`, `[u8]`, and `str` as const).
2024-10-15 05:12:36 +02:00
Matthias Krüger
b9cb20154d
Rollup merge of #131328 - ismailarilik:remove-unnecessary-sorts-in-rustc-hir-analysis, r=compiler-errors
Remove unnecessary sorts in `rustc_hir_analysis`

A follow-up after #131140. Here the related objects are `IndexSet` so do not require a sort to stay stable. And they don't need to be `mut` anymore.

r? ```@compiler-errors```
2024-10-15 05:12:36 +02:00
Matthias Krüger
13e07b9edd
Rollup merge of #131137 - Mark-Simulacrum:relnotes, r=cuviper
Add 1.82 release notes

cc ````@rust-lang/release````

This is using the new release notes infrastructure. My expectation is that most and/or all edits should be made separately from this PR by updating various relnote tracking issues, and then we'll re-run the relnotes tool. That probably comes with an exception for the stabilized APIs for std, which will need to be manually added at the end.
2024-10-15 05:12:35 +02:00
Matthias Krüger
731e360d15
Rollup merge of #130747 - folkertdev:c-cmse-nonsecure-entry-error-messages, r=compiler-errors
improve error messages for `C-cmse-nonsecure-entry` functions

fixes https://github.com/rust-lang/rust/issues/81347

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

brings error messages and testing for `C-cmse-nonsecure-entry` in line with `C-cmse-nonsecure-call`.

r? `@compiler-errors`
2024-10-15 05:12:35 +02:00
Matthias Krüger
fb691b470a
Rollup merge of #130635 - eholk:pin-reborrow-sugar, r=compiler-errors
Add `&pin (mut|const) T` type position sugar

This adds parser support for `&pin mut T` and `&pin const T` references. These are desugared to `Pin<&mut T>` and `Pin<&T>` in the AST lowering phases.

This PR currently includes #130526 since that one is in the commit queue. Only the most recent commits (bd450027eb4a94b814a7dd9c0fa29102e6361149 and following) are new.

Tracking:

- #130494

r? `@compiler-errors`
2024-10-15 05:12:34 +02:00
Matthias Krüger
3a00d35c5d
Rollup merge of #130608 - YohDeadfall:cstr-from-into-str, r=workingjubilee
Implemented `FromStr` for `CString` and `TryFrom<CString>` for `String`

The motivation of this change is making it possible to use `CString` in generic methods with `FromStr` and `TryInto<String>` trait bounds. The same traits are already implemented for `OsString` which is an FFI type too.
2024-10-15 05:12:34 +02:00
bors
785c83015c Auto merge of #129458 - EnzymeAD:enzyme-frontend, r=jieyouxu
Autodiff Upstreaming - enzyme frontend

This is an upstream PR for the `autodiff` rustc_builtin_macro that is part of the autodiff feature.

For the full implementation, see: https://github.com/rust-lang/rust/pull/129175

**Content:**
It contains a new `#[autodiff(<args>)]` rustc_builtin_macro, as well as a `#[rustc_autodiff]` builtin attribute.
The autodiff macro is applied on function `f` and will expand to a second function `df` (name given by user).
It will add a dummy body to `df` to make sure it type-checks. The body will later be replaced by enzyme on llvm-ir level,
we therefore don't really care about the content. Most of the changes (700 from 1.2k) are in `compiler/rustc_builtin_macros/src/autodiff.rs`, which expand the macro. Nothing except expansion is implemented for now.
I have a fallback implementation for relevant functions in case that rustc should be build without autodiff support. The default for now will be off, although we want to flip it later (once everything landed) to on for nightly. For the sake of CI, I have flipped the defaults, I'll revert this before merging.

**Dummy function Body:**
The first line is an `inline_asm` nop to make inlining less likely (I have additional checks to prevent this in the middle end of rustc. If `f` gets inlined too early, we can't pass it to enzyme and thus can't differentiate it.
If `df` gets inlined too early, the call site will just compute this dummy code instead of the derivatives, a correctness issue. The following black_box lines make sure that none of the input arguments is getting optimized away before we replace the body.

**Motivation:**
The user facing autodiff macro can verify the user input. Then I write it as args to the rustc_attribute, so from here on I can know that these values should be sensible. A rustc_attribute also turned out to be quite nice to attach this information to the corresponding function and carry it till the backend.
This is also just an experiment, I expect to adjust the user facing autodiff macro based on user feedback, to improve usability.

As a simple example of what this will do, we can see this expansion:
From:
```
#[autodiff(df, Reverse, Duplicated, Const, Active)]
pub fn f1(x: &[f64], y: f64) -> f64 {
    unimplemented!()
}
```
to
```
#[rustc_autodiff]
#[inline(never)]
pub fn f1(x: &[f64], y: f64) -> f64 {
    ::core::panicking::panic("not implemented")
}
#[rustc_autodiff(Reverse, Duplicated, Const, Active,)]
#[inline(never)]
pub fn df(x: &[f64], dx: &mut [f64], y: f64, dret: f64) -> f64 {
    unsafe { asm!("NOP"); };
    ::core::hint::black_box(f1(x, y));
    ::core::hint::black_box((dx, dret));
    ::core::hint::black_box(f1(x, y))
}
```
I will add a few more tests once I figured out why rustc rebuilds every time I touch a test.

Tracking:

- https://github.com/rust-lang/rust/issues/124509

try-job: dist-x86_64-msvc
2024-10-15 01:30:01 +00:00
Gabriel Bjørnager Jensen
3c31729887
Stabilise 'const_make_ascii' 2024-10-14 17:56:36 -07:00
bors
eb5ca5f53c Auto merge of #3974 - RalfJung:check_min_arg_count, r=RalfJung
use new check_min_arg_count helper in more places
2024-10-14 21:41:07 +00:00
Ralf Jung
413ea993de use new check_min_arg_count helper in more places 2024-10-14 23:37:03 +02:00
bors
b7c06b40e1 Auto merge of #3973 - RalfJung:os-unfair-lock, r=RalfJung
ensure that a macOS os_unfair_lock that is moved while being held is not implicitly unlocked

Fixes https://github.com/rust-lang/miri/issues/3859

We mark an os_unfair_lock that is moved while being held as "poisoned", which means it is not considered forever locked. That's not quite what the real implementation does, but allowing arbitrary moves-while-locked would likely expose a ton of implementation details, so hopefully this is good enough.
2024-10-14 20:47:13 +00:00
Ralf Jung
a802fd9c11 ensure that a macOS os_unfair_lock that is moved while being held is not implicitly unlocked 2024-10-14 22:43:41 +02:00
Folkert de Vries
10aa255541 improve error messages for C-cmse-nonsecure-entry functions 2024-10-14 22:32:32 +02:00
Ralf Jung
4e14ad6d62 move lazy_sync helper methods to be with InterpCx 2024-10-14 21:59:34 +02:00
George Bateman
4e438f7d6b
Fix two const-hacks 2024-10-14 20:50:40 +01:00
bors
2b020bf2cc Auto merge of #3968 - YohDeadfall:variadic-arg-helper, r=RalfJung
Added a variadic argument helper

`@RalfJung,` as you wished (:
2024-10-14 19:39:29 +00:00
Ralf Jung
af98424285 add test ensuring a moved mutex deadlocks 2024-10-14 21:37:34 +02:00
Yoh Deadfall
64259a7b8d Added a variadic argument helper 2024-10-14 22:10:27 +03:00
bors
d3c1036255 Auto merge of #3972 - rust-lang:eager_dyn, r=RalfJung
Avoid some needless monomorphizations

All code paths always end up boxing the type, so let's do it eagerly in the `callback!` macro instead
2024-10-14 18:03:05 +00:00
Oli Scherer
1412993757 Avoid some needless monomorphizations 2024-10-14 19:55:50 +02:00
bors
9322d183f4 Auto merge of #131690 - matthiaskrgr:rollup-mcau4ol, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #129424 (Stabilize `Pin::as_deref_mut()`)
 - #131332 (Fix clobber_abi and disallow SVE-related registers in Arm64EC inline assembly)
 - #131384 (Update precondition tests (especially for zero-size access to null))
 - #131430 (Special treatment empty tuple when suggest adding a string literal in format macro.)
 - #131550 (Make some tweaks to extern block diagnostics)
 - #131667 (Fix AArch64InlineAsmReg::emit)
 - #131679 (compiletest: Document various parts of compiletest's `lib.rs`)
 - #131682 (Tag PRs affecting compiletest with `A-compiletest`)

Failed merges:

 - #131496 (Stabilise `const_make_ascii`.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-14 16:38:40 +00:00
bors
d183660e7d Auto merge of #3966 - RalfJung:dont-trust-the-user, r=RalfJung
Do not store synchronization primitive IDs in adressable memory

We shouldn't store this in a place where the program can mess with it.

Fixes https://github.com/rust-lang/miri/issues/1649

Blocked by https://github.com/rust-lang/rust/pull/131593
2024-10-14 15:47:54 +00:00
Ralf Jung
ba95d52258 pick more clear names for the types 2024-10-14 17:44:29 +02:00
Ralf Jung
9265a6e467 turns out relaxed accesses suffice here 2024-10-14 17:44:29 +02:00
Ralf Jung
e3cfe456d6 make lazy_sync_get_data also take a closure to initialize if needed 2024-10-14 17:44:29 +02:00
Ralf Jung
0f7d321684 Windows InitOnce: also store ID outside addressable memory 2024-10-14 17:44:29 +02:00
Ralf Jung
8f342edd7c macOS os_unfair_lock: also store ID outside addressable memory 2024-10-14 17:44:29 +02:00
Ralf Jung
17f0aed84c pthread_cond: also store ID outside addressable memory 2024-10-14 17:44:29 +02:00
Ralf Jung
1389bb9114 pthread_rwlock: also store ID outside addressable memory 2024-10-14 17:44:29 +02:00
Ralf Jung
89323bff8b pthread_mutex: store mutex ID outside adressable memory, so it can be trusted 2024-10-14 17:44:29 +02:00
bors
bd8f2afc44 Auto merge of #3970 - RalfJung:rustup, r=RalfJung
Rustup
2024-10-14 15:11:07 +00:00
Ralf Jung
543d226589 clippy 2024-10-14 17:09:44 +02:00
Matthias Krüger
ac9b21281e
Rollup merge of #131682 - jieyouxu:compiletest-label, r=Zalathar
Tag PRs affecting compiletest with `A-compiletest`
2024-10-14 17:06:39 +02:00
Matthias Krüger
53cfc10742
Rollup merge of #131679 - Zalathar:ct-docs, r=jieyouxu
compiletest: Document various parts of compiletest's `lib.rs`

This adds some much-needed comments to many of the items in compiletest's `lib.rs`, giving a better overview of how a compiletest invocation actually proceeds.

To make review easier I have refrained from renames or functional changes, though I couldn't resist getting rid of one obviously-redundant `Arc::clone` in `make_test_closure`.
2024-10-14 17:06:39 +02:00
Matthias Krüger
dbb0581ff5
Rollup merge of #131667 - taiki-e:aarch64-inline-asm-reg-emit, r=Amanieu
Fix AArch64InlineAsmReg::emit

Currently, this method uses `self as u32 - Self::x0 as u32` to get register index:
36780360b6/compiler/rustc_target/src/asm/aarch64.rs (L204)

However, this is incorrect for reasons explained in the following comment:
36780360b6/compiler/rustc_codegen_llvm/src/asm.rs (L544-L549)

r? ``@Amanieu``

``@rustbot`` label O-AArch64 +A-inline-assembly
2024-10-14 17:06:38 +02:00
Matthias Krüger
b8cdca8cce
Rollup merge of #131550 - compiler-errors:extern-diags, r=spastorino
Make some tweaks to extern block diagnostics

Self-explanatory. See the diagnostic changes; I hope they make them a bit more descriptive.

r? spastorino
2024-10-14 17:06:38 +02:00
Matthias Krüger
75231f8764
Rollup merge of #131430 - surechen:fix_130495, r=jieyouxu
Special treatment empty tuple when suggest adding a string literal in format macro.

For example:
```rust
let s = "123";
println!({}, "sss", s);
```
Suggest:
`println!("{:?} {} {}", {}, "sss", s);`

fixes #130170
2024-10-14 17:06:37 +02:00
Matthias Krüger
32062b4b8e
Rollup merge of #131384 - saethlin:precondition-tests, r=ibraheemdev
Update precondition tests (especially for zero-size access to null)

I don't much like the current way I've updated the precondition check helpers, but I couldn't come up with anything better. Ideas welcome.

I've organized `tests/ui/precondition-checks` mostly with one file per function that has `assert_unsafe_precondition` in it, with revisions that check each precondition. The important new test is `tests/ui/precondition-checks/zero-size-null.rs`.
2024-10-14 17:06:36 +02:00
Matthias Krüger
43bf4f1fd3
Rollup merge of #131332 - taiki-e:arm64ec-clobber-abi, r=Amanieu
Fix clobber_abi and disallow SVE-related registers in Arm64EC inline assembly

Currently `clobber_abi` in Arm64EC inline assembly is implemented using `InlineAsmClobberAbi::AArch64NoX18`, but broken since it attempts to clobber registers that cannot be used in Arm64EC: https://godbolt.org/z/r3PTrGz5r

```
error: cannot use register `x13`: x13, x14, x23, x24, x28, v16-v31 cannot be used for Arm64EC
 --> <source>:6:14
  |
6 |     asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags));
  |              ^^^^^^^^^^^^^^^^

error: cannot use register `x14`: x13, x14, x23, x24, x28, v16-v31 cannot be used for Arm64EC
 --> <source>:6:14
  |
6 |     asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags));
  |              ^^^^^^^^^^^^^^^^

<omitted the same errors for v16-v31>
```

Additionally, this disallows SVE-related registers per https://github.com/rust-lang/rust/pull/131332#issuecomment-2401189142.

cc ``@dpaoliello``

r? ``@Amanieu``

``@rustbot`` label O-windows O-AArch64 +A-inline-assembly
2024-10-14 17:06:35 +02:00
Matthias Krüger
7ed6d1cd38
Rollup merge of #129424 - coolreader18:stabilize-pin_as_deref_mut, r=dtolnay
Stabilize `Pin::as_deref_mut()`

Tracking issue: closes #86918

Stabilizing the following API:

```rust
impl<Ptr: DerefMut> Pin<Ptr> {
    pub fn as_deref_mut(self: Pin<&mut Pin<Ptr>>) -> Pin<&mut Ptr::Target>;
}
```

I know that an FCP has not been started yet, but this isn't a very complex stabilization, and I'm hoping this can motivate an FCP to *get* started - this has been pending for a while and it's a very useful function when writing Future impls.

r? ``@jonhoo``
2024-10-14 17:06:35 +02:00
Ralf Jung
9d579f5358 Merge from rustc 2024-10-14 17:04:43 +02:00
Ralf Jung
5e6170b97f Preparing for merge from rustc 2024-10-14 17:04:30 +02:00
bors
17a19e684c Auto merge of #131672 - matthiaskrgr:rollup-gyzysj4, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #128967 (std::fs::get_path freebsd update.)
 - #130629 (core/net: add Ipv[46]Addr::from_octets, Ipv6Addr::from_segments.)
 - #131274 (library: Const-stabilize `MaybeUninit::assume_init_mut`)
 - #131473 (compiler: `{TyAnd,}Layout` comes home)
 - #131533 (emscripten: Use the latest emsdk 3.1.68)
 - #131593 (miri: avoid cloning AllocExtra)
 - #131616 (merge const_ipv4 / const_ipv6 feature gate into 'ip' feature gate)
 - #131660 (Also use outermost const-anon for impl items in `non_local_defs` lint)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-14 12:20:35 +00:00
许杰友 Jieyou Xu (Joe)
9f42f9491d triagebot: tag PRs affecting compiletest with A-compiletest 2024-10-14 19:33:58 +08:00
Zalathar
cec5986439 Document various parts of compiletest's lib.rs 2024-10-14 21:09:48 +11:00