Commit graph

31576 commits

Author SHA1 Message Date
bors
82b2d07f6a Auto merge of #18184 - Veykril:veykril/push-wsqsyxynttps, r=Veykril
fix: Pass all-targets for build scripts in more cli commands

Without this, build scripts don't run for tests and as such any proc-macros in dev-deps fail to resolve
2024-09-25 06:27:31 +00:00
Lukas Wirth
10ada02019 Pass all-targets for build scripts in more cli commands
Without this, build scripts don't run for tests and as such any proc-macros in dev-deps fail to resolve
2024-09-25 08:23:09 +02:00
bors
2f55a91552 Auto merge of #18164 - ShoyuVanilla:use-as-alias, r=Veykril
fix: Temporary fix for `remove_unused_imports` not handling import aliases correctly

Fixes #18129
2024-09-24 15:22:57 +00:00
Shoyu Vanilla
d4de84f58a fix: Temporary fix for remove_unused_imports not handling import aliases correctly 2024-09-24 23:48:04 +09:00
bors
e775dd6c70 Auto merge of #18166 - ChayimFriedman2:dollar-crate-root, r=Veykril
fix: Fix a bug in span map merge, and add explanations of how span maps are stored

Because it took me hours to figure out that contrary to common sense, the offset stored is the *end* of the node, and we search by the *start*. Which is why we need a convoluted `partition_point()` instead of a simple `binary_search()`. And this was not documented at all. Which made me make mistakes with my implementation of `SpanMap::merge()`.

The other bug fixed about span map merging is correctly keeping track of the current offset in presence of multiple sibling macro invocations. Unrelated, but because of the previous issue it took me hours to debug, so I figured out I'll put them together for posterity.

Fixes #18163.
2024-09-24 11:01:05 +00:00
bors
f30d4ea9c0 Auto merge of #18161 - ChayimFriedman2:postfix-mut, r=Veykril
fix: Better support references in consuming postfix completions

Fixes #18155.
2024-09-24 10:46:48 +00:00
bors
a159b370ba Auto merge of #18160 - ChayimFriedman2:fix-18138, r=Veykril
fix: Fix name resolution when an import is resolved to some namespace and then later in the algorithm another namespace is added

The import is flagged as "indeterminate", and previously it was re-resolved, but only at the end of name resolution, when it's already too late for anything that depends on it.

This issue was tried to fix in https://github.com/rust-lang/rust-analyzer/pull/2466, but it was not fixed fully.

That PR is also why IDE features did work: the import at the end was resolved correctly, so IDE features that re-resolved the macro path resolved it correctly.

I was concerned about the performance of this, but this doesn't seem to regress `analysis-stats .`, so I guess it's fine to land this. I have no idea about the incremental perf however and I don't know how to measure that, although when typing in `zbus` (including creating a new function, which should recompute the def map) completion was fast enough.

I didn't check what rustc does, so maybe it does something more performant, like keeping track of only possibly problematic imports.

Fixes #18138.
Probably fixes #17630.
2024-09-24 10:32:28 +00:00
bors
b6b56d2abe Auto merge of #18157 - davidbarsky:davidbarsky/respect-disabling-proc-macros-in-analysis-stats, r=Veykril
analysis-stats: respect `--disable-proc-macros` flag

I noticed that this flag wasn't being respected by `analysis-stats` when profiling proc macro expansion, so here's a small fix.
2024-09-24 10:17:56 +00:00
bors
b4eff8971d Auto merge of #18123 - jhgg:fix-ambigius-package-cargo-check, r=Veykril
fix: fix ambigious package name in flycheck

fixes #18121
2024-09-24 10:03:41 +00:00
bors
7eb10bda57 Auto merge of #18175 - Wilfred:completion_marker, r=Veykril
internal: Make COMPLETION_MARKER more explicitly r-a

If a user ever sees the completion marker, it's confusing to see text about IntelliJ. Use a string that's more explicitly about completion for rust-analyzer.
2024-09-24 09:49:25 +00:00
bors
dfee4c8690 Auto merge of #18162 - ChayimFriedman2:gat-object-safe, r=Veykril
fix: Consider lifetime GATs object unsafe

Fixes #18156.
2024-09-24 08:14:00 +00:00
Wilfred Hughes
d95ad12c9c internal: Make COMPLETION_MARKER more explicitly r-a
If a user ever sees the completion marker, it's confusing to see text
about IntelliJ. Use a string that's more explicitly about completion
for rust-analyzer.
2024-09-23 17:04:04 -04:00
bors
3d0343251f Auto merge of #18172 - lnicola:expect-attr-completions, r=davidbarsky
fix: Support expect in attribute completion and hover

