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>
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
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>
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.
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>
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>
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>
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>
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>
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!
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>
* 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