Commit Graph

41079 Commits

Author SHA1 Message Date
Taiki Endo
e2d50315ef Add links about clobber_abi on PowerPC 2024-11-07 22:21:27 +09:00
Taiki Endo
01b5a678c5 Remove fixme comment about clobber_abi on PowerPC 2024-11-07 22:13:15 +09:00
Taiki Endo
241f82ad91 Basic inline assembly support for SPARC and SPARC64 2024-11-07 21:19:03 +09:00
Jonas Böttiger
6b5a58c265
Rollup merge of #132057 - RalfJung:miri-abi-compat, r=wesleywiser
miri: update ABI compat checks to accept Option-like types

This implements the t-lang decision described [here](https://github.com/rust-lang/rust/pull/130628#issuecomment-2402761599).

Fixes https://github.com/rust-lang/miri/issues/3983
2024-11-07 13:08:27 +01:00
bors
c07aa1e171 Auto merge of #132625 - compiler-errors:cache-only-if-opaque, r=lcnr
Only disable cache if predicate has opaques within it

This is an alternative to https://github.com/rust-lang/rust/pull/132075.

This refines the check implemented in https://github.com/rust-lang/rust/pull/126024 to only disable the global cache if the predicate being considered has opaques in it. This is still theoretically unsound, since goals can indirectly rely on opaques in the defining scope, but we're much less likely to hit it.

It doesn't totally fix https://github.com/rust-lang/rust/issues/132064: for example, `lemmy` goes from 1:29 (on rust 1.81) to 9:53 (on nightly) to 4:07 (after this PR). But I think it's at least *more* sound than a total revert :/

r? lcnr
2024-11-06 21:22:14 +00:00
bors
4d215e2426 Auto merge of #132404 - makai410:suggest-swap-lhs-rhs, r=fee1-dead
Suggest swapping LHS and RHS when RHS impls `PartialEq<lhs_ty>`

Closes: #130495
r? `@fee1-dead`
2024-11-06 11:49:52 +00:00
bors
e1fb288562 Auto merge of #132663 - estebank:e0320-tweak, r=compiler-errors
Tweak E0320 overflow error wording

Surround type with backticks as we should in every error.
2024-11-06 06:40:17 +00:00
bors
a69df72bdc Auto merge of #132664 - matthiaskrgr:rollup-i27nr7i, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #131261 (Stabilize `UnsafeCell::from_mut`)
 - #131405 (bootstrap/codegen_ssa: ship llvm-strip and use it for -Cstrip)
 - #132077 (Add a new `wide-arithmetic` feature for WebAssembly)
 - #132562 (Remove the `wasm32-wasi` target from rustc)
 - #132660 (Remove unused errs.rs file)

Failed merges:

 - #131721 (Add new unstable feature `const_eq_ignore_ascii_case`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-06 01:21:42 +00:00
Matthias Krüger
92c1ad8c73
Rollup merge of #132660 - ehuss:remove-unused-errs, r=saethlin
Remove unused errs.rs file

This module was removed in #124895, but the actual file was not removed.
2024-11-05 23:43:58 +01:00
Matthias Krüger
73035552c9
Rollup merge of #132562 - alexcrichton:remove-wasm32-wasi, r=jieyouxu
Remove the `wasm32-wasi` target from rustc

This commit is the final step in the journey of renaming the historical `wasm32-wasi` target in the Rust compiler to `wasm32-wasip1`. Various steps in this journey so far have been:

* 2023-04-03: rust-lang/compiler-team#607 - initial proposal for this rename
* 2024-11-27: rust-lang/compiler-team#695 - amended schedule/procedure for rename
* 2024-01-29: rust-lang/rust#120468 - initial introduction of `wasm32-wasip1`
* 2024-06-18: rust-lang/rust#126662 - warn on usage of `wasm32-wasi`
* 2024-11-08: this PR - remove the `wasm32-wasi` target

The full transition schedule is in [this comment][comment] and is summarized with:

* 2024-05-02: Rust 1.78 released with `wasm32-wasip1` target
* 2024-09-05: Rust 1.81 released warning on usage of `wasm32-wasi`
* 2025-01-09: Rust 1.84 to be released without the `wasm32-wasi` target

This means that support on stable for the replacement target of `wasm32-wasip1` has currently been available for 6 months. Users have already seen warnings on stable for 2 months about usage of `wasm32-wasi` and stable users have another 2 months of warnings before the target is removed from stable.

This commit is intended to be the final step in this transition so the source tree should no longer mention `wasm32-wasi` except in historical reference to the older name of the `wasm32-wasip1` target.

[comment]: https://github.com/rust-lang/rust/pull/120468#issuecomment-1977878747
2024-11-05 23:43:58 +01:00
Matthias Krüger
088e698835
Rollup merge of #132077 - alexcrichton:wide-arithmetic, r=jieyouxu
Add a new `wide-arithmetic` feature for WebAssembly

This commit adds a new rustc target feature named `wide-arithmetic` for WebAssembly targets. This corresponds to the [wide-arithmetic] proposal for WebAssembly which adds new instructions catered towards accelerating integer arithmetic larger than 64-bits. This proposal to WebAssembly is not standard yet so this new feature is flagged as an unstable target feature. Additionally Rust's LLVM version doesn't support this new feature yet since support will first be added in LLVM 20, so the feature filtering logic for LLVM is updated to handle this.

I'll also note that I'm not currently planning to add wasm-specific intrinsics to `std::arch::wasm32` at this time. The currently proposed instructions are all accessible through `i128` or `u128`-based operations which Rust already supports, so intrinsic shouldn't be necessary to get access to these new instructions.

[wide-arithmetic]: https://github.com/WebAssembly/wide-arithmetic
2024-11-05 23:43:57 +01:00
Matthias Krüger
8dee3e978a
Rollup merge of #131405 - davidtwco:hardcoded-strip-macos, r=jieyouxu,albertlarsan68
bootstrap/codegen_ssa: ship llvm-strip and use it for -Cstrip

Fixes #131206.

- Includes `llvm-strip` (a symlink to `llvm-objcopy`) in the compiler dist artifact so that it can be used for `-Cstrip` instead of the system tooling.
- Uses `llvm-strip` instead of `/usr/bin/strip` for macOS. macOS needs a specific linker and the system one is preferred, hence #130781 but that doesn't work when cross-compiling, so use the `llvm-strip` utility instead.

cc #123151
2024-11-05 23:43:56 +01:00
bors
4a91ff6bb5 Auto merge of #132661 - matthiaskrgr:rollup-npytbl6, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #132259 (rustc_codegen_llvm: Add a new 'pc' option to branch-protection)
 - #132409 (CI: switch 7 linux jobs to free runners)
 - #132498 (Suggest fixing typos and let bindings at the same time)
 - #132524 (chore(style): sync submodule exclusion list between tidy and rustfmt)
 - #132567 (Properly suggest `E::assoc` when we encounter `E::Variant::assoc`)
 - #132571 (add const_eval_select macro to reduce redundancy)
 - #132637 (Do not filter empty lint passes & re-do CTFE pass)
 - #132642 (Add documentation on `ast::Attribute`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-05 22:43:15 +00:00
Esteban Küber
dceb3fc9fa Tweak E0320 overflow error wording
Surrount type with backticks as we should in every error.
2024-11-05 21:54:45 +00:00
Matthias Krüger
4346249c88
Rollup merge of #132642 - GuillaumeGomez:attr-docs, r=compiler-errors
Add documentation on `ast::Attribute`

I was working again with attributes in clippy recently and I often find myself in need to read the source code to ensure it's doing what I want.

Instead, a bit of documentation would allow me (and hopefully others) to skip this step.
2024-11-05 20:10:54 +01:00
Matthias Krüger
560248f4f7
Rollup merge of #132637 - blyxyas:lint-less-passes, r=flip1995
Do not filter empty lint passes & re-do CTFE pass

Some structs implement `LintPass` without having a `Lint` associated with them #125116 broke that behaviour by filtering them out. This PR ensures that lintless passes are not filtered out.
2024-11-05 20:10:53 +01:00
Matthias Krüger
bb50ebfca4
Rollup merge of #132567 - estebank:bad-suggestion, r=Nadrieril
Properly suggest `E::assoc` when we encounter `E::Variant::assoc`

Use the right span when encountering an enum variant followed by an associated item so we don't lose the associated item in the resulting code.

Do not suggest the thing twice, once as a removal of the associated item and a second time as a typo suggestion.
2024-11-05 20:10:51 +01:00
Matthias Krüger
b23655893e
Rollup merge of #132498 - uellenberg:typo-and-let-suggestions, r=estebank
Suggest fixing typos and let bindings at the same time

Fixes #132483

Currently, a suggestion for adding a let binding won't be shown if we suggest fixing a typo. This changes that behavior to always show both, if possible. Essentially, this turns the suggestion from
```rust
error[E0425]: cannot find value `x2` in this scope
 --> src/main.rs:4:5
  |
4 |     x2 = 2;
  |     ^^ help: a local variable with a similar name exists: `x1`

For more information about this error, try `rustc --explain E0425`.
```

to
```rust
error[E0425]: cannot find value `x2` in this scope
 --> src/main.rs:4:5
  |
4 |     x2 = 2;
  |     ^^
  |
help: a local variable with a similar name exists
  |
4 |     x1 = 2;
  |     ~~
help: you might have meant to introduce a new binding
  |
4 |     let x2 = 2;
  |     +++

For more information about this error, try `rustc --explain E0425`.
```

for the following code:
```rust
fn main() {
    let x1 = 1;
    x2 = 2;
}
```

The original behavior only shows the suggestion for a let binding if a typo suggestion wasn't already displayed. However, this falls apart in the cases like the one above where we have multiple similar variables. I don't think it makes sense to hide this suggestion if there's a similar variable, since that defeats the purpose of this suggestion in that case (it's meant to help those coming from languages like Python).
2024-11-05 20:10:50 +01:00
Matthias Krüger
c8247c0a19
Rollup merge of #132259 - mrkajetanp:branch-protection-pauth-lr, r=davidtwco
rustc_codegen_llvm: Add a new 'pc' option to branch-protection

