Commit Graph

270502 Commits

Author SHA1 Message Date
Michael Goulet
49153739fd Only disable cache if predicate has opaques within it 2024-11-05 17:38:26 +00:00
bors
e8c698bb3b Auto merge of #129884 - RalfJung:forbidden-target-features, r=workingjubilee
mark some target features as 'forbidden' so they cannot be (un)set with -Ctarget-feature

The context for this is https://github.com/rust-lang/rust/issues/116344: some target features change the way floats are passed between functions. Changing those target features is unsound as code compiled for the same target may now use different ABIs.

So this introduces a new concept of "forbidden" target features (on top of the existing "stable " and "unstable" categories), and makes it a hard error to (un)set such a target feature. For now, the x86 and ARM feature `soft-float` is on that list. We'll have to make some effort to collect more relevant features, and similar features from other targets, but that can happen after the basic infrastructure for this landed. (These features are being collected in https://github.com/rust-lang/rust/issues/131799.)

I've made this a warning for now to give people some time to speak up if this would break something.

MCP: https://github.com/rust-lang/compiler-team/issues/780
2024-11-05 16:25:45 +00:00
MarcoIeni
02b34154fd
CI: switch 7 linux jobs to free runners 2024-11-05 16:56:41 +01:00
Guillaume Gomez
33009601af Add documentation on ast::Attribute 2024-11-05 16:38:15 +01:00
blyxyas
626406f1b3 Do not filter empty passes & Make CTFE Clippy into lintless pass 2024-11-05 15:27:09 +01:00
blyxyas
2eac3c0e53 Do not filter empty passes & Make CTFE Clippy into lintless pass 2024-11-05 15:27:09 +01:00
David Wood
f745467cd9
codegen_ssa: use llvm-objcopy for macOS strip 2024-11-05 11:49:37 +00:00
David Wood
d8ab230e73
bootstrap: include llvm-objcopy in dist 2024-11-05 11:49:03 +00:00
Jubilee
5b1c6264e0
Rollup merge of #132630 - RalfJung:const-eval-pings, r=jieyouxu
triagebot: ping wg-const-eval when relevant files change

This adds pings for `@rust-lang/wg-const-eval` when anything in rustc_const_eval changes (in particular, this covers the const checking logic, which was so far not covered by any notifications). I also added pings for things that so far only pinged the Miri group, since those parts are relevant to wg-const-eval as well.
2024-11-05 01:34:24 -08:00
Jubilee
ea08bbeb34
Rollup merge of #132600 - durin42:llvm-20-passbuilder-arg, r=Zalathar
PassWrapper: adapt for new parameter in LLVM

llvm/llvm-project@390300d9f4 added a new parameter to some callbacks, so we have to handle them.

`@rustbot` label: +llvm-main
2024-11-05 01:34:23 -08:00
Jubilee
57f64c67e0
Rollup merge of #132473 - ZhekaS:core_fmt_radix_no_panic, r=joboet
[core/fmt] Replace checked slice indexing by unchecked to support panic-free code

Fixes #126425

Replace the potentially panicking `[]` indexing with `get_unchecked()` to prevent linking with panic-related code.
2024-11-05 01:34:23 -08:00
Jubilee
1ee6617414
Rollup merge of #132153 - bjoernager:const-char-encode-utf16, r=dtolnay
Stabilise `const_char_encode_utf16`.

Closes: #130660

This PR stabilises the `const_char_encode_utf16` feature gate (i.e. support for `char::encode_utf16` in constant expressions).

~~Note that the linked tracking issue is as of this writing currently awaiting FCP until 2024-11-02.~~
2024-11-05 01:34:22 -08:00
bors
096277e989 Auto merge of #132580 - compiler-errors:globs, r=Noratrieb
Remove unnecessary pub enum glob-imports from `rustc_middle::ty`

We used to have an idiom in the compiler where we'd prefix or suffix all the variants of an enum, for example `BoundRegionKind`, with something like `Br`, and then *glob-import* that enum variant directly.

`@noratrieb` brought this up, and I think that it's easier to read when we just use the normal style `EnumName::Variant`.

