Commit graph

43988 commits

Author SHA1 Message Date
Nicholas Nethercote
c301ba57a6 Fix a typo in a comment. 2025-02-21 07:12:13 +11:00
Nicholas Nethercote
e2e4d0bdb1 Remove an unnecessary re-export.
It's a bit weird.
2025-02-21 07:12:13 +11:00
Nicholas Nethercote
c2dba9ce78 Rename InternedObligationCauseCode.
It's a misleading name, because it's not interned.
2025-02-21 06:56:56 +11:00
Nicholas Nethercote
0895fe20e2 Remove unused items from query.rs. 2025-02-20 13:48:37 +11:00
Nicholas Nethercote
dc4f948299 Move StatementAsExpression to where it's actually used.
Also minimize some visibilities in the destination file.
2025-02-20 13:48:37 +11:00
bors
5986ff05d8 Auto merge of #137248 - matthiaskrgr:rollup-s18zjau, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #136936 (Use 'yes' instead of 'while-echo' in tests/ui/process/process-sigpipe.rs except 'nto')
 - #137026 (Stabilize (and const-stabilize) `integer_sign_cast`)
 - #137059 (fix: Alloc new errorcode E0803 for E0495)
 - #137177 (Update `minifier-rs` version to `0.3.5`)
 - #137210 (compiler: Stop reexporting stuff in cg_llvm::abi)
 - #137213 (Remove `rustc_middle::mir::tcx` module.)
 - #137216 (eval_outlives: bail out early if both regions are in the same SCC)
 - #137228 (Fix typo in hidden internal docs of `TrustedRandomAccess`)
 - #137242 (Add reference annotations for the `do_not_recommend` attribute)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-19 04:37:26 +00:00
bors
17c1c329a5 Auto merge of #135408 - RalfJung:x86-sse2, r=workingjubilee
x86: use SSE2 to pass float and SIMD types

This builds on the new X86Sse2 ABI landed in https://github.com/rust-lang/rust/pull/137037 to actually make it a separate ABI from the default x86 ABI, and use SSE2 registers. Specifically, we use it in two ways: to return `f64` values in a register rather than by-ptr, and to pass vectors of size up to 128bit in a register (or, well, whatever LLVM does when passing `<4 x float>` by-val, I don't actually know if this ends up in a register).

Cc `@workingjubilee`
Fixes #133611

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
try-job: x86_64-msvc-1
2025-02-19 01:25:01 +00:00
Matthias Krüger
cf8d34257d
Rollup merge of #137216 - amandasystems:cheap-outlives-eval, r=compiler-errors
eval_outlives: bail out early if both regions are in the same SCC

A drive-by optimisation of region outlives evaluation: if we are evaluating whether an outlives holds for two regions, bail out early if they are both in the same SCC.

This probably won't make a huge difference, but the cost is one comparison of SCC indices (integers).

May want a perf run, depending on how confident whomever reviewing this is!
2025-02-19 01:30:13 +01:00
Matthias Krüger
34535b6078
Rollup merge of #137213 - nnethercote:rm-rustc_middle-mir-tcx, r=compiler-errors
Remove `rustc_middle::mir::tcx` module.

This is a really weird module. For example, what does `tcx` in `rustc_middle::mir::tcx::PlaceTy` mean? The answer is "not much".

The top-level module comment says:

> Methods for the various MIR types. These are intended for use after
> building is complete.

Awfully broad for a module that has a handful of impl blocks for some MIR types, none of which really relates to `TyCtxt`. `git blame` indicates the comment is ancient, from 2015, and made sense then.

This module is now vestigial. This commit removes it and moves all the code within into `rustc_middle::mir::statement`. Some specifics:

- `Place`, `PlaceRef`, `Rvalue`, `Operand`, `BorrowKind`: they all have `impl` blocks in both the `tcx` and `statement` modules. The commit merges the former into the latter.

- `BinOp`, `UnOp`: they only have `impl` blocks in `tcx`. The commit moves these into `statement`.

- `PlaceTy`, `RvalueInitializationState`: they are defined in `tcx`. This commit moves them into `statement` *and* makes them available in `mir::*`, like many other MIR types.

r? `@tmandry`
2025-02-19 01:30:13 +01:00
Matthias Krüger
2bd65ebede
Rollup merge of #137210 - workingjubilee:fixup-passmode-import, r=RalfJung
compiler: Stop reexporting stuff in cg_llvm::abi

The reexports confuse tooling like rustdoc into thinking cg_llvm is the source of key types that originate in rustc_target.
2025-02-19 01:30:12 +01:00
Matthias Krüger
960b122136
Rollup merge of #137059 - xizheyin:issue-136827, r=davidtwco
fix: Alloc new errorcode E0803 for E0495

As discussion in #136827, I alloc a new errorcode.
2025-02-19 01:30:11 +01:00
Nicholas Nethercote
5d1551b9c6 Remove rustc_middle::mir::tcx module.
This is a really weird module. For example, what does `tcx` in
`rustc_middle::mir::tcx::PlaceTy` mean? The answer is "not much".

The top-level module comment says:

> Methods for the various MIR types. These are intended for use after
> building is complete.

