Commit graph

31035 commits

Author SHA1 Message Date
bors
88258b7fd2 Auto merge of #17653 - Veykril:std-find-path, r=Veykril
Prefer standard library paths over shorter extern deps re-exports

This should generally speed up path finding for std items as we no longer bother looking through all external dependencies. It also makes more sense to prefer importing std items from the std dependencies directly.

Fixes https://github.com/rust-lang/rust-analyzer/issues/17540
2024-07-21 07:24:38 +00:00
Lukas Wirth
40bbc684ad Prefer standard library paths over shorter extern deps re-exports 2024-07-21 09:14:17 +02:00
bors
5f26438b5d Auto merge of #17650 - ObsidianMinor:fix/17645, r=Veykril
Fix path resolution for child mods of those expanded by `include!`

Child modules wouldn't use the correct candidate paths due to a branch that doesn't seem to be doing what it's intended to do. Removing the branch fixes the problem and all existing test cases pass.

Having no knowledge of how any of this works, I believe this fixes #17645. Using another test that writes the included mod directly into `lib.rs` instead, I found the difference can be traced to the candidate files we use to look up mods. A separate branch for if the file comes from an `include!` macro doesn't take into account the original mod we're contained within:

```rust
None if file_id.macro_file().map_or(false, |it| it.is_include_macro(db.upcast())) => {
    candidate_files.push(format!("{}.rs", name.display(db.upcast())));
    candidate_files.push(format!("{}/mod.rs", name.display(db.upcast())));
}
```

I'm not sure why this branch exists. Tracing the branch back takes us to 3bb9efb but it doesn't say *why* the branch was added. The test case that was added in this commit passes with the branch removed, so I think it's just superfluous at this point.
2024-07-21 06:17:14 +00:00
bors
d2a1718d83 Auto merge of #127722 - BoxyUwU:new_adt_const_params_limitations, r=compiler-errors
Forbid borrows and unsized types from being used as the type of a const generic under `adt_const_params`

Fixes #112219
Fixes #112124
Fixes #112125

### Motivation

Currently the `adt_const_params` feature allows writing `Foo<const N: [u8]>` this is entirely useless as it is not possible to write an expression which evaluates to a type that is not `Sized`. In order to actually use unsized types in const generics they are typically written as `const N: &[u8]` which *is* possible to provide a value of.

