about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-02-18remove redundant codeLukas Markeffsky-11/+9
- we normalize before calling `layout_of_uncached`, so we don't need to normalize again later - we check for type/const errors at the top of `layout_of_uncached`, so we don't need to check again later
2025-02-18remove unreachable casesLukas Markeffsky-15/+8
`ty::Placeholder` is used by the trait solver and computing its layout was necessary, because the `PointerLike` trait used to be automatically implemented for all types with pointer-like layout. Nowadays, `PointerLike` requires user-written impls and the trait solver no longer computes any layouts, so this can be removed. Unevaluated constants that aren't generic should have caused a const eval error earlier during normalization.
2025-02-18clean up layout error diagnosticsLukas Markeffsky-25/+25
- group the fluent slugs together - reword (internal-only) "too generic" error to be more in line with the other errors
2025-02-18document and test all `LayoutError` variantsLukas Markeffsky-0/+21
2025-02-18eval_outlives: bail out early if both regions are in the same SCCAmanda Stjerna-0/+5
2025-02-18add last std diagnostic items for clippycyrgani-0/+7
2025-02-18don't ICE for alias-relate goals with error termlcnr-1/+26
2025-02-18cg_clif: Tweak formatting of global commentsJubilee-2/+2
Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2025-02-18compiler: Stop reexporting stuff in cg_llvm::abiJubilee Young-27/+27
The reexports confuse tooling like rustdoc into thinking cg_llvm is the source of key types that originate in rustc_target.
2025-02-18Auto merge of #133852 - x17jiri:cold_path, r=saethlinbors-15/+107
improve cold_path() #120370 added a new instrinsic `cold_path()` and used it to fix `likely` and `unlikely` However, in order to limit scope, the information about cold code paths is only used in 2-target switch instructions. This is sufficient for `likely` and `unlikely`, but limits usefulness of `cold_path` for idiomatic rust. For example, code like this: ``` if let Some(x) = y { ... } ``` may generate 3-target switch: ``` switch y.discriminator: 0 => true branch 1 = > false branch _ => unreachable ``` and therefore marking a branch as cold will have no effect. This PR improves `cold_path()` to work with arbitrary switch instructions. Note that for 2-target switches, we can use `llvm.expect`, but for multiple targets we need to manually emit branch weights. I checked Clang and it also emits weights in this situation. The Clang's weight calculation is more complex that this PR, which I believe is mainly because `switch` in `C/C++` can have multiple cases going to the same target.
2025-02-18Make E0599 a structured errorEsteban Küber-18/+25
2025-02-18Auto merge of #137162 - nnethercote:remove-Map-2, r=Zalatharbors-284/+262
Move methods from `Map` to `TyCtxt`, part 2. Continuing the work started in #136466. Every method gains a `hir_` prefix, though for the ones that already have a `par_` or `try_par_` prefix I added the `hir_` after that. r? Zalathar
2025-02-18Inline and replace `Statement::replace_nop`.Nicholas Nethercote-13/+6
It has a single call site, and doesn't seem worth having as an API function.
2025-02-17Enforce T: Hash for Interned<...>Mark Rousskov-1/+43
This adds panicking Hash impls for several resolver types that don't actually satisfy this condition. It's not obvious to me that rustc_resolve actually upholds the Interned guarantees but fixing that seems pretty hard (the structures have at minimum some interior mutability, so it's not really recursively hashable in place...).
2025-02-18Inline and remove `BasicBlockData::retain_statements`.Nicholas Nethercote-16/+6
It has a single call site, and the code is clearer this way.
2025-02-18Remove `BasicBlockData::expand_statements`.Nicholas Nethercote-49/+0
The previous commit removed its single use. `MirPatch` is a more flexible alternative.
2025-02-18Improve `MirPatch` documentation and naming.Nicholas Nethercote-16/+41
It's currently lacking comments. This commit adds some, which is useful because there are some methods with non-obvious behaviour. The commit also renames two things: - `patch_map` becomes `term_patch_map`, because it's only about terminators. - `is_patched` becomes `is_term_patched`, for the same reason. (I would guess that originally `MirPatch` only handled terminators, and then over time it expanded to allow other modifications, but these names weren't updated.)
2025-02-18Use `MirPatch` in `EnumSizeOpt`.Nicholas Nethercote-112/+74
Instead of `expand_statements`. This makes the code shorter and consistent with other MIR transform passes. The tests require updating because there is a slight change in MIR output: - the old code replaced the original statement with twelve new statements. - the new code inserts converts the original statement to a `nop` and then insert twelve new statements in front of it. I.e. we now end up with an extra `nop`, which doesn't matter at all.
2025-02-18Auto merge of #137176 - matthiaskrgr:rollup-eht05gr, r=matthiaskrgrbors-49/+69
Rollup of 9 pull requests Successful merges: - #136959 (Simplify switch sources) - #137020 (Pass vendored sources from bootstrap to generate-copyright) - #137073 (boostrap: skip no_std targets in Std doc step) - #137165 (Use `tell` for `<File as Seek>::stream_position`) - #137166 (Update default loongarch code model in docs) - #137168 (correct comment) - #137169 (CI: rfl: move job forward to Linux v6.14-rc3) - #137170 (Allow configuring jemalloc per target) - #137173 (Subtree update of `rust-analyzer`) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-18Move methods from `Map` to `TyCtxt`, part 2.Nicholas Nethercote-284/+262
Continuing the work started in #136466. Every method gains a `hir_` prefix, though for the ones that already have a `par_` or `try_par_` prefix I added the `hir_` after that.
2025-02-17cg_clif: use exclusively ABI alignmentJubilee Young-4/+3
2025-02-17Install more signal stack trace handlersUrgau-11/+39
2025-02-17Deeply normalize associated type bounds before proving themMichael Goulet-42/+22
2025-02-17Prefer param-env candidates even when alias's trait bound isn't proven via ↵Michael Goulet-8/+29
param-env
2025-02-17Rollup merge of #137168 - klensy:rc--, r=lcnrMatthias Krüger-3/+1
correct comment Rc was removed in #113573, so r? `@lcnr`
2025-02-17Rollup merge of #136959 - nnethercote:simplify-SwitchSources, r=tmiaskoMatthias Krüger-46/+68
Simplify switch sources `SwitchSources` and the code around it can be simplified. r? `@tmiasko`
2025-02-17Adds binary_format to rustc target specsPyrode-48/+102
2025-02-17Auto merge of #135763 - nikic:llvm-20, r=cuviperbors-8/+12
Update to LLVM 20 LLVM 20 GA is scheduled for March 11th. Rust 1.87 will be stable on May 15th. * [x] https://github.com/rust-lang/rust/pull/135764 * [x] https://github.com/rust-lang/rust/pull/136134 * [x] https://github.com/rust-lang/compiler-builtins/pull/752 * [x] https://github.com/llvm/llvm-project/pull/125287 * [x] https://github.com/rust-lang/rust/pull/136537 * [x] https://github.com/rust-lang/rust/pull/136895 * [x] Wait for beta branch (Feb 14). Tested: host-x86_64, host-aarch64, apple, mingw, msvc
2025-02-17suggest swapping equality on e0277makai410-0/+53
2025-02-17Clean up dropck code a bitMatthew Jasper-55/+38
- Remove `Result` that couldn't be Err on valid compilation. - Always compute errors on failure.
2025-02-17Handle normalization failures in drop elaborationMatthew Jasper-2/+15
Drop elaboration looks at fields of a type, which may error when we try to normalize them. Borrowck will have detected this if HIR typeck didn't, but we don't delete the MIR body for errors in borrowck so still have to handle this happening in drop elaboration by checking whether an error has been emitted.
2025-02-17Report dropck normalization errors in borrowckMatthew Jasper-22/+86
HIR type checking no longer runs dropck, so we may get new errors when we run it in borrowck. If this happens then rerun the query in a local infcx and report errors for it.
2025-02-17Auto merge of #137164 - matthiaskrgr:rollup-dj5826k, r=matthiaskrgrbors-279/+238
Rollup of 7 pull requests Successful merges: - #137095 (Replace some u64 hashes with Hash64) - #137100 (HIR analysis: Remove unnecessary abstraction over list of clauses) - #137105 (Restrict DerefPure for Cow<T> impl to T = impl Clone, [impl Clone], str.) - #137120 (Enable `relative-path-include-bytes-132203` rustdoc-ui test on Windows) - #137125 (Re-add missing empty lines in the releases notes) - #137145 (use add-core-stubs / minicore for a few more tests) - #137149 (Remove SSE ABI from i586-pc-windows-msvc) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-17correct commentklensy-3/+1
2025-02-17improve cold_path()Jiri Bobek-15/+107
2025-02-17Rollup merge of #137149 - Noratrieb:wtf-is-this-target, r=RalfJungMatthias Krüger-0/+1
Remove SSE ABI from i586-pc-windows-msvc As an i586 target, it should not have SSE. This caused the following warning to be emitted: ``` warning: target feature `sse2` must be enabled to ensure that the ABI of the current target can be implemented correctly | = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344> warning: 1 warning emitted ``` see #116344. r? RalfJung
2025-02-17Rollup merge of #137100 - fmease:hirtylow-rm-clauses-wrapper, r=compiler-errorsMatthias Krüger-206/+114
HIR analysis: Remove unnecessary abstraction over list of clauses `rustc_hir_analysis::bounds::Bounds` with its methods is nowadays a paper-thin wrapper around `Vec<(Clause, Span)>`s and `Vec::push` essentially. Its existence slightly annoyed me (and I keep opening its corresp. file instead of the identically named `bounds.rs` in `hir_ty_lowering/` that I actually want most of the time :P). Opening to check if you agree with inlining it. r? compiler-errors or reassign
2025-02-17Rollup merge of #137095 - saethlin:use-hash64-for-hashes, r=workingjubileeMatthias Krüger-73/+123
Replace some u64 hashes with Hash64 I introduced the Hash64 and Hash128 types in https://github.com/rust-lang/rust/pull/110083, essentially as a mechanism to prevent hashes from landing in our leb128 encoding paths. If you just have a u64 or u128 field in a struct then derive Encodable/Decodable, that number gets leb128 encoding. So if you need to store a hash or some other value which behaves very close to a hash, don't store it as a u64. This reverts part of https://github.com/rust-lang/rust/pull/117603, which turned an encoded Hash64 into a u64. Based on https://github.com/rust-lang/rust/pull/110083, I don't expect this to be perf-sensitive on its own, though I expect that it may help stabilize some of the small rmeta size fluctuations we currently see in perf reports.
2025-02-17Rollup merge of #137140 - Noratrieb:const-move, r=jieyouxu,compiler-errorsMatthias Krüger-3/+5
Fix const items not being allowed to be called `r#move` or `r#static` Because of an ambiguity with const closures, the parser needs to ensure that for a const item, the `const` keyword isn't followed by a `move` or `static` keyword, as that would indicate a const closure: ```rust fn main() { const move // ... } ``` This check did not take raw identifiers into account, therefore being unable to distinguish between `const move` and `const r#move`. The latter is obviously not a const closure, so it should be allowed as a const item. This fixes the check in the parser to only treat `const ...` as a const closure if it's followed by the *proper keyword*, and not a raw identifier. Additionally, this adds a large test that tests for all raw identifiers in all kinds of positions, including `const`, to prevent issues like this one from occurring again. fixes #137128
2025-02-17Rollup merge of #137101 - GrigorenkoPV:str-inherent-lint, r=UrgauMatthias Krüger-3/+15
`invalid_from_utf8[_unchecked]`: also lint inherent methods Addressing https://github.com/rust-lang/rust/issues/131114#issuecomment-2646663535 Also corrected a typo: "_an_ invalid literal", not "_a_ invalid literal".
2025-02-17Rollup merge of #136817 - dianne:clean-and-comment-pat-migration, r=NadrierilMatthias Krüger-114/+205
Pattern Migration 2024: clean up and comment This follows up on #136577 by moving the pattern migration logic to its own module, removing a bit of unnecessary complexity, and adding comments. Since there's quite a bit of pattern migration logic now (and potentially more in #136496), I think it makes sense to keep it separate from THIR construction, at least as much as is convenient. r? ``@Nadrieril``
2025-02-17Rollup merge of #136671 - nnethercote:middle-limits, r=NadrierilMatthias Krüger-82/+85
Overhaul `rustc_middle::limits` In particular, to make `pattern_complexity` work more like other limits, which then enables some other simplifications. r? ``@Nadrieril``
2025-02-17Rollup merge of #136466 - nnethercote:start-removing-Map, r=cjgillotMatthias Krüger-448/+432
Start removing `rustc_middle::hir::map::Map` `rustc_middle::hir::map::Map` is now just a low-value wrapper around `TyCtxt`. This PR starts removing it. r? `@cjgillot`
2025-02-16bookkeep properly when pointing into macro expansionsdianne-16/+18
2025-02-17stabilize (const_)ptr_sub_ptrbendn-1/+0
2025-02-17Remove `TyCtxt::hir_krate`.Nicholas Nethercote-8/+2
It's a trivial wrapper around the `hir_crate` query with a small number of uses.
2025-02-17Overhaul the `intravisit::Map` trait.Nicholas Nethercote-134/+135
First of all, note that `Map` has three different relevant meanings. - The `intravisit::Map` trait. - The `map::Map` struct. - The `NestedFilter::Map` associated type. The `intravisit::Map` trait is impl'd twice. - For `!`, where the methods are all unreachable. - For `map::Map`, which gets HIR stuff from the `TyCtxt`. As part of getting rid of `map::Map`, this commit changes `impl intravisit::Map for map::Map` to `impl intravisit::Map for TyCtxt`. It's fairly straightforward except various things are renamed, because the existing names would no longer have made sense. - `trait intravisit::Map` becomes `trait intravisit::HirTyCtxt`, so named because it gets some HIR stuff from a `TyCtxt`. - `NestedFilter::Map` assoc type becomes `NestedFilter::MaybeTyCtxt`, because it's always `!` or `TyCtxt`. - `Visitor::nested_visit_map` becomes `Visitor::maybe_tcx`. I deliberately made the new trait and associated type names different to avoid the old `type Map: Map` situation, which I found confusing. We now have `type MaybeTyCtxt: HirTyCtxt`.
2025-02-17Move some `Map` methods onto `TyCtxt`.Nicholas Nethercote-300/+297
The end goal is to eliminate `Map` altogether. I added a `hir_` prefix to all of them, that seemed simplest. The exceptions are `module_items` which became `hir_module_free_items` because there was already a `hir_module_items`, and `items` which became `hir_free_items` for consistency with `hir_module_free_items`.
2025-02-17Auto merge of #136953 - ken-matsui:import-target-metadata, r=workingjubileebors-568/+679
rustc_target: import TargetMetadata
2025-02-16rustc_target: import TargetMetadataKen Matsui-568/+679