Awfully broad for a module that has a handful of impl blocks for some
MIR types, none of which really relates to `TyCtxt`. `git blame`
indicates the comment is ancient, from 2015, and made sense then.

This module is now vestigial. This commit removes it and moves all the
code within into `rustc_middle::mir::statement`. Some specifics:

- `Place`, `PlaceRef`, `Rvalue`, `Operand`, `BorrowKind`: they all have `impl`
  blocks in both the `tcx` and `statement` modules. The commit merges
  the former into the latter.

- `BinOp`, `UnOp`: they only have `impl` blocks in `tcx`. The commit
  moves these into `statement`.

- `PlaceTy`, `RvalueInitializationState`: they are defined in `tcx`.
  This commit moves them into `statement` *and* makes them available in
  `mir::*`, like many other MIR types.
2025-02-19 10:26:05 +11:00
bors
f44efbf9e1 Auto merge of #137235 - matthiaskrgr:rollup-2kjua2t, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #135711 (Do not ICE on default_field_value const with lifetimes)
 - #136599 (librustdoc: more usages of `Joined::joined`)
 - #136876 (Locking documentation updates)
 - #137000 (Deeply normalize item bounds in new solver)
 - #137126 (fix docs for inherent str constructors)
 - #137161 (Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions)
 - #137191 (Update mdbook and move error_index_generator)
 - #137203 (Improve MIR modification)
 - #137206 (Make E0599 a structured error)
 - #137218 (misc `layout_of` cleanup)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-18 21:08:58 +00:00
Matthias Krüger
bafff1b3af
Rollup merge of #137218 - lukas-code:layout_of_cleanup, r=compiler-errors
misc `layout_of` cleanup

See individual commits for details.

r? `@oli-obk` but feel free to reassign
2025-02-18 18:40:55 +01:00
Matthias Krüger
a66ef2f40e
Rollup merge of #137206 - estebank:e0599-structured, r=jieyouxu
Make E0599 a structured error
2025-02-18 18:40:54 +01:00
Matthias Krüger
10dd016a80
Rollup merge of #137203 - nnethercote:improve-MIR-modification, r=compiler-errors
Improve MIR modification

A few commits that simplify code that manipulates MIR bodies.

r? `@tmiasko`
2025-02-18 18:40:54 +01:00
Matthias Krüger
54db888355
Rollup merge of #137161 - dianne:pat-migration-bookkeeping-for-macros, r=Nadrieril
Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions

See the diff between the two commits for how this affected the error message and suggestion. In order to decide how to format those, the pattern migration diagnostic keeps track of which parts of the user's pattern cause problems in Edition 2024. However, it neglected to do some of this bookkeeping when pointing to macro expansion sites. This fixes that.
2025-02-18 18:40:52 +01:00
Matthias Krüger
c8d904125e
Rollup merge of #137000 - compiler-errors:deeply-normalize-item-bounds, r=lcnr
Deeply normalize item bounds in new solver

Built on #136863.

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/142.
Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/151.

cc https://github.com/rust-lang/trait-system-refactor-initiative/issues/116

First commit reworks candidate preference for projection bounds to prefer param-env projection clauses even if the corresponding trait ref doesn't come from the param-env.

Second commit adjusts the associated type item bounds check to deeply normalize in the new solver. This causes some test fallout which I will point out.

r? lcnr
2025-02-18 18:40:51 +01:00
Matthias Krüger
7edd17cfbb
Rollup merge of #135711 - estebank:issue-135649, r=davidtwco
Do not ICE on default_field_value const with lifetimes

`#![feature(default_field_values)]` uses a `const` body that should be treated as inline `const`s, but is actually being detected otherwise. This is similar to the situation in #78174, so we take the same solution: we check if the const actually comes from a field, and if it does, we use that logic to get the appropriate lifetimes and not ICE during borrowck.

Fix #135649.
2025-02-18 18:40:49 +01:00
Urgau
3ebe11b2e8
Rollup merge of #137221 - bjorn3:remove_unused_field, r=compiler-errors
Remove scrutinee_hir_id from ExprKind::Match

It is unused.
2025-02-18 18:34:19 +01:00
Urgau
b7c2da2231
Rollup merge of #137214 - cyrgani:clippy_diagnostic_items, r=compiler-errors
add last std diagnostic items for clippy

Part of https://github.com/rust-lang/rust-clippy/issues/5393.
Add diagnostic item attributes to the items in `std` and `core` where clippy currently uses hardcoded paths (https://github.com/rust-lang/rust-clippy/blob/master/clippy_utils/src/paths.rs).
2025-02-18 18:34:18 +01:00
Urgau
61f04328db
Rollup merge of #137211 - lcnr:alias-relate-accept-error, r=compiler-errors
don't ICE for alias-relate goals with error term

see comment, fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/165

r? ``@compiler-errors``
2025-02-18 18:34:17 +01:00
Urgau
5b00e0b064
Rollup merge of #137202 - Mark-Simulacrum:interned-is-hash, r=saethlin
Enforce T: Hash for Interned<...>

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...). FIXME comments as such on those impls.

