Commit Graph

48471 Commits

Author SHA1 Message Date
Jakub Beránek
c9d305952e Add infrastructure for emitting timing sections 2025-06-16 11:51:17 +02:00
Jakub Beránek
7ad5248c95 Add parsing of --json=timings 2025-06-16 11:28:42 +02:00
beetrees
5723c9997c Fix RISC-V C function ABI when passing/returning structs containing floats 2025-06-16 10:14:07 +01:00
NotLebedev
7ce7fc56b8 Implement Stable for Discr 2025-06-16 10:51:58 +03:00
NotLebedev
d4de03208b Add discriminant_for_variant to CoroutineDef 2025-06-16 10:51:57 +03:00
NotLebedev
94f7790b19 Add discriminant_for_variant to AdtDef 2025-06-16 10:51:47 +03:00
xizheyin
ade2ad9d52 Add documentation on top of rustc_middle/src/query/mod.rs
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-16 15:39:32 +08:00
Nicholas Nethercote
87456e15b2 Remove an njn: comment accidentaly left behind. 2025-06-16 15:18:48 +10:00
bors
68ac5abb06 Auto merge of #142521 - sayantn:simplify-intrinsics, r=nikic,workingjubilee
Use `LLVMIntrinsicGetDeclaration` to completely remove the hardcoded intrinsics list

Follow-up to rust-lang/rust#142259

This also needs a rustc-perf run, because `Intrinsic::getType` can be expensive

`@rustbot` label A-LLVM A-codegen T-compiler
r? `@workingjubilee`
cc `@nikic`
2025-06-16 03:40:18 +00:00
bors
e314b97ee5 Auto merge of #142550 - fmease:rollup-fteyzcv, r=fmease
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#133952 (Remove wasm legacy abi)
 - rust-lang/rust#134661 (Reduce precedence of expressions that have an outer attr)
 - rust-lang/rust#141769 (Move metadata object generation for dylibs to the linker code )
 - rust-lang/rust#141937 (Report never type lints in dependencies)
 - rust-lang/rust#142347 (Async drop - fix for StorageLive/StorageDead codegen for pinned future)
 - rust-lang/rust#142389 (Apply ABI attributes on return types in `rustc_codegen_cranelift`)
 - rust-lang/rust#142470 (Add some missing mailmap entries)
 - rust-lang/rust#142481 (Add `f16` inline asm support for LoongArch)
 - rust-lang/rust#142499 (Remove check run bootstrap)
 - rust-lang/rust#142543 (Suggest adding semicolon in user code rather than macro impl details)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-16 00:39:47 +00:00
Nicholas Nethercote
248b7a9490 Fix PathSource lifetimes.
It currently has two, which don't accurately capture what's happening --
the `TupleStruct` spans are allocated in `ResolverArenas`, which is
different to where the `Expr` is allocated -- and require some
"outlives" constraints to be used.

This commit adds another lifetime, renames the existing ones, and
removes the "outlives" constraints.
2025-06-16 10:33:00 +10:00
León Orell Valerian Liehr
07048643dd Rollup merge of #142543 - Urgau:span-borrowck-semicolon, r=fmease
Suggest adding semicolon in user code rather than macro impl details

This PR tries to find the right span (by peeling expansion) so that the suggestion for adding a semicolon is suggested in user code rather than in the expanded code (in the example a macro impl).

Fixes rust-lang/rust#139049
r? `@fmease`
2025-06-15 23:51:58 +02:00
León Orell Valerian Liehr
5cce691c5a Rollup merge of #142481 - heiher:loong-asm-f16, r=Amanieu
Add `f16` inline asm support for LoongArch

r? `````@Amanieu`````
2025-06-15 23:51:57 +02:00
León Orell Valerian Liehr
16152661ff Rollup merge of #142389 - beetrees:cranelift-arg-ext, r=bjorn3
Apply ABI attributes on return types in `rustc_codegen_cranelift`

