114 Commits

Author SHA1 Message Date
Lukas Wirth
ccd3924038
Merge pull request #21573 from ChayimFriedman2/include-bytes-len
fix: Infer the expected len in `include_bytes!()`, to avoid mismatches
2026-02-05 11:18:24 +00:00
Geoffry Song
a6d8875ee6 Implement homogeneous & heterogeneous try blocks 2026-02-02 18:13:10 -08:00
Chayim Refael Friedman
948d7e88ce Infer the expected len in include_bytes!(), to avoid mismatches
Since we can't read the real file size.
2026-02-03 02:25:31 +02:00
Lukas Wirth
bb969782b7
Merge pull request #21460 from Veykril/push-vyqmuvkouywu
feat: Implement support for `feature(new_range)`
2026-01-31 10:31:38 +00:00
Laurențiu Nicola
0bd115cd42 Merge ref '94a0cd15f597' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: 94a0cd15f5976fa35e5e6784e621c04e9f958e57
Filtered ref: 1b46aa0fdb1e825363174ce509e40466cc0af416
Upstream diff: 004d710faf...94a0cd15f5

This merge was created using https://github.com/rust-lang/josh-sync.
2026-01-27 16:14:55 +02:00
Simonas Kazlauskas
73b221a686 abi: add a rust-preserve-none calling convention
This is the conceptual opposite of the rust-cold calling convention and
is particularly useful in combination with the new `explicit_tail_calls`
feature.

For relatively tight loops implemented with tail calling (`become`) each
of the function with the regular calling convention is still responsible
for restoring the initial value of the preserved registers. So it is not
unusual to end up with a situation where each step in the tail call loop
is spilling and reloading registers, along the lines of:

    foo:
        push r12
        ; do things
        pop r12
        jmp next_step

This adds up quickly, especially when most of the clobberable registers
are already used to pass arguments or other uses.

I was thinking of making the name of this ABI a little less LLVM-derived
and more like a conceptual inverse of `rust-cold`, but could not come
with a great name (`rust-cold` is itself not a great name: cold in what
context? from which perspective? is it supposed to mean that the
function is rarely called?)
2026-01-24 19:23:17 +02:00
Lukas Wirth
75b41dc58a feat: Implement support for feature(new_range) 2026-01-13 20:36:18 +01:00
The rustc-josh-sync Cronjob Bot
318545f9d4 Merge ref '44a5b55557c2' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: rust-lang/rust@44a5b55557
Filtered ref: rust-lang/rust-analyzer@d2e7b71402
Upstream diff: 548e586795...44a5b55557

This merge was created using https://github.com/rust-lang/josh-sync.
2026-01-12 04:26:37 +00:00
Martin Nordholts
72a6823f8b rust-analyzer: Also use semiopaque instead of semitransparent
Like in rustc.
2026-01-08 19:14:45 +01:00
Chayim Refael Friedman
33894483a6 Fixes for builtin derive expansions
- Do not store the `MacroCallId` of the "real" expansion anywhere, so that the IDE layer could not expand it by mistake
 - Fix a stupid bug where we used the directive of the `derive` itself instead of of the macro, leading us to re-expand it again and again.
2026-01-08 09:49:55 +02:00
Lukas Wirth
8facf7344d perf: Only compute lang items for #![feature(lang_items)] crates 2026-01-03 11:06:33 +01:00
Lukas Wirth
64908c90ba Pre-allocate intern storages with 64kb of data
To reduce the amount of re-allocating the hashtables which can be expensive given the need to re-hash
2026-01-02 13:20:06 +01:00
Lukas Wirth
2cf8bfe72e Reduce allocations in GarbageCollector 2025-12-28 13:14:06 +01:00
Chayim Refael Friedman
bd934c08cf 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
Chayim Refael Friedman
5fbff1d7fb Make builtin derives cheaper, by not really expanding them, instead store them unexpanded 2025-12-25 16:26:11 +02:00
Lukas Wirth
af45994feb Introduce cargo-machete ci step 2025-12-25 10:38:05 +01:00
Chayim Refael Friedman
5e2dfbbd02 Add extensive docs for the unsafe operations 2025-12-18 17:30:20 +02:00
Chayim Refael Friedman
36c9f6224c GC support for solver types
A GC is triggered every X revisions, and is synchronous, unfortunately.
2025-12-18 10:12:03 +02:00
Chayim Refael Friedman
776c818882 Lay the basics for non-Copy solver types with GC
That means stop using Salsa for interning solver types.
2025-12-18 10:12:03 +02:00
Chayim Refael Friedman
d7465cb5b7 Upgrade rustc crates
Changes:
 - `const_of_item()` was added to `Interner`, analogous to `type_of()`. No strongly-typed ID (yet).
 - New solver trait lang item: `TrivialClone`.
 - `TypeRelation` changed a bit, the code was copied from rustc.
2025-12-16 17:00:44 +02:00
Chayim Refael Friedman
a4612ce527 Register define_opaque builtin attribute macro
So that we'll correctly treat it as an attribute.

