Ryo Yoshida
dac27679f7
fix: resolve path Self
alone in value namespace
2022-08-18 20:12:59 +09:00
bors
d6412b5866
Auto merge of #13034 - lowr:fix/regression-from-12993, r=lowr
...
fix: escape keywords used as names in earlier editions
Fixes #13030
There are keywords in Rust 2018+ that you can use as names without escaping when your crate is in Rust 2015 e.g. "try". We need to be consistent on how to keep track of the names regardless of how they are actually written in each crate. This patch attempts at it by taking such names into account and storing them uniformly in their escaped form.
2022-08-17 09:55:14 +00:00
Ryo Yoshida
a3409c3a83
fix: escape keywords used as names in earlier editions
2022-08-17 18:46:17 +09:00
bors
dd9ead591e
Auto merge of #13043 - Veykril:ide-db-trace, r=Veykril
...
minor: Change tracing event level in apply_change
This is a rather spammy one, it shouldn't be `info`
2022-08-17 07:34:07 +00:00
Lukas Wirth
557c5b4dc5
minor: Change tracing event level in apply_change
2022-08-17 09:32:25 +02:00
bors
baa2cccb24
Auto merge of #13038 - Veykril:rev-12947, r=Veykril
...
Revert #12947 , trigger workspace switches on all structure changes again
Closes https://github.com/rust-lang/rust-analyzer/issues/13029
2022-08-16 17:13:44 +00:00
Lukas Wirth
1f73cbe839
Revert #12947 , trigger workspace switches on all structure changes again
2022-08-16 19:13:10 +02:00
bors
8fa8bf1847
Auto merge of #13037 - jonas-schievink:keyword-hover-setting, r=jonas-schievink
...
feat: Add a setting for keyword hover popups
This adds `rust-analyzer.hover.documentation.keywords.enable`, which defaults to `true` and can be turned off to disable the keyword documentation hover popups, which can be somewhat distracting when triggered by accident, and offer relatively little value if you're already familiar with the language.
Fixes https://github.com/rust-lang/rust-analyzer/issues/12950
2022-08-16 16:18:50 +00:00
Jonas Schievink
7fb7c248c7
Add .enable
suffix
2022-08-16 18:12:15 +02:00
Jonas Schievink
0616cee92b
Add a setting for keyword hover popups
2022-08-16 16:51:40 +02:00
bors
b6fae56e38
Auto merge of #13028 - yue4u:fix/literal-lookup, r=jonas-schievink
...
fix: record completion filtering
close #12975
2022-08-16 13:28:00 +00:00
yue4u
91358bd937
fix: format literal lookup
2022-08-16 01:24:21 +09:00
bors
3903243192
Auto merge of #13027 - jonas-schievink:fix-mismatch-with-trailing-empty-macro, r=jonas-schievink
...
fix: Fix incorrect type mismatch with `cfg_if!` and other macros in expression position
Fixes https://github.com/rust-lang/rust-analyzer/issues/12940
This is a bit of a hack, ideally `MacroStmts` would not exist at all after HIR lowering, but that requires changing how the lowering code works.
2022-08-15 16:06:59 +00:00
Jonas Schievink
8c60813096
Fix lowering of empty macro expressions in trailing position
2022-08-15 18:01:58 +02:00
bors
3561433ef2
Auto merge of #13026 - Veykril:nameres, r=Veykril
...
internal: Make `resolve_name_in_module` a bit more lazy
2022-08-15 14:49:12 +00:00
Lukas Wirth
88b19cc39b
Make resolve_name_in_module a bit more lazy
2022-08-15 16:41:51 +02:00
bors
6d6201299c
Auto merge of #13025 - Veykril:simplify2, r=Veykril
...
Simplify
2022-08-15 14:40:26 +00:00
Lukas Wirth
3f149a63d2
Simplify
2022-08-15 16:40:10 +02:00
bors
5076f50c7a
Auto merge of #13024 - jonas-schievink:hir-pretty, r=jonas-schievink
...
internal: Add an HIR pretty-printer
This improves the "View HIR" command by pretty-printing the HIR to make it much more readable.
Example function:
```rust
fn newline(&mut self) {
match self.buf.chars().rev().skip_while(|ch| *ch == ' ').next() {
Some('\n') | None => {}
_ => writeln!(self).unwrap(),
}
}
```
Previous output:
```
HIR expressions in the body of `newline`:
Idx::<Expr>(0): Path(Path { type_anchor: None, mod_path: ModPath { kind: Super(0), segments: [] }, generic_args: [] })
Idx::<Expr>(1): Field { expr: Idx::<Expr>(0), name: Name(Text("buf")) }
Idx::<Expr>(2): MethodCall { receiver: Idx::<Expr>(1), method_name: Name(Text("chars")), args: [], generic_args: None }
Idx::<Expr>(3): MethodCall { receiver: Idx::<Expr>(2), method_name: Name(Text("rev")), args: [], generic_args: None }
Idx::<Expr>(4): Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("ch"))] }, generic_args: [None] })
Idx::<Expr>(5): UnaryOp { expr: Idx::<Expr>(4), op: Deref }
Idx::<Expr>(6): Literal(Char(' '))
Idx::<Expr>(7): BinaryOp { lhs: Idx::<Expr>(5), rhs: Idx::<Expr>(6), op: Some(CmpOp(Eq { negated: false })) }
Idx::<Expr>(8): Closure { args: [Idx::<Pat>(1)], arg_types: [None], ret_type: None, body: Idx::<Expr>(7) }
Idx::<Expr>(9): MethodCall { receiver: Idx::<Expr>(3), method_name: Name(Text("skip_while")), args: [Idx::<Expr>(8)], generic_args: None }
Idx::<Expr>(10): MethodCall { receiver: Idx::<Expr>(9), method_name: Name(Text("next")), args: [], generic_args: None }
Idx::<Expr>(11): Literal(Char('\n'))
Idx::<Expr>(12): Block { id: BlockId(37), statements: [], tail: None, label: None }
Idx::<Expr>(13): Path(Path { type_anchor: None, mod_path: ModPath { kind: Super(0), segments: [] }, generic_args: [] })
Idx::<Expr>(14): Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("std")), Name(Text("fmt")), Name(Text("Arguments")), Name(Text("new_v1"))] }, generic_args: [None, None, None, None] })
Idx::<Expr>(15): Array(ElementList { elements: [], is_assignee_expr: false })
Idx::<Expr>(16): Ref { expr: Idx::<Expr>(15), rawness: Ref, mutability: Shared }
Idx::<Expr>(17): Array(ElementList { elements: [], is_assignee_expr: false })
Idx::<Expr>(18): Ref { expr: Idx::<Expr>(17), rawness: Ref, mutability: Shared }
Idx::<Expr>(19): Call { callee: Idx::<Expr>(14), args: [Idx::<Expr>(16), Idx::<Expr>(18)], is_assignee_expr: false }
Idx::<Expr>(20): MethodCall { receiver: Idx::<Expr>(13), method_name: Name(Text("write_fmt")), args: [Idx::<Expr>(19)], generic_args: None }
Idx::<Expr>(21): MacroStmts { statements: [], tail: Some(Idx::<Expr>(20)) }
Idx::<Expr>(22): MethodCall { receiver: Idx::<Expr>(21), method_name: Name(Text("unwrap")), args: [], generic_args: None }
Idx::<Expr>(23): Match { expr: Idx::<Expr>(10), arms: [MatchArm { pat: Idx::<Pat>(5), guard: None, expr: Idx::<Expr>(12) }, MatchArm { pat: Idx::<Pat>(6), guard: None, expr: Idx::<Expr>(22) }] }
Idx::<Expr>(24): Block { id: BlockId(36), statements: [], tail: Some(Idx::<Expr>(23)), label: None }
```
Output after this PR:
```rust
fn newline(…) {
match self.buf.chars().rev().skip_while(
|ch| (*ch) == (' '),
).next() {
Some('\n') | None => {},
_ => { // macro statements
self.write_fmt(
std::fmt::Arguments::new_v1(
&[],
&[],
),
)
}.unwrap(),
}
}
```
It also works for consts and statics now.
This should make debugging HIR-lowering related issues like https://github.com/rust-lang/rust-analyzer/issues/12940 much easier.
2022-08-15 12:08:35 +00:00
Jonas Schievink
dcbe892d7c
Add an HIR pretty-printer
2022-08-15 13:51:45 +02:00
bors
b6d59f2bb4
Auto merge of #13020 - lnicola:no-pre-release-flag, r=lnicola
...
minor: Remove redundant --pre-release flag from publish
2022-08-14 18:00:29 +00:00
Laurențiu Nicola
c61237b2b2
Remove redundant --pre-release flag from publish
2022-08-14 20:52:43 +03:00
bors
ebc140ecd7
Auto merge of #13000 - shoffmeister:patch-1, r=lnicola
...
Take into account renamed extension id when launching
2022-08-14 17:51:38 +00:00
bors
010f68cacf
Auto merge of #13017 - Veykril:vscode-diag-workaround, r=Veykril
...
Pad empty diagnostic messages in relatedInformation as well
Follw up to https://github.com/rust-lang/rust-analyzer/pull/13016
2022-08-13 18:50:38 +00:00
Lukas Wirth
614969baa7
Pad empty diagnostic messages in relatedInformation as well
2022-08-13 20:49:00 +02:00
bors
bbe5637bbf
Auto merge of #13016 - Veykril:vscode-diag-workaround, r=Veykril
...
Move VSCode diagnostics workaroudn into client code
2022-08-13 18:35:09 +00:00
Lukas Wirth
ec8256dd80
Move VSCode diagnostics workaroudn into client code
2022-08-13 20:30:30 +02:00
bors
306687b640
Auto merge of #13014 - Veykril:simplify, r=Veykril
...
minor: Simplify `GlobalState::handle_event`
2022-08-13 18:03:56 +00:00
Lukas Wirth
038c36a1f5
Simplify GlobalState::handle_event
2022-08-13 20:03:06 +02:00
bors
5941dec0c1
Auto merge of #13010 - Veykril:build-script-probes, r=Veykril
...
Do not unconditionally succeed RUSTC_WRAPPER checks when run by build scripts
rust-analyzer's RUSTC_WRAPPER unconditionally succeeds `cargo check`
invocations tripping up build scripts using `cargo check` to probe for
successful compilations. To prevent this from happening the RUSTC_WRAPPER
now checks if it's run from a build script by looking for the
`CARGO_CFG_TARGET_ARCH` env var that cargo sets only when running build
scripts.
2022-08-13 14:12:38 +00:00
Lukas Wirth
72ae308c73
Do not unconditionally succeed RUSTC_WRAPPER checks when run by build scripts
...
rust-analyzer's RUSTC_WRAPPER unconditionally succeeds `cargo check`
invocations tripping up build scripts using `cargo check` to probe for
successful compilations. To prevent this from happening the RUSTC_WRAPPER
now checks if it's run from a build script by looking for the
`CARGO_CFG_TARGET_ARCH` env var that cargo sets only when running build
scripts.
2022-08-13 12:13:48 +02:00
shoffmeister
fd58459373
Take into account renamed extension id when launching
...
Signed-off-by: Stefan Hoffmeister <stefan.hoffmeister@econos.de>
2022-08-12 18:06:58 +02:00
bors
f982c76161
Auto merge of #13007 - lnicola:node-16, r=lnicola
...
Use Node 16 on CI and upgrade lockfile version
Code is on 16 too, there's hopefully no need to keep using the old version.
2022-08-12 15:23:18 +00:00
Laurențiu Nicola
19da03291d
Upgrade npm lockfile
2022-08-12 18:22:14 +03:00
Laurențiu Nicola
1ce978370b
Use Node 16 in CI workflows
2022-08-12 18:19:48 +03:00
bors
cee1e157d7
Auto merge of #12993 - lowr:patch/swap-name-and-escaped-name, r=Veykril
...
Make `Name` hold escaped name
Resolves #12787
Resolves rust-lang/rust#99361
This PR effectively swaps `Name` and `EscapedName` in hir. In other words, it makes `Name` hold and print escaped raw identifiers and introduces another struct `UnescapedName` for cases where you need to print names without "r#" prefix.
My rationale is that it makes it easier for us to format an escaped name into string, which is what we want when we serialize names in general. This is because we format a name into string usually when we are presenting it to the users and arguably they expect its escaped form as that's what they see and write in the source code.
I split the change for `Name` into 3 commits to make it easier to follow but it also made some tests fail in the intermediate commits. I can squash them into a commit after the review if desired. I've also made similar changes for `ModPath` and `EscapedModPath` as it makes them consistent with `Name`.
For reference, there was a brief discussion on this in [a zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/escaping.20.60Name.60s ).
2022-08-12 14:53:45 +00:00
bors
696bee3246
Auto merge of #12997 - Veykril:no-such-field, r=Veykril
...
fix: Fix panic in `no_such_field` when using tuple fields on record structs
2022-08-11 08:42:04 +00:00
Lukas Wirth
1bb58205f0
Fix panic in no_such_field when using tuple fields on record structs
2022-08-11 10:41:30 +02:00
Ryo Yoshida
ba6db3e9b0
Add test for runnables with raw identifiers
2022-08-11 03:41:23 +09:00
Ryo Yoshida
018266a7ff
Make ModPath
display escaped path
2022-08-11 03:41:10 +09:00
Ryo Yoshida
8fe73a2240
Make tests pass
2022-08-11 01:16:35 +09:00
Ryo Yoshida
4322cf7f5b
Remove EscapedName
2022-08-11 01:11:18 +09:00
Ryo Yoshida
53ec791dc6
Add UnescapedName
and make Name
hold escaped name
2022-08-11 01:03:08 +09:00
bors
3eb340fa4d
Auto merge of #12989 - lnicola:rm-1-64-abi, r=Veykril
...
internal: Remove incomplete 1.64 ABI
This no longer works for current nightlies and should not be needed any more, since we can use the toolchain's proc macro server instead.
2022-08-10 14:53:21 +00:00
bors
b1e9bcddc2
Auto merge of #12984 - Veykril:keep-going, r=Veykril
...
Use `--keep-going` cargo flag when building build scripts
See https://github.com/rust-lang/rust-analyzer/issues/12973#issuecomment-1209159426
2022-08-10 14:43:23 +00:00
bors
e70681f208
Auto merge of #12992 - lowr:fix/type-inference-for-byte-string-pat, r=Veykril
...
fix: infer byte string pattern as `&[u8]` when matched against slices
Fixes #12630
c.f. [rustc_typeck](1603a70f82/compiler/rustc_typeck/src/check/pat.rs (L388-L404)
)
2022-08-10 11:05:02 +00:00
Ryo Yoshida
ffc6b42901
fix: infer byte string pattern as &[u8]
when matched against slices
2022-08-10 19:17:13 +09:00
bors
d79d9e1a2e
Auto merge of #12990 - edwin0cheng:improve-ws, r=Veykril
...
fix: Improve whitespace insertion in mbe
Related: https://github.com/rust-lang/rust-analyzer/issues/12260#issuecomment-1126957162
2022-08-10 09:29:19 +00:00
Edwin Cheng
c47914c6cf
Fixes tests
2022-08-10 16:29:23 +08:00
Edwin Cheng
23e17cd581
Improve insert whitespace in mbe
2022-08-10 16:28:56 +08:00