Commit Graph

266070 Commits

Author SHA1 Message Date
Jubilee 4d9ce4b4b3
Rollup merge of #130513 - shekhirin:fs-write-doc-comment, r=cuviper
Clarify docs for std::fs::File::write

This PR fixes the doc comment for `std::fs::File::write` method.
2024-09-18 14:32:27 -07:00
Jubilee d972605735
Rollup merge of #130487 - cuviper:min-llvm-18, r=nikic
Update the minimum external LLVM to 18

With this change, we'll have stable support for LLVM 18 and 19.
For reference, the previous increase to LLVM 17 was #122649.

cc `@rust-lang/wg-llvm`
r? nikic
2024-09-18 14:32:27 -07:00
Jubilee 12b59e52bc
Rollup merge of #130476 - workingjubilee:more-lazy-methods-take-2, r=Amanieu
Implement ACP 429: add `Lazy{Cell,Lock}::get[_mut]` and `force_mut`

Tracking issue for `lazy_get`: https://github.com/rust-lang/rust/issues/129333
2024-09-18 14:32:26 -07:00
Jubilee b33dd7dc88
Rollup merge of #130450 - workingjubilee:these-names-are-indirect, r=bjorn3
Reduce confusion about `make_indirect_byval` by renaming it

As part of doing so, remove the incorrect handling of the wasm target's `make_indirect_byval` (i.e. using it at all).
2024-09-18 14:32:25 -07:00
Jubilee 591ec6c9ce
Rollup merge of #129934 - ChrisDenton:remove-dir-all3, r=Amanieu
Win: Open dir for sync access in remove_dir_all

A small follow up to #129800.

We should explicitly open directories for synchronous access. We ultimately use `GetFileInformationByHandleEx` to read directories which should paper over any issues caused by using async directory reads (or else return an error) but it's better to do the right thing in the first place. Note though that `delete` does not read or write any data so it's not necessary there.
2024-09-18 14:32:25 -07:00
Jubilee 2eb65a6667
Rollup merge of #129422 - compiler-errors:repr-rust, r=fmease
Gate `repr(Rust)` correctly on non-ADT items

#114201 added `repr(Rust)` but didn't add any attribute validation to it like `repr(C)` has, to only allow it on ADT items.

I consider this code to be nonsense, for example:
```
#[repr(Rust)]
fn foo() {}
```

Reminder that it's different from `extern "Rust"`, which *is* valid on function items. But also this now disallows `repr(Rust)` on modules, impls, traits, etc.

I'll crater it, if it looks bad then I'll add an FCW.

---

https://github.com/rust-lang/rust/labels/relnotes: Compatibility (minor breaking change).
2024-09-18 14:32:24 -07:00
Jubilee 2a1dd3575f
Rollup merge of #127988 - estebank:dupe-derive-params, r=fmease
Do not ICE with incorrect empty suggestion

When we have two types with the same name, one without type parameters and the other with type parameters and a derive macro, we were before incorrectly suggesting to remove type parameters from the former, which ICEd because we were suggesting to remove nothing. We now gate against this.

The output is still not perfect. E0107 should explicitly detect this case and provide better context, but for now let's avoid the ICE.

Fix #108748.
2024-09-18 14:32:24 -07:00
Jubilee 4722ad149e
Rollup merge of #97524 - ibraheemdev:thread-raw, r=ibraheemdev
Add `Thread::{into_raw, from_raw}`

Public API:
```rust
#![unstable(feature = "thread_raw", issue = "97523")]

impl Thread {
    pub fn into_raw(self) -> *const ();
    pub unsafe fn from_raw(ptr: *const ()) -> Thread;
}
```

ACP: https://github.com/rust-lang/libs-team/issues/200
2024-09-18 14:32:23 -07:00
Josh Stone 8bab397835 Revert "Add a hack to prevent proc_macro misopt in CI"
This reverts commit da8ac73d91.
2024-09-18 13:53:33 -07:00
Josh Stone 6fd8a50680 Update the minimum external LLVM to 18 2024-09-18 13:53:31 -07:00
Michael Goulet 12f2bcde63 Check params for unsafety in THIR 2024-09-18 16:45:48 -04:00
Jubilee Young 51718e8eca tests: Move wasm32 to transparent-opaque-ptr.rs test 2024-09-18 12:31:51 -07:00
Jubilee Young b75711df12 tests: Remove test for wrong wasm codegen 2024-09-18 12:28:55 -07:00
Jubilee Young a800d1cf37 compiler: s/make_indirect_byval/pass_by_stack_offset/
The previous name is just an LLVMism, which conveys almost nothing about
what is actually meant by the function relative to the ABI.

