Commit graph

31098 commits

Author SHA1 Message Date
Lukas Wirth
d46060b168 Fix error spans for include! and compile_error! 2024-07-29 15:57:01 +02:00
bors
510a8ffff3 Auto merge of #17736 - hyf0:hyf_09234908234, r=Veykril
feat(ide-completion): explictly show `async` keyword on `impl trait` methods

OLD:

<img width="676" alt="image" src="https://github.com/user-attachments/assets/f6fa626f-6b6d-4c22-af27-b0755e7a6bf8">

Now:

<img width="684" alt="image" src="https://github.com/user-attachments/assets/efbaac0e-c805-4dd2-859d-3e44b2886dbb">

---

This is an preparation for https://github.com/rust-lang/rust-analyzer/issues/17719.

```rust
use std::future::Future;

trait DesugaredAsyncTrait {
    fn foo(&self) -> impl Future<Output = usize> + Send;
    fn bar(&self) -> impl Future<Output = usize> + Send;
}

struct Foo;

impl DesugaredAsyncTrait for Foo {
    fn foo(&self) -> impl Future<Output = usize> + Send {
        async { 1 }
    }

    //
    async fn bar(&self) -> usize {
        1
    }
}

fn main() {
    let fut = Foo.bar();
    fn _assert_send<T: Send>(_: T) {}
    _assert_send(fut);
}
```

If we don't distinguish `async` or not. It would be confusing to generate sugared version `async fn foo ....` and original form `fn foo`  for `async fn in trait` that is defined in desugar form.
2024-07-29 12:55:53 +00:00
Lukas Wirth
ae9c553902 Make basic use of spans for macro expansion errors 2024-07-29 14:52:40 +02:00
Yunfei
8a1b9cab67 Add test in ide-completion/src/tests/item_list.rs 2024-07-29 20:40:51 +08:00
Yunfei
59dc1c9b2c Revert "Fix error message"
This reverts commit 752c49b679.
2024-07-29 20:36:03 +08:00
bors
0cbcbb0357 Auto merge of #17715 - Throne3d:fix/glob-may-override-vis-2, r=Veykril
fix: let glob imports override other globs' visibility

Follow up to #14930

Fixes #11858
Fixes #14902
Fixes #17704

I haven't reworked the code here at all - I don't feel confident in the codebase to do so - just rebased it onto the current main branch and fixed conflicts.

I'm not _entirely_ sure I understand the structure of the `check` function in `crates/hir-def/src/nameres` tests. I think the change to the test expectation from #14930 is correct, marking the `crate::reexport::inner` imports with `i`, and I understand it to mean there's a specific token in the import that we can match it to (in this case, `Trait`, `function` and `makro` of `pub use crate::defs::{Trait, function, makro};` respectively), but I had some trouble understanding the meaning of the different parts of `PerNs` to be sure.
Does this make sense?

I tested building and using RA locally with `cargo xtask install` and after this change the documentation for `arrow_array::ArrowPrimitiveType` seems to be picked up correctly!
2024-07-29 12:06:31 +00:00
bors
2c68c9a753 Auto merge of #17722 - joshka:jm/logs, r=Veykril
feat: use vscode log format for client logs

This change updates the log format to use the vscode log format instead
of the custom log format, by replacing the `OutputChannel` with a
`LogOutputChannel` and using the `debug`, `info`, `warn`, and `error`
methods on it. This has the following benefits:

- Each log level now has its own color and the timestamp is in a more
  standard format
- Inspect output (e.g. the log of the config object) is now colored
- Error stack traces are now shown in the output
- The log level is now controlled on the output tab by clicking the gear
  icon and selecting "Debug" or by passing the `--log` parameter to
  vscode. The `trace.extension` setting has been marked as deprecated.

Motivation:
The large uncolored unformatted log output with a large config object logged whenever it changes has always dominated the logs. This subjectively has made it that looking to see what the client is doing has always been a bit disappointing. That said, there's only 17 log messages total in the client. Hopefully by making the logs more visually useful this will encourage adding more appropriate debug level messages in future.