Unfortunately allowing the types of const parameters to contain references is non trivial (#120961) as it introduces a number of difficult questions about how equality of references in the type system should behave. References in the types of const generics is largely only useful for using unsized types in const generics.

This PR introduces a new feature gate `unsized_const_parameters` and moves support for `const N: [u8]` and `const N: &...` from `adt_const_params` into it. The goal here hopefully is to experiment with allowing `const N: [u8]` to work without references and then eventually completely forbid references in const generics.

Splitting this out into a new feature gate means that stabilization of `adt_const_params` does not have to resolve #120961 which is the only remaining "big" blocker for the feature. Remaining issues after this are a few ICEs and naming bikeshed for `ConstParamTy`.

### Implementation

The implementation is slightly subtle here as we would like to ensure that a stabilization of `adt_const_params` is forwards compatible with any outcome of `unsized_const_parameters`. This is inherently tricky as we do not support unstable trait implementations and we determine whether a type is valid as the type of a const parameter via a trait bound.

There are a few constraints here:
- We would like to *allow for the possibility* of adding a `Sized` supertrait to `ConstParamTy` in the event that we wind up opting to not support unsized types and instead requiring people to write the 'sized version', e.g. `const N: [u8; M]` instead of `const N: [u8]`.
- Crates should be able to enable `unsized_const_parameters` and write trait implementations of `ConstParamTy` for `!Sized` types without downstream crates that only enable `adt_const_params` being able to observe this (required for std to be able to `impl<T> ConstParamTy for [T]`

Ultimately the way this is accomplished is via having two traits (sad), `ConstParamTy` and `UnsizedConstParamTy`. Depending on whether `unsized_const_parameters` is enabled or not we change which trait is used to check whether a type is allowed to be a const parameter.

Long term (when stabilizing `UnsizedConstParamTy`) it should be possible to completely merge these traits (and derive macros), only having a single `trait ConstParamTy` and `macro ConstParamTy`.

Under `adt_const_params` it is now illegal to directly refer to `ConstParamTy` it is only used as an internal impl detail by `derive(ConstParamTy)` and checking const parameters are well formed. This is necessary in order to ensure forwards compatibility with all possible future directions for `feature(unsized_const_parameters)`.

Generally the intuition here should be that `ConstParamTy` is the stable trait that everything uses, and `UnsizedConstParamTy` is that plus unstable implementations (well, I suppose `ConstParamTy` isn't stable yet :P).
2024-07-21 05:36:21 +00:00
bors
cf09dc635a Auto merge of #127715 - klensy:tests-w, r=Mark-Simulacrum
reenable some windows tests

Locally passing on `x86_64-pc-windows-msvc`, fingers crossed for `*-pc-windows-gnu`.

try-job: x86_64-msvc
try-job: x86_64-mingw
2024-07-21 03:06:32 +00:00
bors
71aa0b57b0 Auto merge of #128011 - matthiaskrgr:rollup-0vmf75y, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #127720 ([`macro_metavar_expr_concat`] Allow `concat` in repetitions)
 - #127734 (Windows: move BSD socket shims to netc)
 - #127752 (Ignore allocation bytes in one more mir-opt test)
 - #127839 (Fix git safe-directory path for docker images)
 - #127867 (Add `wasm32-wasip2` to `build-manifest` tool)
 - #127958 (Cleanup rmake.rs setup in compiletest)
 - #127975 (Fix trait bounds display)
 - #128005 (Remove _tls_used hack)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-21 00:39:36 +00:00
bors
84ef2c8c21 Auto merge of #128007 - Mark-Simulacrum:bump-version, r=Mark-Simulacrum
Bump to 1.82

https://forge.rust-lang.org/release/process.html#bump-the-stable-version-number-t-6-days-friday-the-week-before

r? `@Mark-Simulacrum`
2024-07-20 22:14:40 +00:00
Mark Rousskov
f410a2d02f Allow deprecated temporarily to unblock version bump 2024-07-20 15:51:58 -04:00
Sydney Acksman
b9469f52a3 Fix path resolution for child mods of those expanded by include!
Child modules wouldn't use the correct candidate paths due to a branch that doesn't seem to be doing what it's intended to do. Removing the branch fixes the problem and all existing test cases pass.
2024-07-20 14:32:28 -05:00
bors
8d489e21eb Auto merge of #17649 - ShoyuVanilla:issue-17585, r=Veykril
fix: Panic in debug profile for tuple deconstruct with arity mismatch

Fixes #17585, which doesn't affect daily use cases but quite annoying in development of r-a itself like writing tests.

This PR applies similar approach as in #17534, skipping match usefulness check for patterns containing errors
2024-07-20 18:04:01 +00:00
Shoyu Vanilla
6e728df43a fix: Panic in debug profile for tuple deconstruct with arity mismatch 2024-07-21 02:37:37 +09:00
Matthias Krüger
2f48006912
Rollup merge of #127752 - uweigand:s390x-miropt-update, r=Mark-Simulacrum
Ignore allocation bytes in one more mir-opt test

Following on PR #126502, add `rustc -Zdump-mir-exclude-alloc-bytes` to tests/mir-opt/dataflow-const-prop/aggregate_copy.rs as well to skip writing allocation bytes in MIR dumps.

Fixes #126261
2024-07-20 19:28:57 +02:00
Matthias Krüger
8ddc498435
Rollup merge of #127734 - ChrisDenton:netc, r=Mark-Simulacrum
Windows: move BSD socket shims to netc

On Windows we need to alter a few types so that they can be used in the cross-platform socket code. Currently these alterations are spread throughout the `c` module with some more in the `netc` module.

Let's gather all our BSD compatibility shims in the `netc` module so it's all in one place and easier to discover.
2024-07-20 19:28:57 +02:00
bors
6d6a099c08 Auto merge of #17646 - Veykril:dyn-parse, r=lnicola
Add missing dyn parse special cases in 2015 edition

There were a few more special cases to consider here -> https://github.com/rust-lang/reference/pull/1538
2024-07-20 14:22:45 +00:00
Josh McKinney
5b1a5a250b
Rename rust-analyzer commands
The commands `editor.action.triggerParameterHints` and
`editor.action.rename` are now renamed to
`rust-analyzer.triggerParameterHints` and `rust-analyzer.rename`

This change helps make it clear that these commands are specific to
rust-analyzer and not part of the default set of commands provided by
VSCode.

Fixes: https://github.com/rust-lang/rust-analyzer/issues/17644
2024-07-20 01:11:14 -07:00
Lukas Wirth
41603ab14e Add missing dyn parse special cases in 2015 edition 2024-07-20 09:18:40 +02:00
bors
062822ce91 Auto merge of #17641 - nyurik:optimize-refs, r=Veykril
Avoid ref when using format! in compiler

Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse.

See https://github.com/rust-lang/rust-clippy/issues/10851
2024-07-20 06:40:27 +00:00
Lukas Wirth
3092e1c0b1
Keep references in format! when the target is unsized 2024-07-20 08:39:04 +02:00
bors
c847bf730c Auto merge of #17642 - lnicola:typos, r=lnicola
minor: Fix some typos
2024-07-20 05:32:14 +00:00
Laurențiu Nicola
1075978bed Fix some typos 2024-07-20 08:30:22 +03:00
bors
6f84bdd06e Auto merge of #17635 - Young-Flash:block_exp, r=lnicola
feat: add inlay hint support for block expr with lifetime label

![block_expr_with_label](https://github.com/user-attachments/assets/efede15b-d2ba-4aad-9775-a795b6cd473b)

close https://github.com/rust-lang/rust-analyzer/issues/17582
2024-07-20 05:11:10 +00:00
Young-Flash
18e7299997 minor: tweak comment 2024-07-20 09:33:23 +08:00
Young-Flash
a2d142b9f2 internal: add test case for inlay hint support for block expr with lifetime label 2024-07-20 09:33:23 +08:00
Young-Flash
0416dec50a feat: add inlay hint support for block expr with lifetime label 2024-07-20 09:33:23 +08:00
bors
b333f85a9d Auto merge of #17639 - Veykril:salsa-perf, r=Veykril
Some more small salsa memory improvements

This does limit our lru limits to 2^16 but if you want to set them higher than that you might as well not set them at all. Also makes `LRU` opt-in per query now, allowing us to drop all the unnecessary LRU stuff for most queries
2024-07-19 18:45:16 +00:00
Yuri Astrakhan
cc1aded86c Avoid ref when using format! in compiler
Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse.
2024-07-19 14:41:59 -04:00
Lukas Wirth
09ef75c717 Add back equality check that went missing 2024-07-19 20:39:09 +02:00
bors
2c2b6c9bcc Auto merge of #17640 - Veykril:parse-dyn, r=Veykril
Parse contextual dyn keyword properly in edition 2015

Turns out this is more important than I thought it would be given the metrics :)
2024-07-19 18:31:08 +00:00
Lukas Wirth
92f5e806f1 Fix edition used for include macro parsing 2024-07-19 20:29:53 +02:00
Lukas Wirth
f4199f786e Parse contextual dyn keyword properly in edition 2015 2024-07-19 20:20:30 +02:00
roife
f027a46d94 internal: move NavigationTarget::from_expr to goto_definition 2024-07-20 01:58:51 +08:00
roife
1b59cf2d52 fix: sort references in tests 2024-07-20 01:55:55 +08:00
roife
55cd8ab904 fix: handle highlightings inside macro calls & only highlight kws in current file 2024-07-20 01:45:51 +08:00
roife
d94dcfa841 fix: ensure that highlight_related works for macro_expr 2024-07-20 01:42:52 +08:00
roife
ae6e8d56d4 use token_ancestors_with_macros to simplify goto-def on kw 2024-07-20 01:42:52 +08:00
roife
22c5924080 fix: navigate to label directly when perform 'goto-def' on control-flow kw
See https://github.com/rust-lang/rust-analyzer/pull/17542#discussion_r1667656190
2024-07-20 01:42:52 +08:00
roife
07570bac66 feat: find references on control-flow kws 2024-07-20 01:42:52 +08:00
roife
3650b40714 fix: keyword highlighting in macro expansion 2024-07-20 01:42:52 +08:00
roife
1bca00d1bc fix: incorrect highlighting of try blocks with control flow kws 2024-07-20 01:42:51 +08:00
roife
a93a7c2403 fix: ensure that goto-def works on fn/try/async kw 2024-07-20 01:41:01 +08:00
roife
37085d9dcd feat: goto-def on keywords 2024-07-20 01:41:00 +08:00
Lukas Wirth
a324e46b0b Drop an unnecessary Arc::clone 2024-07-19 18:53:52 +02:00
Lukas Wirth
89bcc79b5d Regenerate files 2024-07-19 18:39:42 +02:00
Lukas Wirth
6d4989b3c7 Make LRU opt-in 2024-07-19 18:38:08 +02:00
Lukas Wirth
7fcac48023 Remove duplicate information from interned::Slot 2024-07-19 17:52:49 +02:00
bors
9fd6c695da Auto merge of #17638 - Veykril:salsa-perf, r=Veykril
perf: Reduce memory usage of salsa slots by 8 bytes
2024-07-19 15:48:57 +00:00
Lukas Wirth
8e3133f118 Reduce maximum LRU size to 2^16 entries, reducing memory footprint of LRU entries 2024-07-19 17:48:12 +02:00
Lukas Wirth
4691ca97f1 perf: Reduce memory usage of salsa slots by 8 bytes 2024-07-19 17:34:48 +02:00
bors
9b1b29ca7a Auto merge of #17637 - jjoeldaniel:master, r=Veykril
internal: remove rust-analyzer.openFAQ

Removed no longer functional `rust-analyzer.openFAQ` command created in #17508
2024-07-19 15:34:43 +00:00
bors
aa4768f7be Auto merge of #17622 - roife:fix-issue-17602, r=Veykril
fix: handle synonymous imports with different renaming in 'merge imports'

fix #17602
2024-07-19 15:16:02 +00:00