Commit Graph

281755 Commits

Author SHA1 Message Date
bors
ed49386d3a Auto merge of #136539 - matthewjasper:late-normalize-errors, r=compiler-errors
Emit dropck normalization errors in borrowck

Borrowck generally assumes that any queries it runs for type checking will succeed, thinking that HIR typeck will have errored first if there was a problem. However as of #98641, dropck isn't run on HIR, so there's no direct guarantee that it doesn't error. While a type being well-formed might be expected to ensure that its fields are well-formed, this is not the case for types containing a type projection:

```rust
pub trait AuthUser {
    type Id;
}

pub trait AuthnBackend {
    type User: AuthUser;
}

pub struct AuthSession<Backend: AuthnBackend> {
    data: Option<<<Backend as AuthnBackend>::User as AuthUser>::Id>,
}

pub trait Authz: Sized {
    type AuthnBackend: AuthnBackend<User = Self>;
}

pub fn run_query<User: Authz>(auth: AuthSession<User::AuthnBackend>) {}
// ^ No User: AuthUser bound is required or inferred.
```

While improvements to trait solving might fix this in the future, for now we go for a pragmatic solution of emitting an error from borrowck (by rerunning dropck outside of a query) and making drop elaboration check if an error has been emitted previously before panicking for a failed normalization.

Closes #103899
Closes #135039

r? `@compiler-errors` (feel free to re-assign)
2025-02-19 07:49:08 +00: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
24ba1ad31c
Rollup merge of #137242 - ehuss:reference-do_not_recommend, r=compiler-errors
Add reference annotations for the `do_not_recommend` attribute

This adds reference rule identifiers for the tests of the `diagnostic::do_not_recommend` attribute.
2025-02-19 01:30:14 +01:00
Matthias Krüger
e51fae58da
Rollup merge of #137228 - steffahn:one-coerces-to-supertypes-not-subtypes, r=the8472
Fix typo in hidden internal docs of `TrustedRandomAccess`

I typoed the coercion direction here 4 years ago; fixing it now
2025-02-19 01:30:14 +01: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
d0c1e1c0e8
Rollup merge of #137177 - GuillaumeGomez:update-minifier, r=notriddle
Update `minifier-rs` version to `0.3.5`

Encountered a bug around handling of `*` which blocked me for something I'm working on.

Also includes multiple fixes from ```@notriddle.```

r? ```@notriddle```
2025-02-19 01:30:11 +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
Matthias Krüger
38fba8ca96
Rollup merge of #137026 - GrigorenkoPV:integer_sign_cast, r=jhpratt
Stabilize (and const-stabilize) `integer_sign_cast`

Tracking issue: #125882
Closes: #125882
FCP completed: https://github.com/rust-lang/rust/issues/125882#issuecomment-2658274124
2025-02-19 01:30:10 +01:00
Matthias Krüger
616b6c35a5
Rollup merge of #136936 - xingxue-ibm:sigpipe-test, r=workingjubilee
Use 'yes' instead of 'while-echo' in tests/ui/process/process-sigpipe.rs except 'nto'

