Commit Graph

48471 Commits

Author SHA1 Message Date
Jubilee
4d1ded8768 Rollup merge of #142449 - oli-obk:missing-mgca-args, r=BoxyUwU
Require generic params for const generic params

I think that was just an oversight when the support for them was added

r? `@BoxyUwU` or `@camelid`

fixes rust-lang/rust#137188
fixes rust-lang/rust#138166
fixes rust-lang/rust#138240
fixes rust-lang/rust#138266
fixes rust-lang/rust#138359
2025-06-13 20:59:19 -07:00
Jubilee
c3537c2f9e Rollup merge of #142441 - compiler-errors:lazier-binder-value-folding, r=lcnr
Delay replacing escaping bound vars in `FindParamInClause`

By uplifting the `BoundVarReplacer`, which is used by (e.g.) normalization to replace escaping bound vars that are encountered when folding binders, we can use a similar strategy to delay the instantiation of a binder's contents in the `FindParamInClause` used by the new trait solver.

This should alleviate the recently added requirement that `Binder<T>: TypeVisitable` only if `T: TypeFoldable`, which was previously required b/c we were calling `enter_forall` so that we could structurally normalize aliases that we found within the predicates of a param-env clause.

r? lcnr
2025-06-13 20:59:19 -07:00
Jubilee
179bcf6805 Rollup merge of #142405 - oli-obk:type-once, r=RalfJung
Don't hardcode the intrinsic return types twice in the compiler

We already manually check intrinsic types in intrinsicck so we don't need to do it in the interpreter
2025-06-13 20:59:17 -07:00
Jubilee
4db9554358 Rollup merge of #142302 - JonathanBrouwer:invalid-const-token, r=jdonszelmann
Rework how the disallowed qualifier in function type diagnostics are generated

This pull request fixes two independent issues:
1. When qualifiers of a function type ptr are in the wrong order and one of them is async/const (not permitted on function types), the diagnostic suggests removing the incorrect qualifier.  Fixes https://github.com/rust-lang/rust/issues/142268, which is an issue created by https://github.com/rust-lang/rust/pull/133151. This is fixed by moving the check into `parse_fn_front_matter`, where better span information is available to generate the right suggestions.
2. When qualifiers of a function type ptr are in the wrong order and one of them is async/const (not permitted on function types), `cargo fix` crashes because "cannot replace slice of data that was already replaced". This is fixed by not generating a suggestion for the "wrong order" diagnostic if the "disallowed qualifier" diagnostic is triggered.

There is a commit with failing tests so the test diff is clearer
r? `@jdonszelmann`
2025-06-13 20:59:17 -07:00
Jubilee
efc55fac53 Rollup merge of #141352 - lcnr:no-builtin-preference, r=compiler-errors
builtin dyn impl no guide inference

cc https://github.com/rust-lang/rust/pull/141347

we can already slightly restrict this behavior in the old solver, so why not do so. Needs crater and an FCP.

r? `@compiler-errors`
2025-06-13 20:59:15 -07:00
Jubilee
94dfe49e9a Rollup merge of #140969 - Stypox:logger-layer, r=RalfJung,oli-obk
Allow initializing logger with additional tracing Layer