I don't like that we have to register every builtin macro even if we don't need it, but that's what we got.
2025-12-01 02:31:30 +02:00
Zalathar
fe1469ebd1 Basic support for declarative attribute/derive macros 2025-11-24 21:50:56 +11:00
Chayim Refael Friedman
e8e02d5515
Merge pull request #20974 from ChayimFriedman2/ns4
fix: Rewrite method resolution to follow rustc more closely
2025-11-18 23:20:04 +00:00
Lukas Wirth
c1c6682e8b Merge pull request #20994 from Veykril/push-npvyklkuxnlr
perf: Reduce memory usage of symbol index
2025-11-15 09:17:33 +02:00
Chayim Refael Friedman
50384460c6 Rewrite method resolution to follow rustc more closely
It cannot be exactly the same, because we have needs rustc doesn't have (namely, accurate enumeration of all methods, not just with a specific name, for completions etc., while rustc also needs a best-effort implementation for diagnostics) but it is closer than the previous impl.

In addition we rewrite the closely related handling of operator inference and impl collection.

This in turn necessitate changing some other parts of inference in order to retain behavior. As a result, the behavior more closely matches rustc and is also more correct.

This fixes 2 type mismatches on self (1 remains) and 4 diagnostics (1 remains), plus some unknown types.
2025-11-05 18:43:36 +02:00
Chayim Refael Friedman
bdd7f15b3d Implement Interner::impl_specializes()
Using specialization logic ported from rustc.
2025-10-23 20:48:51 +03:00
Chayim Refael Friedman
6b133c6b1b Implement fallback properly
fallback.rs was ported straight from rustc (minus the lint parts).

This fixes the `!` regressions.
2025-09-24 20:42:06 +03:00
Chayim Refael Friedman
7d1860807e Port a bunch of stuff from rustc and fix a bunch of type mismatches/diagnostics
This started from porting coercion, but ended with porting much more.
2025-09-15 18:56:17 +03:00
jackh726
9418a3f2df Implement next trait solver 2025-08-09 16:08:58 +00:00
Chayim Refael Friedman
b1914e420f Support cfg_select! 2025-07-20 11:56:45 +03:00
Shoyu Vanilla
953e9d1c36 Backport new sized-hierarchy trait bounds in old ways 2025-06-26 23:22:26 +09:00
Chayim Refael Friedman
de312d0c71 Don't run doctests 2025-06-23 00:50:22 +03:00
Shoyu Vanilla
4f8767d790 Minic rustc's new format_args! expansion 2025-06-22 13:22:28 +09:00
Lukas Wirth
23712aea06 cargo upgrade 2025-06-13 10:08:20 +02:00
Trevor Gross
e6e5e3cc41 chore: Remove support for concat_idents!
`concat_idents!` was deprecated in [1] and will be removed in the near
future. rust-analyzer's support is independent of rustc's, so drop RA
support now to make syncing easier.

[1]: https://github.com/rust-lang/rust/pull/137653
2025-05-28 03:59:32 +00:00
Matthias Krüger
573c47c9ba remove a couple of clones 2025-05-01 11:41:42 +02:00
Chayim Refael Friedman
4d95ae52f8 Upgrade dashmap and hashbrown
And adapt `intern` to the changes in the API.
2025-04-25 12:47:26 +03:00
Lukas Wirth
34e7d60e30
Merge pull request #19644 from ChayimFriedman2/const-syms
internal: Make predefined symbols `const` instead of `static`
2025-04-21 12:34:59 +00:00
Lukas Wirth
d16b862ea5 fix: Support unstable UnsafePinned struct in type layout calc 2025-04-21 09:35:30 +02:00
Chayim Refael Friedman
9477e46bec Get rid of static predefined symbols
Make them all `const`.
2025-04-21 03:07:35 +03:00
Lukas Wirth
e7ce86ddea fix: Fix format_args lowering for >=1.87 2025-04-06 10:05:56 +02:00
BenjaminBrienen
2462624a7d prefer default over new 2025-04-04 15:49:50 +02:00
Chayim Refael Friedman
7b584ef9bf Allow crate authors to control completion of their things
Via the new `#[rust_analyzer::completions(...)]` attribute.

Also fix a bug with existing settings for that where the paths wouldn't resolve correctly.
2025-03-27 14:01:26 +02:00
Lukas Wirth
c96421ecf4 ci: run intern tests via cargo miri 2025-03-25 07:26:43 +01:00
Lukas Wirth
c28b80c321 internal: Symbol is not PartialOrd 2025-03-16 16:06:06 +01:00
BenjaminBrienen
7535bb4661 cargo fmt 2025-03-15 21:32:01 +01:00
Chayim Refael Friedman
c94e9efbef Salsify the crate graph
I.e. make it not one giant input but multiple, for incrementality and decreased memory usage for Salsa 3 reasons.
2025-03-12 21:02:30 +02:00
Lukas Wirth
af7f89cc9d Fix path macro hygiene 2025-03-10 09:29:27 +01:00
Thalia Archibald
0811ca0a61 Use size_of from the prelude instead of imported
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the
prelude instead of importing or qualifying them.

These functions were added to all preludes in Rust 1.80.
2025-03-05 00:48:44 -08:00
BenjaminBrienen
bd7375a58f enable doctest 2025-02-27 14:58:46 +01:00