In doing so, remove an already-addressed FIXME.
2024-09-18 12:28:55 -07:00
Jubilee Young 0cf89b5336 compiler: Use make_indirect for the wasm ABI
This is ignored by LLVM, but is still incorrect.
2024-09-18 12:28:55 -07:00
Jubilee Young f22797d3db library: Call it really_init_mut to avoid name collisions 2024-09-18 11:39:24 -07:00
Jubilee Young d9cdb71497 library: Destabilize Lazy{Cell,Lock}::{force,deref}_mut 2024-09-18 11:39:21 -07:00
Lieselotte db09345ef6
Add suggestions for expressions in patterns 2024-09-18 20:38:43 +02:00
Lieselotte c2047219b5
Recover more expressions in patterns 2024-09-18 20:37:56 +02:00
bors f79a912d9e Auto merge of #130519 - matthiaskrgr:rollup-l1hok4x, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #130457 (Cleanup codegen traits)
 - #130471 (Add zlib to musl dist image so rust-lld will support zlib compression for debug info there.)
 - #130507 (Improve handling of raw-idents in check-cfg)
 - #130509 (llvm-wrapper: adapt for LLVM API changes, second try)
 - #130510 (doc: the source of `LetStmt` can also be `AssignDesugar`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-18 17:51:26 +00:00
León Orell Valerian Liehr 682c5f485b
Explicitly mark a hack as a HACK and elaborate its comment 2024-09-18 19:36:44 +02:00
Esteban Küber bd8e88fd7b
Do not ICE with incorrect empty suggestion
When we have two types with the same name, one without type parameters and the other with type parameters and a derive macro, we were before incorrectly suggesting to remove type parameters from the former, which ICEd because we were suggesting to remove nothing. We now gate against this.

The output is still not perfect. E0107 should explicitly detect this case and provide better context, but for now let's avoid the ICE.
2024-09-18 19:21:07 +02:00
GnomedDev a18564c198
[Clippy] Swap `manual_retain` to use diagnostic items instead of paths 2024-09-18 17:20:44 +01:00
Matthias Krüger c0951bbce2
Rollup merge of #130510 - samueltardieu:doc-letstmt-assign-desugar, r=compiler-errors
doc: the source of `LetStmt` can also be `AssignDesugar`

For example, the two following statements are desugared into a block whose `LetStmt` source is `AssignDesugar`:

```rust
_ = ignoring_some_result();
(a, b) = (b, a);
```
2024-09-18 17:49:45 +02:00
Matthias Krüger 48b90aaed3
Rollup merge of #130509 - krasimirgg:llvm-20-2, r=nikic
llvm-wrapper: adapt for LLVM API changes, second try

This is a re-work of https://github.com/rust-lang/rust/pull/129749 after LLVM brought back the APIs used by rust.

No functional changes intended.

`@rustbot` label: +llvm-main
r? `@nikic`
cc: `@tmandry`
2024-09-18 17:49:45 +02:00
Matthias Krüger 00c4be3df8
Rollup merge of #130507 - Urgau:check-cfg-raw-keywords, r=jieyouxu
Improve handling of raw-idents in check-cfg

This PR improves the handling of raw-idents in the check-cfg diagnostics.

In particular the list of expected names and the suggestion now correctly take into account the "keyword-ness" of the ident, and correctly prefix the ident with `r#` when necessary.

`@rustbot` labels +F-check-cfg
2024-09-18 17:49:44 +02:00
Matthias Krüger 3443795606
Rollup merge of #130471 - khuey:zlib-musl, r=Kobzol
Add zlib to musl dist image so rust-lld will support zlib compression for debug info there.

Fixes #130063.

r? `@Kobzol`
2024-09-18 17:49:44 +02:00
Matthias Krüger 21313d7947
Rollup merge of #130457 - nnethercote:cleanup-codegen-traits, r=bjorn3
Cleanup codegen traits

The traits governing codegen are quite complicated and hard to follow. This PR cleans them up a bit.

r? `@bjorn3`
2024-09-18 17:49:43 +02:00
Artyom Tetyukhin ed2e0abc51
Bump cc dependency 2024-09-18 19:34:36 +04:00
bors 7fc70f870a Auto merge of #130497 - saethlin:alloc-zeroed-is-unstable, r=bjorn3
read_volatile __rust_no_alloc_shim_is_unstable in alloc_zeroed

