Commit graph

42592 commits

Author SHA1 Message Date
Matthias Krüger
c371a94e78
Rollup merge of #134745 - compiler-errors:better-arg-span-in-typeck, r=BoxyUwU
Normalize each signature input/output in `typeck_with_fallback` with its own span

Applies the same hack as #106582 but to the args in typeck. Greatly improves normalization error spans from a signature.
2025-01-07 21:39:39 +01:00
Matthias Krüger
191fb23940
Rollup merge of #133810 - lcnr:remove-verify_bound, r=compiler-errors
remove unnecessary `eval_verify_bound`

This does not impact any tests. I feel like any cases where this could useful should instead be fixed by a general improvement to `eval_verify_bound` to avoid having to promote this `TypeTest` in the first place 🤔

r? types cc ``@nikomatsakis``
2025-01-07 21:39:38 +01:00
Guillaume Gomez
225ffebc0a
Rollup merge of #135199 - joshtriplett:unnecessary-to-string, r=lqd
Eliminate an unnecessary `Symbol::to_string`; use `as_str`
2025-01-07 15:30:28 +01:00
Guillaume Gomez
ec266207cb
Rollup merge of #135198 - joshtriplett:str-is-a-type, r=jieyouxu
Avoid naming variables `str`

This renames variables named `str` to other names, to make sure `str`
always refers to a type.

It's confusing to read code where `str` (or another standard type name)
is used as an identifier. It also produces misleading syntax
highlighting.
2025-01-07 15:30:28 +01:00
Guillaume Gomez
a33da79fa9
Rollup merge of #135182 - scottmcm:box-deref-via-transmute, r=oli-obk
Transmute from NonNull to pointer when elaborating a box deref (MCP807)

Since per https://github.com/rust-lang/compiler-team/issues/807 we have to stop projecting into `NonNull`.

cc https://github.com/rust-lang/rust/issues/133652
2025-01-07 15:30:25 +01:00
Guillaume Gomez
020d8758f4
Rollup merge of #135177 - maurer:rename-module, r=nikic
llvm: Ignore error value that is always false

See llvm/llvm-project#121851

For LLVM 20+, this function (`renameModuleForThinLTO`) has no return value. For prior versions of LLVM, this never failed, but had a signature which allowed an error value people were handling.

`@rustbot` label: +llvm-main
r? `@nikic`

Wait a moment before approving while the llvm-main infrastructure picks it up.
2025-01-07 15:30:25 +01:00
Josh Triplett
bb6bbfa13f Avoid naming variables str
This renames variables named `str` to other names, to make sure `str`
always refers to a type.

It's confusing to read code where `str` (or another standard type name)
is used as an identifier. It also produces misleading syntax
highlighting.
2025-01-07 14:30:02 +02:00
Josh Triplett
7cc99a864a Eliminate an unnecessary Symbol::to_string; use as_str 2025-01-07 14:24:47 +02:00
bors
fb546ee09b Auto merge of #135173 - pietroalbini:pa-fix-rvp, r=workingjubilee
Avoid replacing the definition of `CURRENT_RUSTC_VERSION`

Before this PR, replace-version-placeholder hardcoded the path defining CURRENT_RUSTC_VERSION (to avoid replacing it). After a refactor moved the file defining it without changing the hardcoded path, the tool started replacing the constant itself with the version number.

To avoid this from happening in the future, this changes the definition of the constant to avoid the tool from ever matching it.

r? `@workingjubilee`
2025-01-07 07:21:09 +00:00
Jacob Pratt
44808ae798
Rollup merge of #135126 - klensy:deprecated-and-do-nothing, r=jieyouxu
mark deprecated option as deprecated in rustc_session to remove copypasta and small refactor

This marks deprecated options as deprecated via flag in options table in rustc_session, which removes copypasted deprecation text from rustc_driver_impl.

This also adds warning for deprecated `-C ar` option, which didn't emitted any warnings before.
Makes `inline_threshold` `[UNTRACKED]`, as it do nothing.
Adds few tests.

See individual commits.
2025-01-06 22:04:17 -05:00
Jacob Pratt
8b54f951e5
Rollup merge of #135090 - compiler-errors:invalid-tuple-ctor-projection, r=lqd,jieyouxu
Suggest to replace tuple constructor through projection

