]> git.lizzy.rs Git - rust.git/log
rust.git
22 months agoAuto merge of #13058 - dpaoliello:extraenv, r=Veykril
bors [Sun, 18 Sep 2022 17:43:46 +0000 (17:43 +0000)]
Auto merge of #13058 - dpaoliello:extraenv, r=Veykril

Add a new configuration settings to set env vars when running cargo, rustc, etc. commands: cargo.extraEnv and checkOnSave.extraEnv

It can be extremely useful to be able to set environment variables when rust-analyzer is running various cargo or rustc commands (such as `cargo check`, `cargo --print cfg` or `cargo metadata`): users may want to set custom `RUSTFLAGS`, change `PATH` to use a custom toolchain or set a different `CARGO_HOME`.

There is the existing `server.extraEnv` setting that allows env vars to be set when the rust-analyzer server is launched, but using this as the recommended mechanism to also configure cargo/rust has some drawbacks:
- It convolutes configuring the rust-analyzer server with configuring cargo/rustc (one may want to change the `PATH` for cargo/rustc without affecting the rust-analyzer server).
- The name `server.extraEnv` doesn't indicate that cargo/rustc will be affected but renaming it to `cargo.extraEnv` doesn't indicate that the rust-analyzer server would be affected.
- To make the setting useful, it needs to be dynamically reloaded without requiring that the entire extension is reloaded. It might be possible to do this, but it would require the client communicating to the server what the overwritten env vars were at first launch, which isn't easy to do.

This change adds two new configuration settings: `cargo.extraEnv` and `checkOnSave.extraEnv` that can be used to change the environment for the rust-analyzer server after launch (thus affecting any process that rust-analyzer invokes) and the `cargo check` command respectively. `cargo.extraEnv` supports dynamic changes by keeping track of the pre-change values of environment variables, thus it can undo changes made previously before applying the new configuration (and then requesting a workspace reload).

22 months agoAuto merge of #13239 - mdx97:mathew/fix-add-reference-for-macros, r=Veykril
bors [Sat, 17 Sep 2022 11:23:05 +0000 (11:23 +0000)]
Auto merge of #13239 - mdx97:mathew/fix-add-reference-for-macros, r=Veykril

Fix add reference action on macros.

Before we were using the range of the corresponding expression node in the macro expanded file, which is obviously incorrect as we are setting the text in the original source.

For some reason, the test I added is failing and I haven't found a way to fix it. Does anyone know why `check_fix` wouldn't work with macros? Getting this error:

```text
thread 'handlers::type_mismatch::tests::test_add_reference_to_macro_call' panicked at 'no diagnostics', crates/ide-diagnostics/src/handlers/type_mismatch.rs:317:9
```

closes #13219

22 months agoAdd functionality to unwrap tuple declarations
harudagondi [Sat, 17 Sep 2022 07:57:45 +0000 (15:57 +0800)]
Add functionality to unwrap tuple declarations

22 months agoFix tests by using primitive rather than String.
Mathew Horner [Fri, 16 Sep 2022 21:56:19 +0000 (16:56 -0500)]
Fix tests by using primitive rather than String.

22 months agoAuto merge of #13243 - Veykril:search-memchr, r=Veykril
bors [Fri, 16 Sep 2022 14:28:12 +0000 (14:28 +0000)]
Auto merge of #13243 - Veykril:search-memchr, r=Veykril

Use memmem when searching for usages in ide-db

We already have this dependency, so there is no reason not to use it as it is generally faster than std in our use case.

22 months agoUse memmem when searching for usages in ide-db
Lukas Wirth [Fri, 16 Sep 2022 14:26:54 +0000 (16:26 +0200)]
Use memmem when searching for usages in ide-db

22 months agoAuto merge of #13242 - Veykril:completion-alias, r=Veykril
bors [Fri, 16 Sep 2022 14:12:26 +0000 (14:12 +0000)]
Auto merge of #13242 - Veykril:completion-alias, r=Veykril

Complete variants and assoc items in path pattern through type aliases

22 months agoComplete variants and assoc items in path pattern through type aliases
Lukas Wirth [Fri, 16 Sep 2022 14:11:58 +0000 (16:11 +0200)]
Complete variants and assoc items in path pattern through type aliases

22 months agoFix add reference action on macros.
Mathew Horner [Fri, 16 Sep 2022 01:25:29 +0000 (20:25 -0500)]
Fix add reference action on macros.

22 months agoAuto merge of #13235 - Veykril:prelude-handling, r=Veykril
bors [Thu, 15 Sep 2022 10:13:11 +0000 (10:13 +0000)]
Auto merge of #13235 - Veykril:prelude-handling, r=Veykril

Fix prelude injection

Fixes the regression of unknown types introduced in https://github.com/rust-lang/rust-analyzer/pull/13175