Add a new 'pc' option to -Z branch-protection for aarch64 that enables the use of PC as a diversifier in PAC branch protection code.

When the pauth-lr target feature is enabled in combination with -Z branch-protection=pac-ret,pc, the new 9.5-a instructions (pacibsppc, retaasppc, etc) will be generated.
2024-11-05 20:10:49 +01:00
Eric Huss
c7d29cd56d Remove unused errs.rs file
This module was removed in #124895, but the actual file was not removed.
2024-11-05 11:10:12 -08:00
bors
bc5cf994db Auto merge of #132631 - workingjubilee:rollup-dx0krqp, r=workingjubilee
Rollup of 4 pull requests

Successful merges:

 - #132153 (Stabilise `const_char_encode_utf16`.)
 - #132473 ([core/fmt] Replace checked slice indexing by unchecked to support panic-free code)
 - #132600 (PassWrapper: adapt for new parameter in LLVM)
 - #132630 (triagebot: ping wg-const-eval when relevant files change)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-05 18:58:59 +00:00
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
Guillaume Gomez
33009601af Add documentation on ast::Attribute 2024-11-05 16:38:15 +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
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
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
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
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
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
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
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
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
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
Urgau
0bc622d251 Prefer pub(super) in unreachable_pub lint suggestion 2024-11-04 19:09:40 +01:00
Matthias Krüger
a4f323ce9c
Rollup merge of #132583 - mejrs:tuples, r=compiler-errors
Suggest creating unary tuples when types don't match a trait

When you want to have a variadic function, a common workaround to implement this is to create a trait and then implement that trait for various tuples. For example in `pyo3` there exists
```rust
/// Calls the object with only positional arguments.
pub fn call1(&self, args: impl IntoPy<Py<PyTuple>>) -> PyResult<&PyAny> {
   ...
}
```

