Commit Graph

169526 Commits

Author SHA1 Message Date
Chayim Refael Friedman fc1cb48d3b Fix tests that relied on the default variance to be invariant
And now it changed to bivariant.
2025-12-27 20:06:24 +02:00
Chayim Refael Friedman a9da655c9b Bring back fixpoint iteration for variance 2025-12-27 19:57:42 +02:00
Lukas Wirth 31b0cb9484 Merge pull request #21341 from Veykril/veykril/push-wsrtvrkzqyvr
internal: Move library and local root inputs to base-db
2025-12-27 10:24:52 +00:00
Lukas Wirth 61203a098e internal: Move library and local root inputs to base-db 2025-12-27 11:16:17 +01:00
Lukas Wirth e90e264290 Merge pull request #20741 from A4-Tacks/comp-macro-segment
feat: Add macro segment completion
2025-12-27 10:02:35 +00:00
A4-Tacks 06a6a00895 Minor fixup 2025-12-27 17:28:22 +08:00
bit-aloo 720d9eecc7 remove crossbeam-channel from proc-macro-srv-cli 2025-12-27 10:40:42 +05:30
bit-aloo 38f1cccef2 make source_text take non mutable reference of self 2025-12-27 09:43:01 +05:30
bit-aloo 8ae38dc333 rename handler's to be context specific 2025-12-27 09:21:32 +05:30
bit-aloo 231690657e add bidirectional handle in proc-macro-srv-cli to interact with client and srv 2025-12-27 09:07:08 +05:30
A4-Tacks 22fbbd4306 Add macro segment completion
Example
---
```rust
macro_rules! foo {
    ($($x:$0)*) => ();
}
```

**Completion items**:

```text
ba block
ba expr
ba expr_2021
ba ident
ba item
ba lifetime
ba literal
ba meta
ba pat
ba pat_param
ba path
ba stmt
ba tt
ba ty
ba vis
```
2025-12-27 05:04:18 +08:00
bit-aloo 8aa859476c adapt source_text to new handler 2025-12-26 23:04:19 +05:30
bit-aloo 8f141eaab3 remove old subreq/resp constructs 2025-12-26 23:04:04 +05:30
bit-aloo abf22599e3 add bidirectionalHandler trait 2025-12-26 23:03:42 +05:30
Lukas Wirth 50ed4e91fc Merge pull request #21200 from ChayimFriedman2/fake-impls
perf: Do not really expand builtin derives, instead treat them specifically
2025-12-26 13:31:48 +00:00
Chayim Refael Friedman 02763ff0ec Test builtin derives expansions
Via a hack to disable their fast path.
2025-12-26 15:00:27 +02:00
Chayim Refael Friedman 04529b2e83 Allow IDE layer to "see" fake builtin derive impls
It sees them as regular impls; the details are abstracted. It's beautiful for the IDE layer, and less beautiful for `hir`, so this is a big change.

Some small differences still exist:

 - We show builtin derives impl (to the IDE layer) as if they have had no generic parameters. It is possible to show the parameters, but that means also having to handle fake impls in `TypeParam` etc., and the benefit is questionable.
 - Getting the fn *def* type of a method of a builtin derive impl is not supported, as there is no real `FunctionId`, therefore no `CallableDefId`. The trait method is returned instead. Note: getting the fn *ptr* type of the method is supported well.
 - Builtin derive impls and their methods do not fully support `HasSource`, because, well, they have no source (at least, not in the form of `ast::Impl` and `ast::Fn`). To support them, we use the derive's `TextRange` where possible, and the trait method's source when not.

 It's important to note that the def map still records the `MacroCallId`. I have doubts over this, as this means it's very easy to create the queries we don't want to create, but it does make things more convenient. In particular, a nicety of this setup is that even "Expand macro recursively" works (it creates the macro input/output query, but given that they will only be created when the user invokes the command, that does not seem to be a problem).
