Commit Graph

23352 Commits

Author SHA1 Message Date
bors
8c7e37697f Auto merge of #13275 - Veykril:find-path, r=Veykril
Fix find_path using the wrong module for visibility calculations
2022-09-27 01:14:02 +00:00
unexge
7e5e5177b6 Generate From impls manually 2022-09-26 19:29:28 +01:00
unexge
3a8d84b4a3 Use Arc<[DefDiagnostic]> instead of Arc<Vec<DefDiagnostic>> 2022-09-26 19:16:02 +01:00
unexge
b21bf25a07 Collect diagnostics in queries instead of nameres 2022-09-26 19:06:29 +01:00
unexge
89107d5469 Emit unconfigured code diagnostics for fields 2022-09-26 19:04:57 +01:00
Noah Santschi-Cooney
651c586035
formatting 2022-09-26 18:35:06 +01:00
Noah Santschi-Cooney
60b432b7e9
fix model tests 2022-09-26 18:18:12 +01:00
Noah Santschi-Cooney
aa093f5a58
Fix PackageInformation having the crate name instead of package name 2022-09-26 17:31:38 +01:00
bors
1a24003eb6 Auto merge of #13248 - harudagondi:unwrap-tuple, r=Veykril
Feature: Add assist to unwrap tuple declarations

> Implement #12923 for only tuples.
>
> Does not implement unwrapping for structs, as mentioned in the issue.

Add assist to unwrap tuples declarations to separate declarations.

```rust
fn main() {
	$0let (foo, bar, baz) = (1.0, "example", String::new())
}
```

becomes:

```rust
fn main() {
	let foo = 1.0;
	let bar = "example";
	let baz = String::new();
}
```

## Changelog

### Feature

- Added assist to unwrap tuple declarations.
2022-09-26 09:35:59 +00:00
Lukas Wirth
7929e9c56b Remove obsolete in-rust-tree feature from sourcegen 2022-09-26 11:34:30 +02:00
bors
1f929659ac Auto merge of #13209 - lowr:feat/inference-for-generator, r=Veykril
feat: type inference for generators

This PR implements basic type inference for generator and yield expressions.

Things not included in this PR:
- Generator upvars and generator witnesses are not implemented. They are only used to determine auto trait impls, so basic type inference should be fine without them, but method resolutions with auto trait bounds may not be resolved correctly.

Open questions:
- I haven't (yet) implemented `HirDisplay` for `TyKind::Generator`, so generator types are just shown as "{{generator}}" (in tests, inlay hints, hovers, etc.), which is not really nice. How should we show them?
- I added moderate amount of stuffs to minicore. I especially didn't want to add `impl<T> Deref for &T` and `impl<T> Deref for &mut T` exclusively for tests for generators; should I move them into the test fixtures or can they be placed in minicore?

cc #4309
2022-09-26 09:28:41 +00:00
bors
73ab709b38 Auto merge of #13289 - rust-lang:analysis-stats-proc-server, r=Veykril
Use the sysroot proc-macro server for analysis-stats

Should fix the metrics issues
2022-09-24 20:04:48 +00:00
Lukas Wirth
73f6af54c1 Use the sysroot proc-macro server for analysis-stats 2022-09-24 22:04:17 +02:00
bors
fa38c10e7f Auto merge of #13288 - Veykril:variant-body, r=Veykril
Fix diagnostics not working in enum variant bodies

cc https://github.com/rust-lang/rust-analyzer/pull/12966
2022-09-24 01:09:15 +00:00
Lukas Wirth
0231d19f3f Fix diagnostics not working in enum variant bodies 2022-09-24 03:07:05 +02:00
bors
4e7bb5e042 Auto merge of #13285 - Veykril:variant-body, r=Veykril
Properly support IDE functionality in enum variants
2022-09-24 00:39:34 +00:00
Lukas Wirth
7ec9ffa325 Properly support IDE functionality in enum variants 2022-09-24 02:33:59 +02:00
bors
14400785ac Auto merge of #13286 - Veykril:proc-macro-srv-tests, r=Veykril
Don't run proc-macro-srv tests on the rust-analyzer repo

proc-macro ABI breakage still affects the tests when a new stable version releases. Ideally we'd still be able to run the tests on the rust-analyzer repo without having to update the proc-macro ABI, but for now just to unblock CI we will ignore them here, as they are still run in upstream.
2022-09-23 22:19:35 +00:00
Lukas Wirth
f57cd838d8 Don't run proc-macro-srv tests on the rust-analyzer repo
proc-macro ABI breakage still affects the tests when a new stable version
releases. Ideally we'd still be able to run the tests on the rust-analyzer
repo without having to update the proc-macro ABI, but for now just to
unblock CI we will ignore them here, as they are still run in upstream.
2022-09-24 00:08:28 +02:00
Alan Zimmerman
fb0ce25d59 Add RequestFailed error code, as per spec 3.17
See https://github.com/microsoft/language-server-protocol/issues/1341
2022-09-23 09:49:44 +01:00
Lukas Wirth
729a9eb5d0 Fix find_path using the wrong module for visibility calculations 2022-09-22 17:56:58 +02:00
Paul Delafosse
40e8f03e11 docs(guide): fix Analysis and AnalysisHost doc links 2022-09-22 05:17:47 +02:00
Ryo Yoshida
9ede5f0735
Implement HirDisplay for TyKind::Generator 2022-09-21 22:04:55 +09:00
harudagondi
c2dc32c48e return None instead of assert 2022-09-21 09:11:02 +08:00
bors
5b49745d00 Auto merge of #13269 - Veykril:repr, r=Veykril
Properly set the enum variant body type from the repr attribute

Follow up for https://github.com/rust-lang/rust-analyzer/pull/12966, fixes some type inference problems
2022-09-20 15:50:31 +00:00
Lukas Wirth
9bf386f4c0 Fix default enum representation not being isize 2022-09-20 17:50:13 +02:00
Lukas Wirth
2119c1f351 Fix using incorrect type for variants in DefWithBody::body_type 2022-09-20 17:29:35 +02:00
Lukas Wirth
b25f0ba15b Properly set the enum variant body expected type 2022-09-20 17:15:48 +02:00
Lukas Wirth
9f233cd5d2 Parse more repr options 2022-09-20 17:12:27 +02:00
Lukas Wirth
6d0d051628 Simplify 2022-09-20 17:12:10 +02:00
bors
817a6a8609 Auto merge of #12966 - OleStrohm:master, r=Veykril
feat: Display the value of enum variant on hover

fixes #12955

This PR adds const eval support for enums, as well as showing their value on hover, just as consts currently have.

I developed these two things at the same time, but I've realized now that they are separate. However since the hover is just a 10 line change (not including tests), I figured I may as well put them in the same PR. Though if you want them split up into "enum const eval support"  and "show enum variant value on hover", I think that's reasonable too.

Since this adds const eval support for enums this also allows consts that reference enums to have their values computed now too.

The const evaluation itself is quite rudimentary, it doesn't keep track of the actual type of the enum, but it turns out that Rust doesn't actually either, and `E::A as u8` is valid regardless of the `repr` on `E`.

It also doesn't really care about what expression the enum variant contains, it could for example be a string, despite that not being allowed, but I guess it's up to the `cargo check` diagnostics to inform of such issues anyway?
2022-09-20 14:01:16 +00:00
bors
09600a3a5b Auto merge of #13268 - Veykril:simplify, r=Veykril
Simplify
2022-09-20 12:35:18 +00:00
Lukas Wirth
027bfd68ba Fix operator highlighting tags applying too broadly 2022-09-20 14:33:44 +02:00
Lukas Wirth
7e8eac3fd7 Simplify 2022-09-20 14:33:18 +02:00
bors
bde76b9abb Auto merge of #13264 - lowr:patch/no-dyn-without-trait, r=Veykril
Ensure at least one trait bound in `TyKind::DynTy`

One would expect `TyKind::DynTy` to have at least one trait bound, but we may produce a dyn type with no trait bounds at all. This patch prevents it by returning `TyKind::Error` in such cases.

An "empty" dyn type would have caused panic during method resolution without #13257. Although already fixed, I think an invariant to never produce such types would help prevent similar problems in the future.
2022-09-19 20:36:02 +00:00
Ryo Yoshida
9845e37f58
Ensure at least one trait bound in TyKind::DynTy 2022-09-20 04:37:34 +09:00
OleStrohm
f87ad8df05 Added FIXME for the repr type of the enum 2022-09-19 19:26:35 +01:00
bors
4d989b5465 Auto merge of #13262 - DidiBear:master, r=lnicola
Remove reference to Toggle inlay hints

This simply removes the reference to the `Toggle inlay hints` action after its removal in https://github.com/rust-lang/rust-analyzer/pull/13215.
In fact, this reference is still visible [in the User Manual here](https://rust-analyzer.github.io/manual.html#inlay-hints).
2022-09-19 16:08:40 +00:00
DidiBear
cdc362e6cc
docs(inlay-hints): remove reference to Toggle inlay hints 2022-09-19 12:00:58 -04:00
bors
4f2c86e86e Auto merge of #13260 - Veykril:simplify, r=Veykril
Simplify
2022-09-19 15:32:45 +00:00
Lukas Wirth
a6c067c06d Simplify 2022-09-19 17:31:08 +02:00
bors
bc6d574662 Auto merge of #13259 - Veykril:cargo-config-simplify, r=Veykril
Simplify feature representation in CargoConfig
2022-09-19 14:53:06 +00:00
Lukas Wirth
d9f5709609 Simplify feature representation in CargoConfig 2022-09-19 16:52:44 +02:00
bors
187bee0bb1 Auto merge of #13257 - rust-lang:revert-13147-fix/dyn-ty-inherent-methods, r=lnicola
fix: Fix a crash introduced in #13147

Reverts rust-lang/rust-analyzer#13147

https://github.com/rust-lang/rust-analyzer/actions/runs/3041499441/jobs/4898678721#step:18:62
2022-09-19 09:46:21 +00:00
Laurențiu Nicola
e54f61dbdb Try to fix crash introduced in #13147 2022-09-19 12:45:38 +03:00
bors
39eaf7864c Auto merge of #13253 - Veykril:simplify, r=Veykril
Simplify
2022-09-18 17:52:21 +00:00
Lukas Wirth
0d9f97166b Simplify 2022-09-18 19:44:38 +02:00
bors
11bf2e7ffb 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).
2022-09-18 17:43:46 +00:00
bors
932e63b5d4 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
2022-09-17 11:23:05 +00:00
harudagondi
ed0cf1c5fa Add functionality to unwrap tuple declarations 2022-09-17 15:57:45 +08:00