1373 Commits

Author SHA1 Message Date
Lukas Wirth
4fdc2507c6 fix: Fix invalid signature bitflags 2025-04-10 15:39:27 +02:00
Lukas Wirth
f880acd18c
Merge pull request #19461 from Hmikihiro/shadow_by_module
fix: shadow type by module
2025-04-10 12:20:14 +00:00
Lukas Wirth
55efab890b
Merge pull request #19559 from ChayimFriedman2/rust-186
internal: Switch to Rust 1.86.0
2025-04-10 08:33:14 +00:00
Chayim Refael Friedman
8a9a1e3345 Remove all upcasts!
It turns out there were a lot redundant too.
2025-04-10 11:08:38 +03:00
Hayashi Mikihiro
b75a3388f1 Update crates/hir-def/src/resolver.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2025-04-10 16:29:10 +09:00
Hayashi Mikihiro
1b471ebfd5 TypeNs contain module
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
2025-04-10 16:29:10 +09:00
Hayashi Mikihiro
a7dc60a2c4 return single option
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
2025-04-10 16:29:10 +09:00
Hayashi Mikihiro
2854ad9a41 fix: shadow type by module
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
2025-04-10 16:29:10 +09:00
Chayim Refael Friedman
2ae3e4c879
Fix a small bug with catastrophic effects
The tiny bug was that `FnFlags::DEPRECTAED_SAFE_2024` and `FnFlags::RUSTC_ALLOW_INCOHERENT_IMPLS` were assigned the same value.

The catastrophic effect was that every function marked as `#[rustc_allow_incoherent_impl]` was considered safe-deprecated for edition 2024, which caused it to be considered unsafe to call when called from edition 2024. And that includes `<[_]>::into_vec()`, which is called by the `vec![]` macro. So, catastrophic effect.

This innocent-looking bug probably arose from the item tree rewrite. No review would've catch that!
2025-04-10 09:37:37 +03:00
Lukas Wirth
07212140db refactor: Turn LifetimeRef into an enum
This makes things more structured
2025-04-09 15:58:06 +02:00
Lukas Wirth
1fd9520c92 refactor: Lower type-refs before type inference
This refactors how we deal with items in hir-def lowering.

- It now lowers all of them through an "ExpressionStore" (kind of a misnomer as this point) as their so called *Signatures.
- We now uniformly lower type AST into TypeRefs before type inference.
- Likewise, this moves macro expansion out of type inference, resulting in a single place where we do non-defmap macro expansion.
- Finally, this PR removes a lot of information from ItemTree, making the DefMap a lot less likely to be recomputed and have it only depend on actual early name resolution related information (not 100% true, we still have ADT fields in there but thats a follow up removal).
2025-04-09 10:43:23 +02:00
Lukas Wirth
7e00f91a72
Merge pull request #19531 from Veykril/push-kxyrpznnllkx
fix: Fix `format_args` lowering for >=1.87
2025-04-06 08:18:23 +00:00
Lukas Wirth
e7ce86ddea fix: Fix format_args lowering for >=1.87 2025-04-06 10:05:56 +02:00
Lukas Wirth
1d1771c15f
Merge pull request #19501 from ChayimFriedman2/macro-expansion
fix: Fix a bug in MBE expansion that arose from incorrect fixing of an older bug in MBE
2025-04-05 13:00:30 +00:00
BenjaminBrienen
2462624a7d prefer default over new 2025-04-04 15:49:50 +02:00
Chayim Refael Friedman
3953b604ce Fix a bug in MBE expansion that arose from incorrect fixing of an older bug in MBE
Specifically, #18744 was the PR that was supposed to fix the old bug, but it fixed it incorrectly (and didn't add a test!) The underlying reason was that we marked metavariables in expansions as joint if they were joint in the macro call, which is incorrect.