This PR is a bit large, but it's just naming.

The only somewhat opinionated change that this PR does is rename `BorrowKind::Imm` to `BorrowKind::Immutable` and same for the other variants. I think these enums are used sparingly enough that the extra length is fine.

r? `@noratrieb` or reassign
2024-11-05 08:30:56 +00:00
bors
d8a3fcc792 Auto merge of #132580 - compiler-errors:globs, r=Noratrieb
Remove unnecessary pub enum glob-imports from `rustc_middle::ty`

We used to have an idiom in the compiler where we'd prefix or suffix all the variants of an enum, for example `BoundRegionKind`, with something like `Br`, and then *glob-import* that enum variant directly.

`@noratrieb` brought this up, and I think that it's easier to read when we just use the normal style `EnumName::Variant`.

This PR is a bit large, but it's just naming.

The only somewhat opinionated change that this PR does is rename `BorrowKind::Imm` to `BorrowKind::Immutable` and same for the other variants. I think these enums are used sparingly enough that the extra length is fine.

r? `@noratrieb` or reassign
2024-11-05 08:30:56 +00:00
Ralf Jung
613f53ef19 add const_eval_select macro to reduce redundancy
also move internal const_panic helpers to a better location
2024-11-05 09:26:08 +01:00
Ralf Jung
b81e919f65 triagebot: ping wg-const-eval when relevant files change 2024-11-05 09:13:28 +01:00
bors
27e38f8fc7 Auto merge of #132626 - workingjubilee:rollup-hbmtbzk, r=workingjubilee
Rollup of 11 pull requests

Successful merges:

 - #131153 (Improve duplicate derive Copy/Clone diagnostics)
 - #132025 (fix suggestion for diagnostic error E0027)
 - #132303 (More tests for non-exhaustive C-like enums in FFI)
 - #132492 (remove support for extern-block const intrinsics)
 - #132587 (Revert "Avoid nested replacement ranges" from #129346.)
 - #132596 ([rustdoc] Fix `--show-coverage` when JSON output format is used)
 - #132598 (Clippy: Move some attribute lints to be early pass (post expansion))
 - #132601 (Update books)
 - #132606 (Improve example of `impl Pattern for &[char]`)
 - #132608 (document `type_implements_trait`)
 - #132609 (docs: fix grammar in doc comment at unix/process.rs)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-05 05:53:19 +00:00
Augie Fackler
e8d17440e2 PassWrapper: adapt for new parameter in LLVM
llvm/llvm-project@390300d9f4 added a new
parameter to some callbacks, so we have to handle them.

@rustbot label: +llvm-main
2024-11-05 15:49:37 +11:00
Jubilee
7bff6ff3a6
Rollup merge of #132609 - NotWearingPants:patch-1, r=Amanieu
docs: fix grammar in doc comment at unix/process.rs

Fixed the grammar of a sentence in the docs
2024-11-04 20:40:50 -08:00
Jubilee
33ebfff83a
Rollup merge of #132608 - mejrs:type_impls_trait, r=compiler-errors
document `type_implements_trait`

Rendered:

![image](https://github.com/user-attachments/assets/60c00e50-24fd-4b04-bb22-e71b479c0b29)

r? `@compiler-errors`
2024-11-04 20:40:49 -08:00
Jubilee
67477ca342
Rollup merge of #132606 - eduardosm:char-slice-str-pattern-doc, r=tgross35
Improve example of `impl Pattern for &[char]`

The previous version used `['l', 'l']` as pattern, which would suggest that it matches the `ll` of `Hello world` as a whole.
2024-11-04 20:40:49 -08:00
Jubilee
3d4dd742bb
Rollup merge of #132601 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/edition-guide

3 commits in 1f07c242f8162a711a5ac5a4ea8fa7ec884ee7a9..2d482e203eb6d6e353814cf1415c5f94e590b9e0
2024-11-04 14:42:36 UTC to 2019-06-14 21:27:05 UTC

- 2024: rustfmt style edition (rust-lang/edition-guide#331)
- rustdoc: Fix doctest `include` paths (rust-lang/edition-guide#329)
- docs(cargo): Cover MSRV-aware resolver (rust-lang/edition-guide#328)

## rust-lang/reference

3 commits in 23ce619966541bf2c80d45fdfeecf3393e360a13..da0f6dad767670da0e8cd5af8a7090db3272f626
2024-11-01 12:52:51 UTC to 2024-10-30 13:30:17 UTC

- fix typo referring to 'Unsize' trait (rust-lang/reference#1669)
- Add identifier syntax to items.md and subchapters (rust-lang/reference#1599)
- Rename "object safe" to "dyn compatible" (rust-lang/reference#1666)

## rust-lang/rust-by-example

5 commits in 8bede1b919a81ab7d0c961f6bbf68d3efa297bd2..9db78608b17d5f4a6c033b8a3038466b87d63206
2024-10-31 21:03:20 UTC to 2024-10-26 16:06:05 UTC

- fix(doc): correct small errors in pipes.md (rust-lang/rust-by-example#1894)
- Fix ambiguous comment on 2.3 Arrays and Slices page (rust-lang/rust-by-example#1885)
- Fix typo in generics/new_types (rust-lang/rust-by-example#1892)
- docs(zh): fix known issues (rust-lang/rust-by-example#1891)
- `read_lines`: Use `.map_while(Result::ok)` instead of `.flatten()`. (rust-lang/rust-by-example#1890)

## rust-lang/rustc-dev-guide

22 commits in 59d94ea75a0b157e148af14c73c2dd60efb7b60a..6a5accdaf10255882b1e6c59dfe5f1c79ac95484
2024-11-04 14:40:57 UTC to 2024-10-24 20:33:08 UTC

- Add a link for the `reference` compiletest header (rust-lang/rustc-dev-guide#2096)
- Slightly fix up the glossary (rust-lang/rustc-dev-guide#2127)
- Remove an mdbook workaround (rust-lang/rustc-dev-guide#2124)
- Fix broken links (rust-lang/rustc-dev-guide#2123)
- Fix minicore.rs link (rust-lang/rustc-dev-guide#2122)
- Update for recent dataflow simplifications. (rust-lang/rustc-dev-guide#2121)
- Describe `minicore` test auxiliary and directive (rust-lang/rustc-dev-guide#2097)
- Fix and update docs for `needs-force-clang-based-tests` (rust-lang/rustc-dev-guide#2085)
- Add redirects for integration-testing and headers (rust-lang/rustc-dev-guide#2092)
- Fix borked links (rust-lang/rustc-dev-guide#2119)
- Describe how to revert a PR (rust-lang/rustc-dev-guide#2118)
- Linkify the footnotes in the async closure chapter (rust-lang/rustc-dev-guide#2117)
- Try to fix footnotes (rust-lang/rustc-dev-guide#2115)
- Fix rustc-related links that are 404 right now (rust-lang/rustc-dev-guide#2112)
- Async closures chapter (rust-lang/rustc-dev-guide#2110)
- update rfl ci job policy (rust-lang/rustc-dev-guide#2108)
- Fix internal and incomplete links (rust-lang/rustc-dev-guide#2107)
- Describe why and how to use a separate build directory for rust-analyzer (rust-lang/rustc-dev-guide#2106)
- Update current status of diagnostics translation infra (rust-lang/rustc-dev-guide#2105)
- update const stability docs (rust-lang/rustc-dev-guide#2098)
- Advice on auto-formatting C++ code (rust-lang/rustc-dev-guide#2104)
- Update compiler-src.md (rust-lang/rustc-dev-guide#2102)
2024-11-04 20:40:48 -08:00
Jubilee
d70e2e30da
Rollup merge of #132598 - jdonszelmann:move-lints-to-early, r=xFrednet
Clippy: Move some attribute lints to be early pass (post expansion)

r? ```@xFrednet```

As a side effect it removes a duplicated warning on line 53 of the `allow_attributes` test. I discussed this with ```@xFrednet``` , and it's mainly to support the attribute rework https://github.com/rust-lang/rust/issues/131229
2024-11-04 20:40:48 -08:00
Jubilee
b3fc9e6d6f
Rollup merge of #132596 - GuillaumeGomez:show-coverage, r=notriddle
[rustdoc] Fix `--show-coverage` when JSON output format is used

I realized while looking on the docs.rs page of the `sysinfo` crate that the coverage numbers displayed were wrong:

![image](https://github.com/user-attachments/assets/264b2e25-6271-4ed1-8b35-e8bd4fd475c6)

I realized that it was because `--show-coverage --output-format=json` was relying on the same logic as the JSON output for the doc generation whereas it should not. I fixed it by changing the API for querying `is_json` a bit.

The underlying issue is that JSON output format is stripping reexports of items from private modules.

r? ``@notriddle``
2024-11-04 20:40:47 -08:00
Jubilee
f8ac0e71f8
Rollup merge of #132587 - nnethercote:revert-avoid-nested-replacement-ranges, r=petrochenkov
Revert "Avoid nested replacement ranges" from #129346.

It caused a test regression in the `cfg_eval.rs` crate. (The bugfix in #129346 was in a different commit; this commit was just a code simplification.)

r? `@petrochenkov`
2024-11-04 20:40:47 -08:00
Jubilee
23ef001d66
Rollup merge of #132492 - RalfJung:const-intrinsics, r=compiler-errors
remove support for extern-block const intrinsics

This converts all const-callable intrinsics into the "new" form of a regular `fn` with `#[rustc_intrinsic]` attribute. That simplifies some of the logic since those functions can be marked `const fn` like regular functions, so intrinsics no longer need a special case to be considered const-callable at all.

I also added a new attribute `#[rustc_const_stable_intrinsic]` to mark an intrinsic as being ready to be exposed on stable. Previously we used the `#[rustc_const_stable_indirect]` attribute for that, but that attribute had a dual role -- when used on a regular function, it is an entirely safe marker to make this function part of recursive const stability, but on an intrinsic it is a trusted marker requiring special care. It's not great for the same attribute to be sometimes fully checked and safe, and sometimes trusted and requiring special care, so I split this into two attributes.

This also fixes https://github.com/rust-lang/rust/issues/122652 by accepting intrinsics as const-stable if they have a fallback body that is recursively const-stable.

The library changes are best reviewed with whitespace hidden.

r? `@compiler-errors`
2024-11-04 20:40:46 -08:00
Jubilee
56aa51e67f
Rollup merge of #132303 - nyurik:non-exhaustive-err, r=compiler-errors
More tests for non-exhaustive C-like enums in FFI

Add a few more tests for the `improper_ctypes` lint as found with the [varnish-rs](https://github.com/gquintard/varnish-rs) project.

This follows up on #116831, fixed in #116863 by ``@workingjubilee`` - I have been seeing these fail with the bindgen-generated non-exhaustive enums inside other structs. Seems the issue does not exist in the primary branch, so this PR just makes sure more cases are covered for the future.
2024-11-04 20:40:45 -08:00
Jubilee
c17cf1d84e
Rollup merge of #132025 - duncpro:E0027, r=compiler-errors
fix suggestion for diagnostic error E0027

Closes #132008
2024-11-04 20:40:45 -08:00
Jubilee
972fef232e
Rollup merge of #131153 - VulnBandit:copy_impl_vuln, r=compiler-errors
Improve duplicate derive Copy/Clone diagnostics

Improve duplicate derive Copy/Clone diagnostics.
Closes #131083
2024-11-04 20:40:44 -08:00
Zalathar
19d5dc0ed1 coverage: Tidy up coverage-specific FFI functions 2024-11-05 15:32:36 +11:00
Zalathar
b790e4473c coverage: Extract safe FFI wrapper functions to llvm_cov 2024-11-05 15:32:34 +11:00
bors
96477c55bc Auto merge of #131341 - taiki-e:ppc-clobber-abi, r=bzEq,workingjubilee
Support clobber_abi and vector registers (clobber-only) in PowerPC inline assembly

This supports `clobber_abi` which is one of the requirements of stabilization mentioned in #93335.

This basically does a similar thing I did in https://github.com/rust-lang/rust/pull/130630 to implement `clobber_abi` for s390x, but for powerpc/powerpc64/powerpc64le.
- This also supports vector registers (as `vreg`) as clobber-only, which need to support clobbering of them to implement `clobber_abi`.
- `vreg` should be able to accept `#[repr(simd)]` types as input/output if the unstable `altivec` target feature is enabled, but `core::arch::{powerpc,powerpc64}` vector types, `#[repr(simd)]`, and `core::simd` are all unstable, so the fact that this is currently a clobber-only should not be considered a blocker of clobber_abi implementation or stabilization. So I have not implemented it in this PR.
  - See https://github.com/rust-lang/rust/pull/131551 (which is based on this PR) for a PR to implement this.
  - (I'm not sticking to whether that PR should be a separate PR or part of this PR, so I can merge that PR into this PR if needed.)

Refs:
- PPC32 SysV: Section "Function Calling Sequence" in [System V Application Binary Interface PowerPC Processor Supplement](https://refspecs.linuxfoundation.org/elf/elfspec_ppc.pdf)
- PPC64 ELFv1: Section 3.2 "Function Calling Sequence" in [64-bit PowerPC ELF Application Binary Interface Supplement](https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#FUNC-CALL)
- PPC64 ELFv2: Section 2.2 "Function Calling Sequence" in [64-Bit ELF V2 ABI Specification](https://openpowerfoundation.org/specifications/64bitelfabi/)
- AIX: [Register usage and conventions](https://www.ibm.com/docs/en/aix/7.3?topic=overview-register-usage-conventions), [Special registers in the PowerPC®](https://www.ibm.com/docs/en/aix/7.3?topic=overview-special-registers-in-powerpc), [AIX vector programming](https://www.ibm.com/docs/en/aix/7.3?topic=concepts-aix-vector-programming)
- Register definition in LLVM: https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/PowerPC/PPCRegisterInfo.td#L189

If I understand the above four ABI documentations correctly, except for the PPC32 SysV's VR (Vector Registers) and 32-bit AIX (currently not supported by rustc)'s r13, there does not appear to be important differences in terms of implementing `clobber_abi`:
- The above four ABIs are consistent about FPR (0-13: volatile, 14-31: nonvolatile), CR (0-1,5-7: volatile, 2-4: nonvolatile), XER (volatile), and CTR (volatile).
- As for GPR, only the registers we are treating as reserved are slightly different
  - r0, r3-r12 are volatile
  - r1(sp, reserved), r14-31 are nonvolatile
  - r2(reserved) is TOC pointer in PPC64 ELF/AIX, system-reserved register in PPC32 SysV (AFAIK used as thread pointer in Linux/BSDs)
  - r13(reserved for non-32-bit-AIX) is thread pointer in PPC64 ELF, small data area pointer register in PPC32 SysV, "reserved under 64-bit environment; not restored across system calls[^r13]" in AIX)
- As for FPSCR, volatile in PPC64 ELFv1/AIX, some fields are volatile only in certain situations (rest are volatile) in PPC32 SysV/PPC64 ELFv2.
- As for VR (Vector Registers), it is not mentioned in PPC32 SysV, v0-v19 are volatile in both in PPC64 ELF/AIX, v20-v31 are nonvolatile in PPC64 ELF, reserved or nonvolatile depending on the ABI ([vec-extabi vs vec-default in LLVM](https://reviews.llvm.org/D89684), we are [using vec-extabi](https://github.com/rust-lang/rust/pull/131341#discussion_r1797693299)) in AIX:
  > When the default Vector enabled mode is used, these registers are reserved and must not be used.
  > In the extended ABI vector enabled mode, these registers are nonvolatile and their values are preserved across function calls

  I left [FIXME comment about PPC32 SysV](https://github.com/rust-lang/rust/pull/131341#discussion_r1790496095) and added ABI check for AIX.
- As for VRSAVE, it is not mentioned in PPC32 SysV, nonvolatile in PPC64 ELFv1, reserved in PPC64 ELFv2/AIX
- As for VSCR, it is not mentioned in PPC32 SysV/PPC64 ELFv1, some fields are volatile only in certain situations (rest are volatile) in PPC64 ELFv2, volatile in AIX

We are currently treating r1-r2, r13 (non-32-bit-AIX), r29-r31, LR, CTR, and VRSAVE as reserved.
We are currently not processing anything about FPSCR and VSCR, but I feel those are things that should be processed by `preserves_flags` rather than `clobber_abi` if we need to do something about them. (However, PPCRegisterInfo.td in LLVM does not seem to define anything about them.)

Replaces #111335 and #124279

cc `@ecnelises` `@bzEq` `@lu-zero`

r? `@Amanieu`

`@rustbot` label +O-PowerPC +A-inline-assembly

[^r13]: callee-saved, according to [LLVM](6a6af0246b/llvm/lib/Target/PowerPC/PPCCallingConv.td (L322)) and [GCC](a9173a50e7/gcc/config/rs6000/rs6000.h (L859)).
2024-11-05 03:13:47 +00:00
makai410
5791a66a88 suggest swapping the equality 2024-11-05 10:09:34 +08:00
mejrs
e37a3a85e4 Explain how to evaluate an obligation 2024-11-05 01:08:20 +01:00
GnomedDev
44c2a82972
Swap Visitors to early exit, instead of storing poison flag 2024-11-04 23:49:25 +00:00
Ralf Jung
a741b33c14 when an intrinsic has a const-stable fallback body, we can easily expose it on stable 2024-11-04 23:27:46 +01:00
Ralf Jung
5069434c81 most const intrinsics don't need an explicit rustc_const_unstable any more 2024-11-04 23:27:46 +01:00
Ralf Jung
1f0ed2b0f5 add new rustc_const_stable_intrinsic attribute for const-stable intrinsics 2024-11-04 23:27:46 +01:00
Ralf Jung
10723c2896 remove support for extern-block const intrinsics 2024-11-04 23:27:45 +01:00
Ralf Jung
7934f26613 convert all const-callable intrinsics into the new form (without extern block) 2024-11-04 23:21:22 +01:00
Ralf Jung
ffad9aac27 mark some target features as 'forbidden' so they cannot be (un)set
For now, this is just a warning, but should become a hard error in the future
2024-11-04 22:56:47 +01:00
Jonathan Dönszelmann
63d0ba9de9 Move two attribute lints to be early pass (post expansion) 2024-11-04 22:47:22 +01:00
Jonathan Dönszelmann
f4b72dcff0
Move two attribute lints to be early pass (post expansion) 2024-11-04 22:47:22 +01:00
bors
fbab78289d Auto merge of #132594 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`
2024-11-04 20:20:16 +00:00
NotWearingPants
107b4fdba2
docs: fix grammar in doc comment at unix/process.rs 2024-11-04 20:42:21 +02:00
Eduardo Sánchez Muñoz
4872b6bcbd Improve example of impl Pattern for &[char]
The previous version used `['l', 'l']` as pattern, which would suggest that it matches the `ll` of `Hello world` as a whole.
2024-11-04 19:08:28 +01:00
Eugene Shamis
65d8f1b8bf Fixed typo, rebased 2024-11-04 12:43:57 -05:00
bors
82c24eccad Auto merge of #132603 - matthiaskrgr:rollup-ikzofgc, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #132355 (Fix compiler panic with a large number of threads)
 - #132486 (No need to instantiate binder in `confirm_async_closure_candidate`)
 - #132544 (Use backticks instead of single quotes for library feature names in diagnostics)
 - #132559 (find the generic container rather than simply looking up for the assoc with const arg)
 - #132579 (add rustc std workspace crate sources)
 - #132583 (Suggest creating unary tuples when types don't match a trait)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-04 17:39:34 +00:00
Eugene Shamis
37f48da802 Updated SAFETY comment to address underflow 2024-11-04 12:36:24 -05:00
Eugene Shamis
02a1ab8071 Replace checked slice indexing by unchecked to support panic-free code
Fixes #126425

Replace the potentially panicking `[]` indexing with `get_unchecked()`
to prevent linking with panic-related code.
2024-11-04 12:36:24 -05:00