with various impls like
```rust
impl<A: IntoPy<PyObject> IntoPy<Py<PyAny>> for (A,)
impl<A: IntoPy<PyObject, B: IntoPy<PyObject> IntoPy<Py<PyAny>> for (A, B)
... etc
```

This means that if you want to call the method with a single item you have to create a unary tuple, like `(x,)`, rather than just `x`.

This PR implements a suggestion to do that, if applicable.
2024-11-04 18:12:48 +01:00
Matthias Krüger
909574e411
Rollup merge of #132559 - bvanjoi:fix-132534, r=compiler-errors
find the generic container rather than simply looking up for the assoc with const arg

Fixes #132534

This issue is caused by mismatched generic parameters. Previously, it tried to find `T` in `trait X`, but after this change, it will find `T` in `fn a`.

r? `@compiler-errors`  as this assertion was introduced by you.
2024-11-04 18:12:47 +01:00
Matthias Krüger
b9db639ea5
Rollup merge of #132544 - dianne:unstable-library-feature-backticks, r=compiler-errors
Use backticks instead of single quotes for library feature names in diagnostics

This PR changes the text of library feature errors for using unstable or body-unstable items. Displaying library feature names in backticks is consistent with other diagnostics (e.g. those from `rustc_passes`) and with the `reason`s on unstable attributes in the library. Additionally, this simplifies diagnostics when supporting multiple unstable attributes on items (see #131824) since `DiagSymbolList` also displays symbols using backticks.
2024-11-04 18:12:46 +01:00
Matthias Krüger
c89a6cd0ad
Rollup merge of #132486 - compiler-errors:no-binder, r=lcnr
No need to instantiate binder in `confirm_async_closure_candidate`

Removes a FIXME that is redundant. No longer needed since #122267.
2024-11-04 18:12:45 +01:00
Matthias Krüger
31ad4e4a54
Rollup merge of #132355 - practicalrs:fix_117638, r=SparrowLii
Fix compiler panic with a large number of threads

Hi,

This PR is an attempt to fix the problem described here https://github.com/rust-lang/rust/issues/117638 using the solution suggested in this comment https://github.com/rust-lang/rust/issues/117638#issuecomment-1800925067

Best regards,
Michal
2024-11-04 18:12:45 +01:00
mejrs
c88ba28d9a document type_implements_trait 2024-11-04 18:08:30 +01:00
bors
432972cae6 Auto merge of #132275 - compiler-errors:deref-effects, r=fee1-dead
Register `~const` preds for `Deref` adjustments in HIR typeck

This doesn't *do* anything yet, since `Deref` and `DerefMut` aren't constified, and we explicitly don't error on calling non-const trait methods in HIR yet -- presumably that will wait until std is re-constified. But I'm confident this logic is correct, and this (afaict?) is the only major hole left in enforcing `~const` in HIR typeck.

r? fee1-dead
2024-11-04 12:12:55 +00:00
mejrs
5a48fe2c20 Suggest creating unary tuples 2024-11-04 12:06:19 +01:00
Zalathar
5bfa0b106e Simplify FFI calls for -Ztime-llvm-passes and -Zprint-codegen-stats 2024-11-04 20:31:16 +11:00
bors
ca87b535a0 Auto merge of #132250 - nnethercote:rustc_borrowck-cleanups, r=compiler-errors
`rustc_borrowck` cleanups

A bunch of cleanups I made while reading over this crate.

r? `@lqd`
2024-11-04 09:19:05 +00:00
Ralf Jung
b2fe71a2fe miri: update ABI compat checks to accept Option-like types 2024-11-04 07:50:40 +01:00
Nicholas Nethercote
e0e7a432db BorrowckDiags tweaks.
- Store a mut ref to a `BorrowckDiags` in `MirBorrowckCtxt` instead of
  owning it, to save having to pass ownership in and out of
  `promoted_mbcx`.
- Use `buffer_error` in a couple of suitable places.
2024-11-04 17:36:25 +11:00
Nicholas Nethercote
ce2f0b4ce9 Simplify LocalUseMapBuild.
It has four different `insert` methods, with some duplication. This
commit finds the commonality and removes them all.
2024-11-04 17:36:25 +11:00
Nicholas Nethercote
6ecf80e1ad Merge BorrowCheckContext into TypeChecker.
Because there is no real reason for it to be a separate struct.
- It has no methods.
- It's easy to confuse with the nearby `BorrowckInferContext` (which
  does have methods).
- The `mut` ref to it in `TypeChecker` makes it seem like any of the
  fields within might be mutable, but only two (`all_facts` and
  `constraints`) actually are.
- Two of the fields are `pub(crate)` but can be private.

This change makes a lot of code more concise and readable.
2024-11-04 17:36:25 +11:00
Nicholas Nethercote
f86c76a782 Remove unnecessary qualifiers. 2024-11-04 17:36:25 +11:00
Nicholas Nethercote
a07011bde2 Remove unnecessary continue. 2024-11-04 17:36:25 +11:00
Nicholas Nethercote
e23bdd68f9 Remove ToUniverseInfo impl for CanonicalQueryInput<CustomTypeOp>.
It's unused.
2024-11-04 17:36:25 +11:00
Nicholas Nethercote
7901c03d2d Merge UniverseInfo and UniverseInfoInner.
It's strange to have a struct that contains a single anonymous field
that is an enum. This commit merges them. This does require increasing
the visibility of `TypeOfInfo` to `pub(crate)`, but that seems
worthwhile.
2024-11-04 17:36:25 +11:00
Nicholas Nethercote
bf1a5c2b7f Tidy up comments and some formatting.
Mostly by wrapping overly long comment lines, plus a few other things.
2024-11-04 17:36:25 +11:00
Nicholas Nethercote
ad875529bf Move some use declarations.
So they're all in the one place. Also prepend with `crate::`, à la the
`unqualified_local_imports` lint.
2024-11-04 17:36:23 +11:00
Zalathar
920d2774ac Trim and tidy includes in rustc_llvm 2024-11-04 16:35:39 +11:00
Nicholas Nethercote
981dc02eaf 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.)
2024-11-04 15:57:35 +11:00
Michael Goulet
7bd595d216 Make sure to enforce ~const DerefMut on mutability fixup 2024-11-04 04:51:32 +00:00
Michael Goulet
e03e9abe3c Register const preds for Deref adjustments in HIR typeck 2024-11-04 04:51:31 +00:00
Michael Goulet
d458f850aa ty::BrK -> ty::BoundRegionKind::K 2024-11-04 04:45:52 +00:00
Michael Goulet
883f8705d4 Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
Michael Goulet
be4b0261c2 ty::KContainer -> ty::AssocItemContainer::K 2024-11-04 04:45:52 +00:00
Michael Goulet
8e6af16192 Remove the trivial constkind imports 2024-11-04 04:45:51 +00:00
Nicholas Nethercote
6676cec925 Reduce visibilities. 2024-11-04 15:43:45 +11:00
bohan
6026a0f6c9 find the generic container rather than simply looking up for the assoc with const arg 2024-11-04 12:17:44 +08:00
Jubilee
759e80d019
Rollup merge of #132576 - jdonszelmann:no-attrid-in-stats, r=nnethercote
remove attribute ids from hir stats (they're simply not needed)

Turns out these are simply not needed. Yay!

r? `@nnethercote`
2024-11-03 20:08:15 -08:00
Jubilee
7155c65d68
Rollup merge of #132565 - bjorn3:less_target_name_dependence, r=workingjubilee
Reduce dependence on the target name

The target name can be anything with custom target specs. Matching on fields inside the target spec is much more robust than matching on the target name.

Also remove the unused is_builtin target spec field.
2024-11-03 20:08:14 -08:00
Jubilee
3313e760d0
Rollup merge of #132423 - RalfJung:const-eval-align-offset, r=dtolnay
remove const-support for align_offset and is_aligned

As part of the recent discussion to stabilize `ptr.is_null()` in const context, the general vibe was that it's okay for a const function to panic when the same operation would work at runtime (that's just a case of "dynamically detecting that something is not supported as a const operation"), but it is *not* okay for a const function to just return a different result.

Following that, `is_aligned` and `is_aligned_to` have their const status revoked in this PR, since they do return actively wrong results at const time. In the future we can consider having a new intrinsic or so that can check whether a pointer is "guaranteed to be aligned", but the current implementation based on `align_offset` does not have the behavior we want.

In fact `align_offset` itself behaves quite strangely in const, and that support needs a bunch of special hacks. That doesn't seem worth it. Instead, the users that can fall back to a different implementation should just use const_eval_select directly, and everything else should not be made const-callable. So this PR does exactly that, and entirely removes const support for align_offset.

Closes some tracking issues by removing the associated features:
Closes https://github.com/rust-lang/rust/issues/90962
Closes https://github.com/rust-lang/rust/issues/104203

Cc `@rust-lang/wg-const-eval` `@rust-lang/libs-api`
2024-11-03 20:08:13 -08:00
Jubilee
f35433e250
Rollup merge of #131222 - thejpster:fix-sparc-v7-symbol-o, r=workingjubilee
Generate correct symbols.o for sparc-unknown-none-elf

This fixes #130172 by selecting the correct ELF Machine type for sparc-unknown-none-elf (which has a baseline of SPARC V7).
2024-11-03 20:08:13 -08:00
Zalathar
44a056a50b Move LLVMRustAttribute[Kind] out of LLVMWrapper.h 2024-11-04 12:27:23 +11:00
Jubilee
72df7780dd
Rollup merge of #132574 - workingjubilee:abi-in-compiler, r=compiler-errors
compiler: Directly use rustc_abi almost everywhere

Use rustc_abi instead of rustc_target where applicable. This is mostly described by the following substitutions:
```rust
match path_substring {
    rustc_target::spec::abi::Abi => rustc_abi::ExternAbi,
    rustc_target::abi::call => rustc_target::callconv,
    rustc_target::abi => rustc_abi,
}
```

A number of spot-fixes make that not quite the whole story.

The main exception is in 33edc68 where I get a lot more persnickety about how things are imported, especially in `rustc_middle::ty::layout`, not just from where. This includes putting an end to a reexport of `rustc_middle::ty::ReprOptions`, for the same reason that the rest of this change is happening: reexports mostly confound things.

This notably omits rustc_passes and the ast crates, as I'm still examining a question I have about how they do stability checking of `extern "Abi"` strings and if I can simplify their logic. The rustc_abi and rustc_target crates also go untouched because they will be entangled in that cleanup.

r? compiler-errors
2024-11-03 15:25:00 -08:00
Jubilee
3285d12baf
Rollup merge of #132521 - klensy:times, r=compiler-errors
replace manual time convertions with std ones, comptime time format parsing

First commit replaces few manual time conversions with std ones, second makes parsing of time format at compiletime.
2024-11-03 15:24:58 -08:00
dianne
d7d6238b23 use backticks instead of single quotes when reporting "use of unstable library feature"
This is consistent with all other diagnostics I could find containing
features and enables the use of `DiagSymbolList` for generalizing
diagnostics for unstable library features to multiple features.
2024-11-03 13:55:52 -08:00
Jubilee Young
fa2047370b compiler: Remove unused rustc_target from Cargo.tomls 2024-11-03 13:38:47 -08:00
Jubilee Young
5c953ee910 compiler: Replace rustc_target with abi in symbol_mangling 2024-11-03 13:38:47 -08:00
Jubilee Young
7639773e70 compiler: Directly use rustc_abi in session 2024-11-03 13:38:47 -08:00
Jubilee Young
586e141be7 compiler: Directly use rustc_abi in lints 2024-11-03 13:38:47 -08:00
Jubilee Young
092135b7b4 compiler: Directly use rustc_abi in ty_utils 2024-11-03 13:38:47 -08:00
Jubilee Young
6c16a3123b compiler: Directly use rustc_abi in smir again 2024-11-03 13:38:47 -08:00
Jubilee Young
843b6e0859 compiler: Directly use rustc_abi in mir_transform 2024-11-03 13:38:47 -08:00
Jubilee Young
236fe33345 compiler: Directly use rustc_abi in metadata and middle
Stop reexporting ReprOptions from middle::ty
2024-11-03 13:38:47 -08:00
Jubilee Young
89ec8c2cfe compiler: Directly use rustc_abi in hir_{analysis,typeck} 2024-11-03 13:38:47 -08:00
Jubilee Young
bbd18e29da compiler: Directly use rustc_abi in const_eval 2024-11-03 13:38:47 -08:00
Jonathan Dönszelmann
efaf9ab430
remove attribute ids from hir stats (they're simply not needed) 2024-11-03 22:14:54 +01:00
bjorn3
775aad80fc Remove is_builtin target spec field
It is unused.
2024-11-03 21:06:49 +00:00
Jubilee Young
b895bf4fdc compiler: Directly use rustc_abi in codegen 2024-11-03 12:30:32 -08:00
Michael Goulet
6b96103bf3 Rename the FIXMEs, remove a few that dont matter anymore 2024-11-03 18:59:41 +00:00
Michael Goulet
0b5ddf30eb Yeet effects feature 2024-11-03 18:59:31 +00:00
Esteban Küber
e26ad8b67d Properly suggest E::assoc when we encounter E::Variant::assoc
Use the right span when encountering an enum variant followed by an associated item so we don't lose the associated item in the resulting code.

Do not suggest the thing twice, once as a removal of the associated item and a second time as a typo suggestion.
2024-11-03 18:55:19 +00:00
Michael Goulet
ace9e4c078 Gate checking ~const bounds on const_trait_impl 2024-11-03 18:48:24 +00:00
bjorn3
9e6d2da83d Reduce dependence on the target name
The target name can be anything with custom target specs. Matching on
fields inside the target spec is much more robust than matching on the
target name.
2024-11-03 18:29:01 +00:00
Ralf Jung
19e287060d remove const-support for align_offset
Operations like is_aligned would return actively wrong results at compile-time,
i.e. calling it on the same pointer at compiletime and runtime could yield
different results. That's no good.

Instead of having hacks to make align_offset kind-of work in const-eval, just
use const_eval_select in the few places where it makes sense, which also ensures
those places are all aware they need to make sure the fallback behavior is
consistent.
2024-11-03 17:00:44 +01:00
Alex Crichton
c049cc17f3 Remove the wasm32-wasi target from rustc
This commit is the final step in the journey of renaming the historical
`wasm32-wasi` target in the Rust compiler to `wasm32-wasip1`. Various
steps in this journey so far have been:

* 2023-04-03: rust-lang/compiler-team#607 - initial proposal for this rename
* 2024-11-27: rust-lang/compiler-team#695 - amended schedule/procedure for rename
* 2024-01-29: rust-lang/rust#120468 - initial introduction of `wasm32-wasip1`
* 2024-06-18: rust-lang/rust#126662 - warn on usage of `wasm32-wasi`
* 2024-11-08: this PR - remove the `wasm32-wasi` target

The full transition schedule is in [this comment][comment] and is
summarized with:

* 2024-05-02: Rust 1.78 released with `wasm32-wasip1` target
* 2024-09-05: Rust 1.81 released warning on usage of `wasm32-wasi`
* 2025-01-09: Rust 1.84 to be released without the `wasm32-wasi` target

This means that support on stable for the replacement target of
`wasm32-wasip1` has currently been available for 6 months. Users have
already seen warnings on stable for 2 months about usage of
`wasm32-wasi` and stable users have another 2 months of warnings before
the target is removed from stable.

This commit is intended to be the final step in this transition so the
source tree should no longer mention `wasm32-wasi` except in historical
reference to the older name of the `wasm32-wasip1` target.

[comment]: https://github.com/rust-lang/rust/pull/120468#issuecomment-1977878747
2024-11-03 07:09:34 -08:00
bors
7028d9318f Auto merge of #132555 - matthiaskrgr:rollup-2d79661, r=matthiaskrgr
Rollup of 15 pull requests

Successful merges:

 - #129329 (Implement `From<&mut {slice}>` for `Box/Rc/Arc<{slice}>`)
 - #131377 (Add LowerExp and UpperExp implementations to NonZero)
 - #132393 (Docs: added brief colon explanation)
 - #132437 (coverage: Regression test for inlining into an uninstrumented crate)
 - #132499 (unicode_data.rs: show command for generating file)
 - #132503 (better test for const HashMap; remove const_hash leftovers)
 - #132511 (stabilize const_arguments_as_str)
 - #132520 (NFC add known bug nr to test)
 - #132522 (make codegen help output more consistent)
 - #132523 (Added regression test for generics index out of bounds)
 - #132528 (Use `*_opt` typeck results fns to not ICE in fallback suggestion)
 - #132537 (PassWrapper: adapt for llvm/llvm-project@5445edb5d)
 - #132540 (Do not format generic consts)
 - #132543 (add and update some crashtests)
 - #132550 (compiler: Continue introducing rustc_abi to the compiler)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-03 13:46:47 +00:00
klensy
bc1d8e72e7 make time format parsing compiletime 2024-11-03 15:51:39 +03:00
klensy
be3a635fe7 replace manual time convertions with std ones 2024-11-03 15:51:39 +03:00
bors
59ae5eba7e Auto merge of #132514 - Zalathar:print-target-cpus, r=jieyouxu
Port most of `--print=target-cpus` to Rust

The logic and formatting needed by `--print=target-cpus` has historically been carried out in C++ code. Originally it used `printf` to write directly to the console, but later it switched over to writing to a `std::ostringstream` and then passing its buffer to a callback function pointer.

This PR replaces that C++ code with a very simple function that writes a list of CPU names to a `&RustString`, with the rest of the logic and formatting being handled by ordinary safe Rust code.
2024-11-03 11:09:38 +00:00
Matthias Krüger
1ba782ab3d
Rollup merge of #132550 - workingjubilee:rustc-abi-selects-borrowck-for-mono-sans, r=compiler-errors
compiler: Continue introducing rustc_abi to the compiler

Some crates have not heard of rustc_abi before, so arrange introductions.

Encourage some crates to go further and leave rustc_target behind: it was no good for them.
2024-11-03 12:08:56 +01:00
Matthias Krüger
13cdfae599
Rollup merge of #132540 - compiler-errors:gc, r=calebcartwright
Do not format generic consts

We introduced **nightly support** for generic const items in #113522, but formatting of consts was not modified. Making them format *correctly* is hard, so let's just bail formatting them so we don't accidentally strip their generics and where clauses. This is essentially no-op formatting for generic const items.

r? `````@calebcartwright````` or `````@ytmimi`````
2024-11-03 12:08:55 +01:00
Matthias Krüger
7d7f2b5e2f
Rollup merge of #132537 - durin42:llvm-20-prelinklto, r=DianQK
PassWrapper: adapt for llvm/llvm-project@5445edb5d

As with ab5583ed1e, we had been explicitly passing defaults whose type have changed. Rather than do an ifdef, we simply rely on the defaults.

````@rustbot```` label: +llvm-main
2024-11-03 12:08:55 +01:00
Matthias Krüger
1a0ab892cd
Rollup merge of #132528 - compiler-errors:fallback-sugg-opt, r=jieyouxu
Use `*_opt` typeck results fns to not ICE in fallback suggestion

Self-explanatory. Fixes #132517.
2024-11-03 12:08:54 +01:00
Matthias Krüger
a7a0586618
Rollup merge of #132522 - senekor:consistenst-codegen-help, r=compiler-errors
make codegen help output more consistent

The output of `rustc -C help` generally has one option per line. There was one exception because of a (presumably) forgotten line continuation escape.
2024-11-03 12:08:53 +01:00
bors
db034cee00 Auto merge of #132419 - durin42:llvm-20-type-test-thing, r=cuviper
PassWrapper: adapt for llvm/llvm-project@b01e2a8b56

A boolean turned into an enum. None matches the old behavior of false, so we pass that.

`@rustbot` label: +llvm-main
2024-11-03 08:08:00 +00:00
bors
89ab6559cc Auto merge of #132526 - bjorn3:sync_cg_clif-2024-11-02, r=bjorn3
Subtree sync for rustc_codegen_cranelift

The highlight this time is an update to Cranelift 0.113,

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2024-11-03 05:03:52 +00:00
Jubilee Young
ab6994f880 compiler: Add rustc_abi to _sanitizers 2024-11-02 20:31:47 -07:00
Jubilee Young
31cbde037b compiler: Add rustc_abi to _monomorphize 2024-11-02 20:31:47 -07:00
Jubilee Young
4046e3610c compiler: Replace rustc_target with _abi in _trait_selection 2024-11-02 20:31:47 -07:00
Jubilee Young
bb0cd5606a compiler: Replace rustc_target with _abi in _hir 2024-11-02 20:31:47 -07:00
Jubilee Young
586766e790 compiler: Replace rustc_target with _abi in _borrowck 2024-11-02 20:31:47 -07:00
bors
8ccb78e0d5 Auto merge of #125579 - Noratrieb:print-host, r=davidtwco
Add `--print host-tuple` to print host target tuple

People often parse `-vV` output to get to the host tuple, which is annoying to do. It's easier to just get it directly.

I called it "host-tuple" instead of "host" because it's clearer that it's just the target name. I'm open to different names, but I think this one is fine.

a quick GitHub search for `'^host` reveals many instances of people doing the parsing, for example:

68e0ca57cd/README.md (L369)
0e38473b0c/main.sh (L96)
8a3553b865/README.md (L625)
43f3ec3970/do.sh (L35)

needs a compiler FCP. I could also do an MCP but I think just an FCP here makes the most sense.
2024-11-02 23:04:42 +00:00
uellenberg
67a85925b1 Suggest fixing typos and let bindings at the same time
Fixes #132483
2024-11-02 14:40:37 -07:00
Noratrieb
ba481518da Add --print host-triple
People often parse `-vV` output to get to the host triple, which is
annoying to do. It's easier to just get it directly.
2024-11-02 21:29:59 +01:00
Noratrieb
a26450cf81 Rename target triple to target tuple in many places in the compiler
This changes the naming to the new naming, used by `--print
target-tuple`.
It does not change all locations, but many.
2024-11-02 21:29:59 +01:00
Michael Goulet
16394e9776 Do not format generic consts 2024-11-02 20:25:06 +00:00
bors
b3f75cc872 Auto merge of #132147 - estebank:long-types-2, r=davidtwco
Tweak E0277 output when a candidate is available

*Follow up to #132086.*

Go from

```
error[E0277]: the trait bound `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>: CSTParser<'a>` is not satisfied
 --> src/main.rs:7:50
  |
7 | fn leaf<'a, O>(parser: impl CSTParser<'a, O>) -> impl CSTParser<'a, ()> {
  |                                                  ^^^^^^^^^^^^^^^^^^^^^^ the trait `chumsky::private::ParserSealed<'_, &str, (), chumsky::extra::Full<EmptyErr, (), ()>>` is not implemented for `Then<Ignored<Filter<Any<&str, ...>, ...>, ...>, ..., ..., ..., ...>`, which is required by `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>: CSTParser<'a>`
  |
  = help: the trait `chumsky::private::ParserSealed<'_, &'a str, ((), ()), chumsky::extra::Full<EmptyErr, (), ()>>` is implemented for `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>`
  = help: for that trait implementation, expected `((), ())`, found `()`
  = note: required for `Then<Ignored<Filter<Any<&str, ...>, ...>, ...>, ..., ..., ..., ...>` to implement `Parser<'_, &str, ()>`
note: required for `Then<Ignored<Filter<Any<&str, ...>, ...>, ...>, ..., ..., ..., ...>` to implement `CSTParser<'a>`
 --> src/main.rs:5:16
  |
5 | impl<'a, O, T> CSTParser<'a, O> for T where T: Parser<'a, &'a str, O> {}
  |                ^^^^^^^^^^^^^^^^     ^          ---------------------- unsatisfied trait bound introduced here
  = note: the full name for the type has been written to '/home/gh-estebank/longlong/target/debug/deps/longlong-0008f9a4f2023b08.long-type-13239977239800463552.txt'
  = note: consider using `--verbose` to print the full type name to the console
  = note: the full name for the type has been written to '/home/gh-estebank/longlong/target/debug/deps/longlong-0008f9a4f2023b08.long-type-13239977239800463552.txt'
  = note: consider using `--verbose` to print the full type name to the console
```

to

```
error[E0277]: the trait bound `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>: CSTParser<'a>` is not satisfied
  --> src/main.rs:7:50
   |
7  | fn leaf<'a, O>(parser: impl CSTParser<'a, O>) -> impl CSTParser<'a, ()> {
   |                                                  ^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
...
11 |     ws.then(parser.map(|_| ()))
   |     --------------------------- return type was inferred to be `Then<Ignored<..., ...>, ..., ..., ..., ...>` here
   |
   = help: the trait `ParserSealed<'_, &_, (), Full<_, _, _>>` is not implemented for `Then<Ignored<..., ...>, ..., ..., ..., ...>`
           but trait `ParserSealed<'_, &'a _, ((), ()), Full<_, _, _>>` is implemented for it
   = help: for that trait implementation, expected `((), ())`, found `()`
   = note: required for `Then<Ignored<..., ...>, ..., ..., ..., ...>` to implement `Parser<'_, &str, ()>`
note: required for `Then<Ignored<..., ...>, ..., ..., ..., ...>` to implement `CSTParser<'a>`
  --> src/main.rs:5:16
   |
5  | impl<'a, O, T> CSTParser<'a, O> for T where T: Parser<'a, &'a str, O> {}
   |                ^^^^^^^^^^^^^^^^     ^          ---------------------- unsatisfied trait bound introduced here
   = note: the full name for the type has been written to '/home/gh-estebank/longlong/target/debug/deps/longlong-df9d52be87eada65.long-type-1337037744507305372.txt'
   = note: consider using `--verbose` to print the full type name to the console
```

* Remove redundant wording
* Introduce trait diff highlighting logic and use it
* Fix incorrect "long type written to path" logic (can be split off)
* Point at tail expression in more cases in E0277
* Avoid long primary span labels in E0277 by moving them to a `help`

Fix #132013.

There are individual commits that can be their own PR. If the review load is too big, happy to split them off.
2024-11-02 20:22:49 +00:00
Augie Fackler
c61312268e PassWrapper: adapt for llvm/llvm-project@5445edb5d
As with ab5583ed1e, we had been explicitly
passing defaults whose type have changed. Rather than do an ifdef, we
simply rely on the defaults.

@rustbot label: +llvm-main
2024-11-02 15:50:44 -04:00
Augie Fackler
ab5583ed1e PassWrapper: adapt for llvm/llvm-project@b01e2a8b56
We don't see a reason to explicitly pass the default here, so just use
the default instead of explicitly passing it and needing an ifdef.

@rustbot label: +llvm-main
2024-11-02 14:39:58 -04:00
Michael Goulet
82f8b8f0e3 Use opt functions to not ICE in fallback suggestion 2024-11-02 15:25:12 +00:00
bjorn3
60f0cd87e8 Merge commit '5b1246bb4bed72fd0bb8fa497d8e5ed2c7f3515c' into sync_cg_clif-2024-11-02 2024-11-02 14:53:30 +00:00
Zalathar
90f2075b66 Port most of LLVMRustPrintTargetCPUs to Rust 2024-11-02 23:39:29 +11:00
Zalathar
0fa86f9660 Use a dedicated safe wrapper for LLVMRustGetHostCPUName 2024-11-02 23:39:29 +11:00
Remo Senekowitsch
8837fc7542 make codegen help output more consistent
The output of `rustc -C help` generally has one option per line. There was one
exception because of a (presumably) forgotten line continuation escape.
2024-11-02 12:35:48 +01:00
Taiki Endo
d19517dcd0 Support clobber_abi and vector registers (clobber-only) in PowerPC inline assembly 2024-11-02 20:26:08 +09:00
Matthias Krüger
30497b05cd
Rollup merge of #132488 - compiler-errors:more-fixmes-bye, r=jieyouxu
Remove or fix some more `FIXME(async_closure)`

Self-explanatory
2024-11-02 08:33:15 +01:00
Matthias Krüger
020b63aebc
Rollup merge of #132466 - cjgillot:opaque-late, r=compiler-errors
Account for late-bound depth when capturing all opaque lifetimes.

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

r? ````@compiler-errors````
2024-11-02 08:33:14 +01:00
Matthias Krüger
fa69b671a9
Rollup merge of #132453 - Urgau:non_local_defs-impl-mod-transparent, r=jieyouxu
Also treat `impl` definition parent as transparent regarding modules

This PR changes the `non_local_definitions` lint logic to also consider `impl` definition parent as transparent regarding modules.

See tests and explanation in the changes.

``````@rustbot`````` label +L-non_local_definitions
Fixes *(after beta-backport)* #132427
cc ``````@leighmcculloch``````
r? ``````@jieyouxu``````
2024-11-02 08:33:13 +01:00
Matthias Krüger
bb544f863f
Rollup merge of #131037 - madsmtm:move-llvm-target-versioning, r=petrochenkov
Move versioned Apple LLVM targets from `rustc_target` to `rustc_codegen_ssa`

Fully specified LLVM targets contain the OS version on macOS/iOS/tvOS/watchOS/visionOS, and this version depends on the deployment target environment variables like `MACOSX_DEPLOYMENT_TARGET`, `IPHONEOS_DEPLOYMENT_TARGET` etc.

We would like to move this to later in the compilation pipeline, both because it feels impure to access environment variables when fetching target information, but mostly because we need access to more information from https://github.com/rust-lang/rust/pull/130883 to do https://github.com/rust-lang/rust/issues/118204. See also https://github.com/rust-lang/rust/pull/129342#issuecomment-2335156119 for some discussion.

The first and second commit does the actual refactor, it should be a non-functional change, the third commit adds diagnostics for invalid deployment targets, which are now possible to do because we have access to the session.

Tested with the same commands as in https://github.com/rust-lang/rust/pull/130435.

r? ``````@petrochenkov``````
2024-11-02 08:33:10 +01:00
Michael Goulet
9e5e47fc32 Remove or fix some FIXME(async_closure) 2024-11-02 03:33:31 +00:00
Michael Goulet
c10fe34fb9 No need to instantiate binder in confirm_async_closure_candidate 2024-11-02 03:10:37 +00:00
Esteban Küber
143b072c62 Account for negative bounds in E0277 note and suggestion
Do not suggest `#[derive(Copy)]` when we wanted a `!Copy` type.

