Commit Graph

28174 Commits

Author SHA1 Message Date
bors
f8a4553d02 Auto merge of #17014 - Veykril:runnables-exported-main-test, r=Veykril
fix: Consider `exported_name="main"` functions in test modules as tests

Fixes https://github.com/rust-lang/rust-analyzer/issues/17011
2024-04-04 13:04:44 +00:00
Lukas Wirth
5957835cdf Consider exported_name="main" functions in test modules as tests 2024-04-04 14:51:10 +02:00
bors
8e581ac348 Auto merge of #17003 - krobelus:utf8-positions-multibyte, r=Veykril
Fix off-by-one error converting to LSP UTF8 offsets with multi-byte char

On this file,

```rust
fn main() {
    let 된장 = 1;
}
```

when using `"positionEncodings":["utf-16"]` I get an "unused variable" diagnostic on the variable
name (codepoint offset range `8..10`). So far so good.

When using `positionEncodings":["utf-8"]`, I expect to get the equivalent range in bytes (LSP:
"Character offsets count UTF-8 code units (e.g bytes)."), which is `8..14`, because both
characters are 3 bytes in UTF-8.  However I actually get `10..14`.

Looks like this is because we accidentally treat a 1-based index as an offset value: when
converting from our internal char-indices to LSP byte offsets, we look at one character to many.
This causes wrong results if the extra character is a multi-byte one, such as when computing
the start coordinate of 된장.

Fix that by actually passing an offset. While at it, fix the variable name of the line number,
which is not an offset (yet).

Originally reported at https://github.com/kakoune-lsp/kakoune-lsp/issues/740
2024-04-03 14:58:16 +00:00
bors
c0eb78e839 Auto merge of #17006 - Veykril:cfg-censor-fixes, r=Veykril
fix: Fix some cfg censoring bugs

Fixes https://github.com/rust-lang/rust-analyzer/issues/16947
2024-04-03 14:45:19 +00:00
Lukas Wirth
2b62d4b2ba Fix some cfg censoring bugs 2024-04-03 16:43:08 +02:00
Johannes Altmanninger
d24b0ba330 Fix off-by-one error converting to LSP UTF8 offsets with multi-byte char
On this file,

```rust
fn main() {
    let 된장 = 1;
}
```

when using `"positionEncodings":["utf-16"]` I get an "unused variable" diagnostic on the variable
name (codepoint offset range `8..10`). So far so good.

When using `positionEncodings":["utf-8"]`, I expect to get the equivalent range in bytes (LSP:
"Character offsets count UTF-8 code units (e.g bytes)."), which is `8..14`, because both
characters are 3 bytes in UTF-8.  However I actually get `10..14`.

Looks like this is because we accidentally treat a 1-based index as an offset value: when
converting from our internal char-indices to LSP byte offsets, we look at one character to many.
This causes wrong results if the extra character is a multi-byte one, such as when computing
the start coordinate of 된장.

Fix that by actually passing an offset. While at it, fix the variable name of the line number,
which is not an offset (yet).

Originally reported at https://github.com/kakoune-lsp/kakoune-lsp/issues/740
2024-04-03 14:46:51 +02:00
bors
5b08b1776c Auto merge of #17000 - mrnossiom:master, r=Veykril
fix: set the right postfix snippets competion source range

Hi 👋,

Changed the completion item `source_range` to match the replaced text. Though in VS Code it may not be disturbing because the snippet is previewed in a box, but in Helix editor, it's previewed by applying the main text edit.

Before :
![image](https://github.com/rust-lang/rust-analyzer/assets/43814157/75960e02-64f0-4ecd-964f-7e1dd894c713)

After :
![image](https://github.com/rust-lang/rust-analyzer/assets/43814157/84102f0e-9c81-4e7c-8ab5-a25986630e6f)

Thanks
2024-04-03 08:37:12 +00:00
bors
0140272daa Auto merge of #17002 - Veykril:layout-defaults, r=Veykril
internal: Consider ADT generic parameter defaults for unsubstituted layout calculations

For one, this brings back layout information for lifetime generic ADTs (which "regressed" when we started adding lifetimes to chalks-ir), but it also allows layout calculation to work for definitions that don't actually use the generics (where its only used in a `PhantomData` for example)
2024-04-03 07:04:19 +00:00
Lukas Wirth
86967032f7 Consider ADT generic parameter defaults for unsubstituted layout calculations 2024-04-03 09:01:27 +02:00
Milo Moisson
c5686c8941
fix: set the right postfix snippets competion source range
Changed the completion item source_range to match
the replaced text. Though in VS Code it may not be
disturbing because the snippet is previewed in a
box, but in Helix editor, it's previewed by applying
the main text edit.
2024-04-03 00:00:34 +02:00
bors
c3b8c2a254 Auto merge of #16996 - Veykril:lt-err, r=Veykril
internal: Lower outlive goals, respect them in display impls
2024-04-02 14:13:22 +00:00
bors
54faa03121 Auto merge of #16997 - Veykril:cfg-if-patch, r=Veykril
fix: Fix `patch_cfg_if` not applying with stitched sysroot

The condition was inverted accidentally..
2024-04-02 13:06:35 +00:00
Lukas Wirth
600747a1b4 Fix patch_cfg_if not applying with stitched sysroot 2024-04-02 15:04:40 +02:00
Lukas Wirth
707be6b99c Adjust display impls to respect lifetime bounds 2024-04-02 14:51:08 +02:00
Lukas Wirth
0927f86247 Replace static_lifetime usages with error_lifetime, lower outlives goals 2024-04-02 14:51:06 +02:00
bors
23dd54b010 Auto merge of #16968 - roife:fix-issue-16801, r=Veykril
fix: silence mismatches involving unresolved projections

fix #16801
2024-04-01 20:05:33 +00:00
roife
2636e44378 fix: simplify the usage of UnknownMismatch 2024-04-02 03:26:32 +08:00
roife
3d373fec8c tests: add tests for mismatches with unresolved projections 2024-04-02 01:32:43 +08:00
roife
8d6b65c544 fix: silence mismatches involving unresolved projections 2024-04-02 01:27:22 +08:00
bors
3691380c35 Auto merge of #16920 - Veykril:clippy-lints, r=Veykril
internal: Fix new nightly clippy lints
2024-04-01 16:00:18 +00:00
Lukas Wirth
2ae3e57c26 Fix new clippy lints 2024-04-01 17:55:56 +02:00
bors
ff8a24a740 Auto merge of #16988 - Veykril:config-docs, r=Veykril
fix: Fix `allFeatures` config docs
2024-04-01 12:28:14 +00:00
Lukas Wirth
ff279f1e91 Fix allFeatures config docs 2024-04-01 14:16:36 +02:00
bors
c82d168b79 Auto merge of #16979 - Nadrieril:contiguous-enum-id, r=Veykril
pattern analysis: Use contiguous indices for enum variants

The main blocker to using the in-tree version of the `pattern_analysis` crate is that rustc requires enum indices to be contiguous because it uses `IndexVec`/`BitSet` for performance. Currently we swap these out for `FxHashMap`/`FxHashSet` when the `rustc` feature is off, but we can't do that if we use the in-tree crate.

This PR solves the problem by using contiguous indices on the r-a side too.
2024-04-01 12:15:23 +00:00
bors
a6ddf5fb80 Auto merge of #16961 - Wilfred:fix_crate_ids, r=Veykril
Fix crate IDs when multiple workspaces are loaded

Previously, we assumed that the crate numbers in a `rust-project.json` always matched the `CrateId` values in the crate graph. This isn't true when there are multiple workspaces, because the crate graphs are merged and the `CrateId` values in the merged graph are different.

This broke flycheck (see first commit), because we were unable to find the workspace when a file changed, so we every single flycheck, producing duplicate compilation errors.

Instead, use the crate root module path to look up the relevant flycheck. This makes `ProjectWorkspace::Json` consistenet with `ProjectWorkspace::Cargo`.

Also, define a separate JSON crate number type, to prevent bugs like this happening again.
2024-04-01 10:43:06 +00:00
bors
2678660880 Auto merge of #16924 - poliorcetics:ab/push-kxwqvtypvlsq, r=Veykril
feat: Add `rust-analyzer.cargo.allTargets` to configure passing `--all-targets` to cargo invocations

Closes #16859

## Unresolved question:

Should this be a setting for build scripts only ? All the other `--all-targets` I found where already covered by `checkOnSave.allTargets`
2024-04-01 10:30:15 +00:00
Nadrieril
7e8f2d8fd3 Use contiguous indices for enum variants 2024-04-01 12:27:16 +02:00
bors
f3f14d4552 Auto merge of #16970 - Wilfred:fix_tasks, r=Veykril
Fix tasks in tasks.json

#16839 refactored the representation of tasks inside the VS Code extension. However, this data type is exposed to users, who can define their own tasks in the same format in `tasks.json` or `.code-workspace`.

Revert the data type to have a `command` field rather than a `program` field, and document the different fields. This code is also a little complex, so split out a `cargoToExecution` to handle the Task to Execution conversion logic.

After this change, any tasks.json with a `command` field works again. For example, the following tasks.json works as expected:

```
{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "cargo",
			"command": "build",
			"problemMatcher": [
			  "$rustc"
			],
			"group": "build",
			"label": "my example cargo build task"
		}
	]
}
```

Fixes #16943 #16949
2024-04-01 10:17:07 +00:00
bors
9774b114c6 Auto merge of #16986 - roife:update-issue-template, r=Veykril
update: add editor/extension information to bug report template

When attempting to reproduce issues, I encounter difficulties due to differences in versions of LSP clients and editors (such as #16985, #16867, and more)

This sometimes consumes a lot of efforts from contributors to communicate the details about LSP client information. Therefore, I believe adding editor/extension information to the issue template would be helpful for problem reproduction.
2024-04-01 10:03:57 +00:00
roife
d0d23a250d update: add editor/extension information to bug report template 2024-04-01 14:01:56 +08:00
bors
e4a405f877 Auto merge of #16983 - lnicola:sync-from-rust, r=lnicola
minor: sync from downstream
2024-03-31 11:48:14 +00:00
Laurențiu Nicola
424054a8aa Merge branch 'master' into sync-from-rust 2024-03-31 14:32:00 +03:00
Laurențiu Nicola
d3fb9f798a Merge commit 'f5a9250147f6569d8d89334dc9cca79c0322729f' into sync-from-ra 2024-03-31 09:57:00 +03:00
Wilfred Hughes
a758e349bc Document CargoTaskDefinition and factor out converting TaskDefinition to Execution 2024-03-29 16:07:22 -07:00
Wilfred Hughes
e8d6a5ec0b Rename RustTargetDefinition to CargoTaskDefinition 2024-03-29 16:07:22 -07:00
bors
f5a9250147 Auto merge of #16975 - HKalbasi:test-explorer, r=HKalbasi
Prompt the user to reload the window when enabling test explorer
2024-03-29 17:01:51 +00:00
hkalbasi
34cde2cebc Prompt the user to reload the window when enabling test explorer 2024-03-29 18:08:16 +03:30
bors
9d84142ef2 Auto merge of #16974 - dfireBird:generic_params_refactor, r=lnicola
refactor: Implement len and is_empty method in generic_params
2024-03-29 13:15:08 +00:00
dfireBird
69c4ac6304
implement len and is_empty method in generic_params 2024-03-29 18:26:46 +05:30
bors
a8b7acf22f Auto merge of #16971 - HKalbasi:test-explorer, r=HKalbasi
Resolve tests per file instead of per crate in test explorer

Fix part of #16827
2024-03-29 02:06:22 +00:00
hkalbasi
beec6914c8 Resolve tests per file instead of per crate in test explorer 2024-03-29 05:34:43 +03:30
bors
ab10eea62e Auto merge of #16967 - dfireBird:fix-16963, r=lnicola
fix: ADT hover considering only type or const len not lifetimes

I feel like test doesn't do much. Please suggest if I should improve it?

Fixes #16963
2024-03-28 16:45:45 +00:00
dfireBird
34a8cd6a7a
fix ADT hover considering only type or const len not lifetimes 2024-03-28 21:53:22 +05:30
bors
899db83128 Auto merge of #16957 - poliorcetics:ab/push-tlzsqmqqurxs, r=lnicola
fix: check for client support of relative glob patterns before using them

Fixes #16955
2024-03-28 08:57:29 +00:00
bors
29a8e65bbe Auto merge of #16965 - roife:use-lldb-for-cpp-ext, r=lnicola
fix: use lldb when debugging with C++ extension on MacOS

See https://github.com/rust-lang/rust-analyzer/issues/16901#issuecomment-2024486941

This PR resolves the issue of being unable to debug using the C++ extension on macOS. By using special configurations for the `MIMode` on macOS, it enables the C++ extension to connect to lldb when debugging (without affecting other platforms).
2024-03-28 06:49:49 +00:00
roife
3521089985 fix: use lldb when debugging with C++ extension 2024-03-28 14:38:23 +08:00
bors
4bf521df35 Auto merge of #16964 - lnicola:debugger-order, r=roife
fix: Revert debug extension priorities

Close #16901
2024-03-28 06:08:47 +00:00
Laurențiu Nicola
662ea73e4e Revert debug extension priorities 2024-03-28 07:58:36 +02:00
Wilfred Hughes
0f72ab1dd3 Define a separate type for crate indexes in a rust-project.json 2024-03-27 14:18:52 -07:00
bors
ad51a17c62 Auto merge of #16960 - dfireBird:fix-16958, r=lnicola
fix: lifetime length are not added in count of params in highlight

I found these two instances easily but I wonder how many such instances are there.

Fixes #16958
2024-03-27 18:05:45 +00:00