Skip to content
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

replace doesn't work on Theia but others like add labels or remove does #18868

Open
ChayimFriedman2 opened this issue Jan 7, 2025 · 11 comments

Comments

@ChayimFriedman2
Copy link
Contributor

Discussed in #18839

Originally posted by hsnoil January 6, 2025
When using theia, and you have something like this it doesn't work.

enum Pet {
    Cat,
    Dog
}


fn main() {
    let pet = Pet::Cat;
    match pet {
        
    }
}

But if you were to just add like add_label_to_loop, it works:

 fn main() {
     loop {
         break;
         continue;
     }
 }

Another interesting case is this one:

 struct X();
 mod foo {
     use super::X;
 }

If you do "split import" or "remove whole use item" they work but remove all unused imports doesn't.

From the looks of it, replacing with syntax::ted::replace is the issue. Replacing, adding and deleting works unless it touches that function.

Is this an issue with Theia or an underlying issue with how rowan's splice_children works? I know it works with vscode, but sometime things are done in workaround manners (like match arms in analyzer plugin has a bunch of FIXME there)

For now I opened a ticket with Theia:

eclipse-theia/theia#13922

But it has been a while and likely it being rust and not javascript, if someone isn't explicitly familiar with rust I can understand the hesitation to go through it all. Anyone have any idea what the issue can be?

Edit:

I compiled it with with debug=2 and I got this error:

thread 'Worker' panicked at /home/user/Develop/rowan/src/ast.rs:99:9:
tree is mutable
stack backtrace:
   0: rust_begin_unwind
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:652:5
   1: core::panicking::panic_fmt
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/panicking.rs:72:14
   2: rowan::ast::SyntaxNodePtr<L>::try_to_node
             at /home/user/Develop/rowan/src/ast.rs:99:9
   3: rowan::ast::SyntaxNodePtr<L>::to_node
             at /home/user/Develop/rowan/src/ast.rs:81:9
   4: ide_db::source_change::TreeMutator::make_syntax_mut
             at /home/user/Develop/rust-analyzer-master/crates/ide-db/src/source_change.rs:230:9
   5: ide_db::source_change::SourceChangeBuilder::make_syntax_mut
             at /home/user/Develop/rust-analyzer-master/crates/ide-db/src/source_change.rs:282:9
   6: ide_assists::handlers::add_missing_match_arms::add_missing_match_arms::{{closure}}
             at /home/user/Develop/rust-analyzer-master/crates/ide-assists/src/handlers/add_missing_match_arms.rs:274:53
   7: ide_assists::assist_context::Assists::add::{{closure}}
             at /home/user/Develop/rust-analyzer-master/crates/ide-assists/src/assist_context.rs:161:65
   8: ide_assists::assist_context::Assists::add_impl
             at /home/user/Develop/rust-analyzer-master/crates/ide-assists/src/assist_context.rs:191:13
   9: ide_assists::assist_context::Assists::add
             at /home/user/Develop/rust-analyzer-master/crates/ide-assists/src/assist_context.rs:161:9
  10: ide_assists::handlers::add_missing_match_arms::add_missing_match_arms
             at /home/user/Develop/rust-analyzer-master/crates/ide-assists/src/handlers/add_missing_match_arms.rs:201:5
  11: ide_assists::assists::{{closure}}
             at /home/user/Develop/rust-analyzer-master/crates/ide-assists/src/lib.rs:95:9
  12: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::for_each
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/slice/iter/macros.rs:252:21
  13: ide_assists::assists
             at /home/user/Develop/rust-analyzer-master/crates/ide-assists/src/lib.rs:94:5
  14: ide::Analysis::assists_with_fixes::{{closure}}
             at /home/user/Develop/rust-analyzer-master/crates/ide/src/lib.rs:730:27
  15: ide::Analysis::with_db::{{closure}}
             at /home/user/Develop/rust-analyzer-master/crates/ide/src/lib.rs:826:29
  16: std::panicking::try::do_call
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:559:40
  17: __rust_try
  18: std::panicking::try
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:523:19
  19: std::panic::catch_unwind
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panic.rs:149:14
  20: salsa::Cancelled::catch
             at /home/user/Develop/rust-analyzer-master/crates/salsa/src/lib.rs:633:15
  21: ide::Analysis::with_db
             at /home/user/Develop/rust-analyzer-master/crates/ide/src/lib.rs:826:9
  22: ide::Analysis::assists_with_fixes
             at /home/user/Develop/rust-analyzer-master/crates/ide/src/lib.rs:719:9
  23: rust_analyzer::handlers::request::handle_code_action_resolve
             at /home/user/Develop/rust-analyzer-master/crates/rust-analyzer/src/handlers/request.rs:1384:19
  24: rust_analyzer::handlers::dispatch::RequestDispatcher::on_with_thread_intent::{{closure}}::{{closure}}
             at /home/user/Develop/rust-analyzer-master/crates/rust-analyzer/src/handlers/dispatch.rs:219:17
  25: std::panicking::try::do_call
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:559:40
  26: __rust_try
  27: std::panicking::try
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:523:19
  28: std::panic::catch_unwind
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panic.rs:149:14
  29: rust_analyzer::handlers::dispatch::RequestDispatcher::on_with_thread_intent::{{closure}}
             at /home/user/Develop/rust-analyzer-master/crates/rust-analyzer/src/handlers/dispatch.rs:217:26
  30: rust_analyzer::task_pool::TaskPool<T>::spawn::{{closure}}
             at /home/user/Develop/rust-analyzer-master/crates/rust-analyzer/src/task_pool.rs:26:33
  31: stdx::thread::pool::Pool::spawn::{{closure}}
             at /home/user/Develop/rust-analyzer-master/crates/stdx/src/thread/pool.rs:82:13
  32: core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/ops/function.rs:250:5
  33: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/alloc/src/boxed.rs:2063:9
  34: stdx::thread::pool::Pool::new::{{closure}}
             at /home/user/Develop/rust-analyzer-master/crates/stdx/src/thread/pool.rs:61:29
  35: stdx::thread::Builder::spawn::{{closure}}
             at /home/user/Develop/rust-analyzer-master/crates/stdx/src/thread.rs:66:13
