about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-09-06Update comment for werror on rust-lang/rust CI explaining why we keep MSVC ↵Romain Perier-4/+4
definitively excluded
2025-09-06identity uses are ok, even if there are no defining useslcnr-1/+10
2025-09-06Ensure fat LTO doesn't merge everything into the allocator modulebjorn3-3/+21
2025-09-06Rollup merge of #146211 - Urgau:cfg-disallow-shebang, r=fmeaseMatthias Krüger-22/+42
Disallow shebang in `--cfg` and `--check-cfg` arguments This PR is similar to https://github.com/rust-lang/rust/issues/146130, where we disallowed frontmatter in `--cfg` and `--check-cfg` arguments. While fixing the other one we also discovered that shebang `#!/usr/bin/shebang` are currently also allowed in `--cfg` and `--check-cfg` arguments. Allowing shebang in them (which are just ignored) was never intended, this PR fixes that by not stripping shebang for `--cfg` and `--check-cfg` arguments. This is technically a breaking-change, although I don't expect anyone to actually rely on this unintended behavior. Fixes https://github.com/rust-lang/rust/issues/146130#issuecomment-3246299499 r? fmease
2025-09-06Rollup merge of #144801 - estebank:issue-144734, r=spastorinoMatthias Krüger-10/+68
Suggest bounds in more cases, accounting for type parameters referenced in predicate Use a `ty::Visitor` to see if the failed predicate references a type parameter. If it does, then we only suggest adding a bound to an (associated) item only if the referenced parameter is present in its generics. Provide adding bound suggestion in trait and impl associated functions in cases we previously weren't: ``` error[E0277]: `?` couldn't convert the error to `ApplicationError` --> $DIR/suggest-complex-bound-on-method.rs:18:16 | LL | t.run()?; | -----^ the trait `From<<T as Trait>::Error>` is not implemented for `ApplicationError` | | | this can't be annotated with `?` because it has type `Result<_, <T as Trait>::Error>` | note: `ApplicationError` needs to implement `From<<T as Trait>::Error>` --> $DIR/suggest-complex-bound-on-method.rs:12:1 | LL | enum ApplicationError { | ^^^^^^^^^^^^^^^^^^^^^ = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement | LL | fn thing<T: Trait>(&self, t: T) -> Result<(), ApplicationError> where ApplicationError: From<<T as Trait>::Error> { | +++++++++++++++++++++++++++++++++++++++++++++++++ ``` Fix rust-lang/rust#144734.
2025-09-06Rollup merge of #127316 - klensy:tracing-bump, r=KobzolMatthias Krüger-3/+3
move pinned version from tracing_core to tracing This PR removes pin from `tracing-core` and moves it to `tracing`, which regressed perf in > 0.1.37 versions.
2025-09-06Make the allocator shim participate in LTO againbjorn3-26/+39
2025-09-05Some hygiene doc improvementsCameron Steffen-12/+22
2025-09-05Ignore intrinsic calls in cross-crate-inlining cost modelBen Kimock-1/+10
2025-09-06Disallow shebang in `--cfg` and `--check-cfg` argumentsUrgau-22/+42
2025-09-05Rollup merge of #146243 - matthiaskrgr:declone, r=lqdLeón Orell Valerian Liehr-4/+4
remove couple of redundant clones
2025-09-05Rollup merge of #146241 - hkBst:context-1, r=jieyouxuLeón Orell Valerian Liehr-1/+1
rustc_infer: change top-level doc comment to inner
2025-09-05Rollup merge of #146144 - heiher:entry-func-features, r=petrochenkovLeón Orell Valerian Liehr-10/+22
compiler: Apply target features to the entry function Fixes rust-lang/rust#146143
2025-09-05Rollup merge of #138944 - madsmtm:apple_os_version_check, r=tgross35León Orell Valerian Liehr-2/+6
Add `__isPlatformVersionAtLeast` and `__isOSVersionAtLeast` symbols ## Motivation When Objective-C code uses ```@available(...)`,`` Clang inserts a call to [`__isPlatformVersionAtLeast`](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0/compiler-rt/lib/builtins/os_version_check.c#L276) (`__isOSVersionAtLeast` in older Clang versions). These symbols not being available sometimes ends up causing linker errors. See the new test `tests/run-make/apple-c-available-links` for a minimal reproducer. The workaround is to link `libclang_rt.osx.a`, see e.g. https://github.com/alexcrichton/curl-rust/issues/279. But that's very difficult for users to figure out (and the backreferences to that issue indicates that people are still running into this in their own projects every so often). For another recent example, this is preventing `rustc` from using LLVM assertions on macOS, see https://github.com/rust-lang/rust/pull/62592#issuecomment-510670657 and https://github.com/rust-lang/rust/pull/134275#issuecomment-2543067830. It is also a blocker for [setting the correct minimum OS version in `cc-rs`](https://github.com/rust-lang/rust/issues/136113), since fixing this in `cc-rs` might end up introducing linker errors in places where we weren't before (by default, if using e.g. ```@available(macos`` 10.15, *)`, the symbol usually happens to be left out, since `clang` defaults to compiling for the host macOS version, and thus things _seem_ to work - but the availability check actually compiles down to nothing, which is a huge correctness footgun for running on older OSes). (My super secret evil agenda is also to expose some variant of ```@available``` in Rust's `std` after https://github.com/rust-lang/rfcs/pull/3750 progresses further, will probably file an ACP for this later. But I believe this PR has value regardless of those future plans, since we'd be making C/Objective-C/Swift interop easier). ## Solution Implement `__isPlatformVersionAtLeast` and `__isOSVersionAtLeast` as part of the "public ABI" that `std` exposes. **This is insta-stable**, in the same sense that additions to `compiler-builtins` are insta-stable, though the availability of these symbols can probably be considered a "quality of implementation" detail rather than a stable promise. I originally proposed to implement this in `compiler-builtins`, see https://github.com/rust-lang/compiler-builtins/pull/794, but we discussed moving it to `std` instead ([Zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/Provide.20.60__isPlatformVersionAtLeast.60.20in.20.60std.60.3F/with/507880717)), which makes the implementation substantially simpler, and we avoid gnarly issues with requiring the user to link `libSystem.dylib` (since `std` unconditionally does that). Note that this does not solve the linker errors for (pure) `#![no_std]` users, but that's _probably_ fine, if you are using ```@available``` to test the OS version on Apple platforms, you're likely also using `std` (and it is still possible to work around by linking `libclang_rt.*.a`). A thing to note about the implementation, I've choosen to stray a bit from LLVM's upstream implementation, and not use `_availability_version_check` since [it has problems when compiling with an older SDK](https://github.com/llvm/llvm-project/issues/64227). Instead, we use `sysctl kern.osproductversion` when available to still avoid the costly PList lookup in most cases, but still with a fall back to the PList lookup when that is not available (with the PList fallback being is similar to LLVM's implementation). ## Testing Apple has a lot of different "modes" that they can run binaries in, which can be a bit difficult to find your bearings in, but I've tried to be as thorough as I could in testing them all. Tested using roughly the equivalent of `./x test library/std -- platform_version` on the following configurations: - macOS 14.7.3 on a Macbook Pro M2 - `aarch64-apple-darwin` - `x86_64-apple-darwin` (under Rosetta) - `aarch64-apple-ios-macabi` - `x86_64-apple-ios-macabi` (under Rosetta) - `aarch64-apple-ios` (using Xcode's "Designed for iPad" setting) - `aarch64-apple-ios-sim` (in iOS Simulator, as iPhone with iOS 17.5) - `aarch64-apple-ios-sim` (in iOS Simulator, as iPad with iOS 18.2) - `aarch64-apple-tvos-sim` (in tvOS Simulator) - `aarch64-apple-watchos-sim` (in watchOS Simulator) - `aarch64-apple-ios-sim` (in visionOS simulator, using Xcode's "Designed for iPad" setting) - `aarch64-apple-visionos-sim` (in visionOS Simulator) - macOS 15.3.1 VM - `aarch64-apple-darwin` - `aarch64-apple-ios-macabi` - macOS 10.12.6 on an Intel Macbook from 2013 - `x86_64-apple-darwin` - `i686-apple-darwin` - `x86_64-apple-ios` (in iOS Simulator) - iOS 9.3.6 on a 1st generation iPad Mini - `armv7-apple-ios` with an older compiler Along with manually inspecting the output of `version_from_sysctl()` and `version_from_plist()`, and verifying that they actually match what's expected. I believe the only real omissions here would be: - `aarch64-apple-ios` on a newer iPhone that has `sysctl` available (iOS 11.4 or above). - `aarch64-apple-ios` on a Vision Pro using Xcode's "Designed for iPad" setting. But I don't have the hardware available to test those. ``@rustbot`` label O-apple A-linkage -T-compiler -A-meta -A-run-make try-job: aarch64-apple
2025-09-05Use `Itertools::all_equal_value()` where applicableYotam Ofek-46/+35
2025-09-05compiler: Add Windows resources to rustc-main and rustc_driverAleksey Kliger-3/+257
Adds Windows resources with the rust version information to rustc-main.exe and rustc_driver.dll Sets the product description to "Rust Compiler" or "Rust Compiler (channel)" for non-stable channels
2025-09-05rustc_middle: clippy fixesMarijn Schouten-20/+14
2025-09-05Auto merge of #146121 - Muscraft:filter-suggestion-parts, r=petrochenkovbors-16/+17
fix: Filter suggestion parts that match existing code While testing my changes to make `rustc` use `annotate-snippets`, I encountered a new `clippy` test failure stemming from [two](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R275-R278) [suggestion](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R289-R292) output changes in rust-lang/rust#145273. The new output in these two cases feels like a regression as it is not as clear as the old output, and adds unnecessary information. Before rust-lang/rust#145273 (`Diff` style) ![before](https://github.com/user-attachments/assets/36f33635-cbce-45f1-823d-0cbe6f0cfe46) After rust-lang/rust#145273 ("multi-line" style) ![after](https://github.com/user-attachments/assets/d4cb00b8-5a42-436e-9329-db84347138f0) The reason for the change was that a new suggestion part (which matches existing code) was added on a different line than the existing parts, causing the suggestion style to change from `Diff` to "multi-line". Since this new part matches existing code, no code changes show up in the output for it, but it still makes the suggestion style "multi-line" when it doesn't need to be. To get the old output back, I made it so that suggestion parts that perfectly match existing code get filtered out. try-job: aarch64-apple
2025-09-05Add __isOSVersionAtLeast and __isPlatformVersionAtLeast symbolsMads Marquart-2/+6
Allows users to link to Objective-C code using `@available(...)`.
2025-09-05cg_gcc: run `run-make-cargo` testsJieyou Xu-3/+19
2025-09-05cg_clif: run `run-make-cargo` test suiteJieyou Xu-1/+1
2025-09-05cg_clif: account for moved `tests/run-make-cargo/compiler-builtins`Jieyou Xu-1/+1
2025-09-05remove couple of clonesMatthias Krüger-4/+4
2025-09-05rustc_infer: change top-level doc comment to innerMarijn Schouten-1/+1
2025-09-05DynamicConfig: use canonical clone implMarijn Schouten-1/+1
2025-09-05Auto merge of #146044 - estebank:issue-88727, r=chenyukangbors-42/+123
Suggest parentheses when `match` or `if` expression in binop is parsed as statement ``` error[E0308]: mismatched types --> $DIR/expr-as-stmt.rs:81:5 | LL | match () { _ => true } && match () { _ => true }; | ^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `bool` | help: parentheses are required to parse this as an expression | LL | (match () { _ => true }) && match () { _ => true }; | + + ``` Address the common case from rust-lang/rust#88727. The original parse error is still outstanding, but the cases brought up in the thread are resolved.
2025-09-05gpu offload: change suspicious map into filterMarijn Schouten-1/+1
2025-09-05Auto merge of #146224 - tgross35:rollup-1bgjms3, r=tgross35bors-38/+110
Rollup of 5 pull requests Successful merges: - rust-lang/rust#144342 (add exact bitshifts) - rust-lang/rust#145709 (Fix LoongArch C function ABI when passing/returning structs containing floats) - rust-lang/rust#146152 (Unify and deduplicate algebraic float tests) - rust-lang/rust#146207 (std: Implement WASIp2-specific stdio routines) - rust-lang/rust#146217 (fix ICE when suggesting `::new`) r? `@ghost` `@rustbot` modify labels: rollup
2025-09-05Rollup merge of #146217 - lukas-code:suggest-new-ice, r=compiler-errorsTrevor Gross-6/+5
fix ICE when suggesting `::new` fixes https://github.com/rust-lang/rust/issues/146174 This code suggests to write `Foo::new(...)` when the user writes `Foo(...)` or `Foo { ... }` and the constructor is private, where `new` is some associated function that returns `Self`. When checking that the return type of `new` is `Self`, we need to instantiate the parameters of `new` with infer vars, so we don't end up with a type like `Box<$param(0)>` in a context that doesn't have any parameters. But then we can't use `normalize_erasing_late_bound_regions` anymore because that goes though a query that can't deal with infer vars. Since this is diagnostic-only code that is supposed to check for exactly `-> Self`, I think it's fine to just skip normalizing here, especially since The Correct Way<sup>TM</sup> would involve a probe and make this code even more complicated. Also, the code here does almost the same thing, and these suggestions can probably be unified in the future: https://github.com/rust-lang/rust/blob/4ca8078d37c53ee4ff8fb32b4453b915116f25b8/compiler/rustc_hir_typeck/src/method/suggest.rs#L2123-L2129 r? ````@compiler-errors```` cc ````@Qelxiros```` -- this should unblock https://github.com/rust-lang/rust/pull/144420
2025-09-05Rollup merge of #145709 - heiher:issue-145692-1, r=jackh726Trevor Gross-32/+105
Fix LoongArch C function ABI when passing/returning structs containing floats Similar to RISC-V, LoongArch passes structs containing only one or two floats (or a float–integer pair) in registers, as long as each element fits into a single corresponding register. Before this PR, Rust did not check the actual offset of the second float or integer; instead, it assumed the standard offset based on the default alignment. However, since the offset can be affected by `#[repr(align(N))]` and `#[repr(packed)]`, this led to miscompilations (see rust-lang/rust#145692). This PR fixes the issue by explicitly specifying the offset for the remainder of the cast.
2025-09-05Auto merge of #144737 - petrochenkov:extprelcache, r=davidtwcobors-6/+8
resolve: Avoid finalizing extern prelude entries more than once
2025-09-04fix: Filter suggestion parts that match existing codeScott Schafer-10/+11
2025-09-04chore: Remove redundant disjoint spans assertScott Schafer-5/+0
2025-09-04refactor: Move assert for disjoint substitution spansScott Schafer-1/+6
2025-09-04Auto merge of #138736 - azhogin:azhogin/sanitizers-target-modificators, ↵bors-7/+82
r=rcvalle Sanitizers target modificators Depends on bool flag fix: https://github.com/rust-lang/rust/pull/138483. Some sanitizers need to be target modifiers, and some do not. For now, we should mark all sanitizers as target modifiers except for these: AddressSanitizer, LeakSanitizer For kCFI, the helper flag -Zsanitizer-cfi-normalize-integers should also be a target modifier. Many test errors was with sanizer flags inconsistent with std deps. Tests are fixed with `-C unsafe-allow-abi-mismatch`.
2025-09-04fix ICE when suggesting `::new`Lukas Markeffsky-6/+5
2025-09-04compiler: Apply target features to the entry functionWANG Rui-10/+22
2025-09-04Auto merge of #145955 - bjorn3:lto_refactors4, r=nnethercotebors-155/+97
Rework how the codegen coordinator code handles the allocator shim Continuing from https://github.com/rust-lang/rust/pull/144503 this centralizes most handling of the allocator shim to a single 4 line block in the codegen coordinator. The allocator shim is small enough that making it go through the main codegen loop and spawning a worker thread for it is wasted effort.
2025-09-04rustc_log: remove direct dep on tracing_coreklensy-1/+1
required features reexported from tracing
2025-09-04unpin tracing_coreklensy-2/+2
2025-09-04Special case allocator module submission to avoid special casing it elsewherebjorn3-146/+79
A lot of places had special handling just in case they would get an allocator module even though most of these places could never get one or would have a trivial implementation for the allocator module. Moving all handling of the allocator module to a single place simplifies things a fair bit.
2025-09-04Ensure the allocator shim never participates in LTObjorn3-18/+13
Making it participate in LTO would be incorrect if you compile a crate as both a dylib (which needs it) and rlib (which must not include it) in the same rustc invocation. With linker plugin LTO, the allocator shim will still participate in LTO as it is safe to do so in that case.
2025-09-04Export __rdl_* symbols to the allocator shim when doing LTObjorn3-0/+14
2025-09-04Rollup merge of #146182 - ChayimFriedman2:ns-probe, r=jackh726Jacob Pratt-8/+9
Don't require next-solver `ProbeRef` to be `Copy` rust-analyzer would like to use a non-interned `Probe` there. Also rename it to `Probe` for this reason. We can make it `Copy` (although then `Probe` will need to be `Clone` for rust-analyzer) but it seems just non-needed. r? types
2025-09-04Rollup merge of #145690 - sayantn:integer-funnel-shift, r=tgross35Jacob Pratt-8/+23
Implement Integer funnel shifts Tracking issue: rust-lang/rust#145686 ACP: https://github.com/rust-lang/libs-team/issues/642 This implements funnel shifts on primitive integer types. Implements this for cg_llvm, with a fallback impl for everything else Thanks `@folkertdev` for the fixes and tests cc `@rust-lang/libs-api`
2025-09-04Rollup merge of #145682 - dpaoliello:arm64tier1, r=jieyouxuJacob Pratt-1/+1
Promote aarch64-pc-windows-msvc to Tier 1 Per <https://github.com/rust-lang/rfcs/pull/3817> Tracking issue: <https://github.com/rust-lang/rust/issues/145671>
2025-09-04Rollup merge of #146137 - Urgau:cfg-disallow-frontmatter, r=fmeaseStuart Cook-6/+20
Disallow frontmatter in `--cfg` and `--check-cfg` arguments This PR disallows the frontmatter syntax in `--cfg` and `--check-cfg` arguments. Fixes https://github.com/rust-lang/rust/issues/146130 r? fmease
2025-09-04Rollup merge of #146134 - maurer:nvptx-sync, r=durin42Stuart Cook-1/+5
llvm: nvptx: Layout update to match LLVM LLVM upstream switched layouts to support 256-bit vector load/store. ``````@rustbot`````` label llvm-main r? durin42
2025-09-04Rollup merge of #146120 - smoelius:patch-3, r=lqdStuart Cook-1/+1
Correct typo in `rustc_errors` comment
2025-09-04Rollup merge of #146112 - scrabsha:push-utkysktvulto, r=WaffleLapkinStuart Cook-14/+14
don't uppercase error messages