Commit graph

18140 commits

Author SHA1 Message Date
Ryan Mehri
455dacfd3b fix: only trigger assist on Name 2023-09-09 11:59:59 -07:00
Ryan Mehri
91ac1d6194 fix: initializing struct multiple times 2023-09-09 11:59:59 -07:00
Ryan Mehri
83196fd4d9 fix: remove trailing whitespace 2023-09-09 11:59:59 -07:00
Ryan Mehri
59738d5fd5 fix: add generated doctest 2023-09-09 11:59:58 -07:00
Ryan Mehri
d7a8e800c9 feat: initial version of bool_to_enum assist 2023-09-09 11:58:19 -07:00
Lukas Wirth
cfcef69072 shrink_to_fit body source map 2023-09-09 14:40:56 +02:00
Lukas Wirth
8f5fee4a5a Diagnose incorrect and private fields in record structs 2023-09-09 10:45:29 +02:00
Lukas Wirth
55c75450fb Diagnose private fields in record constructor 2023-09-08 23:19:30 +02:00
bors
c405509f2e Auto merge of #15560 - davidbarsky:davidbarsky/use-sysroot-rustc-to-determine-cfgs, r=Veykril
project-model: when using `rust-project.json`, prefer the sysroot-defined rustc over discovery in `$PATH`

At the moment, rust-analyzer discovers `rustc` via the `$PATH` even if the `sysroot` field is defined in a `rust-project.json`. However, this does not work for users who do not have rustup installed, resulting in any `cfg`-based inference in rust-analzyer not working correctly. In my (decently naive!) opinion, it makes more sense to rely on the `sysroot` field in the `rust-project.json`.

One might ask "why not add `rustc` to the `$PATH`?" That is a reasonable question, but that doesn't work for my use case:
- The path to the sysroot in my employer's monorepo changes depending on which platform a user is on. For example, if they're on Linux, they'd want to use the sysroot defined at path `a`, whereas if they're on macOS, they'd want to use the sysroot at path `b` (I wrote the sysroot resolution functionality [here](765da4ca1e/integrations/rust-project/src/sysroot.rs (L39)), if you're curious).
- The location of the sysroot can (and does!) change, especially as people figure out how to make Rust run successfully on non-Linux platforms (e.g., iOS, Android, etc.) in a monorepo. Updating people's `$PATH` company-wide is hard while updating a config inside a CLI is pretty easy.

## Testing

I've created a `rust-project.json` using [rust-project](https://github.com/facebook/buck2/tree/main/integrations/rust-project) and was able to successfully load a project with and without the `sysroot`/`sysroot_src` fields—without those fields, rust-analyzer fell back to the `$PATH` based approach, as evidenced by `[DEBUG project_model::rustc_cfg] using rustc from env rustc="rustc"` showing up in the logs.
2023-09-08 18:14:25 +00:00
David Barsky
0bf6ffaf82
Update crates/project-model/src/rustc_cfg.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2023-09-08 14:07:59 -04:00
bors
c31d418a31 Auto merge of #15578 - Veykril:diag-tuple-struct-count, r=Veykril
Diagnose mismatched arg count for tuple struct patterns
2023-09-08 13:08:10 +00:00
Lukas Wirth
8654a098c7 Diagnose mismatched arg count for tuple struct patterns 2023-09-08 14:54:43 +02:00
bors
ea71a49c8e Auto merge of #15577 - Veykril:clear-native-diags, r=Veykril
Clear native diagnostics on file closing

Fixes https://github.com/rust-lang/rust-analyzer/issues/15562
2023-09-08 11:54:59 +00:00
Lukas Wirth
297ed70a23 Clear native diagnostics on file closing 2023-09-08 13:54:44 +02:00
bors
70a6cf0ef7 Auto merge of #15522 - SomeoneToIgnore:resolve-inlay-hints, r=Veykril
Resolve inlay hint data

Part of https://github.com/rust-lang/rust-analyzer/issues/13962

