Commit Graph

26016 Commits

Author SHA1 Message Date
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
Laurențiu Nicola
0155385b57 Merge commit '99718d0c8bc5aadd993acdcabc1778fc7b5cc572' into sync-from-ra 2023-07-24 12:21:34 +03:00
bors
99718d0c8b Auto merge of #15303 - oxalica:fix/byte-escape-highlight, r=lowr
Fix highlighting of byte escape sequences

Currently non-UTF8 escape sequences in byte strings and any escape sequences in byte literals are ignored.
2023-07-22 20:25:40 +00:00
oxalica
51b35ccb1b
Add comments for why skip highlighting for invalid char/byte literals 2023-07-23 04:24:35 +08:00
bors
c99bb3c782 Auto merge of #15281 - tetsuharuohzeki:split-ci-steps, r=lnicola
editor/code: Break down CI steps to know what is failing easily

This do the thing I mentioned in https://github.com/rust-lang/rust-analyzer/pull/15265#issuecomment-1634424385

This aims to improve CI status check more readable.

I tried to use [`jobs.<job_id>.if`](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idif) to make the configuration
more shortly once.

But it could not fire the `end-success` or `end-failure` status if some jobs in the workflow were skipped. This causes an integration problem with bors.

By their reasons, this patch still uses `jobs.<job_id>.steps[*].if`.

---

To do this change, we reorganize npm-script.

| previous           | after                                  |
|--------------------|----------------------------------------|
| `npm run lint`     | `npm run lint && npm run format:check` |
| `npm run fix`      | `npm run lint:fix && npm run format`   |

The previous `npm run fix` sometimes does not complete fix automatically because ESLint's autofix doees not follow prettier's formatting. So we need to run `npm run lint:fix && npm run format` by this order.
2023-07-22 16:53:21 +00:00
Tetsuharu Ohzeki
5cca093fa8 editor/code: Break down CI steps to know what is failing easily
To do this change, we reorganize npm-script.

| previous           | after                                  |
|--------------------|----------------------------------------|
| `npm run lint`     | `npm run lint && npm run format:check` |
| `npm run fix`      | `npm run lint:fix && npm run format`   |

The previous `npm run fix` sometimes does not complete fix automatically
because ESLint's autofix doees not follow prettier's formatting.
So we need to run `npm run lint:fix && npm run format` by this order.
2023-07-23 01:51:57 +09:00
bors
b17be2720a Auto merge of #15277 - 1Kinoti:pub-assist, r=lowr
limit `change_visibility` assist to applicable items

this pr limits the `change_visibility` assist to applicable items. top level items in this context means items that are not nested within `fn`s or `trait`s.

now
```rs
fn foo {
    // assists on this `struct` keyword won't include `change_visibility`
    struct Bar {}
}

trait Foo {
   // same with the `fn` here
   fn bar();
}
```
2023-07-22 15:02:15 +00:00
1Kinoti
65823b0c74 limit change_visibility assist to applicable items 2023-07-22 17:16:51 +03:00
bors
a317fa865c Auto merge of #15325 - HKalbasi:mir, r=flodiebold
Normalize expected ty in call arguments

fix #15321

I'm not sure if we should do this, or add a normalize in the beginning of `infer_expr_inner`, or somewhere else. r? `@lowr`
2023-07-22 08:14:06 +00:00
hkalbasi
b7d91ca5b2 Normalize expected ty in call arguments 2023-07-22 01:06:58 +03:30
bors
899dd84b4d Auto merge of #15323 - lowr:patch/dep-kind-no-alloc, r=lnicola
internal: optimize `DepKindInfo` -> `DepKind` conversion

We don't need to allocate a `Vec`, nor do we need sorting.
2023-07-21 10:49:45 +00:00
Ryo Yoshida
dfb32cdf10
Optimize DepKindInfo -> DepKind conversion
We don't need to allocate a `Vec`, nor do we need sorting.
2023-07-21 17:10:42 +09:00
bors
59d35d24a7 Auto merge of #15320 - lowr:fix/incorrect-name-case-for-inner-items, r=HKalbasi
Report `incorrect-ident-case` for inner items

Fixes #15319

