Commit graph

12888 commits

Author SHA1 Message Date
Kirill Bulatov
2bb80a4f03 Also replace the associated types with iter 2020-10-10 21:39:57 +03:00
Kirill Bulatov
9a72b7bccd Add a test 2020-10-10 20:02:38 +03:00
bors[bot]
b7596d2483
Merge #5858
5858: Draft: Show reason for failed rename refactoring r=rherrmann a=rherrmann

Return an error with a meaningful message for requests to
`textDocument/rename` if the operation cannot be performed.
Pass errors, raised by rename handling code to the LSP runtime.

As a consequence, the VS Code client shows and logs the request
as if a server-side programming error occured.
Screenshot of a rename error showing in VS Code
![invalid-rename-ui](https://user-images.githubusercontent.com/607182/91059560-2c08a380-e62a-11ea-9297-f092db935a3b.png)

I would kindly ask to get feedback from the maintainers if they can spare the time:
* Is the general direction of the proposed changes acceptable?
* I'm new to Rust. The code feels clumsy and redundant, please suggest improvements
if you find the time for. E.g. is there a simple replacement for `RenameError`?
* Should presenting the error with proper severity (i.e. not as a programming error) be part of this change or in a followup change?

See https://github.com/rust-analyzer/rust-analyzer/issues/3981

Co-authored-by: Rüdiger Herrmann <ruediger.herrmann@gmx.de>
2020-10-10 11:59:25 +00:00
Rüdiger Herrmann
e90931a204 Show reason for failed rename refactoring
Return an error with a meaningful message for requests to
`textDocument/rename` if the operation cannot be performed.
Pass errors raised by rename handling code to the LSP runtime.

As a consequence, the VS Code client shows and logs the request
as if a server-side programming error occured.

Resolves https://github.com/rust-analyzer/rust-analyzer/issues/3981
2020-10-10 13:46:10 +02:00
bors[bot]
05261f5aeb
Merge #6176
6176: add eprintln in fmt-like postfix r=SomeoneToIgnore a=bnjjj



Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-09 23:16:19 +00:00
bors[bot]
b0eb01eddd
Merge #6187
6187: Remove release build overrides r=jonas-schievink a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-10-09 18:53:37 +00:00
bors[bot]
c423738921
Merge #6189
6189: adt: correctly inherit field visibility from enum r=jonas-schievink a=jonas-schievink

Previously, "find all references" on a variant field wouldn't find any
references outside the defining module. This is because variant fields
were incorrectly assumed to be private, like struct fields without
explicit visibility, but they actually inherit the enum's visibility.

bors r+ 🤖 

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-10-09 18:47:52 +00:00
Jonas Schievink
5dcbf03d0f adt: correctly inherit field visibility from enum
Previously, "find all references" on a variant field wouldn't find any
references outside the defining module. This is because variant fields
were incorrectly assumed to be private, like struct fields without
explicit visibility, but they actually inherit the enum's visibility.
2020-10-09 20:46:45 +02:00
bors[bot]
cde189c5d5
Merge #6188
6188: Treat `ast::Name` in field patterns as use r=jonas-schievink a=jonas-schievink

bors r+ 🤖 

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-10-09 17:57:20 +00:00
Jonas Schievink
210456aeaa Treat ast::Name in field patterns as use 2020-10-09 19:56:54 +02:00
Laurențiu Nicola
cca330ef53 Remove release build overrides 2020-10-09 19:55:30 +03:00
bors[bot]
95c498d913
Merge #6185
6185: Add note if RUST_SRC_PATH is likely to be wrong r=jonas-schievink a=jonas-schievink

bors r+ 🤖

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-10-09 14:18:29 +00:00
Jonas Schievink
55ecfbb99b
Update crates/project_model/src/sysroot.rs
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-10-09 16:17:05 +02:00
Jonas Schievink
7d0772e796 Add note if RUST_SRC_PATH is likely to be wrong 2020-10-09 16:11:16 +02:00
bors[bot]
c1a8c03299
Merge #6181
6181: Fix source_to_def for named enum variant fields r=jonas-schievink a=jonas-schievink

bors r+ 🤖

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-10-09 01:00:18 +00:00
Jonas Schievink
468b804856 Fix source_to_def for named enum variant fields 2020-10-09 02:57:35 +02:00
Benjamin Coenen
36459284c7 add eprintln in fmt-like postfix
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-08 20:53:39 +02:00
bors[bot]
636b413e14
Merge #6173
6173: Bump rustc_lexer, cfg-if to 1.0 and add new license to check r=kjeremy a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-10-08 15:58:48 +00:00
kjeremy
13bb0404a8 Bump rustc_lexer, cfg-if to 1.0 and add new license to check 2020-10-08 10:39:02 -04:00
bors[bot]
e6a05e6566
Merge #5651
5651: Add track_env_var to the proc macro server r=kjeremy a=lnicola

See https://github.com/rust-lang/rust/pull/74653.

Fixes #6054.
Fixes #5640, maybe.

Should be merged when 1.47 is released.

Proc macros still don't work for me, but it no longer crashes.



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-10-08 14:27:30 +00:00
Laurențiu Nicola
3d169bd3f4 Add track_env_var to the proc macro server 2020-10-08 17:06:20 +03:00
bors[bot]
e95e666b10
Merge #6161
6161: Bump chalk to use latest git to get upstream fix r=jonas-schievink a=Ameobea

 * Chalk very recently (like an hour ago) merged a fix that prevents rust analyzer from panicking.  This allows it to be usable again for code that hits those situations.  See #6134, #6145, Probably #6120

Co-authored-by: Casey Primozic <me@ameo.link>
2020-10-07 20:46:33 +00:00
Casey Primozic
37df2138ec
Switch from git to latest tagged release of chalk deps 2020-10-07 12:11:22 -07:00
bors[bot]
83a651b123
Merge #6154
6154: Shorten type hints for std::iter Iterators r=SomeoneToIgnore a=Veykril

Fixes #3750.

This re-exports the `hir_expand::name::known` module to be able to fetch the `Iterator` and `iter` names.
I'm not sure if there is anything to do with `Solution::Ambig` in `normalize_trait_assoc_type` or whether discarding those results is always wanted.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-07 11:52:05 +00:00
Lukas Wirth
783af171f7 Clean up inlay_hints 2020-10-07 13:18:12 +02:00
Aleksey Kladov
5359e8f742 minor 2020-10-07 13:11:33 +02:00
bors[bot]
76c68dbefe
Merge #6167
6167: Add comparisons guideline to style r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-10-07 11:03:49 +00:00
Aleksey Kladov
1688e481b3 minor 2020-10-07 13:03:13 +02:00
Aleksey Kladov
6976494781 Add comparisons guideline to style 2020-10-07 12:57:49 +02:00
Aleksey Kladov
fdf2f6226b Reorg style 2020-10-07 12:50:46 +02:00
bors[bot]
2aa46034c2
Merge #6166
6166: Better progress API r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-10-07 10:17:14 +00:00
Aleksey Kladov
6219142c96 Better progress API
Percentage is a UI concern, the physical fact here is fraction. It's
sad that percentage bleeds into the protocol level, we even duplicated
this bad API ourselves!
2020-10-07 12:15:37 +02:00
Lukas Wirth
e106857e80 Shorten iterator hints for std::iter iterators behind references 2020-10-07 12:14:08 +02:00
bors[bot]
67c76c35a3
Merge #6165
6165: Cleanup r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-10-07 09:55:44 +00:00
Aleksey Kladov
fd8622e1ec Cleanup 2020-10-07 11:55:20 +02:00
bors[bot]
faddea9353
Merge #6158
6158: Fix for negative literals in macros r=matklad a=cutsoy

_This pull request fixes #6028._

When writing `-42.0f32` in Rust, it is usually parsed as two different tokens (a minus operator and a float literal).

But a procedural macro can also generate new tokens, including negative [float literals](https://doc.rust-lang.org/stable/proc_macro/struct.Literal.html#method.f32_suffixed):

```rust
#[proc_macro]
fn example_verbose(input: TokenStream) -> TokenStream {
    let literal = Literal::f32_suffixed(-42.0);
    quote! { #literal }
}
```

or even shorter

```rust
#[proc_macro]
fn example(input: TokenStream) -> TokenStream {
    let literal = -42.0f32;
    quote! { #literal }
}
```

Unfortunately, these currently cause RA to crash:

```
thread '<unnamed>' panicked at 'Fail to convert given literal Literal {
    text: "-42.0f32",
    id: TokenId(
        4294967295,
    ),
}', crates/mbe/src/subtree_source.rs:161:28
```

This pull request contains both a fix 8cf9362 and a unit test 27798ee. In addition, I installed the patched server with `cargo xtask install --server` and verified in VSCode that it no longer crashes when a procedural macro returns a negative number literal.

Co-authored-by: Tim <tim@glacyr.com>
2020-10-07 09:32:47 +00:00
Lukas Wirth
209e9b9926 Shorten iterator chain hints 2020-10-07 11:30:42 +02:00
bors[bot]
a184c83535
Merge #6160
6160: Add validation check for ambiguous trait objects r=matklad a=Veykril

Fixes #285.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-07 09:12:09 +00:00
bors[bot]
761c87963d
Merge #6159
6159: Document "*.mutable" trick in manual r=matklad a=stanciuadrian

Closes #5803.

Co-authored-by: Adrian Stanciu <stanciu.adrian@gmail.com>
2020-10-07 09:05:58 +00:00
Lukas Wirth
c133651e0a Move IntoIterator into FamousDefs 2020-10-07 10:14:42 +02:00
Casey Primozic
13bdadb515
Make unimplemented match variants explicit 2020-10-06 23:56:31 -07:00
Casey Primozic
f40e86e141
todo!() -> unimplemented!() // FIXME for CI 2020-10-06 15:19:34 -07:00
Casey Primozic
56a8a7645f
Bump chalk to use latest git to get fix
* Chalk very recently (like an hour ago) merged a fix that prevents rust analyzer from panicking.  This allows it to be usable again for code that hits those situations.  See #6134, #6145, Probably #6120
2020-10-06 15:05:20 -07:00
Lukas Wirth
6f38552edb Add validation check for ambiguous trait objects 2020-10-06 23:52:00 +02:00
Adrian Stanciu
f7641b2e35
Update manual.adoc 2020-10-07 00:44:32 +03:00
Tim
27798ee575
Added unit test for negative number literals in macros. 2020-10-06 22:28:13 +02:00
Tim
8cf9362984
Fixed parsing of negative number literals in macros. 2020-10-06 22:28:13 +02:00
Lukas Wirth
c6f1de6ac5 Use FamousDefs for shorten_iterator hint 2020-10-06 21:25:39 +02:00
bors[bot]
bf1043cac2
Merge #6128
6128: Trim all trailing whitespace in onEnter r=matklad a=repnop

Fixes #5848

Co-authored-by: Wesley Norris <repnop@outlook.com>
2020-10-06 18:17:49 +00:00
bors[bot]
6409d7e810
Merge #6157
6157: Document privacy invariant of SyntaxPtr r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-10-06 18:06:38 +00:00