Support https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#inlayHint_resolve better, by omitting all inlay hint fields specified in the client hint resolve capabilities.

Current list of all capabilities possible to resolve later:
```
"textEdits"
"tooltip"
"label.tooltip"
"label.location"
"label.command"
```

and every one specified in the client capabilities is now resolved by r-a, being omitted in the initial response.

--------------

When editing `inlay_hints.rs` file around line `457` with no resolve capabilities, I get
<details>
  <summary>resolved json, 10803 characters</summary>

```json
{"jsonrpc":"2.0","id":55,"result":[{"position":{"line":477,"character":1},"label":[{"value":"fn inlay_hints","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/ide/src/inlay_hints.rs","range":{"start":{"line":445,"character":14},"end":{"line":445,"character":25}}}}],"paddingLeft":true,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":451,"character":10},"label":[{"value":": "},{"value":"ProfileSpan","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/profile/src/hprof.rs","range":{"start":{"line":85,"character":11},"end":{"line":85,"character":22}}}},{"value":""}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":451,"character":27},"label":[{"value":"label:","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/profile/src/hprof.rs","range":{"start":{"line":60,"character":12},"end":{"line":60,"character":17}}}}],"kind":2,"paddingLeft":false,"paddingRight":true,"data":{"file_id":0}},{"position":{"line":452,"character":12},"label":[{"value":": "},{"value":"Semantics","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/hir/src/semantics.rs","range":{"start":{"line":108,"character":11},"end":{"line":108,"character":20}}}},{"value":"<'_, "},{"value":"RootDatabase","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/ide-db/src/lib.rs","range":{"start":{"line":75,"character":11},"end":{"line":75,"character":23}}}},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":453,"character":12},"label":[{"value":": "},{"value":"SourceFile","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/ast/generated/nodes.rs","range":{"start":{"line":223,"character":11},"end":{"line":223,"character":21}}}},{"value":""}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":454,"character":12},"label":[{"value":": &"},{"value":"SyntaxNode","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.11/src/api.rs","range":{"start":{"line":15,"character":11},"end":{"line":15,"character":21}}}},{"value":"<"},{"value":"RustLanguage","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/syntax_node.rs","range":{"start":{"line":15,"character":9},"end":{"line":15,"character":21}}}},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":456,"character":12},"label":": i32","kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":458,"character":15},"label":[{"value":": "},{"value":"Vec","location":{"uri":"file:///Users/someonetoignore/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs","range":{"start":{"line":395,"character":11},"end":{"line":395,"character":14}}}},{"value":"<"},{"value":"InlayHint","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/ide/src/inlay_hints.rs","range":{"start":{"line":149,"character":11},"end":{"line":149,"character":20}}}},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":460,"character":21},"label":[{"value":": "},{"value":"SemanticsScope","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/hir/src/semantics.rs","range":{"start":{"line":1651,"character":11},"end":{"line":1651,"character":25}}}},{"value":"<'_>"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":460,"character":36},"label":[{"value":"node:","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/hir/src/semantics.rs","range":{"start":{"line":482,"character":24},"end":{"line":482,"character":28}}}}],"kind":2,"paddingLeft":false,"paddingRight":true,"data":{"file_id":0}},{"position":{"line":461,"character":23},"label":[{"value":": "},{"value":"FamousDefs","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/ide-db/src/famous_defs.rs","range":{"start":{"line":20,"character":11},"end":{"line":20,"character":21}}}},{"value":"<'_, '_>"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":463,"character":17},"label":[{"value":": impl FnMut("},{"value":"SyntaxNode","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.11/src/api.rs","range":{"start":{"line":15,"character":11},"end":{"line":15,"character":21}}}},{"value":"<"},{"value":"RustLanguage","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/syntax_node.rs","range":{"start":{"line":15,"character":9},"end":{"line":15,"character":21}}}},{"value":">)"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":463,"character":25},"label":[{"value":": "},{"value":"SyntaxNode","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.11/src/api.rs","range":{"start":{"line":15,"character":11},"end":{"line":15,"character":21}}}},{"value":"<"},{"value":"RustLanguage","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/syntax_node.rs","range":{"start":{"line":15,"character":9},"end":{"line":15,"character":21}}}},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":463,"character":33},"label":[{"value":"hints:","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/ide/src/inlay_hints.rs","range":{"start":{"line":480,"character":4},"end":{"line":480,"character":9}}}}],"kind":2,"paddingLeft":false,"paddingRight":true,"data":{"file_id":0}},{"position":{"line":465,"character":22},"label":[{"value":": "},{"value":"TextRange","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/text-size-1.1.0/src/range.rs","range":{"start":{"line":14,"character":11},"end":{"line":14,"character":20}}}},{"value":""}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":467,"character":35},"label":[{"value":": "},{"value":"SyntaxNode","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.11/src/api.rs","range":{"start":{"line":15,"character":11},"end":{"line":15,"character":21}}}},{"value":"<"},{"value":"RustLanguage","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/syntax_node.rs","range":{"start":{"line":15,"character":9},"end":{"line":15,"character":21}}}},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":469,"character":92},"label":[{"value":"impl "},{"value":"Iterator","location":{"uri":"file:///Users/someonetoignore/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs","range":{"start":{"line":72,"character":10},"end":{"line":72,"character":18}}}},{"value":"<"},{"value":"Item","location":{"uri":"file:///Users/someonetoignore/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs","range":{"start":{"line":76,"character":9},"end":{"line":76,"character":13}}}},{"value":" = "},{"value":"SyntaxNode","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.11/src/api.rs","range":{"start":{"line":15,"character":11},"end":{"line":15,"character":21}}}},{"value":"<"},{"value":"RustLanguage","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/syntax_node.rs","range":{"start":{"line":15,"character":9},"end":{"line":15,"character":21}}}},{"value":">>"}],"kind":1,"paddingLeft":true,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":468,"character":34},"label":[{"value":"impl "},{"value":"Iterator","location":{"uri":"file:///Users/someonetoignore/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs","range":{"start":{"line":72,"character":10},"end":{"line":72,"character":18}}}},{"value":"<"},{"value":"Item","location":{"uri":"file:///Users/someonetoignore/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs","range":{"start":{"line":76,"character":9},"end":{"line":76,"character":13}}}},{"value":" = "},{"value":"SyntaxNode","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.11/src/api.rs","range":{"start":{"line":15,"character":11},"end":{"line":15,"character":21}}}},{"value":"<"},{"value":"RustLanguage","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/syntax_node.rs","range":{"start":{"line":15,"character":9},"end":{"line":15,"character":21}}}},{"value":">>"},{"value":""}],"kind":1,"paddingLeft":true,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":467,"character":41},"label":[{"value":""},{"value":"SyntaxNode","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.11/src/api.rs","range":{"start":{"line":15,"character":11},"end":{"line":15,"character":21}}}},{"value":"<"},{"value":"RustLanguage","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/syntax_node.rs","range":{"start":{"line":15,"character":9},"end":{"line":15,"character":21}}}},{"value":">"}],"kind":1,"paddingLeft":true,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":469,"character":40},"label":" -> bool","kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":469,"character":39},"label":[{"value":": &"},{"value":"SyntaxNode","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.11/src/api.rs","range":{"start":{"line":15,"character":11},"end":{"line":15,"character":21}}}},{"value":"<"},{"value":"RustLanguage","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/syntax_node.rs","range":{"start":{"line":15,"character":9},"end":{"line":15,"character":21}}}},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}}]}
```