Incidentally, it might be worth only logging the config change message at a debug level instead of an info level to reduce the noise.
2024-07-29 11:52:32 +00:00
Yunfei
f3a1b902fd Cargo fmt 2024-07-29 16:51:49 +08:00
Yunfei
752c49b679 Fix error message 2024-07-29 16:35:19 +08:00
Yunfei
94244a7a11 feat(ide-completion): explictly show async keyword on impl trait 2024-07-29 15:55:21 +08:00
Ali Bektas
5ece296adf Remove unnec copying of source_root_ids 2024-07-29 03:46:02 +02:00
Ali Bektas
f0d595dc77 add skip_slow_tests to ratoml tests 2024-07-29 03:43:27 +02:00
Ali Bektas
e0b6d2f681 Combine krate_ratoml and workspace_ratomls into one 2024-07-29 03:39:47 +02:00
bors
fd74511f34 Auto merge of #17732 - lnicola:sync-from-rust, r=lnicola
minor: sync from downstream
2024-07-28 14:22:27 +00:00
Laurențiu Nicola
900db35537 Merge from rust-lang/rust 2024-07-28 17:19:33 +03:00
Laurențiu Nicola
3e55b5b18f Preparing for merge from rust-lang/rust 2024-07-28 17:19:12 +03:00
bors
cdb97b8b30 Auto merge of #17720 - ThouCheese:fix/doc-to-comment-naming, r=Veykril
flip the naming of the doc comment to comment assist

I did this the wrong way around when I implemented these assists, so here is a quick fix for it
2024-07-28 08:46:34 +00:00
bors
3cf17dcfc6 Auto merge of #17472 - duncanawoods:master, r=HKalbasi
#17470 - run unit tests at the crate level not workspace

For https://github.com/rust-lang/rust-analyzer/issues/17470

Use the test path to identify a package in the workspace and run the unit test there instead of at the workspace.
2024-07-28 08:20:06 +00:00
duncan
20d3237dfa 17470 - run test explorer tests at the package level and add missing extra_test_bin_args settings 2024-07-28 07:43:07 +01:00
huntc
ec7451cc8d Determine toolchain RA on age
Selects a rust-toolchain declared RA based on its date. The earliest (oldest) RA wins and becomes the one that the workspace uses as a whole.

In terms of precedence:

nightly > stable-with-version > stable

With stable-with-version, we invoke the RA with a `--version` arg and attempt to extract a date. Given the same date as a nightly, the nightly RA will win.
2024-07-28 16:09:05 +10:00
Josh McKinney
917ed63095
feat: add trace level to client logs 2024-07-27 21:59:12 -07:00
Josh McKinney
45a881313a
feat: use vscode log format for client logs
This change updates the log format to use the vscode log format instead
of the custom log format, by replacing the `OutputChannel` with a
`LogOutputChannel` and using the `debug`, `info`, `warn`, and `error`
methods on it. This has the following benefits:

- Each log level now has its own color and the timestamp is in a more
  standard format
- Inspect output (e.g. the log of the config object) is now colored
- Error stack traces are now shown in the output
- The log level is now controlled on the output tab by clicking the gear
  icon and selecting "Debug" or by passing the `--log` parameter to
  vscode. The `trace.extension` setting has been marked as deprecated.
2024-07-27 21:43:35 -07:00
Luuk Wester
64ee4d3b1e flip the naming of the doc comment to comment assist 2024-07-28 00:48:08 +02:00
Ali Bektas
d7bedc85b3 Down to 1 failing test
And that is due to a case where we have two ratomls in a source root, one of which
is a `workspace_ratoml` and the other one is simple old ratoml. Since we are not checking to see if
the source root is already populated with workspace ratoml, this test fails. Due to principles of clear
code I believe it is reasonable to not have two HashMaps that are almost for the exact same thing.
So next commit should remove `workspace_ratoml` and merge it with `krate_ratoml`s.
2024-07-27 23:52:40 +02:00
bors
a46788318c Auto merge of #17511 - mckenfra:github_issue_17497_fix_v5, r=flodiebold
#17497 - Invalid RA diagnostic error: expected 2 arguments, found 1

Fix for #17497

The issue occurs because in some configurations of traits where one of them has `Deref` as a supertrait, RA's type inference algorithm fails to resolve the `Deref::Target` type, and instead uses a `TyKind::BoundVar` (i.e. an unknown type). This "autoderefed" type then incorrectly acts as if it implements all traits in scope.

The fix is to re-apply the same sanity-check that is done in [`iterate_method_candidates_with_autoref()`](9463d9eea4/crates/hir-ty/src/method_resolution.rs (L1008)), that is: don't try to resolve methods on unknown types. This same sanity-check is now done on each autoderefed type for which trait methods are about to be checked. If the autoderefed type is unknown, then the iterating of the trait methods for that type is skipped.