Fixes #18171
2024-09-23 15:16:15 +00:00
Laurențiu Nicola
a6572e9234 Support expect in attribute completion and hover 2024-09-23 14:55:50 +03:00
bors
b3a3bf770a Auto merge of #18170 - rust-lang:revert-18169-disable-gh-releases, r=lnicola
minor: Revert "internal: Disable GitHub releases for now"

Turns out, this wasn't needed for long.
2024-09-23 08:52:30 +00:00
Laurențiu Nicola
8a49375f64
Revert "internal: Disable GitHub releases for now" 2024-09-23 11:47:37 +03:00
bors
1301e4268f Auto merge of #18169 - lnicola:disable-gh-releases, r=lnicola
internal: Disable GitHub releases for now

These are currently throwing `Error: HttpError: Resource not accessible by integration` because of the organization change, let's disable them for today's release.
2024-09-23 05:58:48 +00:00
Laurențiu Nicola
aed88d349a Disable GitHub releases for now 2024-09-23 08:56:27 +03:00
Chayim Refael Friedman
b275f37db6 Fix a bug in span map merge, and add explanations of how span maps are stored
Because it took me hours to figure out that contrary to common sense, the offset stored is the *end* of the node, and we search by the *start*. Which is why we need a convoluted `partition_point()` instead of a simple `binary_search()`. And this was not documented at all. Which made me make mistakes with my implementation of `SpanMap::merge()`.

The other bug fixed about span map merging is correctly keeping track of the current offset in presence of multiple sibling macro invocations. Unrelated, but because of the previous issue it took me hours to debug, so I figured out I'll put them together for posterity.
2024-09-23 01:54:40 +03:00
Chayim Refael Friedman
141833850c Consider lifetime GATs object unsafe 2024-09-22 15:00:01 +03:00
Chayim Refael Friedman
7c015944b3 Include dereferences in consuming postfix completions (e.g. call) 2024-09-22 06:07:49 +03:00
Chayim Refael Friedman
9274703ac4 Properly account for mutable references when postfix-completing consuming completions (e.g. call) 2024-09-22 06:07:27 +03:00
Chayim Refael Friedman
432b2559cd Fix name resolution when an import is resolved to some namespace and then later in the algorithm another namespace is added
The import is flagged as "indeterminate", and previously it was re-resolved, but only at the end of name resolution, when it's already too late for anything that depends on it.

This issue was tried to fix in https://github.com/rust-lang/rust-analyzer/pull/2466, but it was not fixed fully.
2024-09-22 04:19:10 +03:00
David Barsky
ad52c46478 analysis-stats: respect --disable-proc-macros flag 2024-09-20 13:40:12 -04:00
bors
00037c18ed Auto merge of #18132 - ChayimFriedman2:fix-closure-semi, r=Veykril
fix: Don't complete `;` when in closure return expression

Completing it will break syntax.

Fixes #18130.
2024-09-20 07:38:16 +00:00
bors
d4689f183a Auto merge of #18151 - ChayimFriedman2:metavar-concat, r=Veykril
feat: Support the `${concat(...)}` metavariable expression

I didn't follow rustc precisely, because I think it does some things wrongly (or they are FIXME), but I only allowed more code, not less. So we're all fine.

Closes #18145.
2024-09-20 07:23:43 +00:00
bors
c467115fd9 Auto merge of #18108 - ChayimFriedman2:lint-level-cfg, r=Veykril
fix: Handle lint attributes that are under `#[cfg_attr]`

I forgot `cfg_attr` while working on #18099. Although the original code also didn't handle that (although case lints specifically were correct, by virtue of using hir attrs).
2024-09-20 06:54:53 +00:00
bors
b2a9cc4eff Auto merge of #18153 - ChayimFriedman2:mbe-const, r=Veykril
fix: When checking for forbidden expr kind matches, account for rawness

An expression starting with `r#const` etc. should be accepted even in edition <=2021.

Fixes #18148.

This was not fixed when testing with edition 2024, I wonder whether that means our check for edition is incorrect...
2024-09-20 06:29:50 +00:00
Chayim Refael Friedman
5c06f047b9 When checking for forbidden expr kind matches, account for rawness
An expression starting with `r#const` etc. should be accepted even in edition <=2021.
2024-09-19 23:38:48 +03:00
Chayim Refael Friedman
82124f33b5 Handle lint attributes that are under #[cfg_attr] 2024-09-19 22:21:48 +03:00
Chayim Refael Friedman
8a50aecb07 Support the ${concat(...)} metavariable expression
I didn't follow rustc precisely, because I think it does some things wrongly (or they are FIXME), but I only allowed more code, not less. So we're all fine.
2024-09-19 22:19:12 +03:00
bors
6dad8c5528 Auto merge of #18146 - ChayimFriedman2:allow-comment, r=Veykril
fix: Remove check that text of `parse_expr_from_str()` matches the produced parsed tree

This check is incorrect when we have comments and whitespace in the text.