</details>

for the visible editor range alone, pretty much repeated on every consequent edit.

With this patch and all inlay hint resolve capabilities enabled, for the same example I observe quite a footprint reduction:

<details>
  <summary>unresolved json, 4142 characters</summary>

```json
{"jsonrpc":"2.0","id":49,"result":[{"position":{"line":477,"character":1},"label":[{"value":"fn inlay_hints"}],"paddingLeft":true,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":451,"character":10},"label":[{"value":": "},{"value":"ProfileSpan"},{"value":""}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":451,"character":27},"label":[{"value":"label:"}],"kind":2,"paddingLeft":false,"paddingRight":true,"data":{"file_id":0}},{"position":{"line":452,"character":12},"label":[{"value":": "},{"value":"Semantics"},{"value":"<'_, "},{"value":"RootDatabase"},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":453,"character":12},"label":[{"value":": "},{"value":"SourceFile"},{"value":""}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":454,"character":12},"label":[{"value":": &"},{"value":"SyntaxNode"},{"value":"<"},{"value":"RustLanguage"},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":456,"character":12},"label":": i32","kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":458,"character":15},"label":[{"value":": "},{"value":"Vec"},{"value":"<"},{"value":"InlayHint"},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":460,"character":21},"label":[{"value":": "},{"value":"SemanticsScope"},{"value":"<'_>"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":460,"character":36},"label":[{"value":"node:"}],"kind":2,"paddingLeft":false,"paddingRight":true,"data":{"file_id":0}},{"position":{"line":461,"character":23},"label":[{"value":": "},{"value":"FamousDefs"},{"value":"<'_, '_>"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":463,"character":17},"label":[{"value":": impl FnMut("},{"value":"SyntaxNode"},{"value":"<"},{"value":"RustLanguage"},{"value":">)"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":463,"character":25},"label":[{"value":": "},{"value":"SyntaxNode"},{"value":"<"},{"value":"RustLanguage"},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":463,"character":33},"label":[{"value":"hints:"}],"kind":2,"paddingLeft":false,"paddingRight":true,"data":{"file_id":0}},{"position":{"line":465,"character":22},"label":[{"value":": "},{"value":"TextRange"},{"value":""}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":467,"character":35},"label":[{"value":": "},{"value":"SyntaxNode"},{"value":"<"},{"value":"RustLanguage"},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":469,"character":92},"label":[{"value":"impl "},{"value":"Iterator"},{"value":"<"},{"value":"Item"},{"value":" = "},{"value":"SyntaxNode"},{"value":"<"},{"value":"RustLanguage"},{"value":">>"}],"kind":1,"paddingLeft":true,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":468,"character":34},"label":[{"value":"impl "},{"value":"Iterator"},{"value":"<"},{"value":"Item"},{"value":" = "},{"value":"SyntaxNode"},{"value":"<"},{"value":"RustLanguage"},{"value":">>"},{"value":""}],"kind":1,"paddingLeft":true,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":467,"character":41},"label":[{"value":""},{"value":"SyntaxNode"},{"value":"<"},{"value":"RustLanguage"},{"value":">"}],"kind":1,"paddingLeft":true,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":469,"character":40},"label":" -> bool","kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":469,"character":39},"label":[{"value":": &"},{"value":"SyntaxNode"},{"value":"<"},{"value":"RustLanguage"},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}}]}
```