This wrong fix causes other bug, #19497, which this PR fixes by removing the old (incorrect) fix.
2025-04-01 21:05:51 +03:00
Lukas Wirth
1e1571e1c8 fix: Fix new nightly lints 2025-03-31 13:27:54 +02:00
Lukas Wirth
faf1b49a9a fix: Fix, clarify and require a value for proc_macro_cwd of CrateData 2025-03-29 08:08:48 +01:00
Lukas Wirth
2e1ff255ae
Merge pull request #19375 from ChayimFriedman2/do-not-complete
feat: Allow crate authors to control completion of their things
2025-03-28 09:06:19 +00: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
9a5a11fb30 fix: Fix format_args lowering using wrong integer suffix 2025-03-27 08:56:15 +01:00
Lukas Wirth
452e2ca031 feat: parse unsafe record fields 2025-03-25 08:55:31 +01:00
David Barsky
7d050feb5f analysis-stats: expose and print some limited statistics from hir-def 2025-03-24 09:59:51 -07:00
Lukas Wirth
dcd742301e refactor: Replace custom ThinVec with thin-vec crate 2025-03-24 13:44:13 +01:00
Laurențiu Nicola
fcbba4ec72
Merge pull request #19436 from lnicola/rm-rustc-hashes
minor: drop `rustc_hashes` dependency, add `syn` feature
2025-03-24 06:56:05 +00:00
Laurențiu Nicola
7af69a1952 Drop rustc_hashes dependency 2025-03-24 08:28:52 +02:00
Lukas Wirth
500ea05aef chore: Bump dependencies 2025-03-23 08:46:10 +01:00
Lukas Wirth
d4122434dd chore: Remove unused dependencies 2025-03-23 08:08:17 +01:00
Shoyu Vanilla
602b4f37b9 fix: Handle multiple #[repr(..)] attrs correctly 2025-03-22 18:57:37 +09:00
Lukas Wirth
3d9ac497aa fix: Fix incorrect expansion of builtin PartialOrd derive 2025-03-21 12:14:39 +01:00
Lukas Wirth
c365bd96d3 refactor: Do not use Expander in assoc item lowering
`Expander` is a macro expansion solution for body lowering, there is no need to use it here
2025-03-18 11:11:36 +01:00
Lukas Wirth
a505420751 chore: Bump Edition::CURRENT to 2024 2025-03-17 12:29:19 +01:00
Lukas Wirth
a06aadb9f0 internal: Render root syntax contexts more clearly 2025-03-16 16:26:07 +01:00
Lukas Wirth
918740358b
Merge pull request #19354 from ChayimFriedman2/rtn-prep
Preparation to Return Type Notation (RTN)
2025-03-16 13:21:23 +00:00
Lukas Wirth
b5eedad8e3 refactor: Remove unnecessary Arc 2025-03-16 10:27:48 +01:00
BenjaminBrienen
92ccf3dd8b cargo fmt 2025-03-15 21:32:01 +01:00
BenjaminBrienen
65617851c5 fix temporary value dropped while borrowed 2025-03-15 21:32:01 +01:00
BenjaminBrienen
7535bb4661 cargo fmt 2025-03-15 21:32:01 +01:00
BenjaminBrienen
7f1912c748 cargo clippy --fix 2025-03-15 21:32:01 +01:00
Lukas Wirth
02a793bd59 chore: Remove legacy SyntaxContextId re-export 2025-03-15 17:09:17 +01:00
Lukas Wirth
2ea09b2e47 Split variant_data into its own query 2025-03-14 14:16:33 +01:00
Lukas Wirth
8e8d997304 Split enum variants out of enum_data query 2025-03-14 13:32:53 +01:00
Lukas Wirth
dff1896436 Move attribute parsing out of data module 2025-03-14 13:31:41 +01:00
Lukas Wirth
12f54eec27 Split assoc items out of trait_data/impl_data queries 2025-03-14 13:31:41 +01:00
David Barsky
788232b355 internal: don't panic when the crate graph isn't ready #19351 2025-03-13 15:14:08 -04:00
Chayim Refael Friedman
eaa0a39831 Lower Return Type Notation (Type::method(..): Send)
We do it the way rustc does it, by only marking segments with it, and not the whole path. This will allow extending where it is allowed in the future.
2025-03-12 23:34:16 +02:00
Chayim Refael Friedman
3fc655b239
Merge pull request #19337 from ChayimFriedman2/salsify-crate-graph-final
Salsify the crate graph
2025-03-12 19:17:29 +00: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
¨Florian
9780734028 Make GenericParamsCollector::type_or_consts not unnecessarily pub(crate) 2025-03-11 15:09:39 +01:00
bors
15864ffeb5 Auto merge of #136932 - m-ou-se:fmt-width-precision-u16, r=scottmcm
Reduce formatting `width` and `precision` to 16 bits

This is part of https://github.com/rust-lang/rust/issues/99012

This is reduces the `width` and `precision` fields in format strings to 16 bits. They are currently full `usize`s, but it's a bit nonsensical that we need to support the case where someone wants to pad their value to eighteen quintillion spaces and/or have eighteen quintillion digits of precision.

By reducing these fields to 16 bit, we can reduce `FormattingOptions` to 64 bits (see https://github.com/rust-lang/rust/pull/136974) and improve the in memory representation of `format_args!()`. (See additional context below.)

This also fixes a bug where the width or precision is silently truncated when cross-compiling to a target with a smaller `usize`. By reducing the width and precision fields to the minimum guaranteed size of `usize`, 16 bits, this bug is eliminated.

This is a breaking change, but affects almost no existing code.

---

Details of this change:

There are three ways to set a width or precision today:

1. Directly a formatting string, e.g. `println!("{a:1234}")`
2. Indirectly in a formatting string, e.g. `println!("{a:width$}", width=1234)`
3. Through the unstable `FormattingOptions::width` method.

This PR:

- Adds a compiler error for 1. (`println!("{a:9999999}")` no longer compiles and gives a clear error.)
- Adds a runtime check for 2. (`println!("{a:width$}, width=9999999)` will panic.)
- Changes the signatures of the (unstable) `FormattingOptions::[get_]width` methods to use a `u16` instead.

---

Additional context for improving `FormattingOptions` and `fmt::Arguments`:

All the formatting flags and options are currently:

- The `+` flag (1 bit)
- The `-` flag (1 bit)
- The `#` flag (1 bit)
- The `0` flag (1 bit)
- The `x?` flag (1 bit)
- The `X?` flag (1 bit)
- The alignment (2 bits)
- The fill character (21 bits)
- Whether a width is specified (1 bit)
- Whether a precision is specified (1 bit)
- If used, the width (a full usize)
- If used, the precision (a full usize)

Everything except the last two can simply fit in a `u32` (those add up to 31 bits in total).

If we can accept a max width and precision of u16::MAX, we can make a `FormattingOptions` that is exactly 64 bits in size; the same size as a thin reference on most platforms.

If, additionally, we also limit the number of formatting arguments, we can also reduce the size of `fmt::Arguments` (that is, of a `format_args!()` expression).
2025-03-11 04:07:05 +00:00