Commit graph

590 commits

Author SHA1 Message Date
Jonathan Gruner
df6254f7a2 report call site of inlined scopes for large assignment lints 2025-04-08 20:49:50 +02:00
Oli Scherer
c0fe46d6b7 Make missing optimized MIR error more informative 2025-04-01 09:25:12 +00:00
Stuart Cook
c33df2763f
Rollup merge of #138980 - tmiasko:collect-var-debug-info, r=compiler-errors
Collect items referenced from var_debug_info

The collection is limited to full debuginfo builds to match behavior of FunctionCx::compute_per_local_var_debug_info.

Fixes #138942.
2025-03-27 15:57:25 +11:00
Tomasz Miąsko
b04e5b4963 Collect items referenced from var_debug_info
The collection is limited to full debuginfo builds to match behavior of
FunctionCx::compute_per_local_var_debug_info.
2025-03-26 11:35:34 +01:00
Michael Goulet
5f1e36f8ad Stop using Interner in the compiler randomly 2025-03-26 04:39:38 +00:00
Ralf Jung
e88c49c454 acquire more accurate HirId for ABI check lints 2025-03-25 11:30:57 +01:00
Ralf Jung
072ccce553 make -Zwasm-c-abi=legacy suppress the lint 2025-03-25 08:22:35 +01:00
Ralf Jung
c961d123d2 add FCW to warn about wasm ABI transition 2025-03-25 08:22:35 +01:00
bors
249cb84316 Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #137314 (change definitely unproductive cycles to error)
 - #137701 (Convert `ShardedHashMap` to use `hashbrown::HashTable`)
 - #138269 (uefi: fs: Implement FileType, FilePermissions and FileAttr)
 - #138331 (Use `RUSTC_LINT_FLAGS` more)
 - #138345 (Some autodiff cleanups)
 - #138387 (intrinsics: remove unnecessary leading underscore from argument names)
 - #138390 (fix incorrect tracing log)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-12 17:27:43 +00:00
Matthias Krüger
de7e5e96be
Rollup merge of #138345 - oli-obk:autodiff-cleanup, r=compiler-errors
Some autodiff cleanups

cc ````@ZuseZ4````

just some things I noticed
2025-03-12 17:59:09 +01:00
Oli Scherer
9882eca151 Remove some dead code 2025-03-11 08:41:15 +00:00
Oli Scherer
ff5a8ad2ab Explain the actual reason why stripping binders is fine 2025-03-11 08:40:35 +00:00
Nicholas Nethercote
ff0a5fe975 Remove #![warn(unreachable_pub)] from all compiler/ crates.
It's no longer necessary now that `-Wunreachable_pub` is being passed.
2025-03-11 13:14:21 +11:00
许杰友 Jieyou Xu (Joe)
063ef18fdc Revert "Use workspace lints for crates in compiler/ #138084"
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to
consider options that avoids breaking downstream usages of cargo on
distributed `rustc-src` artifacts, where such cargo invocations fail due
to inability to inherit `lints` from workspace root manifest's
`workspace.lints` (this is only valid for the source rust-lang/rust
workspace, but not really the distributed `rustc-src` artifacts).

This breakage was reported in
<https://github.com/rust-lang/rust/issues/138304>.

This reverts commit 48caf81484, reversing
changes made to c6662879b2.
2025-03-10 18:12:47 +08:00
Nicholas Nethercote
8a3e03392e Remove #![warn(unreachable_pub)] from all compiler/ crates.
(Except for `rustc_codegen_cranelift`.)