- The [x86-64 System V ABI standard](https://gitlab.com/x86-psABIs/x86-64-ABI/-/jobs/artifacts/master/raw/x86-64-ABI/abi.pdf?job=build) doesn't sign/zero-extend integer arguments or return types.
- But the de-facto standard as implemented by Clang and GCC is to sign/zero-extend arguments to 32 bits (but not return types).
- Additionally, Apple targets [sign/zero-extend both arguments and return values to 32 bits](https://developer.apple.com/documentation/xcode/writing-64-bit-intel-code-for-apple-platforms#Pass-arguments-to-functions-correctly).
- However, the `rustc_target` ABI adjustment code currently [unconditionally extends both arguments and return values to 32 bits](e703dff8fe/compiler/rustc_target/src/callconv/x86_64.rs (L240)) on all targets.
- This doesn't cause a miscompilation when compiling with LLVM as LLVM will ignore the `signext`/`zeroext` attribute when applied to return types on non-Apple x86-64 targets.
- Cranelift, however, does not have a similar special case, requiring `rustc` to set the argument extension attribute correctly.
- However, `rustc_codegen_cranelift` doesn't currently apply ABI attributes to return types at all, meaning `rustc_codegen_cranelift` will currently miscompile `i8`/`u8`/`i16`/`u16` returns on x86-64 Apple targets as those targets require sign/zero-extension of return types.

This PR fixes the bug(s) by making the `rustc_target` x86-64 System V ABI only mark return types as sign/zero-extended on Apple platforms, while also making `rustc_codegen_cranelift` apply ABI attributes to return types. The RISC-V and s390x C ABIs also require sign/zero extension of return types, so this will fix those targets when building with `rustc_codegen_cranelift` too.

r? `````@bjorn3`````
2025-06-15 23:51:56 +02:00
León Orell Valerian Liehr
e06196da5b Rollup merge of #142347 - azhogin:azhogin/async-drop-storage-live-dead-fix, r=oli-obk
Async drop - fix for StorageLive/StorageDead codegen for pinned future

Fixes: rust-lang/rust#140429, Fixes: rust-lang/rust#140531, Fixes: rust-lang/rust#141761, Fixes: rust-lang/rust#141409.

StorageLive/StorageDead codegen is corrected for pinned async drop future.
2025-06-15 23:51:56 +02:00
León Orell Valerian Liehr
8b35ae3a22 Rollup merge of #141937 - WaffleLapkin:never-report-in-deps, r=oli-obk,traviscross
Report never type lints in dependencies

This PR marks never type lints (`never_type_fallback_flowing_into_unsafe` & `dependency_on_unit_never_type_fallback`) to be included in cargo's reports / to be emitted when they happen in dependencies.

This PR is based on rust-lang/rust#141936
r? oli-obk
2025-06-15 23:51:55 +02:00
León Orell Valerian Liehr
0b249d3f85 Rollup merge of #141769 - bjorn3:codegen_metadata_module_rework, r=workingjubilee,saethlin
Move metadata object generation for dylibs to the linker code

This deduplicates some code between codegen backends and may in the future allow adding extra metadata that is only known at link time.

Prerequisite of https://github.com/rust-lang/rust/issues/96708.
2025-06-15 23:51:54 +02:00
León Orell Valerian Liehr
b79d3b1ec1 Rollup merge of #134661 - dtolnay:prefixattr, r=fmease
Reduce precedence of expressions that have an outer attr

Previously, `-Zunpretty=expanded` would expand this program as follows:

```rust
#![feature(stmt_expr_attributes)]

macro_rules! repro {
    ($e:expr) => {
        #[allow(deprecated)] $e
    };
}

#[derive(Default)]
struct Thing {
    #[deprecated]
    field: i32,
}

fn main() {
    let thing = Thing::default();
    let _ = repro!(thing).field;
}
```

```rs
#![feature(prelude_import)]
#![feature(stmt_expr_attributes)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;

struct Thing {
    #[deprecated]
    field: i32,
}

#[automatically_derived]
impl ::core::default::Default for Thing {
    #[inline]
    fn default() -> Thing {
        Thing { field: ::core::default::Default::default() }
    }
}

fn main() {
    let thing = Thing::default();
    let _ = #[allow(deprecated)] thing.field;
}
```

This is not the correct expansion. The correct output would have `(#[allow(deprecated)] thing).field` with the attribute applying only to `thing`, not to `thing.field`.
2025-06-15 23:51:54 +02:00
León Orell Valerian Liehr
d6dc9656ea Rollup merge of #133952 - bjorn3:remove_wasm_legacy_abi, r=alexcrichton
Remove wasm legacy abi

Closes https://github.com/rust-lang/rust/issues/122532
Closes https://github.com/rust-lang/rust/issues/138762
Fixes https://github.com/rust-lang/rust/issues/71871
https://github.com/rust-lang/rust/issues/88152
Fixes https://github.com/rust-lang/rust/issues/115666
Fixes https://github.com/rust-lang/rust/issues/129486
2025-06-15 23:51:53 +02:00
bors
f768dc01da Auto merge of #142471 - lqd:sparse-borrows, r=nnethercote
use `MixedBitSet` for borrows-in-scope dataflow analysis

The `Borrows` dataflow analysis uses a dense bitset, but a bitset supporting _some_ amount of sparseness is better suited for big functions with a big number of loans.

The cutoff between dense and chunked bitset is around 2K loans IIRC, and we could finesse that value if we wanted to, but as-is it happens to a couple of rustc-perf benchmarks (which IIRC are at least partially generated from macros and the likes.). It's a small win on these two, and shouldn't have any impact on the others.

r? `@matthewjasper`
2025-06-15 21:38:13 +00:00
Camille GILLOT
89b079d844 Only traverse reachable blocks in JumpThreading. 2025-06-15 21:12:17 +00:00
Urgau
6ff3713e0f Suggest adding semicolon in user code rather than macro impl details 2025-06-15 20:03:46 +02:00
sayantn
a9500d6b0b Correctly account for different address spaces in LLVM intrinsic invocations 2025-06-15 22:45:26 +05:30
bors
586ad391f5 Auto merge of #142455 - jdonszelmann:attempt-to-mitigate-delayed-lint-perf-problems, r=oli-obk
collect delayed lints in hir_crate_items

r? `@oli-obk`

Attempt to mitigate perf problems in rust-lang/rust#138164
2025-06-15 16:52:31 +00:00
sayantn
9415f3d8a6 Use LLVMIntrinsicGetDeclaration to completely remove the hardcoded intrinsics list 2025-06-15 22:15:16 +05:30
Camille GILLOT
a16b49bb93 Manually invalidate caches in SimplifyCfg. 2025-06-15 15:30:14 +00:00
Urgau
268fbfed47 Un-remap rustc-dev component paths 2025-06-15 17:20:08 +02:00
bors
7827d55852 Auto merge of #142430 - compiler-errors:external-constraints, r=lcnr
Don't fold `ExternalConstraintsData` when it's empty

Probably useless, but let's see.

r? lcnr
2025-06-15 12:55:05 +00:00
Deadbeef
a0db28f37c clarify rustc_do_not_const_check comment 2025-06-15 20:40:08 +08:00
xizheyin
1ac89f190f Refactor rustc_attr_data_structures documentation
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-15 20:04:33 +08:00
bors
75e7cf5f85 Auto merge of #142398 - fee1-dead-contrib:push-ynxrtswtkyxw, r=oli-obk
early linting: avoid redundant calls to `check_id`

An attempt to address the regression at https://github.com/rust-lang/rust/pull/142240#issuecomment-2964425460

r? `@oli-obk`

cc `@nnethercote` who might have a better understanding of the performance implications
2025-06-15 09:17:15 +00:00
Deadbeef
96fd9fc2dd use if let guards where possible 2025-06-15 15:46:20 +08:00
bors
0cbc076438 Auto merge of #142388 - cjgillot:span-hash, r=davidtwco
Do not clone Arc when hashing span.

Tiny improvement I was when trying to profile span hashing.
2025-06-15 05:27:08 +00:00
Frank King
afdb54a673 Move the place in &pin mut $place when !Unpin to ensure soundness 2025-06-15 10:31:11 +08:00
bors
32b51523f8 Auto merge of #142355 - lcnr:fast_reject-reject, r=BoxyUwU
move fast reject into inner

to also fast reject inside of the folder

r? `@BoxyUwU`
2025-06-15 02:25:15 +00:00
Frank King
e627f88f88 Implement pinned borrows, part of pin_ergonomics 2025-06-15 10:21:29 +08:00
sayantn
2ffa1dd392 Implement simd_round_ties_even for miri, cg_clif and cg_gcc 2025-06-15 04:33:56 +05:30
sayantn
2038405ff7 Add simd_funnel_sh{l,r} and simd_round_ties_even 2025-06-15 04:33:41 +05:30
bors
49a8ba0684 Auto merge of #142289 - fmease:maybe-perf-gen-args, r=compiler-errors
[perf] `GenericArgs`-related: Change asserts to debug asserts & use more slice interning over iterable interning

1. The 1st commit yields the following perf gains: [#142289 (comment)](https://github.com/rust-lang/rust/pull/142289#issuecomment-2964041303).
2. The 2nd commit might also have a minor positive perf impact, however that one wasn't tested in isolation.

For reference, the initial approach c7e6accd79 (results: https://github.com/rust-lang/rust/pull/142289#issuecomment-2961076587) had a lot more changes (apart from what's now contained in commit 1 and 2) which seemed to be perf irrelevant (cf. the partial countercheck in 6f82bf1cfe (results: https://github.com/rust-lang/rust/pull/142289#issuecomment-2968393647).
2025-06-14 19:42:04 +00:00
bors
cc87afd8c0 Auto merge of #142259 - sayantn:simplify-intrinsics, r=workingjubilee
Simplify implementation of Rust intrinsics by using type parameters in the cache

The current implementation of intrinsics have a lot of duplication to handle different overloads of overloaded LLVM intrinsic. This PR uses the **base name and the type parameters** in the cache instead of the full, overloaded name. This has the benefit that `call_intrinsic` doesn't need to provide the full name, rather the type parameters (which is most of the time more available). This uses `LLVMIntrinsicCopyOverloadedName2` to get the overloaded name from the base name and the type parameters, and only uses it to declare the function.

(originally was part of rust-lang/rust#140763, split off later)

`@rustbot` label A-codegen A-LLVM
r? codegen
2025-06-14 16:43:34 +00:00
Urgau
810d99e7b5 Prepare rustc-dev component un-remapping in the compiler 2025-06-14 15:24:28 +02:00
bors
4a73e3c224 Auto merge of #142129 - shepmaster:mismatched-syntaxes-in-function-like-places, r=jieyouxu
Apply `mismatched-lifetime-syntaxes` to trait and extern functions

r? `@jieyouxu`
2025-06-14 12:37:35 +00:00
bjorn3
3e944fa391 Remove all support for wasm's legacy ABI 2025-06-14 09:57:06 +00:00
Matthias Krüger
4bf7765388 Rollup merge of #142477 - JonathanBrouwer:associated-type-suggestion, r=WaffleLapkin
Fix incorrect suggestion when calling an associated type with a type anchor

`sugg_span` here is the span of the call expression.
That span here is the `<Self>::Assoc`, which is exactly what we need here (even though I would expect it to include the arguments, but I guess it doesn't)

r? ``@WaffleLapkin``
One commit with failing tests and one that fixes it for reviewability

closes rust-lang/rust#142473
2025-06-14 11:27:12 +02:00
Matthias Krüger
fe54c3a5eb Rollup merge of #142464 - RalfJung:variadic-fn-abi-error, r=workingjubilee
variadic functions: remove list of supported ABIs from error

I think this list is problematic for multiple reasons:
- It is bound to go out-of-date as it is in a very different place from where we actually define which functions support varagrs (`fn supports_varargs`).
- Many of the ABIs we list only work on some targets; it makes no sense to mention "aapcs" as a possible ABI when building for x86_64. (This led to a lot of confusion in https://github.com/rust-lang/rust/issues/110505 where the author thought they should use "cdecl" and then were promptly told that "cdecl" is not a legal ABI on their target.)
- Typically, when the programmer wrote `extern "foobar"`, it is because they need the "foobar" ABI. It is of little use to tell them that there are other ABIs with which varargs would work.

Cc ``@workingjubilee``
2025-06-14 11:27:11 +02:00
Matthias Krüger
db23a76217 Rollup merge of #141811 - mejrs:bye_locals, r=compiler-errors
Unimplement unsized_locals

Implements https://github.com/rust-lang/compiler-team/issues/630

Tracking issue here: https://github.com/rust-lang/rust/issues/111942

Note that this just removes the feature, not the implementation, and does not touch `unsized_fn_params`. This is because it is required to support `Box<dyn FnOnce()>: FnOnce()`.

There may be more that should be removed (possibly in follow up prs)
- the `forget_unsized` function and `forget` intrinsic.
- the `unsized_locals` test directory; I've just fixed up the tests for now
- various codegen support for unsized values and allocas

cc ``@JakobDegen`` ``@oli-obk`` ``@Noratrieb`` ``@programmerjake`` ``@bjorn3``

``@rustbot`` label F-unsized_locals

Fixes rust-lang/rust#79409
2025-06-14 11:27:10 +02:00
Matthias Krüger
ade745e214 Rollup merge of #140593 - m-ou-se:some-temp, r=Nadrieril
Temporary lifetime extension through tuple struct and tuple variant constructors

This makes temporary lifetime extension work for tuple struct and tuple variant constructors, such as `Some()`.

Before:
```rust
let a = &temp(); // Extended
let a = Some(&temp()); // Not extended :(
let a = Some { 0: &temp() }; // Extended
```

After:
```rust
let a = &temp(); // Extended
let a = Some(&temp()); // Extended
let a = Some { 0: &temp() }; // Extended
```

So, with this change, this works:

```rust
let a = Some(&String::from("hello")); // New: String lifetime now extended!

println!("{a:?}");
```

Until now, we did not extend through tuple struct/variant constructors (like `Some`), because they are function calls syntactically, and we do not want to extend the String lifetime in:

```rust
let a = some_function(&String::from("hello")); // String not extended!
```

However, it turns out to be very easy to distinguish between regular functions and constructors at the point where we do lifetime extension.

In practice, constructors nearly always use UpperCamelCase while regular functions use lower_snake_case, so it should still be easy to for a human programmer at the call site to see whether something qualifies for lifetime extension or not.

This needs a lang fcp.

---

More examples of what will work after this change:

```rust
let x = Person {
    name: "Ferris",
    job: Some(&Job { // `Job` now extended!
        title: "Chief Rustacean",
        organisation: "Acme Ltd.",
    }),
};

dbg!(x);
```

```rust
let file = if use_stdout {
    None
} else {
    Some(&File::create("asdf")?) // `File` now extended!
};

set_logger(file);
```

```rust
use std::path::Component;

let c = Component::Normal(&OsString::from(format!("test-{num}"))); // OsString now extended!

assert_eq!(path.components.first().unwrap(), c);
```
2025-06-14 11:27:09 +02:00
Andrew Zhogin
d6a9081612 Async drop - fix for StorageLive/StorageDead codegen for pinned async drop future 2025-06-14 15:10:08 +07:00
Mu001999
52167e04e6 Marks ADT live if it appears in pattern 2025-06-14 13:44:43 +08:00
Jubilee
8effd40c4e Rollup merge of #142460 - lcnr:search_graph-3, r=BoxyUwU
cleanup search graph impl

in preparation for my fix of https://github.com/rust-lang/trait-system-refactor-initiative/issues/109

r? `@BoxyUwU`
2025-06-13 20:59:21 -07:00