about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-06-16trait_sel: sort `{Meta,Pointee}Sized` diagnostics lastDavid Wood-10/+17
Like `Sized` diagnostics, sorting `MetaSized` and `PointeeSized` diagnostics last prevents earlier more useful diagnostics from being skipped because there has already been error tainting.
2025-06-16trait_sel: `MetaSized` bounds in dispatchable checkDavid Wood-8/+15
Given the necessary additions of bounds to these traits and their impls in the standard library, it is necessary to add `MetaSized` bounds to the obligation which is proven as part of checking for dyn dispatchability.
2025-06-16trait_sel: stash `{Meta,Pointee}Sized` errorsDavid Wood-1/+4
`Sized` errors are currently stashed to improve diagnostics and this must happen with `{Meta,Pointee}Sized` too to maintain diagnostic output.
2025-06-16hir_analysis: add `{Meta,Pointee}Sized` boundsDavid Wood-142/+323
Opting-out of `Sized` with `?Sized` is now equivalent to adding a `MetaSized` bound, and adding a `MetaSized` or `PointeeSized` bound is equivalent to removing the default `Sized` bound - this commit implements this change in `rustc_hir_analysis::hir_ty_lowering`. `MetaSized` is also added as a supertrait of all traits, as this is necessary to preserve backwards compatibility. Unfortunately, non-global where clauses being preferred over item bounds (where `PointeeSized` bounds would be proven) - which can result in errors when a `PointeeSized` supertrait/bound/predicate is added to some items. Rather than `PointeeSized` being a bound on everything, it can be the absence of a bound on everything, as `?Sized` was.
2025-06-16lint: don't consider sizedness in upcastable lintDavid Wood-1/+2
Adding a sizedness supertrait shouldn't require multiple vtables so shouldn't be linted against.
2025-06-16library/compiler: add `PointeeSized` boundsDavid Wood-24/+53
As core uses an extern type (`ptr::VTable`), the default `?Sized` to `MetaSized` migration isn't sufficient, and some code that previously accepted `VTable` needs relaxed to continue to accept extern types. Similarly, the compiler uses many extern types in `rustc_codegen_llvm` and in the `rustc_middle::ty::List` implementation (`OpaqueListContents`) some bounds must be relaxed to continue to accept these types. Unfortunately, due to the current inability to relax `Deref::Target`, some of the bounds in the standard library are forced to be stricter than they ideally would be.
2025-06-16add and use generic get_const_int functionManuel Drehwald-7/+4
2025-06-16indicate ppc64 elf abi in e_flagsostylk-0/+18
2025-06-16explicitly set llvm_abiname option on existing ppc64 targetsostylk-0/+8
2025-06-16Revert overeager warning for misuse of `--print native-static-libs`Jubilee Young-19/+0
In a PR to emit warnings on misuse of `--print native-static-libs`, we did not consider the matter of composing parts of build systems. If you are not directly invoking rustc, it can be difficult to know when you will in fact compile a staticlib, so making sure everyone uses `--print native-static-lib` correctly can be just a nuisance. This reverts the following commits: - f66787a08d57dc1296619b314d2be596085bfeef - 72a9219e82c157041bfc8dfd378c9cb2b09c0650 - 98bb597c05c32365abbd6898f278b097352774ed - c59b70841c36277464b51161e3fcf12dfcb667e0 Next cycle we can reland a slightly more narrowly focused variant or one that focuses on `--emit` instead of `--print native-static-libs`. But in its current state, I am not sure the warning is very useful.
2025-06-16Apply suggestions from code reviewCelina G. Val-230/+1
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2025-06-16Fix some unused fields in AST visitorMichael Goulet-2/+2
2025-06-16Handle same-crate macro for borrowck semicolon suggestionUrgau-4/+1
2025-06-16Rollup merge of #142573 - lcnr:search_graph-3, r=lqdJakub Beránek-17/+6
`fn candidate_is_applicable` to method r? `@BoxyUwU`
2025-06-16Rollup merge of #142554 - nnethercote:fix-PathSource-lifetimes, r=petrochenkovJakub Beránek-33/+33
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. r? `@petrochenkov`
2025-06-16Rollup merge of #142498 - GrigorenkoPV:as-ptr-refactor, r=jdonszelmannJakub Beránek-13/+41
Port `#[rustc_as_ptr]` to the new attribute system It might make sense to introduce some new parser analogous to `Single`, but even more simple: for parsing attributes that take no arguments and may appear only once (such as `#[rustc_as_ptr]` or `#[rustc_const_stable_indirect]`). Not sure if this should be a single `impl` parsing all such attributes, or one impl per attribute. Or how it will play along with the upcoming rework of attribute validation. Or how these argumentless attributes should be called (I've loosely referred to them as `markers` in the name of the new module in this PR, but not sure how good it is). This is a part of rust-lang/rust#131229, so r? `@jdonszelmann` --- For reference, the `#[rustc_as_ptr]` attribute was created back in rust-lang/rust#132732 as a followup to rust-lang/rust#128985.
2025-06-16Rollup merge of #142341 - xizheyin:142311, r=fee1-deadJakub Beránek-17/+28
Don't suggest converting `///` to `//` when expecting `,` Fixes rust-lang/rust#142311
2025-06-16Rollup merge of #139340 - beetrees:riscv-float-struct-abi, r=workingjubileeJakub Beránek-134/+272
Fix RISC-V C function ABI when passing/returning structs containing floats RISC-V passes structs containing only one or two floats (or a float and integer pair) in registers, as long as the individual floats/integers fit in a single corresponding register (see [the ABI specification](https://github.com/riscv-non-isa/riscv-elf-psabi-doc/releases/download/v1.0/riscv-abi.pdf) for details). Before this PR, Rust would not check what offset the second float/integer was at, instead assuming that it was at the standard offset for its default alignment. However, as the offset can be affected by `#[repr(align(N))]` and `#[repr(packed)]`, this caused miscompilations (see #115609). To fix this, this PR introduces a `rest_offset` field to `CastTarget` that can be used to explicitly specify at what offset the `rest` part of the cast is located at. While fixing this, I discovered another bug: the size of the cast target was being used as the size of the MIR return place (when the function was using a `PassMode::Cast` return type). However, the cast target is allowed to be smaller than the size of the actual type, causing a miscompilation. This PR fixes this issue by using the largest of the size of the type and the size of the cast target as the size of the MIR return place, ensuring all reads/writes will be inbounds. Fixes the RISC-V part of #115609. cc target maintainers of `riscv64gc-unknown-linux-gnu`: `@kito-cheng` `@michaelmaitland` `@robin-randhawa-sifive` `@topperc` r? `@workingjubilee`
2025-06-16Change __rust_no_alloc_shim_is_unstable to be a functionDaniel Paoliello-98/+114
2025-06-16Make sure to propagate result from visit_expr_fieldsMichael Goulet-1/+1
2025-06-16Fold unnecessary visit_struct_field_def in AstValidatorMichael Goulet-18/+2
2025-06-16make more CodegenCx function genericManuel Drehwald-2/+2
2025-06-16Port `#[rustc_as_ptr]` to the new attribute systemPavel Grigorenko-13/+41
2025-06-16Dont suggest converting `///` to regular comment when it appears after ↵xizheyin-17/+28
missing `,` in list Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-16trait_sel: `{Meta,Pointee}Sized` on `?Sized` typesDavid Wood-174/+215
Expand the automatic implementation of `MetaSized` and `PointeeSized` so that it is also implemented on non-`Sized` types, just not `ty::Foreign` (extern type).
2025-06-16trait_sel: `{Meta,Pointee}Sized` on `Sized` typesDavid Wood-0/+101
Introduce the `MetaSized` and `PointeeSized` traits as supertraits of `Sized` and initially implement it on everything that currently implements `Sized` to isolate any changes that simply adding the traits introduces.
2025-06-16Reason about borrowed classes in CopyProp.Camille GILLOT-27/+30
2025-06-16Add comment.Camille GILLOT-0/+3
2025-06-16Rollup merge of #142561 - nnethercote:fix-njn-comment, r=chenyukangJakub Beránek-1/+2
Remove an `njn:` comment accidentaly left behind. r? `@chenyukang`
2025-06-16Rollup merge of #142530 - fee1-dead-contrib:push-klusvwusyqvq, r=compiler-errorsJakub Beránek-20/+12
use `if let` guards where possible these crates already enable the feature
2025-06-16Rollup merge of #142528 - fee1-dead-contrib:push-rlxklunqkwmv, r=RalfJungJakub Beránek-1/+1
clarify `rustc_do_not_const_check` comment ~~Given that we have used this attribute for other reasons before it seems appropriate to make this a "usually".~~ Add function name as a pointer cc ```@rust-lang/wg-const-eval```
2025-06-16Rollup merge of #142450 - xizheyin:rustc-query-doc, r=SparrowLiiJakub Beránek-4/+60
Add documentation on top of `rustc_middle/src/query/mod.rs` The `rustc-dev-guide` gives a high-level intro, but many details—especially about how the code works and modifiers in `query xxx(){...}`—are only in code comments or the macro implementation. This doc makes it easier for contributors and code readers to understand the workflow and available modifiers without jumping between files and docs. This PR adds a comprehensive module-level doc comment to `rustc_middle::query::mod.rs` that: 1. Provides an overview of the query system and macro-based query definitions for reading code more easily 2. Centralizes documentation for all query modifiers (previously scattered or only in `rustc_macro` code), closely following the authoritative list in QueryModifiers.
2025-06-16Rollup merge of #142082 - xizheyin:rustc_attr_data_structures, r=jdonszelmannJakub Beránek-14/+48
Refactor `rustc_attr_data_structures` documentation I was reading through `AttributeKind` and realized that attributes like `InlineAttr` didn't appear in it, however, I found them in `rustc_codegen_ssa` and understood why (guessing). There's almost no overall documentation for this crate, I've added the organized documentation at the top of `lib.rs`, and I've grouped the Attributes into two categories: `AttributeKind` that run all through the compiler, and the ones that are only used in `codegen_ssa`, such as `InlineAttr`, `OptimizeAttr`, `InstructionSetAttr`. Also, I've added documentation for `AttributeKind` that further explains why attributes like `InlineAttr` don't appear in it, with examples for each variant. r? ```@jdonszelmann```
2025-06-16candidate_is_applicable to methodlcnr-17/+6
2025-06-16Emit linker timing sectionJakub Beránek-0/+2
2025-06-16Add infrastructure for emitting timing sectionsJakub Beránek-11/+146
2025-06-16Add parsing of `--json=timings`Jakub Beránek-0/+17
2025-06-16Fix RISC-V C function ABI when passing/returning structs containing floatsbeetrees-134/+272
2025-06-16Implement Stable for DiscrNotLebedev-14/+15
2025-06-16Add discriminant_for_variant to CoroutineDefNotLebedev-8/+44
2025-06-16Add discriminant_for_variant to AdtDefNotLebedev-4/+30
2025-06-16Add documentation on top of `rustc_middle/src/query/mod.rs`xizheyin-4/+60
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-16Remove an `njn:` comment accidentaly left behind.Nicholas Nethercote-1/+2
2025-06-16Auto merge of #142521 - sayantn:simplify-intrinsics, r=nikic,workingjubileebors-242/+55
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-16Auto merge of #142550 - fmease:rollup-fteyzcv, r=fmeasebors-657/+396
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-16Fix `PathSource` lifetimes.Nicholas Nethercote-33/+33
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-15Rollup merge of #142543 - Urgau:span-borrowck-semicolon, r=fmeaseLeón Orell Valerian Liehr-3/+7
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-15Rollup merge of #142481 - heiher:loong-asm-f16, r=AmanieuLeón Orell Valerian Liehr-3/+26
Add `f16` inline asm support for LoongArch r? `````@Amanieu`````
2025-06-15Rollup merge of #142389 - beetrees:cranelift-arg-ext, r=bjorn3León Orell Valerian Liehr-24/+40
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](https://github.com/rust-lang/rust/blame/e703dff8fe220b78195c53478e83fb2f68d8499c/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-15Rollup merge of #142347 - azhogin:azhogin/async-drop-storage-live-dead-fix, ↵León Orell Valerian Liehr-5/+30
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.