Commit Graph

265983 Commits

Author SHA1 Message Date
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
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
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
Jesse Rusak 3cb1f334b8 Fix circular fn_sig queries to return the correct number of arguments for methods 2024-09-17 20:54:04 -04:00
bors f7b4c72c8f Auto merge of #130492 - matthiaskrgr:rollup-9pxkd8i, r=matthiaskrgr
Rollup of 2 pull requests

Successful merges:

 - #130481 (Remove uneeded PartialOrd bound in cmp::Ord::clamp)
 - #130482 (Remove redundant test typeid equality by subtyping)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-17 23:05:43 +00:00
Matthias Krüger 7e8eb7aa93
Rollup merge of #130482 - spastorino:remove-known-bug-97156, r=jackh726
Remove redundant test typeid equality by subtyping

This known-bug label was a left over on #118247

r? `@jackh726`

This doesn't address #110395, I didn't investigate about it yet.
2024-09-18 00:12:19 +02:00
Matthias Krüger 0a35418d34
Rollup merge of #130481 - krtab:clamp_partial_ord, r=cuviper
Remove uneeded PartialOrd bound in cmp::Ord::clamp

There is a `Self: PartialOrd` bound in `Ord::clamp`, but it is already required by the trait itself. Likely a left-over from the const trait deletion in 76dbe29104.

Reported-by: `@noeensarguet`
2024-09-18 00:12:19 +02:00
Matthias Krüger 12814c8aa5 more crash tests 2024-09-18 00:10:25 +02:00
Michael Goulet 5de89bb011 Store raw ident span for raw lifetime 2024-09-17 16:43:18 -04:00
bors 28e8f01c2a Auto merge of #130483 - matthiaskrgr:rollup-q1r0g0y, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #129477 (Fix fluent diagnostics)
 - #129674 (Add new_cyclic_in for Rc and Arc)
 - #130452 (Update Trusty target maintainers)
 - #130467 (Miri subtree update)
 - #130477 (Revert #129749 to fix segfault in LLVM)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-17 19:37:03 +00:00
Arthur Carcano 0c9a17689a Remove uneeded PartialOrd bound in cmp::Ord::clamp
There is a Self: PartialOrd bound in Ord::clamp, but it is already
required by the trait itself. Likely a left-over from the const trait
deletion in 76dbe29104.

Reported-by: @noeensarguet
2024-09-17 21:16:12 +02:00
Matthias Krüger f8090dda64
Rollup merge of #130477 - tmandry:revert-llvm-20-lto, r=tmandry
Revert #129749 to fix segfault in LLVM

This reverts commit 8c7a7e346b, reversing changes made to a00bd75b6c.

Reported in https://github.com/rust-lang/rust/pull/129749#issuecomment-2354417960. `@nikic's` theory is that the LLVM API changed in a way that makes it impossible to use concurrently from multiple threads (https://github.com/llvm/llvm-project/pull/106427#issuecomment-2354783802). I pinged `@krasimirgg` who was fine with reverting.

r? `@rust-lang/wg-llvm`
2024-09-17 20:45:51 +02:00
Matthias Krüger 90873122a7
Rollup merge of #130467 - RalfJung:miri-sync, r=RalfJung
Miri subtree update

r? `@ghost`
2024-09-17 20:45:51 +02:00
Matthias Krüger 084e93a1cf
Rollup merge of #130452 - randomPoison:trusty-update-maintainers, r=ehuss
Update Trusty target maintainers