It was pointed out in https://github.com/rust-lang/rust/issues/128854#issuecomment-2278919897 that the magic volatile read was probably missing from `alloc_zeroed`. I can't find any mention of `alloc_zeroed` on https://github.com/rust-lang/rust/pull/86844, so it looks like this was just missed initially.
2024-09-18 14:48:50 +00:00
Alexey Shekhirin 96a3b48197
Clarify docs for std::fs::File::write 2024-09-18 15:15:54 +01:00
Samuel Tardieu a47e9b6c54 doc: the source of `LetStmt` can also be `AssignDesugar`
For example, the two following statements are desugared into a block
whose `LetStmt` source is `AssignDesugar`:

```rust
_ = ignoring_some_result();
(a, b) = (b, a);
```
2024-09-18 15:27:04 +02:00
Krasimir Georgiev 3a352884f8 llvm-wrapper: adapt for LLVM API changes, second try 2024-09-18 13:23:42 +00:00
bors aaed38b2a6 Auto merge of #129491 - StackOverflowExcept1on:master, r=m-ou-se
Pass `fmt::Arguments` by reference to `PanicInfo` and `PanicMessage`

Resolves #129330

For some reason after #115974 and #126732 optimizations applied to panic handler became worse and compiler stopped removing panic locations if they are not used in the panic message. This PR fixes that and maybe we can merge it into beta before rust 1.81 is released.

Note: optimization only works with `lto = "fat"`.

r? libs-api
2024-09-18 11:57:31 +00:00
bors 82d17a4db3 Auto merge of #130500 - matthiaskrgr:rollup-lfx3bb4, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #130466 (tests: add repr/transparent test for aarch64)
 - #130468 (Make sure that def id <=> lang item map is bidirectional)
 - #130499 (Add myself to the libs review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-18 09:25:01 +00:00
Urgau 89f04c2521 Improve handling of raw-idents in check-cfg 2024-09-18 11:07:32 +02:00
bors f68c28b6ce Auto merge of #129845 - scottmcm:redo-layout, r=Noratrieb
Take more advantage of the `isize::MAX` limit in `Layout`

Things like `padding_needed_for` are current implemented being super careful to handle things like `Layout::size` potentially being `usize::MAX`.

But now that #95295 has happened, that's no longer a concern.  It's possible to add two `Layout::size`s together without risking overflow now.

So take advantage of that to remove a bunch of checked math that's not actually needed.  For example, the round-up-and-add-next-size in `extend` doesn't need any overflow checks at all, just the final check for compatibility with the alignment.

(And while I was doing that I made it all unstably const, because there's nothing in `Layout` that's fundamentally runtime-only.)
2024-09-18 07:05:14 +00:00
Matthias Krüger d20649e79d
Rollup merge of #130499 - ibraheemdev:libs-review, r=Noratrieb
Add myself to the libs review rotation
2024-09-18 09:03:53 +02:00
Matthias Krüger 7e67d90213
Rollup merge of #130468 - compiler-errors:bidi, r=Nadrieril
Make sure that def id <=> lang item map is bidirectional

Self-explanatory from assertion. Just makes sure of an invariant that I forgot to enforce when I added `LanguageItems::from_def_id`.
2024-09-18 09:03:53 +02:00
Matthias Krüger b21581d1cb
Rollup merge of #130466 - davidtwco:aarch64-transparent-test, r=jieyouxu
tests: add repr/transparent test for aarch64

Fixes #74396.

Moves `transparent-struct-ptr.rs` to `transparent-byval-struct-ptr.rs` and then adds a new `transparent-opaque-ptr.rs` for aarch64.
2024-09-18 09:03:52 +02:00
Ibraheem Ahmed f5223276bd
format 2024-09-18 01:10:16 -04:00
Ibraheem Ahmed 99ea16af1a
add myself to the libs review rotation 2024-09-18 01:07:30 -04:00
bors f6bcd094ab Auto merge of #130498 - matthiaskrgr:rollup-tg4d0zi, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #130116 (Implement a Method to Seal `DiagInner`'s Suggestions)
 - #130489 (Ensure that `keyword_ident` lint doesn't trigger on `'r#kw` lifetime)
 - #130491 (more crash tests)
 - #130496 (Fix circular fn_sig queries to correct number of args for methods)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-18 04:01:51 +00:00