</details>

with all unresolved parts needing only for navigation, hover or applying the hint edit — dynamic parts that are made after mouse hover or similar events, that resolve the hint data.
2023-09-08 11:12:27 +00:00
bors
347695abc8 Auto merge of #15528 - Veykril:r-a-cfg, r=Veykril
Enable `rust_analyzer` for cfgs when code is being analyzed by rust-analyzer

This allows one to have r-a skip analysis/replace macros that work not well with r-a at all by gating them behind this cfg (an example being the `quote` macro which r-a struggles with in terms of performance).
2023-09-08 10:51:17 +00:00
bors
b67606c4e2 Auto merge of #15529 - SomeoneToIgnore:less-inlay-hint-refreshes, r=Veykril
Do not send inlay hint refresh requests on file edits

See https://github.com/rust-lang/rust-analyzer/issues/13369#issuecomment-1695306870

Editor itself is able to invalidate hints after edits, and /refresh was sent after editor reports changes to the language server. This forces the editor to either query & invalidate the hints twice after every edit, or wait for /refresh to come before querying the hints.

Both options are rather useless, so instead, send a request on server startup only: client editors do not know when the server actually starts up, this will help to query the initial hints after editor was open and the server was still starting up.
2023-09-08 10:35:23 +00:00
bors
548d2f08e0 Auto merge of #15575 - HKalbasi:mir, r=HKalbasi
Intern projections in mir place

I hope this reduces mir memory usage.
2023-09-08 09:28:46 +00:00
bors
829e77709e Auto merge of #15524 - vsrs:bind_unused_param, r=Veykril
Bind unused parameter assistant

This PR introduces a new **Bind unused parameter assistant**.

While we do have a QuickFix from `rustc` (prefixing the parameter with an underscore), it's sometimes more convenient to suppress the warning using the following approach:
```rust
 fn some_function(unused: i32) {}
```
->
```rust
fn some_function(unused: i32) {
    let _ = unused;
}
```
2023-09-08 09:12:31 +00:00
hkalbasi
9708a29e57 Intern projections in mir place 2023-09-08 12:39:41 +03:30
Lukas Wirth
fddef42e92 Only set rust-analyzer cfg for workspace members 2023-09-08 11:02:56 +02:00
Lukas Wirth
e9e2c1ae75 Update project-model test outputs 2023-09-08 10:49:15 +02:00
Lukas Wirth
853f8a21f7 Fix cfg completions not working 2023-09-08 10:49:15 +02:00
Lukas Wirth
ca6ddd8ea3 Enable rust_analyzer for cfgs when code is being analyzed by rust-analyzer 2023-09-08 10:49:12 +02:00
bors
3325622230 Auto merge of #15430 - alibektas:deunwrap/wrap_return_type_in_result, r=Veykril
minor : Deunwrap wrap_return_type_in_result

#15398 subtask 7
2023-09-08 08:24:29 +00:00
bors
47e0d07eb0 Auto merge of #15573 - alibektas:15539/into_to_from, r=Veykril
assist : `into_to_qualified_from`

fixes #15539. This assist converts an `.into()` call into an explicit fully qualified `from()` call.
2023-09-08 07:44:24 +00:00
bors
5ddad87b1a Auto merge of #15574 - alibektas:15572/false_crate_name_env, r=Veykril
minor : use crate name for `CARGO_CRATE_NAME`

fixes #15572 . Until now we used the package name as a replacement of crate name. With this PR r-a first sets all the env variables it set before and on top of those it tries to set `CARGO_CRATE_NAME` to crates name, following envvar's naming convention.
2023-09-08 07:25:34 +00:00
Ali Bektas
506a477acf Use cargo name as the CARGO_CRATE_NAME instead of package name 2023-09-08 01:41:00 +02:00
Ali Bektas
9762f764ae Add assist into_to_qualified_from
This assist converts an `.into()` call into an explicit
fully qualified from call.
2023-09-07 23:43:46 +02:00
David Barsky
912b22fa07 add doc comment to rustc_cfg::RustcCfgConfig 2023-09-07 15:30:11 -04:00
David Barsky
fad3823a20 rename rustc_cfg::Config to rustc_cfg::RustcCfgConfig and import 2023-09-07 15:19:04 -04:00
David Barsky
553152e2d5 refactor rustc_cfg to be more inline with docs/dev/style.md 2023-09-07 15:06:51 -04:00
bors
d5b6ab2fa5 Auto merge of #15571 - Veykril:mir-alloc, r=Veykril
Remove allocation on mir eval memory write
2023-09-07 17:27:57 +00:00
Lukas Wirth
cd53bd6b8e Remove allocation on mir eval memory write 2023-09-07 18:41:50 +02:00
David Barsky
5b5bce8aaf project-model: when using rust-project.json, prefer the sysroot-defined rustc over an env-based one 2023-09-07 11:46:14 -04:00
bors
8edd81f166 Auto merge of #15568 - Veykril:upstream-rustc-ap, r=Veykril
Replace format-args parser with upstream fork

Turns out we can't bump rustc_abi right now because it got its generics removed accidentally https://github.com/rust-lang/rust/pull/107163
2023-09-07 09:52:08 +00:00
Lukas Wirth
10b0cd7047 Replace format-args parser with upstream fork 2023-09-07 11:37:59 +02:00
hkalbasi
e4c469321c Ignore enum variants in analysis stats of mir bodies 2023-09-07 01:08:47 +03:30
bors
77b359ae31 Auto merge of #15532 - SomeoneToIgnore:more-brackets-on-type-formatting, r=Veykril
On type format '(', by adding closing ')' automatically

If I understand right, `()` can surround pretty much the same `{}` can, so add another on type formatting pair for convenience: sometimes it's not that pleasant to write parenthesis in `Some(2).map(|i| (i, i+1))` cases and I would prefer r-a to do that for me.

One note: currently, b06503b6ec/crates/rust-analyzer/src/handlers/request.rs (L357) fires always.
Should we remove the assertion entirely now, since apparently things work in release despite that check?
2023-09-06 20:32:04 +00:00
bors
5906c26e85 Auto merge of #15565 - Veykril:mir, r=Veykril
Implement `write_via_move` intrinsic for mir-eval

Required for getting `write!`ing to work again. we fail with an odd type mimsatch eval error after this change though
2023-09-06 20:12:48 +00:00
Lukas Wirth
f13b184eb3 Implement write_via_move intrinsic for mir-eval 2023-09-06 21:49:16 +02:00
David Barsky
42f77f89ff internal: use current subcrate's rustfmt.toml with all rustfmt configurations 2023-09-06 15:32:38 -04:00
bors
f29867bd26 Auto merge of #15559 - Veykril:builtin-format-args, r=Veykril
Implement builtin#format_args, using rustc's format_args parser

`format_args!` now expands to `builtin#format_args(template, args...)`, the actual expansion now instead happens in lowering where we desugar this expression by using lang paths.

As a bonus, we no longer need to evaluate `format_args` as an eager macro which means less macro expansions overall -> less cache thrashing!

Fixes https://github.com/rust-lang/rust-analyzer/issues/15082
2023-09-06 17:44:33 +00:00
Lukas Wirth
96f19231d3 Fix hir pretty printing emitting trailing whitespace 2023-09-06 19:31:48 +02:00
Lukas Wirth
5046889f43 Don't allocate the format_args template string as an expression 2023-09-06 19:18:12 +02:00
Lukas Wirth
3fa0bf0dd3 Fix ide-diagnostics test fixture 2023-09-06 18:31:16 +02:00
Lukas Wirth
c0e402637e Emit builtin#format_args in builtin format_args expander 2023-09-06 18:08:20 +02:00
Lukas Wirth
5fdd1e36e3 Remove todo!()s 2023-09-06 15:30:44 +02:00
Lukas Wirth
e243a03da1 Desugar builtin#format_args 2023-09-06 15:21:41 +02:00
bors
b9a9722bda Auto merge of #15556 - gigaroby:master, r=lnicola
Update notify to 6.1.1

Unlike version 6.0.1, this does not pull windows-sys 0.45.0 as observed in #15077.

```
$ cargo tree --target=x86_64-pc-windows-gnu --charset=ascii | grep windows-sys

|           |   `-- windows-sys v0.42.0
|   |   |   |   |   |       `-- windows-sys v0.42.0 (*)
|       `-- windows-sys v0.48.0
    |   |   `-- windows-sys v0.48.0 (*)
    |   `-- windows-sys v0.48.0 (*)
|   `-- windows-sys v0.48.0 (*)
|   `-- windows-sys v0.42.0 (*)
```
2023-09-05 20:01:54 +00:00