```</div>
@alibektas
Copy link
Member

alibektas commented Jan 8, 2025

@hsnoil could you provide more info on

I compiled it with with debug=2 and I got this error

As you claim the problem is there but it is realllly hard to track down when I can't check what is happening on the editor side.

@hsnoil
Copy link

hsnoil commented Jan 8, 2025

@alibektas - What information do you need?

Also, I didn't actually need debug=2, just needed to compile rowan in debug mode to see the error.

@alibektas
Copy link
Member

@alibektas - What information do you need?

Also, I didn't actually need debug=2, just needed to compile rowan in debug mode to see the error.

Ok I thought you built theia with extra envs. Then let me see what I can do 👍

@Veykril
Copy link
Member

Veykril commented Jan 8, 2025

That panic is expected, we can't currently upgrade rowan because we use the mutable API wrong (which in itself isn't a big issue but now it triggers an assert). You shouldn't hit that though unless you explicitly bump the rowan version in rust-analyzer as we have locked the version. So that panic is unrelated to the issue here

@lnicola
Copy link
Member

lnicola commented Jan 8, 2025

Comparing the LSP traces between Code and Theia might be helpful ("rust-analyzer.trace.server": "verbose" and RA_LOG_FILE).

@hsnoil
Copy link

hsnoil commented Jan 8, 2025

I see, if I relock the version then yes no error happens, but it still doesn't work all the same. Just it gives no error of it not working.

I tried setting verbose and RA_LOG_FILE and RA_LOG to debug, it doesn't even get that far and it gave on highlighting .cargo/registry/src/index.crates.io-6f17d22bba15001f/chalk-ir-0.98.0/src/debug.rs:156:13: not implemented: cannot format ProjectionTy without setting Program in tls

@lnicola
Copy link
Member

lnicola commented Jan 8, 2025

cannot format ProjectionTy without setting Program in tls

That sounds like an issue with our debugging infra. You can skip RA_LOG and RA_LOG_FILE, and watch the LSP traffic in one of the Output window channels. Otherwise RA_LOG=error,lsp_server=debug might work.

@hsnoil
Copy link

hsnoil commented Jan 8, 2025

RA_LOG=error,lsp_server=debug outputs nothing.

As for the Rust Analyzer Language Server Trace

Theia - nonworking

[Trace - 1:14:49 PM] Sending request 'codeAction/resolve - (64)'. Params: { "title": "Fill match arms", "kind": "quickfix", "data": { "codeActionParams": { "textDocument": { "uri": "file:///home/user/dev/rust/test3/src/main.rs" }, "range": { "start": { "line": 9, "character": 12 }, "end": { "line": 9, "character": 12 } }, "context": { "diagnostics": [ { "range": { "start": { "line": 9, "character": 10 }, "end": { "line": 9, "character": 13 } }, "severity": 1, "code": "Click for full compiler diagnostic", "codeDescription": { "href": "rust-analyzer-diagnostics-view:/diagnostic%20message%20%5B0%5D?0#file%3A%2F%2F%2Fhome%2Fuser%2Fdev%2Frust%2Ftest3%2Fsrc%2Fmain.rs" }, "source": "rustc", "message": "non-exhaustive patterns: `Pet::Cat` and `Pet::Dog` not covered\nthe matched value is of type `Pet`", "relatedInformation": [ { "location": { "uri": "file:///home/user/dev/rust/test3/src/main.rs", "range": { "start": { "line": 1, "character": 5 }, "end": { "line": 1, "character": 8 } } }, "message": "`Pet` defined here" }, { "location": { "uri": "file:///home/user/dev/rust/test3/src/main.rs", "range": { "start": { "line": 9, "character": 13 }, "end": { "line": 11, "character": 5 } } }, "message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: ` {\n Pet::Cat | Pet::Dog => todo!(),\n }`" } ], "data": { "rendered": "\u001b[0m\u001b[1m\u001b[38;5;9merror[E0004]\u001b[0m\u001b[0m\u001b[1m: non-exhaustive patterns: `Pet::Cat` and `Pet::Dog` not covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:10:11\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m10\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m match pet {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9mpatterns `Pet::Cat` and `Pet::Dog` not covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;10mnote\u001b[0m\u001b[0m: `Pet` defined here\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:2:6\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m2\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0menum Pet {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;10m^^^\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m3\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Cat,\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m---\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mnot covered\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m4\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Dog\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m---\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mnot covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: the matched value is of type `Pet`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14mhelp\u001b[0m\u001b[0m: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m10\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m~ \u001b[0m\u001b[0m match pet\u001b[0m\u001b[0m\u001b[38;5;10m {\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m11\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m+ Pet::Cat | Pet::Dog => todo!(),\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m12\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m+ }\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\n" } }, { "range": { "start": { "line": 9, "character": 10 }, "end": { "line": 9, "character": 13 } }, "severity": 1, "code": "E0004", "codeDescription": { "href": "https://doc.rust-lang.org/stable/error_codes/E0004.html" }, "source": "rust-analyzer", "message": "missing match arm: `Cat` and `Dog` not covered" } ], "triggerKind": 2 } }, "id": "add_missing_match_arms:QuickFix:1", "version": 182 } }

[Trace - 1:14:49 PM] Received response 'codeAction/resolve - (64)' in 10ms.
Result: {
"title": "Fill match arms",
"kind": "quickfix",
"edit": {
"documentChanges": [
{
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"version": 182
},
"edits": [
{
"range": {
"start": {
"line": 9,
"character": 15
},
"end": {
"line": 11,
"character": 4
}
},
"newText": "\n Pet::Cat => ${1:todo!()},\n Pet::Dog => ${2:todo!()},$0\n ",
"insertTextFormat": 2
}
]
}
],
"changeAnnotations": {
"OutsideWorkspace": {
"label": "Edit outside of the workspace",
"needsConfirmation": true,
"description": "This edit lies outside of the workspace and may affect dependencies"
}
}
}
}

[Trace - 1:14:49 PM] Sending request 'textDocument/documentSymbol - (65)'.
Params: {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
}
}

[Trace - 1:14:49 PM] Received response 'textDocument/documentSymbol - (65)' in 2ms.
Result: [
{
"name": "Pet",
"kind": 10,
"tags": [],
"deprecated": false,
"range": {
"start": {
"line": 1,
"character": 0
},
"end": {
"line": 4,
"character": 1
}
},
"selectionRange": {
"start": {
"line": 1,
"character": 5
},
"end": {
"line": 1,
"character": 8
}
},
"children": [
{
"name": "Cat",
"kind": 22,
"tags": [],
"deprecated": false,
"range": {
"start": {
"line": 2,
"character": 4
},
"end": {
"line": 2,
"character": 7
}
},
"selectionRange": {
"start": {
"line": 2,
"character": 4
},
"end": {
"line": 2,
"character": 7
}
}
},
{
"name": "Dog",
"kind": 22,
"tags": [],
"deprecated": false,
"range": {
"start": {
"line": 3,
"character": 4
},
"end": {
"line": 3,
"character": 7
}
},
"selectionRange": {
"start": {
"line": 3,
"character": 4
},
"end": {
"line": 3,
"character": 7
}
}
}
]
},
{
"name": "main",
"detail": "fn()",
"kind": 12,
"tags": [],
"deprecated": false,
"range": {
"start": {
"line": 7,
"character": 0
},
"end": {
"line": 17,
"character": 1
}
},
"selectionRange": {
"start": {
"line": 7,
"character": 3
},
"end": {
"line": 7,
"character": 7
}
},
"children": [
{
"name": "pet",
"kind": 13,
"tags": [],
"deprecated": false,
"range": {
"start": {
"line": 8,
"character": 4
},
"end": {
"line": 8,
"character": 23
}
},
"selectionRange": {
"start": {
"line": 8,
"character": 8
},
"end": {
"line": 8,
"character": 11
}
}
}
]
}
]

[Trace - 1:14:49 PM] Sending request 'textDocument/codeAction - (66)'.
Params: {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 9,
"character": 12
},
"end": {
"line": 9,
"character": 12
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
},
"message": "non-exhaustive patterns: Pet::Cat and Pet::Dog not covered\nthe matched value is of type Pet",
"data": {
"rendered": "\u001b[0m\u001b[1m\u001b[38;5;9merror[E0004]\u001b[0m\u001b[0m\u001b[1m: non-exhaustive patterns: Pet::Cat and Pet::Dog not covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:10:11\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m10\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m match pet {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9mpatterns Pet::Cat and Pet::Dog not covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;10mnote\u001b[0m\u001b[0m: Pet defined here\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:2:6\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m2\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0menum Pet {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;10m^^^\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m3\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Cat,\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m---\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mnot covered\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m4\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Dog\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m---\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mnot covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: the matched value is of type Pet\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14mhelp\u001b[0m\u001b[0m: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m10\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m~ \u001b[0m\u001b[0m match pet\u001b[0m\u001b[0m\u001b[38;5;10m {\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m11\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m+ Pet::Cat | Pet::Dog => todo!(),\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m12\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m+ }\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\n"
},
"code": "Click for full compiler diagnostic",
"codeDescription": {
"href": "rust-analyzer-diagnostics-view:/diagnostic%20message%20%5B0%5D?0#file%3A%2F%2F%2Fhome%2Fuser%2Fdev%2Frust%2Ftest3%2Fsrc%2Fmain.rs"
},
"severity": 1,
"relatedInformation": [
{
"message": "Pet defined here",
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 1,
"character": 5
},
"end": {
"line": 1,
"character": 8
}
}
}
},
{
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }",
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
}
}
}
],
"source": "rustc"
},
{
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
},
"message": "missing match arm: Cat and Dog not covered",
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/stable/error_codes/E0004.html"
},
"severity": 1,
"source": "rust-analyzer"
}
],
"triggerKind": 2
}
}

[Trace - 1:14:49 PM] Received response 'textDocument/codeAction - (66)' in 9ms.
Result: [
{
"title": "Inline variable",
"kind": "refactor.inline",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 9,
"character": 12
},
"end": {
"line": 9,
"character": 12
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
},
"severity": 1,
"code": "Click for full compiler diagnostic",
"codeDescription": {
"href": "rust-analyzer-diagnostics-view:/diagnostic%20message%20%5B0%5D?0#file%3A%2F%2F%2Fhome%2Fuser%2Fdev%2Frust%2Ftest3%2Fsrc%2Fmain.rs"
},
"source": "rustc",
"message": "non-exhaustive patterns: Pet::Cat and Pet::Dog not covered\nthe matched value is of type Pet",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 1,
"character": 5
},
"end": {
"line": 1,
"character": 8
}
}
},
"message": "Pet defined here"
},
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
}
},
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }"
}
],
"data": {
"rendered": "\u001b[0m\u001b[1m\u001b[38;5;9merror[E0004]\u001b[0m\u001b[0m\u001b[1m: non-exhaustive patterns: Pet::Cat and Pet::Dog not covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:10:11\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m10\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m match pet {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9mpatterns Pet::Cat and Pet::Dog not covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;10mnote\u001b[0m\u001b[0m: Pet defined here\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:2:6\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m2\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0menum Pet {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;10m^^^\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m3\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Cat,\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m---\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mnot covered\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m4\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Dog\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m---\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mnot covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: the matched value is of type Pet\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14mhelp\u001b[0m\u001b[0m: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m10\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m~ \u001b[0m\u001b[0m match pet\u001b[0m\u001b[0m\u001b[38;5;10m {\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m11\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m+ Pet::Cat | Pet::Dog => todo!(),\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m12\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m+ }\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\n"
}
},
{
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
},
"severity": 1,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/stable/error_codes/E0004.html"
},
"source": "rust-analyzer",
"message": "missing match arm: Cat and Dog not covered"
}
],
"triggerKind": 2
}
},
"id": "inline_local_variable:RefactorInline:0",
"version": 182
}
},
{
"title": "Fill match arms",
"kind": "quickfix",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 9,
"character": 12
},
"end": {
"line": 9,
"character": 12
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
},
"severity": 1,
"code": "Click for full compiler diagnostic",
"codeDescription": {
"href": "rust-analyzer-diagnostics-view:/diagnostic%20message%20%5B0%5D?0#file%3A%2F%2F%2Fhome%2Fuser%2Fdev%2Frust%2Ftest3%2Fsrc%2Fmain.rs"
},
"source": "rustc",
"message": "non-exhaustive patterns: Pet::Cat and Pet::Dog not covered\nthe matched value is of type Pet",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 1,
"character": 5
},
"end": {
"line": 1,
"character": 8
}
}
},
"message": "Pet defined here"
},
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
}
},
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }"
}
],
"data": {
"rendered": "\u001b[0m\u001b[1m\u001b[38;5;9merror[E0004]\u001b[0m\u001b[0m\u001b[1m: non-exhaustive patterns: Pet::Cat and Pet::Dog not covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:10:11\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m10\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m match pet {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9mpatterns Pet::Cat and Pet::Dog not covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;10mnote\u001b[0m\u001b[0m: Pet defined here\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:2:6\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m2\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0menum Pet {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;10m^^^\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m3\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Cat,\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m---\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mnot covered\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m4\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Dog\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m---\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mnot covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: the matched value is of type Pet\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14mhelp\u001b[0m\u001b[0m: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m10\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m~ \u001b[0m\u001b[0m match pet\u001b[0m\u001b[0m\u001b[38;5;10m {\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m11\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m+ Pet::Cat | Pet::Dog => todo!(),\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m12\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m+ }\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\n"
}
},
{
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
},
"severity": 1,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/stable/error_codes/E0004.html"
},
"source": "rust-analyzer",
"message": "missing match arm: Cat and Dog not covered"
}
],
"triggerKind": 2
}
},
"id": "add_missing_match_arms:QuickFix:1",
"version": 182
}
},
{
"title": "Add this function's return type",
"kind": "refactor.rewrite",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 9,
"character": 12
},
"end": {
"line": 9,
"character": 12
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
},
"severity": 1,
"code": "Click for full compiler diagnostic",
"codeDescription": {
"href": "rust-analyzer-diagnostics-view:/diagnostic%20message%20%5B0%5D?0#file%3A%2F%2F%2Fhome%2Fuser%2Fdev%2Frust%2Ftest3%2Fsrc%2Fmain.rs"
},
"source": "rustc",
"message": "non-exhaustive patterns: Pet::Cat and Pet::Dog not covered\nthe matched value is of type Pet",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 1,
"character": 5
},
"end": {
"line": 1,
"character": 8
}
}
},
"message": "Pet defined here"
},
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
}
},
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }"
}
],
"data": {
"rendered": "\u001b[0m\u001b[1m\u001b[38;5;9merror[E0004]\u001b[0m\u001b[0m\u001b[1m: non-exhaustive patterns: Pet::Cat and Pet::Dog not covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:10:11\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m10\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m match pet {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9mpatterns Pet::Cat and Pet::Dog not covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;10mnote\u001b[0m\u001b[0m: Pet defined here\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:2:6\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m2\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0menum Pet {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;10m^^^\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m3\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Cat,\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m---\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mnot covered\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m4\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Dog\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m---\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mnot covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: the matched value is of type Pet\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14mhelp\u001b[0m\u001b[0m: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m10\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m~ \u001b[0m\u001b[0m match pet\u001b[0m\u001b[0m\u001b[38;5;10m {\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m11\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m+ Pet::Cat | Pet::Dog => todo!(),\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m12\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m+ }\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\n"
}
},
{
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
},
"severity": 1,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/stable/error_codes/E0004.html"
},
"source": "rust-analyzer",
"message": "missing match arm: Cat and Dog not covered"
}
],
"triggerKind": 2
}
},
"id": "add_return_type:RefactorRewrite:2",
"version": 182
}
}
]

VSCodium - working

[Trace - 1:19:23 PM] Sending request 'textDocument/documentHighlight - (41)'. Params: { "textDocument": { "uri": "file:///home/user/dev/rust/test3/src/main.rs" }, "position": { "line": 9, "character": 12 } }

[Trace - 1:19:23 PM] Sending request 'codeAction/resolve - (42)'.
Params: {
"title": "Fill match arms",
"kind": "quickfix",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 9,
"character": 12
},
"end": {
"line": 9,
"character": 12
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
},
"severity": 1,
"code": "Click for full compiler diagnostic",
"codeDescription": {
"href": "rust-analyzer-diagnostics-view:/diagnostic%20message%20%5B0%5D?0#file%3A%2F%2F%2Fhome%2Fuser%2Fdev%2Frust%2Ftest3%2Fsrc%2Fmain.rs"
},
"source": "rustc",
"message": "non-exhaustive patterns: Pet::Cat and Pet::Dog not covered\nthe matched value is of type Pet",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 1,
"character": 5
},
"end": {
"line": 1,
"character": 8
}
}
},
"message": "Pet defined here"
},
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
}
},
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }"
}
],
"data": {
"rendered": "\u001b[0m\u001b[1m\u001b[38;5;9merror[E0004]\u001b[0m\u001b[0m\u001b[1m: non-exhaustive patterns: Pet::Cat and Pet::Dog not covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:10:11\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m10\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m match pet {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9mpatterns Pet::Cat and Pet::Dog not covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;10mnote\u001b[0m\u001b[0m: Pet defined here\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:2:6\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m2\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0menum Pet {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;10m^^^\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m3\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Cat,\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m---\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mnot covered\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m4\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Dog\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m---\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mnot covered\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: the matched value is of type Pet\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14mhelp\u001b[0m\u001b[0m: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m10\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m~ \u001b[0m\u001b[0m match pet\u001b[0m\u001b[0m\u001b[38;5;10m {\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m11\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m+ Pet::Cat | Pet::Dog => todo!(),\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m12\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m+ }\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\n"
}
},
{
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
},
"severity": 1,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/stable/error_codes/E0004.html"
},
"source": "rust-analyzer",
"message": "missing match arm: Cat and Dog not covered"
}
],
"triggerKind": 2
}
},
"id": "add_missing_match_arms:QuickFix:1",
"version": 30
}
}

[Trace - 1:19:23 PM] Received response 'textDocument/documentHighlight - (41)' in 1ms.
Result: [
{
"range": {
"start": {
"line": 8,
"character": 8
},
"end": {
"line": 8,
"character": 11
}
}
},
{
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
},
"kind": 2
}
]

[Trace - 1:19:23 PM] Received response 'codeAction/resolve - (42)' in 2ms.
Result: {
"title": "Fill match arms",
"kind": "quickfix",
"edit": {
"documentChanges": [
{
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"version": 30
},
"edits": [
{
"range": {
"start": {
"line": 9,
"character": 15
},
"end": {
"line": 11,
"character": 4
}
},
"newText": "\n Pet::Cat => ${1:todo!()},\n Pet::Dog => ${2:todo!()},$0\n ",
"insertTextFormat": 2
}
]
}
],
"changeAnnotations": {
"OutsideWorkspace": {
"label": "Edit outside of the workspace",
"needsConfirmation": true,
"description": "This edit lies outside of the workspace and may affect dependencies"
}
}
}
}

[Trace - 1:19:23 PM] Sending notification 'textDocument/didChange'.
Params: {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"version": 31
},
"contentChanges": [
{
"range": {
"start": {
"line": 9,
"character": 15
},
"end": {
"line": 11,
"character": 4
}
},
"rangeLength": 14,
"text": "\n Pet::Cat => todo!(),\n Pet::Dog => todo!(),\n "
}
]
}

[Trace - 1:19:23 PM] Sending request 'textDocument/diagnostic - (43)'.
Params: {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"previousResultId": "rust-analyzer"
}

[Trace - 1:19:23 PM] Received request 'workspace/semanticTokens/refresh - (36)'.
[Trace - 1:19:23 PM] Sending response 'workspace/semanticTokens/refresh - (36)'. Processing request took 0ms
No result returned.

[Trace - 1:19:23 PM] Received request 'workspace/codeLens/refresh - (37)'.
[Trace - 1:19:23 PM] Sending response 'workspace/codeLens/refresh - (37)'. Processing request took 0ms
No result returned.

[Trace - 1:19:23 PM] Received request 'workspace/inlayHint/refresh - (38)'.
[Trace - 1:19:23 PM] Sending response 'workspace/inlayHint/refresh - (38)'. Processing request took 0ms
No result returned.

[Trace - 1:19:23 PM] Received response 'textDocument/diagnostic - (43)' in 2ms.
Result: {
"kind": "full",
"resultId": "rust-analyzer",
"items": []
}

[Trace - 1:19:23 PM] Sending request 'textDocument/codeAction - (44)'.
Params: {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 10,
"character": 20
},
"end": {
"line": 10,
"character": 27
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
},
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }",
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/error-index.html#E0004"
},
"severity": 4,
"relatedInformation": [
{
"message": "original diagnostic",
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
}
}
}
],
"source": "rustc"
}
],
"triggerKind": 2
}
}

[Trace - 1:19:23 PM] Sending request 'textDocument/semanticTokens/full/delta - (45)'.
Params: {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"previousResultId": "3"
}

[Trace - 1:19:23 PM] Received response 'textDocument/semanticTokens/full/delta - (45)' in 1ms.
Result: {
"resultId": "4",
"data": [
1,
0,
4,
6,
0,
0,
5,
3,
3,
4,
1,
4,
3,
2,
4,
1,
4,
3,
2,
4,
4,
0,
2,
6,
0,
0,
3,
4,
4,
4,
1,
4,
3,
6,
0,
0,
4,
3,
17,
4,
0,
4,
1,
11,
0,
0,
2,
3,
3,
0,
0,
3,
2,
11,
0,
0,
2,
3,
2,
0,
1,
4,
5,
6,
1024,
0,
6,
3,
17,
0,
1,
8,
3,
3,
0,
0,
3,
2,
11,
0,
0,
2,
3,
2,
0,
0,
4,
2,
11,
0,
0,
3,
4,
7,
16400,
0,
4,
1,
7,
0,
1,
8,
3,
3,
0,
0,
3,
2,
11,
0,
0,
2,
3,
2,
0,
0,
4,
2,
11,
0,
0,
3,
4,
7,
16400,
0,
4,
1,
7,
0
]
}

[Trace - 1:19:23 PM] Received response 'textDocument/codeAction - (44)' in 14ms.
Result: [
{
"title": "Add braces to arm expression",
"kind": "refactor.rewrite",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 10,
"character": 20
},
"end": {
"line": 10,
"character": 27
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
},
"severity": 4,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/error-index.html#E0004"
},
"source": "rustc",
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
}
},
"message": "original diagnostic"
}
]
}
],
"triggerKind": 2
}
},
"id": "add_braces:RefactorRewrite:0",
"version": 31
}
},
{
"title": "Inline macro",
"kind": "refactor.inline",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 10,
"character": 20
},
"end": {
"line": 10,
"character": 27
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
},
"severity": 4,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/error-index.html#E0004"
},
"source": "rustc",
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
}
},
"message": "original diagnostic"
}
]
}
],
"triggerKind": 2
}
},
"id": "inline_macro:RefactorInline:1",
"version": 31
}
},
{
"title": "Replace todo!() with ()",
"group": "Term search",
"kind": "",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 10,
"character": 20
},
"end": {
"line": 10,
"character": 27
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
},
"severity": 4,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/error-index.html#E0004"
},
"source": "rustc",
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
}
},
"message": "original diagnostic"
}
]
}
],
"triggerKind": 2
}
},
"id": "term_search:Generate:2",
"version": 31
}
},
{
"title": "Replace todo!() with main()",
"group": "Term search",
"kind": "",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 10,
"character": 20
},
"end": {
"line": 10,
"character": 27
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
},
"severity": 4,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/error-index.html#E0004"
},
"source": "rustc",
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
}
},
"message": "original diagnostic"
}
]
}
],
"triggerKind": 2
}
},
"id": "term_search:Generate:3",
"version": 31
}
},
{
"title": "Extract Module",
"kind": "refactor.extract",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 10,
"character": 20
},
"end": {
"line": 10,
"character": 27
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
},
"severity": 4,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/error-index.html#E0004"
},
"source": "rustc",
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
}
},
"message": "original diagnostic"
}
]
}
],
"triggerKind": 2
}
},
"id": "extract_module:RefactorExtract:4",
"version": 31
}
},
{
"title": "Merge match arms",
"kind": "refactor.rewrite",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 10,
"character": 20
},
"end": {
"line": 10,
"character": 27
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
},
"severity": 4,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/error-index.html#E0004"
},
"source": "rustc",
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
}
},
"message": "original diagnostic"
}
]
}
],
"triggerKind": 2
}
},
"id": "merge_match_arms:RefactorRewrite:5",
"version": 31
}
},
{
"title": "Add this function's return type",
"kind": "refactor.rewrite",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 10,
"character": 20
},
"end": {
"line": 10,
"character": 27
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
},
"severity": 4,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/error-index.html#E0004"
},
"source": "rustc",
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
}
},
"message": "original diagnostic"
}
]
}
],
"triggerKind": 2
}
},
"id": "add_return_type:RefactorRewrite:6",
"version": 31
}
}
]

[Trace - 1:19:23 PM] Sending request 'textDocument/foldingRange - (46)'.
Params: {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
}
}

[Trace - 1:19:23 PM] Received response 'textDocument/foldingRange - (46)' in 2ms.
Result: [
{
"startLine": 1,
"endLine": 4
},
{
"startLine": 7,
"endLine": 18
},
{
"startLine": 9,
"endLine": 12
}
]

[Trace - 1:19:23 PM] Sending request 'textDocument/codeLens - (47)'.
Params: {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
}
}

[Trace - 1:19:23 PM] Received response 'textDocument/codeLens - (47)' in 3ms.
Result: [
{
"range": {
"start": {
"line": 1,
"character": 5
},
"end": {
"line": 1,
"character": 8
}
},
"data": {
"version": 31,
"kind": {
"impls": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"position": {
"line": 1,
"character": 5
}
}
}
}
},
{
"range": {
"start": {
"line": 7,
"character": 3
},
"end": {
"line": 7,
"character": 7
}
},
"command": {
"title": "▶︎ Run ",
"command": "rust-analyzer.runSingle",
"arguments": [
{
"label": "run test3",
"location": {
"targetUri": "file:///home/user/dev/rust/test3/src/main.rs",
"targetRange": {
"start": {
"line": 7,
"character": 0
},
"end": {
"line": 18,
"character": 1
}
},
"targetSelectionRange": {
"start": {
"line": 7,
"character": 3
},
"end": {
"line": 7,
"character": 7
}
}
},
"kind": "cargo",
"args": {
"environment": {
"RUSTC_TOOLCHAIN": "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu"
},
"cwd": "/home/user/dev/rust/test3",
"overrideCargo": null,
"workspaceRoot": "/home/user/dev/rust/test3",
"cargoArgs": [
"run",
"--package",
"test3",
"--bin",
"test3"
],
"executableArgs": []
}
}
]
}
},
{
"range": {
"start": {
"line": 7,
"character": 3
},
"end": {
"line": 7,
"character": 7
}
},
"command": {
"title": "⚙︎ Debug",
"command": "rust-analyzer.debugSingle",
"arguments": [
{
"label": "run test3",
"location": {
"targetUri": "file:///home/user/dev/rust/test3/src/main.rs",
"targetRange": {
"start": {
"line": 7,
"character": 0
},
"end": {
"line": 18,
"character": 1
}
},
"targetSelectionRange": {
"start": {
"line": 7,
"character": 3
},
"end": {
"line": 7,
"character": 7
}
}
},
"kind": "cargo",
"args": {
"environment": {
"RUSTC_TOOLCHAIN": "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu"
},
"cwd": "/home/user/dev/rust/test3",
"overrideCargo": null,
"workspaceRoot": "/home/user/dev/rust/test3",
"cargoArgs": [
"run",
"--package",
"test3",
"--bin",
"test3"
],
"executableArgs": []
}
}
]
}
}
]

[Trace - 1:19:23 PM] Sending request 'textDocument/codeAction - (48)'.
Params: {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 10,
"character": 20
},
"end": {
"line": 10,
"character": 27
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
},
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }",
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/error-index.html#E0004"
},
"severity": 4,
"relatedInformation": [
{
"message": "original diagnostic",
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
}
}
}
],
"source": "rustc"
}
],
"triggerKind": 2
}
}

[Trace - 1:19:23 PM] Received response 'textDocument/codeAction - (48)' in 14ms.
Result: [
{
"title": "Add braces to arm expression",
"kind": "refactor.rewrite",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 10,
"character": 20
},
"end": {
"line": 10,
"character": 27
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
},
"severity": 4,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/error-index.html#E0004"
},
"source": "rustc",
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
}
},
"message": "original diagnostic"
}
]
}
],
"triggerKind": 2
}
},
"id": "add_braces:RefactorRewrite:0",
"version": 31
}
},
{
"title": "Inline macro",
"kind": "refactor.inline",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 10,
"character": 20
},
"end": {
"line": 10,
"character": 27
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
},
"severity": 4,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/error-index.html#E0004"
},
"source": "rustc",
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
}
},
"message": "original diagnostic"
}
]
}
],
"triggerKind": 2
}
},
"id": "inline_macro:RefactorInline:1",
"version": 31
}
},
{
"title": "Replace todo!() with ()",
"group": "Term search",
"kind": "",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 10,
"character": 20
},
"end": {
"line": 10,
"character": 27
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
},
"severity": 4,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/error-index.html#E0004"
},
"source": "rustc",
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
}
},
"message": "original diagnostic"
}
]
}
],
"triggerKind": 2
}
},
"id": "term_search:Generate:2",
"version": 31
}
},
{
"title": "Replace todo!() with main()",
"group": "Term search",
"kind": "",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 10,
"character": 20
},
"end": {
"line": 10,
"character": 27
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
},
"severity": 4,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/error-index.html#E0004"
},
"source": "rustc",
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
}
},
"message": "original diagnostic"
}
]
}
],
"triggerKind": 2
}
},
"id": "term_search:Generate:3",
"version": 31
}
},
{
"title": "Extract Module",
"kind": "refactor.extract",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 10,
"character": 20
},
"end": {
"line": 10,
"character": 27
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
},
"severity": 4,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/error-index.html#E0004"
},
"source": "rustc",
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
}
},
"message": "original diagnostic"
}
]
}
],
"triggerKind": 2
}
},
"id": "extract_module:RefactorExtract:4",
"version": 31
}
},
{
"title": "Merge match arms",
"kind": "refactor.rewrite",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 10,
"character": 20
},
"end": {
"line": 10,
"character": 27
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
},
"severity": 4,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/error-index.html#E0004"
},
"source": "rustc",
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
}
},
"message": "original diagnostic"
}
]
}
],
"triggerKind": 2
}
},
"id": "merge_match_arms:RefactorRewrite:5",
"version": 31
}
},
{
"title": "Add this function's return type",
"kind": "refactor.rewrite",
"data": {
"codeActionParams": {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 10,
"character": 20
},
"end": {
"line": 10,
"character": 27
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 9,
"character": 13
},
"end": {
"line": 11,
"character": 5
}
},
"severity": 4,
"code": "E0004",
"codeDescription": {
"href": "https://doc.rust-lang.org/error-index.html#E0004"
},
"source": "rustc",
"message": "ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms: {\n Pet::Cat | Pet::Dog => todo!(),\n }",
"relatedInformation": [
{
"location": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs",
"range": {
"start": {
"line": 9,
"character": 10
},
"end": {
"line": 9,
"character": 13
}
}
},
"message": "original diagnostic"
}
]
}
],
"triggerKind": 2
}
},
"id": "add_return_type:RefactorRewrite:6",
"version": 31
}
}
]

[Trace - 1:19:23 PM] Sending request 'textDocument/documentSymbol - (49)'.
Params: {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
}
}

[Trace - 1:19:23 PM] Received response 'textDocument/documentSymbol - (49)' in 1ms.
Result: [
{
"name": "Pet",
"kind": 10,
"tags": [],
"deprecated": false,
"range": {
"start": {
"line": 1,
"character": 0
},
"end": {
"line": 4,
"character": 1
}
},
"selectionRange": {
"start": {
"line": 1,
"character": 5
},
"end": {
"line": 1,
"character": 8
}
},
"children": [
{
"name": "Cat",
"kind": 22,
"tags": [],
"deprecated": false,
"range": {
"start": {
"line": 2,
"character": 4
},
"end": {
"line": 2,
"character": 7
}
},
"selectionRange": {
"start": {
"line": 2,
"character": 4
},
"end": {
"line": 2,
"character": 7
}
}
},
{
"name": "Dog",
"kind": 22,
"tags": [],
"deprecated": false,
"range": {
"start": {
"line": 3,
"character": 4
},
"end": {
"line": 3,
"character": 7
}
},
"selectionRange": {
"start": {
"line": 3,
"character": 4
},
"end": {
"line": 3,
"character": 7
}
}
}
]
},
{
"name": "main",
"detail": "fn()",
"kind": 12,
"tags": [],
"deprecated": false,
"range": {
"start": {
"line": 7,
"character": 0
},
"end": {
"line": 18,
"character": 1
}
},
"selectionRange": {
"start": {
"line": 7,
"character": 3
},
"end": {
"line": 7,
"character": 7
}
},
"children": [
{
"name": "pet",
"kind": 13,
"tags": [],
"deprecated": false,
"range": {
"start": {
"line": 8,
"character": 4
},
"end": {
"line": 8,
"character": 23
}
},
"selectionRange": {
"start": {
"line": 8,
"character": 8
},
"end": {
"line": 8,
"character": 11
}
}
}
]
}
]

[Trace - 1:19:23 PM] Sending request 'textDocument/documentSymbol - (50)'.
Params: {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
}
}

[Trace - 1:19:23 PM] Received response 'textDocument/documentSymbol - (50)' in 1ms.
Result: [
{
"name": "Pet",
"kind": 10,
"tags": [],
"deprecated": false,
"range": {
"start": {
"line": 1,
"character": 0
},
"end": {
"line": 4,
"character": 1
}
},
"selectionRange": {
"start": {
"line": 1,
"character": 5
},
"end": {
"line": 1,
"character": 8
}
},
"children": [
{
"name": "Cat",
"kind": 22,
"tags": [],
"deprecated": false,
"range": {
"start": {
"line": 2,
"character": 4
},
"end": {
"line": 2,
"character": 7
}
},
"selectionRange": {
"start": {
"line": 2,
"character": 4
},
"end": {
"line": 2,
"character": 7
}
}
},
{
"name": "Dog",
"kind": 22,
"tags": [],
"deprecated": false,
"range": {
"start": {
"line": 3,
"character": 4
},
"end": {
"line": 3,
"character": 7
}
},
"selectionRange": {
"start": {
"line": 3,
"character": 4
},
"end": {
"line": 3,
"character": 7
}
}
}
]
},
{
"name": "main",
"detail": "fn()",
"kind": 12,
"tags": [],
"deprecated": false,
"range": {
"start": {
"line": 7,
"character": 0
},
"end": {
"line": 18,
"character": 1
}
},
"selectionRange": {
"start": {
"line": 7,
"character": 3
},
"end": {
"line": 7,
"character": 7
}
},
"children": [
{
"name": "pet",
"kind": 13,
"tags": [],
"deprecated": false,
"range": {
"start": {
"line": 8,
"character": 4
},
"end": {
"line": 8,
"character": 23
}
},
"selectionRange": {
"start": {
"line": 8,
"character": 8
},
"end": {
"line": 8,
"character": 11
}
}
}
]
}
]

[Trace - 1:19:24 PM] Sending request 'textDocument/inlayHint - (51)'.
Params: {
"textDocument": {
"uri": "file:///home/user/dev/rust/test3/src/main.rs"
},
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 20,
"character": 0
}
}
}

[Trace - 1:19:24 PM] Received response 'textDocument/inlayHint - (51)' in 3ms.
Result: [
{
"position": {
"line": 8,
"character": 11
},
"label": [
{
"value": ": "
},
{
"value": "Pet"
}
],
"kind": 1,
"paddingLeft": false,
"paddingRight": false,
"data": {
"file_id": 0,
"hash": "1988822172602854927",
"resolve_range": {
"start": {
"line": 8,
"character": 8
},
"end": {
"line": 8,
"character": 11
}
},
"version": 31
}
}
]

@hsnoil
Copy link

hsnoil commented Feb 9, 2025

I've been looking around and so far the only difference I have found was that in src/snippets.ts, await vscode.workspace.applyEdit(edit); returns False in Theia but True in vscode.

Despite their input being:

[{"range":[{"line":9,"character":15},{"line":11,"character":4}],"snippet":{"_tabstop":1,"value":"\n    Pet::Cat => ${1:todo!()},\n    Pet::Dog => ${2:todo!()},$0\n"}}]

For the time being though, at the very least

if (editor) {
            edit.set(uri, removeLeadingWhitespace(editor, edits));
            await vscode.workspace.applyEdit(edit);
        }

should be changed to something like this:

if (editor) {
            edit.set(uri, removeLeadingWhitespace(editor, edits));
            if (!await vscode.workspace.applyEdit(edit)) {
                 vscode.window.showErrorMessage("Failed to apply snippet");
            }
        }

so that at least when it fails it gives an error message instead of simply not working.

@hsnoil
Copy link

hsnoil commented Feb 10, 2025

I found a workaround to make it work on Theia.

if (editor) {
          const trimmedEdits = removeLeadingWhitespace(editor, edits)
          edit.set(uri, trimmedEdits);
          if (!await vscode.workspace.applyEdit(edit)) {
            if (trimmedEdits[0] instanceof vscode.SnippetTextEdit && !await editor.insertSnippet(trimmedEdits[0].snippet, trimmedEdits[0].range)) {
              vscode.window.showErrorMessage("Failed to insert snippet");
            }
           }
         }

https://github.com/rust-lang/rust-analyzer/blob/master/editors/code/src/snippets.ts

@hsnoil
Copy link

hsnoil commented Feb 27, 2025

@ChayimFriedman2 - Theia 1.79 fixes the issue so now it should work on Theia.

So only related issue remaining is

await vscode.workspace.applyEdit(edit)

in rust analyzer should return an error if it fails instead of doing nothing. As I showed above maybe something like:

if (editor) {
            edit.set(uri, removeLeadingWhitespace(editor, edits));
            if (!await vscode.workspace.applyEdit(edit)) {
                 vscode.window.showErrorMessage("Failed to apply snippet");
            }
        }

Not sure if this should be under this issue or another issue created for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants