Commit Graph

282175 Commits

Author SHA1 Message Date
Oli Scherer
3565603d25 Use a safe wrapper around an LLVM FFI function 2025-02-24 15:11:29 +00:00
Oli Scherer
f16f64b15a Remove inherent function that has a trait method duplicate of a commonly imported trait 2025-02-24 15:11:29 +00:00
Oli Scherer
241c83f0c7 Deduplicate more functions between SimpleCx and CodegenCx 2025-02-24 15:11:29 +00:00
Oli Scherer
29440b84a9 Remove an unused lifetime param 2025-02-24 15:11:29 +00:00
Oli Scherer
396baa750e Make allocator shim creation mostly use safe code 2025-02-24 15:11:29 +00:00
Oli Scherer
840e31b29f Generalize BaseTypeCodegenMethods 2025-02-24 15:11:29 +00:00
Oli Scherer
75356b7437 Generalize BackendTypes over GenericCx 2025-02-24 15:11:29 +00:00
Oli Scherer
bfd88cead0 Avoid some duplication between SimpleCx and CodegenCx 2025-02-24 15:11:29 +00:00
Oli Scherer
d4379d2afd Remove an unnecessary lifetime 2025-02-24 15:05:56 +00:00
Oli Scherer
a54bfcf52b Use safe FFI for various functions in codegen_llvm 2025-02-24 15:05:56 +00:00
bors
bb029a1d3f Auto merge of #137511 - jhpratt:rollup-07whsax, r=jhpratt
Rollup of 10 pull requests

Successful merges:

 - #136610 (Allow `IndexSlice` to be indexed by ranges.)
 - #136991 ([rustdoc] Add new setting to wrap source code lines when too long)
 - #137061 (Unstable `gen_future` Feature Tracking  )
 - #137393 (Stabilize `unbounded_shifts`)
 - #137482 (Windows: use existing wrappers in `File::open_native`)
 - #137484 (Fix documentation for unstable sort on slice)
 - #137491 (Tighten `str-to-string-128690.rs``CHECK{,-NOT}`s to make it less likely to incorrectly fail with symbol name mangling)
 - #137495 (Added into_value function to ControlFlow<T, T>)
 - #137501 (Move `impl` blocks out of `rustc_middle/src/mir/syntax.rs`)
 - #137505 (Add a span to `CompilerBuiltinsCannotCall`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-24 10:27:53 +00:00
Jacob Pratt
42014b44b3
Rollup merge of #137505 - tgross35:builtins-cannot-call-error, r=compiler-errors
Add a span to `CompilerBuiltinsCannotCall`

Currently, this error emit a diagnostic with no context like:

    error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt`

With this change, it at least usually points to the problematic function:

    error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt`
       --> src/../libm/src/math/support/hex_float.rs:270:5
        |
    270 |     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
2025-02-24 02:11:38 -05:00
Jacob Pratt
c9411ea78e
Rollup merge of #137501 - nnethercote:mv-impls-out-of-syntax, r=compiler-errors
Move `impl` blocks out of `rustc_middle/src/mir/syntax.rs`

Best reviewed one commit at a time.
2025-02-24 02:11:37 -05:00
Jacob Pratt
3a1549ca8e
Rollup merge of #137495 - madhav-madhusoodanan:feature-unstable-control-flow-into-value, r=jhpratt
Added into_value function to ControlFlow<T, T>
2025-02-24 02:11:36 -05:00
Jacob Pratt
e66fcc3410
Rollup merge of #137491 - jieyouxu:mango-less-likely, r=saethlin
Tighten `str-to-string-128690.rs``CHECK{,-NOT}`s to make it less likely to incorrectly fail with symbol name mangling

The `invoke` to match on to `CHECK` or `CHECK-NOT` (latest master) looks like

```llvm
  %_0.i.i.i.i.i.i.i.i.i.i.i.i.i1.i = invoke noundef zeroext i1 ``@"_ZN42_$LT$str$u20$as$u20$core..fmt..Display$GT$3fmt17ha18033e7fb4f14fcE"(ptr`` noalias noundef nonnull readonly align 1 %_3.val.i.i.i.i.i.i.i.i.i.i.i.i.i, i64 noundef %_3.val1.i.i.i.i.i.i.i.i.i.i.i.i.i, ptr noalias noundef nonnull align 8 dereferenceable(64) %formatter.i)
          to label %bb1.i unwind label %cleanup.i, !noalias !80
```

in the local `.ll` output.

This test incorrectly failed in https://github.com/rust-lang/rust/pull/137483#issuecomment-2676925819 due to

```
// CHECK-NOT: {{(call|invoke).*}}fmt
```

matching against the unrelated call

```llvm
tail call void ``@_RNvNtCseLfmtnDCoTB_5alloc7raw_vec12handle_error``
```

It's not pretty by any means, but...

r? ``@saethlin``
2025-02-24 02:11:35 -05:00
Jacob Pratt
8a8c0e25c9
Rollup merge of #137484 - chenyukang:yukang-fix-sort-doc, r=Noratrieb
Fix documentation for unstable sort on slice

Fixes #136665
2025-02-24 02:11:35 -05:00
Jacob Pratt
56fca2638f
Rollup merge of #137482 - rust9x:win-file-open-truncate, r=ChrisDenton
Windows: use existing wrappers in `File::open_native`

Just a small improvement I've noticed - prevents accidents regarding `SetFileInformationByHandle` parameters.

Probably ``@ChrisDenton`` since we talked about it on discord :)
2025-02-24 02:11:34 -05:00
Jacob Pratt
31640178bd
Rollup merge of #137393 - chorman0773:unbounded-shifts-stabilize, r=Amanieu
Stabilize `unbounded_shifts`

This stabilizes and const-stabilizes `<iN>::unbounded_shl` and `<uN>::unbounded_shr` from https://github.com/rust-lang/rust/issues/129375.
2025-02-24 02:11:34 -05:00
Jacob Pratt
b7f11ef362
Rollup merge of #137061 - progressive-galib:gen_future-closing#76249, r=ibraheemdev
Unstable `gen_future` Feature Tracking

This PR removes the reference to the closed tracking issue **#50547** for the `gen_future` feature. Since `gen_future` is an internal feature used in async block desugaring, it does not require a public tracking issue.

#### Changes:
- Replaced `issue = "50547"` with `issue = "none"` in **library/core/src/future/mod.rs**.
- Ensures that it is correctly identified as an internal feature.

#### Rationale:
With this change, the Unstable Book will now state:
> *"This feature has no tracking issue and is therefore likely internal to the compiler, not being intended for general use."*

Closes **#76249**. 🚀🦀
2025-02-24 02:11:33 -05:00
Jacob Pratt
8133652562
Rollup merge of #136991 - GuillaumeGomez:code-wrapping, r=notriddle
[rustdoc] Add new setting to wrap source code lines when too long

Fixes https://github.com/rust-lang/rust/issues/127334.

Wrapped lines look like this:

![image](https://github.com/user-attachments/assets/92006a27-ed1e-4beb-91f2-f453b72c5e1a)

It works in both source code pages and doc pages.

You can test it [here](https://rustdoc.crud.net/imperio/code-wrapping/bar/index.html).

r? ``@notriddle``
2025-02-24 02:11:32 -05:00
Jacob Pratt
6aa015ae9d
Rollup merge of #136610 - Jarcho:range_idx, r=Noratrieb
Allow `IndexSlice` to be indexed by ranges.

This comes with some annoyances as the index type can no longer inferred from indexing expressions. The biggest offender for this is `IndexVec::from_fn_n(|idx| ..., n)` where the index type won't be inferred from the call site or any index expressions inside the closure.

My main use case for this is mapping a `Place` to `Range<Idx>` for value tracking where the range represents all the values the place contains.
2025-02-24 02:11:32 -05:00
bors
f43e549b88 Auto merge of #137285 - yotamofek:pr/rustdoc/pulldown-escaping, r=GuillaumeGomez
librustdoc: Use `pulldown-cmark-escape` for HTML escaping

Implementation of `@notriddle` 's [suggestion](https://github.com/rust-lang/rust/pull/137274#issuecomment-2669001585).
Somewhat related to #137274 , but the two PRs should be complementary.

Local perf results look like a nice improvement! (so would love a perf run on the CI)
2025-02-24 07:11:04 +00:00
Trevor Gross
7a2db88a56 Add a span to CompilerBuiltinsCannotCall
Currently, this error emit a diagnostic with no context like:

    error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt`

With this change, it at least usually points to the problematic
function:

    error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt`
       --> src/../libm/src/math/support/hex_float.rs:270:5
        |
    270 |     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
2025-02-24 03:33:16 +00:00
bors
e0be1a0262 Auto merge of #137271 - nikic:gep-nuw-2, r=scottmcm
Emit getelementptr inbounds nuw for pointer::add()

Lower pointer::add (via intrinsic::offset with unsigned offset) to getelementptr inbounds nuw on LLVM versions that support it. This lets LLVM make use of the pre-condition that the offset addition does not wrap in an unsigned sense. Together with inbounds, this also implies that the offset is non-negative.

Fixes https://github.com/rust-lang/rust/issues/137217.
2025-02-24 03:06:16 +00:00
Madhav Madhusoodanan
f49b6c6cd5 Added into_value const function to ControlFlow<T, T>
Fixed issue with usage of generics and moved feature gate to crate root

Removed const tag

Fixed alphabetical ordering of feature gate, added same to doctest

Removed crate-level declaration of feature gate control_flow_into_value

Used const_precise_live_drops to constify into_value without issue of a drop
2025-02-24 07:36:27 +05:30
bors
9af8985e05 Auto merge of #137497 - tgross35:rollup-1oeclrr, r=tgross35
Rollup of 8 pull requests

Successful merges:

 - #136439 (Misc. `rustc_codegen_ssa` cleanups 🧹)
 - #136543 (intrinsics: unify rint, roundeven, nearbyint in a single round_ties_even intrinsic)
 - #136637 (Add binary_format to rustc target specs)
 - #137099 (Fix rustdoc test directives that were accidentally ignored 🧐)
 - #137297 (Update `compiler-builtins` to 0.1.147)
 - #137451 (FIx `sym` -> `syn` typo in tail-expr-drop-order type opt-out)
 - #137452 (bootstrap: add module docs for core:metadata)
 - #137483 (rename sub_ptr to offset_from_unsigned)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-23 23:49:11 +00:00
Nicholas Nethercote
4183c08511 Fix some use items that import more than necessary. 2025-02-24 09:30:42 +11:00
Nicholas Nethercote
1eddb158f9 Move impl blocks out of rustc_middle/src/mir/syntax.rs.
As the comment at the top says, this file is not supposed to contain any
code. But some has crept in. This commit moves it out.
2025-02-24 09:16:10 +11:00
bors
f8a913b138 Auto merge of #137476 - onur-ozkan:137469, r=jieyouxu
avoid `compiler_for` for dist tools and force the current compiler

Using `compiler_for` in dist steps was causing to install stage1 tools into the dist tarballs, which doesn't match with the stage2 compiler.

Fixes https://github.com/rust-lang/rust/issues/137469
2025-02-23 20:32:32 +00:00
Trevor Gross
18ffee2126
Rollup merge of #137483 - bend-n:😅, r=Noratrieb
rename sub_ptr to offset_from_unsigned

i also made `byte_sub_ptr` `byte_offset_from_unsigned`

fixes #137121
tracking issue #95892
2025-02-23 14:30:28 -05:00
Trevor Gross
e8342e7d42
Rollup merge of #137452 - Shourya742:2025-02-23-add-module-level-doc-for-core-metadata, r=Kobzol
bootstrap: add module docs for core:metadata

Add module doc for bootstrap:core:metadata
2025-02-23 14:30:28 -05:00
Trevor Gross
781203dd87
Rollup merge of #137451 - compiler-errors:synm, r=Noratrieb
FIx `sym` -> `syn` typo in tail-expr-drop-order type opt-out

The #131326 PR attempts to reduce some false positives for the `tail_expr_drop_order` lint by hard-coding some common ecosystem crate names. Specifically, I believe it attempts to opt out the drop impls from `syn` which only exist as optimizations.

However, this was typo'd like "sym", which is a crate that has been [yanked](https://crates.io/crates/sym) (lol). This PR fixes that.

cc `@dingxiangfei2009` `@nikomatsakis` -- did I mistake this? Was this meant to be a different crate?

`@bors` rollup
2025-02-23 14:30:27 -05:00
Trevor Gross
fb54acd700
Rollup merge of #137297 - tgross35:update-builtins, r=tgross35
Update `compiler-builtins` to 0.1.147

Removes an ABI hack that used `<2 x i64>` to return `i128` in `xmm0` on Windows [1].

[1]: https://github.com/rust-lang/compiler-builtins/pull/759
Link: https://github.com/rust-lang/rust/issues/116558
Link: https://github.com/rust-lang/compiler-builtins/issues/758

try-job: x86_64-mingw-1
try-job: x86_64-mingw-2
2025-02-23 14:30:27 -05:00
Trevor Gross
5f35f780a4
Rollup merge of #137099 - yotamofek:pr/rustdoc/fix-ignored-test-directives, r=fmease
Fix rustdoc test directives that were accidentally ignored 🧐

Replace "// `@"` with "//@ ", and fix the tests so they actually pass, after directives are checked.
~~Only the first commit is mandatory, other two are small drive-bys.~~
2025-02-23 14:30:26 -05:00
Trevor Gross
2c6fa32bdc
Rollup merge of #136637 - Pyr0de:binary-format, r=Noratrieb
Add binary_format to rustc target specs

Added binary format field to `TargetOptions`

Fixes #135724

r? `@Noratrieb`
2025-02-23 14:30:26 -05:00
Trevor Gross
a2bb4d748d
Rollup merge of #136543 - RalfJung:round-ties-even, r=tgross35
intrinsics: unify rint, roundeven, nearbyint in a single round_ties_even intrinsic

LLVM has three intrinsics here that all do the same thing (when used in the default FP environment). There's no reason Rust needs to copy that historically-grown mess -- let's just have one intrinsic and leave it up to the LLVM backend to decide how to lower that.

Suggested by `@hanna-kruppe` in https://github.com/rust-lang/rust/issues/136459; Cc `@tgross35`

try-job: test-various
2025-02-23 14:30:25 -05:00
Trevor Gross
31719b59c8
Rollup merge of #136439 - yotamofek:pr/codegen-ssa-no-indexing, r=Noratrieb
Misc. `rustc_codegen_ssa` cleanups 🧹

Just a bunch of stuff I found while reading the crate's code.
Each commit can stand on its own.
Maybe r? `@Noratrieb` because I saw you did some similar cleanups on these files a while ago? (feel free to re-assign, I'm just guessing)
2025-02-23 14:30:24 -05:00
许杰友 Jieyou Xu (Joe)
e15ce94eae tests: tighten CHECK-NOTs to make str-to-string-128690.rs less likely to collide with symbol name mangling 2025-02-24 01:17:32 +08:00
bendn
c813d8f3e4
rename sub_ptr 😅 2025-02-23 23:11:00 +07:00
yukang
1a440d56d6 Fix documentation for unstable sort 2025-02-23 22:29:53 +08:00
bors
b522e7c5ea Auto merge of #137225 - RalfJung:vectorcall, r=nnethercote
vectorcall ABI: require SSE2

According to the official docs at https://learn.microsoft.com/en-us/cpp/cpp/vectorcall, SSE2 is required for this ABI. Add a check that enforces this.

I put this together with the other checks ensuring the target features required for a function are present... however, since the ABI is known pre-monomorphization, it would be possible to do this check earlier, which would have the advantage of checking even in `cargo check`. It would have the disadvantage of spreading this code in yet more places.

The first commit just does a little refactoring of the mono-time ABI check to make it easier to add the new check.

Cc `@workingjubilee`

try-job: dist-i586-gnu-i586-i686-musl
2025-02-23 14:12:38 +00:00
Dennis Duda
87c0380799 Win: use existing wrappers for SetFileInformationByHandle in File::open_native 2025-02-23 14:19:58 +01:00
onur-ozkan
1c7b60f8a4 add FIXME note on Builder::compiler_for
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-02-23 16:05:51 +03:00
onur-ozkan
50f84129e6 avoid compiler_for for dist tools and force the current compiler
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-02-23 11:55:19 +00:00
bors
b880760977 Auto merge of #137237 - cuviper:stage0, r=Mark-Simulacrum
Master bootstrap update

https://forge.rust-lang.org/release/process.html#master-bootstrap-update-tuesday

r? `@Mark-Simulacrum`
2025-02-23 11:12:56 +00:00
Ralf Jung
b9d0555d11 add stdarch compatibility hack 2025-02-23 11:53:49 +01:00
bors
1805b33483 Auto merge of #137466 - jhpratt:rollup-spyi02y, r=jhpratt
Rollup of 9 pull requests

Successful merges:

 - #135354 ([Debuginfo] Add MSVC Synthetic and Summary providers to LLDB)
 - #136826 (Replace mem::zeroed with mem::MaybeUninit::uninit for large struct in Unix)
 - #137194 (More const {} init in thread_local)
 - #137334 (Greatly simplify lifetime captures in edition 2024)
 - #137382 (bootstrap: add doc for vendor build step)
 - #137423 (Improve a bit HIR pretty printer)
 - #137435 (Fix "missing match arm body" suggestion involving `!`)
 - #137448 (Fix bugs due to unhandled `ControlFlow` in compiler)
 - #137458 (Fix missing self subst when rendering `impl Fn*<T>` with no output type)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-23 08:06:25 +00:00
Jacob Pratt
d41520052e
Rollup merge of #137458 - compiler-errors:render-fn, r=fmease
Fix missing self subst when rendering `impl Fn*<T>` with no output type

r? `@fmease` or reassign

Fixes #133597
cc #137456
2025-02-23 02:44:20 -05:00
Jacob Pratt
f5c6287d76
Rollup merge of #137448 - compiler-errors:control-flow-oops, r=scottmcm
Fix bugs due to unhandled `ControlFlow` in compiler

Well, one bug and one nit.
2025-02-23 02:44:20 -05:00
Jacob Pratt
da493c91d6
Rollup merge of #137435 - estebank:match-arm-2, r=compiler-errors
Fix "missing match arm body" suggestion involving `!`

Include the match arm guard in the gated span, so that the suggestion to add a body is correct instead of inserting the body before the guard.

Make the suggestion verbose.

```
error: `match` arm with no body
  --> $DIR/feature-gate-never_patterns.rs:43:9
   |
LL |         Some(_) if false,
   |         ^^^^^^^^^^^^^^^^
   |
help: add a body after the pattern
   |
LL |         Some(_) if false => { todo!() },
   |                          ++++++++++++++
```

r? `@compiler-errors`
2025-02-23 02:44:19 -05:00