Includes a unit test that only passes after applying the fixes in this commit.

Includes a change to the assertion count in test `syntax_highlighting::tests::benchmark_syntax_highlighting_parser` as suggested by Lukas Wirth during review.

Includes a change to the sanity-check code as suggested by Florian Diebold during review.
2024-07-27 17:02:03 +00:00
Francis McKenzie
e77752eaf0 Fix for #17497 - Invalid RA diagnostic error: expected 2 arguments, found 1
The issue occurs because in some configurations of traits where one of them has Deref as a supertrait, RA's type inference algorithm fails to resolve the Deref::Target type, and instead uses a TyKind::BoundVar (i.e. an unknown type). This "autoderefed" type then incorrectly acts as if it implements all traits in scope.

The fix is to re-apply the same sanity-check that is done in iterate_method_candidates_with_autoref(), that is: don't try to resolve methods on unknown types. This same sanity-check is now done on each autoderefed type for which trait methods are about to be checked. If the autoderefed type is unknown, then the iterating of the trait methods for that type is skipped.

Includes a unit test that only passes after applying the fixes in this commit.

Includes a change to the assertion count in test syntax_highlighting::tests::benchmark_syntax_highlighting_parser as suggested by Lukas Wirth during review.

Includes a change to the sanity-check code as suggested by Florian Diebold during review.
2024-07-28 00:32:37 +08:00
bors
9fcaab3704 Auto merge of #17714 - Throne3d:patch-1, r=Veykril
docs: Reference cov_mark crate instead of test_utils/mark

Seems this was switched over in https://github.com/rust-lang/rust-analyzer/issues/7922

I'm guessing this should skip the changelog because it's so minor, right? Reading through https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/style.md and trying to get up to speed here =)
2024-07-27 04:33:24 +00:00
bors
072d7107bc Auto merge of #17713 - alibektas:17710, r=Veykril
fix: early exit if unresolved field is an index

Fixes #17710
2024-07-27 04:19:09 +00:00
Ryo Yoshida
fdb367ab89 fix: let glob imports override other globs' visibility 2024-07-27 00:10:53 -03:00
Edward Jones
d10cdd25e7
docs: Reference cov_mark crate instead of test_utils/mark
Seems this was switched over in https://github.com/rust-lang/rust-analyzer/issues/7922
2024-07-26 22:49:11 -03:00
Ali Bektas
480db310b6 early exit if unresolved field is an index 2024-07-26 22:44:47 +02:00
bors
aae54dde8c Auto merge of #17709 - Young-Flash:hover_tooltip, r=Veykril
fix: tweak hover/tooltip links

close https://github.com/rust-lang/rust-analyzer/issues/17628
2024-07-26 16:12:50 +00:00
Young-Flash
38817263e4 fix: tweak hover/tooltip links 2024-07-26 23:13:55 +08:00
Lukas Wirth
7beac14cba Internal: Cleanup proc-macro error handling 2024-07-26 14:38:19 +02:00
bors
f46af90ba8 Auto merge of #17706 - Veykril:fragment-include-fix, r=Veykril
fix: Fix includes not working with expr fragment inputs

Temporary workaround for https://github.com/rust-lang/rust-analyzer/issues/17701
2024-07-26 08:13:29 +00:00
Lukas Wirth
df15b6f668 fix: Fix includes not working with expr fragment inputs 2024-07-26 10:12:06 +02:00
Ali Bektas
1aece03d16 Globals too are asking for sourcerootid 2024-07-26 03:04:29 +02:00
Ali Bektas
c4c6b64976 Turn root_ratoml into workspace_ratomls 2024-07-26 02:38:02 +02:00
bors
d401839753 Auto merge of #127042 - GrigorenkoPV:derivative, r=compiler-errors
Switch from `derivative` to `derive-where`

This is a part of the effort to get rid of `syn 1.*` in compiler's dependencies: #109302

Derivative has not been maintained in nearly 3 years[^1]. It also depends on `syn 1.*`.

This PR replaces `derivative` with `derive-where`[^2], a not dead alternative, which uses `syn 2.*`.

A couple of `Debug` formats have changed around the skipped fields[^3], but I doubt this is an issue.

[^1]: https://github.com/mcarton/rust-derivative/issues/117
[^2]: https://lib.rs/crates/derive-where
[^3]: See the changes in `tests/ui`
2024-07-25 22:50:58 +00:00
bors
8eba6960d5 Auto merge of #126963 - runtimeverification:smir_serde_derive, r=celinval
Add basic Serde serialization capabilities to Stable MIR