22 months agoFix prelude injection
Lukas Wirth [Thu, 15 Sep 2022 10:12:22 +0000 (12:12 +0200)]
Fix prelude injection

22 months agoAuto merge of #13232 - jplatte:mbe-refactor, r=Veykril
bors [Wed, 14 Sep 2022 22:39:31 +0000 (22:39 +0000)]
Auto merge of #13232 - jplatte:mbe-refactor, r=Veykril

Refactor macro-by-example code

I had a look at the MBE code because of #7857. I found some easy readability wins, that might also _marginally_ improve perf.

22 months agombe: Remove unneeded unwrap
Jonas Platte [Wed, 14 Sep 2022 21:49:08 +0000 (23:49 +0200)]
mbe: Remove unneeded unwrap

22 months agombe: Remove unnecessary reference to usize
Jonas Platte [Wed, 14 Sep 2022 21:42:11 +0000 (23:42 +0200)]
mbe: Remove unnecessary reference to usize

22 months agombe: Remove Vec reference in container
Jonas Platte [Wed, 14 Sep 2022 21:35:12 +0000 (23:35 +0200)]
mbe: Remove Vec reference in container

22 months agombe: Remove double reference in container
Jonas Platte [Wed, 14 Sep 2022 21:30:44 +0000 (23:30 +0200)]
mbe: Remove double reference in container

22 months agombe: Use extend instead of push in loop
Jonas Platte [Wed, 14 Sep 2022 21:26:24 +0000 (23:26 +0200)]
mbe: Use extend instead of push in loop

22 months agombe: Return Bindings from build_inner
Jonas Platte [Wed, 14 Sep 2022 21:22:38 +0000 (23:22 +0200)]
mbe: Return Bindings from build_inner

22 months agoAdd cargo.extraEnv setting
Daniel Paoliello [Thu, 18 Aug 2022 21:41:17 +0000 (14:41 -0700)]
Add cargo.extraEnv setting

22 months agoAuto merge of #13221 - mdx97:mdx97/annotations-above-whole-item, r=Veykril
bors [Tue, 13 Sep 2022 15:09:53 +0000 (15:09 +0000)]
Auto merge of #13221 - mdx97:mdx97/annotations-above-whole-item, r=Veykril

Allow configuration of annotation location.

I've added the ability to configure where lens annotations render relevant to the item they describe. Previously, these would render directly above the line the item is declared on. Now, there is the ability to render these annotations above the entire item (including doc comments, and attributes).

The names of the config options are up for debate, I did what seemed best to me but if anyone has better ideas let me know.

This is my first contribution so if I've missed anything please let me know.

Here's a preview of what the new option looks like:

<img width="577" alt="Screen Shot 2022-09-11 at 10 39 51 PM" src="https://user-images.githubusercontent.com/33100798/189570298-b4fcbf9c-ee49-4b79-aae6-1037ae4f26af.png">

closes https://github.com/rust-lang/rust-analyzer/issues/13218

22 months agoAuto merge of #13225 - lowr:fix/hir-proj-normalization, r=Veykril
bors [Tue, 13 Sep 2022 14:52:58 +0000 (14:52 +0000)]
Auto merge of #13225 - lowr:fix/hir-proj-normalization, r=Veykril

fixup: remove unnecessary `Option`

Fixup for #13223, two things:

- `normalize_projection_query()` (and consequently `HirDatabase::normalize_projection()`) never returns `None` (well, it used to when I first wrote it...), so just return `Ty` instead of `Option<Ty>`
- When chalk cannot normalize projection uniquely, `normalize_trait_assoc_type()` used to return `None` before #13223, but not anymore because of the first point. I restored the behavior so its callers work as before.

22 months agoAuto merge of #13227 - Veykril:core-pref, r=Veykril
bors [Tue, 13 Sep 2022 13:16:57 +0000 (13:16 +0000)]
Auto merge of #13227 - Veykril:core-pref, r=Veykril

Restructure `find_path` into a separate functions for modules and non-module items

Follow up to https://github.com/rust-lang/rust-analyzer/pull/13212
Also renames `prefer_core` imports config to `prefer_no_std` and changes the behavior of no_std path searching by preferring `core` paths `over` alloc

This PR turned into a slight rewrite, so it unfortunately does a few more things that I initially planned to (including a bug fix for enum variant paths)

22 months agoRestructure `find_path` into a separate functions for modules and non-module items
Lukas Wirth [Tue, 13 Sep 2022 13:09:40 +0000 (15:09 +0200)]
Restructure `find_path` into a separate functions for modules and non-module items

Also renames `prefer_core` imports config to `prefer_no_std` and changes the behavior of no_std path searching by preferring `core` paths `over` alloc

