diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index da65b034be..6f270fc63b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ Thank you for your interest in contributing to rust-analyzer! There are many way and we appreciate all of them. To get a quick overview of the crates and structure of the project take a look at the -[./docs/dev](./docs/dev) folder. +[Contributing](https://rust-analyzer.github.io/book/contributing) section of the manual. If you have any questions please ask them in the [rust-analyzer zulip stream]( https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer) or if unsure where diff --git a/README.md b/README.md index 56883723c9..4360dea4a1 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ https://rust-analyzer.github.io/book/installation.html ## Documentation If you want to **contribute** to rust-analyzer check out the [CONTRIBUTING.md](./CONTRIBUTING.md) or -if you are just curious about how things work under the hood, check the [./docs/dev](./docs/dev) -folder. +if you are just curious about how things work under the hood, see the +[Contributing](https://rust-analyzer.github.io/book/contributing) section of the manual. If you want to **use** rust-analyzer's language server with your editor of choice, check [the manual](https://rust-analyzer.github.io/book/). diff --git a/docs/book/book.toml b/docs/book/book.toml index 5ca4badde8..a6f6a6ed78 100644 --- a/docs/book/book.toml +++ b/docs/book/book.toml @@ -34,3 +34,8 @@ use-boolean-and = true [output.html.fold] enable = true level = 3 + +[preprocessor.toc] +command = "mdbook-toc" +renderer = ["html"] +max-level = 3 diff --git a/docs/book/src/SUMMARY.md b/docs/book/src/SUMMARY.md index 9dc4f1f2d2..1f211a97d7 100644 --- a/docs/book/src/SUMMARY.md +++ b/docs/book/src/SUMMARY.md @@ -14,3 +14,11 @@ - [Assists (Code Actions)](assists.md) - [Diagnostics](diagnostics.md) - [Editor Features](editor_features.md) +- [Contributing](contributing/README.md) + - [Architecture](contributing/architecture.md) + - [Debugging](contributing/debugging.md) + - [Guide](contributing/guide.md) + - [LSP Extensions](contributing/lsp-extensions.md) + - [Setup](contributing/setup.md) + - [Style](contributing/style.md) + - [Syntax](contributing/syntax.md) diff --git a/docs/book/src/assists_generated.md b/docs/book/src/assists_generated.md index 3617badeef..761a7f859b 100644 --- a/docs/book/src/assists_generated.md +++ b/docs/book/src/assists_generated.md @@ -1,7 +1,7 @@ //! Generated by `cargo xtask codegen assists-doc-tests`, do not edit by hand. ### `add_braces` -**Source:** [add_braces.rs](crates/ide-assists/src/handlers/add_braces.rs#8) +**Source:** [add_braces.rs](/crates/ide-assists/src/handlers/add_braces.rs#8) Adds braces to lambda and match arm expressions. @@ -29,7 +29,7 @@ fn foo(n: i32) -> i32 { ### `add_explicit_type` -**Source:** [add_explicit_type.rs](crates/ide-assists/src/handlers/add_explicit_type.rs#7) +**Source:** [add_explicit_type.rs](/crates/ide-assists/src/handlers/add_explicit_type.rs#7) Specify type for a let binding. @@ -49,7 +49,7 @@ fn main() { ### `add_hash` -**Source:** [raw_string.rs](crates/ide-assists/src/handlers/raw_string.rs#89) +**Source:** [raw_string.rs](/crates/ide-assists/src/handlers/raw_string.rs#89) Adds a hash to a raw string literal. @@ -69,7 +69,7 @@ fn main() { ### `add_impl_default_members` -**Source:** [add_missing_impl_members.rs](crates/ide-assists/src/handlers/add_missing_impl_members.rs#58) +**Source:** [add_missing_impl_members.rs](/crates/ide-assists/src/handlers/add_missing_impl_members.rs#58) Adds scaffold for overriding default impl members. @@ -105,7 +105,7 @@ impl Trait for () { ### `add_impl_missing_members` -**Source:** [add_missing_impl_members.rs](crates/ide-assists/src/handlers/add_missing_impl_members.rs#16) +**Source:** [add_missing_impl_members.rs](/crates/ide-assists/src/handlers/add_missing_impl_members.rs#16) Adds scaffold for required impl members. @@ -141,7 +141,7 @@ impl Trait for () { ### `add_label_to_loop` -**Source:** [add_label_to_loop.rs](crates/ide-assists/src/handlers/add_label_to_loop.rs#9) +**Source:** [add_label_to_loop.rs](/crates/ide-assists/src/handlers/add_label_to_loop.rs#9) Adds a label to a loop. @@ -167,7 +167,7 @@ fn main() { ### `add_lifetime_to_type` -**Source:** [add_lifetime_to_type.rs](crates/ide-assists/src/handlers/add_lifetime_to_type.rs#5) +**Source:** [add_lifetime_to_type.rs](/crates/ide-assists/src/handlers/add_lifetime_to_type.rs#5) Adds a new lifetime to a struct, enum or union. @@ -189,7 +189,7 @@ struct Point<'a> { ### `add_missing_match_arms` -**Source:** [add_missing_match_arms.rs](crates/ide-assists/src/handlers/add_missing_match_arms.rs#14) +**Source:** [add_missing_match_arms.rs](/crates/ide-assists/src/handlers/add_missing_match_arms.rs#14) Adds missing clauses to a `match` expression. @@ -218,7 +218,7 @@ fn handle(action: Action) { ### `add_return_type` -**Source:** [add_return_type.rs](crates/ide-assists/src/handlers/add_return_type.rs#6) +**Source:** [add_return_type.rs](/crates/ide-assists/src/handlers/add_return_type.rs#6) Adds the return type to a function or closure inferred from its tail expression if it doesn't have a return type specified. This assists is useable in a functions or closures tail expression or return type position. @@ -235,7 +235,7 @@ fn foo() -> i32 { 42i32 } ### `add_turbo_fish` -**Source:** [add_turbo_fish.rs](crates/ide-assists/src/handlers/add_turbo_fish.rs#14) +**Source:** [add_turbo_fish.rs](/crates/ide-assists/src/handlers/add_turbo_fish.rs#14) Adds `::<_>` to a call of a generic method or function. @@ -257,7 +257,7 @@ fn main() { ### `apply_demorgan` -**Source:** [apply_demorgan.rs](crates/ide-assists/src/handlers/apply_demorgan.rs#16) +**Source:** [apply_demorgan.rs](/crates/ide-assists/src/handlers/apply_demorgan.rs#16) Apply [De Morgan's law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws). This transforms expressions of the form `!l || !r` into `!(l && r)`. @@ -280,7 +280,7 @@ fn main() { ### `apply_demorgan_iterator` -**Source:** [apply_demorgan.rs](crates/ide-assists/src/handlers/apply_demorgan.rs#132) +**Source:** [apply_demorgan.rs](/crates/ide-assists/src/handlers/apply_demorgan.rs#132) Apply [De Morgan's law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws) to `Iterator::all` and `Iterator::any`. @@ -311,7 +311,7 @@ fn main() { ### `auto_import` -**Source:** [auto_import.rs](crates/ide-assists/src/handlers/auto_import.rs#73) +**Source:** [auto_import.rs](/crates/ide-assists/src/handlers/auto_import.rs#73) If the name is unresolved, provides all possible imports for it. @@ -333,7 +333,7 @@ fn main() { ### `bind_unused_param` -**Source:** [bind_unused_param.rs](crates/ide-assists/src/handlers/bind_unused_param.rs#12) +**Source:** [bind_unused_param.rs](/crates/ide-assists/src/handlers/bind_unused_param.rs#12) Binds unused function parameter to an underscore. @@ -351,7 +351,7 @@ fn some_function(x: i32) { ### `bool_to_enum` -**Source:** [bool_to_enum.rs](crates/ide-assists/src/handlers/bool_to_enum.rs#29) +**Source:** [bool_to_enum.rs](/crates/ide-assists/src/handlers/bool_to_enum.rs#29) This converts boolean local variables, fields, constants, and statics into a new enum with two variants `Bool::True` and `Bool::False`, as well as replacing @@ -385,7 +385,7 @@ fn main() { ### `change_visibility` -**Source:** [change_visibility.rs](crates/ide-assists/src/handlers/change_visibility.rs#13) +**Source:** [change_visibility.rs](/crates/ide-assists/src/handlers/change_visibility.rs#13) Adds or changes existing visibility specifier. @@ -401,7 +401,7 @@ pub(crate) fn frobnicate() {} ### `comment_to_doc` -**Source:** [convert_comment_from_or_to_doc.rs](crates/ide-assists/src/handlers/convert_comment_from_or_to_doc.rs#9) +**Source:** [convert_comment_from_or_to_doc.rs](/crates/ide-assists/src/handlers/convert_comment_from_or_to_doc.rs#9) Converts comments to documentation. @@ -419,7 +419,7 @@ Converts comments to documentation. ### `convert_bool_then_to_if` -**Source:** [convert_bool_then.rs](crates/ide-assists/src/handlers/convert_bool_then.rs#131) +**Source:** [convert_bool_then.rs](/crates/ide-assists/src/handlers/convert_bool_then.rs#131) Converts a `bool::then` method call to an equivalent if expression. @@ -443,7 +443,7 @@ fn main() { ### `convert_closure_to_fn` -**Source:** [convert_closure_to_fn.rs](crates/ide-assists/src/handlers/convert_closure_to_fn.rs#25) +**Source:** [convert_closure_to_fn.rs](/crates/ide-assists/src/handlers/convert_closure_to_fn.rs#25) This converts a closure to a freestanding function, changing all captures to parameters. @@ -469,7 +469,7 @@ fn main() { ### `convert_for_loop_with_for_each` -**Source:** [convert_iter_for_each_to_for.rs](crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs#76) +**Source:** [convert_iter_for_each_to_for.rs](/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs#76) Converts a for loop into a for_each loop on the Iterator. @@ -495,7 +495,7 @@ fn main() { ### `convert_from_to_tryfrom` -**Source:** [convert_from_to_tryfrom.rs](crates/ide-assists/src/handlers/convert_from_to_tryfrom.rs#10) +**Source:** [convert_from_to_tryfrom.rs](/crates/ide-assists/src/handlers/convert_from_to_tryfrom.rs#10) Converts a From impl to a TryFrom impl, wrapping returns in `Ok`. @@ -527,7 +527,7 @@ impl TryFrom for Thing { ### `convert_if_to_bool_then` -**Source:** [convert_bool_then.rs](crates/ide-assists/src/handlers/convert_bool_then.rs#20) +**Source:** [convert_bool_then.rs](/crates/ide-assists/src/handlers/convert_bool_then.rs#20) Converts an if expression into a corresponding `bool::then` call. @@ -551,7 +551,7 @@ fn main() { ### `convert_integer_literal` -**Source:** [convert_integer_literal.rs](crates/ide-assists/src/handlers/convert_integer_literal.rs#5) +**Source:** [convert_integer_literal.rs](/crates/ide-assists/src/handlers/convert_integer_literal.rs#5) Converts the base of integer literals to other bases. @@ -567,7 +567,7 @@ const _: i32 = 0b1010; ### `convert_into_to_from` -**Source:** [convert_into_to_from.rs](crates/ide-assists/src/handlers/convert_into_to_from.rs#8) +**Source:** [convert_into_to_from.rs](/crates/ide-assists/src/handlers/convert_into_to_from.rs#8) Converts an Into impl to an equivalent From impl. @@ -597,7 +597,7 @@ impl From for Thing { ### `convert_iter_for_each_to_for` -**Source:** [convert_iter_for_each_to_for.rs](crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs#11) +**Source:** [convert_iter_for_each_to_for.rs](/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs#11) Converts an Iterator::for_each function into a for loop. @@ -623,7 +623,7 @@ fn main() { ### `convert_let_else_to_match` -**Source:** [convert_let_else_to_match.rs](crates/ide-assists/src/handlers/convert_let_else_to_match.rs#9) +**Source:** [convert_let_else_to_match.rs](/crates/ide-assists/src/handlers/convert_let_else_to_match.rs#9) Converts let-else statement to let statement and match expression. @@ -646,7 +646,7 @@ fn main() { ### `convert_match_to_let_else` -**Source:** [convert_match_to_let_else.rs](crates/ide-assists/src/handlers/convert_match_to_let_else.rs#12) +**Source:** [convert_match_to_let_else.rs](/crates/ide-assists/src/handlers/convert_match_to_let_else.rs#12) Converts let statement with match initializer to let-else statement. @@ -669,7 +669,7 @@ fn foo(opt: Option<()>) { ### `convert_named_struct_to_tuple_struct` -**Source:** [convert_named_struct_to_tuple_struct.rs](crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs#11) +**Source:** [convert_named_struct_to_tuple_struct.rs](/crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs#11) Converts struct with named fields to tuple struct, and analogously for enum variants with named fields. @@ -714,7 +714,7 @@ impl Point { ### `convert_nested_function_to_closure` -**Source:** [convert_nested_function_to_closure.rs](crates/ide-assists/src/handlers/convert_nested_function_to_closure.rs#7) +**Source:** [convert_nested_function_to_closure.rs](/crates/ide-assists/src/handlers/convert_nested_function_to_closure.rs#7) Converts a function that is defined within the body of another function into a closure. @@ -742,7 +742,7 @@ fn main() { ### `convert_to_guarded_return` -**Source:** [convert_to_guarded_return.rs](crates/ide-assists/src/handlers/convert_to_guarded_return.rs#24) +**Source:** [convert_to_guarded_return.rs](/crates/ide-assists/src/handlers/convert_to_guarded_return.rs#24) Replace a large conditional with a guarded return. @@ -769,7 +769,7 @@ fn main() { ### `convert_tuple_return_type_to_struct` -**Source:** [convert_tuple_return_type_to_struct.rs](crates/ide-assists/src/handlers/convert_tuple_return_type_to_struct.rs#20) +**Source:** [convert_tuple_return_type_to_struct.rs](/crates/ide-assists/src/handlers/convert_tuple_return_type_to_struct.rs#20) This converts the return type of a function from a tuple type into a tuple struct and updates the body accordingly. @@ -800,7 +800,7 @@ fn foo() -> FooResult { ### `convert_tuple_struct_to_named_struct` -**Source:** [convert_tuple_struct_to_named_struct.rs](crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs#10) +**Source:** [convert_tuple_struct_to_named_struct.rs](/crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs#10) Converts tuple struct to struct with named fields, and analogously for tuple enum variants. @@ -844,7 +844,7 @@ impl Point { ### `convert_two_arm_bool_match_to_matches_macro` -**Source:** [convert_two_arm_bool_match_to_matches_macro.rs](crates/ide-assists/src/handlers/convert_two_arm_bool_match_to_matches_macro.rs#8) +**Source:** [convert_two_arm_bool_match_to_matches_macro.rs](/crates/ide-assists/src/handlers/convert_two_arm_bool_match_to_matches_macro.rs#8) Convert 2-arm match that evaluates to a boolean into the equivalent matches! invocation. @@ -867,7 +867,7 @@ fn main() { ### `convert_while_to_loop` -**Source:** [convert_while_to_loop.rs](crates/ide-assists/src/handlers/convert_while_to_loop.rs#20) +**Source:** [convert_while_to_loop.rs](/crates/ide-assists/src/handlers/convert_while_to_loop.rs#20) Replace a while with a loop. @@ -894,7 +894,7 @@ fn main() { ### `destructure_struct_binding` -**Source:** [destructure_struct_binding.rs](crates/ide-assists/src/handlers/destructure_struct_binding.rs#18) +**Source:** [destructure_struct_binding.rs](/crates/ide-assists/src/handlers/destructure_struct_binding.rs#18) Destructures a struct binding in place. @@ -926,7 +926,7 @@ fn main() { ### `destructure_tuple_binding` -**Source:** [destructure_tuple_binding.rs](crates/ide-assists/src/handlers/destructure_tuple_binding.rs#19) +**Source:** [destructure_tuple_binding.rs](/crates/ide-assists/src/handlers/destructure_tuple_binding.rs#19) Destructures a tuple binding in place. @@ -948,7 +948,7 @@ fn main() { ### `desugar_async_into_impl_future` -**Source:** [toggle_async_sugar.rs](crates/ide-assists/src/handlers/toggle_async_sugar.rs#103) +**Source:** [toggle_async_sugar.rs](/crates/ide-assists/src/handlers/toggle_async_sugar.rs#103) Rewrites asynchronous function from `async fn` into `-> impl Future`. This action does not touch the function body and therefore `0` @@ -970,7 +970,7 @@ pub fn foo() -> impl core::future::Future { ### `desugar_doc_comment` -**Source:** [desugar_doc_comment.rs](crates/ide-assists/src/handlers/desugar_doc_comment.rs#14) +**Source:** [desugar_doc_comment.rs](/crates/ide-assists/src/handlers/desugar_doc_comment.rs#14) Desugars doc-comments to the attribute form. @@ -988,7 +988,7 @@ comment"] ### `expand_glob_import` -**Source:** [expand_glob_import.rs](crates/ide-assists/src/handlers/expand_glob_import.rs#18) +**Source:** [expand_glob_import.rs](/crates/ide-assists/src/handlers/expand_glob_import.rs#18) Expands glob imports. @@ -1018,7 +1018,7 @@ fn qux(bar: Bar, baz: Baz) {} ### `explicit_enum_discriminant` -**Source:** [explicit_enum_discriminant.rs](crates/ide-assists/src/handlers/explicit_enum_discriminant.rs#11) +**Source:** [explicit_enum_discriminant.rs](/crates/ide-assists/src/handlers/explicit_enum_discriminant.rs#11) Adds explicit discriminant to all enum variants. @@ -1044,7 +1044,7 @@ enum TheEnum { ### `extract_constant` -**Source:** [extract_variable.rs](crates/ide-assists/src/handlers/extract_variable.rs#35) +**Source:** [extract_variable.rs](/crates/ide-assists/src/handlers/extract_variable.rs#35) Extracts subexpression into a constant. @@ -1065,7 +1065,7 @@ fn main() { ### `extract_expressions_from_format_string` -**Source:** [extract_expressions_from_format_string.rs](crates/ide-assists/src/handlers/extract_expressions_from_format_string.rs#14) +**Source:** [extract_expressions_from_format_string.rs](/crates/ide-assists/src/handlers/extract_expressions_from_format_string.rs#14) Move an expression out of a format string. @@ -1085,7 +1085,7 @@ fn main() { ### `extract_function` -**Source:** [extract_function.rs](crates/ide-assists/src/handlers/extract_function.rs#39) +**Source:** [extract_function.rs](/crates/ide-assists/src/handlers/extract_function.rs#39) Extracts selected statements and comments into new function. @@ -1117,7 +1117,7 @@ fn ┃fun_name(n: i32) { ### `extract_module` -**Source:** [extract_module.rs](crates/ide-assists/src/handlers/extract_module.rs#29) +**Source:** [extract_module.rs](/crates/ide-assists/src/handlers/extract_module.rs#29) Extracts a selected region as separate module. All the references, visibility and imports are resolved. @@ -1148,7 +1148,7 @@ fn bar(name: i32) -> i32 { ### `extract_static` -**Source:** [extract_variable.rs](crates/ide-assists/src/handlers/extract_variable.rs#52) +**Source:** [extract_variable.rs](/crates/ide-assists/src/handlers/extract_variable.rs#52) Extracts subexpression into a static. @@ -1169,7 +1169,7 @@ fn main() { ### `extract_struct_from_enum_variant` -**Source:** [extract_struct_from_enum_variant.rs](crates/ide-assists/src/handlers/extract_struct_from_enum_variant.rs#26) +**Source:** [extract_struct_from_enum_variant.rs](/crates/ide-assists/src/handlers/extract_struct_from_enum_variant.rs#26) Extracts a struct from enum variant. @@ -1187,7 +1187,7 @@ enum A { One(One) } ### `extract_type_alias` -**Source:** [extract_type_alias.rs](crates/ide-assists/src/handlers/extract_type_alias.rs#10) +**Source:** [extract_type_alias.rs](/crates/ide-assists/src/handlers/extract_type_alias.rs#10) Extracts the selected type as a type alias. @@ -1209,7 +1209,7 @@ struct S { ### `extract_variable` -**Source:** [extract_variable.rs](crates/ide-assists/src/handlers/extract_variable.rs#18) +**Source:** [extract_variable.rs](/crates/ide-assists/src/handlers/extract_variable.rs#18) Extracts subexpression into a variable. @@ -1230,7 +1230,7 @@ fn main() { ### `fill_record_pattern_fields` -**Source:** [fill_record_pattern_fields.rs](crates/ide-assists/src/handlers/fill_record_pattern_fields.rs#8) +**Source:** [fill_record_pattern_fields.rs](/crates/ide-assists/src/handlers/fill_record_pattern_fields.rs#8) Fills fields by replacing rest pattern in record patterns. @@ -1254,7 +1254,7 @@ fn foo(bar: Bar) { ### `fix_visibility` -**Source:** [fix_visibility.rs](crates/ide-assists/src/handlers/fix_visibility.rs#14) +**Source:** [fix_visibility.rs](/crates/ide-assists/src/handlers/fix_visibility.rs#14) Makes inaccessible item public. @@ -1280,7 +1280,7 @@ fn main() { ### `flip_binexpr` -**Source:** [flip_binexpr.rs](crates/ide-assists/src/handlers/flip_binexpr.rs#8) +**Source:** [flip_binexpr.rs](/crates/ide-assists/src/handlers/flip_binexpr.rs#8) Flips operands of a binary expression. @@ -1300,7 +1300,7 @@ fn main() { ### `flip_comma` -**Source:** [flip_comma.rs](crates/ide-assists/src/handlers/flip_comma.rs#10) +**Source:** [flip_comma.rs](/crates/ide-assists/src/handlers/flip_comma.rs#10) Flips two comma-separated items. @@ -1320,7 +1320,7 @@ fn main() { ### `flip_trait_bound` -**Source:** [flip_trait_bound.rs](crates/ide-assists/src/handlers/flip_trait_bound.rs#9) +**Source:** [flip_trait_bound.rs](/crates/ide-assists/src/handlers/flip_trait_bound.rs#9) Flips two trait bounds. @@ -1336,7 +1336,7 @@ fn foo() { } ### `generate_constant` -**Source:** [generate_constant.rs](crates/ide-assists/src/handlers/generate_constant.rs#14) +**Source:** [generate_constant.rs](/crates/ide-assists/src/handlers/generate_constant.rs#14) Generate a named constant. @@ -1361,7 +1361,7 @@ fn main() { ### `generate_default_from_enum_variant` -**Source:** [generate_default_from_enum_variant.rs](crates/ide-assists/src/handlers/generate_default_from_enum_variant.rs#6) +**Source:** [generate_default_from_enum_variant.rs](/crates/ide-assists/src/handlers/generate_default_from_enum_variant.rs#6) Adds a Default impl for an enum using a variant. @@ -1391,7 +1391,7 @@ impl Default for Version { ### `generate_default_from_new` -**Source:** [generate_default_from_new.rs](crates/ide-assists/src/handlers/generate_default_from_new.rs#13) +**Source:** [generate_default_from_new.rs](/crates/ide-assists/src/handlers/generate_default_from_new.rs#13) Generates default implementation from new method. @@ -1425,7 +1425,7 @@ impl Default for Example { ### `generate_delegate_methods` -**Source:** [generate_delegate_methods.rs](crates/ide-assists/src/handlers/generate_delegate_methods.rs#15) +**Source:** [generate_delegate_methods.rs](/crates/ide-assists/src/handlers/generate_delegate_methods.rs#15) Generate delegate methods. @@ -1465,7 +1465,7 @@ impl Person { ### `generate_delegate_trait` -**Source:** [generate_delegate_trait.rs](crates/ide-assists/src/handlers/generate_delegate_trait.rs#29) +**Source:** [generate_delegate_trait.rs](/crates/ide-assists/src/handlers/generate_delegate_trait.rs#29) Generate delegate trait implementation for `StructField`s. @@ -1531,7 +1531,7 @@ impl SomeTrait for B { ### `generate_deref` -**Source:** [generate_deref.rs](crates/ide-assists/src/handlers/generate_deref.rs#16) +**Source:** [generate_deref.rs](/crates/ide-assists/src/handlers/generate_deref.rs#16) Generate `Deref` impl using the given struct field. @@ -1561,7 +1561,7 @@ impl core::ops::Deref for B { ### `generate_derive` -**Source:** [generate_derive.rs](crates/ide-assists/src/handlers/generate_derive.rs#8) +**Source:** [generate_derive.rs](/crates/ide-assists/src/handlers/generate_derive.rs#8) Adds a new `#[derive()]` clause to a struct or enum. @@ -1584,7 +1584,7 @@ struct Point { ### `generate_doc_example` -**Source:** [generate_documentation_template.rs](crates/ide-assists/src/handlers/generate_documentation_template.rs#76) +**Source:** [generate_documentation_template.rs](/crates/ide-assists/src/handlers/generate_documentation_template.rs#76) Generates a rustdoc example when editing an item's documentation. @@ -1610,7 +1610,7 @@ pub fn add(a: i32, b: i32) -> i32 { a + b } ### `generate_documentation_template` -**Source:** [generate_documentation_template.rs](crates/ide-assists/src/handlers/generate_documentation_template.rs#13) +**Source:** [generate_documentation_template.rs](/crates/ide-assists/src/handlers/generate_documentation_template.rs#13) Adds a documentation template above a function definition / declaration. @@ -1645,7 +1645,7 @@ impl S { ### `generate_enum_as_method` -**Source:** [generate_enum_projection_method.rs](crates/ide-assists/src/handlers/generate_enum_projection_method.rs#59) +**Source:** [generate_enum_projection_method.rs](/crates/ide-assists/src/handlers/generate_enum_projection_method.rs#59) Generate an `as_` method for this enum variant. @@ -1677,7 +1677,7 @@ impl Value { ### `generate_enum_is_method` -**Source:** [generate_enum_is_method.rs](crates/ide-assists/src/handlers/generate_enum_is_method.rs#11) +**Source:** [generate_enum_is_method.rs](/crates/ide-assists/src/handlers/generate_enum_is_method.rs#11) Generate an `is_` method for this enum variant. @@ -1711,7 +1711,7 @@ impl Version { ### `generate_enum_try_into_method` -**Source:** [generate_enum_projection_method.rs](crates/ide-assists/src/handlers/generate_enum_projection_method.rs#12) +**Source:** [generate_enum_projection_method.rs](/crates/ide-assists/src/handlers/generate_enum_projection_method.rs#12) Generate a `try_into_` method for this enum variant. @@ -1743,7 +1743,7 @@ impl Value { ### `generate_enum_variant` -**Source:** [generate_enum_variant.rs](crates/ide-assists/src/handlers/generate_enum_variant.rs#10) +**Source:** [generate_enum_variant.rs](/crates/ide-assists/src/handlers/generate_enum_variant.rs#10) Adds a variant to an enum. @@ -1772,7 +1772,7 @@ fn main() { ### `generate_fn_type_alias_named` -**Source:** [generate_fn_type_alias.rs](crates/ide-assists/src/handlers/generate_fn_type_alias.rs#10) +**Source:** [generate_fn_type_alias.rs](/crates/ide-assists/src/handlers/generate_fn_type_alias.rs#10) Generate a type alias for the function with named parameters. @@ -1790,7 +1790,7 @@ unsafe fn foo(n: i32) -> i32 { 42i32 } ### `generate_fn_type_alias_unnamed` -**Source:** [generate_fn_type_alias.rs](crates/ide-assists/src/handlers/generate_fn_type_alias.rs#24) +**Source:** [generate_fn_type_alias.rs](/crates/ide-assists/src/handlers/generate_fn_type_alias.rs#24) Generate a type alias for the function with unnamed parameters. @@ -1808,7 +1808,7 @@ unsafe fn foo(n: i32) -> i32 { 42i32 } ### `generate_from_impl_for_enum` -**Source:** [generate_from_impl_for_enum.rs](crates/ide-assists/src/handlers/generate_from_impl_for_enum.rs#8) +**Source:** [generate_from_impl_for_enum.rs](/crates/ide-assists/src/handlers/generate_from_impl_for_enum.rs#8) Adds a From impl for this enum variant with one tuple field. @@ -1830,7 +1830,7 @@ impl From for A { ### `generate_function` -**Source:** [generate_function.rs](crates/ide-assists/src/handlers/generate_function.rs#28) +**Source:** [generate_function.rs](/crates/ide-assists/src/handlers/generate_function.rs#28) Adds a stub function with a signature matching the function under the cursor. @@ -1860,7 +1860,7 @@ fn bar(arg: &str, baz: Baz) ${0:-> _} { ### `generate_getter` -**Source:** [generate_getter_or_setter.rs](crates/ide-assists/src/handlers/generate_getter_or_setter.rs#73) +**Source:** [generate_getter_or_setter.rs](/crates/ide-assists/src/handlers/generate_getter_or_setter.rs#73) Generate a getter method. @@ -1886,7 +1886,7 @@ impl Person { ### `generate_getter_mut` -**Source:** [generate_getter_or_setter.rs](crates/ide-assists/src/handlers/generate_getter_or_setter.rs#127) +**Source:** [generate_getter_or_setter.rs](/crates/ide-assists/src/handlers/generate_getter_or_setter.rs#127) Generate a mut getter method. @@ -1912,7 +1912,7 @@ impl Person { ### `generate_impl` -**Source:** [generate_impl.rs](crates/ide-assists/src/handlers/generate_impl.rs#20) +**Source:** [generate_impl.rs](/crates/ide-assists/src/handlers/generate_impl.rs#20) Adds a new inherent impl for a type. @@ -1934,7 +1934,7 @@ impl Ctx {┃} ### `generate_is_empty_from_len` -**Source:** [generate_is_empty_from_len.rs](crates/ide-assists/src/handlers/generate_is_empty_from_len.rs#12) +**Source:** [generate_is_empty_from_len.rs](/crates/ide-assists/src/handlers/generate_is_empty_from_len.rs#12) Generates is_empty implementation from the len method. @@ -1969,7 +1969,7 @@ impl MyStruct { ### `generate_mut_trait_impl` -**Source:** [generate_mut_trait_impl.rs](crates/ide-assists/src/handlers/generate_mut_trait_impl.rs#12) +**Source:** [generate_mut_trait_impl.rs](/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs#12) Adds a IndexMut impl from the `Index` trait. @@ -2007,7 +2007,7 @@ impl core::ops::Index for [T; 3] { ### `generate_new` -**Source:** [generate_new.rs](crates/ide-assists/src/handlers/generate_new.rs#14) +**Source:** [generate_new.rs](/crates/ide-assists/src/handlers/generate_new.rs#14) Adds a `fn new` for a type. @@ -2033,7 +2033,7 @@ impl Ctx { ### `generate_setter` -**Source:** [generate_getter_or_setter.rs](crates/ide-assists/src/handlers/generate_getter_or_setter.rs#13) +**Source:** [generate_getter_or_setter.rs](/crates/ide-assists/src/handlers/generate_getter_or_setter.rs#13) Generate a setter method. @@ -2059,7 +2059,7 @@ impl Person { ### `generate_trait_from_impl` -**Source:** [generate_trait_from_impl.rs](crates/ide-assists/src/handlers/generate_trait_from_impl.rs#18) +**Source:** [generate_trait_from_impl.rs](/crates/ide-assists/src/handlers/generate_trait_from_impl.rs#18) Generate trait for an already defined inherent impl and convert impl to a trait impl. @@ -2118,7 +2118,7 @@ impl ${0:NewTrait} for Foo { ### `generate_trait_impl` -**Source:** [generate_impl.rs](crates/ide-assists/src/handlers/generate_impl.rs#66) +**Source:** [generate_impl.rs](/crates/ide-assists/src/handlers/generate_impl.rs#66) Adds a new trait impl for a type. @@ -2140,7 +2140,7 @@ impl ${0:_} for Ctx {} ### `inline_call` -**Source:** [inline_call.rs](crates/ide-assists/src/handlers/inline_call.rs#170) +**Source:** [inline_call.rs](/crates/ide-assists/src/handlers/inline_call.rs#170) Inlines a function or method body creating a `let` statement per parameter unless the parameter can be inlined. The parameter will be inlined either if it the supplied argument is a simple local @@ -2165,7 +2165,7 @@ fn foo(name: Option<&str>) { ### `inline_const_as_literal` -**Source:** [inline_const_as_literal.rs](crates/ide-assists/src/handlers/inline_const_as_literal.rs#6) +**Source:** [inline_const_as_literal.rs](/crates/ide-assists/src/handlers/inline_const_as_literal.rs#6) Evaluate and inline const variable as literal. @@ -2189,7 +2189,7 @@ fn something() -> &'static str { ### `inline_into_callers` -**Source:** [inline_call.rs](crates/ide-assists/src/handlers/inline_call.rs#32) +**Source:** [inline_call.rs](/crates/ide-assists/src/handlers/inline_call.rs#32) Inline a function or method body into all of its callers where possible, creating a `let` statement per parameter unless the parameter can be inlined. The parameter will be inlined either if it the supplied argument is a simple local @@ -2232,7 +2232,7 @@ fn bar() { ### `inline_local_variable` -**Source:** [inline_local_variable.rs](crates/ide-assists/src/handlers/inline_local_variable.rs#17) +**Source:** [inline_local_variable.rs](/crates/ide-assists/src/handlers/inline_local_variable.rs#17) Inlines a local variable. @@ -2253,7 +2253,7 @@ fn main() { ### `inline_macro` -**Source:** [inline_macro.rs](crates/ide-assists/src/handlers/inline_macro.rs#7) +**Source:** [inline_macro.rs](/crates/ide-assists/src/handlers/inline_macro.rs#7) Takes a macro and inlines it one step. @@ -2289,7 +2289,7 @@ fn main() { ### `inline_type_alias` -**Source:** [inline_type_alias.rs](crates/ide-assists/src/handlers/inline_type_alias.rs#106) +**Source:** [inline_type_alias.rs](/crates/ide-assists/src/handlers/inline_type_alias.rs#106) Replace a type alias with its concrete type. @@ -2313,7 +2313,7 @@ fn main() { ### `inline_type_alias_uses` -**Source:** [inline_type_alias.rs](crates/ide-assists/src/handlers/inline_type_alias.rs#24) +**Source:** [inline_type_alias.rs](/crates/ide-assists/src/handlers/inline_type_alias.rs#24) Inline a type alias into all of its uses where possible. @@ -2341,7 +2341,7 @@ fn foo() { ### `into_to_qualified_from` -**Source:** [into_to_qualified_from.rs](crates/ide-assists/src/handlers/into_to_qualified_from.rs#10) +**Source:** [into_to_qualified_from.rs](/crates/ide-assists/src/handlers/into_to_qualified_from.rs#10) Convert an `into` method call to a fully qualified `from` call. @@ -2378,7 +2378,7 @@ fn main() -> () { ### `introduce_named_generic` -**Source:** [introduce_named_generic.rs](crates/ide-assists/src/handlers/introduce_named_generic.rs#7) +**Source:** [introduce_named_generic.rs](/crates/ide-assists/src/handlers/introduce_named_generic.rs#7) Replaces `impl Trait` function argument with the named generic. @@ -2394,7 +2394,7 @@ fn foo<┃B: Bar>(bar: B) {} ### `introduce_named_lifetime` -**Source:** [introduce_named_lifetime.rs](crates/ide-assists/src/handlers/introduce_named_lifetime.rs#13) +**Source:** [introduce_named_lifetime.rs](/crates/ide-assists/src/handlers/introduce_named_lifetime.rs#13) Change an anonymous lifetime to a named lifetime. @@ -2422,7 +2422,7 @@ impl<'a> Cursor<'a> { ### `invert_if` -**Source:** [invert_if.rs](crates/ide-assists/src/handlers/invert_if.rs#13) +**Source:** [invert_if.rs](/crates/ide-assists/src/handlers/invert_if.rs#13) This transforms if expressions of the form `if !x {A} else {B}` into `if x {B} else {A}` This also works with `!=`. This assist can only be applied with the cursor on `if`. @@ -2443,7 +2443,7 @@ fn main() { ### `line_to_block` -**Source:** [convert_comment_block.rs](crates/ide-assists/src/handlers/convert_comment_block.rs#9) +**Source:** [convert_comment_block.rs](/crates/ide-assists/src/handlers/convert_comment_block.rs#9) Converts comments between block and single-line form. @@ -2463,7 +2463,7 @@ Converts comments between block and single-line form. ### `make_raw_string` -**Source:** [raw_string.rs](crates/ide-assists/src/handlers/raw_string.rs#7) +**Source:** [raw_string.rs](/crates/ide-assists/src/handlers/raw_string.rs#7) Adds `r#` to a plain string literal. @@ -2483,7 +2483,7 @@ fn main() { ### `make_usual_string` -**Source:** [raw_string.rs](crates/ide-assists/src/handlers/raw_string.rs#47) +**Source:** [raw_string.rs](/crates/ide-assists/src/handlers/raw_string.rs#47) Turns a raw string into a plain string. @@ -2503,7 +2503,7 @@ fn main() { ### `merge_imports` -**Source:** [merge_imports.rs](crates/ide-assists/src/handlers/merge_imports.rs#21) +**Source:** [merge_imports.rs](/crates/ide-assists/src/handlers/merge_imports.rs#21) Merges neighbor imports with a common prefix. @@ -2520,7 +2520,7 @@ use std::{fmt::Formatter, io}; ### `merge_match_arms` -**Source:** [merge_match_arms.rs](crates/ide-assists/src/handlers/merge_match_arms.rs#12) +**Source:** [merge_match_arms.rs](/crates/ide-assists/src/handlers/merge_match_arms.rs#12) Merges the current match arm with the following if their bodies are identical. @@ -2549,7 +2549,7 @@ fn handle(action: Action) { ### `merge_nested_if` -**Source:** [merge_nested_if.rs](crates/ide-assists/src/handlers/merge_nested_if.rs#11) +**Source:** [merge_nested_if.rs](/crates/ide-assists/src/handlers/merge_nested_if.rs#11) This transforms if expressions of the form `if x { if y {A} }` into `if x && y {A}` This assist can only be applied with the cursor on `if`. @@ -2570,7 +2570,7 @@ fn main() { ### `move_arm_cond_to_match_guard` -**Source:** [move_guard.rs](crates/ide-assists/src/handlers/move_guard.rs#69) +**Source:** [move_guard.rs](/crates/ide-assists/src/handlers/move_guard.rs#69) Moves if expression from match arm body into a guard. @@ -2600,7 +2600,7 @@ fn handle(action: Action) { ### `move_bounds_to_where_clause` -**Source:** [move_bounds.rs](crates/ide-assists/src/handlers/move_bounds.rs#12) +**Source:** [move_bounds.rs](/crates/ide-assists/src/handlers/move_bounds.rs#12) Moves inline type bounds to a where clause. @@ -2620,7 +2620,7 @@ fn apply(f: F, x: T) -> U where F: FnOnce(T) -> U { ### `move_const_to_impl` -**Source:** [move_const_to_impl.rs](crates/ide-assists/src/handlers/move_const_to_impl.rs#14) +**Source:** [move_const_to_impl.rs](/crates/ide-assists/src/handlers/move_const_to_impl.rs#14) Move a local constant item in a method to impl's associated constant. All the references will be qualified with `Self::`. @@ -2653,7 +2653,7 @@ impl S { ### `move_from_mod_rs` -**Source:** [move_from_mod_rs.rs](crates/ide-assists/src/handlers/move_from_mod_rs.rs#12) +**Source:** [move_from_mod_rs.rs](/crates/ide-assists/src/handlers/move_from_mod_rs.rs#12) Moves xxx/mod.rs to xxx.rs. @@ -2672,7 +2672,7 @@ fn t() {} ### `move_guard_to_arm_body` -**Source:** [move_guard.rs](crates/ide-assists/src/handlers/move_guard.rs#8) +**Source:** [move_guard.rs](/crates/ide-assists/src/handlers/move_guard.rs#8) Moves match guard into match arm body. @@ -2704,7 +2704,7 @@ fn handle(action: Action) { ### `move_module_to_file` -**Source:** [move_module_to_file.rs](crates/ide-assists/src/handlers/move_module_to_file.rs#15) +**Source:** [move_module_to_file.rs](/crates/ide-assists/src/handlers/move_module_to_file.rs#15) Moves inline module's contents to a separate file. @@ -2722,7 +2722,7 @@ mod foo; ### `move_to_mod_rs` -**Source:** [move_to_mod_rs.rs](crates/ide-assists/src/handlers/move_to_mod_rs.rs#12) +**Source:** [move_to_mod_rs.rs](/crates/ide-assists/src/handlers/move_to_mod_rs.rs#12) Moves xxx.rs to xxx/mod.rs. @@ -2741,7 +2741,7 @@ fn t() {} ### `normalize_import` -**Source:** [normalize_import.rs](crates/ide-assists/src/handlers/normalize_import.rs#9) +**Source:** [normalize_import.rs](/crates/ide-assists/src/handlers/normalize_import.rs#9) Normalizes an import. @@ -2757,7 +2757,7 @@ use std::{fmt::Formatter, io}; ### `promote_local_to_const` -**Source:** [promote_local_to_const.rs](crates/ide-assists/src/handlers/promote_local_to_const.rs#17) +**Source:** [promote_local_to_const.rs](/crates/ide-assists/src/handlers/promote_local_to_const.rs#17) Promotes a local variable to a const item changing its name to a `SCREAMING_SNAKE_CASE` variant if the local uses no non-const expressions. @@ -2790,7 +2790,7 @@ fn main() { ### `pull_assignment_up` -**Source:** [pull_assignment_up.rs](crates/ide-assists/src/handlers/pull_assignment_up.rs#11) +**Source:** [pull_assignment_up.rs](/crates/ide-assists/src/handlers/pull_assignment_up.rs#11) Extracts variable assignment to outside an if or match statement. @@ -2822,7 +2822,7 @@ fn main() { ### `qualify_method_call` -**Source:** [qualify_method_call.rs](crates/ide-assists/src/handlers/qualify_method_call.rs#10) +**Source:** [qualify_method_call.rs](/crates/ide-assists/src/handlers/qualify_method_call.rs#10) Replaces the method call with a qualified function call. @@ -2852,7 +2852,7 @@ fn main() { ### `qualify_path` -**Source:** [qualify_path.rs](crates/ide-assists/src/handlers/qualify_path.rs#24) +**Source:** [qualify_path.rs](/crates/ide-assists/src/handlers/qualify_path.rs#24) If the name is unresolved, provides all possible qualified paths for it. @@ -2872,7 +2872,7 @@ fn main() { ### `reformat_number_literal` -**Source:** [number_representation.rs](crates/ide-assists/src/handlers/number_representation.rs#7) +**Source:** [number_representation.rs](/crates/ide-assists/src/handlers/number_representation.rs#7) Adds or removes separators from integer literal. @@ -2888,7 +2888,7 @@ const _: i32 = 1_012_345; ### `remove_dbg` -**Source:** [remove_dbg.rs](crates/ide-assists/src/handlers/remove_dbg.rs#9) +**Source:** [remove_dbg.rs](/crates/ide-assists/src/handlers/remove_dbg.rs#9) Removes `dbg!()` macro call. @@ -2908,7 +2908,7 @@ fn main() { ### `remove_hash` -**Source:** [raw_string.rs](crates/ide-assists/src/handlers/raw_string.rs#117) +**Source:** [raw_string.rs](/crates/ide-assists/src/handlers/raw_string.rs#117) Removes a hash from a raw string literal. @@ -2928,7 +2928,7 @@ fn main() { ### `remove_mut` -**Source:** [remove_mut.rs](crates/ide-assists/src/handlers/remove_mut.rs#5) +**Source:** [remove_mut.rs](/crates/ide-assists/src/handlers/remove_mut.rs#5) Removes the `mut` keyword. @@ -2948,7 +2948,7 @@ impl Walrus { ### `remove_parentheses` -**Source:** [remove_parentheses.rs](crates/ide-assists/src/handlers/remove_parentheses.rs#5) +**Source:** [remove_parentheses.rs](/crates/ide-assists/src/handlers/remove_parentheses.rs#5) Removes redundant parentheses. @@ -2968,7 +2968,7 @@ fn main() { ### `remove_unused_imports` -**Source:** [remove_unused_imports.rs](crates/ide-assists/src/handlers/remove_unused_imports.rs#17) +**Source:** [remove_unused_imports.rs](/crates/ide-assists/src/handlers/remove_unused_imports.rs#17) Removes any use statements in the current selection that are unused. @@ -2989,7 +2989,7 @@ mod foo { ### `remove_unused_param` -**Source:** [remove_unused_param.rs](crates/ide-assists/src/handlers/remove_unused_param.rs#15) +**Source:** [remove_unused_param.rs](/crates/ide-assists/src/handlers/remove_unused_param.rs#15) Removes unused function parameter. @@ -3013,7 +3013,7 @@ fn main() { ### `reorder_fields` -**Source:** [reorder_fields.rs](crates/ide-assists/src/handlers/reorder_fields.rs#8) +**Source:** [reorder_fields.rs](/crates/ide-assists/src/handlers/reorder_fields.rs#8) Reorder the fields of record literals and record patterns in the same order as in the definition. @@ -3032,7 +3032,7 @@ const test: Foo = Foo {foo: 1, bar: 0} ### `reorder_impl_items` -**Source:** [reorder_impl_items.rs](crates/ide-assists/src/handlers/reorder_impl_items.rs#11) +**Source:** [reorder_impl_items.rs](/crates/ide-assists/src/handlers/reorder_impl_items.rs#11) Reorder the items of an `impl Trait`. The items will be ordered in the same order as in the trait definition. @@ -3071,7 +3071,7 @@ impl Foo for Bar { ### `replace_arith_with_checked` -**Source:** [replace_arith_op.rs](crates/ide-assists/src/handlers/replace_arith_op.rs#9) +**Source:** [replace_arith_op.rs](/crates/ide-assists/src/handlers/replace_arith_op.rs#9) Replaces arithmetic on integers with the `checked_*` equivalent. @@ -3091,7 +3091,7 @@ fn main() { ### `replace_arith_with_saturating` -**Source:** [replace_arith_op.rs](crates/ide-assists/src/handlers/replace_arith_op.rs#28) +**Source:** [replace_arith_op.rs](/crates/ide-assists/src/handlers/replace_arith_op.rs#28) Replaces arithmetic on integers with the `saturating_*` equivalent. @@ -3111,7 +3111,7 @@ fn main() { ### `replace_arith_with_wrapping` -**Source:** [replace_arith_op.rs](crates/ide-assists/src/handlers/replace_arith_op.rs#50) +**Source:** [replace_arith_op.rs](/crates/ide-assists/src/handlers/replace_arith_op.rs#50) Replaces arithmetic on integers with the `wrapping_*` equivalent. @@ -3131,7 +3131,7 @@ fn main() { ### `replace_char_with_string` -**Source:** [replace_string_with_char.rs](crates/ide-assists/src/handlers/replace_string_with_char.rs#51) +**Source:** [replace_string_with_char.rs](/crates/ide-assists/src/handlers/replace_string_with_char.rs#51) Replace a char literal with a string literal. @@ -3151,7 +3151,7 @@ fn main() { ### `replace_derive_with_manual_impl` -**Source:** [replace_derive_with_manual_impl.rs](crates/ide-assists/src/handlers/replace_derive_with_manual_impl.rs#20) +**Source:** [replace_derive_with_manual_impl.rs](/crates/ide-assists/src/handlers/replace_derive_with_manual_impl.rs#20) Converts a `derive` impl into a manual one. @@ -3175,7 +3175,7 @@ impl Debug for S { ### `replace_if_let_with_match` -**Source:** [replace_if_let_with_match.rs](crates/ide-assists/src/handlers/replace_if_let_with_match.rs#20) +**Source:** [replace_if_let_with_match.rs](/crates/ide-assists/src/handlers/replace_if_let_with_match.rs#20) Replaces a `if let` expression with a `match` expression. @@ -3206,7 +3206,7 @@ fn handle(action: Action) { ### `replace_is_some_with_if_let_some` -**Source:** [replace_is_method_with_if_let_method.rs](crates/ide-assists/src/handlers/replace_is_method_with_if_let_method.rs#9) +**Source:** [replace_is_method_with_if_let_method.rs](/crates/ide-assists/src/handlers/replace_is_method_with_if_let_method.rs#9) Replace `if x.is_some()` with `if let Some(_tmp) = x` or `if x.is_ok()` with `if let Ok(_tmp) = x`. @@ -3228,7 +3228,7 @@ fn main() { ### `replace_let_with_if_let` -**Source:** [replace_let_with_if_let.rs](crates/ide-assists/src/handlers/replace_let_with_if_let.rs#9) +**Source:** [replace_let_with_if_let.rs](/crates/ide-assists/src/handlers/replace_let_with_if_let.rs#9) Replaces `let` with an `if let`. @@ -3255,7 +3255,7 @@ fn compute() -> Option { None } ### `replace_match_with_if_let` -**Source:** [replace_if_let_with_match.rs](crates/ide-assists/src/handlers/replace_if_let_with_match.rs#188) +**Source:** [replace_if_let_with_match.rs](/crates/ide-assists/src/handlers/replace_if_let_with_match.rs#188) Replaces a binary `match` with a wildcard pattern and no guards with an `if let` expression. @@ -3286,7 +3286,7 @@ fn handle(action: Action) { ### `replace_named_generic_with_impl` -**Source:** [replace_named_generic_with_impl.rs](crates/ide-assists/src/handlers/replace_named_generic_with_impl.rs#18) +**Source:** [replace_named_generic_with_impl.rs](/crates/ide-assists/src/handlers/replace_named_generic_with_impl.rs#18) Replaces named generic with an `impl Trait` in function argument. @@ -3302,7 +3302,7 @@ fn new(location: impl AsRef) -> Self {} ### `replace_qualified_name_with_use` -**Source:** [replace_qualified_name_with_use.rs](crates/ide-assists/src/handlers/replace_qualified_name_with_use.rs#13) +**Source:** [replace_qualified_name_with_use.rs](/crates/ide-assists/src/handlers/replace_qualified_name_with_use.rs#13) Adds a use statement for a given fully-qualified name. @@ -3320,7 +3320,7 @@ fn process(map: HashMap) {} ### `replace_string_with_char` -**Source:** [replace_string_with_char.rs](crates/ide-assists/src/handlers/replace_string_with_char.rs#11) +**Source:** [replace_string_with_char.rs](/crates/ide-assists/src/handlers/replace_string_with_char.rs#11) Replace string literal with char literal. @@ -3340,7 +3340,7 @@ fn main() { ### `replace_try_expr_with_match` -**Source:** [replace_try_expr_with_match.rs](crates/ide-assists/src/handlers/replace_try_expr_with_match.rs#18) +**Source:** [replace_try_expr_with_match.rs](/crates/ide-assists/src/handlers/replace_try_expr_with_match.rs#18) Replaces a `try` expression with a `match` expression. @@ -3363,7 +3363,7 @@ fn handle() { ### `replace_turbofish_with_explicit_type` -**Source:** [replace_turbofish_with_explicit_type.rs](crates/ide-assists/src/handlers/replace_turbofish_with_explicit_type.rs#12) +**Source:** [replace_turbofish_with_explicit_type.rs](/crates/ide-assists/src/handlers/replace_turbofish_with_explicit_type.rs#12) Converts `::<_>` to an explicit type assignment. @@ -3385,7 +3385,7 @@ fn main() { ### `replace_with_eager_method` -**Source:** [replace_method_eager_lazy.rs](crates/ide-assists/src/handlers/replace_method_eager_lazy.rs#89) +**Source:** [replace_method_eager_lazy.rs](/crates/ide-assists/src/handlers/replace_method_eager_lazy.rs#89) Replace `unwrap_or_else` with `unwrap_or` and `ok_or_else` with `ok_or`. @@ -3407,7 +3407,7 @@ fn foo() { ### `replace_with_lazy_method` -**Source:** [replace_method_eager_lazy.rs](crates/ide-assists/src/handlers/replace_method_eager_lazy.rs#9) +**Source:** [replace_method_eager_lazy.rs](/crates/ide-assists/src/handlers/replace_method_eager_lazy.rs#9) Replace `unwrap_or` with `unwrap_or_else` and `ok_or` with `ok_or_else`. @@ -3429,7 +3429,7 @@ fn foo() { ### `sort_items` -**Source:** [sort_items.rs](crates/ide-assists/src/handlers/sort_items.rs#12) +**Source:** [sort_items.rs](/crates/ide-assists/src/handlers/sort_items.rs#12) Sorts item members alphabetically: fields, enum variants and methods. @@ -3520,7 +3520,7 @@ enum Animal { ### `split_import` -**Source:** [split_import.rs](crates/ide-assists/src/handlers/split_import.rs#5) +**Source:** [split_import.rs](/crates/ide-assists/src/handlers/split_import.rs#5) Wraps the tail of import into braces. @@ -3536,7 +3536,7 @@ use std::{collections::HashMap}; ### `sugar_impl_future_into_async` -**Source:** [toggle_async_sugar.rs](crates/ide-assists/src/handlers/toggle_async_sugar.rs#13) +**Source:** [toggle_async_sugar.rs](/crates/ide-assists/src/handlers/toggle_async_sugar.rs#13) Rewrites asynchronous function from `-> impl Future` into `async fn`. This action does not touch the function body and therefore `async { 0 }` @@ -3558,7 +3558,7 @@ pub async fn foo() -> usize { ### `toggle_ignore` -**Source:** [toggle_ignore.rs](crates/ide-assists/src/handlers/toggle_ignore.rs#8) +**Source:** [toggle_ignore.rs](/crates/ide-assists/src/handlers/toggle_ignore.rs#8) Adds `#[ignore]` attribute to the test. @@ -3581,7 +3581,7 @@ fn arithmetics { ### `toggle_macro_delimiter` -**Source:** [toggle_macro_delimiter.rs](crates/ide-assists/src/handlers/toggle_macro_delimiter.rs#9) +**Source:** [toggle_macro_delimiter.rs](/crates/ide-assists/src/handlers/toggle_macro_delimiter.rs#9) Change macro delimiters in the order of `( -> { -> [ -> (`. @@ -3605,7 +3605,7 @@ sth!{ } ### `unmerge_match_arm` -**Source:** [unmerge_match_arm.rs](crates/ide-assists/src/handlers/unmerge_match_arm.rs#10) +**Source:** [unmerge_match_arm.rs](/crates/ide-assists/src/handlers/unmerge_match_arm.rs#10) Splits the current match with a `|` pattern into two arms with identical bodies. @@ -3634,7 +3634,7 @@ fn handle(action: Action) { ### `unmerge_use` -**Source:** [unmerge_use.rs](crates/ide-assists/src/handlers/unmerge_use.rs#12) +**Source:** [unmerge_use.rs](/crates/ide-assists/src/handlers/unmerge_use.rs#12) Extracts single use item from use list. @@ -3651,7 +3651,7 @@ use std::fmt::Display; ### `unnecessary_async` -**Source:** [unnecessary_async.rs](crates/ide-assists/src/handlers/unnecessary_async.rs#17) +**Source:** [unnecessary_async.rs](/crates/ide-assists/src/handlers/unnecessary_async.rs#17) Removes the `async` mark from functions which have no `.await` in their body. Looks for calls to the functions and removes the `.await` on the call site. @@ -3670,7 +3670,7 @@ pub async fn bar() { foo() } ### `unqualify_method_call` -**Source:** [unqualify_method_call.rs](crates/ide-assists/src/handlers/unqualify_method_call.rs#9) +**Source:** [unqualify_method_call.rs](/crates/ide-assists/src/handlers/unqualify_method_call.rs#9) Transforms universal function call syntax into a method call. @@ -3692,7 +3692,7 @@ fn main() { ### `unwrap_block` -**Source:** [unwrap_block.rs](crates/ide-assists/src/handlers/unwrap_block.rs#12) +**Source:** [unwrap_block.rs](/crates/ide-assists/src/handlers/unwrap_block.rs#12) This assist removes if...else, for, while and loop control statements to just keep the body. @@ -3714,7 +3714,7 @@ fn foo() { ### `unwrap_option_return_type` -**Source:** [unwrap_return_type.rs](crates/ide-assists/src/handlers/unwrap_return_type.rs#13) +**Source:** [unwrap_return_type.rs](/crates/ide-assists/src/handlers/unwrap_return_type.rs#13) Unwrap the function's return type. @@ -3730,7 +3730,7 @@ fn foo() -> i32 { 42i32 } ### `unwrap_result_return_type` -**Source:** [unwrap_return_type.rs](crates/ide-assists/src/handlers/unwrap_return_type.rs#26) +**Source:** [unwrap_return_type.rs](/crates/ide-assists/src/handlers/unwrap_return_type.rs#26) Unwrap the function's return type. @@ -3746,7 +3746,7 @@ fn foo() -> i32 { 42i32 } ### `unwrap_tuple` -**Source:** [unwrap_tuple.rs](crates/ide-assists/src/handlers/unwrap_tuple.rs#8) +**Source:** [unwrap_tuple.rs](/crates/ide-assists/src/handlers/unwrap_tuple.rs#8) Unwrap the tuple to different variables. @@ -3767,7 +3767,7 @@ fn main() { ### `wrap_return_type_in_option` -**Source:** [wrap_return_type.rs](crates/ide-assists/src/handlers/wrap_return_type.rs#16) +**Source:** [wrap_return_type.rs](/crates/ide-assists/src/handlers/wrap_return_type.rs#16) Wrap the function's return type into Option. @@ -3783,7 +3783,7 @@ fn foo() -> Option { Some(42i32) } ### `wrap_return_type_in_result` -**Source:** [wrap_return_type.rs](crates/ide-assists/src/handlers/wrap_return_type.rs#29) +**Source:** [wrap_return_type.rs](/crates/ide-assists/src/handlers/wrap_return_type.rs#29) Wrap the function's return type into Result. @@ -3799,7 +3799,7 @@ fn foo() -> Result { Ok(42i32) } ### `wrap_unwrap_cfg_attr` -**Source:** [wrap_unwrap_cfg_attr.rs](crates/ide-assists/src/handlers/wrap_unwrap_cfg_attr.rs#12) +**Source:** [wrap_unwrap_cfg_attr.rs](/crates/ide-assists/src/handlers/wrap_unwrap_cfg_attr.rs#12) Wraps an attribute to a cfg_attr attribute or unwraps a cfg_attr attribute to the inner attributes. diff --git a/docs/dev/README.md b/docs/book/src/contributing/README.md similarity index 98% rename from docs/dev/README.md rename to docs/book/src/contributing/README.md index c990212d58..cbbf6acf3e 100644 --- a/docs/dev/README.md +++ b/docs/book/src/contributing/README.md @@ -9,7 +9,7 @@ $ cargo test should be enough to get you started! -To learn more about how rust-analyzer works, see [./architecture.md](./architecture.md). +To learn more about how rust-analyzer works, see [Architecture](architecture.md). It also explains the high-level layout of the source code. Do skim through that document. @@ -24,7 +24,9 @@ rust-analyzer is a part of the [RLS-2.0 working group](https://github.com/rust-lang/compiler-team/tree/6a769c13656c0a6959ebc09e7b1f7c09b86fb9c0/working-groups/rls-2.0). Discussion happens in this Zulip stream: -https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer + + + # Issue Labels @@ -54,7 +56,7 @@ https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer # Code Style & Review Process -Do see [./style.md](./style.md). +See the [Style Guide](style.md). # Cookbook @@ -88,11 +90,13 @@ As a sanity check after I'm done, I use `cargo xtask install --server` and **Rel If the problem concerns only the VS Code extension, I use **Run Installed Extension** launch configuration from `launch.json`. Notably, this uses the usual `rust-analyzer` binary from `PATH`. For this, it is important to have the following in your `settings.json` file: + ```json { "rust-analyzer.server.path": "rust-analyzer" } ``` + After I am done with the fix, I use `cargo xtask install --client` to try the new extension for real. If I need to fix something in the `rust-analyzer` crate, I feel sad because it's on the boundary between the two processes, and working there is slow. @@ -117,6 +121,7 @@ cd editors/code npm ci npm run lint ``` + ## How to ... * ... add an assist? [#7535](https://github.com/rust-lang/rust-analyzer/pull/7535) @@ -142,14 +147,15 @@ Note that `stdout` is used for the actual protocol, so `println!` will break thi To log all communication between the server and the client, there are two choices: * You can log on the server side, by running something like + ``` env RA_LOG=lsp_server=debug code . ``` + * You can log on the client side, by the `rust-analyzer: Toggle LSP Logs` command or enabling `"rust-analyzer.trace.server": "verbose"` workspace setting. These logs are shown in a separate tab in the output and could be used with LSP inspector. Kudos to [@DJMcNab](https://github.com/DJMcNab) for setting this awesome infra up! - There are also several VS Code commands which might be of interest: * `rust-analyzer: Status` shows some memory-usage statistics. diff --git a/docs/dev/architecture.md b/docs/book/src/contributing/architecture.md similarity index 98% rename from docs/dev/architecture.md rename to docs/book/src/contributing/architecture.md index 9c9e05a429..b9b98bfea3 100644 --- a/docs/dev/architecture.md +++ b/docs/book/src/contributing/architecture.md @@ -8,19 +8,20 @@ It goes deeper than what is covered in this document, but will take some time to See also these implementation-related blog posts: -* https://rust-analyzer.github.io/blog/2019/11/13/find-usages.html -* https://rust-analyzer.github.io/blog/2020/07/20/three-architectures-for-responsive-ide.html -* https://rust-analyzer.github.io/blog/2020/09/16/challeging-LR-parsing.html -* https://rust-analyzer.github.io/blog/2020/09/28/how-to-make-a-light-bulb.html -* https://rust-analyzer.github.io/blog/2020/10/24/introducing-ungrammar.html +* +* +* +* +* For older, by now mostly outdated stuff, see the [guide](./guide.md) and [another playlist](https://www.youtube.com/playlist?list=PL85XCvVPmGQho7MZkdW-wtPtuJcFpzycE). - ## Bird's Eye View ![](https://user-images.githubusercontent.com/4789492/107129398-0ab70f00-687a-11eb-9bfc-d4eb023aec06.png) + + On the highest level, rust-analyzer is a thing which accepts input source code from the client and produces a structured semantic model of the code. More specifically, input data consists of a set of test files (`(PathBuf, String)` pairs) and information about project structure, captured in the so called `CrateGraph`. diff --git a/docs/dev/debugging.md b/docs/book/src/contributing/debugging.md similarity index 99% rename from docs/dev/debugging.md rename to docs/book/src/contributing/debugging.md index 48caec1d8f..db3a28eed1 100644 --- a/docs/dev/debugging.md +++ b/docs/book/src/contributing/debugging.md @@ -8,6 +8,7 @@ Debug options view - Install all TypeScript dependencies + ```bash cd editors/code npm ci @@ -19,7 +20,6 @@ where **only** the `rust-analyzer` extension being debugged is enabled. * To activate the extension you need to open any Rust project folder in `[Extension Development Host]`. - ## Debug TypeScript VSCode extension - `Run Installed Extension` - runs the extension with the globally installed `rust-analyzer` binary. @@ -36,12 +36,12 @@ To apply changes to an already running debug process, press Ctrl+Shift+PCtrl+Shift+P + ## The big picture On the highest possible level, rust-analyzer is a stateful component. A client may @@ -76,10 +78,10 @@ to study its methods to understand all the input data. The `change_file` method controls the set of the input files, where each file has an integer id (`FileId`, picked by the client) and text (`Option>`). -Paths are tricky; they'll be explained below, in source roots section, +Paths are tricky; they'll be explained below, in source roots section, together with the `set_roots` method. The "source root" [`is_library`] flag -along with the concept of [`durability`] allows us to add a group of files which -are assumed to rarely change. It's mostly an optimization and does not change +along with the concept of [`durability`] allows us to add a group of files which +are assumed to rarely change. It's mostly an optimization and does not change the fundamental picture. [`is_library`]: https://github.com/rust-lang/rust-analyzer/blob/2024-01-01/crates/base-db/src/input.rs#L38 @@ -141,7 +143,7 @@ the source root, even `/dev/random`. ## Language Server Protocol -Now let's see how the `Analysis` API is exposed via the JSON RPC based language server protocol. +Now let's see how the `Analysis` API is exposed via the JSON RPC based language server protocol. The hard part here is managing changes (which can come either from the file system or from the editor) and concurrency (we want to spawn background jobs for things like syntax highlighting). We use the event loop pattern to manage the zoo, and @@ -152,13 +154,12 @@ the loop is the [`GlobalState::run`] function initiated by [`main_loop`] after [`GlobalState::new`]: https://github.com/rust-lang/rust-analyzer/blob/2024-01-01/crates/rust-analyzer/src/global_state.rs#L148-L215 [`GlobalState::run`]: https://github.com/rust-lang/rust-analyzer/blob/2024-01-01/crates/rust-analyzer/src/main_loop.rs#L114-L140 - Let's walk through a typical analyzer session! First, we need to figure out what to analyze. To do this, we run `cargo metadata` to learn about Cargo packages for current workspace and dependencies, and we run `rustc --print sysroot` and scan the "sysroot" -(the directory containing the current Rust toolchain's files) to learn about crates +(the directory containing the current Rust toolchain's files) to learn about crates like `std`. This happens in the [`GlobalState::fetch_workspaces`] method. We load this configuration at the start of the server in [`GlobalState::new`], but it's also triggered by workspace change events and requests to reload the diff --git a/docs/dev/lsp-extensions.md b/docs/book/src/contributing/lsp-extensions.md similarity index 99% rename from docs/dev/lsp-extensions.md rename to docs/book/src/contributing/lsp-extensions.md index c7ee4e4023..14a3fd1ebd 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/book/src/contributing/lsp-extensions.md @@ -19,6 +19,8 @@ Requests, which are likely to always remain specific to `rust-analyzer` are unde If you want to be notified about the changes to this document, subscribe to [#4604](https://github.com/rust-lang/rust-analyzer/issues/4604). + + ## Configuration in `initializationOptions` **Upstream Issue:** https://github.com/microsoft/language-server-protocol/issues/567 diff --git a/docs/dev/setup.md b/docs/book/src/contributing/setup.md similarity index 100% rename from docs/dev/setup.md rename to docs/book/src/contributing/setup.md diff --git a/docs/dev/style.md b/docs/book/src/contributing/style.md similarity index 99% rename from docs/dev/style.md rename to docs/book/src/contributing/style.md index 51b60ab2eb..6e5d1869b1 100644 --- a/docs/dev/style.md +++ b/docs/book/src/contributing/style.md @@ -1,3 +1,5 @@ +# Style + Our approach to "clean code" is two-fold: * We generally don't block PRs on style changes. diff --git a/docs/dev/syntax.md b/docs/book/src/contributing/syntax.md similarity index 100% rename from docs/dev/syntax.md rename to docs/book/src/contributing/syntax.md diff --git a/xtask/src/tidy.rs b/xtask/src/tidy.rs index 35412be876..fbc88e7acf 100644 --- a/xtask/src/tidy.rs +++ b/xtask/src/tidy.rs @@ -27,8 +27,9 @@ fn check_lsp_extensions_docs(sh: &Shell) { }; let actual_hash = { - let lsp_extensions_md = - sh.read_file(project_root().join("docs/dev/lsp-extensions.md")).unwrap(); + let lsp_extensions_md = sh + .read_file(project_root().join("docs/book/src/contributing/lsp-extensions.md")) + .unwrap(); let text = lsp_extensions_md .lines() .find_map(|line| line.strip_prefix("lsp/ext.rs hash:"))