See the code example. when `Self::Assoc` normalizes to a struct that has a tuple constructor, you cannot construct the type via `Self::Assoc(field, field)`. Instead, suggest to replace it with the correct named struct.

Fixes #120871
2025-01-06 22:04:15 -05:00
Jacob Pratt
3deb5c289e
Rollup merge of #134744 - compiler-errors:transmute-non-wf, r=lcnr
Don't ice on bad transmute in typeck in new solver

Old trait solver ends up getting its infcx tainted because we try to normalize the type, but the new trait solver doesn't. This means we try to compute the stalled transmute obligations, which tries to normalize a type an ICEs. Let's make this a delayed bug.

r? lcnr
2025-01-06 22:04:15 -05:00
Jacob Pratt
b642740e4f
Rollup merge of #132345 - compiler-errors:fx-diag, r=lcnr
Improve diagnostics for `HostEffectPredicate` in the new solver

Adds derived cause for host effect predicates. Some diagnostics regress, but that's connected to the fact that our predicate visitor doesn't play well with aliases just yet.
2025-01-06 22:04:13 -05:00
Jacob Pratt
4e4a93c2dd
Rollup merge of #131830 - hoodmane:emscripten-wasm-eh, r=workingjubilee
Add support for wasm exception handling to Emscripten target

This is a draft because we need some additional setting for the Emscripten target to select between the old exception handling and the new exception handling. I don't know how to add a setting like that, would appreciate advice from Rust folks. We could maybe choose to use the new exception handling if `Ctarget-feature=+exception-handling` is passed? I tried this but I get errors from llvm so I'm not doing it right.
2025-01-06 22:04:13 -05:00
Scott McMurray
ad5f912d96 Transmute from NonNull to pointer when elaborating a box deref (MCP807) 2025-01-06 18:43:40 -08:00
Matthew Maurer
fc32dd49cb llvm: Ignore error value that is always false
See llvm/llvm-project#121851

For LLVM 20+, this function (`renameModuleForThinLTO`) has no return
value. For prior versions of LLVM, this never failed, but had a
signature which allowed an error value people were handling.
2025-01-07 01:02:22 +00:00
Pietro Albini
80cdaeac3d
avoid replacing the definition of CURRENT_RUSTC_VERSION
Before this commit, replace-version-placeholder hardcoded the path
defining CURRENT_RUSTC_VERSION (to avoid replacing it). After a refactor
moved the file defining it without changing the hardcoded path, the tool
started replacing the constant itself with the version number.

To avoid this from happening in the future, this changes the definition
of the constant to avoid the tool from ever matching it.
2025-01-06 21:53:48 +01:00
Matthias Krüger
68791efa29
Rollup merge of #134951 - compiler-errors:double-trait-err-msg, r=davidtwco
Suppress host effect predicates if underlying trait doesn't hold

Don't report two errors for when the (`HostEffectPredicate`) `T: const Trait` isn't implemented because (`TraitPredicate`) `T: Trait` doesn't even hold.
2025-01-06 20:59:33 +01:00
Matthias Krüger
44c6e83b49
Rollup merge of #134771 - compiler-errors:const-arg-has-type-err, r=lcnr
Report correct `SelectionError` for `ConstArgHasType` in new solver fulfill

r? ``@BoxyUwU``
2025-01-06 20:59:32 +01:00
Matthias Krüger
49b05ed7c1
Rollup merge of #134742 - compiler-errors:post-borrowck-analysis, r=lcnr
Use `PostBorrowckAnalysis` in `check_coroutine_obligations`

This currently errors with:

```
error: concrete type differs from previous defining opaque type use
  --> tests/ui/coroutine/issue-52304.rs:10:21
   |
10 | pub fn example() -> impl Coroutine {
   |                     ^^^^^^^^^^^^^^ expected `{example::{closure#0} upvar_tys=() resume_ty=() yield_ty=&'{erased} i32 return_ty=() witness={example::{closure#0}}}`, got `{example::{closure#0} upvar_tys=() resume_ty=() yield_ty=&'static i32 return_ty=() witness={example::{closure#0}}}`
   |
   = note: previous use here
```

This is because we end up redefining the opaque in `check_coroutine_obligations` but with the `yield_ty = &'erased i32` from hir typeck, which causes the *equality* check for opaques to fail.

The coroutine obligtions in question (when `-Znext-solver` is enabled) are:

```
Binder { value: TraitPredicate(<Opaque(DefId(0:5 ~ issue_52304[4c6d]::example::{opaque#0}), []) as std::marker::Sized>, polarity:Positive), bound_vars: [] }

Binder { value: AliasRelate(Term::Ty(Alias(Opaque, AliasTy { args: [], def_id: DefId(0:5 ~ issue_52304[4c6d]::example::{opaque#0}), .. })), Equate, Term::Ty(Coroutine(DefId(0:6 ~ issue_52304[4c6d]::example::{closure#0}), [(), (), &'{erased} i32, (), CoroutineWitness(DefId(0:6 ~ issue_52304[4c6d]::example::{closure#0}), []), ()]))), bound_vars: [] }

Binder { value: AliasRelate(Term::Ty(Coroutine(DefId(0:6 ~ issue_52304[4c6d]::example::{closure#0}), [(), (), &'{erased} i32, (), CoroutineWitness(DefId(0:6 ~ issue_52304[4c6d]::example::{closure#0}), []), ()])), Subtype, Term::Ty(Alias(Opaque, AliasTy { args: [], def_id: DefId(0:5 ~ issue_52304[4c6d]::example::{opaque#0}), .. }))), bound_vars: [] }
```

Ignoring the fact that we end up stalling some really dumb obligations here (lol), I think it makes more sense for us to be using post borrowck analysis for this check anyways.

r? lcnr
2025-01-06 20:59:31 +01:00
Michael Goulet
304ccf45d1 Suggest to replace tuple constructor through projection 2025-01-06 18:04:33 +00:00
Michael Goulet
ebdf19a8bb Recurse on GAT where clauses in fulfillment error proof tree visitor 2025-01-06 17:58:42 +00:00
Michael Goulet
5a566005c1 Normalize each signature input/output in typeck_with_fallback with its own span 2025-01-06 17:58:30 +00:00
Michael Goulet
96285bde38 Don't ice on bad transmute in typeck in new solver 2025-01-06 17:56:16 +00:00
Michael Goulet
2be9ffc1af Add derived causes for host effect predicates 2025-01-06 17:49:46 +00:00
klensy
37f26311eb add deprecated and do nothing flag to options table
inline_threshold mark deprecated

no-stack-check

print deprecation message for -Car too

inline_threshold deprecated and do nothing: make in untracked

make OptionDesc struct from tuple
2025-01-06 15:38:02 +03:00
Hood Chatham
49c74234a7 Add support for wasm exception handling to Emscripten target
Gated behind an unstable `-Z emscripten-wasm-eh` flag
2025-01-06 10:29:54 +01:00
bors
13738b0abe Auto merge of #135151 - matthiaskrgr:rollup-2vy1hwl, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #135111 (Add doc aliases for `libm` and IEEE names)
 - #135129 (triagebot: label `src/doc/rustc-dev-guide` changes with `A-rustc-dev-guide`)
 - #135132 (dev guide ping group and set adhoc reviewers to compiler)
 - #135145 (Mention `unnameable_types` in `unreachable_pub` documentation.)
 - #135147 (A few borrowck tweaks to improve 2024 edition migration lints)
 - #135150 (move footnote to ordinary comment)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-06 08:08:13 +00:00
Matthias Krüger
c5c05c2528
Rollup merge of #135150 - lcnr:unconstrained-lts-comment, r=oli-obk
move footnote to ordinary comment

cc #135057
2025-01-06 08:09:07 +01:00
Matthias Krüger
ee6914a45b
Rollup merge of #135147 - compiler-errors:borrowck-tweaks, r=chenyukang
A few borrowck tweaks to improve 2024 edition migration lints

See first two commits' changes to test outputs. Test coverage in this area is kinda weak, but I think it affects more cases than this (like the craters that will begin to trigger the `tail_expr_drop_order` tests in #134523).

Third commit is a drive-by change that removes a deref hack from `UseSpans` which doesn't really improve diagnostics much.
2025-01-06 08:09:06 +01:00
Matthias Krüger
b561659e43
Rollup merge of #135145 - kpreid:unnameable, r=compiler-errors
Mention `unnameable_types` in `unreachable_pub` documentation.

This link makes sense because someone who wishes to avoid unusable `pub` is likely, but not guaranteed, to be interested in avoiding unnameable types.

Also fixed some grammar problems I noticed in the area.

Fixes #116604.

r? Urgau
2025-01-06 08:09:05 +01:00
lcnr
ae6a3313cf footnote to ordinary comment 2025-01-06 07:37:52 +01:00
bors
fd98df8f14 Auto merge of #135085 - knickish:m68k_unknown_none, r=workingjubilee
add m68k-unknown-none-elf target

r? `@workingjubilee`

The existing `m68k-unknown-linux-gnu` target builds `std` by default, requires atomics, and has a base cpu with an fpu. A smaller/more embedded target is desirable both to have a baseline target for the ISA, as well to make debugging easier for working on the llvm backend. Currently this target is using the `M68010` as the minimum CPU due, but as missing features are merged into the `M68k` llvm backend I am hoping to lower this further.

I have been able to build very small crates using a toolchain built against this target (together with a later version of `object`) using the configuration described in the target platform-support documentation, although getting anything of substantial complexity to build quickly hits errors in the llvm backend
2025-01-06 05:23:55 +00:00
Michael Goulet
339902908e Remove CallKind::Deref hack from UseSpans
It's not really necessary
2025-01-06 03:55:19 +00:00
Michael Goulet
cd65cd27db Improve find_self_call with reborrowed receiver 2025-01-06 03:17:04 +00:00
Michael Goulet
3560a2b399 Improve span when temporary receiver is dropped in edition 2024 2025-01-06 03:14:04 +00:00
bors
56f9e6f935 Auto merge of #135140 - jhpratt:rollup-pn2gi84, r=jhpratt
Rollup of 3 pull requests

Successful merges:

 - #135115 (cg_llvm: Use constants for DWARF opcodes, instead of FFI calls)
 - #135118 (Clarified the documentation on `core::iter::from_fn` and `core::iter::successors`)
 - #135121 (Mark `slice::reverse` unstably const)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-06 02:30:55 +00:00
Kevin Reid
2a96478dd8 Mention unnameable_types in unreachable_pub documentation.
This link makes sense because someone who wishes to avoid unusable `pub`
is likely, but not guaranteed, to be interested in avoiding unnameable
types.

Also fixed some grammar problems I noticed in the area.

Fixes #116604.
2025-01-05 17:13:33 -08:00
Jacob Pratt
b9f971a52c
Rollup merge of #135115 - Zalathar:dwarf-const, r=workingjubilee
cg_llvm: Use constants for DWARF opcodes, instead of FFI calls

Split off from #134009 to incorporate feedback from https://github.com/rust-lang/rust/pull/134009#discussion_r1903133906.

Most of the constant values now come from gimli, which is already a compiler dependency.

I noticed that `DW_OP_LLVM_fragment` is an LLVM detail that is not defined by DWARF and could hypothetically change, so I added a static assertion on the C++ side to detect that if it ever happens.

r? workingjubilee
2025-01-05 18:35:04 -05:00
bors
feb32c6546 Auto merge of #134794 - RalfJung:abi-required-target-features, r=workingjubilee
Add a notion of "some ABIs require certain target features"

I think I finally found the right shape for the data and checks that I recently added in https://github.com/rust-lang/rust/pull/133099, https://github.com/rust-lang/rust/pull/133417, https://github.com/rust-lang/rust/pull/134337: we have a notion of "this ABI requires the following list of target features, and it is incompatible with the following list of target features". Both `-Ctarget-feature` and `#[target_feature]` are updated to ensure we follow the rules of the ABI.  This removes all the "toggleability" stuff introduced before, though we do keep the notion of a fully "forbidden" target feature -- this is needed to deal with target features that are actual ABI switches, and hence are needed to even compute the list of required target features.

We always explicitly (un)set all required and in-conflict features, just to avoid potential trouble caused by the default features of whatever the base CPU is. We do this *before* applying `-Ctarget-feature` to maintain backward compatibility; this poses a slight risk of missing some implicit feature dependencies in LLVM but has the advantage of not breaking users that deliberately toggle ABI-relevant target features. They get a warning but the feature does get toggled the way they requested.

For now, our logic supports x86, ARM, and RISC-V (just like the previous logic did). Unsurprisingly, RISC-V is the nicest. ;)

As a side-effect this also (unstably) allows *enabling* `x87` when that is harmless. I used the opportunity to mark SSE2 as required on x86-64, to better match the actual logic in LLVM and because all x86-64 chips do have SSE2. This infrastructure also prepares us for requiring SSE on x86-32 when we want to use that for our ABI (and for float semantics sanity), see https://github.com/rust-lang/rust/issues/133611, but no such change is happening in this PR.

r? `@workingjubilee`
2025-01-05 23:21:06 +00:00
bjorn3
a94e2d513b Merge commit '918acafef6' into sync_cg_clif-2025-01-05 2025-01-05 15:44:46 +00:00
Zalathar
f50721ebad Explain why the DW_TAG_* constants remain as-is for now 2025-01-05 22:16:49 +11:00
Zalathar
1b62645418 Use constants for DWARF opcodes, instead of FFI calls 2025-01-05 22:16:25 +11:00
Zalathar
e267106104 Use gimli to get the values of DWARF constants needed by codegen
The `gimli` crate is already a dependency of `thorin-dwp`, which is already a
dependency of `rustc_codegen_ssa`.
2025-01-05 22:07:48 +11:00
Ralf Jung
2e64b5352b add dedicated type for ABI target feature constraints 2025-01-05 10:46:30 +01:00
bors
7270e73b62 Auto merge of #135074 - wzssyqa:mips-mti, r=oli-obk
Target: Add mips mti baremetal support

Do the same thing as gcc, which use the vendor `mti` to mark the toolchain as MIPS32r2 default.

We support both big endian and little endian flavor:
  mips-mti-none-elf
  mipsel-mti-none-elf
2025-01-05 07:01:38 +00:00
kirk
ff7f818fc7 change to static relocation model 2025-01-05 05:04:34 +00:00
bors
3dc3c524f7 Auto merge of #133990 - Walnut356:static_const, r=workingjubilee
[Debuginfo] Force enum `DISCR_*` to `static const u64` to allow for inspection via LLDB

see [here](486614878) for more info.

This change mainly helps `*-msvc` debugged with LLDB. Currently, LLDB cannot inspect `static` struct fields, so the intended visualization for enums is only borderline functional, and niche enums with ranges of discriminant cannot be determined at all .

LLDB *can* inspect `static const` values (though for whatever reason, non-enum/non-u64 consts don't work).

This change adds the `LLVMRustDIBuilderCreateQualifiedType` to the rust FFI layer to wrap the discr type with a `const` modifier, as well as forcing all generated integer enum `DISCR_*` values to be u64's. Those values will only ever be used by debugger visualizers anyway, so it shouldn't be a huge deal, but I left a fixme comment for it just in case.. The `tag` also still properly reflects the discriminant type, so no information is lost.
2025-01-04 23:56:29 +00:00
bors
1891c28669 Auto merge of #135101 - workingjubilee:rollup-owp3czl, r=workingjubilee
Rollup of 6 pull requests

Successful merges:

 - #135046 (turn rustc_box into an intrinsic)
 - #135061 (crashes: add latest batch of tests)
 - #135070 (std: sync to dep versions of backtrace)
 - #135088 (Force code generation in assembly generation smoke-tests)
 - #135091 (Bump backtrace to 0.3.75)
 - #135094 (bootstrap: If dir_is_empty fails, show the non-existent directory path)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-04 21:11:28 +00:00
knickish
139ca10f65
Apply suggestions from workingjubilee's code review
Co-authored-by: Jubilee <workingjubilee@gmail.com>
2025-01-04 12:52:19 -06:00