We can strip comments, but then we still have whitespace, which we cannot strip without changing meaning for the parser. So instead I opt to remove the check, and wrap the expression in parentheses (asserting what produced is a parenthesized expression) to strengthen verification.

Fixes #18144.
2024-09-19 13:27:21 +00:00
Chayim Refael Friedman
9ef460ba2d Remove check that text of parse_expr_from_str() matches the produced parsed tree
This check is incorrect when we have comments and whitespace in the text.

We can strip comments, but then we still have whitespace, which we cannot strip without changing meaning for the parser. So instead I opt to remove the check, and wrap the expression in parentheses (asserting what produced is a parenthesized expression) to strengthen verification.
2024-09-19 14:18:07 +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
bors
bd59dc8e4c Auto merge of #18139 - ShoyuVanilla:issue-18109, r=Veykril
fix: Extend `type_variable_table` when modifying index is larger than the table size

Fixes #18109

Whenever we create an inference variable in r-a, we extend `type_variable_table` to matching size here;

f4aca78c92/crates/hir-ty/src/infer/unify.rs (L378-L381)

But sometimes, an inference variable is [created from chalk](ab710e0c9b/chalk-solve/src/infer/unify.rs (L743)) and passed to r-a as a type of an expression or a pattern.
If r-a set diverging flag to this before the table is extended to a sufficient size, it panics here;

f4aca78c92/crates/hir-ty/src/infer/unify.rs (L275-L277)

I think that extending table when setting diverging flag is reasonable becase we are already doing such extending to a size that covers the inference vars created from chalk and this change only covers the order-dependent random cases that this might fail
2024-09-18 20:01:38 +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
Shoyu Vanilla
b368f9125b fix: Extend type_variable_table when modifying index is larger than table size 2024-09-19 00:02:08 +09:00
Chayim Refael Friedman
c9758da280 Extract logic to decide how to complete semicolon for unit-returning function into CompletionContext
So that we don't recompute it for every item.
2024-09-18 14:07:23 +03:00
Chayim Refael Friedman
7f023154f0 Don't complete ; when in closure return expression
Completing it will break syntax.
2024-09-18 13:53:11 +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
bors
4a08e77842 Auto merge of #18128 - ChayimFriedman2:external-macros-lint, r=Veykril
fix: Handle errors and lints from external macros

Some lints should not be reported if they originate from an external macro, and quickfixes should be disabled (or they'll change library code).

Fixes #18122.
Closes #18124.
2024-09-18 09:04:53 +00:00
bors
5b7c812634 Auto merge of #18136 - valadaptive:no-mangle-lints, r=Veykril
Don't lint names of #[no_mangle] extern fns

[Rust doesn't run the `non_snake_case_name` lint on `extern fn`s with the `#[no_mangle]` attribute](https://github.com/rust-lang/rust/pull/44966).

The conditions are:
- The function must be `extern` and have a `#[no_mangle]` attribute.
- The function's ABI must not be explicitly set to "Rust".

This PR replicates that logic here.
2024-09-18 08:50:40 +00:00
bors
30e0953187 Auto merge of #18135 - ChayimFriedman2:unsafe-op-in-unsafe-fn, r=Veykril
feat: 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 08:35:42 +00:00
bors
2617bd4b92 Auto merge of #18137 - ShoyuVanilla:expr-2021, r=Veykril
feat: Implement `expr_2021`

Resolves #18062
2024-09-18 08:21:24 +00:00
Shoyu Vanilla
d34a663c70 feat: Implement expr_2021 2024-09-18 15:58:03 +09:00
bors
f0e7bea19d Auto merge of #18134 - DropDemBits:source-change-sed, r=lnicola
internal: Extend SourceChangeBuilder to make make working with `SyntaxEditor`s easier

Part of #15710

Adds additional `SourceChangeBuilder` methods to make it easier to migrate assists to `SyntaxEditor`.

As `SyntaxEditor`s are composable before they're completed, each created `SyntaxEditor` can represent logical groups of changes (e.g. independently performing renames of uses in a file from inserting the new item). Once a group of changes is considered "done", `SourceChangeBuilder::add_file_edits` is used to submit a set of changes to be part of the source change.

`SyntaxAnnotation`s are used to indicate where snippets are attached to, and using `SyntaxAnnotation`s also means that we can attach snippets at any time, rather than being required to be after all edits.
2024-09-18 06:21:56 +00:00
valadaptive
893f79270f Don't lint names of #[no_mangle] extern fns 2024-09-18 01:54:03 -04: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
DropDemBits
5537e2739c
Use SyntaxEditor in extract_type_alias 2024-09-17 18:25:32 -04:00
DropDemBits
23c4ab7e4b
internal: Extend SourceChangeBuilder to make make working with SyntaxEditors easier 2024-09-17 18:24:27 -04:00