Commit Graph

26396 Commits

Author SHA1 Message Date
bors
151c750dac Auto merge of #15367 - Veykril:eager-macro-inputs, r=Veykril
fix: Strip unused token ids from eager macro input token maps
2023-08-01 11:23:02 +00:00
Lukas Wirth
a5059da57a Update test fixture 2023-08-01 13:13:56 +02:00
Lukas Wirth
e14d84d0a6 Skip out on single-segment immediate macro resolution when there are errors 2023-08-01 12:38:53 +02:00
Lukas Wirth
3c1c319c88 Allow match to matches assist to trigger on non-literal bool arms 2023-08-01 12:10:38 +02:00
bors
62dcf39ef0 Auto merge of #14723 - obsgolem:master, r=Veykril
Added remove unused imports assist

This resolves the most important part of #5131. I needed to make a couple of cosmetic changes to the search infrastructure to do this.

A few open questions:
* Should imports that don't resolve to anything be considered unused? I figured probably not, but it would be a trivial change to make if we want it.
* Is there a cleaner way to make the edits to the use list?
* Is there a cleaner way to get the list of uses that intersect the current selection?
* Is the performance acceptable? When testing this on itself, it takes a good couple seconds to perform the assist.
* Is there a way to hide the rustc diagnostics that overlap with this functionality?
2023-08-01 09:50:16 +00:00
bors
43ecf2944d Auto merge of #15358 - Veykril:no-merges, r=Veykril
Add triagebot no-merges config

cc https://github.com/rust-lang/triagebot/pull/1704 https://github.com/rust-lang/rust/pull/114157
2023-08-01 09:35:44 +00:00
Lukas Wirth
d999d34e39 Don't bail eager expansion when inner macros fail to resolve 2023-08-01 11:26:30 +02:00
bors
c71e1368fd Auto merge of #15269 - DropDemBits:structured-snippets-deferred-rendering, r=Veykril
internal: Defer structured snippet rendering to allow escaping snippet bits

Since we know exactly where snippets are, we can transparently escape snippet bits to the exact text edits that need it, and not have to do it for anything other text edits.

Also will eventually fix #11006 once all assists are migrated. This comes as a side-effect of text edits that don't have snippets get marked as having no insert formatting at all.
2023-08-01 09:18:46 +00:00
bors
f6bffa4dd3 Auto merge of #15345 - lowr:fix/add_missing_match_arms-upmap-failure, r=Veykril
Don't provide `add_missing_match_arms` assist when upmapping match arm list failed

Fixes #15310

We shouldn't provide the assist when we fail to find the original match arm list.

Note that this PR will temporarily make the assist not applicable when attribute macro operates on the match expression in question, just like the case in #15310, for most of the current stable toolchain users. This is because the sysroot-abi proc-macro-srv on the current stable [discards] spans for `Group` delimiters in some code paths, which the popular `proc-macro2` crate almost always calls, and it makes the identity of match arm list's brackets lost, leading to the upmapping failure. This has been fixed by #14960, which will land in the next stable, 1.71.

[discards]: 8ede3aae28/src/tools/rust-analyzer/crates/proc-macro-srv/src/abis/abi_sysroot/ra_server.rs (L231)
2023-08-01 08:58:43 +00:00
bors
efc5a813de Auto merge of #15050 - alibektas:14957, r=Veykril
bugfix :  skip doc(hidden) default members

fixes  #14957 . I have two questions :

1.  I am definitely looking for a more idiomatic way for the things I added in `crates/ide-assists/src/utils.rs`. See `FIXME` in that file.
2. Would it be actually better to change `DefaultMethods` to something like

```rust
enum DefaultMethods {
     Only( IgnoreHidden ( bool ) ) ,
     None
}
```

instead of adding a boolean to every function that calls `crates/ide-assists/src/utils.rs::filter_assoc_items`
2023-08-01 08:38:36 +00:00
Max Heller
b9ee4a5167 working for path segments 2023-07-31 21:21:40 -04:00
Lukas Wirth
c7b34e4873 fix: Strip unused token ids from eager macro input token maps 2023-07-31 17:12:17 +02:00
bors
8202b5aaa7 Auto merge of #15366 - Veykril:eager-macro-inputs, r=Veykril
fix: Remove another faulty unwrap (expect)

