about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-06-17Dont replace escaping bound vars in item sigsBoxy-84/+67
2025-06-17Test whether we use DeepRejectCtxtBoxy-4/+8
2025-06-17Don't build `ParamEnv` and do trait solving in `ItemCtxt`sBoxy-127/+194
2025-06-17apply clippy::or_fun_callklensy-24/+27
2025-06-17Rollup merge of #142598 - ostylk:fix/ppc64_llvmabi, r=nikic,workingjubileeJubilee-0/+26
Set elf e_flags on ppc64 targets according to abi (This PR contains the non user-facing changes of https://github.com/rust-lang/rust/pull/142321) Fixes https://github.com/rust-lang/rust/issues/85589 by making sure that ld.lld errors out instead of generating a broken binary. Basically the problem is that ld.lld assumes that all ppc64 object files with e_flags=0 are object files which use the ELFv2 ABI (this here is the check https://github.com/llvm/llvm-project/blob/main/lld/ELF/Arch/PPC64.cpp#L639). This pull request sets the correct e_flags to indicate the used ABI so ld.lld errors out when encountering ELFv1 ABI files instead of generating a broken binary. For example compare code generation for this program (file name ``min.rs``): ```rust #![feature(no_core, lang_items, repr_simd)] #![crate_type = "bin"] #![no_core] #![no_main] #[lang = "sized"] trait Sized {} #[lang = "copy"] trait Copy {} #[lang = "panic_cannot_unwind"] pub fn panic() -> ! { loop {} } pub fn my_rad_unmangled_function() { loop {} } pub fn my_rad_function() { loop {} } #[no_mangle] pub fn _start() { my_rad_unmangled_function(); my_rad_function(); } ``` Compile with ``rustc --target=powerpc64-unknown-linux-gnu -C linker=ld.lld -C relocation-model=static min.rs`` Before change: ``` $ llvm-objdump -d min Disassembly of section .text: 000000001001030c <.text>: ... 10010334: 7c 08 02 a6 mflr 0 10010338: f8 21 ff 91 stdu 1, -112(1) 1001033c: f8 01 00 80 std 0, 128(1) 10010340: 48 02 00 39 bl 0x10030378 <_ZN3min25my_rad_unmangled_function17h7471c49af58039f5E> 10010344: 60 00 00 00 nop 10010348: 48 02 00 49 bl 0x10030390 <_ZN3min15my_rad_function17h37112b8fd1008c9bE> 1001034c: 60 00 00 00 nop ... ``` The branch instructions ``bl 0x10030378`` and ``bl 0x10030390`` are jumping into the ``.opd`` section which is data. That is a broken binary (because fixing those branches is the task of the linker). After change: ``` error: linking with `ld.lld` failed: exit status: 1 | = note: "ld.lld" "/tmp/rustcNYKZCS/symbols.o" "<1 object files omitted>" "--as-needed" "-L" "/tmp/rustcNYKZCS/raw-dylibs" "-Bdynamic" "--eh-frame-hdr" "-z" "noexecstack" "-L" "<sysroot>/lib/rustlib/powerpc64-unknown-linux-gnu/lib" "-o" "min" "--gc-sections" "-z" "relro" "-z" "now" = note: some arguments are omitted. use `--verbose` to show all linker arguments = note: ld.lld: error: /tmp/rustcNYKZCS/symbols.o: ABI version 1 is not supported ``` Which is correct because ld.lld doesn't support ELFv1 ABI.
2025-06-17Rollup merge of #142595 - workingjubilee:revert-warning-138139, r=ChrisDentonJubilee-19/+0
Revert overeager warning for misuse of `--print native-static-libs` 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 uses `--print native-static-lib` correctly can be just a nuisance. 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-17Rollup merge of #142587 - compiler-errors:try-visit-expr-fields, r=jieyouxuJubilee-3/+3
Make sure to propagate result from `visit_expr_fields` We weren't propagating the `ControlFlow::Break` out of a struct field, which means that the solution implemented in rust-lang/rust#130443 didn't work for nested fields. Fixes rust-lang/rust#142525.
2025-06-17Rollup merge of #142586 - compiler-errors:remove-visit-struct-field-def, ↵Jubilee-18/+2
r=fmease Fold unnecessary `visit_struct_field_def` in AstValidator We don't need it anymore since we removed the `_: struct { }` syntax experiment.
2025-06-17Rollup merge of #142584 - Urgau:span-borrowck-139049, r=fmeaseJubilee-4/+1
Handle same-crate macro for borrowck semicolon suggestion Handles https://github.com/rust-lang/rust/pull/142543#discussion_r2149545623 cc ``@m-ou-se`` r? ``@fmease``
2025-06-17Rollup merge of #142570 - jieyouxu:disunion, r=estebankJubilee-10/+41
Reject union default field values Fixes rust-lang/rust#142555. The [`default_field_values` RFC][rfc] does not specify that default field values may be used on `union`s, and it's not clear how default field values may be used with `union`s without an design extension to the RFC. So, for now, reject trying to use default field values with `union`s. ### Review notes - The first commit adds the `union` with default field values test case to `tests/ui/structs/default-field-values/failures.rs`, where `union`s with default field values are currently accepted. - The second commit rejects trying to supply default field values to `union` definitions. - When `default_field_values` feature gate is disabled, we show the feature gate error when the user tries to write `union`s with default field values. When the feature gate is enabled, we reject this usage with > unions cannot have default field values ``@rustbot`` label: +F-default_field_values [rfc]: https://rust-lang.github.io/rfcs/3681-default-field-values.html
2025-06-17Rollup merge of #142542 - cjgillot:invalidate-simplify-cfg, r=SparrowLiiJubilee-3/+16
Manually invalidate caches in SimplifyCfg. The current `SimplifyCfg` pass unconditionally invalidates CFG caches. This is unfortunate if there are no modifications that require this invalidation.
2025-06-16compiler: Redescribe rustc_target search algo more accuratelyJubilee Young-14/+7
2025-06-16compiler: Redescribe rustc_target::spec more accuratelyJubilee Young-8/+18
2025-06-17Add a warning to LateContext::get_def_pathblyxyas-0/+9
2025-06-17Reject union default field valuesJieyou Xu-10/+41
2025-06-16cranelift/gcc: `{Meta,Pointee,}Sized` in minicoreDavid Wood-60/+72
As in many previous commits, adding the new traits to minicore, but this time for cranelift and gcc.
2025-06-16trait_sel: skip `nominal_obligations` for `Sized`David Wood-0/+8
`nominal_obligations` calls `predicates_of` on a `Sized` obligation, effectively elaborating the trait and making the well-formedness checking machinery do a bunch of extra work checking a `MetaSized` obligation is well-formed, but given that both `Sized` and `MetaSized` are built-ins, if `Sized` is otherwise well-formed, so `MetaSized` will be.
2025-06-16trait_sel: skip elaboration of sizedness supertraitDavid Wood-12/+152
As a performance optimization, skip elaborating the supertraits of `Sized`, and if a `MetaSized` obligation is being checked, then look for a `Sized` predicate in the parameter environment. This makes the `ParamEnv` smaller which should improve compiler performance as it avoids all the iteration over the larger `ParamEnv`.
2025-06-16trait_sel: extend fast path with sized hierarchyDavid Wood-23/+47
Extend the fast path for `Sized` traits to include constness and `MetaSized`.
2025-06-16middle: print `{Meta,Pointee}Sized` in opaquesDavid Wood-5/+31
When `sized_hierarchy` is enabled, rustc should print `MetaSized` or `PointeeSized` instead of `?Sized` in opaques.
2025-06-16trait_sel: print `{Meta,Pointee}Sized` impl headersDavid Wood-16/+46
When printing impl headers in a diagnostic, the compiler has to account for `?Sized` implying `MetaSized` and new `MetaSized` and `PointeeSized` bounds.
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`