Scott McMurray 18ca8bf8ee Take more advantage of the `isize::MAX` limit in `Layout`
Things like `padding_needed_for` are current implemented being super careful to handle things like `Layout::size` potentially being `usize::MAX`.

But now that 95295 has happened, that's no longer a concern.  It's possible to add two `Layout::size`s together without risking overflow now.

So take advantage of that to remove a bunch of checked math that's not actually needed.  For example, the round-up-and-add-next-size in `extend` doesn't need any overflow checks at all, just the final check for compatibility with the alignment.

(And while I was doing that I made it all unstably const, because there's nothing in `Layout` that's fundamentally runtime-only.)
2024-09-17 20:05:57 -07:00
Matthias Krüger c52d58dce1
Rollup merge of #130496 - jder:issue-130400, r=compiler-errors
Fix circular fn_sig queries to correct number of args for methods

Fixes #130400. This was a [debug assert](28e8f01c2a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs (L2557)) added to some argument error reporting code in #129320 which verified that the number of params (from the HIR) matched the `matched_inputs` which ultimately come from ty::FnSig. In the reduced test case:

```
fn foo(&mut self) -> _ {
    foo()
}
```

There is a circular dependency computing the ty::FnSig -- when trying to compute it, we try to figure out the return value, which again depends on this ty::FnSig. In #105162, this was supported by short-circuiting the cycle by synthesizing a FnSig with error types for parameters. The [code in question](https://github.com/rust-lang/rust/pull/105162/files#diff-a65feec6bfffb19fbdc60a80becd1030c82a56c16b177182cd277478fdb04592R44) computes the number of parameters by taking the number of parameters from the hir::FnDecl and adding 1 if there is an implicit self parameter.

I might be missing a subtlety here, but AFAICT the adjustment for implicit self args is unnecessary and results in one too many args. For example, for this non-errorful code:

```
trait Foo {
    fn bar(&self) {}
}
```

The resulting hir::FnDecl and ty::FnSig both have the same number of inputs -- 1. So, this PR removes that adjustment and adds a test for the debug ICE.

r? `@compiler-errors`
2024-09-18 04:42:32 +02:00
Matthias Krüger 862f3e7685
Rollup merge of #130491 - matthiaskrgr:sehsarc, r=compiler-errors
more crash tests

r? `@compiler-errors`
2024-09-18 04:42:32 +02:00
Matthias Krüger 32c4d4112c
Rollup merge of #130489 - compiler-errors:raw-lt-lint, r=jieyouxu
Ensure that `keyword_ident` lint doesn't trigger on `'r#kw` lifetime

Fixes #130486
2024-09-18 04:42:31 +02:00
Matthias Krüger 09b255d3d4
Rollup merge of #130116 - veera-sivarajan:freeze-suggestions, r=chenyukang
Implement a Method to Seal `DiagInner`'s Suggestions

This PR adds a method on `DiagInner` called `.seal_suggestions()` to prevent new suggestions from being added while preserving existing suggestions.

This is useful because currently there is no way to prevent new suggestions from being added to a diagnostic. `.disable_suggestions()` is the closest but it gets rid of all suggestions before and after the call.

Therefore, `.seal_suggestions()` can be used when, for example, misspelled keyword is detected and reported. In such cases, we may want to prevent other suggestions from being added to the diagnostic, as they would likely be meaningless once the misspelled keyword is identified. For context: https://github.com/rust-lang/rust/pull/129899#discussion_r1741307132

To store an additional state, the type of the `suggestions` field in `DiagInner` was changed into a three variant enum. While this change affects files across different crates, care was taken to preserve the existing code's semantics. This is validated by the fact that all UI tests pass without any modifications.

r? chenyukang
2024-09-18 04:42:31 +02:00
Ben Kimock 46761442b0 read_volatile __rust_no_alloc_shim_is_unstable in alloc_zeroed 2024-09-17 22:26:21 -04:00
bors 60c3673456 Auto merge of #130454 - durin42:llvm-20-notrunc, r=workingjubilee
tests: allow trunc/select instructions to be missing

On LLVM 20, these instructions already get eliminated, which at least partially satisfies a TODO. I'm not talented enough at using FileCheck to try and constrain this further, but if we really want to we could copy an LLVM 20 specific version of this test that would restore it to being CHECK-NEXT: insertvalue ...

`@rustbot` label: +llvm-main
r? `@DianQK`
2024-09-18 01:27:26 +00:00