2025-12-26 15:00:08 +02:00
Lukas Wirth abefb5254a Merge pull request #20193 from ChayimFriedman2/setting-rename-conflict
feat: Provide a setting to disable showing rename conflicts
2025-12-26 09:08:49 +00:00
Lukas Wirth 9fcf441721 Merge pull request #21297 from osdyne/fix-lsp-configuration-request
fix: Fix LSP configuration request handling
2025-12-26 09:05:09 +00:00
Lukas Wirth 4665de582c Merge pull request #21330 from A4-Tacks/to-guarded-indent
Fix indent for convert_to_guarded_return
2025-12-26 09:02:22 +00:00
Lukas Wirth 856cc543a3 Merge pull request #21335 from ChayimFriedman2/tupled-closure
internal: Store closures with "tupled" inputs
2025-12-26 08:18:20 +00:00
Lukas Wirth 2986b2714e Merge pull request #21249 from Shourya742/2025-11-27-bidirectional-protocol
Add bidirectional messaging proc-macro-srv
2025-12-26 08:08:24 +00:00
Chayim Refael Friedman 2f3a23c7e9 Stabilize type mismatch diagnostic 🎉 2025-12-26 09:35:55 +02:00
Chayim Refael Friedman ebb0d0b7bd Make builtin derives cheaper, by not really expanding them, instead store them unexpanded 2025-12-25 16:26:11 +02:00
Chayim Refael Friedman 2c7bd6d462 Store closures with "tupled" inputs
And remove it when needed, the opposite of what was previously, where we stored without a tuple and tupled for the solver (because it requires that).

Because this is what rustc does, and generally, the closer we follow rustc, the easier our lives become.

The weird name `signature_unclosure()` also comes from rustc.
2025-12-25 16:18:11 +02:00
Lukas Wirth 38ff5a7a5e Introduce cargo-machete ci step 2025-12-25 10:38:05 +01:00
The rustc-josh-sync Cronjob Bot a1ae5afd66 Merge ref 'e7d44143a12a' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: e7d44143a1
Filtered ref: fe2cf3fa56a4ce08f56aee660fbe289c7d13dede
Upstream diff: https://github.com/rust-lang/rust/compare/f41f40408d719aa9ae0c6bfa17619d8f3f9e5b99...e7d44143a12a526488e4f0c0d7ea8e62a4fe9354

This merge was created using https://github.com/rust-lang/josh-sync.
2025-12-25 04:19:28 +00:00
The rustc-josh-sync Cronjob Bot faac1b517f Prepare for merging from rust-lang/rust
This updates the rust-version file to e7d44143a1.
2025-12-25 04:19:22 +00:00
A4-Tacks 5c99ebf42c Fix indent for convert_to_guarded_return 2025-12-24 21:46:57 +08:00
bors efa32de15b Auto merge of #150283 - Urgau:remap-debuginfo-absolute, r=jieyouxu
Remap both absolute and relative paths when building `rustc` and `std`

Turns out [#150110](https://github.com/rust-lang/rust/issues/150110) didn't work as expected, because when the standard library sources are present, we [helpfully un-remap the paths](https://github.com/rust-lang/rust/blob/e951f470d76febcc6f0a5b409c509eb77450a336/compiler/rustc_metadata/src/rmeta/decoder.rs#L1656-L1702) to the local directory of the user, including when we are building the compiler and standard library it-self (duh!), and since those paths are absolute (not relative), our purely relative remapping didn't pick them up.

This behavior wasn't a issue before because the un-remap logic immediately tries to remap them again, and since we had the absolute remapping we would just remap them to the the same thing.

To fix that issue I've adjusted our remapping to remap both the absolute and relative paths when building `rustc` and `std`, as well as added a run-make to make sure we don't regress it again (with a new `needs-std-remap-debuginfo` directive).

r? `@jieyouxu`
2025-12-24 06:23:00 +00:00
bors 5a7ad8ee06 Auto merge of #150324 - matthiaskrgr:rollup-cl7wrqn, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#149800 (Fix ICE in normalization during closure capture analysis (rust-lang/rust#149746))
 - rust-lang/rust#150182 (Don't export upstream monomorphizations from compiler-builtins)
 - rust-lang/rust#150216 (Tidying up tests/ui/issues 15 tests [6/N])
 - rust-lang/rust#150308 (Update bors configuration)
 - rust-lang/rust#150314 (rustc-dev-guide subtree update)
 - rust-lang/rust#150319 (use new term in description of --target)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-24 03:02:44 +00:00
Matthias Krüger 2237db5d27 Rollup merge of #150319 - tshepang:triple-is-tuple, r=Kivooeo
use new term in description of --target

this changes _triple_ to _tuple_ in `--target` description
2025-12-24 00:54:37 +01:00
Matthias Krüger 6348e9454c Rollup merge of #150314 - tshepang:rdg-sync, r=tshepang
rustc-dev-guide subtree update

Subtree update of `rustc-dev-guide` to https://github.com/rust-lang/rustc-dev-guide/commit/1127d2ac601b9bb00bb94181d1377b7585671709.

Created using https://github.com/rust-lang/josh-sync.

r? ``@ghost``
2025-12-24 00:54:37 +01:00
Matthias Krüger ebfdc44ceb Rollup merge of #150308 - Kobzol:bors-conf, r=marcoieni
Update bors configuration

Updates the configuration of bors to bring it up to speed with homu, in preparation for https://github.com/rust-lang/infra-team/issues/168. Mirrors configuration from homu's [configuration file](https://github.com/rust-lang/homu/blob/master/cfg.production.toml#L46).

This PR also enables reporting of merge conflicts, so that we can test this part of bors on `rust-lang/rust`. The merge conflict reports will be duplicated (until/unless we disable it in homu), but that hopefully shouldn't be such a big deal.

r? ``@marcoieni``
2025-12-24 00:54:36 +01:00
bors 8796b3b8b4 Auto merge of #149114 - BoxyUwU:mgca_adt_exprs, r=lcnr
MGCA: Support struct expressions without intermediary anon consts

r? oli-obk

tracking issue: rust-lang/rust#132980

Fixes rust-lang/rust#127972
Fixes rust-lang/rust#137888
Fixes rust-lang/rust#140275

due to delaying a bug instead of ICEing in HIR ty lowering.

### High level goal

Under `feature(min_generic_const_args)` this PR adds another kind of const argument. A struct/variant construction const arg kind. We represent the values of the fields as themselves being const arguments which allows for uses of generic parameters subject to the existing restrictions present in `min_generic_const_args`:
```rust
fn foo<const N: Option<u32>>() {}

trait Trait {
    #[type_const]
    const ASSOC: usize;
}

fn bar<T: Trait, const N: u32>() {
    // the initializer of `_0` is a `N` which is a legal const argument
    // so this is ok.
    foo::<{ Some::<u32> { 0: N } }>();

    // this is allowed as mgca supports uses of assoc consts in the
    // type system. ie `<T as Trait>::ASSOC` is a legal const argument
    foo::<{ Some::<u32> { 0: <T as Trait>::ASSOC } }>();

    // this on the other hand is not allowed as `N + 1` is not a legal
    // const argument
    foo::<{ Some::<u32> { 0: N + 1 } }>();
}
```

This PR does not support uses of const ctors, e.g. `None`. And also does not support tuple constructors, e.g. `Some(N)`. I believe that it would not be difficult to add support for such functionality after this PR lands so have left it out deliberately.

We currently require that all generic parameters on the type being constructed be explicitly specified. I haven't really looked into why that is but it doesn't seem desirable to me as it should be legal to write `Some { ... }` in a const argument inside of a body and have that desugar to `Some::<_> { ... }`. Regardless this can definitely be a follow-up PR and I assume this is some underlying consistency with the way that elided args are handled with type paths elsewhere.

This PRs implementation of supporting struct expressions is somewhat incomplete. We don't handle `Foo { ..expr }` at all and aren't handling privacy/stability. The printing of `ConstArgKind::Struct` HIR nodes doesn't really exist either :')

I've tried to keep the implementation here somewhat deliberately incomplete as I think a number of these issues are actually quite small and self contained after this PR lands and I'm hoping it could be a good set of issues to mentor newer contributors on 🤔 I just wanted the "bare minimum" required to actually demonstrate that the previous changes are "necessary".

### `ValTree` now recurse through `ty::Const`

In order to actually represent struct/variant construction in `ty::Const` without going through an anon const we would need to introduce some new `ConstKind` variant. Let's say some hypothetical `ConstKind::ADT(Ty<'tcx>, List<Const<'tcx>>)`.