This PR adds basic Serde serialization capabilities to Stable MIR. It is intentionally minimal (just wrapping all stable MIR types with a Serde `derive`), so that any important design decisions can be discussed before going further. A simple test is included with this PR to validate that JSON can actually be emitted.

## Notes

When I wrapped the Stable MIR error types in `compiler/stable_mir/src/error.rs`, it caused test failures (though I'm not sure why) so I backed those out.

## Future Work

So, this PR will support serializing basic stable MIR, but it _does not_ support serializing interned values beneath `Ty`s and `AllocId`s, etc... My current thinking about how to handle this is as follows:

1.  Add new `visited_X` fields to the `Tables` struct for each interned category of interest.

2.  As serialization is occuring, serialize interned values as usual _and_ also record the interned value we referenced in `visited_X`.

    (Possibly) In addition, if an interned value recursively references other interned values, record those interned values as well.

3.  Teach the stable MIR `Context` how to access the `visited_X` values and expose them with wrappers in `stable_mir/src/lib.rs` to users (e.g. to serialize and/or further analyze them).

### Pros

This approach does not commit to any specific serialization format regarding interned values or other more complex cases, which avoids us locking into any behaviors that may not be desired long-term.

### Cons

The user will need to manually handle serializing interned values.

### Alternatives

1.  We can directly provide access to the underlying `Tables` maps for interned values; the disadvantage of this approach is that it either requires extra processing for users to filter out to only use the values that they need _or_ users may serialize extra values that they don't need. The advantage is that the implementation is even simpler. The other pros/cons are similar to the above.

2.  We can directly serialize interned values by expanding them in-place. The pro is that this may make some basic inputs easier to consume. However, the cons are that there will need to be special provisions for dealing with cyclical values on both the producer and consumer _and_ global values will possibly need to be de-duplicated on the consumer side.
2024-07-25 20:27:51 +00:00
bors
c02a4a31ea Auto merge of #17698 - Veykril:remove-trace, r=Veykril
internal: Remove unused trace module
2024-07-25 12:10:30 +00:00
Lukas Wirth
d32e60467f Remove unused trace module 2024-07-25 14:08:48 +02:00
bors
0ba6f4eda0 Auto merge of #17676 - winstxnhdw:precise-capturing, r=Veykril
feat: add preliminary support for `+ use<..>` `precise_capturing` syntax

## Summary

This PR adds basic support for the following syntax.

```rs
fn captures<'a: 'a, 'b: 'b, T>() -> impl Sized + use<'b, T> {}
//                                  ~~~~~~~~~~~~~~~~~~~~~~~
//                          This opaque type does not capture `'a`.

fn outlives<'o, T: 'o>(_: T) {}

fn caller<'o, 'a, 'b: 'o, T: 'o>() {
    //        ~~
    //        ^ Note that we don't need `'a: 'o`.
    outlives::<'o>(captures::<'a, 'b, T>());
}
```

Related to #17598
2024-07-25 11:10:56 +00:00
Winston H.
9f74787d5d fix: handle new TypeBoundKind variant 2024-07-25 10:58:25 +00:00
bors
fa5ff86e04 Auto merge of #17697 - Veykril:cargo-env, r=Veykril
fix: Support new cargo config get env format

Fixes https://github.com/rust-lang/rust-analyzer/issues/17686
2024-07-25 10:30:03 +00:00
Lukas Wirth
c7d6fe5257 fix: Support new cargo config get env format 2024-07-25 12:28:31 +02:00
bors
cddce62237 Auto merge of #17695 - Veykril:typeref-size, r=Veykril
internal: Reduce size of TypeRef by 8 bytes
2024-07-25 09:52:30 +00:00
Lukas Wirth
0e93e6fee7 Make legacy_const_generics_indices thin by double boxing as its seldom used 2024-07-25 11:51:15 +02:00
Lukas Wirth
7f884487d7 Reduce size of TypeRef by 8 bytes 2024-07-25 11:14:55 +02:00
bors
42facc20c6 Auto merge of #17693 - Veykril:astidmap, r=Veykril
Remove Params and Fields from AstIdMap

These are too volatile, and the only reason for them seems to be for cfg diagnostics which does not carry the weight
2024-07-25 09:06:34 +00:00