about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-02-14Rollup merge of #137037 - RalfJung:x86-sse2-abi, r=workingjubileeJubilee-19/+71
add x86-sse2 (32bit) ABI that requires SSE2 target feature This is the first commit of https://github.com/rust-lang/rust/pull/135408: The primary goal of this is to make SSE2 required for our i686 targets (at least for the ones that use Pentium 4 as their baseline), to ensure they cannot be affected by https://github.com/rust-lang/rust/issues/114479. This has been MCPd in https://github.com/rust-lang/compiler-team/issues/808, and is tracked in https://github.com/rust-lang/rust/issues/133611. We do this by defining a new ABI that these targets select, and making SSE2 required by the ABI (that's the first commit). That's kind of a hack, but it is the easiest way to make a target feature required via the target spec. In a follow-up change (https://github.com/rust-lang/rust/pull/135408), we can actually make use of SSE2 for the ABI, but that is running into some infrastructure issues. r? `@workingjubilee` try-job: aarch64-apple try-job: aarch64-gnu try-job: aarch64-gnu-debug try-job: test-various try-job: x86_64-gnu-nopt try-job: dist-i586-gnu-i586-i686-musl
2025-02-14Rollup merge of #137035 - compiler-errors:eagerly-mono-closures-after-norm, ↵Jubilee-0/+7
r=saethlin Normalize closure instance before eagerly monomorphizing it We were monomorphizing two versions of the closure (or in the original issue, coroutine) -- one with normalized captures and one with unnormalized captures. This led to a symbol collision. Fixes #137009 r? `@saethlin` or reassign
2025-02-14Rollup merge of #137032 - oli-obk:push-ptvssqnomkpo, r=the8472Jubilee-4/+1
Decode metadata buffer in one go Not sure if this is perf relevant at all, but it was a bit odd before r? ``@the8472``
2025-02-14Rollup merge of #137006 - dianne:remove-errci-fields, r=compiler-errorsJubilee-29/+11
borrowck diagnostics cleanup: remove an unused and a barely-used field This removes the fields `fr_is_local` and `outlived_fr_is_local` from the struct `ErrorConstraintInfo`. `fr_is_local` was fully unused, but wasn't caught by dead-code analysis. For symmetry, and since `outlived_fr_is_local` was used only once and is easy to recompute, I've removed it too. That makes its one use a bit longer, but constructing/destructuring an `ErrorConsraintInfo` now fits on one line.
2025-02-14Rollup merge of #137002 - chenyukang:fix-early-lint-check-desc, ↵Jubilee-1/+1
r=compiler-errors Fix early lint check desc in query When I debugging this issue: https://github.com/rust-lang/rust/pull/136906#discussion_r1954151036 I found early lint checking is performed after [macro expansion](https://github.com/chenyukang/rust/blob/37520e6d89eeea96b966ab281a7adf1775f7e207/compiler/rustc_interface/src/passes.rs#L267), but [prior to AST lowering](https://github.com/chenyukang/rust/blob/37520e6d89eeea96b966ab281a7adf1775f7e207/compiler/rustc_ast_lowering/src/lib.rs#L427). r? ``@cjgillot``
2025-02-14Normalize closure instance before eagerly monomorphizing itMichael Goulet-0/+7
2025-02-14add x86-sse2 (32bit) ABI that requires SSE2 target featureRalf Jung-19/+71
2025-02-14Auto merge of #137030 - matthiaskrgr:rollup-267aumr, r=matthiaskrgrbors-85/+125
Rollup of 9 pull requests Successful merges: - #135778 (account for `c_enum_min_bits` in `multiple-reprs` UI test) - #136052 (Correct comment for FreeBSD and DragonFly BSD in unix/thread) - #136886 (Remove the common prelude module) - #136956 (add vendor directory to .gitignore) - #136958 (Fix presentation of purely "additive" replacement suggestion parts) - #136967 (Use `slice::fill` in `io::Repeat` implementation) - #136976 (alloc boxed: docs: use MaybeUninit::write instead of as_mut_ptr) - #137007 (Emit MIR for each bit with on `dont_reset_cast_kind_without_updating_operand`) - #137008 (Move code into `rustc_mir_transform`) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-14Decode metadata buffer in one goOli Scherer-4/+1
2025-02-14Rollup merge of #137008 - nnethercote:mv-code-into-rustc_mir_transform, ↵Matthias Krüger-78/+77
r=oli-obk Move code into `rustc_mir_transform` I found two modules in other crates that are better placed in `rustc_mir_transform`, because that's the only crate that uses them. r? ``@matthewjasper``
2025-02-14Rollup merge of #136958 - compiler-errors:additive-replacmeent, r=estebankMatthias Krüger-7/+48
Fix presentation of purely "additive" replacement suggestion parts #127541 changes replacement suggestions to use the "diff" view always, which I think is really verbose in cases where a replacement snippet is a "superset" of the snippet that is being replaced. Consider: ``` LL - Self::Baz: Clone, LL + Self::Baz: Clone, T: std::clone::Clone ``` In this code, we suggest replacing `", "` with `", T: std::clone::Clone"`. This is a consequence of how the snippet is constructed. I believe that since the string that is being replaced is a subset of the replacement string, it's not providing much value to present this as a diff. Users should be able to clearly understand what's being suggested here using the `~` underline view we've been suggesting for some time now. Given that this affects ~100 tests out of the ~1000 UI tests affected, I expect this to be a pretty meaningful improvement of the fallout of #127541. --- In the last commit, this PR also "trims" replacement parts so that they are turned into their purely additive subset, if possible. See the diff for what this means. --- r? estebank
2025-02-14Auto merge of #136575 - scottmcm:nsuw-math, r=nikicbors-39/+66
Set both `nuw` and `nsw` in slice size calculation There's an old note in the code to do this, and now that [LLVM-C has an API for it](https://github.com/llvm/llvm-project/blob/f0b8ff12519270adcfef93410abff76ab073476a/llvm/include/llvm-c/Core.h#L4403-L4408), we might as well. And it's been there since what looks like LLVM 17 https://github.com/llvm/llvm-project/commit/de9b6aa341d8951625d62ae3dac8670ebb3eb006 so doesn't even need to be conditional. (There's other places, like `RawVecInner` or `Layout`, that might want to do things like this too, but I'll leave those for a future PR.)
2025-02-14further simplify a matchdianne-12/+11
2025-02-14Auto merge of #136735 - scottmcm:transmute-nonnull, r=oli-obkbors-9/+26
`transmute` should also assume non-null pointers Previously it only did integer-ABI things, but this way it does data pointers too. That gives more information in general to the backend, and allows slightly simplifying one of the helpers in slice iterators.
2025-02-14Trim suggestion parts to the subset that is purely additiveMichael Goulet-6/+34
2025-02-14Consider add-prefix replacements tooMichael Goulet-3/+4
2025-02-14Use underline suggestions for purely 'additive' replacementsMichael Goulet-1/+13
2025-02-14Auto merge of #137010 - workingjubilee:rollup-g00c07v, r=workingjubileebors-171/+91
Rollup of 9 pull requests Successful merges: - #135439 (Make `-O` mean `OptLevel::Aggressive`) - #136460 (Simplify `rustc_span` `analyze_source_file`) - #136904 (add `IntoBounds` trait) - #136908 ([AIX] expect `EINVAL` for `pthread_mutex_destroy`) - #136924 (Add profiling of bootstrap commands using Chrome events) - #136951 (Use the right binder for rebinding `PolyTraitRef`) - #136981 (ci: switch loongarch jobs to free runners) - #136992 (Update backtrace) - #136993 ([cg_llvm] Remove dead error message) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-13Rollup merge of #136993 - dpaoliello:cleanllvm4, r=workingjubileeJubilee-8/+0
[cg_llvm] Remove dead error message Part of #135502 Discovered a dead error message in rustc_codegen_llvm, so removing it. r? ``@Zalathar``
2025-02-13Rollup merge of #136951 - compiler-errors:clause-binder, r=lqdJubilee-2/+2
Use the right binder for rebinding `PolyTraitRef` Fixes #136940 I committed a slightly different test which still demonstrates the issue.
2025-02-13Rollup merge of #136460 - real-eren:simplify-rustc_span-analyze, r=NoratriebJubilee-132/+55
Simplify `rustc_span` `analyze_source_file` Simplifies the logic to what the code *actually* does, which is to just record newlines and multibyte characters. Checking for other ASCII control characters is unnecessary because the generic fallback doesn't do anything for those cases. Also uses a simpler (and more efficient) means of iterating the set bits of the mask.
2025-02-13Set both `nuw` and `nsw` in slice size calculationScott McMurray-39/+66
There's an old note in the code to do this, and now that LLVM-C has an API for it, we might as well.
2025-02-14Move `MirPatch` from `rustc_middle` to `rustc_mir_transform`.Nicholas Nethercote-42/+43
Because it's only used in `rustc_mir_transform`. (Presumably it is currently in `rustc_middle` because lots of other MIR-related stuff is, but that's not a hard requirement.) And because `rustc_middle` is huge and it's always good to make it smaller.
2025-02-14Move drop elaboration infrastructure.Nicholas Nethercote-37/+35
`rustc_mir_dataflow/src/elaborate_drops.rs` contains some infrastructure used by a few MIR passes: the `elaborate_drop` function, the `DropElaborator` trait, etc. `rustc_mir_transform/src/elaborate_drops.rs` (same file name, different crate) contains the `ElaborateDrops` pass. It relies on a lot of the infrastructure from `rustc_mir_dataflow/src/elaborate_drops.rs`. It turns out that the drop infrastructure is only used in `rustc_mir_transform`, so this commit moves it there. (The only exception is the small `DropFlagState` type, which is moved to the existing `rustc_mir_dataflow/src/drop_flag_effects.rs`.) The file is renamed from `rustc_mir_dataflow/src/elaborate_drops.rs` to `rustc_mir_transform/src/elaborate_drop.rs` (with no trailing `s`) because (a) the `elaborate_drop` function is the most important export, and (b) `rustc_mir_transform/src/elaborate_drops.rs` already exists. All the infrastructure pieces that used to be `pub` are now `pub(crate)`, because they are now only used within `rustc_mir_transform`.
2025-02-13remove `fr_is_local` and `outlived_fr_is_local` fields from ↵dianne-31/+14
`ErrorConstraintInfo` `fr_is_local` was fully unused, and `outlived_fr_is_local` was used once
2025-02-14Fix early lint check desc in queryyukang-1/+1
2025-02-13Rollup merge of #136957 - Zalathar:counters, r=oli-obkJubilee-11/+16
coverage: Eliminate more counters by giving them to unreachable nodes When preparing a function's coverage counters and metadata during codegen, any part of the original coverage graph that was removed by MIR optimizations can be treated as having an execution count of zero. Somewhat counter-intuitively, if we give those unreachable nodes a _higher_ priority for receiving physical counters (instead of counter expressions), that ends up reducing the total number of physical counters needed. This works because if a node is unreachable, we don't actually create a physical counter for it. Instead that node gets a fixed zero counter, and any other node that would have relied on that physical counter in its counter expression can just ignore that term completely.
2025-02-13Rollup merge of #136928 - lcnr:method-lookup-check-wf, r=compiler-errorsJubilee-25/+8
eagerly prove WF when resolving fully qualified paths fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/161. This hopefully shouldn't impact perf. I do think we need to deal with at least part of the fallout here, opening for vibes. r? ``@compiler-errors``
2025-02-13Rollup merge of #136895 - maurer:fix-enum-discr, r=nikicJubilee-1/+7
debuginfo: Set bitwidth appropriately in enum variant tags Previously, we unconditionally set the bitwidth to 128-bits, the largest an enum would possibly be. Then, LLVM would cut down the constant by chopping off leading zeroes before emitting the DWARF. LLVM only supported 64-bit enumerators, so this would also have occasionally resulted in truncated data. LLVM added support for 128-bit enumerators in llvm/llvm-project#125578 That patchset trusts the constant to describe how wide the variant tag is, so the high 64-bits of zeros are considered potentially load-bearing. As a result, we went from emitting tags that looked like: DW_AT_discr_value (0xfe) (because `dwarf::BestForm` selected `data1`) to emitting tags that looked like: DW_AT_discr_value (<0x10> fe ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 ) This makes the `DW_AT_discr_value` encode at the bitwidth of the tag, which: 1. Is probably closer to our intentions in terms of describing the data. 2. Doesn't invoke the 128-bit support which may not be supported by all debuggers / downstream tools. 3. Will result in smaller debug information.
2025-02-13Rollup merge of #136869 - chenyukang:yukang-fix-133713-let-binding, r=estebankJubilee-1/+22
Fix diagnostic when using = instead of : in let binding Fixes #133713 r? ``@estebank``
2025-02-13[cg_llvm] Remove dead error messageDaniel Paoliello-8/+0
2025-02-14eagerly prove WF when resolving fully qualified pathslcnr-25/+8
2025-02-13adjust derive_errorlcnr-46/+108
2025-02-13rework pointee handling for the new rigid alias approachlcnr-67/+79
2025-02-13normalizes-to rework rigid alias handlinglcnr-99/+77
2025-02-13Make `-O` mean `-C opt-level=3`clubby789-29/+34
2025-02-13Auto merge of #136593 - lukas-code:ty-value-perf, r=oli-obkbors-124/+152
valtree performance tuning Summary: This PR makes type checking of code with many type-level constants faster. After https://github.com/rust-lang/rust/pull/136180 was merged, we observed a small perf regression (https://github.com/rust-lang/rust/pull/136318#issuecomment-2635562821). This happened because that PR introduced additional copies in the fast reject code path for consts, which is very hot for certain crates: https://github.com/rust-lang/rust/blob/6c1d960d88dd3755548b3818630acb63fa98187e/compiler/rustc_type_ir/src/fast_reject.rs#L486-L487 This PR improves the performance again by properly interning the valtrees so that copying and comparing them becomes faster. This will become especially useful with `feature(adt_const_params)`, so the fast reject code doesn't have to do a deep compare of the valtrees. Note that we can't just compare the interned consts themselves in the fast reject, because sometimes `'static` lifetimes in the type are be replaced with inference variables (due to canonicalization) on one side but not the other. A less invasive alternative that I considered is simply avoiding copies introduced by https://github.com/rust-lang/rust/pull/136180 and comparing the valtrees it in-place (see commit: https://github.com/rust-lang/rust/commit/9e91e50ac5920f0b9b4a3b1e0880c85336ba5c64 / perf results: https://github.com/rust-lang/rust/pull/136593#issuecomment-2642303245), however that was still measurably slower than interning. There are some minor regressions in secondary benchmarks: These happen due to changes in memory allocations and seem acceptable to me. The crates that make heavy use of valtrees show no significant changes in memory usage.
2025-02-13Auto merge of #136965 - jhpratt:rollup-bsnqvmf, r=jhprattbors-622/+1007
Rollup of 8 pull requests Successful merges: - #134999 (Add cygwin target.) - #136559 (Resolve named regions when reporting type test failures in NLL) - #136660 (Use a trait to enforce field validity for union fields + `unsafe` fields + `unsafe<>` binder types) - #136858 (Parallel-compiler-related cleanup) - #136881 (cg_llvm: Reduce visibility of all functions in the llvm module) - #136888 (Always perform discr read for never pattern in EUV) - #136948 (Split out the `extern_system_varargs` feature) - #136949 (Fix import in bench for wasm) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-13Rollup merge of #136948 - workingjubilee:split-off-extern-system-varargs, ↵Jacob Pratt-17/+32
r=compiler-errors Split out the `extern_system_varargs` feature After the stabilization PR was opened, `extern "system"` functions were added to `extended_varargs_abi_support`. This has a number of questions regarding it that were not discussed and were somewhat surprising. It deserves to be considered as its own feature, separate from `extended_varargs_abi_support`. Tracking issue: - https://github.com/rust-lang/rust/issues/136946
2025-02-13Rollup merge of #136888 - compiler-errors:never-read, r=NadrierilJacob Pratt-47/+66
Always perform discr read for never pattern in EUV Always perform a read of `!` discriminants to ensure that it's captured by closures in expr use visitor Fixes #136852 r? Nadrieril or reassign
2025-02-13Rollup merge of #136881 - dpaoliello:cleanllvm3, r=ZalatharJacob Pratt-421/+479
cg_llvm: Reduce visibility of all functions in the llvm module Next part of #135502 This reduces the visibility of all functions in the `llvm` module to `pub(crate)` and marks the `enzyme_ffi` modules with `#![expect(dead_code)]` (as previously discussed: <https://github.com/rust-lang/rust/pull/135502#discussion_r1915608085>). r? ``@Zalathar``
2025-02-13Rollup merge of #136858 - safinaskar:parallel-cleanup-2025-02-11-07-54, ↵Jacob Pratt-67/+17
r=SparrowLii Parallel-compiler-related cleanup Parallel-compiler-related cleanup I carefully split changes into commits. Commit messages are self-explanatory. Squashing is not recommended. cc "Parallel Rustc Front-end" https://github.com/rust-lang/rust/issues/113349 r? SparrowLii ``@rustbot`` label: +WG-compiler-parallel
2025-02-13Rollup merge of #136660 - compiler-errors:BikeshedGuaranteedNoDrop, r=lcnrJacob Pratt-66/+334
Use a trait to enforce field validity for union fields + `unsafe` fields + `unsafe<>` binder types This PR introduces a new, internal-only trait called `BikeshedGuaranteedNoDrop`[^1] to faithfully model the field check that used to be implemented manually by `allowed_union_or_unsafe_field`. https://github.com/rust-lang/rust/blob/942db6782f4a28c55b0b75b38fd4394d0483390f/compiler/rustc_hir_analysis/src/check/check.rs#L84-L115 Copying over the doc comment from the trait: ```rust /// Marker trait for the types that are allowed in union fields, unsafe fields, /// and unsafe binder types. /// /// Implemented for: /// * `&T`, `&mut T` for all `T`, /// * `ManuallyDrop<T>` for all `T`, /// * tuples and arrays whose elements implement `BikeshedGuaranteedNoDrop`, /// * or otherwise, all types that are `Copy`. /// /// Notably, this doesn't include all trivially-destructible types for semver /// reasons. /// /// Bikeshed name for now. ``` As far as I am aware, there's no new behavior being guaranteed by this trait, since it operates the same as the manually implemented check. We could easily rip out this trait and go back to using the manually implemented check for union fields, however using a trait means that this code can be shared by WF for `unsafe<>` binders too. See the last commit. The only diagnostic changes are that this now fires false-negatives for fields that are ill-formed. I don't consider that to be much of a problem though. r? oli-obk [^1]: Please let's not bikeshed this name lol. There's no good name for `ValidForUnsafeFieldsUnsafeBindersAndUnionFields`.
2025-02-13Rollup merge of #136559 - ↵Jacob Pratt-2/+5
compiler-errors:resolve-regions-for-type-test-failure, r=BoxyUwU Resolve named regions when reporting type test failures in NLL Just a improvement tweak to an error message that I broke out of a bigger PR that I had to close lol
2025-02-13Rollup merge of #134999 - Berrysoft:dev/new-cygwin-target, ↵Jacob Pratt-2/+74
r=chenyukang,workingjubilee Add cygwin target. This PR simply adds cygwin target together with msys2 target, based on ````@ookiineko```` 's (the account has been deleted) [work](https://github.com/ookiineko-cygport/rust) on cygwin target. My full work is here: https://github.com/rust-lang/rust/compare/master...Berrysoft:rust:dev/cygwin I have succeeded in building a new rustc for cygwin target, and eventually distributed a new version of [fish-shell](https://github.com/Berrysoft/fish-shell/releases) (rewritten by Rust) for MSYS2. I will open a new PR to fix std if this PR is accepted.
2025-02-12`transmute` should also assume non-null pointersScott McMurray-9/+26
Previously it only did integer-ABI things, but this way it does data pointers too. That gives more information in general to the backend, and allows slightly simplifying one of the helpers in slice iterators.
2025-02-13Implement lint for definition site item shadowing tooMichael Goulet-6/+124
2025-02-13Rework collapse method to work correctly with more complex supertrait graphsMichael Goulet-21/+46
2025-02-13Implement shadowing lintMichael Goulet-12/+155
2025-02-13Implement RFC 3624 supertrait_item_shadowingMichael Goulet-4/+63