This variant would represent things the same way that `ValTree` does with the first element representing the `VariantIdx` of the enum (if its an enum), and then followed by a list of field values in definition order.

This *could* work but there are a few reasons why it's suboptimal.

First it would mean we have a second kind of `Const` that can be normalized. Right now we only have `ConstKind::Unevaluated` which possibly needs normalization. Similarly with `TyKind` we *only* have `TyKind::Alias`. If we introduced `ConstKind::ADT` it would need to be normalized to a `ConstKind::Value` eventually. This feels to me like it has the potential to cause bugs in the long run where only `ConstKind::Unevaluated` is handled by some code paths.

Secondly it would make type equality/inference be kind of... weird... It's desirable for `Some { 0: ?x } eq Some { 0: 1_u32 }` to result in `?x=1_u32`.  I can't see a way for this to work with this `ConstKind::ADT` design under the current architecture for how we represent types/consts and generally do equality operations.

We would need to wholly special case these two variants in type equality and have a custom recursive walker separate from the existing architecture for doing type equality. It would also be somewhat unique in that it's a non-rigid `ty::Const` (it can be normalized more later on in type inference) while also having somewhat "structural" equality behaviour.

Lastly, it's worth noting that its not *actually* `ConstKind::ADT` that we want. It's desirable to extend this setup to also support tuples and arrays, or even references if we wind up supporting those in const generics. Therefore this isn't really `ConstKind::ADT` but a more general `ConstKind::ShallowValue` or something to that effect. It represents at least one "layer" of a types value :')

Instead of doing this implementation choice we instead change `ValTree::Branch`:
```rust
enum ValTree<'tcx> {
    Leaf(ScalarInt),
    // Before this PR:
    Branch(Box<[ValTree<'tcx>]>),
    // After this PR
    Branch(Box<[Const<'tcx>]>),
}
```

The representation for so called "shallow values" is now the same as the representation for the *entire* full value. The desired inference/type equality behaviour just falls right out of this. We also don't wind up with these shallow values actually being non-rigid. And `ValTree` *already* supports references/tuples/arrays so we can handle those just fine.

I think in the future it might be worth considering inlining `ValTree` into `ty::ConstKind`. E.g:
```rust
enum ConstKind {
    Scalar(Ty<'tcx>, ScalarInt),
    ShallowValue(Ty<'tcx>, List<Const<'tcx>>),
    Unevaluated(UnevaluatedConst<'tcx>),
    ...
}
```

This would imply that the usage of `ValTree`s in patterns would now be using `ty::Const` but they already kind of are anyway and I think that's probably okay in the long run. It also would mean that the set of things we *could* represent in const patterns is greater which may be desirable in the long run for supporting things such as const patterns of const generic parameters.

Regardless, this PR doesn't actually inline `ValTree` into `ty::ConstKind`, it only changes `Branch` to recurse through `Const`. This change could be split out of this PR if desired.

I'm not sure if there'll be a perf impact from this change. It's somewhat plausible as now all const pattern values that have nesting will be interning a lot more `Ty`s. We shall see :>

### Forbidding generic parameters under mgca

Under mgca we now allow all const arguments to resolve paths to generic parameters. We then *later* actually validate that the const arg should be allowed to access generic parameters if it did wind up resolving to any.

This winds up just being a lot simpler to implement than trying to make name resolution "keep track" of whether we're inside of a non-anon-const const arg and then encounter a `const { ... }` indicating we should now stop allowing resolving to generic parameters.

It's also somewhat in line with what we'll need for a `feature(generic_const_args)` where we'll want to decide whether an anon const should have any generic parameters based off syntactically whether any generic parameters were used. Though that design is entirely hypothetical at this point :)

### Followup Work