Although we have been collecting the diagnostics for inner items within function bodies, we were discarding them and never reported to the users. This PR makes sure that they are all reported and additionally collects the diagnostics for inner items within const bodies, static bodies, and enum variant bodies.
2023-07-21 06:41:30 +00:00
Ryo Yoshida
33b7b45f67
Report incorrect case for inner items within all bodies 2023-07-21 15:07:55 +09:00
Ryo Yoshida
b53a07835b
Report incorrect case for fn inner items 2023-07-21 15:07:49 +09:00
bors
994f4f6e2e Auto merge of #15290 - igorskyflyer:igorskyflyer-dx-install-extension, r=lnicola
editor/code: [DX] Use notification command links for debugger installation

This PR improves DX (developer experience) when installing the VS Code extension for the first time. When doing so and trying to debug a Rust file, we get an error notification that either CodeLLDB or C++ extension/debugger should be installed (see image below).

<div align="center">
	<img src="https://github.com/rust-lang/rust-analyzer/assets/20957750/e8ebeb1e-85f4-44e2-b79f-c48cf52e5f36" alt="Rust, prompt to install debug extension">
</div>

The PR enhances the links in the given notification and upon clicking instead of opening the Web page of the extension it installs the extension immediately, without the need to leave the editor.

Note: the feature needs to be refined, maybe an "install in progress" message or something similar, I left that for you guys to decide and implement. I think it also possible to first open the sidebar, open the Extensions tab, then run the extension installation command which would make it more user-friendly.

P.S. it is also possible to open the extension's details in VS Code directly via the same links and then the user would have to manually click on the Install button - if installation is not the desired behavior.

Happy coding! 🎉
2023-07-20 14:20:34 +00:00
igorskyflyer
5d67cbea43 Use notification command links for debugger installation 2023-07-20 15:41:08 +02:00
bors
be82869dd5 Auto merge of #15317 - HKalbasi:mir, r=HKalbasi
Lookup super traits in `is_dyn_method`
2023-07-20 12:30:45 +00:00
hkalbasi
ed8e1fd472 Lookup super traits in is_dyn_method 2023-07-20 15:43:42 +03:30
bors
cbf3713348 Auto merge of #15313 - prez:patch-1, r=lnicola
docs: Add example on how to change configuration options in Kate

closes #15305
2023-07-20 09:56:26 +00:00
prez
b6f31f0fee docs: Add example on how to change configuration options in Kate 2023-07-20 11:47:41 +02:00
bors
6b8eb75e12 Auto merge of #15316 - HKalbasi:mir, r=HKalbasi
Pass `TraitEnvironment` into `layout_ty` and `const_eval`

We need to do either this or get rid of trait environment in `normalize_ty`. Let's go with this for now.
2023-07-20 09:39:06 +00:00
hkalbasi
eb143383c3 Pass TraitEnvironment into layout_ty and const_eval 2023-07-20 13:08:38 +03:30
bors
cecbd3f84a Auto merge of #15312 - alexkirsz:alexkirsz/resolve-deref-raw-follow-up, r=lnicola
Don't follow raw pointer derefs when considering method receiver candidates

In https://github.com/rust-lang/rust-analyzer/pull/15118, I enabled following raw pointer derefs when considering self type candidates. However, I also inadvertently enabled it for receiver type candidates, which is invalid and causes false positives (see new test).
2023-07-19 17:52:17 +00:00
Alex Kirszenberg
5187533495 Don't follow raw pointer derefs for method receiver type candidates 2023-07-19 19:48:56 +02:00
oxalica
1f35e4d3f1
Introduce invalidEscapeSequence semantic token type 2023-07-19 15:12:53 +08:00
bors
3759c41d3c Auto merge of #15287 - lowr:internal/remove-crate-vis, r=lnicola
internal: remove `crate` visibility modifier

This PR removes `crate` as a now-unaccepted experimental visibility modifier from our parser. This feature has been [unaccepted] and [removed] from rustc more than a year ago, so I don't think this removal affects anyone.

[unaccepted]: https://github.com/rust-lang/rust/issues/53120#issuecomment-1124065083
[removed]: https://github.com/rust-lang/rust/pull/97239
2023-07-18 14:03:32 +00:00
vsrs
08b3b2a56d Fix lint 2023-07-18 18:06:20 +07:00
vsrs
7f29f016f3 Add docs 2023-07-18 17:58:51 +07:00
oxalica
59a3e42ac9
Fix unescaping of C string literals 2023-07-18 18:52:34 +08:00
vsrs
3468b093bd Platform specific runnables env 2023-07-18 17:51:57 +07:00