-
Notifications
You must be signed in to change notification settings - Fork 13.3k
⬆️ rust-analyzer #100908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
⬆️ rust-analyzer #100908
Conversation
…chievink 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 rust-lang/rust-analyzer#12940 much easier.
internal: Make `resolve_name_in_module` a bit more lazy
…iling-empty-macro, r=jonas-schievink fix: Fix incorrect type mismatch with `cfg_if!` and other macros in expression position Fixes rust-lang/rust-analyzer#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.
…ievink fix: record completion filtering close rust-lang#12975
…, 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 rust-lang/rust-analyzer#12950
Revert rust-lang#12947, trigger workspace switches on all structure changes again Closes rust-lang/rust-analyzer#13029
This change improves the `generate_function` assist to support generating static methods/associated functions using the `Self::assoc()` syntax. Previously, one could generate a static method, but only when specifying the type name directly (like `Foo::assoc()`). After this change, `Self` is supported as well as the type name. Fixes rust-lang#13012
minor: Change tracing event level in apply_change This is a rather spammy one, it shouldn't be `info`
fix: escape keywords used as names in earlier editions Fixes rust-lang#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.
This PR will fix some typos detected by [typos]. There are also some other typos in the function names, variable names, and file names, which I leave as they are. I'm more certain that typos in comments should be fixed. [typos]: https://github.com/crate-ci/typos
fix: a bunch of typos This PR will fix some typos detected by [typos]. There are also some other typos in the function names, variable names, and file names, which I leave as they are. I'm more certain that typos in comments should be fixed. [typos]: https://github.com/crate-ci/typos
The "Run" feature of rust-analyzer is super useful, especially for running individual tests or test-modules during development. One common pattern in rust development is to develop tests in the same file as production code, inside a module (usually called `test` or `tests`) marked with `#[cfg(test)]`. Unforunately, this pattern is not well supported by r-a today, as a test module won't show up as a runnable unless the cursor is inside it. In my experience, it is quite common to want to run the tests associated with some production code immediately after editing it, not only after editing the tests themselves. As such it would be better if test modules were available from the "Run" menu even when the cursor is outside the test module. This change updates the filtration logic for runnables in `handlers::handle_runnables` to special case `RunnableKind::TestMod`, making test modules available regardless of the cursor location. Other `RunnableKind`s are unnaffected. Fixes rust-lang#9589
Implement lsp extension for cancelling running flychecks Fixes rust-lang/rust-analyzer#4828
We unconditionally pass an edition parameter to rustfmt, for some crates this might fail rustfmt so instead of swallowing the error, at least Log it on a level that is logged by default so users won't be completely confused about it. See for context rust-lang/rust-analyzer#10209 Closes rust-lang/rust-analyzer#10209
Log rustfmt parsing errors as warnings We unconditionally pass an edition parameter to rustfmt, for some crates this might fail rustfmt so instead of swallowing the error, at least Log it on a level that is logged by default so users won't be completely confused about it. See for context rust-lang/rust-analyzer#10209 Closes rust-lang/rust-analyzer#10209
feat: Improved inline_call to replace `Self` Fixes rust-lang#13060
…soc-2, r=Veykril feat: Generate static method using Self::assoc() syntax This change improves the `generate_function` assist to support generating static methods/associated functions using the `Self::assoc()` syntax. Previously, one could generate a static method, but only when specifying the type name directly (like `Foo::assoc()`). After this change, `Self` is supported as well as the type name. Fixes rust-lang#13012
…kril document interaction of checkOnSave.overrideCommand and multiple linked projects Cc rust-lang/rust-analyzer#10793 r? `@Veykril`
minor: Bump deps
internal: Build release binaries on `ubuntu-20.04` Ubuntu 18.04 is still available until December 1st, but will start failing from time to time, which is not something we want when building nightlies.
…predicate, r=lowr Consider bounds on inherent impl in method resolution There are three type-related things we should consider in method resolution: `Self` type, receiver type, and impl bounds. While we check the first two and impl bounds on trait impls, we've been ignoring the impl bounds on inherent impls. With this patch rust-analyzer now takes them into account and is able to select the appropriate inherent method. Resolves rust-lang#5441 Resolves rust-lang#12308
@bors r+ rollup=iffy
|
☀️ Test successful - checks-actions |
Finished benchmarking commit (7c142a6): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Footnotes |
r? @ghost