cc https://github.com/rust-lang/rust/pull/137196#issuecomment-2664350287

r? ``@saethlin``
2025-02-18 18:34:16 +01:00
Urgau
626fcdf48f
Rollup merge of #137195 - workingjubilee:remove-pref-align-from-cg-clif, r=bjorn3
cg_clif: use exclusively ABI alignment

This will minimize possible conflict with future updates to AbiAndPrefAlign that may remove some fields. It is also almost a bug to consider them.

r? ``@bjorn3``
2025-02-18 18:34:15 +01:00
Urgau
1391f75512
Rollup merge of #137151 - Urgau:register-more-signals, r=workingjubilee
Install more signal stack trace handlers

This PR install the signal stack handler to more signals (`SIGILL`, ~~`SIGTRAP`~~, ~~`SIGABRT`~~, ~~`SIGFPE`~~, `SIGBUS`, ~~`SIGQUIT`~~).

Noticed in https://github.com/rust-lang/rust/issues/137138 that we didn't print anything for `SIGILL`, so I though we could just handle more signals.

r? `````@workingjubilee````` since you last touched it
2025-02-18 18:34:14 +01:00
Ralf Jung
803feb5dc6 x86-sse2 ABI: use SSE registers for floats and SIMD 2025-02-18 16:11:41 +01:00
bjorn3
768a5bd470
Remove scrutinee_hir_id from ExprKind::Match
It is unused
2025-02-18 13:51:32 +01:00
Lukas Markeffsky
2fbc413d83 cosmetic changes
- change function parameter order to `cx, ty, ...` to match the other
  functions in this file
- use `ct` identifier for `ty::Const` to match the majority of the
  compiler codebase
- remove useless return
- bring match arms in a more natural order
2025-02-18 13:22:46 +01:00
Lukas Markeffsky
67345f9203 remove useless parameter
Remove the `repr` parameter from the wrappers around `calc.univariant`,
because it's always defaulted. Only ADTs can have a repr and those call
`calc.layout_of_struct_or_enum` and not `calc.univariant`.
2025-02-18 13:22:46 +01:00
Lukas Markeffsky
1d1ac3d310 remove redundant code
- 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-18 13:22:45 +01:00
Lukas Markeffsky
7a667d206c remove unreachable cases
`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-18 13:22:45 +01:00
Lukas Markeffsky
802b7abab7 clean up layout error diagnostics
- group the fluent slugs together
- reword (internal-only) "too generic" error to be more in line with
  the other errors
2025-02-18 13:22:45 +01:00
Lukas Markeffsky
d0a5bbbb8e document and test all LayoutError variants 2025-02-18 13:22:45 +01:00
Amanda Stjerna
53effa4566 eval_outlives: bail out early if both regions are in the same SCC 2025-02-18 13:02:05 +01:00
cyrgani
a72402a0f9 add last std diagnostic items for clippy 2025-02-18 10:54:37 +01:00
lcnr
f910684616 don't ICE for alias-relate goals with error term 2025-02-18 10:30:37 +01:00
Jubilee
fa53181f42
cg_clif: Tweak formatting of global comments
Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2025-02-18 01:29:23 -08:00
Jubilee Young
2d2de18166 compiler: Stop reexporting stuff in cg_llvm::abi
The reexports confuse tooling like rustdoc into thinking cg_llvm is
the source of key types that originate in rustc_target.
2025-02-18 00:31:29 -08:00
bors
3b022d8cee Auto merge of #133852 - x17jiri:cold_path, r=saethlin
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-18 07:49:09 +00:00
Esteban Küber
693f7035f1 Make E0599 a structured error 2025-02-18 04:50:33 +00:00
bors
aaa8614934 Auto merge of #137162 - nnethercote:remove-Map-2, r=Zalathar
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-18 04:26:30 +00:00
Nicholas Nethercote
04eeda47ab Inline and replace Statement::replace_nop.
It has a single call site, and doesn't seem worth having as an API
function.
2025-02-18 13:43:43 +11:00
Mark Rousskov
9fc759099b Enforce T: Hash for Interned<...>
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-17 21:35:52 -05:00
Nicholas Nethercote
69f5e342bf Inline and remove BasicBlockData::retain_statements.
It has a single call site, and the code is clearer this way.
2025-02-18 13:31:08 +11:00
Nicholas Nethercote
627e08c909 Remove BasicBlockData::expand_statements.
The previous commit removed its single use. `MirPatch` is a more
flexible alternative.
2025-02-18 13:13:32 +11:00
Nicholas Nethercote
e3316ae453 Improve MirPatch documentation and naming.
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-18 13:12:50 +11:00
Nicholas Nethercote
a1daa34ad0 Use MirPatch in EnumSizeOpt.
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-18 12:52:56 +11:00
bors
de91711756 Auto merge of #137176 - matthiaskrgr:rollup-eht05gr, r=matthiaskrgr
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-18 00:05:30 +00:00
Nicholas Nethercote
fd7b4bf4e1 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.
2025-02-18 10:17:44 +11:00
Jubilee Young
59e9eb9b2b cg_clif: use exclusively ABI alignment 2025-02-17 15:10:51 -08:00