22 months agoAuto merge of #13228 - Veykril:ref-import-filtering, r=Veykril
bors [Tue, 13 Sep 2022 12:59:20 +0000 (12:59 +0000)]
Auto merge of #13228 - Veykril:ref-import-filtering, r=Veykril

Move reference imports filtering into to_proto layer

Follow up to https://github.com/rust-lang/rust-analyzer/pull/13186

22 months agoMove reference imports filtering into to_proto layer
Lukas Wirth [Tue, 13 Sep 2022 12:47:26 +0000 (14:47 +0200)]
Move reference imports filtering into to_proto layer

22 months agoAddress comments and fix build.
Mathew Horner [Mon, 12 Sep 2022 21:34:13 +0000 (16:34 -0500)]
Address comments and fix build.

22 months agoFixed lints
OleStrohm [Mon, 12 Sep 2022 20:27:19 +0000 (21:27 +0100)]
Fixed lints

22 months agoRebased
OleStrohm [Mon, 12 Sep 2022 20:02:30 +0000 (21:02 +0100)]
Rebased

22 months agoCleaned up code based on feedback
OleStrohm [Mon, 12 Sep 2022 17:45:51 +0000 (18:45 +0100)]
Cleaned up code based on feedback

22 months agoAdded more consteval tests and fixed consteval result
OleStrohm [Sun, 7 Aug 2022 16:42:59 +0000 (18:42 +0200)]
Added more consteval tests and fixed consteval result

22 months agoAdded consteval tests
OleStrohm [Sun, 7 Aug 2022 16:22:18 +0000 (18:22 +0200)]
Added consteval tests

22 months agoAlmost there
OleStrohm [Sat, 6 Aug 2022 20:12:33 +0000 (22:12 +0200)]
Almost there

22 months agoCleaned up code
OleStrohm [Sat, 6 Aug 2022 17:12:57 +0000 (19:12 +0200)]
Cleaned up code

22 months agoRemoved unnecessary TODO
OleStrohm [Sat, 6 Aug 2022 16:52:35 +0000 (18:52 +0200)]
Removed unnecessary TODO

22 months agoImplemented basic enum const eval
OleStrohm [Sat, 6 Aug 2022 16:50:21 +0000 (18:50 +0200)]
Implemented basic enum const eval

22 months agoAdd tests for type inference for generators
Ryo Yoshida [Fri, 9 Sep 2022 06:27:25 +0000 (15:27 +0900)]
Add tests for type inference for generators

22 months agoImplement `RustIrDatabase::generator_datum()`
Ryo Yoshida [Fri, 9 Sep 2022 06:25:42 +0000 (15:25 +0900)]
Implement `RustIrDatabase::generator_datum()`

22 months agoImplement type inference for generator and yield expressions
Ryo Yoshida [Tue, 6 Sep 2022 08:48:06 +0000 (17:48 +0900)]
Implement type inference for generator and yield expressions

22 months agoRemove unnecessary `Option`
Ryo Yoshida [Mon, 12 Sep 2022 16:52:16 +0000 (01:52 +0900)]
Remove unnecessary `Option`

22 months agoAuto merge of #13216 - DesmondWillowbrook:move_format_string_arg, r=DesmondWillowbrook
bors [Mon, 12 Sep 2022 15:50:42 +0000 (15:50 +0000)]
Auto merge of #13216 - DesmondWillowbrook:move_format_string_arg, r=DesmondWillowbrook

New assist: move_format_string_arg

The name might need some improving.

```rust
fn main() {
    print!("{x + 1}");
}
```
to
```rust
fn main() {
    print!("{}"$0, x + 1);
}
```

fixes #13180

ref to #5988 for similar work

* extracted `format_like`'s parser to it's own module in `ide-db`
* reworked the parser's API to be more direct
* added assist to extract expressions in format args

22 months agoAuto merge of #13223 - lowr:fix/hir-proj-normalization, r=flodiebold
bors [Mon, 12 Sep 2022 14:24:57 +0000 (14:24 +0000)]
Auto merge of #13223 - lowr:fix/hir-proj-normalization, r=flodiebold

fix: handle lifetime variables in projection normalization

Fixes #12674