The `sh` of AIX prints a message about a broken pipe when using the `while-echo` command. It works as expected when using the `yes` command instead. `yes` was originally used in this test but was later replaced with `while-echo` because QNX Neutrino does not have `yes` ([Replace yes command by while-echo in test tests/ui/process/process-sigpipe.rs](https://github.com/rust-lang/rust/pull/109379)). This PR updates the test to use `while-echo` for QNX Neutrino while reverting to `yes` for other platforms.
2025-02-19 01:30:09 +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
Eric Huss
0a094196f3 Add reference annotations for the do_not_recommend attribute 2025-02-18 10:36:53 -08:00
bors
827a0d638d Auto merge of #137231 - Urgau:rollup-heiq934, r=Urgau
Rollup of 9 pull requests

Successful merges:

 - #136750 (Make ub_check message clear that it's not an assert)
 - #137151 (Install more signal stack trace handlers)
 - #137167 (tests: Also gate `f16::erfc()` doctest with `reliable_f16_math` cfg)
 - #137195 (cg_clif: use exclusively ABI alignment)
 - #137202 (Enforce T: Hash for Interned<...>)
 - #137205 (Remove `std::os::wasi::fs::FileExt::tell`)
 - #137211 (don't ICE for alias-relate goals with error term)
 - #137214 (add last std diagnostic items for clippy)
 - #137221 (Remove scrutinee_hir_id from ExprKind::Match)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-18 18:04:32 +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
05dbe6ddff
Rollup merge of #137191 - ehuss:update-mdbook, r=jieyouxu
Update mdbook and move error_index_generator

This moves error_index_generator to the rustbook workspace so that it can share the dependency with mdbook. I had forgotten that error_index_generator is using mdbook.

This includes a corresponding update to mdbook which avoids a regression in error_index_generator.

Closes https://github.com/rust-lang/rust/issues/137052
2025-02-18 18:40:53 +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
ac3b179c3b
Rollup merge of #137126 - m4rch3n1ng:fix-inherent-str-docs, r=Amanieu
fix docs for inherent str constructors

related to #131114

when implementing inherent str constructors in #136517, i forgot to change the docs, so the code examples still imported the `std::str` module and used the constructor from there, instead of using "itself" (the inherent constructor).
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
5a942d67a6
Rollup merge of #136876 - joshtriplett:locking-might-not-be-advisory, r=Amanieu
Locking documentation updates

- Reword file lock documentation to clarify advisory vs mandatory. Remove the
  word "advisory", and make it more explicit that the lock may be advisory or
  mandatory depending on platform.

- Document that locking a file fails on Windows if the file is opened only for append
2025-02-18 18:40:50 +01:00
Matthias Krüger
58a622b019
Rollup merge of #136599 - yotamofek:pr/rustdoc-more-joined, r=GuillaumeGomez
librustdoc: more usages of `Joined::joined`

Some missed opportunities from #136244
r? ```@GuillaumeGomez``` since you reviewed the last one (feel free to re-assign, of course 😊)
First two commits are just drive-by cleanups
2025-02-18 18:40:50 +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
73e5abd175
Rollup merge of #137205 - thaliaarchi:remove-wasi-fileext-tell, r=alexcrichton
Remove `std::os::wasi::fs::FileExt::tell`

Following #137165 (Use `tell` for `<File as Seek>::stream_position`), `tell` is now directly exposed via `stream_position`, making `<File as FileExt>::tell` redundant. Remove it.

`std::os::wasi::fs::FileExt::tell` is currently unstable and tracked in https://github.com/rust-lang/rust/issues/71213.

``@rustbot`` ping wasi
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
14fb84a5bb
Rollup merge of #137167 - martn3:reliable_f16_math-f16-erfc, r=tgross35
tests: Also gate `f16::erfc()` doctest with `reliable_f16_math` cfg

In #136324 the doctest for `f16::erf()` was gated with `reliable_f16_math`. Add the same gate on `f16::erfc()` to avoid:

    rust_out.71e2e529d20ea47d-cgu.0:\
    (.text._ZN8rust_out4main43_doctest_main_library_std_src_f16_rs_1321_017h485f3ffe6bf2a981E+0x38): \
    undefined reference to `__gnu_h2f_ieee'

on MIPS (and maybe other architectures).

r? tgross35
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
Urgau
d7fe4c0e92
Rollup merge of #136750 - kornelski:ub-bug, r=saethlin
Make ub_check message clear that it's not an assert

I've seen a user assume that their unsound code was *safe*, because ub_check prevented the program from performing the unsafe operation.

This PR makes the panic message clearer that ub_check is a bug detector, not run-time safety protection.
2025-02-18 18:34:13 +01:00
Frank Steffahn
d93926cb5d Fix typo in hidden internal docs of TrustedRandomAccess
I typoed the coercion direction here 4 years ago; fixing it now
2025-02-18 17:54:56 +01:00
Josh Triplett
ec2034d53d Reorder "This lock may be advisory or mandatory." earlier in the lock docs 2025-02-18 17:31:10 +01:00
Josh Triplett
35674eff6f Clarify that locking on Windows also works for files opened with .read(true) 2025-02-18 17:26:33 +01:00
Xing Xue
0ffb771607 Use yes except target_os = "nto". 2025-02-18 16:22:16 +00: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