Like the other ones, this also results in a panic when writing out `include!`  due to the missing tt
2023-07-31 15:09:34 +00:00
Lukas Wirth
bf5624664d fix: Remove another faulty unwrap (expect) 2023-07-31 16:47:45 +02:00
bors
7736b656e2 Auto merge of #15361 - Veykril:eager-macro-inputs, r=Veykril
fix: Expand eager macros to delimited comma separated expression list

Prior to this, we were just parsing it as an expression which works fine for `()` and `[]` calls as those are tuple and array expressions respectively, but if tails for `{}` calls which with my recent changes reported errors for such eager macro invocations.
2023-07-31 14:24:29 +00:00
Max Heller
91581becac update tests 2023-07-30 16:01:59 -04:00
bors
429a3816ad Auto merge of #15363 - HKalbasi:mir, r=HKalbasi
Support `Self` without field in mir lowering
2023-07-30 19:36:50 +00:00
hkalbasi
a9d81ae89c Support Self in mir lowering 2023-07-30 23:05:10 +03:30
bors
cecbed98d8 Auto merge of #15360 - lowr:fix/mbe-transcribe-path-of-different-types, r=HKalbasi
Fixup path fragments upon MBE transcription

Fixes #14367

There are roughly two types of paths: paths in expression context, where a separator `::` between an identifier and its following generic argument list is mandatory, and paths in type context, where `::` can be omitted.

Unlike rustc, we need to transform the parsed fragments back into tokens during transcription. When the matched path fragment is a type-context path and is transcribed as an expression-context path, verbatim transcription would cause a syntax error.

This PR fixes up path fragments by inserting `::` to make sure they are syntactically correct in all contexts. Note that this works because expression-context paths are a strict superset of type-context paths.
2023-07-30 17:29:36 +00:00
Lukas Wirth
7c765d9f9e fix: Expand eager macros to delimited comma separated expression list 2023-07-30 17:31:26 +02:00
Max Heller
c4cff80269 use nodes from actual file 2023-07-30 11:12:49 -04:00
Ryo Yoshida
fd7435d463
Fixup path fragments upon MBE transcription 2023-07-30 23:36:42 +09:00
bors
712b53865f Auto merge of #15359 - Veykril:proc-macro-srv-spawn-err, r=Veykril
Write proc-macro server spawn errors to the status text
2023-07-30 12:39:13 +00:00
Lukas Wirth
bd6ec06237 Write proc-macro server spawn errors to the status text 2023-07-30 14:38:25 +02:00
Lukas Wirth
4172dcc9fd Add triagebot no-merges config 2023-07-30 14:02:03 +02:00
bors
ebcd25d46c Auto merge of #15357 - Veykril:mismatched-macro-def-call, r=Veykril
fix: Do not create fn macro calls with non-fn expanders

Fixes https://github.com/rust-lang/rust-analyzer/issues/15327
2023-07-30 10:55:14 +00:00
Lukas Wirth
df725d6b6d fix: Do not create fn macro calls with non-fn expanders 2023-07-30 12:18:19 +02:00
bors
2266ecf9dd Auto merge of #15356 - Veykril:eager-missing-tt, r=Veykril
fix: Fix bad unwrap in eager_macro_recur

Some logic changed so this path can be hit now with a missing token tree.
2023-07-30 09:41:59 +00:00
Lukas Wirth
3db437cbd6 fix: Fix bad unwrap in eager_macro_recur 2023-07-30 11:41:21 +02:00
Max Heller
784379eb79 wip 2023-07-29 15:23:35 -04:00
Max Heller
4bb7702833 check_edit test 2023-07-29 11:39:59 -04:00
bors
f442c4aad6 Auto merge of #15353 - HKalbasi:mir, r=HKalbasi
Add manual implementation of clone for tuples in mir interpreter

And some other minor changes.

Clone for tuple is not implemented in the std and it is magically implemented by the compiler, so we need this.
2023-07-28 16:02:13 +00:00
hkalbasi
bd2a8ca507 Add manual implementation of clone for tuples in mir interpreter 2023-07-28 18:52:01 +03:30
Max Heller
bc2b70d678 formatting 2023-07-28 09:23:05 -04:00
Max Heller
047bc47ecd
Cleanup
Co-authored-by: LowR <low.ryoshida@gmail.com>
2023-07-28 09:22:22 -04:00
Max Heller
37a8493138 tests 2023-07-28 06:45:35 -04:00
bors
3eba6d30ad Auto merge of #15349 - lowr:fix/fn-def-display-source-code, r=lnicola
Show anonymous fn def type as a fn pointer in source code