Do not say "`Copy` is not implemented for `T` but `Copy` is".

Do not talk about `Trait` having no implementations when `!Trait` was desired.
2024-11-02 03:08:04 +00:00
Esteban Küber
1a0c502183 On long E0277 primary span label, move it to a help
Long span labels don't read well.
2024-11-02 03:08:04 +00:00
Esteban Küber
092ecca5b9 Point at tail expression on rpit E0277
```
error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:8}: Coroutine` is not satisfied
  --> $DIR/gen_block_is_coro.rs:6:13
   |
LL | fn foo() -> impl Coroutine<Yield = u32, Return = ()> {
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:8}`
LL |     gen { yield 42 }
   |     ---------------- return type was inferred to be `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:8}` here
```

The secondary span label is new.
2024-11-02 03:08:04 +00:00
Esteban Küber
86b5965608 Use short_ty_string 2024-11-02 03:08:04 +00:00
Esteban Küber
c6017badb4 Fix type shortening writing to file
Make sure that we append to the file for long ty paths. Do not write the same type more than once. Shorten the calculated width a bit.
2024-11-02 03:08:04 +00:00
Esteban Küber
7b9105dd88 Trim output of E0277 in some cases
Remove default note for "trait is not implemented" in favor of the
more colorful diff output from the previous commit. Removes
duplicated output.
2024-11-02 03:08:04 +00:00
Esteban Küber
b7fc1a7431 Add trait diff highlighting logic and use it in E0277
When a trait is not implemented for a type, but there *is* an `impl`
for another type or different trait params, we format the output to
use highlighting in the same way that E0308 does for types.

The logic accounts for 3 cases:
- When both the type and trait in the expected predicate and the candidate are different
- When only the types are different
- When only the trait generic params are different

For each case, we use slightly different formatting and wording.
2024-11-02 03:08:04 +00:00
bors
7c7bb7dc01 Auto merge of #132470 - GuillaumeGomez:rollup-1a1mkmp, r=GuillaumeGomez
Rollup of 14 pull requests

Successful merges:

 - #131829 (Remove support for `-Zprofile` (gcov-style coverage instrumentation))
 - #132369 (style-guide: Only use the new binop heuristic for assignments)
 - #132383 (Implement suggestion for never type fallback lints)
 - #132413 (update offset_of! docs to reflect the stabilization of nesting)
 - #132438 (Remove unncessary option for default rust-analyzer setting)
 - #132439 (Add `f16` and `f128` to `invalid_nan_comparison`)
 - #132444 (rustdoc: Directly use rustc_abi instead of reexports)
 - #132445 (Cleanup attributes around unchecked shifts and unchecked negation in const)
 - #132448 (Add missing backtick)
 - #132450 (Show actual MIR when MIR building forgot to terminate block)
 - #132451 (remove some unnecessary rustc_allow_const_fn_unstable)
 - #132455 (make const_alloc_layout feature gate only about functions that are already stable)
 - #132456 (Move remaining inline assembly test files into asm directory)
 - #132459 (feat(byte_sub_ptr): unstably add ptr::byte_sub_ptr)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-01 21:49:15 +00:00
Luca Versari
c8b76bcf58 Emit warning when calling/declaring functions with unavailable vectors.
On some architectures, vector types may have a different ABI depending
on whether the relevant target features are enabled. (The ABI when the
feature is disabled is often not specified, but LLVM implements some
de-facto ABI.)

As discussed in rust-lang/lang-team#235, this turns out to very easily
lead to unsound code.

This commit makes it a post-monomorphization future-incompat warning to
declare or call functions using those vector types in a context in which
the corresponding target features are disabled, if using an ABI for
which the difference is relevant. This ensures that these functions are
always called with a consistent ABI.

See the [nomination comment](https://github.com/rust-lang/rust/pull/127731#issuecomment-2288558187)
for more discussion.

Part of #116558
2024-11-01 22:24:35 +01:00
Guillaume Gomez
7bfdc3d898
Rollup merge of #132450 - bjorn3:better_mir_errors, r=jieyouxu
Show actual MIR when MIR building forgot to terminate block

This makes it significantly easier to debug bugs of this kind.
2024-11-02 03:08:54 +08:00
Guillaume Gomez
2896483320
Rollup merge of #132439 - tgross35:f16-f128-nan-lint, r=jieyouxu
Add `f16` and `f128` to `invalid_nan_comparison`

Currently `f32_nan` and `f64_nan` are used to provide the `invalid_nan_comparison` lint. Since we have `f16_nan` and `f128_nan`, hook these up so the new float types get the same lints.
2024-11-02 03:08:52 +08:00