Commit graph

1550 commits

Author SHA1 Message Date
Chayim Refael Friedman
890d155ffe Complete derive helper attributes
Only their names, anything can go inside.
2024-12-04 08:20:41 +02:00
Chayim Refael Friedman
b66bc91b4b Fix a bug when synthetic AST node were searched in the AST ID map and caused panics 2024-11-25 14:52:58 +02:00
Vincent Esche
e6461522bc Add direct_supertraits(…) HIR-level method to hir::Trait type 2024-11-06 10:02:13 +01:00
Vincent Esche
5a9767b115 Refactor hir::Trait's existing items_with_supertraits(…) method based on new all_supertraits(…) method 2024-11-06 10:02:13 +01:00
Vincent Esche
89a002ef9b Add pub fn all_supertraits(…) HIR-level method to hir::Trait type 2024-11-06 10:02:13 +01:00
Lukas Wirth
36d68c5d0f Support new #[rustc_intrinsic] attribute and fallback bodies 2024-11-04 13:33:55 +01:00
Lukas Wirth
78f3112626 Allow interpreting consts and statics with interpret function command 2024-11-03 15:35:45 +01:00
Lukas Wirth
94c35f6138 Allow static initializers to be const evaluated 2024-11-02 12:43:11 +01:00
Lukas Wirth
70348faf2b Move child_by_source from hir-def to hir 2024-10-31 09:28:08 +01:00
Lukas Wirth
436ace3ecb
Merge pull request #18436 from Veykril/lw-yvkqwpnwsouo
Do not render meta info when hovering usages
2024-10-30 09:21:35 +00:00
Lukas Wirth
a953875f49 Style hover messages a bit differently 2024-10-29 16:59:48 +01:00
Chayim Refael Friedman
41658de227 Cleanup TypeRef lowering
By removing interior mutability from it.
2024-10-28 17:38:37 +02:00
Lukas Wirth
80e9d014be
Merge pull request #18074 from ChayimFriedman2/typeref-source-map
internal: Build source map for `hir_def::TypeRef`s
2024-10-28 11:01:12 +00:00
Lukas Wirth
715b67c425
Merge pull request #18410 from Veykril/veykril/push-lvwxpnowqrxk
internal: Invert token iteration order in macro mapping
2024-10-27 10:44:32 +00:00
Lukas Wirth
20ac30fb75 Invert token iteration order in macro mapping 2024-10-27 11:32:12 +01:00
Lukas Wirth
79b86f25b4
Merge pull request #18418 from ChayimFriedman2/explicitly-disable
feat: Split `macro-error` diagnostic so users can ignore only parts of it
2024-10-27 09:37:56 +00:00
Chayim Refael Friedman
f4585ea023 Split macro-error diagnostic so users can ignore only parts of it
Split it into `macro-error`, `proc-macros-disabled` and `proc-macro-disabled`.
2024-10-27 02:24:15 +02:00
Lukas Wirth
a12f1781eb Only construct a resolver in macro descension when needed 2024-10-25 10:23:59 +02:00
Chayim Refael Friedman
bf7edd3783 Shrink TypeRef from 16 from 32 bytes
Only references and arrays need to be boxed, and they comprise only 9.4% of the types (according to counting on r-a's code).

This saves 17mb.
2024-10-25 06:44:56 +03:00
Chayim Refael Friedman
1fae57fa55 Fix memory usage calculation's queries list 2024-10-25 06:15:06 +03:00
Chayim Refael Friedman
89c0ffa6b0 Build source map for hir_def::TypeRefs
So that given a `TypeRef` we will be able to trace it back to source code.

This is necessary to be able to provide diagnostics for lowering to chalk tys, since the input to that is `TypeRef`.

This means that `TypeRef`s now have an identity, which means storing them in arena and not interning them, which is an unfortunate (but necessary) loss but also a pretty massive change. Luckily, because of the separation layer we have for IDE and HIR, this change never crosses the IDE boundary.
2024-10-25 06:15:04 +03:00
Lukas Wirth
98935325ca minor: Remove intermediate allocations 2024-10-24 13:34:32 +02:00
Chayim Refael Friedman
8adcbdcc49 Implement semitransparent hygiene
Or macro_rules hygiene, or mixed site hygiene. In other words, hygiene for variables and labels but not items.

The realization that made me implement this was that while "full" hygiene (aka. def site hygiene) is really hard for us to implement, and will likely involve intrusive changes and performance losses, since every `Name` will have to carry hygiene, mixed site hygiene is very local: it applies only to bodies, and we very well can save it in a side map with minor losses.

This fixes one diagnostic in r-a that was about `izip!()` using hygiene (yay!) but it introduces a huge number of others, because of #18262. Up until now this issue wasn't a major problem because it only affected few cases, but with hygiene identifiers referred by macros like that are not resolved at all. The next commit will fix that.
2024-10-22 21:26:56 +03:00
Lukas Wirth
c286786888
Merge pull request #18254 from ChayimFriedman2/fix-mut
fix: Nail destructuring assignment once and for all
2024-10-22 17:40:52 +00:00
bors
d509449d7e Auto merge of #18370 - duncpro:goto-def-ranges, r=Veykril
feat: resolve range patterns to their structs

Closes #18367
2024-10-22 12:24:25 +00:00
Duncan Proctor
4fd471c571 tidy 2024-10-22 06:54:44 -04:00
Duncan Proctor
271f64f94d resolve range patterns to the their struct types 2024-10-22 06:20:16 -04:00
Lukas Wirth
6c23f25e7f Fix new nightly lints 2024-10-22 11:48:41 +02:00
bors
17055aaca9 Auto merge of #18362 - duncpro:goto-def-ranges, r=Veykril
feat: goto definition on range operators

Closes #18342
2024-10-22 07:49:18 +00:00
Duncan Proctor
2f6923b844 tidy 2024-10-22 03:19:47 -04:00
Duncan Proctor
f54a863965 goto definition on RangeFrom, RangeFull, RangeTo, and RangeToInclusive links to respective struct 2024-10-22 03:11:23 -04:00
duncanproctor
c7a8be110d Move explicit range handling out of goto_definition, use OperatorClass instead 2024-10-21 20:07:07 -04:00
Lukas Wirth
d878b8caad fix: Fix token downmapping failing for include! inputs 2024-10-21 17:22:18 +02:00
Chayim Refael Friedman
2d4d6b678f Store patterns desugared from destructuring assignments in source map
And few more fixups.

I was worried this will lead to more memory usage since `ExprOrPatId` is double the size of `ExprId`, but this does not regress `analysis-stats .`. If this turns out to be a problem, we can easily use the high bit to encode this information.
2024-10-20 19:11:32 +03:00
Chayim Refael Friedman
61f162a43d Handle destructuring assignments uniformly
Instead of lowering them to `<expr> = <expr>`, then hacking on-demand to resolve them, we lower them to `<pat> = <expr>`, and use the pattern infrastructure to handle them. It turns out, destructuring assignments are surprisingly similar to pattern bindings, and so only minor modifications are needed.

This fixes few bugs that arose because of the non-uniform handling (for example, MIR lowering not handling slice and record patterns, and closure capture calculation not handling destructuring assignments at all), and furthermore, guarantees we won't have such bugs in the future, since the programmer will always have to explicitly handle `Expr::Assignment`.

Tests don't pass yet; that's because the generated patterns do not exist in the source map. The next commit will fix that.
2024-10-20 19:09:51 +03:00
bors
5982d9c420 Auto merge of #18227 - davidbarsky:davidbarsky/push-lmntvwvznyyx, r=davidbarsky
internal: add json `tracing` Layer for profiling startup

On `buck2/integrations/rust-project`, this results in the following being printed:

```json
{"name":"discover_command","elapsed_ms":18703}
{"name":"parallel_prime_caches","elapsed_ms":0}
{"name":"vfs_load","elapsed_ms":5895}
{"name":"vfs_load","elapsed_ms":547}
{"name":"parallel_prime_caches","elapsed_ms":23}
{"name":"parallel_prime_caches","elapsed_ms":84}
{"name":"parallel_prime_caches","elapsed_ms":5819}
```
2024-10-04 17:59:02 +00:00
David Barsky
56c10ca981 internal: add JSON formatting for hprof 2024-10-04 11:26:15 -04:00
bors
510f72e12c Auto merge of #18234 - Veykril:veykril/push-vzynqtlxmrnl, r=Veykril
internal: Filter out opaque tokens in some IDE feature macro descensions
2024-10-04 10:26:04 +00:00
Lukas Wirth
24d65bb7cf internal: Filter out opaque tokens in some of IDE feature macro descensions 2024-10-04 11:53:12 +02:00
Shoyu Vanilla
e09c2a08d7 Fix: Handle block exprs as modules when finding their parents 2024-10-01 14:05:15 +09:00
bors
ac8509a74b Auto merge of #18210 - ChayimFriedman2:label-macro, r=Veykril
fix: Fix resolution of label inside macro

When working on Something Else (TM) (I left a hint in the commits :P), I noticed to my surprise that labels inside macros are not resolved. This led to a discovery of *two* unrelated bugs, which are hereby fixed in two commits.
2024-09-30 13:09:54 +00:00
Chayim Refael Friedman
cd7cbddaf6 When resolving labels in break and continue for the IDE, do not resolve them textually, instead reuse the results of HIR lowering
This fixes a bug where labels inside macros were not resolved, but more importantly this prepares us to a future where we have hygiene, and textual equivalence isn't enough to resolve identifiers.
2024-09-30 15:13:45 +03:00
Noah Bright
4255cae1bb Rename object_safety to dyn_compatibility
Up to a trait implemented by another package, linking to
$CARGO_HOME/registry/cache/index.crates.io-6f17d22bba15001f/
2024-09-29 07:26:45 -04:00
Chayim Refael Friedman
82124f33b5 Handle lint attributes that are under #[cfg_attr] 2024-09-19 22:21:48 +03:00
bors
990c48cb0d Auto merge of #18131 - ChayimFriedman2:macro-expand-dollar-crate, r=Veykril
fix: Get rid of `$crate` in expansions shown to the user

Be it "Expand Macro Recursively", "Inline macro" or few other things.

We replace it with the crate name, as should've always been.

Probably fixes some issues, but I don't know what they are.
2024-09-18 20:17:21 +00:00
Chayim Refael Friedman
cfb701ac78 Get rid of $crate in expansions shown to the user
Be it "Expand Macro Recursively", "Inline macro" or few other things.

We replace it with the crate name, as should've always been.
2024-09-18 18:30:59 +03:00
bors
f4aca78c92 Auto merge of #18117 - ChayimFriedman2:issue-18089, r=Veykril
fix: Always cache macro expansions' root node in Semantics

Previously some expansions were not cached, but were cached in the expansion cache, which caused panics when later queries tried to lookup the node from the expansion cache.

Fixes #18089.
2024-09-18 09:19:30 +00:00
Chayim Refael Friedman
f6eb5be591 Add diagnostics for unsafe_op_in_unsafe_fn
Turns out it's pretty easy, but I did have to add support for allowed-by-default lints.
2024-09-18 03:02:12 +03:00
Chayim Refael Friedman
35e171aa01 Always cache macro expansions' root node in Semantics
Previously some expansions were not cached, but were cached in the expansion cache, which caused panics when later queries tried to lookup the node from the expansion cache.
2024-09-17 00:19:39 +03:00
Chayim Refael Friedman
798c963875 Fix printing of constants greater than i128::MAX 2024-09-16 01:30:18 +03:00