Fixes #15346

The second commit is an unrelated change. I can remove it if not desired.
2023-07-28 10:30:07 +00:00
Ryo Yoshida
104d707d6a
Add default implementation for HirWrite methods 2023-07-28 19:11:55 +09:00
Ryo Yoshida
b517aeeca5
Show TyKind::FnDef as a fn pointer in source code 2023-07-28 19:09:38 +09:00
bors
037844c8a0 Auto merge of #15271 - lowr:patch/re-castable, r=HKalbasi
Properly infer types with type casts

This PR reenables `Expectation::Castable` (previous attempt at #14104, reverted by #14120) and implements type cast checks, which enable us to infer a bit more.

Castable expectations are relatively weak -- they only influence the inference if we cannot infer the types by other means. Therefore, we need to defer possible type unification with the casted type until we type check all expressions of the body. This PR adds a struct and slots in `InferenceContext` for the deferred cast checks (c.f. [`CastCheck`] in `rustc_hir_typeck`).

I only implemented the bits that affect the inference result. It should be possible to return type adjustments for well-formed casts and report diagnostics for invalid casts, but I'm leaving them for future work for now.

Fixes #11571
Fixes #15246

[`CastCheck`]: da1d099f91/compiler/rustc_hir_typeck/src/cast.rs (L55)
2023-07-28 07:17:38 +00:00
bors
bc1b0bfa7f Auto merge of #15308 - vsrs:runnable_env_per_platform, r=HKalbasi
Runnable env per platform

This PR adds an option to specify runnables `env` per platform (win32, linux, etc.):
```
{
    "rust-analyzer.runnables.extraEnv": [
            {
                "platform": "win32",
                "env": {
                    "SCITER_BIN_FOLDER": "C:\\Projects\\3rd\\sciter-js-sdk\\bin\\windows\\x64",
                }
            },
            {
                "platform":["linux","darwin"],
                "env": {
                    "SCITER_BIN_FOLDER": "/home/vit/Projects/sciter/sciter-js-sdk/bin/linux/x64",
                }
            }
        ]
}
```
2023-07-28 07:03:09 +00:00
Max Heller
008b639ef5 handle #[cfg]s on generic parameters 2023-07-27 21:17:10 -04:00
Max Heller
9349769363 exclude non-identifier aliases from completion filtering text 2023-07-27 19:33:00 -04:00
hkalbasi
17cc813e92 Support atomic fence intrinsic 2023-07-27 12:28:16 +03:30
Ryo Yoshida
fbec711ada
Don't provide add_missing_match_arms assist when upmapping match arm list failed 2023-07-27 16:43:01 +09:00
Ryo Yoshida
10b5fd1431
Minor refactoring
- use `str::parse()` rather than `FromStr::from_str()`
- use `iter::once()` instead of constructing `Vec` for a single element
2023-07-27 16:30:57 +09:00
bors
b64e5b3919 Auto merge of #15333 - davidbarsky:davidbarsky/downgrade-vscode-to-1.75, r=lnicola
vscode: change minimum VS Code version to 1.75 from 1.78

I previously mentioned [in a comment](https://github.com/rust-lang/rust-analyzer/pull/15265#issuecomment-1633240290) that folks at my employer are on 1.78, but I was incorrect: people are on 1.75. I know this is outside the standard version support policy, but I haven't seen any of the new features in VS Code be used in rust-analyzer. The most applicable feature in those three versions of VS Code that I can find [is lazily resolving code actions](https://code.visualstudio.com/updates/v1_78#_resolve-code-action-commands-in-resolvecodeaction), but it doesn't seem like rust-analyzer is making use of that feature.

(I'll be posting a PR that adds support for `$saved_file` within the next day, so feel free to bump the minimum VS Code version back to 1.78 if/when that PR lands. This just makes vendoring the _actual_ change I'm interested in a little bit easier.)
2023-07-24 16:29:18 +00:00
David Barsky
ba722165a0 vscode: change minimum VS Code version to 1.75 from 1.78 2023-07-24 11:24:24 -04:00
bors
febb3b31ce Auto merge of #15330 - lnicola:sync-from-rust, r=lnicola
minor: sync from downstream
2023-07-24 11:34:24 +00:00
Laurențiu Nicola
a11aed1074 Merge branch 'master' into sync-from-rust 2023-07-24 14:33:32 +03:00