Commit graph

45175 commits

Author SHA1 Message Date
bors
a2e63569fd Auto merge of #138824 - Zoxc:dep-graph-no-prev-map, r=oli-obk
Remove `prev_index_to_index` field from `CurrentDepGraph`

The dep graph currently has 2 ways to map a previous index into a current index. The `prev_index_to_index` map stores the current index equivalent of a previous index. For indices which are marked green, we also store the same information in the `DepNodeColorMap`. We actually only need to known the mapping for green nodes however, so this PR removes `prev_index_to_index` and instead makes use of the `DepNodeColorMap`.

To avoid racing when promoting a node from the previous session, the encoder lock is now used to ensure only one thread encodes the promoted node. This was previously done by the lock in `prev_index_to_index`.

This also changes `nodes_newly_allocated_in_current_session` used to detect duplicate dep nodes to contain both new and previous nodes, which is simpler and can better catch duplicates.

The dep node index encoding used in `DepNodeColorMap` is tweak to avoid subtraction / addition to optimize accessing the current equivalent of a previous index.

r? `@oli-obk`
2025-03-26 17:36:52 +00:00
bors
19cab6b878 Auto merge of #130324 - petrochenkov:ctxtache, r=oli-obk
hygiene: Ensure uniqueness of `SyntaxContextData`s

`SyntaxContextData`s are basically interned with `SyntaxContext`s working as indices, so they are supposed to be unique.
However, currently duplicate `SyntaxContextData`s can be created during decoding from metadata or incremental cache.
This PR fixes that.

cc https://github.com/rust-lang/rust/pull/129827#discussion_r1759074553
2025-03-26 14:11:48 +00:00
bors
f1bc669636 Auto merge of #138974 - Zalathar:rollup-568cpmy, r=Zalathar
Rollup of 7 pull requests

Successful merges:

 - #138483 (Target modifiers fix for bool flags without value)
 - #138818 (Don't produce debug information for compiler-introduced-vars when desugaring assignments.)
 - #138898 (Mostly parser: Eliminate code that's been dead / semi-dead since the removal of type ascription syntax)
 - #138930 (Add bootstrap step diff to CI job analysis)
 - #138954 (Ensure `define_opaque` attrs are accounted for in HIR hash)
 - #138959 (Revert "Make MatchPairTree::place non-optional")
 - #138967 (Fix typo in error message)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-26 11:03:12 +00:00
Stuart Cook
33c90235a1
Rollup merge of #138959 - meithecatte:matchpair-place-option, r=Zalathar
Revert "Make MatchPairTree::place non-optional"

Reverts a part of #137875. Fixes #138958.

cc `@Zalathar`
2025-03-26 19:40:31 +11:00
Stuart Cook
19a53b7d3f
Rollup merge of #138954 - compiler-errors:hash-opaques, r=oli-obk
Ensure `define_opaque` attrs are accounted for in HIR hash

Fixes #138948

r? oli-obk
2025-03-26 19:40:30 +11:00
Stuart Cook
30344f7fa3
Rollup merge of #138898 - fmease:decrustify-parser-post-ty-ascr, r=compiler-errors
Mostly parser: Eliminate code that's been dead / semi-dead since the removal of type ascription syntax

**Disclaimer**: This PR is intended to mostly clean up code as opposed to bringing about behavioral changes. Therefore it doesn't aim to address any of the 'FIXME: remove after a month [dated: 2023-05-02]: "type ascription syntax has been removed, see issue [#]101728"'.

---

By commit:

1. Removes truly dead code:
   * Since 1.71 (#109128) `let _ = { f: x };` is a syntax error as opposed to a semantic error which allows the parse-time diagnostic (suggestion) "*struct literal body without path // you might have forgotten […]*" to kick in.
   * The analysis-time diagnostic (suggestion) from <=1.70 "*cannot find value \`f\` in this scope // you might have forgotten […]*" is therefore no longer reachable.
2. Updates `is_certainly_not_a_block` to be in line with the current grammar:
   * The seq. `{ ident:` is definitely not the start of a block. Before the removal of ty ascr, `{ ident: ty_start` would begin a block expr.
   * This shouldn't make more code compile IINM, it should *ultimately* only affect diagnostics.
   * For example, `if T { f: () } {}` will now be interpreted as an `if` with struct lit `T { f: () }` as its *condition* (which is banned in the parser anyway) as opposed to just `T` (with the *consequent* being `f : ()` which is also invalid (since 1.71)). The diagnostics are almost the same because we have two separate parse recovery procedures + diagnostics: `StructLiteralNeedingParens` (*invalid struct lit*) before and `StructLiteralNotAllowedHere` (*struct lits aren't allowed here*) now, as you can see from the diff.
   * (As an aside, even before this PR, fn `maybe_suggest_struct_literal` should've just used the much older & clearer `StructLiteralNotAllowedHere`)
   * NB: This does sadly regress the compiler output for `tests/ui/parser/type-ascription-in-pattern.rs` but that can be fixed in follow-up PRs. It's not super important IMO and a natural consequence.
3. Removes code that's become dead due to the prior commit.
   * Basically reverts #106620 + #112475 (without regressing rustc's output!).
   * Now the older & more robust parse recovery procedure (cc `StructLiteralNotAllowedHere`) takes care of the cases the removed code used to handle.
   * This automatically fixes the suggestions for \[[playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=7e2030163b11ee96d17adc3325b01780)\]:
     * `if Ty::<i32> { f: K }.m() {}`: `if Ty::<i32> { SomeStruct { f: K } }.m() {}` (broken) → ` if (Ty::<i32> { f: K }).m() {}`
     * `if <T as Trait>::Out { f: K::<> }.m() {}`: `if <T as Trait>(::Out { f: K::<> }).m() {}` (broken) → `if (<T as Trait>::Out { f: K::<> }).m() {}`
4. Merge and simplify UI tests pertaining to this issue, so it's easier to add more regression tests like for the two cases mentioned above.
5. Merge UI tests and add the two regression tests.

Best reviewed commit by commit (on request I'll partially squash after approval).
2025-03-26 19:40:28 +11:00
Stuart Cook
ff325e0a00
Rollup merge of #138818 - khuey:138198, r=jieyouxu
Don't produce debug information for compiler-introduced-vars when desugaring assignments.

An assignment such as

(a, b) = (b, c);

desugars to the HIR

{ let (lhs, lhs) = (b, c); a = lhs; b = lhs; };

The repeated `lhs` leads to multiple Locals assigned to the same DILocalVariable. Rather than attempting to fix that, get rid of the debug info for these bindings that don't even exist in the program to begin with.

Fixes #138198

r? `@jieyouxu`
2025-03-26 19:40:28 +11:00
Stuart Cook
7eb27a9cf9
Rollup merge of #138483 - azhogin:azhogin/target-modifiers-bool-fix, r=fee1-dead
Target modifiers fix for bool flags without value

Fixed support of boolean flags without values: `-Zbool-flag` is now consistent with `-Zbool-flag=true` in another crate.

When flag is explicitly set to default value, target modifier will not be set in crate metainfo (`-Zflag=false` when `false` is a default value for the flag).

Improved error notification when target modifier flag is absent in a crate ("-Zflag unset").
Example:
```
note: `-Zreg-struct-return=true` in this crate is incompatible with unset `-Zreg-struct-return` in dependency `default_reg_struct_return`
```
2025-03-26 19:40:27 +11:00
bors
65899c06f1 Auto merge of #138893 - klensy:thorin-0.9, r=Mark-Simulacrum
bump thorin to 0.9 to drop duped deps

Bumps `thorin`, removing duped deps.

This also changes features for hashbrown:
```
hashbrown v0.15.2
`-- indexmap v2.7.0
    |-- object v0.36.7
    |-- wasmparser v0.219.1
    |-- wasmparser v0.223.0
    `-- wit-component v0.223.0
    |-- indexmap feature "default"
    |-- indexmap feature "serde"
    `-- indexmap feature "std"
|-- hashbrown feature "default-hasher"
|   |-- object v0.36.7 (*)
|   `-- wasmparser v0.223.0 (*)
|-- hashbrown feature "nightly"
|   |-- rustc_data_structures v0.0.0
|   `-- rustc_query_system v0.0.0
`-- hashbrown feature "serde"
    `-- wasmparser feature "serde"
```
to
```
hashbrown v0.15.2
`-- indexmap v2.7.0
    |-- object v0.36.7
    |-- wasmparser v0.219.1
    |-- wasmparser v0.223.0
    `-- wit-component v0.223.0
    |-- indexmap feature "default"
    |-- indexmap feature "serde"
    `-- indexmap feature "std"
|-- hashbrown feature "allocator-api2"
|   `-- hashbrown feature "default"
|-- hashbrown feature "default" (*)
|-- hashbrown feature "default-hasher"
|   |-- object v0.36.7 (*)
|   `-- wasmparser v0.223.0 (*)
|   `-- hashbrown feature "default" (*)
|-- hashbrown feature "equivalent"
|   `-- hashbrown feature "default" (*)
|-- hashbrown feature "inline-more"
|   `-- hashbrown feature "default" (*)
|-- hashbrown feature "nightly"
|   |-- rustc_data_structures v0.0.0
|   `-- rustc_query_system v0.0.0
|-- hashbrown feature "raw-entry"
|   `-- hashbrown feature "default" (*)
`-- hashbrown feature "serde"
    `-- wasmparser feature "serde"
```

To be safe, as this can be perf-sensitive:
`@bors` rollup=never
2025-03-26 07:54:26 +00:00
bors
6e8abb5ec6 Auto merge of #138956 - jhpratt:rollup-6g7ppwd, r=jhpratt
Rollup of 11 pull requests

Successful merges:

 - #138128 (Stabilize `#![feature(precise_capturing_in_traits)]`)
 - #138834 (Group test diffs by stage in post-merge analysis)
 - #138867 (linker: Fix staticlib naming for UEFI)
 - #138874 (Batch mark waiters as unblocked when resuming in the deadlock handler)
 - #138875 (Trusty: Fix build for anonymous pipes and std::sys::process)
 - #138877 (Ignore doctests only in specified targets)
 - #138885 (Fix ui pattern_types test for big-endian platforms)
 - #138905 (Add target maintainer information for powerpc64-unknown-linux-musl)
 - #138911 (Allow defining opaques in statics and consts)
 - #138917 (rustdoc: remove useless `Symbol::is_empty` checks.)
 - #138945 (Override PartialOrd methods for bool)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-26 03:21:26 +00:00
Maja Kądziołka
c8a5b3677b
MatchPairTree: update invariant comment 2025-03-26 02:18:13 +01:00
Maja Kądziołka
0c162b19ec
Revert "Make MatchPairTree::place non-optional"
This reverts commit e3e74bc89a.

The comment that was used to justify the change was outdated.
2025-03-26 02:09:13 +01:00
Jacob Pratt
5bd69d940e
Rollup merge of #138911 - compiler-errors:define-opaque, r=oli-obk
Allow defining opaques in statics and consts

r? oli-obk

Fixes https://github.com/rust-lang/rust/issues/138902
2025-03-25 20:34:49 -04:00
Jacob Pratt
8b61871eda
Rollup merge of #138874 - Zoxc:waiter-race, r=SparrowLii,davidtwco
Batch mark waiters as unblocked when resuming in the deadlock handler

This fixes a race when resuming multiple threads to resolve query cycles. This now marks all threads as unblocked before resuming  any of them. Previously if one was resumed and marked as unblocked at a time. The first thread resumed could fall asleep then Rayon would detect a second false deadlock. Later the initial deadlock handler thread would resume further threads.

This also reverts the workaround added in https://github.com/rust-lang/rust/pull/137731.

cc `@SparrowLii` `@lqd`
2025-03-25 20:34:46 -04:00
Jacob Pratt
a883b23ef5
Rollup merge of #138867 - petrochenkov:linkfix, r=nnethercote
linker: Fix staticlib naming for UEFI

And one minor refactoring in the second commit.
2025-03-25 20:34:46 -04:00
Jacob Pratt
1c84c063f0
Rollup merge of #138128 - compiler-errors:precise-capturing-in-traits, r=oli-obk,traviscross
Stabilize `#![feature(precise_capturing_in_traits)]`

# Precise capturing (`+ use<>` bounds) in traits - Stabilization Report

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

## Stabilization summary

This report proposes the stabilization of `use<>` precise capturing bounds in return-position impl traits in traits (RPITITs). This completes a missing part of [RFC 3617 "Precise capturing"].

Precise capturing in traits was not ready for stabilization when the first subset was proposed for stabilization (namely, RPITs on free and inherent functions - https://github.com/rust-lang/rust/pull/127672) since this feature has a slightly different implementation, and it hadn't yet been implemented or tested at the time. It is now complete, and the type system implications of this stabilization are detailed below.

## Motivation

Currently, RPITITs capture all in-scope lifetimes, according to the decision made in the ["lifetime capture rules 2024" RFC](https://rust-lang.github.io/rfcs/3498-lifetime-capture-rules-2024.html#return-position-impl-trait-in-trait-rpitit). However, traits can be designed such that some lifetimes in arguments may not want to be captured. There is currently no way to express this.

## Major design decisions since the RFC

No major decisions were made. This is simply an extension to the RFC that was understood as a follow-up from the original stabilization.

## What is stabilized?

Users may write `+ use<'a, T>` bounds on their RPITITs. This conceptually modifies the desugaring of the RPITIT to omit the lifetimes that we would copy over from the method. For example,

```rust
trait Foo {
    fn method<'a>(&'a self) -> impl Sized;

    // ... desugars to something like:
    type RPITIT_1<'a>: Sized;
    fn method_desugared<'a>(&'a self) -> Self::RPITIT_1<'a>;

    // ... whereas with precise capturing ...
    fn precise<'a>(&'a self) -> impl Sized + use<Self>;

    // ... desugars to something like:
    type RPITIT_2: Sized;
    fn precise_desugared<'a>(&'a self) -> Self::RPITIT_2;
}
```

And thus the GAT doesn't name `'a`. In the compiler internals, it's not implemented exactly like this, but not in a way that users should expect to be able to observe.

#### Limitations on what generics must be captured

Currently, we require that all generics from the trait (including the `Self`) type are captured. This is because the generics from the trait are required to be *invariant* in order to do associated type normalization.

And like regular precise capturing bounds, all type and const generics in scope must be captured.

Thus, only the in-scope method lifetimes may be relaxed with this syntax today.

## What isn't stabilized? (a.k.a. potential future work)

See section above. Relaxing the requirement to capture all type and const generics in scope may be relaxed when https://github.com/rust-lang/rust/issues/130043 is implemented, however it currently interacts with some underexplored corners of the type system (e.g. unconstrained type bivariance) so I don't expect it to come soon after.

## Implementation summary

This functionality is implemented analogously to the way that *opaque type* precise capturing works.

Namely, we currently use *variance* to model the capturedness of lifetimes. However, since RPITITs are anonymous GATs instead of opaque types, we instead modify the type relation of GATs to consider variances for RPITITs (along with opaque types which it has done since https://github.com/rust-lang/rust/pull/103491).

30f168ef81/compiler/rustc_middle/src/ty/util.rs (L954-L976)

30f168ef81/compiler/rustc_type_ir/src/relate.rs (L240-L244)

Using variance to model capturedness is an implementation detail, and in the future it would be desirable if opaques and RPITITs simply did not include the uncaptured lifetimes in their generics. This can be changed in a forwards-compatible way, and almost certainly would not be observable by users (at least not negatively, since it may indeed fix some bugs along the way).

## Tests

* Test that the lifetime isn't actually captured: `tests/ui/impl-trait/precise-capturing/rpitit.rs` and `tests/ui/impl-trait/precise-capturing/rpitit-outlives.rs` and `tests/ui/impl-trait/precise-capturing/rpitit-outlives-2.rs`.
* Technical test for variance computation: `tests/ui/impl-trait/in-trait/variance.rs`.
* Test that you must capture all trait generics: `tests/ui/impl-trait/precise-capturing/forgot-to-capture-type.rs`.
* Test that you cannot capture more than what the trait specifies: `tests/ui/impl-trait/precise-capturing/rpitit-captures-more-method-lifetimes.rs` and `tests/ui/impl-trait/precise-capturing/rpitit-impl-captures-too-much.rs`.
* Undercapturing (refinement) lint: `tests/ui/impl-trait/in-trait/refine-captures.rs`.

### What other unstable features may be exposed by this feature?

I don't believe that this exposes any new unstable features indirectly.

## Remaining bugs and open issues

Not aware of any open issues or bugs.

## Tooling support

Rustfmt:  Supports formatting `+ use<>` everywhere.

Clippy:  No support needed, unless specific clippy lints are impl'd to care for precise capturing itself.

Rustdoc:  Rendering `+ use<>` precise capturing bounds is supported.

Rust-analyzer:  Parser support, and then lifetime support isn't needed https://github.com/rust-lang/rust/pull/138128#issuecomment-2705292494 (previous: ~~ There is parser support, but I am unsure of rust-analyzer's level of support for RPITITs in general.~~)

## History

Tracking issue: https://github.com/rust-lang/rust/issues/130044

* https://github.com/rust-lang/rust/pull/131033
* https://github.com/rust-lang/rust/pull/132795
* https://github.com/rust-lang/rust/pull/136554
2025-03-25 20:34:45 -04:00
Michael Goulet
4b22ac5296 Ensure define_opaque is accounted for in HIR hash 2025-03-26 00:15:34 +00:00
bors
068609ce76 Auto merge of #138601 - RalfJung:wasm-abi-fcw, r=alexcrichton
add FCW to warn about wasm ABI transition

See https://github.com/rust-lang/rust/issues/122532 for context: the "C" ABI on wasm32-unk-unk will change. The goal of this lint is to warn about any function definition and calls whose behavior will be affected by the change. My understanding is the following:
- scalar arguments are fine
  - including 128 bit types, they get passed as two `i64` arguments in both ABIs
- `repr(C)` structs (recursively) wrapping a single scalar argument are fine (unless they have extra padding due to over-alignment attributes)
- all return values are fine

`@bjorn3` `@alexcrichton` `@Manishearth` is that correct?

I am making this a "show up in future compat reports" lint to maximize the chances people become aware of this. OTOH this likely means warnings for most users of Diplomat so maybe we shouldn't do this?

IIUC, wasm-bindgen should be unaffected by this lint as they only pass scalar types as arguments.

Tracking issue: https://github.com/rust-lang/rust/issues/138762
Transition plan blog post: https://github.com/rust-lang/blog.rust-lang.org/pull/1531

try-job: dist-various-2
2025-03-26 00:06:46 +00:00
Matthias Krüger
1107fc7ad2
Rollup merge of #138929 - oli-obk:assoc-ctxt-of-trait, r=compiler-errors
Visitors track whether an assoc item is in a trait impl or an inherent impl

`AssocCtxt::Impl` now contains an `of_trait` field. This allows ast lowering and nameres to not have to track whether we're in a trait impl or an inherent impl.
2025-03-25 18:09:07 +01:00
Matthias Krüger
ffc571797b
Rollup merge of #138924 - nnethercote:less-kw-Empty-3, r=compiler-errors
Reduce `kw::Empty` usage, part 3

Remove some more `kw::Empty` uses, in support of #137978.

r? `@davidtwco`
2025-03-25 18:09:07 +01:00
Matthias Krüger
946192b25a
Rollup merge of #138886 - samueltardieu:push-xxkzmupznoky, r=jieyouxu
Fix autofix for `self` and `self as …` in `unused_imports` lint

This fixes two problems with the autofixes for the `unused_imports` lint:

- `use std::collections::{HashMap, self as coll};` would suggest, when `HashMap` is unused, the incorrect `use std::collections::self as coll;` which does not compile.
- `use std::borrow::{self, Cow};` would suggest, when `self` is unused, `use std::borrow::{Cow};`, which contains unnecessary brackets.

The first problem was reported in rust-lang/rust-clippy#14450, the second found while fixing the first one.

Fix #133750
(thanks to `@richardsamuels` for spotting the duplicate)
2025-03-25 18:09:06 +01:00
Matthias Krüger
91b98d6511
Rollup merge of #138776 - Zalathar:unexpand, r=oli-obk
coverage: Separate span-extraction from unexpansion

Historically, coverage instrumentation has relied on eagerly “unexpanding” MIR spans back to ancestor spans that have the same context as the function body, and lie within that body. Doing so makes several subsequent operations more straightforward.

In order to support expansion regions, we need to stop doing that, and handle layers of macro-expansion more explicitly. This PR takes a step in that direction, by deferring some of the unexpansion steps, and concentrating them in one place (`spans::extract_refined_covspans`).

Unexpansion still takes place as before, but these changes will make it easier to experiment with expansion-aware coverage instrumentation.
2025-03-25 18:09:05 +01:00
Matthias Krüger
43297ffc22
Rollup merge of #138581 - Zoxc:abort-handler-if-locked, r=SparrowLii
Abort in deadlock handler if we fail to get a query map

Resolving query cycles requires the complete active query map, or it may miss query cycles. We did not check that the map is completely constructed before. If there is some error collecting the map, something has gone wrong already. This adds a check to abort/panic if we fail to construct the complete map.

This can help differentiate errors from the `deadlock detected` case if constructing query map has errors in practice.

An `Option` is not used for `collect_active_jobs` as the panic handler can still make use of a partial map.
2025-03-25 18:09:05 +01:00
Matthias Krüger
81e227583a
Rollup merge of #138317 - petrochenkov:libsearch3, r=compiler-errors
privacy: Visit types and traits in impls in type privacy lints

With one exception to avoid false positives.

Fixes the same issue as https://github.com/rust-lang/rust/pull/134176.
2025-03-25 18:09:04 +01:00
Matthias Krüger
b66e9320c5
Rollup merge of #137247 - dpaoliello:cleanllvm, r=Zalathar
cg_llvm: Reduce the visibility of types, modules and using declarations in `rustc_codegen_llvm`.

Final part of #135502

Reduces the visibility of types, modules and using declarations in the `rustc_codegen_llvm` to private or `pub(crate)` where possible, and marks unused fields and enum entries with `#[expect(dead_code)]`.

r? Zalathar
2025-03-25 18:09:03 +01:00
Michael Goulet
0827f76586 Test define opaques in extern items 2025-03-25 16:44:59 +00:00
Michael Goulet
f8df298d74 Allow defining opaques in statics and consts 2025-03-25 16:44:59 +00:00
Michael Goulet
2bf0c2df14 Make printing define_opaque less goofy 2025-03-25 16:44:59 +00:00
León Orell Valerian Liehr
9f336ce2eb
Remove now unreachable parse recovery code
StructLiteralNeedingParens is no longer reachable always giving
precedence to StructLiteralNotAllowedHere.

As an aside: The former error struct shouldn't've existed in the
first place. We should've just used the latter in this branch.
2025-03-25 15:15:41 +01:00
León Orell Valerian Liehr
82796dd858
Brace-ident-colon can certainly no longer start a block
thanks to the removal of type ascription.
2025-03-25 15:15:21 +01:00
bors
48994b1674 Auto merge of #138923 - TaKO8Ki:rollup-f3hkmqj, r=TaKO8Ki
Rollup of 9 pull requests

Successful merges:

 - #138385 (Keyword tweaks)
 - #138580 (resolve: Avoid some unstable iteration 2)
 - #138652 (Reintroduce remote-test support in run-make tests)
 - #138701 (Make default_codegen_backend serializable)
 - #138755 ([rustdoc] Remove duplicated loop when computing doc cfgs)
 - #138829 (Slightly reword triagebot ping message for `relnotes-interest-group`)
 - #138837 (resolve: Avoid remaining unstable iteration)
 - #138838 (Fix/tweak some tests in new solver)
 - #138895 (Add a helper for building an owner id in ast lowering)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-25 13:29:50 +00:00
Oli Scherer
59e3380744 Avoid some more global state 2025-03-25 10:33:25 +00:00
Ralf Jung
e88c49c454 acquire more accurate HirId for ABI check lints 2025-03-25 11:30:57 +01:00
Oli Scherer
7cdc456727 Track whether an assoc item is in a trait impl or an inherent impl 2025-03-25 10:12:07 +00:00
Oli Scherer
502d57cb78 Deduplicate assoc item cfg handling 2025-03-25 10:11:56 +00:00
Vadim Petrochenkov
f756304655 privacy: Visit types and traits in impls in type privacy lints 2025-03-25 12:40:02 +03: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
Nicholas Nethercote
501945a22e Use sym::dummy for a dummy arg in parse_fn_params. 2025-03-25 18:00:14 +11:00
bors
7d49ae9731 Auto merge of #136410 - saethlin:clean-up-cgu-internal-copy, r=compiler-errors
Remove InstanceKind::generates_cgu_internal_copy

This PR should not contain any behavior changes. Before this PR, the logic for selecting instantiation mode is spread across all of
* `instantiation_mode`
* `cross_crate_inlinable`
* `generates_cgu_internal_copy`
* `requires_inline`

The last two of those functions are not well-designed. The function that actually decides if we generate a CGU-internal copy is `instantiation_mode`, _not_ `generates_cgu_internal_copy`. The function `requires_inline` documents that it is about the LLVM `inline` attribute and that it is a hint. The LLVM attribute is called `inlinehint`, this function is also used by other codegen backends, and since it is part of instantiation mode selection it is *not* a hint.

The goal of this PR is to start cleaning up the logic into a sequence of checks that have a more logical flow and are easier to customize in the future (to do things like improve incrementality or improve optimizations without causing obscure linker errors because you forgot to update another part of the compiler).
2025-03-25 06:36:41 +00:00
Takayuki Maeda
3757104071
Rollup merge of #138895 - oli-obk:dedup-owner-id-creation, r=compiler-errors
Add a helper for building an owner id in ast lowering

Just some deduplication of owner-id creations. Will also help me later split up ast lowering into per-owner queries, as it won't be possible anymore to go from a NodeId to a DefId of an owner without doing extra work to check whether we have an owner id. So I'd just do that in the new `owner_id` function and keep the `local_def_id` function free of that logic
2025-03-25 15:36:36 +09:00
Takayuki Maeda
b2629be2de
Rollup merge of #138838 - compiler-errors:new-solver-crashes-tweaks, r=lcnr
Fix/tweak some tests in new solver

Bunch of miscellaneous new solver tweaks that I found from the failing tests. Can split these out, but they all seemed small enough to not warrant separate PRs.

r? lcnr
2025-03-25 15:36:35 +09:00
Takayuki Maeda
117b3fdbb8
Rollup merge of #138837 - petrochenkov:resinstab2, r=jieyouxu
resolve: Avoid remaining unstable iteration

Continuation of #138580.
This should be the performance sensitive part.
2025-03-25 15:36:35 +09:00
Takayuki Maeda
e9a528c9b5
Rollup merge of #138701 - tvladyslav:serializable_default_codegen_backend, r=workingjubilee
Make default_codegen_backend serializable

This PR makes default_codegen_backend serializable.
2025-03-25 15:36:33 +09:00
Takayuki Maeda
922cc7555f
Rollup merge of #138580 - petrochenkov:resinstab, r=Nadrieril
resolve: Avoid some unstable iteration 2

Continuation of https://github.com/rust-lang/rust/pull/138502.
2025-03-25 15:36:32 +09:00
Takayuki Maeda
8020558507
Rollup merge of #138385 - nnethercote:keyword-tweaks, r=Noratrieb
Keyword tweaks

r? ```@Noratrieb```
2025-03-25 15:36:31 +09:00
Nicholas Nethercote
867da30cc7 Avoid kw::Empty when dealing with rustc_allowed_through_unstable_modules.
The existing code produces `Some(kw::Empty)` for these invalid forms:

- a non-name-value, e.g. `#[rustc_allowed_through_unstable_modules]`

- a non-string arg, e.g. `#[rustc_allowed_through_unstable_modules = 3]`

The new code avoids the `kw::Empty` and is a little shorter. It will
produce `None` in those cases, which means E0789 won't be produced if
the `stable` attribute is missing for these invalid forms. This doesn't
matter, because these invalid forms will trigger an "malformed
`rustc_allowed_through_unstable_modules` attribute" anyway.
2025-03-25 16:48:03 +11:00
Daniel Paoliello
79b9664091 Reduce visibility of most items in rustc_codegen_llvm 2025-03-25 16:36:47 +11:00
Nicholas Nethercote
e576d8850d Use Option<Symbol> in DuplicateLangItem.
For the the symbols that might not be present, instead of `kw::Empty`.
2025-03-25 16:20:43 +11:00
Nicholas Nethercote
3f32a321bc Use Option<Symbol> in ModuleKind::Def.
This way, `None` represents "crate root without a name" instead of
`kw::Empty`. This changes makes it impossible to forget to handle the
exceptional case.
2025-03-25 16:14:27 +11:00