Remove Stephen Crane from the list of Trusty target maintainers and add Andrei Homescu (`@ahomescu)` and Chris Wailes.
2024-09-17 20:45:50 +02:00
Matthias Krüger f6fd305282
Rollup merge of #129674 - matthewpipie:rc-arc-new-cyclic-in, r=dtolnay
Add new_cyclic_in for Rc and Arc

Currently, new_cyclic_in does not exist for Rc and Arc. This is an oversight according to https://github.com/rust-lang/wg-allocators/issues/132.

This PR adds new_cyclic_in for Rc and Arc. The implementation is almost the exact same as new_cyclic with some small differences to make it allocator-specific. new_cyclic's implementation has been replaced with a call to `new_cyclic_in(data_fn, Global)`.

Remaining questions:
* ~~Is requiring Allocator to be Clone OK? According to https://github.com/rust-lang/wg-allocators/issues/88, Allocators should be cheap to clone. I'm just hesitant to add unnecessary constraints, though I don't see an obvious workaround for this function since many called functions in new_cyclic_in expect an owned Allocator. I see Allocator.by_ref() as an option, but that doesn't work on when creating Weak { ptr: init_ptr, alloc: alloc.clone() }, because the type of Weak then becomes Weak<T, &A> which is incompatible.~~ Fixed, thank you `@zakarumych!` This PR no longer requires the allocator to be Clone.
* Currently, new_cyclic_in's documentation is almost entirely copy-pasted from new_cyclic, with minor tweaks to make it more accurate (e.g. Rc<T> -> Rc<T, A>). The example section is removed to mitigate redundancy and instead redirects to cyclic_in. Is this appropriate?
* ~~The comments in new_cyclic_in (and much of the implementation) are also copy-pasted from new_cyclic. Would it be better to make a helper method new_cyclic_in_internal that both functions call, with either Global or the custom allocator? I'm not sure if that's even possible, since the internal method would have to return Arc<T, Global> and I don't know if it's possible to "downcast" that to an Arc<T>. Maybe transmute would work here?~~ Done, thanks `@zakarumych`
* Arc::new_cyclic is #[inline], but Rc::new_cyclic is not. Which is preferred?
* nit: does it matter where in the impl block new_cyclic_in is defined?
2024-09-17 20:45:50 +02:00
Matthias Krüger 8b36ecba97
Rollup merge of #129477 - Xiretza:fix-fluent-diagnostics, r=compiler-errors
Fix fluent diagnostics

This line number calculation was both wrong and unnecessary.
2024-09-17 20:45:49 +02:00
Santiago Pastorino 65f8999026
Remove redundant test typeid equality by subtyping 2024-09-17 15:45:15 -03:00
bors f609b7e058 Auto merge of #130473 - matthiaskrgr:rollup-lf29374, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #128535 (Format `std::env::consts` docstrings with markdown backticks)
 - #128961 (Fix #128930: Print documentation of CLI options missing their arg)
 - #129988 (Use `Vec` in `rustc_interface::Config::locale_resources`)
 - #130201 (Encode `coroutine_by_move_body_def_id` in crate metadata)
 - #130275 (Don't call `extern_crate` when local crate name is the same as a dependency and we have a trait error)
 - #130314 (Use the same precedence for all macro-like exprs)
 - #130440 (Don't ICE in `opaque_hidden_inferred_bound` lint for RPITIT in trait with no default method body)
 - #130458 (`rustc_codegen_ssa` cleanups)
 - #130469 (Mark `where_clauses_object_safety` as removed)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-17 16:48:36 +00:00
Matthias Krüger 065690e186
Rollup merge of #130469 - compiler-errors:wc-obj-safety, r=jackh726
Mark `where_clauses_object_safety` as removed

r? lcnr
2024-09-17 17:28:35 +02:00
Matthias Krüger d5a081981d
Rollup merge of #130458 - nnethercote:rustc_codegen_ssa-cleanups, r=jieyouxu
`rustc_codegen_ssa` cleanups

Just some minor improvements I found while reading through this code.

r? ``@jieyouxu``
2024-09-17 17:28:35 +02:00
Matthias Krüger 02b1776cd3
Rollup merge of #130440 - compiler-errors:rpitit-opaque-hidden, r=jieyouxu
Don't ICE in `opaque_hidden_inferred_bound` lint for RPITIT in trait with no default method body

Inline comment should explain the fix.

Fixes #130422
2024-09-17 17:28:34 +02:00
Matthias Krüger c896f06bdb
Rollup merge of #130314 - compiler-errors:mac-prec, r=davidtwco
Use the same precedence for all macro-like exprs

No need to make these have a different precedence since they're all written like `whatever!(expr)`, and it makes it simpler when adding new macro-based built-in operators in the future.
2024-09-17 17:28:33 +02:00
Matthias Krüger 62f2ec9b59
Rollup merge of #130275 - compiler-errors:extern-crate, r=lcnr
Don't call `extern_crate` when local crate name is the same as a dependency and we have a trait error

#124944 implemented logic to point out when a trait bound failure involves a *trait* and *type* who come from identically named but different crates. This logic calls the `extern_crate` query which is not valid on `LOCAL_CRATE` cnum, so let's filter that out eagerly.

Fixes #130272
Fixes #129184
2024-09-17 17:28:33 +02:00
Matthias Krüger ddcb9c132a
Rollup merge of #130201 - compiler-errors:foreign-synthetic-body, r=lcnr
Encode `coroutine_by_move_body_def_id` in crate metadata

We synthesize the MIR for a by-move body for the `FnOnce` implementation of async closures. It can be accessed with the `coroutine_by_move_body_def_id` query. We weren't encoding this query in the metadata though, nor were we properly recording that synthetic MIR in `mir_keys`, so the `optimized_mir` wasn't getting encoded either!

Stacked on top is a fix to consider `DefKind::SyntheticCoroutineBody` to return true in several places I missed. Specifically, we should consider the def-kind in `fn DefKind::is_fn_like()`, since that's what we were using to make sure we ensure `query mir_inliner_callees` before the MIR gets stolen for the body. This led to some CI failures that were caught by miri but which I added a test for.
2024-09-17 17:28:32 +02:00
Matthias Krüger 732ad59779
Rollup merge of #129988 - arnaudgolfouse:modify-locale_resources, r=davidtwco
Use `Vec` in `rustc_interface::Config::locale_resources`

This allows a third-party tool to injects its own resources, when receiving the config via `rustc_driver::Callbacks::config`.
2024-09-17 17:28:32 +02:00
Matthias Krüger fe3428d9ac
Rollup merge of #128961 - GKFX:issue-128930-explain-missing-option, r=jieyouxu
Fix #128930: Print documentation of CLI options missing their arg

Fix #128930. Failing to give an argument to CLI options which require it now prints something like:
```
$ rustc --print
error: Argument to option 'print' missing
       Usage:
           --print [crate-name|file-names|sysroot|target-libdir|cfg|check-cfg|calling-conventions|target-list|target-cpus|target-features|relocation-models|code-models|tls-models|target-spec-json|all-target-specs-json|native-static-libs|stack-protector-strategies|link-args|deployment-target]
                               Compiler information to print on stdout
```
2024-09-17 17:28:31 +02:00
Matthias Krüger 11fe22c3fb
Rollup merge of #128535 - mmvanheusden:master, r=workingjubilee
Format `std::env::consts` docstrings with markdown backticks

This clarifies possible outputs the constants might be.

**Before:**
--
<img src="https://github.com/user-attachments/assets/8ee8772a-7562-42a2-89be-f8772b76dbd5" width="500px">

**After:**
--
<img src="https://github.com/user-attachments/assets/4632e5e2-db3e-4372-b13e-006cc1701eb1" width="500px">
2024-09-17 17:28:31 +02:00
Kyle Huey 930db09236 Add zlib to musl dist image so rust-lld will support zlib compression for debug info there.
Fixes #130063.
2024-09-17 08:10:44 -07:00
Xiretza 5b3bde953e fluent_macro: fix diagnostics for fluent parse failures
This line number calculation was both wrong and unnecessary.
2024-09-17 14:49:33 +00:00
Xiretza 0a253246f7 Add test for fluent diagnostics 2024-09-17 14:47:57 +00:00
Michael Goulet 1c3b03a170 Mark where_clauses_object_safety as removed 2024-09-17 09:44:27 -04:00
Michael Goulet d9624ed16c Make sure that def id <=> lang item map is bidirectional 2024-09-17 09:41:12 -04:00
Ralf Jung ba86cf8686 update lockfile 2024-09-17 15:20:50 +02:00
Augie Fackler 9692513b7e 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
2024-09-17 08:55:26 -04:00