- Make HIR ty lowering check whether lowering generic parameters is supported and if not lower to an error type/const. Should make the code cleaner, fix some other bugs, and maybe(?) recover perf since we'll be accessing less queries which I think is part of the perf regression of this PR
- Make the ValTree setup less scuffed. We should find a new name for `ConstKind::Value` and the `Val` part of `ValTree` and `ty::Value` as they no longer correspond to a fully normalized structure. It may also be worth looking into inlining `ValTreeKind` into `ConstKind` or atleast into `ty::Value` or sth 🤔
- Support tuple constructors and const constructors not just struct expressions.
- Reduce code duplication between HIR ty lowering's handling of struct expressions, and HIR typeck's handling of struct expressions
- Try fix perf https://github.com/rust-lang/rust/pull/149114#issuecomment-3668038853. Maybe this will clear up once we clean up `ValTree` a bit and stop doing double interning and whatnot
2025-12-23 23:53:55 +00:00
Tshepang Mbambo e7965821e8 use new term in description of --target 2025-12-23 23:35:58 +02:00
Ada Alakbarova df2833d5d3 Fix typo in a URL 2025-12-23 21:20:11 +01:00
bit-aloo d6a2a52883 return error on combination of bidirectional message and json framing 2025-12-23 23:14:47 +05:30
Jakub Beránek bbf4ec3b0f Add support for automation/bors/auto merge branch 2025-12-23 15:47:03 +01:00
bors 99ff3fbb86 Auto merge of #149202 - ZuseZ4:automate-offload-clangs, r=oli-obk
automate offload, part 2 - clang calls

This automates steps 2+3 (the clang invocations) of the rust offload usage pipeline.
Now all that remains is a clang-linker-invocation after this step.

r? oli-obk
2025-12-23 14:37:46 +00:00
Boxy Uwu 79fd535473 Fix tools 2025-12-23 13:55:00 +00:00
Manuel Drehwald 8e1d80305f Update offloading docs to account for simplified usage 2025-12-23 05:20:11 -08:00
bit-aloo 184e06223f chore: remove unwanted comments, extra lines and putting cli srv on default 2025-12-23 18:30:47 +05:30
Lukas Wirth d0e14f1885 fix: Fix flycheck generations not being synced for multiple workspaces
The diagnostics collection globally tracks the generation for all loaded workspaces as its shared between them, yet the flycheck actors track their own separate generations per workspace.
This mismatch could cause flycheck to not work correctly when multiple workspaces were loaded.
2025-12-23 13:57:06 +01:00
Jonathan Brouwer c0337ca5f0 Rollup merge of #150205 - Enselic:line-no, r=Zalathar,jieyouxu
compiletest: Add `LineNumber` newtype to avoid `+1` magic here and there

Start small. If it works well we can increase usage bit by bit as time passes.

My main motivation for doing this is to get rid of the `+ 1` I otherwise have to add in https://github.com/rust-lang/rust/pull/150201 on this line:
```rs
                crate::directives::line::line_directive(file, zero_based_line_no + 1, &line)
```
But I think this is a nice general improvement by itself.

Note that we keep using "0" to represent "no specific line" because changing to `Option<LineNumber>` everywhere is a very noisy and significant change. That _can_ be changed later if wanted, but let's not do it now.
2025-12-23 12:01:01 +01:00
Martin Nordholts ffbb9a5932 compiletest: Add LineNumber newtype to avoid +1 magic here and there
Start small. If it works well we can increase usage bit by bit as time
passes.

Note that we keep using "0" to represent "no specific line" because
changing to `Option<LineNumber>` everywhere is much bigger and noisier
change. That can be done later if wanted.
2025-12-23 08:20:17 +01:00
bit-aloo cf02cff2cf remove channels with callbacks in proc-macro-srv 2025-12-23 11:59:56 +05:30
bit-aloo 6c525fa2d9 remove internal callbacks, and move callback to rust-analyzer level 2025-12-23 07:58:53 +05:30
bors a0c97e3255 Auto merge of #150217 - notriddle:stringdex-0.0.4, r=yotamofek,GuillaumeGomez
rustdoc: upgrade to stringdex 0.0.4

- code cleanup
- smaller encoding for runs
- fast path for the common encoding case
2025-12-22 23:19:14 +00:00
bors 4f14395c37 Auto merge of #150284 - JonathanBrouwer:rollup-yeibc0p, r=JonathanBrouwer
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#149928 (Detail expectation on non-`()` block tail in `if` then condition with no `else`)
 - rust-lang/rust#150166 (Don't lint on interior mutable `const` item coming from derefs)
 - rust-lang/rust#150281 (miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-22 20:09:56 +00:00