The problem is that we've been skipping the binders of normalized projections assuming they should be empty, but the assumption is unfortunately wrong. We may get back lifetime variables and should handle them before returning them as normalized projections. For those who are curious why we get those even though we treat all lifetimes as 'static, [this comment in chalk](https://github.com/rust-lang/chalk/blob/d875af0ff196dd6430b5f5fd87a640fa5ab59d1e/chalk-solve/src/infer/unify.rs#L888-L908) may be interesting.

I thought using `InferenceTable` would be cleaner than the other ways as it already has the methods for canonicalization, normalizing projection, and resolving variables, so moved goal building and trait solving logic to a new `HirDatabase` query. I made it transparent query as the query itself doesn't do much work but the eventual call to `HirDatabase::trait_solve_query()` does.

22 months agofix: handle lifetime variables in projection normalization
Ryo Yoshida [Mon, 12 Sep 2022 12:56:46 +0000 (21:56 +0900)]
fix: handle lifetime variables in projection normalization

22 months agoAuto merge of #13215 - Veykril:toggle-inlay, r=Veykril
bors [Mon, 12 Sep 2022 13:45:25 +0000 (13:45 +0000)]
Auto merge of #13215 - Veykril:toggle-inlay, r=Veykril

Remove the toggleInlayHints command from VSCode

Inlay hints are no longer something specifc to r-a as it has been upstreamed into the LSP, we don't have a reason to give the config for this feature special treatment in regards to toggling. There are plenty of other options out there in the VSCode marketplace to create toggle commands/hotkeys for configurations in general which I believe we should nudge people towards instead.

22 months agoUpdate crates/ide-assists/src/handlers/move_format_string_arg.rs
Kartavya Vashishtha [Mon, 12 Sep 2022 12:45:11 +0000 (05:45 -0700)]
Update crates/ide-assists/src/handlers/move_format_string_arg.rs

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
22 months agoAuto merge of #13147 - lowr:fix/dyn-ty-inherent-methods, r=Veykril
bors [Mon, 12 Sep 2022 12:19:14 +0000 (12:19 +0000)]
Auto merge of #13147 - lowr:fix/dyn-ty-inherent-methods, r=Veykril

fix: handle trait methods as inherent methods for trait-related types

Fixes #10677

When resolving methods for trait object types and placeholder types that are bounded by traits, we need to count the methods of the trait and its super traits as inherent methods. This matters because these trait methods have higher priority than the other traits' methods.

Relevant code in rustc: [`assemble_inherent_candidates_from_object()`](https://github.com/rust-lang/rust/blob/0631ea5d73f4a3199c776687b12c20c50a91f0d2/compiler/rustc_typeck/src/check/method/probe.rs#L783-L792) for trait object types, [`assemble_inherent_candidates_from_param()`](https://github.com/rust-lang/rust/blob/0631ea5d73f4a3199c776687b12c20c50a91f0d2/compiler/rustc_typeck/src/check/method/probe.rs#L838-L847) for placeholder types. Notice the second arg of `push_candidate()` is `is_inherent`.

22 months agoAuto merge of #13186 - enomado:master, r=Veykril
bors [Mon, 12 Sep 2022 12:09:57 +0000 (12:09 +0000)]
Auto merge of #13186 - enomado:master, r=Veykril

Filter imports on find-all-references

Attempt to #13184

22 months agoAuto merge of #13212 - Veykril:no-std-config, r=Veykril
bors [Mon, 12 Sep 2022 11:51:31 +0000 (11:51 +0000)]
Auto merge of #13212 - Veykril:no-std-config, r=Veykril

Add config to unconditionally prefer core imports over std

Fixes https://github.com/rust-lang/rust-analyzer/issues/12979

22 months agoAuto merge of #13222 - BorysMinaiev:master, r=flodiebold
bors [Mon, 12 Sep 2022 11:30:24 +0000 (11:30 +0000)]
Auto merge of #13222 - BorysMinaiev:master, r=flodiebold

Remove redundant 'resolve_obligations_as_possible' call

Hi! I was looking for a "good first issue" and saw this one: https://github.com/rust-lang/rust-analyzer/issues/7542. I like searching for performance improvements, so I wanted to try to find something useful there.

There are two tests in integrated_benchmarks.rs, I looked at 'integrated_highlighting_benchmark' (not the one discussed in the issue above).

Profile from that test looks like this:
```
$ RUN_SLOW_BENCHES=1 cargo test --release --package rust-analyzer --lib -- integrated_benchmarks::integrated_highlighting_benchmark --exact --nocapture
    Finished release [optimized] target(s) in 0.06s
     Running unittests src/lib.rs (target/release/deps/rust_analyzer-a80ca6bb8f877458)

running 1 test
workspace loading: 358.45ms
initial: 9.60s
change: 13.96µs
cpu profiling is disabled, uncomment `default = [ "cpu_profiler" ]` in Cargo.toml to enable.
  273ms - highlight
      143ms - infer:wait @ per_query_memory_usage
          143ms - infer_query
                0   - crate_def_map:wait (3165 calls)
                4ms - deref_by_trait (967 calls)
               96ms - resolve_obligations_as_possible (22106 calls)
                0   - trait_solve::wait (2068 calls)
       21ms - Semantics::analyze_impl (18 calls)
        0   - SourceBinder::to_module_def (20 calls)
       36ms - classify_name (19 calls)
       19ms - classify_name_ref (308 calls)
        0   - crate_def_map:wait (461 calls)
        4ms - descend_into_macros (628 calls)
        0   - generic_params_query (4 calls)
        0   - impl_data_with_diagnostics_query (1 calls)
       45ms - infer:wait (37 calls)
        0   - resolve_obligations_as_possible (2 calls)
        0   - source_file_to_def (1 calls)
        0   - trait_solve::wait (42 calls)
after change: 275.23ms
test integrated_benchmarks::integrated_highlighting_benchmark ... ok
```
22106 calls to `resolve_obligations_as_possible` seem like the main issue there.

One thing I noticed (and fixed in this PR) is that `InferenceContext::resolve_ty_shallow` first calls `resolve_obligations_as_possible`, and then calls `InferenceTable::resolve_ty_shallow`. But `InferenceTable::resolve_ty_shallow` [inside](https://github.com/rust-lang/rust-analyzer/blob/2e9f1204ca01c3e20898d4a67c8b84899d394a88/crates/hir-ty/src/infer/unify.rs#L372) again calls `resolve_obligations_as_possible`.

`resolve_obligations_as_possible` inside has a while loop, which works until it can't find any helpful information. So calling this function for the second time does nothing, so one of the calls could be safely removed.

`InferenceContext::resolve_ty_shallow` is actually quite a hot place, and after fixing it, the total number of `resolve_obligations_as_possible` in this test is reduced to 15516 (from 22106). "After change" time also improves from ~270ms to ~240ms, which is not a very huge win, but still something measurable.

Same profile after PR:
```
$ RUN_SLOW_BENCHES=1 cargo test --release --package rust-analyzer --lib -- integrated_benchmarks::integrated_highlighting_benchmark --exact --nocapture
    Finished release [optimized] target(s) in 0.06s
     Running unittests src/lib.rs (target/release/deps/rust_analyzer-a80ca6bb8f877458)

running 1 test
workspace loading: 339.86ms
initial: 9.28s
change: 10.69µs
cpu profiling is disabled, uncomment `default = [ "cpu_profiler" ]` in Cargo.toml to enable.
  236ms - highlight
      110ms - infer:wait @ per_query_memory_usage
          110ms - infer_query
                0   - crate_def_map:wait (3165 calls)
                4ms - deref_by_trait (967 calls)
               64ms - resolve_obligations_as_possible (15516 calls)
                0   - trait_solve::wait (2068 calls)
       21ms - Semantics::analyze_impl (18 calls)
        0   - SourceBinder::to_module_def (20 calls)
       34ms - classify_name (19 calls)
       18ms - classify_name_ref (308 calls)
        0   - crate_def_map:wait (461 calls)
        3ms - descend_into_macros (628 calls)
        0   - generic_params_query (4 calls)
        0   - impl_data_with_diagnostics_query (1 calls)
       45ms - infer:wait (37 calls)
        0   - resolve_obligations_as_possible (2 calls)
        0   - source_file_to_def (1 calls)
        0   - trait_solve::wait (42 calls)
after change: 238.15ms
test integrated_benchmarks::integrated_highlighting_benchmark ... ok
```

The performance of this test could be further improved but at the cost of making code more complicated, so I wanted to check if such a change is desirable before sending another PR.

`resolve_obligations_as_possible` is actually called a lot of times even when no new information was provided. As I understand, `resolve_obligations_as_possible` could do something useful only if some variables/values were unified since the last check. We can store a boolean variable inside `InferenceTable`, which indicates if `try_unify` was called after last `resolve_obligations_as_possible`. If it wasn't called, we can safely not call `resolve_obligations_as_possible` again.

I tested this change locally, and it reduces the number of `resolve_obligations_as_possible` to several thousand (it is not shown in the profile anymore, so don't know the exact number), and the total time is reduced to ~180ms. Here is a generated profile:
```
$ RUN_SLOW_BENCHES=1 cargo test --release --package rust-analyzer --lib -- integrated_benchmarks::integrated_highlighting_benchmark --exact --nocapture
    Finished release [optimized] target(s) in 0.06s
     Running unittests src/lib.rs (target/release/deps/rust_analyzer-a80ca6bb8f877458)

running 1 test
workspace loading: 349.92ms
initial: 8.56s
change: 11.32µs
cpu profiling is disabled, uncomment `default = [ "cpu_profiler" ]` in Cargo.toml to enable.
  175ms - highlight
       21ms - Semantics::analyze_impl (18 calls)
        0   - SourceBinder::to_module_def (20 calls)
       33ms - classify_name (19 calls)
       17ms - classify_name_ref (308 calls)
        0   - crate_def_map:wait (461 calls)
        3ms - descend_into_macros (628 calls)
        0   - generic_params_query (4 calls)
        0   - impl_data_with_diagnostics_query (1 calls)
       97ms - infer:wait (38 calls)
        0   - resolve_obligations_as_possible (2 calls)
        0   - source_file_to_def (1 calls)
        0   - trait_solve::wait (42 calls)
after change: 177.04ms
test integrated_benchmarks::integrated_highlighting_benchmark ... ok
```
Let me know if adding a new bool field seems like a reasonable tradeoff, so I can send a PR.

22 months agoRemove redundant 'resolve_obligations_as_possible' call
Borys Minaiev [Mon, 12 Sep 2022 10:03:44 +0000 (11:03 +0100)]
Remove redundant 'resolve_obligations_as_possible' call

22 months agoAllow configuration of annotation location.
Mathew Horner [Mon, 12 Sep 2022 03:40:33 +0000 (22:40 -0500)]
Allow configuration of annotation location.

Previously, annotations would only appear above the name of an item (function signature, struct declaration, etc).

Now, rust-analyzer can be configured to show annotations either above the name or above the whole item (including doc comments and attributes).

22 months agoAuto merge of #13214 - SpencerSharkey:ubuntu-container-build, r=lnicola
bors [Sun, 11 Sep 2022 11:34:25 +0000 (11:34 +0000)]
Auto merge of #13214 - SpencerSharkey:ubuntu-container-build, r=lnicola

Build release artifact against older Glibc

When GitHub [deprecated Ubuntu 18.04](https://github.blog/changelog/2022-08-09-github-actions-the-ubuntu-18-04-actions-runner-image-is-being-deprecated-and-will-be-removed-by-12-1-22/) runners, rust-analyzer was forced to bump runners to 20.04 which includes an updated Glib. This renders RA incompatible with the still popular Ubuntu 18.04 and other slightly older distro versions.

Until a deprecation plan is announced on RA's side, I propose binaries shall be built against older glibc to maintain compatibility.

This PR changes the Release CI workflow to build the `linux-x64/x86_64-unknown-linux-gnu` release in an Ubuntu 18.04 container.

Fixes #13081 and #13085

22 months agouse rustup minimal profile and add curl retries
Spencer [Sun, 11 Sep 2022 06:43:33 +0000 (23:43 -0700)]
use rustup minimal profile and add curl retries

22 months agoadd rustup bin to path
Spencer [Sun, 11 Sep 2022 06:29:15 +0000 (23:29 -0700)]
add rustup bin to path

22 months agoinstall rustup directly
Spencer [Sun, 11 Sep 2022 06:25:30 +0000 (23:25 -0700)]
install rustup directly

22 months agosuggest ExtractRefactor if no expressions found
Kartavya Vashishtha [Sun, 11 Sep 2022 05:09:25 +0000 (10:39 +0530)]
suggest ExtractRefactor if no expressions found

Added `Ident` variant to arg enum.

22 months agorevert conditional logic for apt update step
Spencer [Sun, 11 Sep 2022 01:10:56 +0000 (18:10 -0700)]
revert conditional logic for apt update step

22 months agoremove false positive
Kartavya Vashishtha [Sat, 10 Sep 2022 15:34:25 +0000 (21:04 +0530)]
remove false positive

22 months agonew lint: move_format_string_arg
Kartavya Vashishtha [Sat, 10 Sep 2022 14:42:47 +0000 (20:12 +0530)]
new lint: move_format_string_arg

The name might need some improving.

extract format_like's parser to it's own module in ide-db

reworked the parser's API to be more direct

added assist to extract expressions in format args

22 months agowip
Kartavya Vashishtha [Sat, 10 Sep 2022 13:36:50 +0000 (19:06 +0530)]
wip

22 months agoRemove the toggleInlayHints command from VSCode
Lukas Wirth [Sat, 10 Sep 2022 09:50:55 +0000 (11:50 +0200)]
Remove the toggleInlayHints command from VSCode

Inlay hints are no longer something specifc to r-a as it has been
upstreamed into the LSP, we don't have a reason to give the config
for this feature special treatment in regards to toggling. There are
plenty of other options out there in the VSCode marketplace to create
toggle commands/hotkeys for configurations in general which I believe
we should nudge people towards instead.

22 months agouse ubuntu 18.04 container for release
Spencer Sharkey [Fri, 9 Sep 2022 05:29:08 +0000 (22:29 -0700)]
use ubuntu 18.04 container for release

22 months agoAdd config to unconditionally prefer core imports over std
Lukas Wirth [Fri, 9 Sep 2022 18:04:56 +0000 (20:04 +0200)]
Add config to unconditionally prefer core imports over std

Fixes https://github.com/rust-lang/rust-analyzer/issues/12979

22 months agofixes
Stanislav [Fri, 9 Sep 2022 17:58:06 +0000 (20:58 +0300)]
fixes

22 months agoAdd `TyBuilder` method to build `Substitution` for generator
Ryo Yoshida [Fri, 9 Sep 2022 06:20:18 +0000 (15:20 +0900)]
Add `TyBuilder` method to build `Substitution` for generator

22 months agoLower generator expression to HIR
Ryo Yoshida [Mon, 5 Sep 2022 13:43:26 +0000 (22:43 +0900)]
Lower generator expression to HIR

22 months agoAuto merge of #13207 - randomicon00:semicol#13196, r=lnicola
bors [Fri, 9 Sep 2022 04:15:20 +0000 (04:15 +0000)]
Auto merge of #13207 - randomicon00:semicol#13196, r=lnicola

fix: add semicolon completion to mod

fixes #13196

`@Veykril` The tests are passing. I added one specifically for this case.

22 months agofix. round 4
Stanislav [Thu, 8 Sep 2022 22:19:34 +0000 (01:19 +0300)]
fix. round 4

22 months agofix: removed swap file
Peh [Thu, 8 Sep 2022 21:44:10 +0000 (22:44 +0100)]
fix: removed swap file

22 months agofix: add semicolon completion to mod
Peh [Thu, 8 Sep 2022 21:37:31 +0000 (22:37 +0100)]
fix: add semicolon completion to mod

22 months agofix comment round 3
Stanislav [Thu, 8 Sep 2022 19:55:04 +0000 (22:55 +0300)]
fix comment round 3

22 months agofix comment round 2
Stanislav [Thu, 8 Sep 2022 19:47:39 +0000 (22:47 +0300)]
fix comment round 2

22 months agofix comment
Stanislav [Thu, 8 Sep 2022 19:36:36 +0000 (22:36 +0300)]
fix comment

22 months agoAuto merge of #13158 - jonas-schievink:inlayhint-links, r=jonas-schievink
bors [Thu, 8 Sep 2022 16:38:40 +0000 (16:38 +0000)]
Auto merge of #13158 - jonas-schievink:inlayhint-links, r=jonas-schievink

feat: make clicking a closing brace inlay hint go to the opening brace

22 months agoUpdate crates/rust-analyzer/src/to_proto.rs
Jonas Schievink [Thu, 8 Sep 2022 16:33:53 +0000 (18:33 +0200)]
Update crates/rust-analyzer/src/to_proto.rs

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
22 months agoMake clicking closing brace hint go to the opening brace
Jonas Schievink [Wed, 31 Aug 2022 16:54:19 +0000 (18:54 +0200)]
Make clicking closing brace hint go to the opening brace

22 months agoadd config for import filtering
Stanislav [Wed, 7 Sep 2022 22:53:20 +0000 (01:53 +0300)]
add config for import filtering

23 months agoAuto merge of #13200 - P1n3appl3:sysroot, r=Veykril
bors [Wed, 7 Sep 2022 09:36:03 +0000 (09:36 +0000)]
Auto merge of #13200 - P1n3appl3:sysroot, r=Veykril

Use proc-macro-srv from sysroot in rust-project.json workspaces

This was discussed [on zulip](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/.60sysroot.60.20vs.20.60sysroot_src.60.20for.20.60rust-project.2Ejson.60.3F/near/293023920), basically in `rust-project.json` workspaces RA doesn't respect the `sysroot` setting when picking which `proc-macro-srv` to launch, and this causes abi mismatches in practice.

This is the simple fix that `@Veykril` suggested, and I've verified that it works on Fuchsia by inspecting the cmdline with `pgrep rust-analyzer | xargs ps -fp` to check that it's using the `proc-macro-srv` from our prebuilts which matches the `sysroot` specified in our `rust-project.json`.

Can this be merged as is, or do we need to add tests that exercise this?

23 months agoUse proc-macro-srv from sysroot in rust-project.json
Joseph Ryan [Wed, 7 Sep 2022 01:27:17 +0000 (18:27 -0700)]
Use proc-macro-srv from sysroot in rust-project.json

23 months agopretty solition works
Stanislav [Wed, 7 Sep 2022 01:09:25 +0000 (04:09 +0300)]
pretty solition works

23 months agotypo and draft
Stanislav [Wed, 7 Sep 2022 00:23:21 +0000 (03:23 +0300)]
typo and draft

23 months agoUpdate crates/ide/src/references.rs
Stanislav [Wed, 7 Sep 2022 00:01:06 +0000 (03:01 +0300)]
Update crates/ide/src/references.rs

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
23 months agoAuto merge of #13192 - lowr:fix/dyn-sort-all-bounds, r=Veykril
bors [Mon, 5 Sep 2022 11:24:54 +0000 (11:24 +0000)]
Auto merge of #13192 - lowr:fix/dyn-sort-all-bounds, r=Veykril

fix: sort all bounds on trait object types

Fixes #13181

#12793 allowed different ordering of trait bounds in trait object types but failed to account for the ordering of projection bounds. I opted for sorting all the bounds at once rather than splitting them into `SmallVec`s so it's easier to do the same thing for other bounds when we have them.

23 months agoAuto merge of #13185 - ChayimFriedman2:insert-ws-in-static-const-macro, r=Veykril
bors [Mon, 5 Sep 2022 11:10:40 +0000 (11:10 +0000)]
Auto merge of #13185 - ChayimFriedman2:insert-ws-in-static-const-macro, r=Veykril

fix: Insert whitespaces into static & const bodies if they are expanded from macro on hover

Partially fixes #13143.

To resolve the other part we need to expand macros in unevaluated static & const bodies, and I'm not sure we want to. If for example it includes a call to `assert!()`, expanding it will lead to worse hover.

23 months agoAuto merge of #13139 - Austaras:enum, r=Veykril
bors [Mon, 5 Sep 2022 10:59:38 +0000 (10:59 +0000)]
Auto merge of #13139 - Austaras:enum, r=Veykril

Suggest struct when completing enum

closes #13107

23 months agoAuto merge of #13091 - ice1k:hey, r=Veykril
bors [Mon, 5 Sep 2022 10:49:19 +0000 (10:49 +0000)]
Auto merge of #13091 - ice1k:hey, r=Veykril

Remove type alias definition on inline

Fix #13079

23 months agofix: sort all bounds on trait object types
Ryo Yoshida [Mon, 5 Sep 2022 09:35:50 +0000 (18:35 +0900)]
fix: sort all bounds on trait object types

23 months agocomplete full struct in enum varaint
austaras [Fri, 2 Sep 2022 16:58:24 +0000 (00:58 +0800)]
complete full struct in enum varaint

23 months agoAuto merge of #13187 - matklad:return, r=Veykril
bors [Sun, 4 Sep 2022 18:25:55 +0000 (18:25 +0000)]
Auto merge of #13187 - matklad:return, r=Veykril

fix: correct broken logic for return complition

It seems that we've accidentally deleted the tests here couple of years
ago, and then fairly recently made a typo during refactor as well.

Reinstall tests, with coverage marks this time :-)

23 months agofix: correct broken logic for return complition
Aleksey Kladov [Sun, 4 Sep 2022 16:56:01 +0000 (17:56 +0100)]
fix: correct broken logic for return complition

It seems that we've accidentally deleted the tests here couple of years
ago, and then fairly recently made a typo during refactor as well.

Reinstall tests, with coverage marks this time :-)

23 months agofix
Stanislav [Sun, 4 Sep 2022 16:45:50 +0000 (19:45 +0300)]
fix

23 months agoUpdate crates/ide/src/references.rs
Stanislav [Sun, 4 Sep 2022 16:41:06 +0000 (19:41 +0300)]
Update crates/ide/src/references.rs

Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
23 months agoRetain imports on find-all-references
Stanislav [Sun, 4 Sep 2022 16:10:04 +0000 (19:10 +0300)]
Retain imports on find-all-references

23 months agoDo not insert a newline after `;` if the next token is a `}`
Chayim Refael Friedman [Sun, 4 Sep 2022 14:24:16 +0000 (14:24 +0000)]
Do not insert a newline after `;` if the next token is a `}`

This creates double newline.

23 months agoInsert whitespaces into static & const bodies if they are expanded from macro on...
Chayim Refael Friedman [Sun, 4 Sep 2022 13:26:00 +0000 (13:26 +0000)]
Insert whitespaces into static & const bodies if they are expanded from macro on hover

Macro expansion erases whitespace information, and so we end with invalid Rust code.

23 months agoAuto merge of #13183 - Veykril:break-break, r=Veykril
bors [Sat, 3 Sep 2022 15:33:21 +0000 (15:33 +0000)]
Auto merge of #13183 - Veykril:break-break, r=Veykril

Fix nested break expressions, expecting unknown types

23 months agoFix nested break expressions, expecting unknown types
Lukas Wirth [Sat, 3 Sep 2022 15:08:18 +0000 (17:08 +0200)]
Fix nested break expressions, expecting unknown types

23 months agoFmt
ice1000 [Fri, 2 Sep 2022 05:13:33 +0000 (05:13 +0000)]
Fmt

23 months agoFix test
ice1000 [Fri, 2 Sep 2022 05:13:02 +0000 (05:13 +0000)]
Fix test

23 months agoCreate `trait Removable`, replace `ted` APIs with builder APIs
ice1000 [Fri, 2 Sep 2022 05:06:51 +0000 (05:06 +0000)]
Create `trait Removable`, replace `ted` APIs with builder APIs

23 months agoAddress comments
ice1000 [Mon, 29 Aug 2022 20:27:53 +0000 (20:27 +0000)]
Address comments