This PR adds functions to the `rustc_log` and `rustc_driver_impl` crates to allow initializing the logger with an additional `tracing_subscriber::Layer`. This will be used in Miri to save trace events to file using e.g. [`tracing-chrome`](https://github.com/thoren-d/tracing-chrome)'s or [`tracing-tracy`](https://github.com/nagisa/rust_tracy_client)'s `Layer`s.

Additional context on the choice of signature can be found in [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Adding.20a.20dependency.20to.20Miri.20that.20depends.20on.20a.20rustc.20dep/near/515707776).

I re-exported `tracing_subscriber::{Layer, Registry};` from `rustc_log` so that `rustc_driver_impl` can use them in the function signature without depending on `tracing_subscriber` directly. I did this to avoid copy-pasting the dependency line with all of the enabled features from the `rustc_log` to the `rustc_driver_impl`'s Cargo.toml, which would have possibly led to redundancies and inconsistencies.

r? `@RalfJung`
2025-06-13 20:59:14 -07:00
WANG Rui
c49ec83868 Add f16 inline asm support for LoongArch 2025-06-14 09:39:30 +08:00
David Tolnay
2171f89eb2 Reduce precedence of expressions that have an outer attr 2025-06-13 18:09:13 -07:00
bors
d087f112b7 Auto merge of #134841 - estebank:serde-attr-4, r=wesleywiser
Look at proc-macro attributes when encountering unknown attribute

```
error: cannot find attribute `sede` in this scope
  --> $DIR/missing-derive-2.rs:22:7
   |
LL |     #[sede(untagged)]
   |       ^^^^
   |
help: the derive macros `Deserialize` and `Serialize` accept the similarly named `serde` attribute
   |
LL |     #[serde(untagged)]
   |         +

error: cannot find attribute `serde` in this scope
  --> $DIR/missing-derive-2.rs:16:7
   |
LL |     #[serde(untagged)]
   |       ^^^^^
   |
note: `serde` is imported here, but it is a crate, not an attribute
  --> $DIR/missing-derive-2.rs:5:1
   |
LL | extern crate serde;
   | ^^^^^^^^^^^^^^^^^^^
help: `serde` is an attribute that can be used by the derive macros `Serialize` and `Deserialize`, you might be missing a `derive` attribute
   |
LL + #[derive(Serialize, Deserialize)]
LL | enum B {
   |
```

Partially address #47608. This PR doesn't find [macros that haven't yet been imported by name](af945cb86e).
2025-06-13 22:59:24 +00:00
Jonathan Brouwer
1d036f408e Fix incorrect suggestion when calling an associated type with a type anchor
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-14 00:08:28 +02:00
Rémy Rakic
2554f8f74d use MixedBitSet for borrows-in-scope computation
Some code can have a few thousand loans, and this bitset is better
suited to these somewhat sparse cases.

That includes a couple of rustc-perf benchmarks.
2025-06-13 18:01:32 +00:00
Michael Goulet
73c4863c6d Don't fold ExternalConstraintsData when it's empty 2025-06-13 17:57:25 +00:00
Michael Goulet
b138202002 TypeVisiting binders no longer requires TypeFolding its interior 2025-06-13 17:54:45 +00:00
Michael Goulet
da8d529820 Replace escaping bound vars in ty/ct visiting, not binder visiting 2025-06-13 17:54:45 +00:00
Michael Goulet
6fa6d0e097 Uplift BoundVarReplacer 2025-06-13 17:54:45 +00:00
Michael Goulet
fe92efaf31 Make connection between Placeholder and Bound a bit more clear in the type abstraction 2025-06-13 17:54:45 +00:00
Michael Goulet
86497e6376 Don't use BTreeMap for mapped_consts 2025-06-13 17:54:45 +00:00
bors
8da623945f Auto merge of #142443 - matthiaskrgr:rollup-l1l6d0v, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#128425 (Make `missing_fragment_specifier` an unconditional error)
 - rust-lang/rust#135927 (retpoline and retpoline-external-thunk flags (target modifiers) to enable retpoline-related target features)
 - rust-lang/rust#140770 (add `extern "custom"` functions)
 - rust-lang/rust#142176 (tests: Split dont-shuffle-bswaps along opt-levels and arches)
 - rust-lang/rust#142248 (Add supported asm types for LoongArch32)
 - rust-lang/rust#142267 (assert more in release in `rustc_ast_lowering`)
 - rust-lang/rust#142274 (Update the stdarch submodule)
 - rust-lang/rust#142276 (Update dependencies in `library/Cargo.lock`)
 - rust-lang/rust#142308 (Upgrade `object`, `addr2line`, and `unwinding` in the standard library)

Failed merges:

 - rust-lang/rust#140920 (Extract some shared code from codegen backend target feature handling)

r? `@ghost`
`@rustbot` modify labels: rollup

try-job: aarch64-apple
try-job: x86_64-msvc-1
try-job: x86_64-gnu
try-job: dist-i586-gnu-i586-i686-musl
try-job: test-various
2025-06-13 17:44:15 +00:00
Jonathan Brouwer
b131b6f630 Rework how the disallowed qualifier lints are generated
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-13 18:13:34 +02:00
Ralf Jung
963fdbc852 variadic functions: remove list of supported ABIs from error 2025-06-13 18:10:06 +02:00
lcnr
9c07e8ec80 remove unnecessary function arg 2025-06-13 16:36:48 +02:00
lcnr
64f9c47211 refactor reached_depth -> required_depth 2025-06-13 16:36:48 +02:00
lcnr
85fe615036 move stack into submodule 2025-06-13 16:34:37 +02:00
Oli Scherer
1d41c2c01c Merge unboxed trait object error suggestion into regular dyn incompat error 2025-06-13 13:54:06 +00:00
Jana Dönszelmann
6f5a717a6c collect delayed lints in hir_crate_items 2025-06-13 14:03:01 +02:00
bors
c359117819 Auto merge of #142442 - matthiaskrgr:rollup-6yodjfx, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#134847 (Implement asymmetrical precedence for closures and jumps)
 - rust-lang/rust#141491 (Delegate `<CStr as Debug>` to `ByteStr`)
 - rust-lang/rust#141770 (Merge `Cfg::render_long_html` and `Cfg::render_long_plain` methods common code)
 - rust-lang/rust#142069 (Introduce `-Zmacro-stats`)
 - rust-lang/rust#142158 (Tracking the old name of renamed unstable library features)
 - rust-lang/rust#142221 ([AIX] strip underlying xcoff object)
 - rust-lang/rust#142340 (miri: we can use apfloat's mul_add now)
 - rust-lang/rust#142379 (Add bootstrap option to compile a tool with features)
 - rust-lang/rust#142410 (intrinsics: rename min_align_of to align_of)
 - rust-lang/rust#142413 (rustc-dev-guide subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-13 11:42:31 +00:00
Oli Scherer
bb2b765702 Require generic params for const generic params 2025-06-13 07:48:00 +00:00
Mara Bos
e71a93b5c2 Add comment. 2025-06-13 09:20:55 +02:00
Mara Bos
99929fa9e6 Implement temporary lifetime extension for tuple ctors. 2025-06-13 09:04:12 +02:00
bors
015c7770ec Auto merge of #142432 - matthiaskrgr:rollup-ziuls9y, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#138016 (Added `Clone` implementation for `ChunkBy`)
 - rust-lang/rust#141162 (refactor  `AttributeGate` and `rustc_attr!` to emit notes during feature checking)
 - rust-lang/rust#141474 (Add `ParseMode::Diagnostic` and fix multiline spans in diagnostic attribute lints)
 - rust-lang/rust#141947 (Specify that "option-like" enums must be `#[repr(Rust)]` to be ABI-compatible with their non-1ZST field.)
 - rust-lang/rust#142252 (Improve clarity of `core::sync::atomic` docs about "Considerations" in regards to CAS operations)
 - rust-lang/rust#142337 (miri: add flag to suppress float non-determinism)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-13 05:09:09 +00:00
Matthias Krüger
6a09b67bdc Rollup merge of #142267 - workingjubilee:debug-assert-less-in-ast-lowering, r=oli-obk
assert more in release in `rustc_ast_lowering`

My understanding of the compiler's architecture is that in the `ast_lowering` crate, we are constructing the HIR as a one-time thing per crate. This is after tokenizing, parsing, resolution, expansion, possible reparsing, reresolution, reexpansion, and so on. In other words, there are many reasons that perf-focused PRs spend a lot of time touching `rustc_parse`, `rustc_expand`, `rustc_ast`, and then `rustc_hir` and "onwards", but `ast_lowering` is a little bit of an odd duck.

In this crate, we have a number of debug assertions. Some are clearly expensive checks that seem like they are prohibitive to run in actual optimized compiler builds, but then there are a number that are simple asserts on integer equalities, `is_empty`, or the like. I believe we should do some of them even in release builds, because the correctness gain is worth the performance cost: almost zero.
2025-06-13 05:19:16 +02:00
Matthias Krüger
f6b02bbfa3 Rollup merge of #142248 - heiher:loong32-asm-types, r=Amanieu
Add supported asm types for LoongArch32

r? ``````@Amanieu``````
2025-06-13 05:19:15 +02:00
Matthias Krüger
7c3b2e5254 Rollup merge of #140770 - folkertdev:custom-abi, r=tgross35
add `extern "custom"` functions

tracking issue: rust-lang/rust#140829
previous discussion: https://github.com/rust-lang/rust/issues/140566

In short, an `extern "custom"` function is a function with a custom ABI, that rust does not know about. Therefore, such functions can only be defined with `#[unsafe(naked)]` and `naked_asm!`, or via an `extern "C" { /* ... */ }` block. These functions cannot be called using normal rust syntax: calling them can only be done from inline assembly.

The motivation is low-level scenarios where a custom calling convention is used. Currently, we often pick `extern "C"`, but that is a lie because the function does not actually respect the C calling convention.

At the moment `"custom"` seems to be the name with the most support. That name is not final, but we need to pick something to actually implement this.

r? `@traviscross`
cc `@tgross35`

try-job: x86_64-apple-2
2025-06-13 05:19:14 +02:00
Matthias Krüger
1a865fbe4e Rollup merge of #135927 - azhogin:azhogin/retpoline, r=davidtwco
retpoline and retpoline-external-thunk flags (target modifiers) to enable retpoline-related target features

`-Zretpoline` and `-Zretpoline-external-thunk` flags are target modifiers (tracked to be equal in linked crates).
* Enables target features for `-Zretpoline-external-thunk`:
`+retpoline-external-thunk`, `+retpoline-indirect-branches`, `+retpoline-indirect-calls`.
* Enables target features for `-Zretpoline`:
`+retpoline-indirect-branches`, `+retpoline-indirect-calls`.

It corresponds to clang -mretpoline & -mretpoline-external-thunk flags.

Also this PR forbids to specify those target features manually (warning).

Issue: rust-lang/rust#116852
2025-06-13 05:19:13 +02:00
Matthias Krüger
8002683e99 Rollup merge of #128425 - tgross35:missing-fragment-specifier-unconditional, r=petrochenkov,traviscross
Make `missing_fragment_specifier` an unconditional error

This was attempted in [1] then reverted in [2] because of fallout. Recently, this was made an edition-dependent error in [3].

Make missing fragment specifiers an unconditional error again, across all editions.

More context: https://github.com/rust-lang/rust/pull/128006
Most recent crater: https://github.com/rust-lang/rust/pull/128425#issuecomment-2686949847
Fixes: https://github.com/rust-lang/rust/issues/40107

[1]: https://github.com/rust-lang/rust/pull/75516
[2]: https://github.com/rust-lang/rust/pull/80210
[3]: https://github.com/rust-lang/rust/pull/128006
2025-06-13 05:19:13 +02:00
Matthias Krüger
86e9995e7a Rollup merge of #142410 - RalfJung:align_of, r=WaffleLapkin,workingjubilee
intrinsics: rename min_align_of to align_of

Now that `pref_align_of` is gone (https://github.com/rust-lang/rust/pull/141803), we can give the intrinsic backing `align_of` its proper name.

r? `@workingjubilee` or `@bjorn3`
2025-06-13 05:16:59 +02:00
Matthias Krüger
b24473cfd1 Rollup merge of #142221 - mustartt:aix-fix-strip-order, r=davidtwco
[AIX] strip underlying xcoff object

When stripping, we need to strip the archive member first before archiving. Otherwise, the shared library remain untouched, only the archive symbol table will be modified.
2025-06-13 05:16:57 +02:00
Matthias Krüger
fac011eb2d Rollup merge of #142158 - xizheyin:141617, r=jdonszelmann
Tracking the old name of renamed unstable library features

This PR resolves the first problem of rust-lang/rust#141617 : tracking renamed unstable features. The first commit is to add a ui test, and the second one tracks the changes. I will comment on the code for clarification.

r? `@jdonszelmann`
There have been a lot of PR's reviewed by you lately, thanks for your time!

cc `@jyn514`
2025-06-13 05:16:56 +02:00
Matthias Krüger
9639a7c522 Rollup merge of #142069 - nnethercote:Zmacro-stats, r=petrochenkov
Introduce `-Zmacro-stats`

Introduce `-Zmacro-stats`.

It collects data about macro expansions and prints them in a table after expansion finishes. It's very useful for detecting macro bloat, especially for proc macros.

r? `@petrochenkov`
2025-06-13 05:16:56 +02:00
Matthias Krüger
b12bb2530b Rollup merge of #134847 - dtolnay:asymmetrical, r=fmease
Implement asymmetrical precedence for closures and jumps

I have been through a series of asymmetrical precedence designs in Syn, and finally have one that I like and is worth backporting into rustc. It is based on just 2 bits of state: `next_operator_can_begin_expr` and `next_operator_can_continue_expr`.

Asymmetrical precedence is the thing that enables `(return 1) + 1` to require parentheses while `1 + return 1` does not, despite `+` always having stronger precedence than `return` [according to the Rust Reference](https://doc.rust-lang.org/1.83.0/reference/expressions.html#expression-precedence). This is facilitated by `next_operator_can_continue_expr`.

Relatedly, it is the thing that enables `(return) - 1` to require parentheses while `return + 1` does not, despite `+` and `-` having exactly the same precedence. This is facilitated by `next_operator_can_begin_expr`.

**Example:**

```rust
macro_rules! repro {
    ($e:expr) => {
        $e - $e;
        $e + $e;
    };
}

fn main() {
    repro!{return}
    repro!{return 1}
}
```

`-Zunpretty=expanded` **Before:**

```console
fn main() {
    (return) - (return);
    (return) + (return);
    (return 1) - (return 1);
    (return 1) + (return 1);
}
```

**After:**

```console
fn main() {
    (return) - return;
    return + return;
    (return 1) - return 1;
    (return 1) + return 1;
}
```
2025-06-13 05:16:54 +02:00
bors
ed44c0e3b3 Auto merge of #142353 - workingjubilee:warn-less-about-cdecl-and-other-abis, r=ChrisDenton,RalfJung
compiler: Ease off the accelerator on `unsupported_calling_conventions`

This is to give us more time to discuss rust-lang/rust#142330 without the ecosystem having an anxiety attack. I have withdrawn `unsupported_calling_conventions` from report-in-deps

I believe we should consider this a simple suspension of the decision in rust-lang/rust#141435 to start this process, rather than a reversal. That is, we may continue with linting again. But I believe we are about to get a... reasonable amount of feedback just from currently available information and should allow ourselves time to process it.
2025-06-13 02:06:04 +00:00
mejrs
c0e02e26b3 Unimplement unsized_locals 2025-06-13 01:16:36 +02:00
León Orell Valerian Liehr
3a31f62421 Use more slicing and slice interning over iterable interning 2025-06-13 01:16:01 +02:00
León Orell Valerian Liehr
a58fdd18a2 [perf] Change asserts to debug ones in trait_ref_and_own_args 2025-06-13 01:16:01 +02:00
bors
bb3a3c530c Auto merge of #142438 - matthiaskrgr:rollup-u1jdnhz, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#134536 (Lint on fn pointers comparisons in external macros)
 - rust-lang/rust#141069 (Suggest mut when possbile for temporary value dropped while borrowed)
 - rust-lang/rust#141934 (resolve: Tweak `private_macro_use` lint to be compatible with upcoming macro prelude changes)
 - rust-lang/rust#142034 (Detect method not being present that is present in other tuple types)
 - rust-lang/rust#142402 (chore(doctest): Remove redundant blank lines)
 - rust-lang/rust#142406 (Note when enum variants shadow an associated function)
 - rust-lang/rust#142407 (Remove bootstrap adhoc group)
 - rust-lang/rust#142408 (Add myself (WaffleLapkin) to review rotation)
 - rust-lang/rust#142418 (Remove lower_arg_ty as all callers were passing `None`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-12 23:05:49 +00:00
Esteban Küber
92a798dac0 Detect when attribute is provided by missing derive macro
```
error: cannot find attribute `empty_helper` in this scope
  --> $DIR/derive-helper-legacy-limits.rs:17:3
   |
LL | #[empty_helper]
   |   ^^^^^^^^^^^^
   |
help: `empty_helper` is an attribute that can be used by the derive macro `Empty`, you might be missing a `derive` attribute
   |
LL + #[derive(Empty)]
LL | struct S2;
   |
```

Look at proc-macro attributes when encountering unknown attribute

```
error: cannot find attribute `sede` in this scope
  --> src/main.rs:18:7
   |
18 |     #[sede(untagged)]
   |       ^^^^
   |
help: the derive macros `Serialize` and `Deserialize` accept the similarly named `serde` attribute
   |
18 |     #[serde(untagged)]
   |       ~~~~~

error: cannot find attribute `serde` in this scope
  --> src/main.rs:12:7
   |
12 |     #[serde(untagged)]
   |       ^^^^^
   |
   = note: `serde` is in scope, but it is a crate, not an attribute
help: `serde` is an attribute that can be used by the derive macros `Serialize` and `Deserialize`, you might be missing a `derive` attribute
   |
10 | #[derive(Serialize, Deserialize)]
   |
```
2025-06-12 21:28:49 +00:00
Matthias Krüger
7309c103ba Rollup merge of #142418 - oli-obk:lower_arg_ty, r=BoxyUwU,fmease
Remove lower_arg_ty as all callers were passing `None`

r? ``@fmease`` or ``@BoxyUwU``

I think this is just leftover from other refactorings
2025-06-12 22:09:46 +02:00
Matthias Krüger
7cd6944458 Rollup merge of #142406 - jdonszelmann:dead-code-enum-variant, r=WaffleLapkin
Note when enum variants shadow an associated function

r? ``@WaffleLapkin``

Closes rust-lang/rust#142263
2025-06-12 22:09:44 +02:00
Matthias Krüger
c77191f46b Rollup merge of #142034 - estebank:issue-141258, r=davidtwco
Detect method not being present that is present in other tuple types

When a method is not present because of a trait bound not being met, and that trait bound is on a tuple, we check if making the tuple have no borrowed types makes the method to be found and highlight it if it does. This is a common problem for Bevy in particular and ORMs in general.

<img width="1166" alt="Screenshot 2025-06-04 at 10 38 24 AM" src="https://github.com/user-attachments/assets/d257c9ea-c2d7-42e7-8473-8b93aa54b8e0" />

Address rust-lang/rust#141258. I believe that more combination of cases in the tuple types should be handled (like adding borrows and checking when a specific type needs to not be a borrow while the rest stay the same), but for now this handles the most common case.
2025-06-12 22:09:43 +02:00
Matthias Krüger
8b6d55e782 Rollup merge of #141934 - petrochenkov:privmacuse, r=compiler-errors
resolve: Tweak `private_macro_use` lint to be compatible with upcoming macro prelude changes

Unblocks https://github.com/rust-lang/rust/pull/139493.
Zulip thread requesting help - [#t-compiler/help > Help requested for effects of #139493](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/Help.20requested.20for.20effects.20of.20.23139493/with/514653911).

This PR by itself shouldn't cause any observable changes, its only observable effect is that the prelude changes from https://github.com/rust-lang/rust/pull/139493 will no longer cause regressions in tests like `tests/ui/imports/issue-119369.rs` or `tests/ui/extern/issue-80074.rs`.

This is achieved by moving the "is this thing in stdlib prelude" check from an early point (`fn process_macro_use_imports`) to a later point (`fn record_use_inner`), at which the stdlib prelude is already populated and can be inspected.
(The `is_builtin_macro` check is subsumed by the stdlib prelude check, all built-in macros go through the stdlib prelude anyway.)
2025-06-12 22:09:42 +02:00