It's no longer necessary now that `unreachable_pub` is in the workspace
lints.
2025-03-08 08:41:43 +11:00
Nicholas Nethercote
beba32cebb Specify rust lints for compiler/ crates via Cargo.
By naming them in `[workspace.lints.rust]` in the top-level
`Cargo.toml`, and then making all `compiler/` crates inherit them with
`[lints] workspace = true`. (I omitted `rustc_codegen_{cranelift,gcc}`,
because they're a bit different.)

The advantages of this over the current approach:
- It uses a standard Cargo feature, rather than special handling in
  bootstrap. So, easier to understand, and less likely to get
  accidentally broken in the future.
- It works for proc macro crates.

It's a shame it doesn't work for rustc-specific lints, as the comments
explain.
2025-03-08 08:41:09 +11:00
Nicholas Nethercote
293fe0a966 Increase recursion_limit in numerous crates.
This is temporarily needed for `x doc compiler` to work. They can be
removed once the `Nonterminal` is removed (#124141).
2025-03-07 14:51:07 +11:00
Jubilee Young
e81fbe30e6 compiler: use is_rustic_abi in abi_check
warns on fewer ABIs now
2025-03-04 18:23:51 -08:00
Zalathar
32c5449d45 Remove some unnecessary aliases from rustc_data_structures::sync
With the removal of `cfg(parallel_compiler)`, these are always shared
references and `std::sync::OnceLock`.
2025-03-03 20:20:24 +11:00
Ralf Jung
aac65f562b rename BackendRepr::Vector → SimdVector 2025-02-28 17:17:45 +01:00
León Orell Valerian Liehr
51085b21ce
Rollup merge of #137601 - davidtwco:deduplicate-type-has-metadata, r=fmease,bjorn3
ssa/mono: deduplicate `type_has_metadata`

The implementation of the `type_has_metadata` function is duplicated in `rustc_codegen_ssa` and `rustc_monomorphize`, so move this to `rustc_middle`.
2025-02-26 04:15:05 +01:00
León Orell Valerian Liehr
292c003ce7
Rollup merge of #137529 - klensy:unused3, r=lcnr
remove few unused args
2025-02-26 04:15:04 +01:00
klensy
cede9029fd cleanup few unused args 2025-02-24 12:19:52 +03:00
David Wood
5afa6a111b
ssa/mono: deduplicate type_has_metadata
The implementation of the `type_has_metadata` function is duplicated in
`rustc_codegen_ssa` and `rustc_monomorphize`, so move this to
`rustc_middle`.
2025-02-24 08:08:23 +00:00
bors
b522e7c5ea Auto merge of #137225 - RalfJung:vectorcall, r=nnethercote
vectorcall ABI: require SSE2

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

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

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

Cc `@workingjubilee`

try-job: dist-i586-gnu-i586-i686-musl
2025-02-23 14:12:38 +00:00
Jacob Pratt
7f14d2eba4
Rollup merge of #137334 - compiler-errors:edition-2024-fresh-2, r=saethlin,traviscross
Greatly simplify lifetime captures in edition 2024

Remove most of the `+ Captures` and `+ '_` from the compiler, since they are now unnecessary with the new edition 2021 lifetime capture rules. Use some `+ 'tcx` and `+ 'static` rather than being overly verbose with precise capturing syntax.
2025-02-23 02:44:18 -05:00
Matthias Krüger
4115f51d15
Rollup merge of #137180 - compiler-errors:sym-regions, r=oli-obk
Give `global_asm` a fake body to store typeck results, represent `sym fn` as a hir expr to fix `sym fn` operands with lifetimes

There are a few intertwined problems with `sym fn` operands in both inline and global asm macros.

Specifically, unlike other anon consts, they may evaluate to a type with free regions in them without actually having an item-level type annotation to give them a "proper" type. This is in contrast to named constants, which always have an item-level type annotation, or unnamed constants which are constrained by their position (e.g. a const arg in a turbofish, or a const array length).

Today, we infer the type of the operand by looking at the HIR typeck results; however, those results are region-erased, so during borrowck we ICE since we don't expect to encounter erased regions. We can't just fill this type with something like `'static`, since we may want to use real (free) regions:

```rust
fn foo<'a>() {
  asm!("/* ... */", sym bar::<&'a ()>);
}
```

The first idea may be to represent `sym fn` operands using *inline* consts instead of anon consts. This makes sense, since inline consts can reference regions from the parent body (like the `'a` in the example above). However, this introduces a problem with `global_asm!`, which doesn't *have* a parent body; inline consts *must* be associated with a parent body since they are not a body owner of their own. In #116087, I attempted to fix this by using two separate `sym` operands for global and inline asm. However, this led to a lot of confusion and also some unattractive code duplication.

In this PR, I adjust the lowering of `global_asm!` so that it's lowered in a "fake" HIR body. This body contains a single expression which is `ExprKind::InlineAsm`; we don't *use* this HIR body, but it's used in typeck and borrowck so that we can properly infer and validate the the lifetimes of `sym fn` operands.

I then adjust the lowering of `sym fn` to instead be represented with a HIR expression. This is both because it's no longer necessary to represent this operand as an anon const, since it's *just* a path expression, and also more importantly to sidestep yet another ICE (https://github.com/rust-lang/rust/issues/137179), which has to do with the existing code breaking an invariant of def-id creation and anon consts. Specifically, we are not allowed to synthesize a def-id for an anon const when that anon const contains expressions with def-ids whose parent is *not* that anon const. This is somewhat related to https://github.com/rust-lang/rust/pull/130443#issuecomment-2445678945, which is also a place in the compiler where synthesizing anon consts leads to def-id parenting issue.

As a side-effect, this consolidates the type checking for inline and global asm, so it allows us to simplify `InlineAsmCtxt` a bit. It also allows us to delete a bit of hacky code from anon const `type_of` which was there to detect `sym fn` operands specifically. This also could be generalized to support `const` asm operands with types with lifetimes in them. Since we specifically reject these consts today, I'm not going to change the representation of those consts (but they'd just be turned into inline consts).

r? oli-obk -- mostly b/c you're patient and also understand the breadth of the code that this touches, please reassign if you don't want to review this.

Fixes #111709
Fixes #96304
Fixes #137179
2025-02-23 00:16:19 +01:00
Michael Goulet
12e3911d81 Greatly simplify lifetime captures in edition 2024 2025-02-22 22:24:52 +00:00
bors
15469f8f8a Auto merge of #137420 - matthiaskrgr:rollup-rr0q37f, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #136910 (Implement feature `isolate_most_least_significant_one` for integer types)
 - #137183 (Prune dead regionck code)
 - #137333 (Use `edition = "2024"` in the compiler (redux))
 - #137356 (Ferris 🦀 Identifier naming conventions)
 - #137362 (Add build step log for `run-make-support`)
 - #137377 (Always allow reusing cratenum in CrateLoader::load)
 - #137388 (Fix(lib/fs/tests): Disable rename POSIX semantics FS tests under Windows 7)
 - #137410 (Use StableHasher + Hash64 for dep_tracking_hash)
 - #137413 (jubilee cleared out the review queue)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-22 13:32:44 +00:00
Manuel Drehwald
f4e2218b13 clean up autodiff code/comments 2025-02-21 21:47:48 -05:00
Michael Goulet
3d5438accd Fix binding mode problems 2025-02-22 00:13:19 +00:00
Michael Goulet
6ba39f7dc7 Make a fake body to store typeck results for global_asm 2025-02-22 00:12:07 +00:00
Michael Goulet
2a6daaf89a Make asm a named field 2025-02-22 00:05:09 +00:00
Michael Goulet
76d341fa09 Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
Ralf Jung
83fd16f625 vectorcall ABI: error if sse2 is not available 2025-02-20 12:40:58 +01:00
Ralf Jung
79b2360d98 mono-time abi_check: unify error paths for call and definition sites
also move the existing tests to a more sensible location
2025-02-20 11:55:31 +01:00
Michael Goulet
047e77cff1 Register USAGE_OF_TYPE_IR_INHERENT, remove inherent usages 2025-02-19 07:19:27 +00:00
Nicholas Nethercote
f86f7ad5f2 Move some Map methods onto TyCtxt.
The end goal is to eliminate `Map` altogether.

I added a `hir_` prefix to all of them, that seemed simplest. The
exceptions are `module_items` which became `hir_module_free_items` because
there was already a `hir_module_items`, and `items` which became
`hir_free_items` for consistency with `hir_module_free_items`.
2025-02-17 13:21:02 +11:00
Ralf Jung
313e8526dc abi_unsupported_vector_types: say which type is the problem 2025-02-15 20:02:16 +01:00
Michael Goulet
2ada9ccb7d Normalize closure instance before eagerly monomorphizing it 2025-02-14 19:18:43 +00:00
bors
124cc92199 Auto merge of #136751 - bjorn3:update_rustfmt, r=Mark-Simulacrum
Update bootstrap compiler and rustfmt

The rustfmt version we previously used formats things differently from what the latest nightly rustfmt does. This causes issues for subtrees that get formatted both in-tree and in their own repo. Updating the rustfmt used in-tree solves those issues. Also bumped the bootstrap compiler as the stage0 update command always updates both at the same
time.
2025-02-09 15:44:16 +00:00
Jubilee
5e4d6278af
Rollup merge of #136706 - workingjubilee:finish-up-rustc-abi-updates, r=compiler-errors
compiler: mostly-finish `rustc_abi` updates

This almost-finishes all the updates in the compiler to use `rustc_abi` and removes some of the reexports of `rustc_abi` items in `rustc_target` that were previously available.

r? ```@compiler-errors```
2025-02-08 20:41:21 -08:00
bjorn3
1fcae03369 Rustfmt 2025-02-08 22:12:13 +00:00
Jubilee Young
1f37b9a643 compiler: remove rustc_target::abi entirely 2025-02-07 11:23:12 -08:00
bjorn3
f68cd90412 Remove Linkage::Appending
It can only be used for certain LLVM internal variables like
llvm.global_ctors which users are not allowed to define.
2025-02-07 16:02:19 +00:00
bjorn3
382e4031c2 Remove Linkage::Private
This is the same as Linkage::Internal except that it doesn't emit any
symbol. Some backends may not support it and it isn't all that useful
anyway.
2025-02-07 16:02:19 +00:00
bors
534d79adf9 Auto merge of #136481 - jieyouxu:rollup-w0lnnqb, r=jieyouxu
Rollup of 8 pull requests

Successful merges:

 - #136356 (Docs for f16 and f128: correct a typo and add details)
 - #136404 (Remove a footgun-y feature / relic of the past from the compiletest DSL)
 - #136432 (LTA: Actually check where-clauses for well-formedness at the def site)
 - #136438 (miri: improve error when offset_from preconditions are violated)
 - #136441 ([`compiletest`-related cleanups 1/7] Cleanup `is_rustdoc` logic and remove a useless path join in rustdoc-json runtest logic)
 - #136455 (Remove some `Clone` bounds and derives.)
 - #136464 (Remove hook calling via `TyCtxtAt`.)
 - #136467 (override default config profile on tarballs)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-03 16:42:25 +00:00
许杰友 Jieyou Xu (Joe)
5bd0f32378
Rollup merge of #136464 - nnethercote:rm-TyCtxtAt-for-hooks, r=oli-obk
Remove hook calling via `TyCtxtAt`.

All hooks receive a `TyCtxtAt` argument.

Currently hooks can be called through `TyCtxtAt` or `TyCtxt`. In the latter case, a `TyCtxtAt` is constructed with a dummy span and passed to the hook.

However, in practice hooks are never called through `TyCtxtAt`, and always receive a dummy span. (I confirmed this via code inspection, and double-checked it by temporarily making the `TyCtxtAt` code path panic and running all the tests.)

This commit removes all the `TyCtxtAt` machinery for hooks. All hooks now receive `TyCtxt` instead of `TyCtxtAt`. There are two existing hooks that use `TyCtxtAt::span`: `const_caller_location_provider` and `try_destructure_mir_constant_for_user_output`. For both hooks the span is always a dummy span, probably unintentionally. This dummy span use is now explicit. If a non-dummy span is needed for these two hooks it would be easy to add it as an extra argument because hooks are less constrained than queries.

r? `@oli-obk`
2025-02-03 19:13:29 +08:00
bors
a5db378dc1 Auto merge of #136413 - EnzymeAD:fix-autodiff-comptime-regression, r=oli-obk
fix autodiff compile time regression

Tries to fix the regression from https://github.com/rust-lang/rust/pull/133429

Tracking:

- https://github.com/rust-lang/rust/issues/124509
2025-02-03 11:10:56 +00:00
Nicholas Nethercote
e661514bda Remove hook calling via TyCtxtAt.
All hooks receive a `TyCtxtAt` argument.

Currently hooks can be called through `TyCtxtAt` or `TyCtxt`. In the
latter case, a `TyCtxtAt` is constructed with a dummy span and passed to
the hook.

However, in practice hooks are never called through `TyCtxtAt`, and
always receive a dummy span. (I confirmed this via code inspection, and
double-checked it by temporarily making the `TyCtxtAt` code path panic
and running all the tests.)

This commit removes all the `TyCtxtAt` machinery for hooks. All hooks
now receive `TyCtxt` instead of `TyCtxtAt`. There are two existing hooks
that use `TyCtxtAt::span`: `const_caller_location_provider` and
`try_destructure_mir_constant_for_user_output`. For both hooks the span
is always a dummy span, probably unintentionally. This dummy span use is
now explicit. If a non-dummy span is needed for these two hooks it would
be easy to add it as an extra argument because hooks are less
constrained than queries.
2025-02-03 17:02:33 +11:00