7184: Changes Cursor Marker To $0 r=matklad a=kevaundray



Co-authored-by: Kevaundray Wedderburn <kevtheappdev@gmail.com>
This commit is contained in:
bors[bot] 2021-01-07 12:27:17 +00:00 committed by GitHub
commit 7967ce85cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
110 changed files with 1745 additions and 1765 deletions

View file

@ -12,7 +12,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// //
// ``` // ```
// fn main() { // fn main() {
// let x<|> = 92; // let x$0 = 92;
// } // }
// ``` // ```
// -> // ->
@ -81,21 +81,17 @@ mod tests {
#[test] #[test]
fn add_explicit_type_target() { fn add_explicit_type_target() {
check_assist_target(add_explicit_type, "fn f() { let a<|> = 1; }", "a"); check_assist_target(add_explicit_type, "fn f() { let a$0 = 1; }", "a");
} }
#[test] #[test]
fn add_explicit_type_works_for_simple_expr() { fn add_explicit_type_works_for_simple_expr() {
check_assist(add_explicit_type, "fn f() { let a<|> = 1; }", "fn f() { let a: i32 = 1; }"); check_assist(add_explicit_type, "fn f() { let a$0 = 1; }", "fn f() { let a: i32 = 1; }");
} }
#[test] #[test]
fn add_explicit_type_works_for_underscore() { fn add_explicit_type_works_for_underscore() {
check_assist( check_assist(add_explicit_type, "fn f() { let a$0: _ = 1; }", "fn f() { let a: i32 = 1; }");
add_explicit_type,
"fn f() { let a<|>: _ = 1; }",
"fn f() { let a: i32 = 1; }",
);
} }
#[test] #[test]
@ -109,7 +105,7 @@ mod tests {
} }
fn f() { fn f() {
let a<|>: Option<_> = Option::Some(1); let a$0: Option<_> = Option::Some(1);
}"#, }"#,
r#" r#"
enum Option<T> { enum Option<T> {
@ -127,7 +123,7 @@ mod tests {
fn add_explicit_type_works_for_macro_call() { fn add_explicit_type_works_for_macro_call() {
check_assist( check_assist(
add_explicit_type, add_explicit_type,
r"macro_rules! v { () => {0u64} } fn f() { let a<|> = v!(); }", r"macro_rules! v { () => {0u64} } fn f() { let a$0 = v!(); }",
r"macro_rules! v { () => {0u64} } fn f() { let a: u64 = v!(); }", r"macro_rules! v { () => {0u64} } fn f() { let a: u64 = v!(); }",
); );
} }
@ -136,31 +132,31 @@ mod tests {
fn add_explicit_type_works_for_macro_call_recursive() { fn add_explicit_type_works_for_macro_call_recursive() {
check_assist( check_assist(
add_explicit_type, add_explicit_type,
r#"macro_rules! u { () => {0u64} } macro_rules! v { () => {u!()} } fn f() { let a<|> = v!(); }"#, r#"macro_rules! u { () => {0u64} } macro_rules! v { () => {u!()} } fn f() { let a$0 = v!(); }"#,
r#"macro_rules! u { () => {0u64} } macro_rules! v { () => {u!()} } fn f() { let a: u64 = v!(); }"#, r#"macro_rules! u { () => {0u64} } macro_rules! v { () => {u!()} } fn f() { let a: u64 = v!(); }"#,
); );
} }
#[test] #[test]
fn add_explicit_type_not_applicable_if_ty_not_inferred() { fn add_explicit_type_not_applicable_if_ty_not_inferred() {
check_assist_not_applicable(add_explicit_type, "fn f() { let a<|> = None; }"); check_assist_not_applicable(add_explicit_type, "fn f() { let a$0 = None; }");
} }
#[test] #[test]
fn add_explicit_type_not_applicable_if_ty_already_specified() { fn add_explicit_type_not_applicable_if_ty_already_specified() {
check_assist_not_applicable(add_explicit_type, "fn f() { let a<|>: i32 = 1; }"); check_assist_not_applicable(add_explicit_type, "fn f() { let a$0: i32 = 1; }");
} }
#[test] #[test]
fn add_explicit_type_not_applicable_if_specified_ty_is_tuple() { fn add_explicit_type_not_applicable_if_specified_ty_is_tuple() {
check_assist_not_applicable(add_explicit_type, "fn f() { let a<|>: (i32, i32) = (3, 4); }"); check_assist_not_applicable(add_explicit_type, "fn f() { let a$0: (i32, i32) = (3, 4); }");
} }
#[test] #[test]
fn add_explicit_type_not_applicable_if_cursor_after_equals() { fn add_explicit_type_not_applicable_if_cursor_after_equals() {
check_assist_not_applicable( check_assist_not_applicable(
add_explicit_type, add_explicit_type,
"fn f() {let a =<|> match 1 {2 => 3, 3 => 5};}", "fn f() {let a =$0 match 1 {2 => 3, 3 => 5};}",
) )
} }
@ -168,7 +164,7 @@ mod tests {
fn add_explicit_type_not_applicable_if_cursor_before_let() { fn add_explicit_type_not_applicable_if_cursor_before_let() {
check_assist_not_applicable( check_assist_not_applicable(
add_explicit_type, add_explicit_type,
"fn f() <|>{let a = match 1 {2 => 3, 3 => 5};}", "fn f() $0{let a = match 1 {2 => 3, 3 => 5};}",
) )
} }
@ -178,7 +174,7 @@ mod tests {
add_explicit_type, add_explicit_type,
r#" r#"
fn main() { fn main() {
let multiply_by_two<|> = |i| i * 3; let multiply_by_two$0 = |i| i * 3;
let six = multiply_by_two(2); let six = multiply_by_two(2);
}"#, }"#,
) )
@ -195,7 +191,7 @@ struct Test<K, T = u8> {
} }
fn main() { fn main() {
let test<|> = Test { t: 23u8, k: 33 }; let test$0 = Test { t: 23u8, k: 33 };
}"#, }"#,
r#" r#"
struct Test<K, T = u8> { struct Test<K, T = u8> {

View file

@ -20,7 +20,7 @@ use crate::{
// fn bar(&self) {} // fn bar(&self) {}
// } // }
// //
// impl Trait<u32> for () {<|> // impl Trait<u32> for () {$0
// //
// } // }
// ``` // ```
@ -63,7 +63,7 @@ pub(crate) fn add_missing_impl_members(acc: &mut Assists, ctx: &AssistContext) -
// //
// impl Trait for () { // impl Trait for () {
// type X = (); // type X = ();
// fn foo(&self) {}<|> // fn foo(&self) {}$0
// //
// } // }
// ``` // ```
@ -166,7 +166,7 @@ struct S;
impl Foo for S { impl Foo for S {
fn bar(&self) {} fn bar(&self) {}
<|> $0
}"#, }"#,
r#" r#"
trait Foo { trait Foo {
@ -214,7 +214,7 @@ struct S;
impl Foo for S { impl Foo for S {
fn bar(&self) {} fn bar(&self) {}
<|> $0
}"#, }"#,
r#" r#"
trait Foo { trait Foo {
@ -242,7 +242,7 @@ impl Foo for S {
r#" r#"
trait Foo { fn foo(&self); } trait Foo { fn foo(&self); }
struct S; struct S;
impl Foo for S { <|> }"#, impl Foo for S { $0 }"#,
r#" r#"
trait Foo { fn foo(&self); } trait Foo { fn foo(&self); }
struct S; struct S;
@ -261,7 +261,7 @@ impl Foo for S {
r#" r#"
trait Foo { fn foo(&self); } trait Foo { fn foo(&self); }
struct S; struct S;
impl Foo for S<|>"#, impl Foo for S$0"#,
r#" r#"
trait Foo { fn foo(&self); } trait Foo { fn foo(&self); }
struct S; struct S;
@ -280,7 +280,7 @@ impl Foo for S {
r#" r#"
trait Foo<T> { fn foo(&self, t: T) -> &T; } trait Foo<T> { fn foo(&self, t: T) -> &T; }
struct S; struct S;
impl Foo<u32> for S { <|> }"#, impl Foo<u32> for S { $0 }"#,
r#" r#"
trait Foo<T> { fn foo(&self, t: T) -> &T; } trait Foo<T> { fn foo(&self, t: T) -> &T; }
struct S; struct S;
@ -299,7 +299,7 @@ impl Foo<u32> for S {
r#" r#"
trait Foo<T> { fn foo(&self, t: T) -> &T; } trait Foo<T> { fn foo(&self, t: T) -> &T; }
struct S; struct S;
impl<U> Foo<U> for S { <|> }"#, impl<U> Foo<U> for S { $0 }"#,
r#" r#"
trait Foo<T> { fn foo(&self, t: T) -> &T; } trait Foo<T> { fn foo(&self, t: T) -> &T; }
struct S; struct S;
@ -318,7 +318,7 @@ impl<U> Foo<U> for S {
r#" r#"
trait Foo { fn foo(&self); } trait Foo { fn foo(&self); }
struct S; struct S;
impl Foo for S {}<|>"#, impl Foo for S {}$0"#,
r#" r#"
trait Foo { fn foo(&self); } trait Foo { fn foo(&self); }
struct S; struct S;
@ -340,7 +340,7 @@ mod foo {
trait Foo { fn foo(&self, bar: Bar); } trait Foo { fn foo(&self, bar: Bar); }
} }
struct S; struct S;
impl foo::Foo for S { <|> }"#, impl foo::Foo for S { $0 }"#,
r#" r#"
mod foo { mod foo {
pub struct Bar; pub struct Bar;
@ -370,7 +370,7 @@ mod foo {
use foo::bar; use foo::bar;
struct S; struct S;
impl bar::Foo for S { <|> }"#, impl bar::Foo for S { $0 }"#,
r#" r#"
mod foo { mod foo {
pub mod bar { pub mod bar {
@ -400,7 +400,7 @@ mod foo {
trait Foo { fn foo(&self, bar: Bar<u32>); } trait Foo { fn foo(&self, bar: Bar<u32>); }
} }
struct S; struct S;
impl foo::Foo for S { <|> }"#, impl foo::Foo for S { $0 }"#,
r#" r#"
mod foo { mod foo {
pub struct Bar<T>; pub struct Bar<T>;
@ -425,7 +425,7 @@ mod foo {
trait Foo<T> { fn foo(&self, bar: Bar<T>); } trait Foo<T> { fn foo(&self, bar: Bar<T>); }
} }
struct S; struct S;
impl foo::Foo<u32> for S { <|> }"#, impl foo::Foo<u32> for S { $0 }"#,
r#" r#"
mod foo { mod foo {
pub struct Bar<T>; pub struct Bar<T>;
@ -452,7 +452,7 @@ mod foo {
} }
struct Param; struct Param;
struct S; struct S;
impl foo::Foo<Param> for S { <|> }"#, impl foo::Foo<Param> for S { $0 }"#,
r#" r#"
mod foo { mod foo {
trait Foo<T> { fn foo(&self, bar: T); } trait Foo<T> { fn foo(&self, bar: T); }
@ -479,7 +479,7 @@ mod foo {
trait Foo { fn foo(&self, bar: Bar<u32>::Assoc); } trait Foo { fn foo(&self, bar: Bar<u32>::Assoc); }
} }
struct S; struct S;
impl foo::Foo for S { <|> }"#, impl foo::Foo for S { $0 }"#,
r#" r#"
mod foo { mod foo {
pub struct Bar<T>; pub struct Bar<T>;
@ -506,7 +506,7 @@ mod foo {
trait Foo { fn foo(&self, bar: Bar<Baz>); } trait Foo { fn foo(&self, bar: Bar<Baz>); }
} }
struct S; struct S;
impl foo::Foo for S { <|> }"#, impl foo::Foo for S { $0 }"#,
r#" r#"
mod foo { mod foo {
pub struct Bar<T>; pub struct Bar<T>;
@ -532,7 +532,7 @@ mod foo {
trait Foo { fn foo(&self, bar: dyn Fn(u32) -> i32); } trait Foo { fn foo(&self, bar: dyn Fn(u32) -> i32); }
} }
struct S; struct S;
impl foo::Foo for S { <|> }"#, impl foo::Foo for S { $0 }"#,
r#" r#"
mod foo { mod foo {
pub trait Fn<Args> { type Output; } pub trait Fn<Args> { type Output; }
@ -554,7 +554,7 @@ impl foo::Foo for S {
r#" r#"
trait Foo; trait Foo;
struct S; struct S;
impl Foo for S { <|> }"#, impl Foo for S { $0 }"#,
) )
} }
@ -568,7 +568,7 @@ trait Foo {
fn valid(some: u32) -> bool { false } fn valid(some: u32) -> bool { false }
} }
struct S; struct S;
impl Foo for S { <|> }"#, impl Foo for S { $0 }"#,
) )
} }
@ -586,7 +586,7 @@ trait Foo {
fn foo(&self); fn foo(&self);
} }
struct S; struct S;
impl Foo for S {}<|>"#, impl Foo for S {}$0"#,
r#" r#"
#[doc(alias = "test alias")] #[doc(alias = "test alias")]
trait Foo { trait Foo {
@ -621,7 +621,7 @@ trait Foo {
fn foo(some: u32) -> bool; fn foo(some: u32) -> bool;
} }
struct S; struct S;
impl Foo for S { <|> }"#, impl Foo for S { $0 }"#,
r#" r#"
trait Foo { trait Foo {
type Output; type Output;
@ -648,7 +648,7 @@ trait Foo<T = Self> {
} }
struct S; struct S;
impl Foo for S { <|> }"#, impl Foo for S { $0 }"#,
r#" r#"
trait Foo<T = Self> { trait Foo<T = Self> {
fn bar(&self, other: &T); fn bar(&self, other: &T);
@ -673,7 +673,7 @@ trait Foo<T1, T2 = Self> {
} }
struct S<T>; struct S<T>;
impl Foo<T> for S<T> { <|> }"#, impl Foo<T> for S<T> { $0 }"#,
r#" r#"
trait Foo<T1, T2 = Self> { trait Foo<T1, T2 = Self> {
fn bar(&self, this: &T1, that: &T2); fn bar(&self, this: &T1, that: &T2);
@ -697,7 +697,7 @@ trait Tr {
type Ty: Copy + 'static; type Ty: Copy + 'static;
} }
impl Tr for ()<|> { impl Tr for ()$0 {
}"#, }"#,
r#" r#"
trait Tr { trait Tr {
@ -719,7 +719,7 @@ trait Tr {
fn foo(); fn foo();
} }
impl Tr for ()<|> { impl Tr for ()$0 {
+++ +++
}"#, }"#,
r#" r#"
@ -745,7 +745,7 @@ trait Tr {
fn foo(); fn foo();
} }
impl Tr for ()<|> { impl Tr for ()$0 {
// very important // very important
}"#, }"#,
r#" r#"
@ -771,7 +771,7 @@ trait Test {
fn foo(&self, x: crate) fn foo(&self, x: crate)
} }
impl Test for () { impl Test for () {
<|> $0
} }
"#, "#,
r#" r#"
@ -796,7 +796,7 @@ trait Foo<BAR> {
fn foo(&self, bar: BAR); fn foo(&self, bar: BAR);
} }
impl Foo for () { impl Foo for () {
<|> $0
} }
"#, "#,
r#" r#"

View file

@ -14,7 +14,7 @@ use crate::{
// ``` // ```
// fn make<T>() -> T { todo!() } // fn make<T>() -> T { todo!() }
// fn main() { // fn main() {
// let x = make<|>(); // let x = make$0();
// } // }
// ``` // ```
// -> // ->
@ -77,7 +77,7 @@ mod tests {
r#" r#"
fn make<T>() -> T {} fn make<T>() -> T {}
fn main() { fn main() {
make<|>(); make$0();
} }
"#, "#,
r#" r#"
@ -97,7 +97,7 @@ fn main() {
r#" r#"
fn make<T>() -> T {} fn make<T>() -> T {}
fn main() { fn main() {
make()<|>; make()$0;
} }
"#, "#,
r#" r#"
@ -119,7 +119,7 @@ impl S {
fn make<T>(&self) -> T {} fn make<T>(&self) -> T {}
} }
fn main() { fn main() {
S.make<|>(); S.make$0();
} }
"#, "#,
r#" r#"
@ -142,7 +142,7 @@ fn main() {
r#" r#"
fn make<T>() -> T {} fn make<T>() -> T {}
fn main() { fn main() {
make<|>::<()>(); make$0::<()>();
} }
"#, "#,
); );
@ -156,7 +156,7 @@ fn main() {
r#" r#"
fn make() -> () {} fn make() -> () {}
fn main() { fn main() {
make<|>(); make$0();
} }
"#, "#,
); );

View file

@ -12,7 +12,7 @@ use crate::{utils::invert_boolean_expression, AssistContext, AssistId, AssistKin
// //
// ``` // ```
// fn main() { // fn main() {
// if x != 4 ||<|> !y {} // if x != 4 ||$0 !y {}
// } // }
// ``` // ```
// -> // ->
@ -68,26 +68,26 @@ mod tests {
#[test] #[test]
fn demorgan_turns_and_into_or() { fn demorgan_turns_and_into_or() {
check_assist(apply_demorgan, "fn f() { !x &&<|> !x }", "fn f() { !(x || x) }") check_assist(apply_demorgan, "fn f() { !x &&$0 !x }", "fn f() { !(x || x) }")
} }
#[test] #[test]
fn demorgan_turns_or_into_and() { fn demorgan_turns_or_into_and() {
check_assist(apply_demorgan, "fn f() { !x ||<|> !x }", "fn f() { !(x && x) }") check_assist(apply_demorgan, "fn f() { !x ||$0 !x }", "fn f() { !(x && x) }")
} }
#[test] #[test]
fn demorgan_removes_inequality() { fn demorgan_removes_inequality() {
check_assist(apply_demorgan, "fn f() { x != x ||<|> !x }", "fn f() { !(x == x && x) }") check_assist(apply_demorgan, "fn f() { x != x ||$0 !x }", "fn f() { !(x == x && x) }")
} }
#[test] #[test]
fn demorgan_general_case() { fn demorgan_general_case() {
check_assist(apply_demorgan, "fn f() { x ||<|> x }", "fn f() { !(!x && !x) }") check_assist(apply_demorgan, "fn f() { x ||$0 x }", "fn f() { !(!x && !x) }")
} }
#[test] #[test]
fn demorgan_doesnt_apply_with_cursor_not_on_op() { fn demorgan_doesnt_apply_with_cursor_not_on_op() {
check_assist_not_applicable(apply_demorgan, "fn f() { <|> !x || !x }") check_assist_not_applicable(apply_demorgan, "fn f() { $0 !x || !x }")
} }
} }

View file

@ -70,7 +70,7 @@ use crate::{
// //
// ``` // ```
// fn main() { // fn main() {
// let map = HashMap<|>::new(); // let map = HashMap$0::new();
// } // }
// # pub mod std { pub mod collections { pub struct HashMap { } } } // # pub mod std { pub mod collections { pub struct HashMap { } } }
// ``` // ```
@ -151,7 +151,7 @@ mod tests {
use std::fmt; use std::fmt;
<|>Formatter $0Formatter
", ",
r" r"
mod std { mod std {
@ -172,7 +172,7 @@ mod tests {
check_assist( check_assist(
auto_import, auto_import,
r" r"
<|>PubStruct $0PubStruct
pub mod PubMod { pub mod PubMod {
pub struct PubStruct; pub struct PubStruct;
@ -198,7 +198,7 @@ mod tests {
macro_rules! foo { macro_rules! foo {
($i:ident) => { fn foo(a: $i) {} } ($i:ident) => { fn foo(a: $i) {} }
} }
foo!(Pub<|>Struct); foo!(Pub$0Struct);
pub mod PubMod { pub mod PubMod {
pub struct PubStruct; pub struct PubStruct;
@ -227,7 +227,7 @@ mod tests {
use PubMod::PubStruct1; use PubMod::PubStruct1;
struct Test { struct Test {
test: Pub<|>Struct2<u8>, test: Pub$0Struct2<u8>,
} }
pub mod PubMod { pub mod PubMod {
@ -259,7 +259,7 @@ mod tests {
check_assist( check_assist(
auto_import, auto_import,
r" r"
PubSt<|>ruct PubSt$0ruct
pub mod PubMod1 { pub mod PubMod1 {
pub struct PubStruct; pub struct PubStruct;
@ -296,7 +296,7 @@ mod tests {
r" r"
use PubMod::PubStruct; use PubMod::PubStruct;
PubStruct<|> PubStruct$0
pub mod PubMod { pub mod PubMod {
pub struct PubStruct; pub struct PubStruct;
@ -310,7 +310,7 @@ mod tests {
check_assist_not_applicable( check_assist_not_applicable(
auto_import, auto_import,
r" r"
PrivateStruct<|> PrivateStruct$0
pub mod PubMod { pub mod PubMod {
struct PrivateStruct; struct PrivateStruct;
@ -324,7 +324,7 @@ mod tests {
check_assist_not_applicable( check_assist_not_applicable(
auto_import, auto_import,
" "
PubStruct<|>", PubStruct$0",
); );
} }
@ -333,7 +333,7 @@ mod tests {
check_assist_not_applicable( check_assist_not_applicable(
auto_import, auto_import,
r" r"
use PubStruct<|>; use PubStruct$0;
pub mod PubMod { pub mod PubMod {
pub struct PubStruct; pub struct PubStruct;
@ -346,7 +346,7 @@ mod tests {
check_assist( check_assist(
auto_import, auto_import,
r" r"
test_function<|> test_function$0
pub mod PubMod { pub mod PubMod {
pub fn test_function() {}; pub fn test_function() {};
@ -377,7 +377,7 @@ macro_rules! foo {
//- /main.rs crate:main deps:crate_with_macro //- /main.rs crate:main deps:crate_with_macro
fn main() { fn main() {
foo<|> foo$0
} }
", ",
r"use crate_with_macro::foo; r"use crate_with_macro::foo;
@ -395,7 +395,7 @@ fn main() {
auto_import, auto_import,
r" r"
struct AssistInfo { struct AssistInfo {
group_label: Option<<|>GroupLabel>, group_label: Option<$0GroupLabel>,
} }
mod m { pub struct GroupLabel; } mod m { pub struct GroupLabel; }
@ -419,7 +419,7 @@ fn main() {
use mod1::mod2; use mod1::mod2;
fn main() { fn main() {
mod2::mod3::TestStruct<|> mod2::mod3::TestStruct$0
} }
", ",
); );
@ -436,7 +436,7 @@ fn main() {
use test_mod::test_function; use test_mod::test_function;
fn main() { fn main() {
test_function<|> test_function$0
} }
", ",
); );
@ -455,7 +455,7 @@ fn main() {
} }
fn main() { fn main() {
TestStruct::test_function<|> TestStruct::test_function$0
} }
", ",
r" r"
@ -488,7 +488,7 @@ fn main() {
} }
fn main() { fn main() {
TestStruct::TEST_CONST<|> TestStruct::TEST_CONST$0
} }
", ",
r" r"
@ -524,7 +524,7 @@ fn main() {
} }
fn main() { fn main() {
test_mod::TestStruct::test_function<|> test_mod::TestStruct::test_function$0
} }
", ",
r" r"
@ -573,7 +573,7 @@ fn main() {
use test_mod::TestTrait2; use test_mod::TestTrait2;
fn main() { fn main() {
test_mod::TestEnum::test_function<|>; test_mod::TestEnum::test_function$0;
} }
", ",
) )
@ -595,7 +595,7 @@ fn main() {
} }
fn main() { fn main() {
test_mod::TestStruct::TEST_CONST<|> test_mod::TestStruct::TEST_CONST$0
} }
", ",
r" r"
@ -644,7 +644,7 @@ fn main() {
use test_mod::TestTrait2; use test_mod::TestTrait2;
fn main() { fn main() {
test_mod::TestEnum::TEST_CONST<|>; test_mod::TestEnum::TEST_CONST$0;
} }
", ",
) )
@ -667,7 +667,7 @@ fn main() {
fn main() { fn main() {
let test_struct = test_mod::TestStruct {}; let test_struct = test_mod::TestStruct {};
test_struct.test_meth<|>od() test_struct.test_meth$0od()
} }
", ",
r" r"
@ -699,7 +699,7 @@ fn main() {
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
let test_struct = dep::test_mod::TestStruct {}; let test_struct = dep::test_mod::TestStruct {};
test_struct.test_meth<|>od() test_struct.test_meth$0od()
} }
//- /dep.rs crate:dep //- /dep.rs crate:dep
pub mod test_mod { pub mod test_mod {
@ -730,7 +730,7 @@ fn main() {
r" r"
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
dep::test_mod::TestStruct::test_func<|>tion dep::test_mod::TestStruct::test_func$0tion
} }
//- /dep.rs crate:dep //- /dep.rs crate:dep
pub mod test_mod { pub mod test_mod {
@ -760,7 +760,7 @@ fn main() {
r" r"
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
dep::test_mod::TestStruct::CONST<|> dep::test_mod::TestStruct::CONST$0
} }
//- /dep.rs crate:dep //- /dep.rs crate:dep
pub mod test_mod { pub mod test_mod {
@ -791,7 +791,7 @@ fn main() {
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
let test_struct = dep::test_mod::TestStruct {}; let test_struct = dep::test_mod::TestStruct {};
test_struct.test_func<|>tion() test_struct.test_func$0tion()
} }
//- /dep.rs crate:dep //- /dep.rs crate:dep
pub mod test_mod { pub mod test_mod {
@ -815,7 +815,7 @@ fn main() {
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
let test_struct = dep::test_mod::TestStruct {}; let test_struct = dep::test_mod::TestStruct {};
test_struct.test_meth<|>od() test_struct.test_meth$0od()
} }
//- /dep.rs crate:dep //- /dep.rs crate:dep
pub mod test_mod { pub mod test_mod {
@ -858,7 +858,7 @@ fn main() {
use test_mod::TestTrait2; use test_mod::TestTrait2;
fn main() { fn main() {
let one = test_mod::TestEnum::One; let one = test_mod::TestEnum::One;
one.test<|>_method(); one.test$0_method();
} }
", ",
) )
@ -874,7 +874,7 @@ pub struct Struct;
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
Struct<|> Struct$0
} }
", ",
r"use dep::Struct; r"use dep::Struct;
@ -902,7 +902,7 @@ pub fn panic_fmt() {}
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
struct S; struct S;
impl f<|>mt::Display for S {} impl f$0mt::Display for S {}
", ",
r"use dep::fmt; r"use dep::fmt;
@ -930,7 +930,7 @@ mac!();
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
Cheese<|>; Cheese$0;
} }
", ",
r"use dep::Cheese; r"use dep::Cheese;
@ -954,7 +954,7 @@ pub struct fmt;
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
FMT<|>; FMT$0;
} }
", ",
r"use dep::FMT; r"use dep::FMT;

View file

@ -13,7 +13,7 @@ use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, Assists};
// Adds or changes existing visibility specifier. // Adds or changes existing visibility specifier.
// //
// ``` // ```
// <|>fn frobnicate() {} // $0fn frobnicate() {}
// ``` // ```
// -> // ->
// ``` // ```
@ -118,23 +118,23 @@ mod tests {
#[test] #[test]
fn change_visibility_adds_pub_crate_to_items() { fn change_visibility_adds_pub_crate_to_items() {
check_assist(change_visibility, "<|>fn foo() {}", "pub(crate) fn foo() {}"); check_assist(change_visibility, "$0fn foo() {}", "pub(crate) fn foo() {}");
check_assist(change_visibility, "f<|>n foo() {}", "pub(crate) fn foo() {}"); check_assist(change_visibility, "f$0n foo() {}", "pub(crate) fn foo() {}");
check_assist(change_visibility, "<|>struct Foo {}", "pub(crate) struct Foo {}"); check_assist(change_visibility, "$0struct Foo {}", "pub(crate) struct Foo {}");
check_assist(change_visibility, "<|>mod foo {}", "pub(crate) mod foo {}"); check_assist(change_visibility, "$0mod foo {}", "pub(crate) mod foo {}");
check_assist(change_visibility, "<|>trait Foo {}", "pub(crate) trait Foo {}"); check_assist(change_visibility, "$0trait Foo {}", "pub(crate) trait Foo {}");
check_assist(change_visibility, "m<|>od {}", "pub(crate) mod {}"); check_assist(change_visibility, "m$0od {}", "pub(crate) mod {}");
check_assist(change_visibility, "unsafe f<|>n foo() {}", "pub(crate) unsafe fn foo() {}"); check_assist(change_visibility, "unsafe f$0n foo() {}", "pub(crate) unsafe fn foo() {}");
} }
#[test] #[test]
fn change_visibility_works_with_struct_fields() { fn change_visibility_works_with_struct_fields() {
check_assist( check_assist(
change_visibility, change_visibility,
r"struct S { <|>field: u32 }", r"struct S { $0field: u32 }",
r"struct S { pub(crate) field: u32 }", r"struct S { pub(crate) field: u32 }",
); );
check_assist(change_visibility, r"struct S ( <|>u32 )", r"struct S ( pub(crate) u32 )"); check_assist(change_visibility, r"struct S ( $0u32 )", r"struct S ( pub(crate) u32 )");
} }
#[test] #[test]
@ -142,33 +142,33 @@ mod tests {
mark::check!(change_visibility_field_false_positive); mark::check!(change_visibility_field_false_positive);
check_assist_not_applicable( check_assist_not_applicable(
change_visibility, change_visibility,
r"struct S { field: [(); { let <|>x = ();}] }", r"struct S { field: [(); { let $0x = ();}] }",
) )
} }
#[test] #[test]
fn change_visibility_pub_to_pub_crate() { fn change_visibility_pub_to_pub_crate() {
check_assist(change_visibility, "<|>pub fn foo() {}", "pub(crate) fn foo() {}") check_assist(change_visibility, "$0pub fn foo() {}", "pub(crate) fn foo() {}")
} }
#[test] #[test]
fn change_visibility_pub_crate_to_pub() { fn change_visibility_pub_crate_to_pub() {
check_assist(change_visibility, "<|>pub(crate) fn foo() {}", "pub fn foo() {}") check_assist(change_visibility, "$0pub(crate) fn foo() {}", "pub fn foo() {}")
} }
#[test] #[test]
fn change_visibility_const() { fn change_visibility_const() {
check_assist(change_visibility, "<|>const FOO = 3u8;", "pub(crate) const FOO = 3u8;"); check_assist(change_visibility, "$0const FOO = 3u8;", "pub(crate) const FOO = 3u8;");
} }
#[test] #[test]
fn change_visibility_static() { fn change_visibility_static() {
check_assist(change_visibility, "<|>static FOO = 3u8;", "pub(crate) static FOO = 3u8;"); check_assist(change_visibility, "$0static FOO = 3u8;", "pub(crate) static FOO = 3u8;");
} }
#[test] #[test]
fn change_visibility_type_alias() { fn change_visibility_type_alias() {
check_assist(change_visibility, "<|>type T = ();", "pub(crate) type T = ();"); check_assist(change_visibility, "$0type T = ();", "pub(crate) type T = ();");
} }
#[test] #[test]
@ -181,7 +181,7 @@ mod tests {
// comments // comments
#[derive(Debug)] #[derive(Debug)]
<|>struct Foo; $0struct Foo;
", ",
r" r"
/// docs /// docs
@ -199,14 +199,14 @@ mod tests {
check_assist_not_applicable( check_assist_not_applicable(
change_visibility, change_visibility,
r"mod foo { pub enum Foo {Foo1} } r"mod foo { pub enum Foo {Foo1} }
fn main() { foo::Foo::Foo1<|> } ", fn main() { foo::Foo::Foo1$0 } ",
); );
} }
#[test] #[test]
fn change_visibility_target() { fn change_visibility_target() {
check_assist_target(change_visibility, "<|>fn foo() {}", "fn"); check_assist_target(change_visibility, "$0fn foo() {}", "fn");
check_assist_target(change_visibility, "pub(crate)<|> fn foo() {}", "pub(crate)"); check_assist_target(change_visibility, "pub(crate)$0 fn foo() {}", "pub(crate)");
check_assist_target(change_visibility, "struct S { <|>field: u32 }", "field"); check_assist_target(change_visibility, "struct S { $0field: u32 }", "field");
} }
} }

View file

@ -7,7 +7,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, GroupLabel};
// Converts the base of integer literals to other bases. // Converts the base of integer literals to other bases.
// //
// ``` // ```
// const _: i32 = 10<|>; // const _: i32 = 10$0;
// ``` // ```
// -> // ->
// ``` // ```
@ -65,47 +65,47 @@ mod tests {
#[test] #[test]
fn binary_target() { fn binary_target() {
check_assist_target(convert_integer_literal, "const _: i32 = 0b1010<|>;", "0b1010"); check_assist_target(convert_integer_literal, "const _: i32 = 0b1010$0;", "0b1010");
} }
#[test] #[test]
fn octal_target() { fn octal_target() {
check_assist_target(convert_integer_literal, "const _: i32 = 0o12<|>;", "0o12"); check_assist_target(convert_integer_literal, "const _: i32 = 0o12$0;", "0o12");
} }
#[test] #[test]
fn decimal_target() { fn decimal_target() {
check_assist_target(convert_integer_literal, "const _: i32 = 10<|>;", "10"); check_assist_target(convert_integer_literal, "const _: i32 = 10$0;", "10");
} }
#[test] #[test]
fn hexadecimal_target() { fn hexadecimal_target() {
check_assist_target(convert_integer_literal, "const _: i32 = 0xA<|>;", "0xA"); check_assist_target(convert_integer_literal, "const _: i32 = 0xA$0;", "0xA");
} }
#[test] #[test]
fn binary_target_with_underscores() { fn binary_target_with_underscores() {
check_assist_target(convert_integer_literal, "const _: i32 = 0b10_10<|>;", "0b10_10"); check_assist_target(convert_integer_literal, "const _: i32 = 0b10_10$0;", "0b10_10");
} }
#[test] #[test]
fn octal_target_with_underscores() { fn octal_target_with_underscores() {
check_assist_target(convert_integer_literal, "const _: i32 = 0o1_2<|>;", "0o1_2"); check_assist_target(convert_integer_literal, "const _: i32 = 0o1_2$0;", "0o1_2");
} }
#[test] #[test]
fn decimal_target_with_underscores() { fn decimal_target_with_underscores() {
check_assist_target(convert_integer_literal, "const _: i32 = 1_0<|>;", "1_0"); check_assist_target(convert_integer_literal, "const _: i32 = 1_0$0;", "1_0");
} }
#[test] #[test]
fn hexadecimal_target_with_underscores() { fn hexadecimal_target_with_underscores() {
check_assist_target(convert_integer_literal, "const _: i32 = 0x_A<|>;", "0x_A"); check_assist_target(convert_integer_literal, "const _: i32 = 0x_A$0;", "0x_A");
} }
#[test] #[test]
fn convert_decimal_integer() { fn convert_decimal_integer() {
let before = "const _: i32 = 1000<|>;"; let before = "const _: i32 = 1000$0;";
check_assist_by_label( check_assist_by_label(
convert_integer_literal, convert_integer_literal,
@ -131,7 +131,7 @@ mod tests {
#[test] #[test]
fn convert_hexadecimal_integer() { fn convert_hexadecimal_integer() {
let before = "const _: i32 = 0xFF<|>;"; let before = "const _: i32 = 0xFF$0;";
check_assist_by_label( check_assist_by_label(
convert_integer_literal, convert_integer_literal,
@ -157,7 +157,7 @@ mod tests {
#[test] #[test]
fn convert_binary_integer() { fn convert_binary_integer() {
let before = "const _: i32 = 0b11111111<|>;"; let before = "const _: i32 = 0b11111111$0;";
check_assist_by_label( check_assist_by_label(
convert_integer_literal, convert_integer_literal,
@ -183,7 +183,7 @@ mod tests {
#[test] #[test]
fn convert_octal_integer() { fn convert_octal_integer() {
let before = "const _: i32 = 0o377<|>;"; let before = "const _: i32 = 0o377$0;";
check_assist_by_label( check_assist_by_label(
convert_integer_literal, convert_integer_literal,
@ -209,7 +209,7 @@ mod tests {
#[test] #[test]
fn convert_integer_with_underscores() { fn convert_integer_with_underscores() {
let before = "const _: i32 = 1_00_0<|>;"; let before = "const _: i32 = 1_00_0$0;";
check_assist_by_label( check_assist_by_label(
convert_integer_literal, convert_integer_literal,
@ -235,7 +235,7 @@ mod tests {
#[test] #[test]
fn convert_integer_with_suffix() { fn convert_integer_with_suffix() {
let before = "const _: i32 = 1000i32<|>;"; let before = "const _: i32 = 1000i32$0;";
check_assist_by_label( check_assist_by_label(
convert_integer_literal, convert_integer_literal,
@ -262,7 +262,7 @@ mod tests {
#[test] #[test]
fn convert_overflowing_literal() { fn convert_overflowing_literal() {
let before = "const _: i32 = let before = "const _: i32 =
111111111111111111111111111111111111111111111111111111111111111111111111<|>;"; 111111111111111111111111111111111111111111111111111111111111111111111111$0;";
check_assist_not_applicable(convert_integer_literal, before); check_assist_not_applicable(convert_integer_literal, before);
} }
} }

View file

@ -24,7 +24,7 @@ use crate::{
// //
// ``` // ```
// fn main() { // fn main() {
// <|>if cond { // $0if cond {
// foo(); // foo();
// bar(); // bar();
// } // }
@ -200,7 +200,7 @@ mod tests {
r#" r#"
fn main() { fn main() {
bar(); bar();
if<|> true { if$0 true {
foo(); foo();
//comment //comment
@ -230,7 +230,7 @@ mod tests {
r#" r#"
fn main(n: Option<String>) { fn main(n: Option<String>) {
bar(); bar();
if<|> let Some(n) = n { if$0 let Some(n) = n {
foo(n); foo(n);
//comment //comment
@ -260,7 +260,7 @@ mod tests {
convert_to_guarded_return, convert_to_guarded_return,
r#" r#"
fn main() { fn main() {
if<|> let Ok(x) = Err(92) { if$0 let Ok(x) = Err(92) {
foo(x); foo(x);
} }
} }
@ -284,7 +284,7 @@ mod tests {
r#" r#"
fn main(n: Option<String>) { fn main(n: Option<String>) {
bar(); bar();
if<|> let Ok(n) = n { if$0 let Ok(n) = n {
foo(n); foo(n);
//comment //comment
@ -315,7 +315,7 @@ mod tests {
r#" r#"
fn main() { fn main() {
while true { while true {
if<|> true { if$0 true {
foo(); foo();
bar(); bar();
} }
@ -343,7 +343,7 @@ mod tests {
r#" r#"
fn main() { fn main() {
while true { while true {
if<|> let Some(n) = n { if$0 let Some(n) = n {
foo(n); foo(n);
bar(); bar();
} }
@ -372,7 +372,7 @@ mod tests {
r#" r#"
fn main() { fn main() {
loop { loop {
if<|> true { if$0 true {
foo(); foo();
bar(); bar();
} }
@ -400,7 +400,7 @@ mod tests {
r#" r#"
fn main() { fn main() {
loop { loop {
if<|> let Some(n) = n { if$0 let Some(n) = n {
foo(n); foo(n);
bar(); bar();
} }
@ -428,7 +428,7 @@ mod tests {
convert_to_guarded_return, convert_to_guarded_return,
r#" r#"
fn main() { fn main() {
if<|> true { if$0 true {
return; return;
} }
} }
@ -443,7 +443,7 @@ mod tests {
r#" r#"
fn main() { fn main() {
loop { loop {
if<|> true { if$0 true {
continue; continue;
} }
} }
@ -458,7 +458,7 @@ mod tests {
convert_to_guarded_return, convert_to_guarded_return,
r#" r#"
fn main() { fn main() {
if<|> true { if$0 true {
return return
} }
} }
@ -472,7 +472,7 @@ mod tests {
convert_to_guarded_return, convert_to_guarded_return,
r#" r#"
fn main() { fn main() {
if<|> true { if$0 true {
foo(); foo();
} else { } else {
bar() bar()
@ -488,7 +488,7 @@ mod tests {
convert_to_guarded_return, convert_to_guarded_return,
r#" r#"
fn main() { fn main() {
if<|> true { if$0 true {
foo(); foo();
} }
bar(); bar();
@ -504,7 +504,7 @@ mod tests {
r#" r#"
fn main() { fn main() {
if false { if false {
if<|> true { if$0 true {
foo(); foo();
} }
} }

View file

@ -25,7 +25,7 @@ use crate::{
// pub struct Baz; // pub struct Baz;
// } // }
// //
// use foo::*<|>; // use foo::*$0;
// //
// fn qux(bar: Bar, baz: Baz) {} // fn qux(bar: Bar, baz: Baz) {}
// ``` // ```
@ -201,7 +201,7 @@ fn is_mod_visible_from(ctx: &AssistContext, module: Module, from: Module) -> boo
// } // }
// //
// ↓ --------------- // ↓ ---------------
// use foo::*<|>; // use foo::*$0;
// use baz::Baz; // use baz::Baz;
// ↑ --------------- // ↑ ---------------
fn find_imported_defs(ctx: &AssistContext, star: SyntaxToken) -> Option<Vec<Def>> { fn find_imported_defs(ctx: &AssistContext, star: SyntaxToken) -> Option<Vec<Def>> {
@ -303,7 +303,7 @@ mod foo {
pub fn f() {} pub fn f() {}
} }
use foo::*<|>; use foo::*$0;
fn qux(bar: Bar, baz: Baz) { fn qux(bar: Bar, baz: Baz) {
f(); f();
@ -340,7 +340,7 @@ mod foo {
pub fn f() {} pub fn f() {}
} }
use foo::{*<|>, f}; use foo::{*$0, f};
fn qux(bar: Bar, baz: Baz) { fn qux(bar: Bar, baz: Baz) {
f(); f();
@ -378,7 +378,7 @@ mod foo {
} }
use foo::Bar; use foo::Bar;
use foo::{*<|>, f}; use foo::{*$0, f};
fn qux(bar: Bar, baz: Baz) { fn qux(bar: Bar, baz: Baz) {
f(); f();
@ -422,7 +422,7 @@ mod foo {
} }
} }
use foo::{bar::{*<|>, f}, baz::*}; use foo::{bar::{*$0, f}, baz::*};
fn qux(bar: Bar, baz: Baz) { fn qux(bar: Bar, baz: Baz) {
f(); f();
@ -470,7 +470,7 @@ mod foo {
} }
} }
use foo::{bar::{Bar, Baz, f}, baz::*<|>}; use foo::{bar::{Bar, Baz, f}, baz::*$0};
fn qux(bar: Bar, baz: Baz) { fn qux(bar: Bar, baz: Baz) {
f(); f();
@ -529,7 +529,7 @@ mod foo {
use foo::{ use foo::{
bar::{*, f}, bar::{*, f},
baz::{g, qux::*<|>} baz::{g, qux::*$0}
}; };
fn qux(bar: Bar, baz: Baz) { fn qux(bar: Bar, baz: Baz) {
@ -605,7 +605,7 @@ mod foo {
use foo::{ use foo::{
bar::{*, f}, bar::{*, f},
baz::{g, qux::{h, q::*<|>}} baz::{g, qux::{h, q::*$0}}
}; };
fn qux(bar: Bar, baz: Baz) { fn qux(bar: Bar, baz: Baz) {
@ -681,7 +681,7 @@ mod foo {
use foo::{ use foo::{
bar::{*, f}, bar::{*, f},
baz::{g, qux::{q::j, *<|>}} baz::{g, qux::{q::j, *$0}}
}; };
fn qux(bar: Bar, baz: Baz) { fn qux(bar: Bar, baz: Baz) {
@ -747,7 +747,7 @@ fn qux(bar: Bar, baz: Baz) {
// pub fn baz() {} // pub fn baz() {}
// //- /main.rs crate:main deps:foo // //- /main.rs crate:main deps:foo
// use foo::*<|>; // use foo::*$0;
// fn main() { // fn main() {
// bar!(); // bar!();
@ -777,7 +777,7 @@ pub trait Tr {
impl Tr for () {} impl Tr for () {}
//- /main.rs crate:main deps:foo //- /main.rs crate:main deps:foo
use foo::*<|>; use foo::*$0;
fn main() { fn main() {
().method(); ().method();
@ -807,7 +807,7 @@ pub trait Tr2 {
impl Tr2 for () {} impl Tr2 for () {}
//- /main.rs crate:main deps:foo //- /main.rs crate:main deps:foo
use foo::*<|>; use foo::*$0;
fn main() { fn main() {
().method(); ().method();
@ -834,7 +834,7 @@ mod foo {
} }
} }
use foo::bar::*<|>; use foo::bar::*$0;
fn baz(bar: Bar) {} fn baz(bar: Bar) {}
", ",
@ -851,7 +851,7 @@ mod foo {
} }
} }
use foo::bar::baz::*<|>; use foo::bar::baz::*$0;
fn qux(baz: Baz) {} fn qux(baz: Baz) {}
", ",
@ -869,7 +869,7 @@ fn qux(baz: Baz) {}
pub struct Qux; pub struct Qux;
} }
use foo::Bar<|>; use foo::Bar$0;
fn qux(bar: Bar, baz: Baz) {} fn qux(bar: Bar, baz: Baz) {}
", ",
@ -885,7 +885,7 @@ mod foo {
pub struct Bar; pub struct Bar;
} }
use foo::{*<|>}; use foo::{*$0};
struct Baz { struct Baz {
bar: Bar bar: Bar

View file

@ -21,7 +21,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// Extracts a struct from enum variant. // Extracts a struct from enum variant.
// //
// ``` // ```
// enum A { <|>One(u32, u32) } // enum A { $0One(u32, u32) }
// ``` // ```
// -> // ->
// ``` // ```
@ -251,7 +251,7 @@ mod tests {
fn test_extract_struct_several_fields_tuple() { fn test_extract_struct_several_fields_tuple() {
check_assist( check_assist(
extract_struct_from_enum_variant, extract_struct_from_enum_variant,
"enum A { <|>One(u32, u32) }", "enum A { $0One(u32, u32) }",
r#"struct One(pub u32, pub u32); r#"struct One(pub u32, pub u32);
enum A { One(One) }"#, enum A { One(One) }"#,
@ -262,7 +262,7 @@ enum A { One(One) }"#,
fn test_extract_struct_several_fields_named() { fn test_extract_struct_several_fields_named() {
check_assist( check_assist(
extract_struct_from_enum_variant, extract_struct_from_enum_variant,
"enum A { <|>One { foo: u32, bar: u32 } }", "enum A { $0One { foo: u32, bar: u32 } }",
r#"struct One{ pub foo: u32, pub bar: u32 } r#"struct One{ pub foo: u32, pub bar: u32 }
enum A { One(One) }"#, enum A { One(One) }"#,
@ -273,7 +273,7 @@ enum A { One(One) }"#,
fn test_extract_struct_one_field_named() { fn test_extract_struct_one_field_named() {
check_assist( check_assist(
extract_struct_from_enum_variant, extract_struct_from_enum_variant,
"enum A { <|>One { foo: u32 } }", "enum A { $0One { foo: u32 } }",
r#"struct One{ pub foo: u32 } r#"struct One{ pub foo: u32 }
enum A { One(One) }"#, enum A { One(One) }"#,
@ -285,7 +285,7 @@ enum A { One(One) }"#,
check_assist( check_assist(
extract_struct_from_enum_variant, extract_struct_from_enum_variant,
r#"const One: () = (); r#"const One: () = ();
enum A { <|>One(u32, u32) }"#, enum A { $0One(u32, u32) }"#,
r#"const One: () = (); r#"const One: () = ();
struct One(pub u32, pub u32); struct One(pub u32, pub u32);
@ -297,7 +297,7 @@ enum A { One(One) }"#,
fn test_extract_struct_pub_visibility() { fn test_extract_struct_pub_visibility() {
check_assist( check_assist(
extract_struct_from_enum_variant, extract_struct_from_enum_variant,
"pub enum A { <|>One(u32, u32) }", "pub enum A { $0One(u32, u32) }",
r#"pub struct One(pub u32, pub u32); r#"pub struct One(pub u32, pub u32);
pub enum A { One(One) }"#, pub enum A { One(One) }"#,
@ -319,7 +319,7 @@ pub enum A { One(One) }"#,
} }
pub enum MyEnum { pub enum MyEnum {
<|>MyField(u8, u8), $0MyField(u8, u8),
} }
} }
} }
@ -361,7 +361,7 @@ fn another_fn() {
extract_struct_from_enum_variant, extract_struct_from_enum_variant,
r#" r#"
enum E { enum E {
<|>V { i: i32, j: i32 } $0V { i: i32, j: i32 }
} }
fn f() { fn f() {
@ -389,7 +389,7 @@ fn f() {
r#" r#"
//- /main.rs //- /main.rs
enum E { enum E {
<|>V(i32, i32) $0V(i32, i32)
} }
mod foo; mod foo;
@ -424,7 +424,7 @@ fn f() {
r#" r#"
//- /main.rs //- /main.rs
enum E { enum E {
<|>V { i: i32, j: i32 } $0V { i: i32, j: i32 }
} }
mod foo; mod foo;
@ -457,7 +457,7 @@ fn f() {
check_assist( check_assist(
extract_struct_from_enum_variant, extract_struct_from_enum_variant,
r#" r#"
enum A { <|>One { a: u32, b: u32 } } enum A { $0One { a: u32, b: u32 } }
struct B(A); struct B(A);
@ -487,29 +487,29 @@ fn foo() {
#[test] #[test]
fn test_extract_enum_not_applicable_for_element_with_no_fields() { fn test_extract_enum_not_applicable_for_element_with_no_fields() {
check_not_applicable("enum A { <|>One }"); check_not_applicable("enum A { $0One }");
} }
#[test] #[test]
fn test_extract_enum_not_applicable_if_struct_exists() { fn test_extract_enum_not_applicable_if_struct_exists() {
check_not_applicable( check_not_applicable(
r#"struct One; r#"struct One;
enum A { <|>One(u8, u32) }"#, enum A { $0One(u8, u32) }"#,
); );
} }
#[test] #[test]
fn test_extract_not_applicable_one_field() { fn test_extract_not_applicable_one_field() {
check_not_applicable(r"enum A { <|>One(u32) }"); check_not_applicable(r"enum A { $0One(u32) }");
} }
#[test] #[test]
fn test_extract_not_applicable_no_field_tuple() { fn test_extract_not_applicable_no_field_tuple() {
check_not_applicable(r"enum A { <|>None() }"); check_not_applicable(r"enum A { $0None() }");
} }
#[test] #[test]
fn test_extract_not_applicable_no_field_named() { fn test_extract_not_applicable_no_field_named() {
check_not_applicable(r"enum A { <|>None {} }"); check_not_applicable(r"enum A { $0None {} }");
} }
} }

View file

@ -16,7 +16,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// //
// ``` // ```
// fn main() { // fn main() {
// <|>(1 + 2)<|> * 4; // $0(1 + 2)$0 * 4;
// } // }
// ``` // ```
// -> // ->
@ -187,7 +187,7 @@ mod tests {
extract_variable, extract_variable,
r#" r#"
fn foo() { fn foo() {
foo(<|>1 + 1<|>); foo($01 + 1$0);
}"#, }"#,
r#" r#"
fn foo() { fn foo() {
@ -200,7 +200,7 @@ fn foo() {
#[test] #[test]
fn extract_var_in_comment_is_not_applicable() { fn extract_var_in_comment_is_not_applicable() {
mark::check!(extract_var_in_comment_is_not_applicable); mark::check!(extract_var_in_comment_is_not_applicable);
check_assist_not_applicable(extract_variable, "fn main() { 1 + /* <|>comment<|> */ 1; }"); check_assist_not_applicable(extract_variable, "fn main() { 1 + /* $0comment$0 */ 1; }");
} }
#[test] #[test]
@ -210,7 +210,7 @@ fn foo() {
extract_variable, extract_variable,
r#" r#"
fn foo() { fn foo() {
<|>1 + 1<|>; $01 + 1$0;
}"#, }"#,
r#" r#"
fn foo() { fn foo() {
@ -221,7 +221,7 @@ fn foo() {
extract_variable, extract_variable,
" "
fn foo() { fn foo() {
<|>{ let x = 0; x }<|> $0{ let x = 0; x }$0
something_else(); something_else();
}", }",
" "
@ -238,7 +238,7 @@ fn foo() {
extract_variable, extract_variable,
" "
fn foo() { fn foo() {
<|>1<|> + 1; $01$0 + 1;
}", }",
" "
fn foo() { fn foo() {
@ -255,7 +255,7 @@ fn foo() {
extract_variable, extract_variable,
r#" r#"
fn foo() { fn foo() {
bar(<|>1 + 1<|>) bar($01 + 1$0)
} }
"#, "#,
r#" r#"
@ -269,7 +269,7 @@ fn foo() {
extract_variable, extract_variable,
r#" r#"
fn foo() { fn foo() {
<|>bar(1 + 1)<|> $0bar(1 + 1)$0
} }
"#, "#,
r#" r#"
@ -289,7 +289,7 @@ fn foo() {
fn main() { fn main() {
let x = true; let x = true;
let tuple = match x { let tuple = match x {
true => (<|>2 + 2<|>, true) true => ($02 + 2$0, true)
_ => (0, false) _ => (0, false)
}; };
} }
@ -316,7 +316,7 @@ fn main() {
let tuple = match x { let tuple = match x {
true => { true => {
let y = 1; let y = 1;
(<|>2 + y<|>, true) ($02 + y$0, true)
} }
_ => (0, false) _ => (0, false)
}; };
@ -344,7 +344,7 @@ fn main() {
extract_variable, extract_variable,
" "
fn main() { fn main() {
let lambda = |x: u32| <|>x * 2<|>; let lambda = |x: u32| $0x * 2$0;
} }
", ",
" "
@ -361,7 +361,7 @@ fn main() {
extract_variable, extract_variable,
" "
fn main() { fn main() {
let lambda = |x: u32| { <|>x * 2<|> }; let lambda = |x: u32| { $0x * 2$0 };
} }
", ",
" "
@ -378,7 +378,7 @@ fn main() {
extract_variable, extract_variable,
" "
fn main() { fn main() {
let o = <|>Some(true)<|>; let o = $0Some(true)$0;
} }
", ",
" "
@ -396,7 +396,7 @@ fn main() {
extract_variable, extract_variable,
" "
fn main() { fn main() {
let v = <|>bar.foo()<|>; let v = $0bar.foo()$0;
} }
", ",
" "
@ -414,7 +414,7 @@ fn main() {
extract_variable, extract_variable,
" "
fn foo() -> u32 { fn foo() -> u32 {
<|>return 2 + 2<|>; $0return 2 + 2$0;
} }
", ",
" "
@ -434,7 +434,7 @@ fn foo() -> u32 {
fn foo() -> u32 { fn foo() -> u32 {
<|>return 2 + 2<|>; $0return 2 + 2$0;
} }
", ",
" "
@ -452,7 +452,7 @@ fn foo() -> u32 {
" "
fn foo() -> u32 { fn foo() -> u32 {
<|>return 2 + 2<|>; $0return 2 + 2$0;
} }
", ",
" "
@ -473,7 +473,7 @@ fn foo() -> u32 {
// bar // bar
<|>return 2 + 2<|>; $0return 2 + 2$0;
} }
", ",
" "
@ -497,7 +497,7 @@ fn foo() -> u32 {
" "
fn main() { fn main() {
let result = loop { let result = loop {
<|>break 2 + 2<|>; $0break 2 + 2$0;
}; };
} }
", ",
@ -518,7 +518,7 @@ fn main() {
extract_variable, extract_variable,
" "
fn main() { fn main() {
let v = <|>0f32 as u32<|>; let v = $00f32 as u32$0;
} }
", ",
" "
@ -540,7 +540,7 @@ struct S {
} }
fn main() { fn main() {
S { foo: <|>1 + 1<|> } S { foo: $01 + 1$0 }
} }
"#, "#,
r#" r#"
@ -558,18 +558,18 @@ fn main() {
#[test] #[test]
fn test_extract_var_for_return_not_applicable() { fn test_extract_var_for_return_not_applicable() {
check_assist_not_applicable(extract_variable, "fn foo() { <|>return<|>; } "); check_assist_not_applicable(extract_variable, "fn foo() { $0return$0; } ");
} }
#[test] #[test]
fn test_extract_var_for_break_not_applicable() { fn test_extract_var_for_break_not_applicable() {
check_assist_not_applicable(extract_variable, "fn main() { loop { <|>break<|>; }; }"); check_assist_not_applicable(extract_variable, "fn main() { loop { $0break$0; }; }");
} }
// FIXME: This is not quite correct, but good enough(tm) for the sorting heuristic // FIXME: This is not quite correct, but good enough(tm) for the sorting heuristic
#[test] #[test]
fn extract_var_target() { fn extract_var_target() {
check_assist_target(extract_variable, "fn foo() -> u32 { <|>return 2 + 2<|>; }", "2 + 2"); check_assist_target(extract_variable, "fn foo() -> u32 { $0return 2 + 2$0; }", "2 + 2");
check_assist_target( check_assist_target(
extract_variable, extract_variable,
@ -577,7 +577,7 @@ fn main() {
fn main() { fn main() {
let x = true; let x = true;
let tuple = match x { let tuple = match x {
true => (<|>2 + 2<|>, true) true => ($02 + 2$0, true)
_ => (0, false) _ => (0, false)
}; };
} }

View file

@ -21,7 +21,7 @@ use crate::{
// //
// fn handle(action: Action) { // fn handle(action: Action) {
// match action { // match action {
// <|> // $0
// } // }
// } // }
// ``` // ```
@ -231,7 +231,7 @@ mod tests {
Cs(i32, Option<i32>), Cs(i32, Option<i32>),
} }
fn main() { fn main() {
match A::As<|> { match A::As$0 {
A::As, A::As,
A::Bs{x,y:Some(_)} => {} A::Bs{x,y:Some(_)} => {}
A::Cs(_, Some(_)) => {} A::Cs(_, Some(_)) => {}
@ -249,7 +249,7 @@ mod tests {
fill_match_arms, fill_match_arms,
r#" r#"
fn main() { fn main() {
match (0, false)<|> { match (0, false)$0 {
} }
} }
"#, "#,
@ -267,7 +267,7 @@ mod tests {
Cs(i32, Option<i32>), Cs(i32, Option<i32>),
} }
fn main() { fn main() {
match A::As<|> { match A::As$0 {
A::Bs { x, y: Some(_) } => {} A::Bs { x, y: Some(_) } => {}
A::Cs(_, Some(_)) => {} A::Cs(_, Some(_)) => {}
} }
@ -297,7 +297,7 @@ mod tests {
r#" r#"
enum A { As, Bs, Cs(Option<i32>) } enum A { As, Bs, Cs(Option<i32>) }
fn main() { fn main() {
match A::As<|> { match A::As$0 {
A::Cs(_) | A::Bs => {} A::Cs(_) | A::Bs => {}
} }
} }
@ -322,7 +322,7 @@ fn main() {
enum A { As, Bs, Cs, Ds(String), Es(B) } enum A { As, Bs, Cs, Ds(String), Es(B) }
enum B { Xs, Ys } enum B { Xs, Ys }
fn main() { fn main() {
match A::As<|> { match A::As$0 {
A::Bs if 0 < 1 => {} A::Bs if 0 < 1 => {}
A::Ds(_value) => { let x = 1; } A::Ds(_value) => { let x = 1; }
A::Es(B::Xs) => (), A::Es(B::Xs) => (),
@ -352,7 +352,7 @@ fn main() {
r#" r#"
enum A { As, Bs, Cs(Option<i32>) } enum A { As, Bs, Cs(Option<i32>) }
fn main() { fn main() {
match A::As<|> { match A::As$0 {
A::As(_) => {} A::As(_) => {}
a @ A::Bs(_) => {} a @ A::Bs(_) => {}
} }
@ -380,7 +380,7 @@ enum A { As, Bs, Cs(String), Ds(String, String), Es { x: usize, y: usize } }
fn main() { fn main() {
let a = A::As; let a = A::As;
match a<|> {} match a$0 {}
} }
"#, "#,
r#" r#"
@ -411,7 +411,7 @@ fn main() {
fn main() { fn main() {
let a = A::One; let a = A::One;
let b = B::One; let b = B::One;
match (a<|>, b) {} match (a$0, b) {}
} }
"#, "#,
r#" r#"
@ -443,7 +443,7 @@ fn main() {
fn main() { fn main() {
let a = A::One; let a = A::One;
let b = B::One; let b = B::One;
match (&a<|>, &b) {} match (&a$0, &b) {}
} }
"#, "#,
r#" r#"
@ -475,7 +475,7 @@ fn main() {
fn main() { fn main() {
let a = A::One; let a = A::One;
let b = B::One; let b = B::One;
match (a<|>, b) { match (a$0, b) {
(A::Two, B::One) => {} (A::Two, B::One) => {}
} }
} }
@ -494,7 +494,7 @@ fn main() {
fn main() { fn main() {
let a = A::One; let a = A::One;
let b = B::One; let b = B::One;
match (a<|>, b) { match (a$0, b) {
(A::Two, B::One) => {} (A::Two, B::One) => {}
(A::One, B::One) => {} (A::One, B::One) => {}
(A::One, B::Two) => {} (A::One, B::Two) => {}
@ -517,7 +517,7 @@ fn main() {
fn main() { fn main() {
let a = A::One; let a = A::One;
match (a<|>, ) { match (a$0, ) {
} }
} }
"#, "#,
@ -532,7 +532,7 @@ fn main() {
enum A { As } enum A { As }
fn foo(a: &A) { fn foo(a: &A) {
match a<|> { match a$0 {
} }
} }
"#, "#,
@ -555,7 +555,7 @@ fn main() {
} }
fn foo(a: &mut A) { fn foo(a: &mut A) {
match a<|> { match a$0 {
} }
} }
"#, "#,
@ -581,7 +581,7 @@ fn main() {
enum E { X, Y } enum E { X, Y }
fn main() { fn main() {
match E::X<|> {} match E::X$0 {}
} }
"#, "#,
"match E::X {}", "match E::X {}",
@ -597,7 +597,7 @@ fn main() {
fn main() { fn main() {
match E::X { match E::X {
<|>_ => {} $0_ => {}
} }
} }
"#, "#,
@ -624,7 +624,7 @@ fn main() {
fn main() { fn main() {
match X { match X {
<|> $0
} }
} }
"#, "#,
@ -650,7 +650,7 @@ fn main() {
enum A { One, Two } enum A { One, Two }
fn foo(a: A) { fn foo(a: A) {
match a { match a {
// foo bar baz<|> // foo bar baz$0
A::One => {} A::One => {}
// This is where the rest should be // This is where the rest should be
} }
@ -678,7 +678,7 @@ fn main() {
enum A { One, Two } enum A { One, Two }
fn foo(a: A) { fn foo(a: A) {
match a { match a {
// foo bar baz<|> // foo bar baz$0
} }
} }
"#, "#,
@ -702,7 +702,7 @@ fn main() {
r#" r#"
enum A { One, Two, } enum A { One, Two, }
fn foo(a: A) { fn foo(a: A) {
match a<|> { match a$0 {
_ => (), _ => (),
} }
} }
@ -724,7 +724,7 @@ fn main() {
mark::check!(option_order); mark::check!(option_order);
let before = r#" let before = r#"
fn foo(opt: Option<i32>) { fn foo(opt: Option<i32>) {
match opt<|> { match opt$0 {
} }
} }
"#; "#;

View file

@ -18,7 +18,7 @@ use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, Assists};
// fn frobnicate() {} // fn frobnicate() {}
// } // }
// fn main() { // fn main() {
// m::frobnicate<|>() {} // m::frobnicate$0() {}
// } // }
// ``` // ```
// -> // ->
@ -218,14 +218,14 @@ mod tests {
check_assist( check_assist(
fix_visibility, fix_visibility,
r"mod foo { fn foo() {} } r"mod foo { fn foo() {} }
fn main() { foo::foo<|>() } ", fn main() { foo::foo$0() } ",
r"mod foo { $0pub(crate) fn foo() {} } r"mod foo { $0pub(crate) fn foo() {} }
fn main() { foo::foo() } ", fn main() { foo::foo() } ",
); );
check_assist_not_applicable( check_assist_not_applicable(
fix_visibility, fix_visibility,
r"mod foo { pub fn foo() {} } r"mod foo { pub fn foo() {} }
fn main() { foo::foo<|>() } ", fn main() { foo::foo$0() } ",
) )
} }
@ -234,38 +234,38 @@ mod tests {
check_assist( check_assist(
fix_visibility, fix_visibility,
r"mod foo { struct Foo; } r"mod foo { struct Foo; }
fn main() { foo::Foo<|> } ", fn main() { foo::Foo$0 } ",
r"mod foo { $0pub(crate) struct Foo; } r"mod foo { $0pub(crate) struct Foo; }
fn main() { foo::Foo } ", fn main() { foo::Foo } ",
); );
check_assist_not_applicable( check_assist_not_applicable(
fix_visibility, fix_visibility,
r"mod foo { pub struct Foo; } r"mod foo { pub struct Foo; }
fn main() { foo::Foo<|> } ", fn main() { foo::Foo$0 } ",
); );
check_assist( check_assist(
fix_visibility, fix_visibility,
r"mod foo { enum Foo; } r"mod foo { enum Foo; }
fn main() { foo::Foo<|> } ", fn main() { foo::Foo$0 } ",
r"mod foo { $0pub(crate) enum Foo; } r"mod foo { $0pub(crate) enum Foo; }
fn main() { foo::Foo } ", fn main() { foo::Foo } ",
); );
check_assist_not_applicable( check_assist_not_applicable(
fix_visibility, fix_visibility,
r"mod foo { pub enum Foo; } r"mod foo { pub enum Foo; }
fn main() { foo::Foo<|> } ", fn main() { foo::Foo$0 } ",
); );
check_assist( check_assist(
fix_visibility, fix_visibility,
r"mod foo { union Foo; } r"mod foo { union Foo; }
fn main() { foo::Foo<|> } ", fn main() { foo::Foo$0 } ",
r"mod foo { $0pub(crate) union Foo; } r"mod foo { $0pub(crate) union Foo; }
fn main() { foo::Foo } ", fn main() { foo::Foo } ",
); );
check_assist_not_applicable( check_assist_not_applicable(
fix_visibility, fix_visibility,
r"mod foo { pub union Foo; } r"mod foo { pub union Foo; }
fn main() { foo::Foo<|> } ", fn main() { foo::Foo$0 } ",
); );
} }
@ -276,7 +276,7 @@ mod tests {
r" r"
//- /main.rs //- /main.rs
mod foo; mod foo;
fn main() { foo::Foo<|> } fn main() { foo::Foo$0 }
//- /foo.rs //- /foo.rs
struct Foo; struct Foo;
@ -291,7 +291,7 @@ struct Foo;
check_assist( check_assist(
fix_visibility, fix_visibility,
r"mod foo { pub struct Foo { bar: (), } } r"mod foo { pub struct Foo { bar: (), } }
fn main() { foo::Foo { <|>bar: () }; } ", fn main() { foo::Foo { $0bar: () }; } ",
r"mod foo { pub struct Foo { $0pub(crate) bar: (), } } r"mod foo { pub struct Foo { $0pub(crate) bar: (), } }
fn main() { foo::Foo { bar: () }; } ", fn main() { foo::Foo { bar: () }; } ",
); );
@ -300,7 +300,7 @@ struct Foo;
r" r"
//- /lib.rs //- /lib.rs
mod foo; mod foo;
fn main() { foo::Foo { <|>bar: () }; } fn main() { foo::Foo { $0bar: () }; }
//- /foo.rs //- /foo.rs
pub struct Foo { bar: () } pub struct Foo { bar: () }
", ",
@ -310,14 +310,14 @@ pub struct Foo { bar: () }
check_assist_not_applicable( check_assist_not_applicable(
fix_visibility, fix_visibility,
r"mod foo { pub struct Foo { pub bar: (), } } r"mod foo { pub struct Foo { pub bar: (), } }
fn main() { foo::Foo { <|>bar: () }; } ", fn main() { foo::Foo { $0bar: () }; } ",
); );
check_assist_not_applicable( check_assist_not_applicable(
fix_visibility, fix_visibility,
r" r"
//- /lib.rs //- /lib.rs
mod foo; mod foo;
fn main() { foo::Foo { <|>bar: () }; } fn main() { foo::Foo { $0bar: () }; }
//- /foo.rs //- /foo.rs
pub struct Foo { pub bar: () } pub struct Foo { pub bar: () }
", ",
@ -331,14 +331,14 @@ pub struct Foo { pub bar: () }
check_assist_not_applicable( check_assist_not_applicable(
fix_visibility, fix_visibility,
r"mod foo { pub enum Foo { Bar { bar: () } } } r"mod foo { pub enum Foo { Bar { bar: () } } }
fn main() { foo::Foo::Bar { <|>bar: () }; } ", fn main() { foo::Foo::Bar { $0bar: () }; } ",
); );
check_assist_not_applicable( check_assist_not_applicable(
fix_visibility, fix_visibility,
r" r"
//- /lib.rs //- /lib.rs
mod foo; mod foo;
fn main() { foo::Foo::Bar { <|>bar: () }; } fn main() { foo::Foo::Bar { $0bar: () }; }
//- /foo.rs //- /foo.rs
pub enum Foo { Bar { bar: () } } pub enum Foo { Bar { bar: () } }
", ",
@ -346,14 +346,14 @@ pub enum Foo { Bar { bar: () } }
check_assist_not_applicable( check_assist_not_applicable(
fix_visibility, fix_visibility,
r"mod foo { pub struct Foo { pub bar: (), } } r"mod foo { pub struct Foo { pub bar: (), } }
fn main() { foo::Foo { <|>bar: () }; } ", fn main() { foo::Foo { $0bar: () }; } ",
); );
check_assist_not_applicable( check_assist_not_applicable(
fix_visibility, fix_visibility,
r" r"
//- /lib.rs //- /lib.rs
mod foo; mod foo;
fn main() { foo::Foo { <|>bar: () }; } fn main() { foo::Foo { $0bar: () }; }
//- /foo.rs //- /foo.rs
pub struct Foo { pub bar: () } pub struct Foo { pub bar: () }
", ",
@ -367,7 +367,7 @@ pub struct Foo { pub bar: () }
check_assist( check_assist(
fix_visibility, fix_visibility,
r"mod foo { pub union Foo { bar: (), } } r"mod foo { pub union Foo { bar: (), } }
fn main() { foo::Foo { <|>bar: () }; } ", fn main() { foo::Foo { $0bar: () }; } ",
r"mod foo { pub union Foo { $0pub(crate) bar: (), } } r"mod foo { pub union Foo { $0pub(crate) bar: (), } }
fn main() { foo::Foo { bar: () }; } ", fn main() { foo::Foo { bar: () }; } ",
); );
@ -376,7 +376,7 @@ pub struct Foo { pub bar: () }
r" r"
//- /lib.rs //- /lib.rs
mod foo; mod foo;
fn main() { foo::Foo { <|>bar: () }; } fn main() { foo::Foo { $0bar: () }; }
//- /foo.rs //- /foo.rs
pub union Foo { bar: () } pub union Foo { bar: () }
", ",
@ -386,14 +386,14 @@ pub union Foo { bar: () }
check_assist_not_applicable( check_assist_not_applicable(
fix_visibility, fix_visibility,
r"mod foo { pub union Foo { pub bar: (), } } r"mod foo { pub union Foo { pub bar: (), } }
fn main() { foo::Foo { <|>bar: () }; } ", fn main() { foo::Foo { $0bar: () }; } ",
); );
check_assist_not_applicable( check_assist_not_applicable(
fix_visibility, fix_visibility,
r" r"
//- /lib.rs //- /lib.rs
mod foo; mod foo;
fn main() { foo::Foo { <|>bar: () }; } fn main() { foo::Foo { $0bar: () }; }
//- /foo.rs //- /foo.rs
pub union Foo { pub bar: () } pub union Foo { pub bar: () }
", ",
@ -405,14 +405,14 @@ pub union Foo { pub bar: () }
check_assist( check_assist(
fix_visibility, fix_visibility,
r"mod foo { const FOO: () = (); } r"mod foo { const FOO: () = (); }
fn main() { foo::FOO<|> } ", fn main() { foo::FOO$0 } ",
r"mod foo { $0pub(crate) const FOO: () = (); } r"mod foo { $0pub(crate) const FOO: () = (); }
fn main() { foo::FOO } ", fn main() { foo::FOO } ",
); );
check_assist_not_applicable( check_assist_not_applicable(
fix_visibility, fix_visibility,
r"mod foo { pub const FOO: () = (); } r"mod foo { pub const FOO: () = (); }
fn main() { foo::FOO<|> } ", fn main() { foo::FOO$0 } ",
); );
} }
@ -421,14 +421,14 @@ pub union Foo { pub bar: () }
check_assist( check_assist(
fix_visibility, fix_visibility,
r"mod foo { static FOO: () = (); } r"mod foo { static FOO: () = (); }
fn main() { foo::FOO<|> } ", fn main() { foo::FOO$0 } ",
r"mod foo { $0pub(crate) static FOO: () = (); } r"mod foo { $0pub(crate) static FOO: () = (); }
fn main() { foo::FOO } ", fn main() { foo::FOO } ",
); );
check_assist_not_applicable( check_assist_not_applicable(
fix_visibility, fix_visibility,
r"mod foo { pub static FOO: () = (); } r"mod foo { pub static FOO: () = (); }
fn main() { foo::FOO<|> } ", fn main() { foo::FOO$0 } ",
); );
} }
@ -437,14 +437,14 @@ pub union Foo { pub bar: () }
check_assist( check_assist(
fix_visibility, fix_visibility,
r"mod foo { trait Foo { fn foo(&self) {} } } r"mod foo { trait Foo { fn foo(&self) {} } }
fn main() { let x: &dyn foo::<|>Foo; } ", fn main() { let x: &dyn foo::$0Foo; } ",
r"mod foo { $0pub(crate) trait Foo { fn foo(&self) {} } } r"mod foo { $0pub(crate) trait Foo { fn foo(&self) {} } }
fn main() { let x: &dyn foo::Foo; } ", fn main() { let x: &dyn foo::Foo; } ",
); );
check_assist_not_applicable( check_assist_not_applicable(
fix_visibility, fix_visibility,
r"mod foo { pub trait Foo { fn foo(&self) {} } } r"mod foo { pub trait Foo { fn foo(&self) {} } }
fn main() { let x: &dyn foo::Foo<|>; } ", fn main() { let x: &dyn foo::Foo$0; } ",
); );
} }
@ -453,14 +453,14 @@ pub union Foo { pub bar: () }
check_assist( check_assist(
fix_visibility, fix_visibility,
r"mod foo { type Foo = (); } r"mod foo { type Foo = (); }
fn main() { let x: foo::Foo<|>; } ", fn main() { let x: foo::Foo$0; } ",
r"mod foo { $0pub(crate) type Foo = (); } r"mod foo { $0pub(crate) type Foo = (); }
fn main() { let x: foo::Foo; } ", fn main() { let x: foo::Foo; } ",
); );
check_assist_not_applicable( check_assist_not_applicable(
fix_visibility, fix_visibility,
r"mod foo { pub type Foo = (); } r"mod foo { pub type Foo = (); }
fn main() { let x: foo::Foo<|>; } ", fn main() { let x: foo::Foo$0; } ",
); );
} }
@ -469,7 +469,7 @@ pub union Foo { pub bar: () }
check_assist( check_assist(
fix_visibility, fix_visibility,
r"mod foo { mod bar { fn bar() {} } } r"mod foo { mod bar { fn bar() {} } }
fn main() { foo::bar<|>::bar(); } ", fn main() { foo::bar$0::bar(); } ",
r"mod foo { $0pub(crate) mod bar { fn bar() {} } } r"mod foo { $0pub(crate) mod bar { fn bar() {} } }
fn main() { foo::bar::bar(); } ", fn main() { foo::bar::bar(); } ",
); );
@ -479,7 +479,7 @@ pub union Foo { pub bar: () }
r" r"
//- /main.rs //- /main.rs
mod foo; mod foo;
fn main() { foo::bar<|>::baz(); } fn main() { foo::bar$0::baz(); }
//- /foo.rs //- /foo.rs
mod bar { mod bar {
@ -495,7 +495,7 @@ mod bar {
check_assist_not_applicable( check_assist_not_applicable(
fix_visibility, fix_visibility,
r"mod foo { pub mod bar { pub fn bar() {} } } r"mod foo { pub mod bar { pub fn bar() {} } }
fn main() { foo::bar<|>::bar(); } ", fn main() { foo::bar$0::bar(); } ",
); );
} }
@ -506,7 +506,7 @@ mod bar {
r" r"
//- /main.rs //- /main.rs
mod foo; mod foo;
fn main() { foo::bar<|>::baz(); } fn main() { foo::bar$0::baz(); }
//- /foo.rs //- /foo.rs
mod bar; mod bar;
@ -525,7 +525,7 @@ pub fn baz() {}
r" r"
//- /main.rs //- /main.rs
mod foo; mod foo;
fn main() { foo::bar<|>>::baz(); } fn main() { foo::bar$0>::baz(); }
//- /foo.rs //- /foo.rs
mod bar { mod bar {
@ -545,7 +545,7 @@ mod bar {
fix_visibility, fix_visibility,
r" r"
//- /main.rs crate:a deps:foo //- /main.rs crate:a deps:foo
foo::Bar<|> foo::Bar$0
//- /lib.rs crate:foo //- /lib.rs crate:foo
struct Bar; struct Bar;
", ",
@ -560,7 +560,7 @@ struct Bar;
fix_visibility, fix_visibility,
r" r"
//- /main.rs crate:a deps:foo //- /main.rs crate:a deps:foo
foo::Bar<|> foo::Bar$0
//- /lib.rs crate:foo //- /lib.rs crate:foo
pub(crate) struct Bar; pub(crate) struct Bar;
", ",
@ -572,7 +572,7 @@ pub(crate) struct Bar;
r" r"
//- /main.rs crate:a deps:foo //- /main.rs crate:a deps:foo
fn main() { fn main() {
foo::Foo { <|>bar: () }; foo::Foo { $0bar: () };
} }
//- /lib.rs crate:foo //- /lib.rs crate:foo
pub struct Foo { pub(crate) bar: () } pub struct Foo { pub(crate) bar: () }
@ -593,7 +593,7 @@ pub struct Foo { pub(crate) bar: () }
use bar::Baz; use bar::Baz;
mod bar { pub(super) struct Baz; } mod bar { pub(super) struct Baz; }
} }
foo::Baz<|> foo::Baz$0
", ",
r" r"
mod foo { mod foo {

View file

@ -8,7 +8,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// //
// ``` // ```
// fn main() { // fn main() {
// let _ = 90 +<|> 2; // let _ = 90 +$0 2;
// } // }
// ``` // ```
// -> // ->
@ -77,42 +77,34 @@ mod tests {
#[test] #[test]
fn flip_binexpr_target_is_the_op() { fn flip_binexpr_target_is_the_op() {
check_assist_target(flip_binexpr, "fn f() { let res = 1 ==<|> 2; }", "==") check_assist_target(flip_binexpr, "fn f() { let res = 1 ==$0 2; }", "==")
} }
#[test] #[test]
fn flip_binexpr_not_applicable_for_assignment() { fn flip_binexpr_not_applicable_for_assignment() {
check_assist_not_applicable(flip_binexpr, "fn f() { let mut _x = 1; _x +=<|> 2 }") check_assist_not_applicable(flip_binexpr, "fn f() { let mut _x = 1; _x +=$0 2 }")
} }
#[test] #[test]
fn flip_binexpr_works_for_eq() { fn flip_binexpr_works_for_eq() {
check_assist( check_assist(flip_binexpr, "fn f() { let res = 1 ==$0 2; }", "fn f() { let res = 2 == 1; }")
flip_binexpr,
"fn f() { let res = 1 ==<|> 2; }",
"fn f() { let res = 2 == 1; }",
)
} }
#[test] #[test]
fn flip_binexpr_works_for_gt() { fn flip_binexpr_works_for_gt() {
check_assist(flip_binexpr, "fn f() { let res = 1 ><|> 2; }", "fn f() { let res = 2 < 1; }") check_assist(flip_binexpr, "fn f() { let res = 1 >$0 2; }", "fn f() { let res = 2 < 1; }")
} }
#[test] #[test]
fn flip_binexpr_works_for_lteq() { fn flip_binexpr_works_for_lteq() {
check_assist( check_assist(flip_binexpr, "fn f() { let res = 1 <=$0 2; }", "fn f() { let res = 2 >= 1; }")
flip_binexpr,
"fn f() { let res = 1 <=<|> 2; }",
"fn f() { let res = 2 >= 1; }",
)
} }
#[test] #[test]
fn flip_binexpr_works_for_complex_expr() { fn flip_binexpr_works_for_complex_expr() {
check_assist( check_assist(
flip_binexpr, flip_binexpr,
"fn f() { let res = (1 + 1) ==<|> (2 + 2); }", "fn f() { let res = (1 + 1) ==$0 (2 + 2); }",
"fn f() { let res = (2 + 2) == (1 + 1); }", "fn f() { let res = (2 + 2) == (1 + 1); }",
) )
} }
@ -125,7 +117,7 @@ mod tests {
fn dyn_eq(&self, other: &dyn Diagnostic) -> bool { fn dyn_eq(&self, other: &dyn Diagnostic) -> bool {
match other.downcast_ref::<Self>() { match other.downcast_ref::<Self>() {
None => false, None => false,
Some(it) => it ==<|> self, Some(it) => it ==$0 self,
} }
} }
"#, "#,

View file

@ -8,7 +8,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// //
// ``` // ```
// fn main() { // fn main() {
// ((1, 2),<|> (3, 4)); // ((1, 2),$0 (3, 4));
// } // }
// ``` // ```
// -> // ->
@ -49,14 +49,14 @@ mod tests {
fn flip_comma_works_for_function_parameters() { fn flip_comma_works_for_function_parameters() {
check_assist( check_assist(
flip_comma, flip_comma,
"fn foo(x: i32,<|> y: Result<(), ()>) {}", "fn foo(x: i32,$0 y: Result<(), ()>) {}",
"fn foo(y: Result<(), ()>, x: i32) {}", "fn foo(y: Result<(), ()>, x: i32) {}",
) )
} }
#[test] #[test]
fn flip_comma_target() { fn flip_comma_target() {
check_assist_target(flip_comma, "fn foo(x: i32,<|> y: Result<(), ()>) {}", ",") check_assist_target(flip_comma, "fn foo(x: i32,$0 y: Result<(), ()>) {}", ",")
} }
#[test] #[test]
@ -68,7 +68,7 @@ mod tests {
check_assist_target( check_assist_target(
flip_comma, flip_comma,
"pub enum Test { \ "pub enum Test { \
A,<|> \ A,$0 \
}", }",
",", ",",
); );
@ -76,7 +76,7 @@ mod tests {
check_assist_target( check_assist_target(
flip_comma, flip_comma,
"pub struct Test { \ "pub struct Test { \
foo: usize,<|> \ foo: usize,$0 \
}", }",
",", ",",
); );

View file

@ -11,7 +11,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// Flips two trait bounds. // Flips two trait bounds.
// //
// ``` // ```
// fn foo<T: Clone +<|> Copy>() { } // fn foo<T: Clone +$0 Copy>() { }
// ``` // ```
// -> // ->
// ``` // ```
@ -52,19 +52,19 @@ mod tests {
#[test] #[test]
fn flip_trait_bound_assist_available() { fn flip_trait_bound_assist_available() {
check_assist_target(flip_trait_bound, "struct S<T> where T: A <|>+ B + C { }", "+") check_assist_target(flip_trait_bound, "struct S<T> where T: A $0+ B + C { }", "+")
} }
#[test] #[test]
fn flip_trait_bound_not_applicable_for_single_trait_bound() { fn flip_trait_bound_not_applicable_for_single_trait_bound() {
check_assist_not_applicable(flip_trait_bound, "struct S<T> where T: <|>A { }") check_assist_not_applicable(flip_trait_bound, "struct S<T> where T: $0A { }")
} }
#[test] #[test]
fn flip_trait_bound_works_for_struct() { fn flip_trait_bound_works_for_struct() {
check_assist( check_assist(
flip_trait_bound, flip_trait_bound,
"struct S<T> where T: A <|>+ B { }", "struct S<T> where T: A $0+ B { }",
"struct S<T> where T: B + A { }", "struct S<T> where T: B + A { }",
) )
} }
@ -73,21 +73,21 @@ mod tests {
fn flip_trait_bound_works_for_trait_impl() { fn flip_trait_bound_works_for_trait_impl() {
check_assist( check_assist(
flip_trait_bound, flip_trait_bound,
"impl X for S<T> where T: A +<|> B { }", "impl X for S<T> where T: A +$0 B { }",
"impl X for S<T> where T: B + A { }", "impl X for S<T> where T: B + A { }",
) )
} }
#[test] #[test]
fn flip_trait_bound_works_for_fn() { fn flip_trait_bound_works_for_fn() {
check_assist(flip_trait_bound, "fn f<T: A <|>+ B>(t: T) { }", "fn f<T: B + A>(t: T) { }") check_assist(flip_trait_bound, "fn f<T: A $0+ B>(t: T) { }", "fn f<T: B + A>(t: T) { }")
} }
#[test] #[test]
fn flip_trait_bound_works_for_fn_where_clause() { fn flip_trait_bound_works_for_fn_where_clause() {
check_assist( check_assist(
flip_trait_bound, flip_trait_bound,
"fn f<T>(t: T) where T: A +<|> B { }", "fn f<T>(t: T) where T: A +$0 B { }",
"fn f<T>(t: T) where T: B + A { }", "fn f<T>(t: T) where T: B + A { }",
) )
} }
@ -96,7 +96,7 @@ mod tests {
fn flip_trait_bound_works_for_lifetime() { fn flip_trait_bound_works_for_lifetime() {
check_assist( check_assist(
flip_trait_bound, flip_trait_bound,
"fn f<T>(t: T) where T: A <|>+ 'static { }", "fn f<T>(t: T) where T: A $0+ 'static { }",
"fn f<T>(t: T) where T: 'static + A { }", "fn f<T>(t: T) where T: 'static + A { }",
) )
} }
@ -105,7 +105,7 @@ mod tests {
fn flip_trait_bound_works_for_complex_bounds() { fn flip_trait_bound_works_for_complex_bounds() {
check_assist( check_assist(
flip_trait_bound, flip_trait_bound,
"struct S<T> where T: A<T> <|>+ b_mod::B<T> + C<T> { }", "struct S<T> where T: A<T> $0+ b_mod::B<T> + C<T> { }",
"struct S<T> where T: b_mod::B<T> + A<T> + C<T> { }", "struct S<T> where T: b_mod::B<T> + A<T> + C<T> { }",
) )
} }
@ -114,7 +114,7 @@ mod tests {
fn flip_trait_bound_works_for_long_bounds() { fn flip_trait_bound_works_for_long_bounds() {
check_assist( check_assist(
flip_trait_bound, flip_trait_bound,
"struct S<T> where T: A + B + C + D + E + F +<|> G + H + I + J { }", "struct S<T> where T: A + B + C + D + E + F +$0 G + H + I + J { }",
"struct S<T> where T: A + B + C + D + E + G + F + H + I + J { }", "struct S<T> where T: A + B + C + D + E + G + F + H + I + J { }",
) )
} }

View file

@ -12,7 +12,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// ``` // ```
// enum Version { // enum Version {
// Undefined, // Undefined,
// Minor<|>, // Minor$0,
// Major, // Major,
// } // }
// ``` // ```
@ -108,7 +108,7 @@ mod tests {
r#" r#"
enum Variant { enum Variant {
Undefined, Undefined,
Minor<|>, Minor$0,
Major, Major,
}"#, }"#,
r#"enum Variant { r#"enum Variant {
@ -132,7 +132,7 @@ impl Default for Variant {
r#" r#"
enum Variant { enum Variant {
Undefined, Undefined,
Minor<|>, Minor$0,
Major, Major,
} }
@ -151,7 +151,7 @@ impl Default for Variant {
r#" r#"
enum Variant { enum Variant {
Undefined, Undefined,
Minor(u32)<|>, Minor(u32)$0,
Major, Major,
}"#, }"#,
); );
@ -161,7 +161,7 @@ enum Variant {
fn test_generate_default_from_variant_with_one_variant() { fn test_generate_default_from_variant_with_one_variant() {
check_assist( check_assist(
generate_default_from_enum_variant, generate_default_from_enum_variant,
r#"enum Variant { Undefi<|>ned }"#, r#"enum Variant { Undefi$0ned }"#,
r#" r#"
enum Variant { Undefined } enum Variant { Undefined }

View file

@ -13,7 +13,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// ``` // ```
// struct Point { // struct Point {
// x: u32, // x: u32,
// y: u32,<|> // y: u32,$0
// } // }
// ``` // ```
// -> // ->
@ -76,12 +76,12 @@ mod tests {
fn add_derive_new() { fn add_derive_new() {
check_assist( check_assist(
generate_derive, generate_derive,
"struct Foo { a: i32, <|>}", "struct Foo { a: i32, $0}",
"#[derive($0)]\nstruct Foo { a: i32, }", "#[derive($0)]\nstruct Foo { a: i32, }",
); );
check_assist( check_assist(
generate_derive, generate_derive,
"struct Foo { <|> a: i32, }", "struct Foo { $0 a: i32, }",
"#[derive($0)]\nstruct Foo { a: i32, }", "#[derive($0)]\nstruct Foo { a: i32, }",
); );
} }
@ -90,7 +90,7 @@ mod tests {
fn add_derive_existing() { fn add_derive_existing() {
check_assist( check_assist(
generate_derive, generate_derive,
"#[derive(Clone)]\nstruct Foo { a: i32<|>, }", "#[derive(Clone)]\nstruct Foo { a: i32$0, }",
"#[derive(Clone$0)]\nstruct Foo { a: i32, }", "#[derive(Clone$0)]\nstruct Foo { a: i32, }",
); );
} }
@ -102,7 +102,7 @@ mod tests {
" "
/// `Foo` is a pretty important struct. /// `Foo` is a pretty important struct.
/// It does stuff. /// It does stuff.
struct Foo { a: i32<|>, } struct Foo { a: i32$0, }
", ",
" "
/// `Foo` is a pretty important struct. /// `Foo` is a pretty important struct.
@ -121,7 +121,7 @@ struct Foo { a: i32, }
struct SomeThingIrrelevant; struct SomeThingIrrelevant;
/// `Foo` is a pretty important struct. /// `Foo` is a pretty important struct.
/// It does stuff. /// It does stuff.
struct Foo { a: i32<|>, } struct Foo { a: i32$0, }
struct EvenMoreIrrelevant; struct EvenMoreIrrelevant;
", ",
"/// `Foo` is a pretty important struct. "/// `Foo` is a pretty important struct.

View file

@ -10,7 +10,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// Adds a From impl for an enum variant with one tuple field. // Adds a From impl for an enum variant with one tuple field.
// //
// ``` // ```
// enum A { <|>One(u32) } // enum A { $0One(u32) }
// ``` // ```
// -> // ->
// ``` // ```
@ -101,7 +101,7 @@ mod tests {
fn test_generate_from_impl_for_enum() { fn test_generate_from_impl_for_enum() {
check_assist( check_assist(
generate_from_impl_for_enum, generate_from_impl_for_enum,
"enum A { <|>One(u32) }", "enum A { $0One(u32) }",
r#"enum A { One(u32) } r#"enum A { One(u32) }
impl From<u32> for A { impl From<u32> for A {
@ -116,7 +116,7 @@ impl From<u32> for A {
fn test_generate_from_impl_for_enum_complicated_path() { fn test_generate_from_impl_for_enum_complicated_path() {
check_assist( check_assist(
generate_from_impl_for_enum, generate_from_impl_for_enum,
r#"enum A { <|>One(foo::bar::baz::Boo) }"#, r#"enum A { $0One(foo::bar::baz::Boo) }"#,
r#"enum A { One(foo::bar::baz::Boo) } r#"enum A { One(foo::bar::baz::Boo) }
impl From<foo::bar::baz::Boo> for A { impl From<foo::bar::baz::Boo> for A {
@ -135,17 +135,17 @@ impl From<foo::bar::baz::Boo> for A {
#[test] #[test]
fn test_add_from_impl_no_element() { fn test_add_from_impl_no_element() {
check_not_applicable("enum A { <|>One }"); check_not_applicable("enum A { $0One }");
} }
#[test] #[test]
fn test_add_from_impl_more_than_one_element_in_tuple() { fn test_add_from_impl_more_than_one_element_in_tuple() {
check_not_applicable("enum A { <|>One(u32, String) }"); check_not_applicable("enum A { $0One(u32, String) }");
} }
#[test] #[test]
fn test_add_from_impl_struct_variant() { fn test_add_from_impl_struct_variant() {
check_not_applicable("enum A { <|>One { x: u32 } }"); check_not_applicable("enum A { $0One { x: u32 } }");
} }
#[test] #[test]
@ -153,7 +153,7 @@ impl From<foo::bar::baz::Boo> for A {
mark::check!(test_add_from_impl_already_exists); mark::check!(test_add_from_impl_already_exists);
check_not_applicable( check_not_applicable(
r#" r#"
enum A { <|>One(u32), } enum A { $0One(u32), }
impl From<u32> for A { impl From<u32> for A {
fn from(v: u32) -> Self { fn from(v: u32) -> Self {
@ -168,7 +168,7 @@ impl From<u32> for A {
fn test_add_from_impl_different_variant_impl_exists() { fn test_add_from_impl_different_variant_impl_exists() {
check_assist( check_assist(
generate_from_impl_for_enum, generate_from_impl_for_enum,
r#"enum A { <|>One(u32), Two(String), } r#"enum A { $0One(u32), Two(String), }
impl From<String> for A { impl From<String> for A {
fn from(v: String) -> Self { fn from(v: String) -> Self {

View file

@ -23,7 +23,7 @@ use crate::{
// struct Baz; // struct Baz;
// fn baz() -> Baz { Baz } // fn baz() -> Baz { Baz }
// fn foo() { // fn foo() {
// bar<|>("", baz()); // bar$0("", baz());
// } // }
// //
// ``` // ```
@ -342,7 +342,7 @@ mod tests {
generate_function, generate_function,
r" r"
fn foo() { fn foo() {
bar<|>(); bar$0();
} }
", ",
r" r"
@ -366,7 +366,7 @@ fn bar() ${0:-> ()} {
r" r"
impl Foo { impl Foo {
fn foo() { fn foo() {
bar<|>(); bar$0();
} }
} }
", ",
@ -391,7 +391,7 @@ fn bar() ${0:-> ()} {
generate_function, generate_function,
r" r"
fn foo1() { fn foo1() {
bar<|>(); bar$0();
} }
fn foo2() {} fn foo2() {}
@ -417,7 +417,7 @@ fn foo2() {}
r" r"
mod baz { mod baz {
fn foo() { fn foo() {
bar<|>(); bar$0();
} }
} }
", ",
@ -443,7 +443,7 @@ mod baz {
struct Baz; struct Baz;
fn baz() -> Baz { todo!() } fn baz() -> Baz { todo!() }
fn foo() { fn foo() {
bar<|>(baz()); bar$0(baz());
} }
", ",
r" r"
@ -468,7 +468,7 @@ fn bar(baz: Baz) ${0:-> ()} {
struct Baz; struct Baz;
impl Baz { impl Baz {
fn foo(&self) -> Baz { fn foo(&self) -> Baz {
ba<|>r(self.baz()) ba$0r(self.baz())
} }
fn baz(&self) -> Baz { fn baz(&self) -> Baz {
Baz Baz
@ -499,7 +499,7 @@ fn bar(baz: Baz) ${0:-> ()} {
generate_function, generate_function,
r#" r#"
fn foo() { fn foo() {
<|>bar("bar") $0bar("bar")
} }
"#, "#,
r#" r#"
@ -520,7 +520,7 @@ fn bar(arg: &str) ${0:-> ()} {
generate_function, generate_function,
r#" r#"
fn foo() { fn foo() {
<|>bar('x') $0bar('x')
} }
"#, "#,
r#" r#"
@ -541,7 +541,7 @@ fn bar(arg: char) ${0:-> ()} {
generate_function, generate_function,
r" r"
fn foo() { fn foo() {
<|>bar(42) $0bar(42)
} }
", ",
r" r"
@ -562,7 +562,7 @@ fn bar(arg: i32) ${0:-> ()} {
generate_function, generate_function,
r" r"
fn foo() { fn foo() {
<|>bar(42 as u8) $0bar(42 as u8)
} }
", ",
r" r"
@ -586,7 +586,7 @@ fn bar(arg: u8) ${0:-> ()} {
r" r"
fn foo() { fn foo() {
let x = 42; let x = 42;
bar<|>(x as u8) bar$0(x as u8)
} }
", ",
r" r"
@ -609,7 +609,7 @@ fn bar(x: u8) ${0:-> ()} {
r" r"
fn foo() { fn foo() {
let worble = (); let worble = ();
<|>bar(worble) $0bar(worble)
} }
", ",
r" r"
@ -635,7 +635,7 @@ fn foo() -> impl Foo {
todo!() todo!()
} }
fn baz() { fn baz() {
<|>bar(foo()) $0bar(foo())
} }
", ",
r" r"
@ -663,7 +663,7 @@ struct Baz;
fn baz() -> Baz { todo!() } fn baz() -> Baz { todo!() }
fn foo() { fn foo() {
bar<|>(&baz()) bar$0(&baz())
} }
", ",
r" r"
@ -691,7 +691,7 @@ mod Baz {
pub fn baz() -> Bof { Bof } pub fn baz() -> Bof { Bof }
} }
fn foo() { fn foo() {
<|>bar(Baz::baz()) $0bar(Baz::baz())
} }
", ",
r" r"
@ -718,7 +718,7 @@ fn bar(baz: Baz::Bof) ${0:-> ()} {
generate_function, generate_function,
r" r"
fn foo<T>(t: T) { fn foo<T>(t: T) {
<|>bar(t) $0bar(t)
} }
", ",
r" r"
@ -745,7 +745,7 @@ impl Baz {
fn new() -> Self { Baz } fn new() -> Self { Baz }
} }
fn foo() { fn foo() {
<|>bar(Baz::new); $0bar(Baz::new);
} }
", ",
r" r"
@ -773,7 +773,7 @@ fn bar(arg: fn() -> Baz) ${0:-> ()} {
r" r"
fn foo() { fn foo() {
let closure = |x: i64| x - 1; let closure = |x: i64| x - 1;
<|>bar(closure) $0bar(closure)
} }
", ",
r" r"
@ -795,7 +795,7 @@ fn bar(closure: impl Fn(i64) -> i64) ${0:-> ()} {
generate_function, generate_function,
r" r"
fn foo() { fn foo() {
<|>bar(baz) $0bar(baz)
} }
", ",
r" r"
@ -818,7 +818,7 @@ fn bar(baz: ()) ${0:-> ()} {
struct Baz; struct Baz;
fn baz() -> Baz { Baz } fn baz() -> Baz { Baz }
fn foo() { fn foo() {
<|>bar(baz(), baz()) $0bar(baz(), baz())
} }
", ",
r" r"
@ -843,7 +843,7 @@ fn bar(baz_1: Baz, baz_2: Baz) ${0:-> ()} {
struct Baz; struct Baz;
fn baz() -> Baz { Baz } fn baz() -> Baz { Baz }
fn foo() { fn foo() {
<|>bar(baz(), baz(), "foo", "bar") $0bar(baz(), baz(), "foo", "bar")
} }
"#, "#,
r#" r#"
@ -868,7 +868,7 @@ fn bar(baz_1: Baz, baz_2: Baz, arg_1: &str, arg_2: &str) ${0:-> ()} {
mod bar {} mod bar {}
fn foo() { fn foo() {
bar::my_fn<|>() bar::my_fn$0()
} }
", ",
r" r"
@ -899,7 +899,7 @@ mod foo {
fn bar() { fn bar() {
use foo::Foo; use foo::Foo;
let foo = Foo; let foo = Foo;
baz<|>(foo) baz$0(foo)
} }
", ",
" "
@ -929,7 +929,7 @@ mod bar {
} }
fn foo() { fn foo() {
bar::my_fn<|>() bar::my_fn$0()
} }
", ",
r" r"
@ -958,7 +958,7 @@ mod bar {
} }
fn foo() { fn foo() {
bar::baz::my_fn<|>() bar::baz::my_fn$0()
} }
", ",
r" r"
@ -986,7 +986,7 @@ fn foo() {
mod foo; mod foo;
fn main() { fn main() {
foo::bar<|>() foo::bar$0()
} }
//- /foo.rs //- /foo.rs
", ",
@ -1005,7 +1005,7 @@ pub(crate) fn bar() ${0:-> ()} {
generate_function, generate_function,
r" r"
fn foo() { fn foo() {
bar<|>(); bar$0();
} }
fn bar() {} fn bar() {}
@ -1022,7 +1022,7 @@ fn bar() {}
generate_function, generate_function,
r" r"
fn foo() { fn foo() {
bar(b<|>az); bar(b$0az);
} }
fn bar(baz: ()) {} fn bar(baz: ()) {}
@ -1039,7 +1039,7 @@ fn bar(baz: ()) {}
struct Foo; struct Foo;
impl Foo { impl Foo {
fn foo(&self) { fn foo(&self) {
self.bar()<|>; self.bar()$0;
} }
} }
", ",

View file

@ -10,7 +10,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// //
// ``` // ```
// struct Ctx<T: Clone> { // struct Ctx<T: Clone> {
// data: T,<|> // data: T,$0
// } // }
// ``` // ```
// -> // ->
@ -87,24 +87,24 @@ mod tests {
fn test_add_impl() { fn test_add_impl() {
check_assist( check_assist(
generate_impl, generate_impl,
"struct Foo {<|>}\n", "struct Foo {$0}\n",
"struct Foo {}\n\nimpl Foo {\n $0\n}\n", "struct Foo {}\n\nimpl Foo {\n $0\n}\n",
); );
check_assist( check_assist(
generate_impl, generate_impl,
"struct Foo<T: Clone> {<|>}", "struct Foo<T: Clone> {$0}",
"struct Foo<T: Clone> {}\n\nimpl<T: Clone> Foo<T> {\n $0\n}", "struct Foo<T: Clone> {}\n\nimpl<T: Clone> Foo<T> {\n $0\n}",
); );
check_assist( check_assist(
generate_impl, generate_impl,
"struct Foo<'a, T: Foo<'a>> {<|>}", "struct Foo<'a, T: Foo<'a>> {$0}",
"struct Foo<'a, T: Foo<'a>> {}\n\nimpl<'a, T: Foo<'a>> Foo<'a, T> {\n $0\n}", "struct Foo<'a, T: Foo<'a>> {}\n\nimpl<'a, T: Foo<'a>> Foo<'a, T> {\n $0\n}",
); );
check_assist( check_assist(
generate_impl, generate_impl,
r#" r#"
#[cfg(feature = "foo")] #[cfg(feature = "foo")]
struct Foo<'a, T: Foo<'a>> {<|>}"#, struct Foo<'a, T: Foo<'a>> {$0}"#,
r#" r#"
#[cfg(feature = "foo")] #[cfg(feature = "foo")]
struct Foo<'a, T: Foo<'a>> {} struct Foo<'a, T: Foo<'a>> {}
@ -119,7 +119,7 @@ mod tests {
generate_impl, generate_impl,
r#" r#"
#[cfg(not(feature = "foo"))] #[cfg(not(feature = "foo"))]
struct Foo<'a, T: Foo<'a>> {<|>}"#, struct Foo<'a, T: Foo<'a>> {$0}"#,
r#" r#"
#[cfg(not(feature = "foo"))] #[cfg(not(feature = "foo"))]
struct Foo<'a, T: Foo<'a>> {} struct Foo<'a, T: Foo<'a>> {}
@ -138,7 +138,7 @@ mod tests {
" "
struct SomeThingIrrelevant; struct SomeThingIrrelevant;
/// Has a lifetime parameter /// Has a lifetime parameter
struct Foo<'a, T: Foo<'a>> {<|>} struct Foo<'a, T: Foo<'a>> {$0}
struct EvenMoreIrrelevant; struct EvenMoreIrrelevant;
", ",
"/// Has a lifetime parameter "/// Has a lifetime parameter

View file

@ -14,7 +14,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// //
// ``` // ```
// struct Ctx<T: Clone> { // struct Ctx<T: Clone> {
// data: T,<|> // data: T,$0
// } // }
// ``` // ```
// -> // ->
@ -182,7 +182,7 @@ mod tests {
// Check output of generation // Check output of generation
check_assist( check_assist(
generate_new, generate_new,
"struct Foo {<|>}", "struct Foo {$0}",
"struct Foo {} "struct Foo {}
impl Foo { impl Foo {
@ -192,7 +192,7 @@ impl Foo {
); );
check_assist( check_assist(
generate_new, generate_new,
"struct Foo<T: Clone> {<|>}", "struct Foo<T: Clone> {$0}",
"struct Foo<T: Clone> {} "struct Foo<T: Clone> {}
impl<T: Clone> Foo<T> { impl<T: Clone> Foo<T> {
@ -202,7 +202,7 @@ impl<T: Clone> Foo<T> {
); );
check_assist( check_assist(
generate_new, generate_new,
"struct Foo<'a, T: Foo<'a>> {<|>}", "struct Foo<'a, T: Foo<'a>> {$0}",
"struct Foo<'a, T: Foo<'a>> {} "struct Foo<'a, T: Foo<'a>> {}
impl<'a, T: Foo<'a>> Foo<'a, T> { impl<'a, T: Foo<'a>> Foo<'a, T> {
@ -212,7 +212,7 @@ impl<'a, T: Foo<'a>> Foo<'a, T> {
); );
check_assist( check_assist(
generate_new, generate_new,
"struct Foo { baz: String <|>}", "struct Foo { baz: String $0}",
"struct Foo { baz: String } "struct Foo { baz: String }
impl Foo { impl Foo {
@ -222,7 +222,7 @@ impl Foo {
); );
check_assist( check_assist(
generate_new, generate_new,
"struct Foo { baz: String, qux: Vec<i32> <|>}", "struct Foo { baz: String, qux: Vec<i32> $0}",
"struct Foo { baz: String, qux: Vec<i32> } "struct Foo { baz: String, qux: Vec<i32> }
impl Foo { impl Foo {
@ -234,7 +234,7 @@ impl Foo {
// Check that visibility modifiers don't get brought in for fields // Check that visibility modifiers don't get brought in for fields
check_assist( check_assist(
generate_new, generate_new,
"struct Foo { pub baz: String, pub qux: Vec<i32> <|>}", "struct Foo { pub baz: String, pub qux: Vec<i32> $0}",
"struct Foo { pub baz: String, pub qux: Vec<i32> } "struct Foo { pub baz: String, pub qux: Vec<i32> }
impl Foo { impl Foo {
@ -246,7 +246,7 @@ impl Foo {
// Check that it reuses existing impls // Check that it reuses existing impls
check_assist( check_assist(
generate_new, generate_new,
"struct Foo {<|>} "struct Foo {$0}
impl Foo {} impl Foo {}
", ",
@ -259,7 +259,7 @@ impl Foo {
); );
check_assist( check_assist(
generate_new, generate_new,
"struct Foo {<|>} "struct Foo {$0}
impl Foo { impl Foo {
fn qux(&self) {} fn qux(&self) {}
@ -277,7 +277,7 @@ impl Foo {
check_assist( check_assist(
generate_new, generate_new,
"struct Foo {<|>} "struct Foo {$0}
impl Foo { impl Foo {
fn qux(&self) {} fn qux(&self) {}
@ -302,7 +302,7 @@ impl Foo {
// Check visibility of new fn based on struct // Check visibility of new fn based on struct
check_assist( check_assist(
generate_new, generate_new,
"pub struct Foo {<|>}", "pub struct Foo {$0}",
"pub struct Foo {} "pub struct Foo {}
impl Foo { impl Foo {
@ -312,7 +312,7 @@ impl Foo {
); );
check_assist( check_assist(
generate_new, generate_new,
"pub(crate) struct Foo {<|>}", "pub(crate) struct Foo {$0}",
"pub(crate) struct Foo {} "pub(crate) struct Foo {}
impl Foo { impl Foo {
@ -327,7 +327,7 @@ impl Foo {
check_assist_not_applicable( check_assist_not_applicable(
generate_new, generate_new,
" "
struct Foo {<|>} struct Foo {$0}
impl Foo { impl Foo {
fn new() -> Self { fn new() -> Self {
@ -339,7 +339,7 @@ impl Foo {
check_assist_not_applicable( check_assist_not_applicable(
generate_new, generate_new,
" "
struct Foo {<|>} struct Foo {$0}
impl Foo { impl Foo {
fn New() -> Self { fn New() -> Self {
@ -356,7 +356,7 @@ impl Foo {
" "
struct SomeThingIrrelevant; struct SomeThingIrrelevant;
/// Has a lifetime parameter /// Has a lifetime parameter
struct Foo<'a, T: Foo<'a>> {<|>} struct Foo<'a, T: Foo<'a>> {$0}
struct EvenMoreIrrelevant; struct EvenMoreIrrelevant;
", ",
"/// Has a lifetime parameter "/// Has a lifetime parameter
@ -381,7 +381,7 @@ impl<N: AstNode> AstId<N> {
} }
pub struct Source<T> { pub struct Source<T> {
pub file_id: HirFileId,<|> pub file_id: HirFileId,$0
pub ast: T, pub ast: T,
} }

View file

@ -10,7 +10,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// type specified. This assists is useable in a functions or closures tail expression or return type position. // type specified. This assists is useable in a functions or closures tail expression or return type position.
// //
// ``` // ```
// fn foo() { 4<|>2i32 } // fn foo() { 4$02i32 }
// ``` // ```
// -> // ->
// ``` // ```
@ -131,7 +131,7 @@ mod tests {
mark::check!(existing_infer_ret_type); mark::check!(existing_infer_ret_type);
check_assist( check_assist(
infer_function_return_type, infer_function_return_type,
r#"fn foo() -> <|>_ { r#"fn foo() -> $0_ {
45 45
}"#, }"#,
r#"fn foo() -> i32 { r#"fn foo() -> i32 {
@ -146,7 +146,7 @@ mod tests {
check_assist( check_assist(
infer_function_return_type, infer_function_return_type,
r#"fn foo() { r#"fn foo() {
|| -> _ {<|>45}; || -> _ {$045};
}"#, }"#,
r#"fn foo() { r#"fn foo() {
|| -> i32 {45}; || -> i32 {45};
@ -159,7 +159,7 @@ mod tests {
mark::check!(cursor_in_ret_position); mark::check!(cursor_in_ret_position);
check_assist( check_assist(
infer_function_return_type, infer_function_return_type,
r#"fn foo() <|>{ r#"fn foo() $0{
45 45
}"#, }"#,
r#"fn foo() -> i32 { r#"fn foo() -> i32 {
@ -174,7 +174,7 @@ mod tests {
check_assist( check_assist(
infer_function_return_type, infer_function_return_type,
r#"fn foo() { r#"fn foo() {
|| <|>45 || $045
}"#, }"#,
r#"fn foo() { r#"fn foo() {
|| -> i32 {45} || -> i32 {45}
@ -188,7 +188,7 @@ mod tests {
check_assist( check_assist(
infer_function_return_type, infer_function_return_type,
r#"fn foo() { r#"fn foo() {
45<|> 45$0
}"#, }"#,
r#"fn foo() -> i32 { r#"fn foo() -> i32 {
45 45
@ -202,7 +202,7 @@ mod tests {
infer_function_return_type, infer_function_return_type,
r#"fn foo() { r#"fn foo() {
if true { if true {
3<|> 3$0
} else { } else {
5 5
} }
@ -223,7 +223,7 @@ mod tests {
check_assist_not_applicable( check_assist_not_applicable(
infer_function_return_type, infer_function_return_type,
r#"fn foo() -> i32 { r#"fn foo() -> i32 {
( 45<|> + 32 ) * 123 ( 45$0 + 32 ) * 123
}"#, }"#,
); );
} }
@ -233,7 +233,7 @@ mod tests {
check_assist_not_applicable( check_assist_not_applicable(
infer_function_return_type, infer_function_return_type,
r#"fn foo() { r#"fn foo() {
let x = <|>3; let x = $03;
( 45 + 32 ) * 123 ( 45 + 32 ) * 123
}"#, }"#,
); );
@ -244,7 +244,7 @@ mod tests {
check_assist_not_applicable( check_assist_not_applicable(
infer_function_return_type, infer_function_return_type,
r#"fn foo() { r#"fn foo() {
(<|>) ($0)
}"#, }"#,
); );
} }
@ -256,7 +256,7 @@ mod tests {
infer_function_return_type, infer_function_return_type,
r#"fn foo() { r#"fn foo() {
|x: i32| { |x: i32| {
x<|> x$0
}; };
}"#, }"#,
r#"fn foo() { r#"fn foo() {
@ -272,7 +272,7 @@ mod tests {
check_assist( check_assist(
infer_function_return_type, infer_function_return_type,
r#"fn foo() { r#"fn foo() {
|x: i32| { x<|> }; |x: i32| { x$0 };
}"#, }"#,
r#"fn foo() { r#"fn foo() {
|x: i32| -> i32 { x }; |x: i32| -> i32 { x };
@ -286,7 +286,7 @@ mod tests {
check_assist( check_assist(
infer_function_return_type, infer_function_return_type,
r#"fn foo() { r#"fn foo() {
|x: i32| x<|>; |x: i32| x$0;
}"#, }"#,
r#"fn foo() { r#"fn foo() {
|x: i32| -> i32 {x}; |x: i32| -> i32 {x};
@ -301,7 +301,7 @@ mod tests {
r#"fn foo() { r#"fn foo() {
|| { || {
if true { if true {
3<|> 3$0
} else { } else {
5 5
} }
@ -325,7 +325,7 @@ mod tests {
check_assist_not_applicable( check_assist_not_applicable(
infer_function_return_type, infer_function_return_type,
r#"fn foo() { r#"fn foo() {
|| -> i32 { 3<|> } || -> i32 { 3$0 }
}"#, }"#,
); );
} }
@ -336,7 +336,7 @@ mod tests {
infer_function_return_type, infer_function_return_type,
r#"fn foo() { r#"fn foo() {
|| -> i32 { || -> i32 {
let x = 3<|>; let x = 3$0;
6 6
} }
}"#, }"#,

View file

@ -18,7 +18,7 @@ use crate::{
// ``` // ```
// fn add(a: u32, b: u32) -> u32 { a + b } // fn add(a: u32, b: u32) -> u32 { a + b }
// fn main() { // fn main() {
// let x = add<|>(1, 2); // let x = add$0(1, 2);
// } // }
// ``` // ```
// -> // ->
@ -104,7 +104,7 @@ mod tests {
r#" r#"
fn foo() { println!("Hello, World!"); } fn foo() { println!("Hello, World!"); }
fn main() { fn main() {
fo<|>o(); fo$0o();
} }
"#, "#,
r#" r#"
@ -125,7 +125,7 @@ fn main() {
r#" r#"
fn foo(name: String) { println!("Hello, {}!", name); } fn foo(name: String) { println!("Hello, {}!", name); }
fn main() { fn main() {
foo<|>(String::from("Michael")); foo$0(String::from("Michael"));
} }
"#, "#,
r#" r#"
@ -148,7 +148,7 @@ fn main() {
struct Foo; struct Foo;
impl Foo { fn bar(&self) {} } impl Foo { fn bar(&self) {} }
fn main() { Foo.bar<|>(); } fn main() { Foo.bar$0(); }
", ",
); );
} }
@ -160,7 +160,7 @@ fn main() { Foo.bar<|>(); }
inline_function, inline_function,
r#" r#"
fn add(a: u32, b: u32) -> u32 { a + b } fn add(a: u32, b: u32) -> u32 { a + b }
fn main() { let x = add<|>(42); } fn main() { let x = add$0(42); }
"#, "#,
); );
} }
@ -177,7 +177,7 @@ fn foo(a: u32, b: u32) -> u32 {
} }
fn main() { fn main() {
let x = foo<|>(1, 2); let x = foo$0(1, 2);
} }
"#, "#,
r#" r#"

View file

@ -16,7 +16,7 @@ use crate::{
// //
// ``` // ```
// fn main() { // fn main() {
// let x<|> = 1 + 2; // let x$0 = 1 + 2;
// x * 4; // x * 4;
// } // }
// ``` // ```
@ -146,7 +146,7 @@ mod tests {
r" r"
fn bar(a: usize) {} fn bar(a: usize) {}
fn foo() { fn foo() {
let a<|> = 1; let a$0 = 1;
a + 1; a + 1;
if a > 10 { if a > 10 {
} }
@ -180,7 +180,7 @@ fn foo() {
r" r"
fn bar(a: usize) {} fn bar(a: usize) {}
fn foo() { fn foo() {
let a<|> = 1 + 1; let a$0 = 1 + 1;
a + 1; a + 1;
if a > 10 { if a > 10 {
} }
@ -214,7 +214,7 @@ fn foo() {
r" r"
fn bar(a: usize) {} fn bar(a: usize) {}
fn foo() { fn foo() {
let a<|> = bar(1); let a$0 = bar(1);
a + 1; a + 1;
if a > 10 { if a > 10 {
} }
@ -248,7 +248,7 @@ fn foo() {
r" r"
fn bar(a: usize): usize { a } fn bar(a: usize): usize { a }
fn foo() { fn foo() {
let a<|> = bar(1) as u64; let a$0 = bar(1) as u64;
a + 1; a + 1;
if a > 10 { if a > 10 {
} }
@ -281,7 +281,7 @@ fn foo() {
inline_local_variable, inline_local_variable,
r" r"
fn foo() { fn foo() {
let a<|> = { 10 + 1 }; let a$0 = { 10 + 1 };
a + 1; a + 1;
if a > 10 { if a > 10 {
} }
@ -313,7 +313,7 @@ fn foo() {
inline_local_variable, inline_local_variable,
r" r"
fn foo() { fn foo() {
let a<|> = ( 10 + 1 ); let a$0 = ( 10 + 1 );
a + 1; a + 1;
if a > 10 { if a > 10 {
} }
@ -346,7 +346,7 @@ fn foo() {
inline_local_variable, inline_local_variable,
r" r"
fn foo() { fn foo() {
let mut a<|> = 1 + 1; let mut a$0 = 1 + 1;
a + 1; a + 1;
}", }",
); );
@ -358,7 +358,7 @@ fn foo() {
inline_local_variable, inline_local_variable,
r" r"
fn foo() { fn foo() {
let a<|> = bar(10 + 1); let a$0 = bar(10 + 1);
let b = a * 10; let b = a * 10;
let c = a as usize; let c = a as usize;
}", }",
@ -377,7 +377,7 @@ fn foo() {
r" r"
fn foo() { fn foo() {
let x = vec![1, 2, 3]; let x = vec![1, 2, 3];
let a<|> = x[0]; let a$0 = x[0];
let b = a * 10; let b = a * 10;
let c = a as usize; let c = a as usize;
}", }",
@ -397,7 +397,7 @@ fn foo() {
r" r"
fn foo() { fn foo() {
let bar = vec![1]; let bar = vec![1];
let a<|> = bar.len(); let a$0 = bar.len();
let b = a * 10; let b = a * 10;
let c = a as usize; let c = a as usize;
}", }",
@ -421,7 +421,7 @@ struct Bar {
fn foo() { fn foo() {
let bar = Bar { foo: 1 }; let bar = Bar { foo: 1 };
let a<|> = bar.foo; let a$0 = bar.foo;
let b = a * 10; let b = a * 10;
let c = a as usize; let c = a as usize;
}", }",
@ -445,7 +445,7 @@ fn foo() {
r" r"
fn foo() -> Option<usize> { fn foo() -> Option<usize> {
let bar = Some(1); let bar = Some(1);
let a<|> = bar?; let a$0 = bar?;
let b = a * 10; let b = a * 10;
let c = a as usize; let c = a as usize;
None None
@ -467,7 +467,7 @@ fn foo() -> Option<usize> {
r" r"
fn foo() { fn foo() {
let bar = 10; let bar = 10;
let a<|> = &bar; let a$0 = &bar;
let b = a * 10; let b = a * 10;
}", }",
r" r"
@ -484,7 +484,7 @@ fn foo() {
inline_local_variable, inline_local_variable,
r" r"
fn foo() { fn foo() {
let a<|> = (10, 20); let a$0 = (10, 20);
let b = a[0]; let b = a[0];
}", }",
r" r"
@ -500,7 +500,7 @@ fn foo() {
inline_local_variable, inline_local_variable,
r" r"
fn foo() { fn foo() {
let a<|> = [1, 2, 3]; let a$0 = [1, 2, 3];
let b = a.len(); let b = a.len();
}", }",
r" r"
@ -516,7 +516,7 @@ fn foo() {
inline_local_variable, inline_local_variable,
r" r"
fn foo() { fn foo() {
let a<|> = (10 + 20); let a$0 = (10 + 20);
let b = a * 10; let b = a * 10;
let c = a as usize; let c = a as usize;
}", }",
@ -535,7 +535,7 @@ fn foo() {
r" r"
fn foo() { fn foo() {
let d = 10; let d = 10;
let a<|> = d; let a$0 = d;
let b = a * 10; let b = a * 10;
let c = a as usize; let c = a as usize;
}", }",
@ -554,7 +554,7 @@ fn foo() {
inline_local_variable, inline_local_variable,
r" r"
fn foo() { fn foo() {
let a<|> = { 10 }; let a$0 = { 10 };
let b = a * 10; let b = a * 10;
let c = a as usize; let c = a as usize;
}", }",
@ -572,7 +572,7 @@ fn foo() {
inline_local_variable, inline_local_variable,
r" r"
fn foo() { fn foo() {
let a<|> = 10 + 20; let a$0 = 10 + 20;
let b = a * 10; let b = a * 10;
let c = (a, 20); let c = (a, 20);
let d = [a, 10]; let d = [a, 10];
@ -594,7 +594,7 @@ fn foo() {
inline_local_variable, inline_local_variable,
r" r"
fn foo() { fn foo() {
let a<|> = vec![10, 20]; let a$0 = vec![10, 20];
for i in a {} for i in a {}
}", }",
r" r"
@ -610,7 +610,7 @@ fn foo() {
inline_local_variable, inline_local_variable,
r" r"
fn foo() { fn foo() {
let a<|> = 1 > 0; let a$0 = 1 > 0;
while a {} while a {}
}", }",
r" r"
@ -626,7 +626,7 @@ fn foo() {
inline_local_variable, inline_local_variable,
r" r"
fn foo() { fn foo() {
let a<|> = 1 + 1; let a$0 = 1 + 1;
loop { loop {
break a; break a;
} }
@ -646,7 +646,7 @@ fn foo() {
inline_local_variable, inline_local_variable,
r" r"
fn foo() { fn foo() {
let a<|> = 1 > 0; let a$0 = 1 > 0;
return a; return a;
}", }",
r" r"
@ -662,7 +662,7 @@ fn foo() {
inline_local_variable, inline_local_variable,
r" r"
fn foo() { fn foo() {
let a<|> = 1 > 0; let a$0 = 1 > 0;
match a {} match a {}
}", }",
r" r"
@ -680,7 +680,7 @@ fn foo() {
r" r"
struct S { foo: i32} struct S { foo: i32}
fn main() { fn main() {
let <|>foo = 92; let $0foo = 92;
S { foo } S { foo }
} }
", ",
@ -700,7 +700,7 @@ fn main() {
inline_local_variable, inline_local_variable,
r" r"
fn foo() { fn foo() {
let <|>a = 0; let $0a = 0;
} }
", ",
) )
@ -713,7 +713,7 @@ fn foo() {
inline_local_variable, inline_local_variable,
r" r"
fn main() { fn main() {
let x = <|>1 + 2; let x = $01 + 2;
x * 4; x * 4;
} }
", ",

View file

@ -14,7 +14,7 @@ static ASSIST_LABEL: &str = "Introduce named lifetime";
// Change an anonymous lifetime to a named lifetime. // Change an anonymous lifetime to a named lifetime.
// //
// ``` // ```
// impl Cursor<'_<|>> { // impl Cursor<'_$0> {
// fn node(self) -> &SyntaxNode { // fn node(self) -> &SyntaxNode {
// match self { // match self {
// Cursor::Replace(node) | Cursor::Before(node) => node, // Cursor::Replace(node) | Cursor::Before(node) => node,
@ -33,7 +33,7 @@ static ASSIST_LABEL: &str = "Introduce named lifetime";
// } // }
// ``` // ```
// FIXME: How can we handle renaming any one of multiple anonymous lifetimes? // FIXME: How can we handle renaming any one of multiple anonymous lifetimes?
// FIXME: should also add support for the case fun(f: &Foo) -> &<|>Foo // FIXME: should also add support for the case fun(f: &Foo) -> &$0Foo
pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
let lifetime = let lifetime =
ctx.find_node_at_offset::<ast::Lifetime>().filter(|lifetime| lifetime.text() == "'_")?; ctx.find_node_at_offset::<ast::Lifetime>().filter(|lifetime| lifetime.text() == "'_")?;
@ -150,7 +150,7 @@ mod tests {
fn test_example_case() { fn test_example_case() {
check_assist( check_assist(
introduce_named_lifetime, introduce_named_lifetime,
r#"impl Cursor<'_<|>> { r#"impl Cursor<'_$0> {
fn node(self) -> &SyntaxNode { fn node(self) -> &SyntaxNode {
match self { match self {
Cursor::Replace(node) | Cursor::Before(node) => node, Cursor::Replace(node) | Cursor::Before(node) => node,
@ -171,7 +171,7 @@ mod tests {
fn test_example_case_simplified() { fn test_example_case_simplified() {
check_assist( check_assist(
introduce_named_lifetime, introduce_named_lifetime,
r#"impl Cursor<'_<|>> {"#, r#"impl Cursor<'_$0> {"#,
r#"impl<'a> Cursor<'a> {"#, r#"impl<'a> Cursor<'a> {"#,
); );
} }
@ -180,7 +180,7 @@ mod tests {
fn test_example_case_cursor_after_tick() { fn test_example_case_cursor_after_tick() {
check_assist( check_assist(
introduce_named_lifetime, introduce_named_lifetime,
r#"impl Cursor<'<|>_> {"#, r#"impl Cursor<'$0_> {"#,
r#"impl<'a> Cursor<'a> {"#, r#"impl<'a> Cursor<'a> {"#,
); );
} }
@ -189,7 +189,7 @@ mod tests {
fn test_impl_with_other_type_param() { fn test_impl_with_other_type_param() {
check_assist( check_assist(
introduce_named_lifetime, introduce_named_lifetime,
"impl<I> fmt::Display for SepByBuilder<'_<|>, I> "impl<I> fmt::Display for SepByBuilder<'_$0, I>
where where
I: Iterator, I: Iterator,
I::Item: fmt::Display, I::Item: fmt::Display,
@ -206,28 +206,28 @@ mod tests {
fn test_example_case_cursor_before_tick() { fn test_example_case_cursor_before_tick() {
check_assist( check_assist(
introduce_named_lifetime, introduce_named_lifetime,
r#"impl Cursor<<|>'_> {"#, r#"impl Cursor<$0'_> {"#,
r#"impl<'a> Cursor<'a> {"#, r#"impl<'a> Cursor<'a> {"#,
); );
} }
#[test] #[test]
fn test_not_applicable_cursor_position() { fn test_not_applicable_cursor_position() {
check_assist_not_applicable(introduce_named_lifetime, r#"impl Cursor<'_><|> {"#); check_assist_not_applicable(introduce_named_lifetime, r#"impl Cursor<'_>$0 {"#);
check_assist_not_applicable(introduce_named_lifetime, r#"impl Cursor<|><'_> {"#); check_assist_not_applicable(introduce_named_lifetime, r#"impl Cursor$0<'_> {"#);
} }
#[test] #[test]
fn test_not_applicable_lifetime_already_name() { fn test_not_applicable_lifetime_already_name() {
check_assist_not_applicable(introduce_named_lifetime, r#"impl Cursor<'a<|>> {"#); check_assist_not_applicable(introduce_named_lifetime, r#"impl Cursor<'a$0> {"#);
check_assist_not_applicable(introduce_named_lifetime, r#"fn my_fun<'a>() -> X<'a<|>>"#); check_assist_not_applicable(introduce_named_lifetime, r#"fn my_fun<'a>() -> X<'a$0>"#);
} }
#[test] #[test]
fn test_with_type_parameter() { fn test_with_type_parameter() {
check_assist( check_assist(
introduce_named_lifetime, introduce_named_lifetime,
r#"impl<T> Cursor<T, '_<|>>"#, r#"impl<T> Cursor<T, '_$0>"#,
r#"impl<T, 'a> Cursor<T, 'a>"#, r#"impl<T, 'a> Cursor<T, 'a>"#,
); );
} }
@ -236,7 +236,7 @@ mod tests {
fn test_with_existing_lifetime_name_conflict() { fn test_with_existing_lifetime_name_conflict() {
check_assist( check_assist(
introduce_named_lifetime, introduce_named_lifetime,
r#"impl<'a, 'b> Cursor<'a, 'b, '_<|>>"#, r#"impl<'a, 'b> Cursor<'a, 'b, '_$0>"#,
r#"impl<'a, 'b, 'c> Cursor<'a, 'b, 'c>"#, r#"impl<'a, 'b, 'c> Cursor<'a, 'b, 'c>"#,
); );
} }
@ -245,7 +245,7 @@ mod tests {
fn test_function_return_value_anon_lifetime_param() { fn test_function_return_value_anon_lifetime_param() {
check_assist( check_assist(
introduce_named_lifetime, introduce_named_lifetime,
r#"fn my_fun() -> X<'_<|>>"#, r#"fn my_fun() -> X<'_$0>"#,
r#"fn my_fun<'a>() -> X<'a>"#, r#"fn my_fun<'a>() -> X<'a>"#,
); );
} }
@ -254,7 +254,7 @@ mod tests {
fn test_function_return_value_anon_reference_lifetime() { fn test_function_return_value_anon_reference_lifetime() {
check_assist( check_assist(
introduce_named_lifetime, introduce_named_lifetime,
r#"fn my_fun() -> &'_<|> X"#, r#"fn my_fun() -> &'_$0 X"#,
r#"fn my_fun<'a>() -> &'a X"#, r#"fn my_fun<'a>() -> &'a X"#,
); );
} }
@ -263,7 +263,7 @@ mod tests {
fn test_function_param_anon_lifetime() { fn test_function_param_anon_lifetime() {
check_assist( check_assist(
introduce_named_lifetime, introduce_named_lifetime,
r#"fn my_fun(x: X<'_<|>>)"#, r#"fn my_fun(x: X<'_$0>)"#,
r#"fn my_fun<'a>(x: X<'a>)"#, r#"fn my_fun<'a>(x: X<'a>)"#,
); );
} }
@ -272,7 +272,7 @@ mod tests {
fn test_function_add_lifetime_to_params() { fn test_function_add_lifetime_to_params() {
check_assist( check_assist(
introduce_named_lifetime, introduce_named_lifetime,
r#"fn my_fun(f: &Foo) -> X<'_<|>>"#, r#"fn my_fun(f: &Foo) -> X<'_$0>"#,
r#"fn my_fun<'a>(f: &'a Foo) -> X<'a>"#, r#"fn my_fun<'a>(f: &'a Foo) -> X<'a>"#,
); );
} }
@ -281,7 +281,7 @@ mod tests {
fn test_function_add_lifetime_to_params_in_presence_of_other_lifetime() { fn test_function_add_lifetime_to_params_in_presence_of_other_lifetime() {
check_assist( check_assist(
introduce_named_lifetime, introduce_named_lifetime,
r#"fn my_fun<'other>(f: &Foo, b: &'other Bar) -> X<'_<|>>"#, r#"fn my_fun<'other>(f: &Foo, b: &'other Bar) -> X<'_$0>"#,
r#"fn my_fun<'other, 'a>(f: &'a Foo, b: &'other Bar) -> X<'a>"#, r#"fn my_fun<'other, 'a>(f: &'a Foo, b: &'other Bar) -> X<'a>"#,
); );
} }
@ -291,7 +291,7 @@ mod tests {
// this is not permitted under lifetime elision rules // this is not permitted under lifetime elision rules
check_assist_not_applicable( check_assist_not_applicable(
introduce_named_lifetime, introduce_named_lifetime,
r#"fn my_fun(f: &Foo, b: &Bar) -> X<'_<|>>"#, r#"fn my_fun(f: &Foo, b: &Bar) -> X<'_$0>"#,
); );
} }
@ -299,7 +299,7 @@ mod tests {
fn test_function_add_lifetime_to_self_ref_param() { fn test_function_add_lifetime_to_self_ref_param() {
check_assist( check_assist(
introduce_named_lifetime, introduce_named_lifetime,
r#"fn my_fun<'other>(&self, f: &Foo, b: &'other Bar) -> X<'_<|>>"#, r#"fn my_fun<'other>(&self, f: &Foo, b: &'other Bar) -> X<'_$0>"#,
r#"fn my_fun<'other, 'a>(&'a self, f: &Foo, b: &'other Bar) -> X<'a>"#, r#"fn my_fun<'other, 'a>(&'a self, f: &Foo, b: &'other Bar) -> X<'a>"#,
); );
} }
@ -308,7 +308,7 @@ mod tests {
fn test_function_add_lifetime_to_param_with_non_ref_self() { fn test_function_add_lifetime_to_param_with_non_ref_self() {
check_assist( check_assist(
introduce_named_lifetime, introduce_named_lifetime,
r#"fn my_fun<'other>(self, f: &Foo, b: &'other Bar) -> X<'_<|>>"#, r#"fn my_fun<'other>(self, f: &Foo, b: &'other Bar) -> X<'_$0>"#,
r#"fn my_fun<'other, 'a>(self, f: &'a Foo, b: &'other Bar) -> X<'a>"#, r#"fn my_fun<'other, 'a>(self, f: &'a Foo, b: &'other Bar) -> X<'a>"#,
); );
} }

View file

@ -18,7 +18,7 @@ use crate::{
// //
// ``` // ```
// fn main() { // fn main() {
// if<|> !y { A } else { B } // if$0 !y { A } else { B }
// } // }
// ``` // ```
// -> // ->
@ -72,7 +72,7 @@ mod tests {
fn invert_if_composite_condition() { fn invert_if_composite_condition() {
check_assist( check_assist(
invert_if, invert_if,
"fn f() { i<|>f x == 3 || x == 4 || x == 5 { 1 } else { 3 * 2 } }", "fn f() { i$0f x == 3 || x == 4 || x == 5 { 1 } else { 3 * 2 } }",
"fn f() { if !(x == 3 || x == 4 || x == 5) { 3 * 2 } else { 1 } }", "fn f() { if !(x == 3 || x == 4 || x == 5) { 3 * 2 } else { 1 } }",
) )
} }
@ -81,7 +81,7 @@ mod tests {
fn invert_if_remove_not_parentheses() { fn invert_if_remove_not_parentheses() {
check_assist( check_assist(
invert_if, invert_if,
"fn f() { i<|>f !(x == 3 || x == 4 || x == 5) { 3 * 2 } else { 1 } }", "fn f() { i$0f !(x == 3 || x == 4 || x == 5) { 3 * 2 } else { 1 } }",
"fn f() { if x == 3 || x == 4 || x == 5 { 1 } else { 3 * 2 } }", "fn f() { if x == 3 || x == 4 || x == 5 { 1 } else { 3 * 2 } }",
) )
} }
@ -90,7 +90,7 @@ mod tests {
fn invert_if_remove_inequality() { fn invert_if_remove_inequality() {
check_assist( check_assist(
invert_if, invert_if,
"fn f() { i<|>f x != 3 { 1 } else { 3 + 2 } }", "fn f() { i$0f x != 3 { 1 } else { 3 + 2 } }",
"fn f() { if x == 3 { 3 + 2 } else { 1 } }", "fn f() { if x == 3 { 3 + 2 } else { 1 } }",
) )
} }
@ -99,7 +99,7 @@ mod tests {
fn invert_if_remove_not() { fn invert_if_remove_not() {
check_assist( check_assist(
invert_if, invert_if,
"fn f() { <|>if !cond { 3 * 2 } else { 1 } }", "fn f() { $0if !cond { 3 * 2 } else { 1 } }",
"fn f() { if cond { 1 } else { 3 * 2 } }", "fn f() { if cond { 1 } else { 3 * 2 } }",
) )
} }
@ -108,21 +108,21 @@ mod tests {
fn invert_if_general_case() { fn invert_if_general_case() {
check_assist( check_assist(
invert_if, invert_if,
"fn f() { i<|>f cond { 3 * 2 } else { 1 } }", "fn f() { i$0f cond { 3 * 2 } else { 1 } }",
"fn f() { if !cond { 1 } else { 3 * 2 } }", "fn f() { if !cond { 1 } else { 3 * 2 } }",
) )
} }
#[test] #[test]
fn invert_if_doesnt_apply_with_cursor_not_on_if() { fn invert_if_doesnt_apply_with_cursor_not_on_if() {
check_assist_not_applicable(invert_if, "fn f() { if !<|>cond { 3 * 2 } else { 1 } }") check_assist_not_applicable(invert_if, "fn f() { if !$0cond { 3 * 2 } else { 1 } }")
} }
#[test] #[test]
fn invert_if_doesnt_apply_with_if_let() { fn invert_if_doesnt_apply_with_if_let() {
check_assist_not_applicable( check_assist_not_applicable(
invert_if, invert_if,
"fn f() { i<|>f let Some(_) = Some(1) { 1 } else { 0 } }", "fn f() { i$0f let Some(_) = Some(1) { 1 } else { 0 } }",
) )
} }
@ -130,7 +130,7 @@ mod tests {
fn invert_if_option_case() { fn invert_if_option_case() {
check_assist( check_assist(
invert_if, invert_if,
"fn f() { if<|> doc_style.is_some() { Class::DocComment } else { Class::Comment } }", "fn f() { if$0 doc_style.is_some() { Class::DocComment } else { Class::Comment } }",
"fn f() { if doc_style.is_none() { Class::Comment } else { Class::DocComment } }", "fn f() { if doc_style.is_none() { Class::Comment } else { Class::DocComment } }",
) )
} }
@ -139,7 +139,7 @@ mod tests {
fn invert_if_result_case() { fn invert_if_result_case() {
check_assist( check_assist(
invert_if, invert_if,
"fn f() { i<|>f doc_style.is_err() { Class::Err } else { Class::Ok } }", "fn f() { i$0f doc_style.is_err() { Class::Err } else { Class::Ok } }",
"fn f() { if doc_style.is_ok() { Class::Ok } else { Class::Err } }", "fn f() { if doc_style.is_ok() { Class::Ok } else { Class::Err } }",
) )
} }

View file

@ -15,7 +15,7 @@ use crate::{
// Merges two imports with a common prefix. // Merges two imports with a common prefix.
// //
// ``` // ```
// use std::<|>fmt::Formatter; // use std::$0fmt::Formatter;
// use std::io; // use std::io;
// ``` // ```
// -> // ->
@ -75,7 +75,7 @@ mod tests {
check_assist( check_assist(
merge_imports, merge_imports,
r" r"
use std::fmt<|>::{Display, Debug}; use std::fmt$0::{Display, Debug};
use std::fmt::{Display, Debug}; use std::fmt::{Display, Debug};
", ",
r" r"
@ -89,7 +89,7 @@ use std::fmt::{Debug, Display};
check_assist( check_assist(
merge_imports, merge_imports,
r" r"
use std::fmt<|>::Debug; use std::fmt$0::Debug;
use std::fmt::Display; use std::fmt::Display;
", ",
r" r"
@ -104,7 +104,7 @@ use std::fmt::{Debug, Display};
merge_imports, merge_imports,
r" r"
use std::fmt::Debug; use std::fmt::Debug;
use std::fmt<|>::Display; use std::fmt$0::Display;
", ",
r" r"
use std::fmt::{Debug, Display}; use std::fmt::{Debug, Display};
@ -117,7 +117,7 @@ use std::fmt::{Debug, Display};
check_assist( check_assist(
merge_imports, merge_imports,
r" r"
use std::fmt<|>; use std::fmt$0;
use std::fmt::Display; use std::fmt::Display;
", ",
r" r"
@ -131,7 +131,7 @@ use std::fmt::{self, Display};
check_assist( check_assist(
merge_imports, merge_imports,
r" r"
use std::{fmt, <|>fmt::Display}; use std::{fmt, $0fmt::Display};
", ",
r" r"
use std::{fmt::{self, Display}}; use std::{fmt::{self, Display}};
@ -144,7 +144,7 @@ use std::{fmt::{self, Display}};
check_assist_not_applicable( check_assist_not_applicable(
merge_imports, merge_imports,
r" r"
pub use std::fmt<|>::Debug; pub use std::fmt$0::Debug;
use std::fmt::Display; use std::fmt::Display;
", ",
); );
@ -155,7 +155,7 @@ use std::fmt::Display;
check_assist_not_applicable( check_assist_not_applicable(
merge_imports, merge_imports,
r" r"
use std::fmt<|>::Debug; use std::fmt$0::Debug;
pub use std::fmt::Display; pub use std::fmt::Display;
", ",
); );
@ -166,7 +166,7 @@ pub use std::fmt::Display;
check_assist_not_applicable( check_assist_not_applicable(
merge_imports, merge_imports,
r" r"
pub(crate) use std::fmt<|>::Debug; pub(crate) use std::fmt$0::Debug;
pub use std::fmt::Display; pub use std::fmt::Display;
", ",
); );
@ -177,7 +177,7 @@ pub use std::fmt::Display;
check_assist_not_applicable( check_assist_not_applicable(
merge_imports, merge_imports,
r" r"
pub use std::fmt<|>::Debug; pub use std::fmt$0::Debug;
pub(crate) use std::fmt::Display; pub(crate) use std::fmt::Display;
", ",
); );
@ -188,7 +188,7 @@ pub(crate) use std::fmt::Display;
check_assist( check_assist(
merge_imports, merge_imports,
r" r"
pub use std::fmt<|>::Debug; pub use std::fmt$0::Debug;
pub use std::fmt::Display; pub use std::fmt::Display;
", ",
r" r"
@ -202,7 +202,7 @@ pub use std::fmt::{Debug, Display};
check_assist( check_assist(
merge_imports, merge_imports,
r" r"
pub(crate) use std::fmt<|>::Debug; pub(crate) use std::fmt$0::Debug;
pub(crate) use std::fmt::Display; pub(crate) use std::fmt::Display;
", ",
r" r"
@ -216,7 +216,7 @@ pub(crate) use std::fmt::{Debug, Display};
check_assist( check_assist(
merge_imports, merge_imports,
r" r"
use std::{fmt<|>::Debug, fmt::Display}; use std::{fmt$0::Debug, fmt::Display};
", ",
r" r"
use std::{fmt::{Debug, Display}}; use std::{fmt::{Debug, Display}};
@ -229,7 +229,7 @@ use std::{fmt::{Debug, Display}};
check_assist( check_assist(
merge_imports, merge_imports,
r" r"
use std::{fmt::Debug, fmt<|>::Display}; use std::{fmt::Debug, fmt$0::Display};
", ",
r" r"
use std::{fmt::{Debug, Display}}; use std::{fmt::{Debug, Display}};
@ -242,7 +242,7 @@ use std::{fmt::{Debug, Display}};
check_assist( check_assist(
merge_imports, merge_imports,
r" r"
use std<|>::cell::*; use std$0::cell::*;
use std::str; use std::str;
", ",
r" r"
@ -256,7 +256,7 @@ use std::{cell::*, str};
check_assist( check_assist(
merge_imports, merge_imports,
r" r"
use std<|>::cell::*; use std$0::cell::*;
use std::str::*; use std::str::*;
", ",
r" r"
@ -270,7 +270,7 @@ use std::{cell::*, str::*};
check_assist( check_assist(
merge_imports, merge_imports,
r" r"
use foo<|>::bar; use foo$0::bar;
use foo::baz; use foo::baz;
/// Doc comment /// Doc comment
@ -289,7 +289,7 @@ use foo::{bar, baz};
merge_imports, merge_imports,
r" r"
use { use {
foo<|>::bar, foo$0::bar,
foo::baz, foo::baz,
}; };
", ",
@ -304,7 +304,7 @@ use {
r" r"
use { use {
foo::baz, foo::baz,
foo<|>::bar, foo$0::bar,
}; };
", ",
r" r"
@ -321,7 +321,7 @@ use {
merge_imports, merge_imports,
r" r"
use foo::bar::baz; use foo::bar::baz;
use foo::<|>{ use foo::$0{
FooBar, FooBar,
}; };
", ",
@ -336,7 +336,7 @@ use foo::{FooBar, bar::baz};
check_assist_not_applicable( check_assist_not_applicable(
merge_imports, merge_imports,
r" r"
use std::<|> use std::$0
fn main() {}", fn main() {}",
); );
} }

View file

@ -17,7 +17,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, TextRange};
// //
// fn handle(action: Action) { // fn handle(action: Action) {
// match action { // match action {
// <|>Action::Move(..) => foo(), // $0Action::Move(..) => foo(),
// Action::Stop => foo(), // Action::Stop => foo(),
// } // }
// } // }
@ -106,7 +106,7 @@ mod tests {
fn main() { fn main() {
let x = X::A; let x = X::A;
let y = match x { let y = match x {
X::A => { 1i32<|> } X::A => { 1i32$0 }
X::B => { 1i32 } X::B => { 1i32 }
X::C => { 2i32 } X::C => { 2i32 }
} }
@ -138,7 +138,7 @@ mod tests {
fn main() { fn main() {
let x = X::A; let x = X::A;
let y = match x { let y = match x {
X::A | X::B => {<|> 1i32 }, X::A | X::B => {$0 1i32 },
X::C | X::D => { 1i32 }, X::C | X::D => { 1i32 },
X::E => { 2i32 }, X::E => { 2i32 },
} }
@ -171,7 +171,7 @@ mod tests {
let x = X::A; let x = X::A;
let y = match x { let y = match x {
X::A => { 1i32 }, X::A => { 1i32 },
X::B => { 2i<|>32 }, X::B => { 2i$032 },
_ => { 2i32 } _ => { 2i32 }
} }
} }
@ -200,7 +200,7 @@ mod tests {
fn main() { fn main() {
match X::A { match X::A {
X::A<|> => 92, X::A$0 => 92,
X::B => 92, X::B => 92,
X::C => 92, X::C => 92,
X::D => 62, X::D => 62,
@ -237,7 +237,7 @@ mod tests {
fn main() { fn main() {
let x = X::A; let x = X::A;
let y = match x { let y = match x {
X::A(a) if a > 5 => { <|>1i32 }, X::A(a) if a > 5 => { $01i32 },
X::B => { 1i32 }, X::B => { 1i32 },
X::C => { 2i32 } X::C => { 2i32 }
} }

View file

@ -12,7 +12,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// Moves inline type bounds to a where clause. // Moves inline type bounds to a where clause.
// //
// ``` // ```
// fn apply<T, U, <|>F: FnOnce(T) -> U>(f: F, x: T) -> U { // fn apply<T, U, $0F: FnOnce(T) -> U>(f: F, x: T) -> U {
// f(x) // f(x)
// } // }
// ``` // ```
@ -103,7 +103,7 @@ mod tests {
check_assist( check_assist(
move_bounds_to_where_clause, move_bounds_to_where_clause,
r#" r#"
fn foo<T: u32, <|>F: FnOnce(T) -> T>() {} fn foo<T: u32, $0F: FnOnce(T) -> T>() {}
"#, "#,
r#" r#"
fn foo<T, F>() where T: u32, F: FnOnce(T) -> T {} fn foo<T, F>() where T: u32, F: FnOnce(T) -> T {}
@ -116,7 +116,7 @@ mod tests {
check_assist( check_assist(
move_bounds_to_where_clause, move_bounds_to_where_clause,
r#" r#"
impl<U: u32, <|>T> A<U, T> {} impl<U: u32, $0T> A<U, T> {}
"#, "#,
r#" r#"
impl<U, T> A<U, T> where U: u32 {} impl<U, T> A<U, T> where U: u32 {}
@ -129,7 +129,7 @@ mod tests {
check_assist( check_assist(
move_bounds_to_where_clause, move_bounds_to_where_clause,
r#" r#"
struct A<<|>T: Iterator<Item = u32>> {} struct A<$0T: Iterator<Item = u32>> {}
"#, "#,
r#" r#"
struct A<T> where T: Iterator<Item = u32> {} struct A<T> where T: Iterator<Item = u32> {}
@ -142,7 +142,7 @@ mod tests {
check_assist( check_assist(
move_bounds_to_where_clause, move_bounds_to_where_clause,
r#" r#"
struct Pair<<|>T: u32>(T, T); struct Pair<$0T: u32>(T, T);
"#, "#,
r#" r#"
struct Pair<T>(T, T) where T: u32; struct Pair<T>(T, T) where T: u32;

View file

@ -14,7 +14,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// //
// fn handle(action: Action) { // fn handle(action: Action) {
// match action { // match action {
// Action::Move { distance } <|>if distance > 10 => foo(), // Action::Move { distance } $0if distance > 10 => foo(),
// _ => (), // _ => (),
// } // }
// } // }
@ -74,7 +74,7 @@ pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext) ->
// //
// fn handle(action: Action) { // fn handle(action: Action) {
// match action { // match action {
// Action::Move { distance } => <|>if distance > 10 { foo() }, // Action::Move { distance } => $0if distance > 10 { foo() },
// _ => (), // _ => (),
// } // }
// } // }
@ -158,7 +158,7 @@ mod tests {
r#" r#"
fn main() { fn main() {
match 92 { match 92 {
x <|>if x > 10 => false, x $0if x > 10 => false,
_ => true _ => true
} }
} }
@ -174,7 +174,7 @@ fn main() {
r#" r#"
fn main() { fn main() {
match 92 { match 92 {
x <|>if x > 10 => false, x $0if x > 10 => false,
_ => true _ => true
} }
} }
@ -199,7 +199,7 @@ fn main() {
r#" r#"
fn main() { fn main() {
match 92 { match 92 {
<|>x @ 4 | x @ 5 if x > 5 => true, $0x @ 4 | x @ 5 if x > 5 => true,
_ => false _ => false
} }
} }
@ -224,7 +224,7 @@ fn main() {
r#" r#"
fn main() { fn main() {
match 92 { match 92 {
x => if x > 10 { <|>false }, x => if x > 10 { $0false },
_ => true _ => true
} }
} }
@ -248,7 +248,7 @@ fn main() {
fn main() { fn main() {
match 92 { match 92 {
x => { x => {
<|>if x > 10 { $0if x > 10 {
false false
} }
}, },
@ -274,7 +274,7 @@ fn main() {
r#" r#"
fn main() { fn main() {
match 92 { match 92 {
x => if let 62 = x { <|>false }, x => if let 62 = x { $0false },
_ => true _ => true
} }
} }
@ -289,7 +289,7 @@ fn main() {
r#" r#"
fn main() { fn main() {
match 92 { match 92 {
x => if x > 10 { <|> }, x => if x > 10 { $0 },
_ => true _ => true
} }
} }
@ -313,7 +313,7 @@ fn main() {
fn main() { fn main() {
match 92 { match 92 {
x => if x > 10 { x => if x > 10 {
92;<|> 92;$0
false false
}, },
_ => true _ => true
@ -343,7 +343,7 @@ fn main() {
match 92 { match 92 {
x => { x => {
if x > 10 { if x > 10 {
92;<|> 92;$0
false false
} }
} }

View file

@ -13,7 +13,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// Moves inline module's contents to a separate file. // Moves inline module's contents to a separate file.
// //
// ``` // ```
// mod <|>foo { // mod $0foo {
// fn t() {} // fn t() {}
// } // }
// ``` // ```
@ -78,7 +78,7 @@ mod tests {
check_assist( check_assist(
move_module_to_file, move_module_to_file,
r#" r#"
mod <|>tests { mod $0tests {
#[test] fn t() {} #[test] fn t() {}
} }
"#, "#,
@ -99,7 +99,7 @@ mod tests;
//- /main.rs //- /main.rs
mod submod; mod submod;
//- /submod.rs //- /submod.rs
<|>mod inner { $0mod inner {
fn f() {} fn f() {}
} }
fn g() {} fn g() {}
@ -122,7 +122,7 @@ fn f() {}
//- /main.rs //- /main.rs
mod submodule; mod submodule;
//- /submodule/mod.rs //- /submodule/mod.rs
mod inner<|> { mod inner$0 {
fn f() {} fn f() {}
} }
fn g() {} fn g() {}
@ -140,6 +140,6 @@ fn f() {}
#[test] #[test]
fn available_before_curly() { fn available_before_curly() {
mark::check!(available_before_curly); mark::check!(available_before_curly);
check_assist_not_applicable(move_module_to_file, r#"mod m { <|> }"#); check_assist_not_applicable(move_module_to_file, r#"mod m { $0 }"#);
} }
} }

View file

@ -18,7 +18,7 @@ use crate::{
// let mut foo = 6; // let mut foo = 6;
// //
// if true { // if true {
// <|>foo = 5; // $0foo = 5;
// } else { // } else {
// foo = 4; // foo = 4;
// } // }
@ -175,7 +175,7 @@ fn foo() {
let mut a = 1; let mut a = 1;
if true { if true {
<|>a = 2; $0a = 2;
} else { } else {
a = 3; a = 3;
} }
@ -203,7 +203,7 @@ fn foo() {
match 1 { match 1 {
1 => { 1 => {
<|>a = 2; $0a = 2;
}, },
2 => { 2 => {
a = 3; a = 3;
@ -241,7 +241,7 @@ fn foo() {
let mut a = 1; let mut a = 1;
if true { if true {
<|>a = 2; $0a = 2;
b = a; b = a;
} else { } else {
a = 3; a = 3;
@ -260,7 +260,7 @@ fn foo() {
let mut a = 1; let mut a = 1;
if true { if true {
<|>a = 2; $0a = 2;
} else if false { } else if false {
a = 3; a = 3;
} else { } else {
@ -292,7 +292,7 @@ fn foo() {
if true { if true {
let b = 2; let b = 2;
<|>a = 2; $0a = 2;
} else { } else {
let b = 3; let b = 3;
a = 3; a = 3;
@ -322,7 +322,7 @@ fn foo() {
let mut a = 1; let mut a = 1;
let b = if true { let b = if true {
<|>a = 2 $0a = 2
} else { } else {
a = 3 a = 3
}; };
@ -339,7 +339,7 @@ fn foo() {
let mut a = 1; let mut a = 1;
if true { if true {
<|>a = 2; $0a = 2;
} else {} } else {}
}"#, }"#,
) )
@ -355,7 +355,7 @@ fn foo() {
match 1 { match 1 {
1 => { 1 => {
<|>a = 2; $0a = 2;
}, },
2 => { 2 => {
a = 3; a = 3;
@ -378,7 +378,7 @@ fn foo() {
let mut a = A(1); let mut a = A(1);
if true { if true {
<|>a.0 = 2; $0a.0 = 2;
} else { } else {
a.0 = 3; a.0 = 3;
} }

View file

@ -22,7 +22,7 @@ use crate::{
// //
// ``` // ```
// fn main() { // fn main() {
// let map = HashMap<|>::new(); // let map = HashMap$0::new();
// } // }
// # pub mod std { pub mod collections { pub struct HashMap { } } } // # pub mod std { pub mod collections { pub struct HashMap { } } }
// ``` // ```
@ -221,7 +221,7 @@ mod tests {
use std::fmt; use std::fmt;
<|>Formatter $0Formatter
", ",
r" r"
mod std { mod std {
@ -242,7 +242,7 @@ mod tests {
check_assist( check_assist(
qualify_path, qualify_path,
r" r"
<|>PubStruct $0PubStruct
pub mod PubMod { pub mod PubMod {
pub struct PubStruct; pub struct PubStruct;
@ -266,7 +266,7 @@ mod tests {
macro_rules! foo { macro_rules! foo {
($i:ident) => { fn foo(a: $i) {} } ($i:ident) => { fn foo(a: $i) {} }
} }
foo!(Pub<|>Struct); foo!(Pub$0Struct);
pub mod PubMod { pub mod PubMod {
pub struct PubStruct; pub struct PubStruct;
@ -290,7 +290,7 @@ mod tests {
check_assist( check_assist(
qualify_path, qualify_path,
r" r"
PubSt<|>ruct PubSt$0ruct
pub mod PubMod1 { pub mod PubMod1 {
pub struct PubStruct; pub struct PubStruct;
@ -325,7 +325,7 @@ mod tests {
r" r"
use PubMod::PubStruct; use PubMod::PubStruct;
PubStruct<|> PubStruct$0
pub mod PubMod { pub mod PubMod {
pub struct PubStruct; pub struct PubStruct;
@ -339,7 +339,7 @@ mod tests {
check_assist_not_applicable( check_assist_not_applicable(
qualify_path, qualify_path,
r" r"
PrivateStruct<|> PrivateStruct$0
pub mod PubMod { pub mod PubMod {
struct PrivateStruct; struct PrivateStruct;
@ -353,7 +353,7 @@ mod tests {
check_assist_not_applicable( check_assist_not_applicable(
qualify_path, qualify_path,
" "
PubStruct<|>", PubStruct$0",
); );
} }
@ -362,7 +362,7 @@ mod tests {
check_assist_not_applicable( check_assist_not_applicable(
qualify_path, qualify_path,
r" r"
use PubStruct<|>; use PubStruct$0;
pub mod PubMod { pub mod PubMod {
pub struct PubStruct; pub struct PubStruct;
@ -375,7 +375,7 @@ mod tests {
check_assist( check_assist(
qualify_path, qualify_path,
r" r"
test_function<|> test_function$0
pub mod PubMod { pub mod PubMod {
pub fn test_function() {}; pub fn test_function() {};
@ -404,7 +404,7 @@ macro_rules! foo {
//- /main.rs crate:main deps:crate_with_macro //- /main.rs crate:main deps:crate_with_macro
fn main() { fn main() {
foo<|> foo$0
} }
", ",
r" r"
@ -421,7 +421,7 @@ fn main() {
qualify_path, qualify_path,
r" r"
struct AssistInfo { struct AssistInfo {
group_label: Option<<|>GroupLabel>, group_label: Option<$0GroupLabel>,
} }
mod m { pub struct GroupLabel; } mod m { pub struct GroupLabel; }
@ -445,7 +445,7 @@ fn main() {
use mod1::mod2; use mod1::mod2;
fn main() { fn main() {
mod2::mod3::TestStruct<|> mod2::mod3::TestStruct$0
} }
", ",
); );
@ -462,7 +462,7 @@ fn main() {
use test_mod::test_function; use test_mod::test_function;
fn main() { fn main() {
test_function<|> test_function$0
} }
", ",
); );
@ -481,7 +481,7 @@ fn main() {
} }
fn main() { fn main() {
TestStruct::test_function<|> TestStruct::test_function$0
} }
", ",
r" r"
@ -513,7 +513,7 @@ fn main() {
} }
fn main() { fn main() {
TestStruct::TEST_CONST<|> TestStruct::TEST_CONST$0
} }
", ",
r" r"
@ -547,7 +547,7 @@ fn main() {
} }
fn main() { fn main() {
test_mod::TestStruct::test_function<|> test_mod::TestStruct::test_function$0
} }
", ",
r" r"
@ -594,7 +594,7 @@ fn main() {
use test_mod::TestTrait2; use test_mod::TestTrait2;
fn main() { fn main() {
test_mod::TestEnum::test_function<|>; test_mod::TestEnum::test_function$0;
} }
", ",
) )
@ -617,7 +617,7 @@ fn main() {
} }
fn main() { fn main() {
test_mod::TestStruct::TEST_CONST<|> test_mod::TestStruct::TEST_CONST$0
} }
", ",
r" r"
@ -664,7 +664,7 @@ fn main() {
use test_mod::TestTrait2; use test_mod::TestTrait2;
fn main() { fn main() {
test_mod::TestEnum::TEST_CONST<|>; test_mod::TestEnum::TEST_CONST$0;
} }
", ",
) )
@ -688,7 +688,7 @@ fn main() {
fn main() { fn main() {
let test_struct = test_mod::TestStruct {}; let test_struct = test_mod::TestStruct {};
test_struct.test_meth<|>od() test_struct.test_meth$0od()
} }
", ",
r" r"
@ -727,7 +727,7 @@ fn main() {
fn main() { fn main() {
let test_struct = test_mod::TestStruct {}; let test_struct = test_mod::TestStruct {};
test_struct.test_meth<|>od(42) test_struct.test_meth$0od(42)
} }
", ",
r" r"
@ -766,7 +766,7 @@ fn main() {
fn main() { fn main() {
let test_struct = test_mod::TestStruct {}; let test_struct = test_mod::TestStruct {};
test_struct.test_meth<|>od() test_struct.test_meth$0od()
} }
", ",
r" r"
@ -796,7 +796,7 @@ fn main() {
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
let test_struct = dep::test_mod::TestStruct {}; let test_struct = dep::test_mod::TestStruct {};
test_struct.test_meth<|>od() test_struct.test_meth$0od()
} }
//- /dep.rs crate:dep //- /dep.rs crate:dep
pub mod test_mod { pub mod test_mod {
@ -825,7 +825,7 @@ fn main() {
r" r"
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
dep::test_mod::TestStruct::test_func<|>tion dep::test_mod::TestStruct::test_func$0tion
} }
//- /dep.rs crate:dep //- /dep.rs crate:dep
pub mod test_mod { pub mod test_mod {
@ -853,7 +853,7 @@ fn main() {
r" r"
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
dep::test_mod::TestStruct::CONST<|> dep::test_mod::TestStruct::CONST$0
} }
//- /dep.rs crate:dep //- /dep.rs crate:dep
pub mod test_mod { pub mod test_mod {
@ -882,7 +882,7 @@ fn main() {
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
let test_struct = dep::test_mod::TestStruct {}; let test_struct = dep::test_mod::TestStruct {};
test_struct.test_func<|>tion() test_struct.test_func$0tion()
} }
//- /dep.rs crate:dep //- /dep.rs crate:dep
pub mod test_mod { pub mod test_mod {
@ -906,7 +906,7 @@ fn main() {
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
let test_struct = dep::test_mod::TestStruct {}; let test_struct = dep::test_mod::TestStruct {};
test_struct.test_meth<|>od() test_struct.test_meth$0od()
} }
//- /dep.rs crate:dep //- /dep.rs crate:dep
pub mod test_mod { pub mod test_mod {
@ -949,7 +949,7 @@ fn main() {
use test_mod::TestTrait2; use test_mod::TestTrait2;
fn main() { fn main() {
let one = test_mod::TestEnum::One; let one = test_mod::TestEnum::One;
one.test<|>_method(); one.test$0_method();
} }
", ",
) )
@ -965,7 +965,7 @@ pub struct Struct;
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
Struct<|> Struct$0
} }
", ",
r" r"
@ -992,7 +992,7 @@ pub fn panic_fmt() {}
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
struct S; struct S;
impl f<|>mt::Display for S {} impl f$0mt::Display for S {}
", ",
r" r"
struct S; struct S;
@ -1019,7 +1019,7 @@ mac!();
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
Cheese<|>; Cheese$0;
} }
", ",
r" r"
@ -1042,7 +1042,7 @@ pub struct fmt;
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
FMT<|>; FMT$0;
} }
", ",
r" r"
@ -1062,7 +1062,7 @@ fn main() {
pub mod generic { pub struct Thing<'a, T>(&'a T); } pub mod generic { pub struct Thing<'a, T>(&'a T); }
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn foo() -> Thin<|>g<'static, ()> {} fn foo() -> Thin$0g<'static, ()> {}
fn main() {} fn main() {}
", ",
@ -1083,7 +1083,7 @@ fn main() {}
pub mod generic { pub struct Thing<'a, T>(&'a T); } pub mod generic { pub struct Thing<'a, T>(&'a T); }
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn foo() -> Thin<|>g::<'static, ()> {} fn foo() -> Thin$0g::<'static, ()> {}
fn main() {} fn main() {}
", ",
@ -1108,7 +1108,7 @@ fn main() {}
} }
fn main() { fn main() {
TestStruct::<()>::TEST_CONST<|> TestStruct::<()>::TEST_CONST$0
} }
", ",
r" r"
@ -1142,7 +1142,7 @@ fn main() {}
} }
fn main() { fn main() {
test_mod::TestStruct::<()>::TEST_CONST<|> test_mod::TestStruct::<()>::TEST_CONST$0
} }
", ",
r" r"
@ -1180,7 +1180,7 @@ fn main() {}
fn main() { fn main() {
let test_struct = test_mod::TestStruct {}; let test_struct = test_mod::TestStruct {};
test_struct.test_meth<|>od::<()>() test_struct.test_meth$0od::<()>()
} }
", ",
r" r"

View file

@ -11,7 +11,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// //
// ``` // ```
// fn main() { // fn main() {
// "Hello,<|> World!"; // "Hello,$0 World!";
// } // }
// ``` // ```
// -> // ->
@ -53,7 +53,7 @@ pub(crate) fn make_raw_string(acc: &mut Assists, ctx: &AssistContext) -> Option<
// //
// ``` // ```
// fn main() { // fn main() {
// r#"Hello,<|> "World!""#; // r#"Hello,$0 "World!""#;
// } // }
// ``` // ```
// -> // ->
@ -95,7 +95,7 @@ pub(crate) fn make_usual_string(acc: &mut Assists, ctx: &AssistContext) -> Optio
// //
// ``` // ```
// fn main() { // fn main() {
// r#"Hello,<|> World!"#; // r#"Hello,$0 World!"#;
// } // }
// ``` // ```
// -> // ->
@ -123,7 +123,7 @@ pub(crate) fn add_hash(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
// //
// ``` // ```
// fn main() { // fn main() {
// r#"Hello,<|> World!"#; // r#"Hello,$0 World!"#;
// } // }
// ``` // ```
// -> // ->
@ -194,7 +194,7 @@ mod tests {
make_raw_string, make_raw_string,
r#" r#"
fn f() { fn f() {
let s = <|>"random\nstring"; let s = $0"random\nstring";
} }
"#, "#,
r#""random\nstring""#, r#""random\nstring""#,
@ -207,7 +207,7 @@ mod tests {
make_raw_string, make_raw_string,
r#" r#"
fn f() { fn f() {
let s = <|>"random\nstring"; let s = $0"random\nstring";
} }
"#, "#,
r##" r##"
@ -225,7 +225,7 @@ string"#;
make_raw_string, make_raw_string,
r#" r#"
fn f() { fn f() {
format!(<|>"x = {}", 92) format!($0"x = {}", 92)
} }
"#, "#,
r##" r##"
@ -242,7 +242,7 @@ string"#;
make_raw_string, make_raw_string,
r###" r###"
fn f() { fn f() {
let s = <|>"#random##\nstring"; let s = $0"#random##\nstring";
} }
"###, "###,
r####" r####"
@ -260,7 +260,7 @@ string"#;
make_raw_string, make_raw_string,
r###" r###"
fn f() { fn f() {
let s = <|>"#random\"##\nstring"; let s = $0"#random\"##\nstring";
} }
"###, "###,
r####" r####"
@ -278,7 +278,7 @@ string"###;
make_raw_string, make_raw_string,
r#" r#"
fn f() { fn f() {
let s = <|>"random string"; let s = $0"random string";
} }
"#, "#,
r##" r##"
@ -295,7 +295,7 @@ string"###;
make_raw_string, make_raw_string,
r#" r#"
fn f() { fn f() {
let s = "foo<|> let s = "foo$0
} }
"#, "#,
) )
@ -307,7 +307,7 @@ string"###;
make_usual_string, make_usual_string,
r#" r#"
fn main() { fn main() {
let s = r#"bar<|> let s = r#"bar$0
} }
"#, "#,
) )
@ -319,7 +319,7 @@ string"###;
add_hash, add_hash,
r#" r#"
fn f() { fn f() {
let s = <|>r"random string"; let s = $0r"random string";
} }
"#, "#,
r#"r"random string""#, r#"r"random string""#,
@ -332,7 +332,7 @@ string"###;
add_hash, add_hash,
r#" r#"
fn f() { fn f() {
let s = <|>r"random string"; let s = $0r"random string";
} }
"#, "#,
r##" r##"
@ -349,7 +349,7 @@ string"###;
add_hash, add_hash,
r##" r##"
fn f() { fn f() {
let s = <|>r#"random"string"#; let s = $0r#"random"string"#;
} }
"##, "##,
r###" r###"
@ -366,7 +366,7 @@ string"###;
add_hash, add_hash,
r#" r#"
fn f() { fn f() {
let s = <|>"random string"; let s = $0"random string";
} }
"#, "#,
); );
@ -378,7 +378,7 @@ string"###;
remove_hash, remove_hash,
r##" r##"
fn f() { fn f() {
let s = <|>r#"random string"#; let s = $0r#"random string"#;
} }
"##, "##,
r##"r#"random string"#"##, r##"r#"random string"#"##,
@ -389,7 +389,7 @@ string"###;
fn remove_hash_works() { fn remove_hash_works() {
check_assist( check_assist(
remove_hash, remove_hash,
r##"fn f() { let s = <|>r#"random string"#; }"##, r##"fn f() { let s = $0r#"random string"#; }"##,
r#"fn f() { let s = r"random string"; }"#, r#"fn f() { let s = r"random string"; }"#,
) )
} }
@ -401,7 +401,7 @@ string"###;
remove_hash, remove_hash,
r##" r##"
fn f() { fn f() {
let s = <|>r#"random"str"ing"#; let s = $0r#"random"str"ing"#;
} }
"##, "##,
) )
@ -413,7 +413,7 @@ string"###;
remove_hash, remove_hash,
r###" r###"
fn f() { fn f() {
let s = <|>r##"random string"##; let s = $0r##"random string"##;
} }
"###, "###,
r##" r##"
@ -426,12 +426,12 @@ string"###;
#[test] #[test]
fn remove_hash_doesnt_work() { fn remove_hash_doesnt_work() {
check_assist_not_applicable(remove_hash, r#"fn f() { let s = <|>"random string"; }"#); check_assist_not_applicable(remove_hash, r#"fn f() { let s = $0"random string"; }"#);
} }
#[test] #[test]
fn remove_hash_no_hash_doesnt_work() { fn remove_hash_no_hash_doesnt_work() {
check_assist_not_applicable(remove_hash, r#"fn f() { let s = <|>r"random string"; }"#); check_assist_not_applicable(remove_hash, r#"fn f() { let s = $0r"random string"; }"#);
} }
#[test] #[test]
@ -440,7 +440,7 @@ string"###;
make_usual_string, make_usual_string,
r##" r##"
fn f() { fn f() {
let s = <|>r#"random string"#; let s = $0r#"random string"#;
} }
"##, "##,
r##"r#"random string"#"##, r##"r#"random string"#"##,
@ -453,7 +453,7 @@ string"###;
make_usual_string, make_usual_string,
r##" r##"
fn f() { fn f() {
let s = <|>r#"random string"#; let s = $0r#"random string"#;
} }
"##, "##,
r#" r#"
@ -470,7 +470,7 @@ string"###;
make_usual_string, make_usual_string,
r##" r##"
fn f() { fn f() {
let s = <|>r#"random"str"ing"#; let s = $0r#"random"str"ing"#;
} }
"##, "##,
r#" r#"
@ -487,7 +487,7 @@ string"###;
make_usual_string, make_usual_string,
r###" r###"
fn f() { fn f() {
let s = <|>r##"random string"##; let s = $0r##"random string"##;
} }
"###, "###,
r##" r##"
@ -504,7 +504,7 @@ string"###;
make_usual_string, make_usual_string,
r#" r#"
fn f() { fn f() {
let s = <|>"random string"; let s = $0"random string";
} }
"#, "#,
); );

View file

@ -11,7 +11,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// //
// ``` // ```
// fn main() { // fn main() {
// <|>dbg!(92); // $0dbg!(92);
// } // }
// ``` // ```
// -> // ->
@ -161,19 +161,19 @@ mod tests {
#[test] #[test]
fn test_remove_dbg() { fn test_remove_dbg() {
check_assist(remove_dbg, "<|>dbg!(1 + 1)", "1 + 1"); check_assist(remove_dbg, "$0dbg!(1 + 1)", "1 + 1");
check_assist(remove_dbg, "dbg!<|>((1 + 1))", "(1 + 1)"); check_assist(remove_dbg, "dbg!$0((1 + 1))", "(1 + 1)");
check_assist(remove_dbg, "dbg!(1 <|>+ 1)", "1 + 1"); check_assist(remove_dbg, "dbg!(1 $0+ 1)", "1 + 1");
check_assist(remove_dbg, "let _ = <|>dbg!(1 + 1)", "let _ = 1 + 1"); check_assist(remove_dbg, "let _ = $0dbg!(1 + 1)", "let _ = 1 + 1");
check_assist( check_assist(
remove_dbg, remove_dbg,
" "
fn foo(n: usize) { fn foo(n: usize) {
if let Some(_) = dbg!(n.<|>checked_sub(4)) { if let Some(_) = dbg!(n.$0checked_sub(4)) {
// ... // ...
} }
} }
@ -187,20 +187,20 @@ fn foo(n: usize) {
", ",
); );
check_assist(remove_dbg, "<|>dbg!(Foo::foo_test()).bar()", "Foo::foo_test().bar()"); check_assist(remove_dbg, "$0dbg!(Foo::foo_test()).bar()", "Foo::foo_test().bar()");
} }
#[test] #[test]
fn test_remove_dbg_with_brackets_and_braces() { fn test_remove_dbg_with_brackets_and_braces() {
check_assist(remove_dbg, "dbg![<|>1 + 1]", "1 + 1"); check_assist(remove_dbg, "dbg![$01 + 1]", "1 + 1");
check_assist(remove_dbg, "dbg!{<|>1 + 1}", "1 + 1"); check_assist(remove_dbg, "dbg!{$01 + 1}", "1 + 1");
} }
#[test] #[test]
fn test_remove_dbg_not_applicable() { fn test_remove_dbg_not_applicable() {
check_assist_not_applicable(remove_dbg, "<|>vec![1, 2, 3]"); check_assist_not_applicable(remove_dbg, "$0vec![1, 2, 3]");
check_assist_not_applicable(remove_dbg, "<|>dbg(5, 6, 7)"); check_assist_not_applicable(remove_dbg, "$0dbg(5, 6, 7)");
check_assist_not_applicable(remove_dbg, "<|>dbg!(5, 6, 7"); check_assist_not_applicable(remove_dbg, "$0dbg!(5, 6, 7");
} }
#[test] #[test]
@ -209,7 +209,7 @@ fn foo(n: usize) {
remove_dbg, remove_dbg,
" "
fn foo(n: usize) { fn foo(n: usize) {
if let Some(_) = dbg!(n.<|>checked_sub(4)) { if let Some(_) = dbg!(n.$0checked_sub(4)) {
// ... // ...
} }
} }
@ -226,7 +226,7 @@ fn foo(n: usize) {
// the ast::MacroCall to include the semicolon at the end // the ast::MacroCall to include the semicolon at the end
check_assist( check_assist(
remove_dbg, remove_dbg,
r#"let res = <|>dbg!(1 * 20); // needless comment"#, r#"let res = $0dbg!(1 * 20); // needless comment"#,
r#"let res = 1 * 20; // needless comment"#, r#"let res = 1 * 20; // needless comment"#,
); );
} }
@ -238,7 +238,7 @@ fn foo(n: usize) {
" "
fn main() { fn main() {
let mut a = 1; let mut a = 1;
while dbg!<|>(a) < 10000 { while dbg!$0(a) < 10000 {
a += 1; a += 1;
} }
} }
@ -258,31 +258,31 @@ fn main() {
fn test_remove_dbg_keep_expression() { fn test_remove_dbg_keep_expression() {
check_assist( check_assist(
remove_dbg, remove_dbg,
r#"let res = <|>dbg!(a + b).foo();"#, r#"let res = $0dbg!(a + b).foo();"#,
r#"let res = (a + b).foo();"#, r#"let res = (a + b).foo();"#,
); );
check_assist(remove_dbg, r#"let res = <|>dbg!(2 + 2) * 5"#, r#"let res = (2 + 2) * 5"#); check_assist(remove_dbg, r#"let res = $0dbg!(2 + 2) * 5"#, r#"let res = (2 + 2) * 5"#);
check_assist(remove_dbg, r#"let res = <|>dbg![2 + 2] * 5"#, r#"let res = (2 + 2) * 5"#); check_assist(remove_dbg, r#"let res = $0dbg![2 + 2] * 5"#, r#"let res = (2 + 2) * 5"#);
} }
#[test] #[test]
fn test_remove_dbg_method_chaining() { fn test_remove_dbg_method_chaining() {
check_assist( check_assist(
remove_dbg, remove_dbg,
r#"let res = <|>dbg!(foo().bar()).baz();"#, r#"let res = $0dbg!(foo().bar()).baz();"#,
r#"let res = foo().bar().baz();"#, r#"let res = foo().bar().baz();"#,
); );
check_assist( check_assist(
remove_dbg, remove_dbg,
r#"let res = <|>dbg!(foo.bar()).baz();"#, r#"let res = $0dbg!(foo.bar()).baz();"#,
r#"let res = foo.bar().baz();"#, r#"let res = foo.bar().baz();"#,
); );
} }
#[test] #[test]
fn test_remove_dbg_field_chaining() { fn test_remove_dbg_field_chaining() {
check_assist(remove_dbg, r#"let res = <|>dbg!(foo.bar).baz;"#, r#"let res = foo.bar.baz;"#); check_assist(remove_dbg, r#"let res = $0dbg!(foo.bar).baz;"#, r#"let res = foo.bar.baz;"#);
} }
#[test] #[test]
@ -295,7 +295,7 @@ fn square(x: u32) -> u32 {
} }
fn main() { fn main() {
let x = square(dbg<|>!(5 + 10)); let x = square(dbg$0!(5 + 10));
println!("{}", x); println!("{}", x);
}"#, }"#,
"dbg!(5 + 10)", "dbg!(5 + 10)",
@ -309,7 +309,7 @@ fn square(x: u32) -> u32 {
} }
fn main() { fn main() {
let x = square(dbg<|>!(5 + 10)); let x = square(dbg$0!(5 + 10));
println!("{}", x); println!("{}", x);
}"#, }"#,
r#" r#"
@ -328,7 +328,7 @@ fn main() {
fn test_remove_dbg_try_expr() { fn test_remove_dbg_try_expr() {
check_assist( check_assist(
remove_dbg, remove_dbg,
r#"let res = <|>dbg!(result?).foo();"#, r#"let res = $0dbg!(result?).foo();"#,
r#"let res = result?.foo();"#, r#"let res = result?.foo();"#,
); );
} }
@ -337,7 +337,7 @@ fn main() {
fn test_remove_dbg_await_expr() { fn test_remove_dbg_await_expr() {
check_assist( check_assist(
remove_dbg, remove_dbg,
r#"let res = <|>dbg!(fut.await).foo();"#, r#"let res = $0dbg!(fut.await).foo();"#,
r#"let res = fut.await.foo();"#, r#"let res = fut.await.foo();"#,
); );
} }
@ -346,7 +346,7 @@ fn main() {
fn test_remove_dbg_as_cast() { fn test_remove_dbg_as_cast() {
check_assist( check_assist(
remove_dbg, remove_dbg,
r#"let res = <|>dbg!(3 as usize).foo();"#, r#"let res = $0dbg!(3 as usize).foo();"#,
r#"let res = (3 as usize).foo();"#, r#"let res = (3 as usize).foo();"#,
); );
} }
@ -355,12 +355,12 @@ fn main() {
fn test_remove_dbg_index_expr() { fn test_remove_dbg_index_expr() {
check_assist( check_assist(
remove_dbg, remove_dbg,
r#"let res = <|>dbg!(array[3]).foo();"#, r#"let res = $0dbg!(array[3]).foo();"#,
r#"let res = array[3].foo();"#, r#"let res = array[3].foo();"#,
); );
check_assist( check_assist(
remove_dbg, remove_dbg,
r#"let res = <|>dbg!(tuple.3).foo();"#, r#"let res = $0dbg!(tuple.3).foo();"#,
r#"let res = tuple.3.foo();"#, r#"let res = tuple.3.foo();"#,
); );
} }
@ -369,12 +369,12 @@ fn main() {
fn test_remove_dbg_range_expr() { fn test_remove_dbg_range_expr() {
check_assist( check_assist(
remove_dbg, remove_dbg,
r#"let res = <|>dbg!(foo..bar).foo();"#, r#"let res = $0dbg!(foo..bar).foo();"#,
r#"let res = (foo..bar).foo();"#, r#"let res = (foo..bar).foo();"#,
); );
check_assist( check_assist(
remove_dbg, remove_dbg,
r#"let res = <|>dbg!(foo..=bar).foo();"#, r#"let res = $0dbg!(foo..=bar).foo();"#,
r#"let res = (foo..=bar).foo();"#, r#"let res = (foo..=bar).foo();"#,
); );
} }
@ -384,7 +384,7 @@ fn main() {
check_assist( check_assist(
remove_dbg, remove_dbg,
r#"fn foo() { r#"fn foo() {
if <|>dbg!(x || y) {} if $0dbg!(x || y) {}
}"#, }"#,
r#"fn foo() { r#"fn foo() {
if x || y {} if x || y {}
@ -393,7 +393,7 @@ fn main() {
check_assist( check_assist(
remove_dbg, remove_dbg,
r#"fn foo() { r#"fn foo() {
while let foo = <|>dbg!(&x) {} while let foo = $0dbg!(&x) {}
}"#, }"#,
r#"fn foo() { r#"fn foo() {
while let foo = &x {} while let foo = &x {}
@ -402,7 +402,7 @@ fn main() {
check_assist( check_assist(
remove_dbg, remove_dbg,
r#"fn foo() { r#"fn foo() {
if let foo = <|>dbg!(&x) {} if let foo = $0dbg!(&x) {}
}"#, }"#,
r#"fn foo() { r#"fn foo() {
if let foo = &x {} if let foo = &x {}
@ -411,7 +411,7 @@ fn main() {
check_assist( check_assist(
remove_dbg, remove_dbg,
r#"fn foo() { r#"fn foo() {
match <|>dbg!(&x) {} match $0dbg!(&x) {}
}"#, }"#,
r#"fn foo() { r#"fn foo() {
match &x {} match &x {}

View file

@ -8,7 +8,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// //
// ``` // ```
// impl Walrus { // impl Walrus {
// fn feed(&mut<|> self, amount: u32) {} // fn feed(&mut$0 self, amount: u32) {}
// } // }
// ``` // ```
// -> // ->

View file

@ -16,7 +16,7 @@ use crate::{
// Removes unused function parameter. // Removes unused function parameter.
// //
// ``` // ```
// fn frobnicate(x: i32<|>) {} // fn frobnicate(x: i32$0) {}
// //
// fn main() { // fn main() {
// frobnicate(92); // frobnicate(92);
@ -123,7 +123,7 @@ mod tests {
remove_unused_param, remove_unused_param,
r#" r#"
fn a() { foo(9, 2) } fn a() { foo(9, 2) }
fn foo(x: i32, <|>y: i32) { x; } fn foo(x: i32, $0y: i32) { x; }
fn b() { foo(9, 2,) } fn b() { foo(9, 2,) }
"#, "#,
r#" r#"
@ -139,7 +139,7 @@ fn b() { foo(9, ) }
check_assist( check_assist(
remove_unused_param, remove_unused_param,
r#" r#"
fn foo(<|>x: i32, y: i32) { y; } fn foo($0x: i32, y: i32) { y; }
fn a() { foo(1, 2) } fn a() { foo(1, 2) }
fn b() { foo(1, 2,) } fn b() { foo(1, 2,) }
"#, "#,
@ -156,7 +156,7 @@ fn b() { foo(2,) }
check_assist( check_assist(
remove_unused_param, remove_unused_param,
r#" r#"
fn foo(<|>x: i32) { 0; } fn foo($0x: i32) { 0; }
fn a() { foo(1) } fn a() { foo(1) }
fn b() { foo(1, ) } fn b() { foo(1, ) }
"#, "#,
@ -173,7 +173,7 @@ fn b() { foo( ) }
check_assist( check_assist(
remove_unused_param, remove_unused_param,
r#" r#"
fn foo(x: i32, <|>y: i32, z: i32) { x; } fn foo(x: i32, $0y: i32, z: i32) { x; }
fn a() { foo(1, 2, 3) } fn a() { foo(1, 2, 3) }
fn b() { foo(1, 2, 3,) } fn b() { foo(1, 2, 3,) }
"#, "#,
@ -190,7 +190,7 @@ fn b() { foo(1, 3,) }
check_assist( check_assist(
remove_unused_param, remove_unused_param,
r#" r#"
mod bar { pub fn foo(x: i32, <|>y: i32) { x; } } mod bar { pub fn foo(x: i32, $0y: i32) { x; } }
fn b() { bar::foo(9, 2) } fn b() { bar::foo(9, 2) }
"#, "#,
r#" r#"
@ -205,7 +205,7 @@ fn b() { bar::foo(9) }
check_assist( check_assist(
remove_unused_param, remove_unused_param,
r#" r#"
pub fn foo<T>(x: T, <|>y: i32) { x; } pub fn foo<T>(x: T, $0y: i32) { x; }
fn b() { foo::<i32>(9, 2) } fn b() { foo::<i32>(9, 2) }
"#, "#,
r#" r#"
@ -220,7 +220,7 @@ fn b() { foo::<i32>(9) }
check_assist( check_assist(
remove_unused_param, remove_unused_param,
r#" r#"
pub fn foo<T>(x: i32, <|>y: T) { x; } pub fn foo<T>(x: i32, $0y: T) { x; }
fn b() { foo::<i32>(9, 2) } fn b() { foo::<i32>(9, 2) }
fn b2() { foo(9, 2) } fn b2() { foo(9, 2) }
"#, "#,
@ -238,7 +238,7 @@ fn b2() { foo(9) }
check_assist_not_applicable( check_assist_not_applicable(
remove_unused_param, remove_unused_param,
r#" r#"
fn foo(x: i32, <|>y: i32) { y; } fn foo(x: i32, $0y: i32) { y; }
fn main() { foo(9, 2) } fn main() { foo(9, 2) }
"#, "#,
); );
@ -250,7 +250,7 @@ fn main() { foo(9, 2) }
remove_unused_param, remove_unused_param,
r#" r#"
//- /main.rs //- /main.rs
fn foo(x: i32, <|>y: i32) { x; } fn foo(x: i32, $0y: i32) { x; }
mod foo; mod foo;

View file

@ -15,7 +15,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// //
// ``` // ```
// struct Foo {foo: i32, bar: i32}; // struct Foo {foo: i32, bar: i32};
// const test: Foo = <|>Foo {bar: 0, foo: 1} // const test: Foo = $0Foo {bar: 0, foo: 1}
// ``` // ```
// -> // ->
// ``` // ```
@ -126,7 +126,7 @@ struct Foo {
bar: i32, bar: i32,
} }
const test: Foo = <|>Foo { foo: 0, bar: 0 }; const test: Foo = $0Foo { foo: 0, bar: 0 };
"#, "#,
) )
} }
@ -137,7 +137,7 @@ const test: Foo = <|>Foo { foo: 0, bar: 0 };
reorder_fields, reorder_fields,
r#" r#"
struct Foo {}; struct Foo {};
const test: Foo = <|>Foo {} const test: Foo = $0Foo {}
"#, "#,
) )
} }
@ -148,7 +148,7 @@ const test: Foo = <|>Foo {}
reorder_fields, reorder_fields,
r#" r#"
struct Foo {foo: i32, bar: i32}; struct Foo {foo: i32, bar: i32};
const test: Foo = <|>Foo {bar: 0, foo: 1} const test: Foo = $0Foo {bar: 0, foo: 1}
"#, "#,
r#" r#"
struct Foo {foo: i32, bar: i32}; struct Foo {foo: i32, bar: i32};
@ -166,7 +166,7 @@ struct Foo { foo: i64, bar: i64, baz: i64 }
fn f(f: Foo) -> { fn f(f: Foo) -> {
match f { match f {
<|>Foo { baz: 0, ref mut bar, .. } => (), $0Foo { baz: 0, ref mut bar, .. } => (),
_ => () _ => ()
} }
} }
@ -197,7 +197,7 @@ struct Foo {
impl Foo { impl Foo {
fn new() -> Foo { fn new() -> Foo {
let foo = String::new(); let foo = String::new();
<|>Foo { $0Foo {
bar: foo.clone(), bar: foo.clone(),
extra: "Extra field", extra: "Extra field",
foo, foo,

View file

@ -22,7 +22,7 @@ use crate::{
// //
// ``` // ```
// # trait Debug { fn fmt(&self, f: &mut Formatter) -> Result<()>; } // # trait Debug { fn fmt(&self, f: &mut Formatter) -> Result<()>; }
// #[derive(Deb<|>ug, Display)] // #[derive(Deb$0ug, Display)]
// struct S; // struct S;
// ``` // ```
// -> // ->
@ -219,7 +219,7 @@ mod fmt {
} }
} }
#[derive(Debu<|>g)] #[derive(Debu$0g)]
struct Foo { struct Foo {
bar: String, bar: String,
} }
@ -261,7 +261,7 @@ mod foo {
} }
} }
#[derive(<|>Bar)] #[derive($0Bar)]
struct Foo { struct Foo {
bar: String, bar: String,
} }
@ -300,7 +300,7 @@ impl foo::Bar for Foo {
check_assist( check_assist(
replace_derive_with_manual_impl, replace_derive_with_manual_impl,
" "
#[derive(Debu<|>g)] #[derive(Debu$0g)]
struct Foo { struct Foo {
bar: String, bar: String,
} }
@ -322,7 +322,7 @@ impl Debug for Foo {
check_assist( check_assist(
replace_derive_with_manual_impl, replace_derive_with_manual_impl,
" "
#[derive(Debug<|>)] #[derive(Debug$0)]
pub struct Foo { pub struct Foo {
bar: String, bar: String,
} }
@ -344,7 +344,7 @@ impl Debug for Foo {
check_assist( check_assist(
replace_derive_with_manual_impl, replace_derive_with_manual_impl,
" "
#[derive(Display, Debug<|>, Serialize)] #[derive(Display, Debug$0, Serialize)]
struct Foo {} struct Foo {}
", ",
" "
@ -363,7 +363,7 @@ impl Debug for Foo {
check_assist_not_applicable( check_assist_not_applicable(
replace_derive_with_manual_impl, replace_derive_with_manual_impl,
" "
#[derive(<|>)] #[derive($0)]
struct Foo {} struct Foo {}
", ",
) )
@ -374,7 +374,7 @@ struct Foo {}
check_assist_not_applicable( check_assist_not_applicable(
replace_derive_with_manual_impl, replace_derive_with_manual_impl,
" "
#[derive<|>(Debug)] #[derive$0(Debug)]
struct Foo {} struct Foo {}
", ",
); );
@ -382,7 +382,7 @@ struct Foo {}
check_assist_not_applicable( check_assist_not_applicable(
replace_derive_with_manual_impl, replace_derive_with_manual_impl,
" "
#[derive(Debug)<|>] #[derive(Debug)$0]
struct Foo {} struct Foo {}
", ",
) )
@ -393,7 +393,7 @@ struct Foo {}
check_assist_not_applicable( check_assist_not_applicable(
replace_derive_with_manual_impl, replace_derive_with_manual_impl,
" "
#[allow(non_camel_<|>case_types)] #[allow(non_camel_$0case_types)]
struct Foo {} struct Foo {}
", ",
) )

View file

@ -20,7 +20,7 @@ use crate::{utils::unwrap_trivial_block, AssistContext, AssistId, AssistKind, As
// enum Action { Move { distance: u32 }, Stop } // enum Action { Move { distance: u32 }, Stop }
// //
// fn handle(action: Action) { // fn handle(action: Action) {
// <|>if let Action::Move { distance } = action { // $0if let Action::Move { distance } = action {
// foo(distance) // foo(distance)
// } else { // } else {
// bar() // bar()
@ -89,7 +89,7 @@ pub(crate) fn replace_if_let_with_match(acc: &mut Assists, ctx: &AssistContext)
// enum Action { Move { distance: u32 }, Stop } // enum Action { Move { distance: u32 }, Stop }
// //
// fn handle(action: Action) { // fn handle(action: Action) {
// <|>match action { // $0match action {
// Action::Move { distance } => foo(distance), // Action::Move { distance } => foo(distance),
// _ => bar(), // _ => bar(),
// } // }
@ -179,7 +179,7 @@ mod tests {
r#" r#"
impl VariantData { impl VariantData {
pub fn is_struct(&self) -> bool { pub fn is_struct(&self) -> bool {
if <|>let VariantData::Struct(..) = *self { if $0let VariantData::Struct(..) = *self {
true true
} else { } else {
false false
@ -204,7 +204,7 @@ impl VariantData {
replace_if_let_with_match, replace_if_let_with_match,
r#" r#"
fn foo() { fn foo() {
if <|>let VariantData::Struct(..) = a { if $0let VariantData::Struct(..) = a {
bar( bar(
123 123
) )
@ -233,7 +233,7 @@ fn foo() {
r#" r#"
impl VariantData { impl VariantData {
pub fn is_struct(&self) -> bool { pub fn is_struct(&self) -> bool {
if <|>let VariantData::Struct(..) = *self { if $0let VariantData::Struct(..) = *self {
true true
} else { } else {
false false
@ -257,7 +257,7 @@ enum Option<T> { Some(T), None }
use Option::*; use Option::*;
fn foo(x: Option<i32>) { fn foo(x: Option<i32>) {
<|>if let Some(x) = x { $0if let Some(x) = x {
println!("{}", x) println!("{}", x)
} else { } else {
println!("none") println!("none")
@ -287,7 +287,7 @@ enum Result<T, E> { Ok(T), Err(E) }
use Result::*; use Result::*;
fn foo(x: Result<i32, ()>) { fn foo(x: Result<i32, ()>) {
<|>if let Ok(x) = x { $0if let Ok(x) = x {
println!("{}", x) println!("{}", x)
} else { } else {
println!("none") println!("none")
@ -315,7 +315,7 @@ fn foo(x: Result<i32, ()>) {
r#" r#"
fn main() { fn main() {
if true { if true {
<|>if let Ok(rel_path) = path.strip_prefix(root_path) { $0if let Ok(rel_path) = path.strip_prefix(root_path) {
let rel_path = RelativePathBuf::from_path(rel_path).ok()?; let rel_path = RelativePathBuf::from_path(rel_path).ok()?;
Some((*id, rel_path)) Some((*id, rel_path))
} else { } else {
@ -347,7 +347,7 @@ fn main() {
r#" r#"
impl VariantData { impl VariantData {
pub fn is_struct(&self) -> bool { pub fn is_struct(&self) -> bool {
<|>match *self { $0match *self {
VariantData::Struct(..) => true, VariantData::Struct(..) => true,
_ => false, _ => false,
} }
@ -372,7 +372,7 @@ impl VariantData {
replace_match_with_if_let, replace_match_with_if_let,
r#" r#"
fn foo() { fn foo() {
<|>match a { $0match a {
VariantData::Struct(..) => { VariantData::Struct(..) => {
bar( bar(
123 123
@ -401,7 +401,7 @@ fn foo() {
r#" r#"
impl VariantData { impl VariantData {
pub fn is_struct(&self) -> bool { pub fn is_struct(&self) -> bool {
<|>match *self { $0match *self {
VariantData::Struct(..) => true, VariantData::Struct(..) => true,
_ => false, _ => false,
} }
@ -423,7 +423,7 @@ enum Option<T> { Some(T), None }
use Option::*; use Option::*;
fn foo(x: Option<i32>) { fn foo(x: Option<i32>) {
<|>match x { $0match x {
Some(x) => println!("{}", x), Some(x) => println!("{}", x),
None => println!("none"), None => println!("none"),
} }
@ -453,7 +453,7 @@ enum Result<T, E> { Ok(T), Err(E) }
use Result::*; use Result::*;
fn foo(x: Result<i32, ()>) { fn foo(x: Result<i32, ()>) {
<|>match x { $0match x {
Ok(x) => println!("{}", x), Ok(x) => println!("{}", x),
Err(_) => println!("none"), Err(_) => println!("none"),
} }
@ -481,7 +481,7 @@ fn foo(x: Result<i32, ()>) {
r#" r#"
fn main() { fn main() {
if true { if true {
<|>match path.strip_prefix(root_path) { $0match path.strip_prefix(root_path) {
Ok(rel_path) => { Ok(rel_path) => {
let rel_path = RelativePathBuf::from_path(rel_path).ok()?; let rel_path = RelativePathBuf::from_path(rel_path).ok()?;
Some((*id, rel_path)) Some((*id, rel_path))
@ -512,7 +512,7 @@ fn main() {
replace_match_with_if_let, replace_match_with_if_let,
r#" r#"
fn main() { fn main() {
<|>match path.strip_prefix(root_path) { $0match path.strip_prefix(root_path) {
Ok(rel_path) => println!("{}", rel_path), Ok(rel_path) => println!("{}", rel_path),
_ => (), _ => (),
} }

View file

@ -7,7 +7,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// Replaces `impl Trait` function argument with the named generic. // Replaces `impl Trait` function argument with the named generic.
// //
// ``` // ```
// fn foo(bar: <|>impl Bar) {} // fn foo(bar: $0impl Bar) {}
// ``` // ```
// -> // ->
// ``` // ```
@ -56,7 +56,7 @@ mod tests {
check_assist( check_assist(
replace_impl_trait_with_generic, replace_impl_trait_with_generic,
r#" r#"
fn foo<G>(bar: <|>impl Bar) {} fn foo<G>(bar: $0impl Bar) {}
"#, "#,
r#" r#"
fn foo<G, B: Bar>(bar: B) {} fn foo<G, B: Bar>(bar: B) {}
@ -69,7 +69,7 @@ mod tests {
check_assist( check_assist(
replace_impl_trait_with_generic, replace_impl_trait_with_generic,
r#" r#"
fn foo(bar: <|>impl Bar) {} fn foo(bar: $0impl Bar) {}
"#, "#,
r#" r#"
fn foo<B: Bar>(bar: B) {} fn foo<B: Bar>(bar: B) {}
@ -82,7 +82,7 @@ mod tests {
check_assist( check_assist(
replace_impl_trait_with_generic, replace_impl_trait_with_generic,
r#" r#"
fn foo<G>(foo: impl Foo, bar: <|>impl Bar) {} fn foo<G>(foo: impl Foo, bar: $0impl Bar) {}
"#, "#,
r#" r#"
fn foo<G, B: Bar>(foo: impl Foo, bar: B) {} fn foo<G, B: Bar>(foo: impl Foo, bar: B) {}
@ -95,7 +95,7 @@ mod tests {
check_assist( check_assist(
replace_impl_trait_with_generic, replace_impl_trait_with_generic,
r#" r#"
fn foo<>(bar: <|>impl Bar) {} fn foo<>(bar: $0impl Bar) {}
"#, "#,
r#" r#"
fn foo<B: Bar>(bar: B) {} fn foo<B: Bar>(bar: B) {}
@ -109,7 +109,7 @@ mod tests {
replace_impl_trait_with_generic, replace_impl_trait_with_generic,
r#" r#"
fn foo< fn foo<
>(bar: <|>impl Bar) {} >(bar: $0impl Bar) {}
"#, "#,
r#" r#"
fn foo<B: Bar fn foo<B: Bar
@ -124,7 +124,7 @@ mod tests {
check_assist( check_assist(
replace_impl_trait_with_generic, replace_impl_trait_with_generic,
r#" r#"
fn foo<B>(bar: <|>impl Bar) {} fn foo<B>(bar: $0impl Bar) {}
"#, "#,
r#" r#"
fn foo<B, C: Bar>(bar: C) {} fn foo<B, C: Bar>(bar: C) {}
@ -141,7 +141,7 @@ mod tests {
G: Foo, G: Foo,
F, F,
H, H,
>(bar: <|>impl Bar) {} >(bar: $0impl Bar) {}
"#, "#,
r#" r#"
fn foo< fn foo<
@ -158,7 +158,7 @@ mod tests {
check_assist( check_assist(
replace_impl_trait_with_generic, replace_impl_trait_with_generic,
r#" r#"
fn foo(bar: <|>impl Foo + Bar) {} fn foo(bar: $0impl Foo + Bar) {}
"#, "#,
r#" r#"
fn foo<F: Foo + Bar>(bar: F) {} fn foo<F: Foo + Bar>(bar: F) {}

View file

@ -20,7 +20,7 @@ use ide_db::ty_filter::TryEnum;
// # enum Option<T> { Some(T), None } // # enum Option<T> { Some(T), None }
// //
// fn main(action: Action) { // fn main(action: Action) {
// <|>let x = compute(); // $0let x = compute();
// } // }
// //
// fn compute() -> Option<i32> { None } // fn compute() -> Option<i32> { None }
@ -85,7 +85,7 @@ mod tests {
enum E<T> { X(T), Y(T) } enum E<T> { X(T), Y(T) }
fn main() { fn main() {
<|>let x = E::X(92); $0let x = E::X(92);
} }
", ",
r" r"

View file

@ -9,7 +9,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// Adds a use statement for a given fully-qualified name. // Adds a use statement for a given fully-qualified name.
// //
// ``` // ```
// fn process(map: std::collections::<|>HashMap<String, String>) {} // fn process(map: std::collections::$0HashMap<String, String>) {}
// ``` // ```
// -> // ->
// ``` // ```
@ -127,7 +127,7 @@ mod tests {
r"use std::fs; r"use std::fs;
fn main() { fn main() {
std::f<|>s::Path std::f$0s::Path
}", }",
r"use std::fs; r"use std::fs;
@ -142,7 +142,7 @@ fn main() {
check_assist( check_assist(
replace_qualified_name_with_use, replace_qualified_name_with_use,
r" r"
std::fmt::Debug<|> std::fmt::Debug$0
", ",
r" r"
use std::fmt::Debug; use std::fmt::Debug;
@ -156,7 +156,7 @@ Debug
check_assist( check_assist(
replace_qualified_name_with_use, replace_qualified_name_with_use,
r" r"
std::fmt::Debug<|> std::fmt::Debug$0
fn main() { fn main() {
} }
@ -180,7 +180,7 @@ fn main() {
fn main() { fn main() {
} }
std::fmt::Debug<|> std::fmt::Debug$0
", ",
r" r"
use std::fmt::Debug; use std::fmt::Debug;
@ -198,7 +198,7 @@ Debug
check_assist( check_assist(
replace_qualified_name_with_use, replace_qualified_name_with_use,
r" r"
std::fmt<|>::Debug std::fmt$0::Debug
", ",
r" r"
use std::fmt; use std::fmt;
@ -215,7 +215,7 @@ fmt::Debug
r" r"
use stdx; use stdx;
impl std::fmt::Debug<|> for Foo { impl std::fmt::Debug$0 for Foo {
} }
", ",
r" r"
@ -234,7 +234,7 @@ impl Debug for Foo {
check_assist( check_assist(
replace_qualified_name_with_use, replace_qualified_name_with_use,
r" r"
impl std::fmt::Debug<|> for Foo { impl std::fmt::Debug$0 for Foo {
} }
", ",
r" r"
@ -251,7 +251,7 @@ impl Debug for Foo {
check_assist( check_assist(
replace_qualified_name_with_use, replace_qualified_name_with_use,
r" r"
impl std::fmt::Debug<|> for Foo { impl std::fmt::Debug$0 for Foo {
} }
", ",
r" r"
@ -270,7 +270,7 @@ impl Debug for Foo {
r" r"
use std::fmt; use std::fmt;
impl std::io<|> for Foo { impl std::io$0 for Foo {
} }
", ",
r" r"
@ -289,7 +289,7 @@ impl io for Foo {
r" r"
use std::fmt; use std::fmt;
impl std::fmt::Debug<|> for Foo { impl std::fmt::Debug$0 for Foo {
} }
", ",
r" r"
@ -308,7 +308,7 @@ impl Debug for Foo {
r" r"
use std::fmt::Debug; use std::fmt::Debug;
impl std::fmt<|> for Foo { impl std::fmt$0 for Foo {
} }
", ",
r" r"
@ -327,7 +327,7 @@ impl fmt for Foo {
r" r"
use std::fmt::{Debug, nested::{Display}}; use std::fmt::{Debug, nested::{Display}};
impl std::fmt::nested<|> for Foo { impl std::fmt::nested$0 for Foo {
} }
", ",
r" r"
@ -346,7 +346,7 @@ impl nested for Foo {
r" r"
use std::fmt::{Debug, nested::{self, Display}}; use std::fmt::{Debug, nested::{self, Display}};
impl std::fmt::nested<|> for Foo { impl std::fmt::nested$0 for Foo {
} }
", ",
r" r"
@ -365,7 +365,7 @@ impl nested for Foo {
r" r"
use std::fmt::{Debug, nested::{Display}}; use std::fmt::{Debug, nested::{Display}};
impl std::fmt::nested::Debug<|> for Foo { impl std::fmt::nested::Debug$0 for Foo {
} }
", ",
r" r"
@ -384,7 +384,7 @@ impl Debug for Foo {
r" r"
use std::fmt::Debug; use std::fmt::Debug;
impl std::fmt::nested::Display<|> for Foo { impl std::fmt::nested::Display$0 for Foo {
} }
", ",
r" r"
@ -403,7 +403,7 @@ impl Display for Foo {
r" r"
use std::fmt::nested::Debug; use std::fmt::nested::Debug;
impl std::fmt::Display<|> for Foo { impl std::fmt::Display$0 for Foo {
} }
", ",
r" r"
@ -425,7 +425,7 @@ use crate::{
AssocItem, AssocItem,
}; };
fn foo() { crate::ty::lower<|>::trait_env() } fn foo() { crate::ty::lower$0::trait_env() }
", ",
r" r"
use crate::{AssocItem, ty::{Substs, Ty, lower}}; use crate::{AssocItem, ty::{Substs, Ty, lower}};
@ -442,7 +442,7 @@ fn foo() { lower::trait_env() }
r" r"
use std::fmt as foo; use std::fmt as foo;
impl foo::Debug<|> for Foo { impl foo::Debug$0 for Foo {
} }
", ",
r" r"
@ -462,7 +462,7 @@ impl Debug for Foo {
check_assist_not_applicable( check_assist_not_applicable(
replace_qualified_name_with_use, replace_qualified_name_with_use,
r" r"
impl foo<|> for Foo { impl foo$0 for Foo {
} }
", ",
); );
@ -473,7 +473,7 @@ impl foo<|> for Foo {
check_assist_not_applicable( check_assist_not_applicable(
replace_qualified_name_with_use, replace_qualified_name_with_use,
r" r"
use std::fmt<|>; use std::fmt$0;
", ",
); );
} }
@ -485,7 +485,7 @@ use std::fmt<|>;
r" r"
mod foo { mod foo {
mod bar { mod bar {
std::fmt::Debug<|> std::fmt::Debug$0
} }
} }
", ",
@ -509,7 +509,7 @@ mod foo {
#![allow(dead_code)] #![allow(dead_code)]
fn main() { fn main() {
std::fmt::Debug<|> std::fmt::Debug$0
} }
", ",
r" r"
@ -530,7 +530,7 @@ fn main() {
replace_qualified_name_with_use, replace_qualified_name_with_use,
r" r"
fn main() { fn main() {
std::fmt::Debug<|>; std::fmt::Debug$0;
let x: std::fmt::Debug = std::fmt::Debug; let x: std::fmt::Debug = std::fmt::Debug;
} }
", ",
@ -552,7 +552,7 @@ fn main() {
r" r"
mod m { mod m {
fn f() { fn f() {
std::fmt::Debug<|>; std::fmt::Debug$0;
let x: std::fmt::Debug = std::fmt::Debug; let x: std::fmt::Debug = std::fmt::Debug;
} }
fn g() { fn g() {
@ -590,7 +590,7 @@ fn f() {
replace_qualified_name_with_use, replace_qualified_name_with_use,
r" r"
fn main() { fn main() {
std::fmt::Debug<|>; std::fmt::Debug$0;
} }
mod sub { mod sub {
@ -623,7 +623,7 @@ mod sub {
use std::fmt::Display; use std::fmt::Display;
fn main() { fn main() {
std::fmt<|>; std::fmt$0;
} }
", ",
r" r"
@ -643,7 +643,7 @@ fn main() {
r" r"
pub use std::fmt; pub use std::fmt;
impl std::io<|> for Foo { impl std::io$0 for Foo {
} }
", ",
r" r"
@ -663,7 +663,7 @@ impl io for Foo {
r" r"
pub(crate) use std::fmt; pub(crate) use std::fmt;
impl std::io<|> for Foo { impl std::io$0 for Foo {
} }
", ",
r" r"

View file

@ -8,7 +8,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// //
// ``` // ```
// fn main() { // fn main() {
// find("{<|>"); // find("{$0");
// } // }
// ``` // ```
// -> // ->
@ -48,7 +48,7 @@ mod tests {
replace_string_with_char, replace_string_with_char,
r#" r#"
fn f() { fn f() {
let s = "<|>c"; let s = "$0c";
} }
"#, "#,
r#""c""#, r#""c""#,
@ -61,7 +61,7 @@ mod tests {
replace_string_with_char, replace_string_with_char,
r#" r#"
fn f() { fn f() {
let s = "<|>c"; let s = "$0c";
} }
"#, "#,
r##" r##"
@ -78,7 +78,7 @@ mod tests {
replace_string_with_char, replace_string_with_char,
r#" r#"
fn f() { fn f() {
let s = "<|>😀"; let s = "$0😀";
} }
"#, "#,
r##" r##"
@ -95,7 +95,7 @@ mod tests {
replace_string_with_char, replace_string_with_char,
r#" r#"
fn f() { fn f() {
let s = "<|>test"; let s = "$0test";
} }
"#, "#,
) )
@ -107,7 +107,7 @@ mod tests {
replace_string_with_char, replace_string_with_char,
r#" r#"
fn f() { fn f() {
format!(<|>"x", 92) format!($0"x", 92)
} }
"#, "#,
r##" r##"
@ -124,7 +124,7 @@ mod tests {
replace_string_with_char, replace_string_with_char,
r#" r#"
fn f() { fn f() {
find(<|>"x"); find($0"x");
} }
"#, "#,
r##" r##"

View file

@ -23,7 +23,7 @@ use ide_db::ty_filter::TryEnum;
// enum Result<T, E> { Ok(T), Err(E) } // enum Result<T, E> { Ok(T), Err(E) }
// fn main() { // fn main() {
// let x: Result<i32, i32> = Result::Ok(92); // let x: Result<i32, i32> = Result::Ok(92);
// let y = x.<|>unwrap(); // let y = x.$0unwrap();
// } // }
// ``` // ```
// -> // ->
@ -101,7 +101,7 @@ enum Result<T, E> { Ok(T), Err(E) }
fn i<T>(a: T) -> T { a } fn i<T>(a: T) -> T { a }
fn main() { fn main() {
let x: Result<i32, i32> = Result::Ok(92); let x: Result<i32, i32> = Result::Ok(92);
let y = i(x).<|>unwrap(); let y = i(x).$0unwrap();
} }
", ",
r" r"
@ -127,7 +127,7 @@ enum Option<T> { Some(T), None }
fn i<T>(a: T) -> T { a } fn i<T>(a: T) -> T { a }
fn main() { fn main() {
let x = Option::Some(92); let x = Option::Some(92);
let y = i(x).<|>unwrap(); let y = i(x).$0unwrap();
} }
", ",
r" r"
@ -153,7 +153,7 @@ enum Result<T, E> { Ok(T), Err(E) }
fn i<T>(a: T) -> T { a } fn i<T>(a: T) -> T { a }
fn main() { fn main() {
let x: Result<i32, i32> = Result::Ok(92); let x: Result<i32, i32> = Result::Ok(92);
let y = i(x).<|>unwrap().count_zeroes(); let y = i(x).$0unwrap().count_zeroes();
} }
", ",
r" r"
@ -179,7 +179,7 @@ enum Option<T> { Some(T), None }
fn i<T>(a: T) -> T { a } fn i<T>(a: T) -> T { a }
fn main() { fn main() {
let x = Option::Some(92); let x = Option::Some(92);
let y = i(x).<|>unwrap(); let y = i(x).$0unwrap();
} }
", ",
r"i(x).unwrap()", r"i(x).unwrap()",

View file

@ -9,7 +9,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// Wraps the tail of import into braces. // Wraps the tail of import into braces.
// //
// ``` // ```
// use std::<|>collections::HashMap; // use std::$0collections::HashMap;
// ``` // ```
// -> // ->
// ``` // ```
@ -43,7 +43,7 @@ mod tests {
fn test_split_import() { fn test_split_import() {
check_assist( check_assist(
split_import, split_import,
"use crate::<|>db::RootDatabase;", "use crate::$0db::RootDatabase;",
"use crate::{db::RootDatabase};", "use crate::{db::RootDatabase};",
) )
} }
@ -52,19 +52,19 @@ mod tests {
fn split_import_works_with_trees() { fn split_import_works_with_trees() {
check_assist( check_assist(
split_import, split_import,
"use crate:<|>:db::{RootDatabase, FileSymbol}", "use crate:$0:db::{RootDatabase, FileSymbol}",
"use crate::{db::{RootDatabase, FileSymbol}}", "use crate::{db::{RootDatabase, FileSymbol}}",
) )
} }
#[test] #[test]
fn split_import_target() { fn split_import_target() {
check_assist_target(split_import, "use crate::<|>db::{RootDatabase, FileSymbol}", "::"); check_assist_target(split_import, "use crate::$0db::{RootDatabase, FileSymbol}", "::");
} }
#[test] #[test]
fn issue4044() { fn issue4044() {
check_assist_not_applicable(split_import, "use crate::<|>:::self;") check_assist_not_applicable(split_import, "use crate::$0:::self;")
} }
#[test] #[test]
@ -72,7 +72,7 @@ mod tests {
check_assist_not_applicable( check_assist_not_applicable(
split_import, split_import,
r" r"
use std::<|> use std::$0
fn main() {}", fn main() {}",
); );
} }

View file

@ -10,7 +10,7 @@ use crate::{utils::test_related_attribute, AssistContext, AssistId, AssistKind,
// Adds `#[ignore]` attribute to the test. // Adds `#[ignore]` attribute to the test.
// //
// ``` // ```
// <|>#[test] // $0#[test]
// fn arithmetics { // fn arithmetics {
// assert_eq!(2 + 2, 5); // assert_eq!(2 + 2, 5);
// } // }
@ -69,7 +69,7 @@ mod tests {
check_assist( check_assist(
toggle_ignore, toggle_ignore,
r#" r#"
#[test<|>] #[test$0]
fn test() {} fn test() {}
"#, "#,
r#" r#"
@ -85,7 +85,7 @@ mod tests {
check_assist( check_assist(
toggle_ignore, toggle_ignore,
r#" r#"
#[test<|>] #[test$0]
#[ignore] #[ignore]
fn test() {} fn test() {}
"#, "#,

View file

@ -14,7 +14,7 @@ use crate::{utils::unwrap_trivial_block, AssistContext, AssistId, AssistKind, As
// //
// ``` // ```
// fn foo() { // fn foo() {
// if true {<|> // if true {$0
// println!("foo"); // println!("foo");
// } // }
// } // }
@ -124,7 +124,7 @@ mod tests {
unwrap_block, unwrap_block,
r#" r#"
fn main() { fn main() {
<|>{ $0{
92 92
} }
} }
@ -143,7 +143,7 @@ fn main() {
unwrap_block, unwrap_block,
r#" r#"
fn main() { fn main() {
<|>{ $0{
92; 92;
} }
() ()
@ -161,7 +161,7 @@ fn main() {
unwrap_block, unwrap_block,
r#" r#"
fn main() { fn main() {
<|>{ $0{
92 92
} }
() ()
@ -183,7 +183,7 @@ fn main() {
r#" r#"
fn main() { fn main() {
bar(); bar();
if true {<|> if true {$0
foo(); foo();
//comment //comment
@ -217,7 +217,7 @@ fn main() {
//comment //comment
bar(); bar();
} else {<|> } else {$0
println!("bar"); println!("bar");
} }
} }
@ -249,7 +249,7 @@ fn main() {
//comment //comment
//bar(); //bar();
} else if false {<|> } else if false {$0
println!("bar"); println!("bar");
} else { } else {
println!("foo"); println!("foo");
@ -285,7 +285,7 @@ fn main() {
//bar(); //bar();
} else if false { } else if false {
println!("bar"); println!("bar");
} else if true {<|> } else if true {$0
println!("foo"); println!("foo");
} }
} }
@ -323,7 +323,7 @@ fn main() {
println!("bar"); println!("bar");
} else if true { } else if true {
println!("foo"); println!("foo");
} else {<|> } else {$0
println!("else"); println!("else");
} }
} }
@ -361,7 +361,7 @@ fn main() {
//bar(); //bar();
} else if false { } else if false {
println!("bar"); println!("bar");
} else if true {<|> } else if true {$0
println!("foo"); println!("foo");
} else { } else {
println!("else"); println!("else");
@ -391,7 +391,7 @@ fn main() {
unwrap_block, unwrap_block,
r#" r#"
fn main() { fn main() {
bar();<|> bar();$0
if true { if true {
foo(); foo();
@ -411,7 +411,7 @@ fn main() {
unwrap_block, unwrap_block,
r#" r#"
fn main() { fn main() {
for i in 0..5 {<|> for i in 0..5 {$0
if true { if true {
foo(); foo();
@ -445,7 +445,7 @@ fn main() {
r#" r#"
fn main() { fn main() {
for i in 0..5 { for i in 0..5 {
if true {<|> if true {$0
foo(); foo();
//comment //comment
@ -475,7 +475,7 @@ fn main() {
unwrap_block, unwrap_block,
r#" r#"
fn main() { fn main() {
loop {<|> loop {$0
if true { if true {
foo(); foo();
@ -508,7 +508,7 @@ fn main() {
unwrap_block, unwrap_block,
r#" r#"
fn main() { fn main() {
while true {<|> while true {$0
if true { if true {
foo(); foo();
@ -542,7 +542,7 @@ fn main() {
r#" r#"
fn main() { fn main() {
match rel_path { match rel_path {
Ok(rel_path) => {<|> Ok(rel_path) => {$0
let rel_path = RelativePathBuf::from_path(rel_path).ok()?; let rel_path = RelativePathBuf::from_path(rel_path).ok()?;
Some((*id, rel_path)) Some((*id, rel_path))
} }
@ -567,7 +567,7 @@ fn main() {
fn main() { fn main() {
while true { while true {
if true { if true {
foo();<|> foo();$0
//comment //comment
bar(); bar();

View file

@ -13,7 +13,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// Wrap the function's return type into Result. // Wrap the function's return type into Result.
// //
// ``` // ```
// fn foo() -> i32<|> { 42i32 } // fn foo() -> i32$0 { 42i32 }
// ``` // ```
// -> // ->
// ``` // ```
@ -282,7 +282,7 @@ mod tests {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -> i3<|>2 { fn foo() -> i3$02 {
let test = "test"; let test = "test";
return 42i32; return 42i32;
} }
@ -302,7 +302,7 @@ fn foo() -> Result<i32, ${0:_}> {
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() { fn foo() {
|| -> i32<|> { || -> i32$0 {
let test = "test"; let test = "test";
return 42i32; return 42i32;
}; };
@ -325,7 +325,7 @@ fn foo() {
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -> i32 { fn foo() -> i32 {
let test = "test";<|> let test = "test";$0
return 42i32; return 42i32;
} }
"#, "#,
@ -339,7 +339,7 @@ fn foo() -> i32 {
r#" r#"
fn foo() { fn foo() {
|| -> i32 { || -> i32 {
let test = "test";<|> let test = "test";$0
return 42i32; return 42i32;
}; };
} }
@ -349,7 +349,7 @@ fn foo() {
#[test] #[test]
fn wrap_return_type_in_result_closure_non_block() { fn wrap_return_type_in_result_closure_non_block() {
check_assist_not_applicable(wrap_return_type_in_result, r#"fn foo() { || -> i<|>32 3; }"#); check_assist_not_applicable(wrap_return_type_in_result, r#"fn foo() { || -> i$032 3; }"#);
} }
#[test] #[test]
@ -357,7 +357,7 @@ fn foo() {
check_assist_not_applicable( check_assist_not_applicable(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -> std::result::Result<i32<|>, String> { fn foo() -> std::result::Result<i32$0, String> {
let test = "test"; let test = "test";
return 42i32; return 42i32;
} }
@ -371,7 +371,7 @@ fn foo() -> std::result::Result<i32<|>, String> {
check_assist_not_applicable( check_assist_not_applicable(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -> Result<i32<|>, String> { fn foo() -> Result<i32$0, String> {
let test = "test"; let test = "test";
return 42i32; return 42i32;
} }
@ -385,7 +385,7 @@ fn foo() -> Result<i32<|>, String> {
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() { fn foo() {
|| -> Result<i32<|>, String> { || -> Result<i32$0, String> {
let test = "test"; let test = "test";
return 42i32; return 42i32;
}; };
@ -399,7 +399,7 @@ fn foo() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -> <|>i32 { fn foo() -> $0i32 {
let test = "test"; let test = "test";
return 42i32; return 42i32;
} }
@ -418,7 +418,7 @@ fn foo() -> Result<i32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -><|> i32 { fn foo() ->$0 i32 {
let test = "test"; let test = "test";
42i32 42i32
} }
@ -438,7 +438,7 @@ fn foo() -> Result<i32, ${0:_}> {
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() { fn foo() {
|| -><|> i32 { || ->$0 i32 {
let test = "test"; let test = "test";
42i32 42i32
}; };
@ -459,7 +459,7 @@ fn foo() {
fn wrap_return_type_in_result_simple_with_tail_only() { fn wrap_return_type_in_result_simple_with_tail_only() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> i32<|> { 42i32 }"#, r#"fn foo() -> i32$0 { 42i32 }"#,
r#"fn foo() -> Result<i32, ${0:_}> { Ok(42i32) }"#, r#"fn foo() -> Result<i32, ${0:_}> { Ok(42i32) }"#,
); );
} }
@ -469,7 +469,7 @@ fn foo() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -> i32<|> { fn foo() -> i32$0 {
if true { if true {
42i32 42i32
} else { } else {
@ -495,7 +495,7 @@ fn foo() -> Result<i32, ${0:_}> {
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() { fn foo() {
|| -> i32<|> { || -> i32$0 {
if true { if true {
42i32 42i32
} else { } else {
@ -523,7 +523,7 @@ fn foo() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -> i32<|> { fn foo() -> i32$0 {
if true { if true {
if false { if false {
1 1
@ -556,7 +556,7 @@ fn foo() -> Result<i32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
async fn foo() -> i<|>32 { async fn foo() -> i$032 {
if true { if true {
if false { if false {
1.await 1.await
@ -588,7 +588,7 @@ async fn foo() -> Result<i32, ${0:_}> {
fn wrap_return_type_in_result_simple_with_array() { fn wrap_return_type_in_result_simple_with_array() {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#"fn foo() -> [i32;<|> 3] { [1, 2, 3] }"#, r#"fn foo() -> [i32;$0 3] { [1, 2, 3] }"#,
r#"fn foo() -> Result<[i32; 3], ${0:_}> { Ok([1, 2, 3]) }"#, r#"fn foo() -> Result<[i32; 3], ${0:_}> { Ok([1, 2, 3]) }"#,
); );
} }
@ -598,7 +598,7 @@ async fn foo() -> Result<i32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -<|>> i32 { fn foo() -$0> i32 {
if true { if true {
if false { if false {
1 as i32 1 as i32
@ -631,7 +631,7 @@ fn foo() -> Result<i32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -> i32<|> { fn foo() -> i32$0 {
let my_var = 5; let my_var = 5;
match my_var { match my_var {
5 => 42i32, 5 => 42i32,
@ -656,7 +656,7 @@ fn foo() -> Result<i32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -> i32<|> { fn foo() -> i32$0 {
let my_var = 5; let my_var = 5;
loop { loop {
println!("test"); println!("test");
@ -683,7 +683,7 @@ fn foo() -> Result<i32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -> i32<|> { fn foo() -> i32$0 {
let my_var = let x = loop { let my_var = let x = loop {
break 1; break 1;
}; };
@ -706,7 +706,7 @@ fn foo() -> Result<i32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -> i32<|> { fn foo() -> i32$0 {
let my_var = 5; let my_var = 5;
let res = match my_var { let res = match my_var {
5 => 42i32, 5 => 42i32,
@ -730,7 +730,7 @@ fn foo() -> Result<i32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -> i32<|> { fn foo() -> i32$0 {
let my_var = 5; let my_var = 5;
let res = if my_var == 5 { let res = if my_var == 5 {
42i32 42i32
@ -759,7 +759,7 @@ fn foo() -> Result<i32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -> i32<|> { fn foo() -> i32$0 {
let my_var = 5; let my_var = 5;
match my_var { match my_var {
5 => { 5 => {
@ -808,7 +808,7 @@ fn foo() -> Result<i32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -> i<|>32 { fn foo() -> i$032 {
let test = "test"; let test = "test";
if test == "test" { if test == "test" {
return 24i32; return 24i32;
@ -833,7 +833,7 @@ fn foo() -> Result<i32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo(the_field: u32) -><|> u32 { fn foo(the_field: u32) ->$0 u32 {
let true_closure = || { return true; }; let true_closure = || { return true; };
if the_field < 5 { if the_field < 5 {
let mut i = 0; let mut i = 0;
@ -865,7 +865,7 @@ fn foo(the_field: u32) -> Result<u32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo(the_field: u32) -> u32<|> { fn foo(the_field: u32) -> u32$0 {
let true_closure = || { let true_closure = || {
return true; return true;
}; };
@ -912,7 +912,7 @@ fn foo(the_field: u32) -> Result<u32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -> i32<|> { fn foo() -> i32$0 {
let test = "test"; let test = "test";
if test == "test" { if test == "test" {
return 24i32; return 24i32;
@ -946,7 +946,7 @@ fn foo() -> Result<i32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -> i32<|> { fn foo() -> i32$0 {
let test = "test"; let test = "test";
if test == "test" { if test == "test" {
return 24i32; return 24i32;
@ -984,7 +984,7 @@ fn foo() -> Result<i32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo() -> i3<|>2 { fn foo() -> i3$02 {
let test = "test"; let test = "test";
let other = 5; let other = 5;
if test == "test" { if test == "test" {
@ -1030,7 +1030,7 @@ fn foo() -> Result<i32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo(the_field: u32) -> u32<|> { fn foo(the_field: u32) -> u32$0 {
if the_field < 5 { if the_field < 5 {
let mut i = 0; let mut i = 0;
loop { loop {
@ -1070,7 +1070,7 @@ fn foo(the_field: u32) -> Result<u32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo(the_field: u32) -> u3<|>2 { fn foo(the_field: u32) -> u3$02 {
if the_field < 5 { if the_field < 5 {
let mut i = 0; let mut i = 0;
match i { match i {
@ -1098,7 +1098,7 @@ fn foo(the_field: u32) -> Result<u32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo(the_field: u32) -> u32<|> { fn foo(the_field: u32) -> u32$0 {
if the_field < 5 { if the_field < 5 {
let mut i = 0; let mut i = 0;
if i == 5 { if i == 5 {
@ -1128,7 +1128,7 @@ fn foo(the_field: u32) -> Result<u32, ${0:_}> {
check_assist( check_assist(
wrap_return_type_in_result, wrap_return_type_in_result,
r#" r#"
fn foo(the_field: u32) -> <|>u32 { fn foo(the_field: u32) -> $0u32 {
if the_field < 5 { if the_field < 5 {
let mut i = 0; let mut i = 0;
if i == 5 { if i == 5 {

View file

@ -166,7 +166,7 @@ fn check(handler: Handler, before: &str, expected: ExpectedResult, assist_label:
#[test] #[test]
fn assist_order_field_struct() { fn assist_order_field_struct() {
let before = "struct Foo { <|>bar: u32 }"; let before = "struct Foo { $0bar: u32 }";
let (before_cursor_pos, before) = extract_offset(before); let (before_cursor_pos, before) = extract_offset(before);
let (db, file_id) = with_single_file(&before); let (db, file_id) = with_single_file(&before);
let frange = FileRange { file_id, range: TextRange::empty(before_cursor_pos) }; let frange = FileRange { file_id, range: TextRange::empty(before_cursor_pos) };
@ -181,7 +181,7 @@ fn assist_order_field_struct() {
fn assist_order_if_expr() { fn assist_order_if_expr() {
let before = " let before = "
pub fn test_some_range(a: int) -> bool { pub fn test_some_range(a: int) -> bool {
if let 2..6 = <|>5<|> { if let 2..6 = $05$0 {
true true
} else { } else {
false false
@ -201,7 +201,7 @@ fn assist_order_if_expr() {
fn assist_filter_works() { fn assist_filter_works() {
let before = " let before = "
pub fn test_some_range(a: int) -> bool { pub fn test_some_range(a: int) -> bool {
if let 2..6 = <|>5<|> { if let 2..6 = $05$0 {
true true
} else { } else {
false false

View file

@ -8,7 +8,7 @@ fn doctest_add_explicit_type() {
"add_explicit_type", "add_explicit_type",
r#####" r#####"
fn main() { fn main() {
let x<|> = 92; let x$0 = 92;
} }
"#####, "#####,
r#####" r#####"
@ -25,7 +25,7 @@ fn doctest_add_hash() {
"add_hash", "add_hash",
r#####" r#####"
fn main() { fn main() {
r#"Hello,<|> World!"#; r#"Hello,$0 World!"#;
} }
"#####, "#####,
r#####" r#####"
@ -49,7 +49,7 @@ trait Trait {
impl Trait for () { impl Trait for () {
type X = (); type X = ();
fn foo(&self) {}<|> fn foo(&self) {}$0
} }
"#####, "#####,
@ -81,7 +81,7 @@ trait Trait<T> {
fn bar(&self) {} fn bar(&self) {}
} }
impl Trait<u32> for () {<|> impl Trait<u32> for () {$0
} }
"#####, "#####,
@ -110,7 +110,7 @@ fn doctest_add_turbo_fish() {
r#####" r#####"
fn make<T>() -> T { todo!() } fn make<T>() -> T { todo!() }
fn main() { fn main() {
let x = make<|>(); let x = make$0();
} }
"#####, "#####,
r#####" r#####"
@ -128,7 +128,7 @@ fn doctest_apply_demorgan() {
"apply_demorgan", "apply_demorgan",
r#####" r#####"
fn main() { fn main() {
if x != 4 ||<|> !y {} if x != 4 ||$0 !y {}
} }
"#####, "#####,
r#####" r#####"
@ -145,7 +145,7 @@ fn doctest_auto_import() {
"auto_import", "auto_import",
r#####" r#####"
fn main() { fn main() {
let map = HashMap<|>::new(); let map = HashMap$0::new();
} }
pub mod std { pub mod collections { pub struct HashMap { } } } pub mod std { pub mod collections { pub struct HashMap { } } }
"#####, "#####,
@ -165,7 +165,7 @@ fn doctest_change_visibility() {
check_doc_test( check_doc_test(
"change_visibility", "change_visibility",
r#####" r#####"
<|>fn frobnicate() {} $0fn frobnicate() {}
"#####, "#####,
r#####" r#####"
pub(crate) fn frobnicate() {} pub(crate) fn frobnicate() {}
@ -178,7 +178,7 @@ fn doctest_convert_integer_literal() {
check_doc_test( check_doc_test(
"convert_integer_literal", "convert_integer_literal",
r#####" r#####"
const _: i32 = 10<|>; const _: i32 = 10$0;
"#####, "#####,
r#####" r#####"
const _: i32 = 0b1010; const _: i32 = 0b1010;
@ -192,7 +192,7 @@ fn doctest_convert_to_guarded_return() {
"convert_to_guarded_return", "convert_to_guarded_return",
r#####" r#####"
fn main() { fn main() {
<|>if cond { $0if cond {
foo(); foo();
bar(); bar();
} }
@ -220,7 +220,7 @@ mod foo {
pub struct Baz; pub struct Baz;
} }
use foo::*<|>; use foo::*$0;
fn qux(bar: Bar, baz: Baz) {} fn qux(bar: Bar, baz: Baz) {}
"#####, "#####,
@ -242,7 +242,7 @@ fn doctest_extract_struct_from_enum_variant() {
check_doc_test( check_doc_test(
"extract_struct_from_enum_variant", "extract_struct_from_enum_variant",
r#####" r#####"
enum A { <|>One(u32, u32) } enum A { $0One(u32, u32) }
"#####, "#####,
r#####" r#####"
struct One(pub u32, pub u32); struct One(pub u32, pub u32);
@ -258,7 +258,7 @@ fn doctest_extract_variable() {
"extract_variable", "extract_variable",
r#####" r#####"
fn main() { fn main() {
<|>(1 + 2)<|> * 4; $0(1 + 2)$0 * 4;
} }
"#####, "#####,
r#####" r#####"
@ -279,7 +279,7 @@ enum Action { Move { distance: u32 }, Stop }
fn handle(action: Action) { fn handle(action: Action) {
match action { match action {
<|> $0
} }
} }
"#####, "#####,
@ -305,7 +305,7 @@ mod m {
fn frobnicate() {} fn frobnicate() {}
} }
fn main() { fn main() {
m::frobnicate<|>() {} m::frobnicate$0() {}
} }
"#####, "#####,
r#####" r#####"
@ -325,7 +325,7 @@ fn doctest_flip_binexpr() {
"flip_binexpr", "flip_binexpr",
r#####" r#####"
fn main() { fn main() {
let _ = 90 +<|> 2; let _ = 90 +$0 2;
} }
"#####, "#####,
r#####" r#####"
@ -342,7 +342,7 @@ fn doctest_flip_comma() {
"flip_comma", "flip_comma",
r#####" r#####"
fn main() { fn main() {
((1, 2),<|> (3, 4)); ((1, 2),$0 (3, 4));
} }
"#####, "#####,
r#####" r#####"
@ -358,7 +358,7 @@ fn doctest_flip_trait_bound() {
check_doc_test( check_doc_test(
"flip_trait_bound", "flip_trait_bound",
r#####" r#####"
fn foo<T: Clone +<|> Copy>() { } fn foo<T: Clone +$0 Copy>() { }
"#####, "#####,
r#####" r#####"
fn foo<T: Copy + Clone>() { } fn foo<T: Copy + Clone>() { }
@ -373,7 +373,7 @@ fn doctest_generate_default_from_enum_variant() {
r#####" r#####"
enum Version { enum Version {
Undefined, Undefined,
Minor<|>, Minor$0,
Major, Major,
} }
"#####, "#####,
@ -400,7 +400,7 @@ fn doctest_generate_derive() {
r#####" r#####"
struct Point { struct Point {
x: u32, x: u32,
y: u32,<|> y: u32,$0
} }
"#####, "#####,
r#####" r#####"
@ -418,7 +418,7 @@ fn doctest_generate_from_impl_for_enum() {
check_doc_test( check_doc_test(
"generate_from_impl_for_enum", "generate_from_impl_for_enum",
r#####" r#####"
enum A { <|>One(u32) } enum A { $0One(u32) }
"#####, "#####,
r#####" r#####"
enum A { One(u32) } enum A { One(u32) }
@ -440,7 +440,7 @@ fn doctest_generate_function() {
struct Baz; struct Baz;
fn baz() -> Baz { Baz } fn baz() -> Baz { Baz }
fn foo() { fn foo() {
bar<|>("", baz()); bar$0("", baz());
} }
"#####, "#####,
@ -465,7 +465,7 @@ fn doctest_generate_impl() {
"generate_impl", "generate_impl",
r#####" r#####"
struct Ctx<T: Clone> { struct Ctx<T: Clone> {
data: T,<|> data: T,$0
} }
"#####, "#####,
r#####" r#####"
@ -486,7 +486,7 @@ fn doctest_generate_new() {
"generate_new", "generate_new",
r#####" r#####"
struct Ctx<T: Clone> { struct Ctx<T: Clone> {
data: T,<|> data: T,$0
} }
"#####, "#####,
r#####" r#####"
@ -507,7 +507,7 @@ fn doctest_infer_function_return_type() {
check_doc_test( check_doc_test(
"infer_function_return_type", "infer_function_return_type",
r#####" r#####"
fn foo() { 4<|>2i32 } fn foo() { 4$02i32 }
"#####, "#####,
r#####" r#####"
fn foo() -> i32 { 42i32 } fn foo() -> i32 { 42i32 }
@ -522,7 +522,7 @@ fn doctest_inline_function() {
r#####" r#####"
fn add(a: u32, b: u32) -> u32 { a + b } fn add(a: u32, b: u32) -> u32 { a + b }
fn main() { fn main() {
let x = add<|>(1, 2); let x = add$0(1, 2);
} }
"#####, "#####,
r#####" r#####"
@ -544,7 +544,7 @@ fn doctest_inline_local_variable() {
"inline_local_variable", "inline_local_variable",
r#####" r#####"
fn main() { fn main() {
let x<|> = 1 + 2; let x$0 = 1 + 2;
x * 4; x * 4;
} }
"#####, "#####,
@ -561,7 +561,7 @@ fn doctest_introduce_named_lifetime() {
check_doc_test( check_doc_test(
"introduce_named_lifetime", "introduce_named_lifetime",
r#####" r#####"
impl Cursor<'_<|>> { impl Cursor<'_$0> {
fn node(self) -> &SyntaxNode { fn node(self) -> &SyntaxNode {
match self { match self {
Cursor::Replace(node) | Cursor::Before(node) => node, Cursor::Replace(node) | Cursor::Before(node) => node,
@ -587,7 +587,7 @@ fn doctest_invert_if() {
"invert_if", "invert_if",
r#####" r#####"
fn main() { fn main() {
if<|> !y { A } else { B } if$0 !y { A } else { B }
} }
"#####, "#####,
r#####" r#####"
@ -604,7 +604,7 @@ fn doctest_make_raw_string() {
"make_raw_string", "make_raw_string",
r#####" r#####"
fn main() { fn main() {
"Hello,<|> World!"; "Hello,$0 World!";
} }
"#####, "#####,
r#####" r#####"
@ -621,7 +621,7 @@ fn doctest_make_usual_string() {
"make_usual_string", "make_usual_string",
r#####" r#####"
fn main() { fn main() {
r#"Hello,<|> "World!""#; r#"Hello,$0 "World!""#;
} }
"#####, "#####,
r#####" r#####"
@ -637,7 +637,7 @@ fn doctest_merge_imports() {
check_doc_test( check_doc_test(
"merge_imports", "merge_imports",
r#####" r#####"
use std::<|>fmt::Formatter; use std::$0fmt::Formatter;
use std::io; use std::io;
"#####, "#####,
r#####" r#####"
@ -655,7 +655,7 @@ enum Action { Move { distance: u32 }, Stop }
fn handle(action: Action) { fn handle(action: Action) {
match action { match action {
<|>Action::Move(..) => foo(), $0Action::Move(..) => foo(),
Action::Stop => foo(), Action::Stop => foo(),
} }
} }
@ -681,7 +681,7 @@ enum Action { Move { distance: u32 }, Stop }
fn handle(action: Action) { fn handle(action: Action) {
match action { match action {
Action::Move { distance } => <|>if distance > 10 { foo() }, Action::Move { distance } => $0if distance > 10 { foo() },
_ => (), _ => (),
} }
} }
@ -704,7 +704,7 @@ fn doctest_move_bounds_to_where_clause() {
check_doc_test( check_doc_test(
"move_bounds_to_where_clause", "move_bounds_to_where_clause",
r#####" r#####"
fn apply<T, U, <|>F: FnOnce(T) -> U>(f: F, x: T) -> U { fn apply<T, U, $0F: FnOnce(T) -> U>(f: F, x: T) -> U {
f(x) f(x)
} }
"#####, "#####,
@ -725,7 +725,7 @@ enum Action { Move { distance: u32 }, Stop }
fn handle(action: Action) { fn handle(action: Action) {
match action { match action {
Action::Move { distance } <|>if distance > 10 => foo(), Action::Move { distance } $0if distance > 10 => foo(),
_ => (), _ => (),
} }
} }
@ -750,7 +750,7 @@ fn doctest_move_module_to_file() {
check_doc_test( check_doc_test(
"move_module_to_file", "move_module_to_file",
r#####" r#####"
mod <|>foo { mod $0foo {
fn t() {} fn t() {}
} }
"#####, "#####,
@ -769,7 +769,7 @@ fn main() {
let mut foo = 6; let mut foo = 6;
if true { if true {
<|>foo = 5; $0foo = 5;
} else { } else {
foo = 4; foo = 4;
} }
@ -795,7 +795,7 @@ fn doctest_qualify_path() {
"qualify_path", "qualify_path",
r#####" r#####"
fn main() { fn main() {
let map = HashMap<|>::new(); let map = HashMap$0::new();
} }
pub mod std { pub mod collections { pub struct HashMap { } } } pub mod std { pub mod collections { pub struct HashMap { } } }
"#####, "#####,
@ -814,7 +814,7 @@ fn doctest_remove_dbg() {
"remove_dbg", "remove_dbg",
r#####" r#####"
fn main() { fn main() {
<|>dbg!(92); $0dbg!(92);
} }
"#####, "#####,
r#####" r#####"
@ -831,7 +831,7 @@ fn doctest_remove_hash() {
"remove_hash", "remove_hash",
r#####" r#####"
fn main() { fn main() {
r#"Hello,<|> World!"#; r#"Hello,$0 World!"#;
} }
"#####, "#####,
r#####" r#####"
@ -848,7 +848,7 @@ fn doctest_remove_mut() {
"remove_mut", "remove_mut",
r#####" r#####"
impl Walrus { impl Walrus {
fn feed(&mut<|> self, amount: u32) {} fn feed(&mut$0 self, amount: u32) {}
} }
"#####, "#####,
r#####" r#####"
@ -864,7 +864,7 @@ fn doctest_remove_unused_param() {
check_doc_test( check_doc_test(
"remove_unused_param", "remove_unused_param",
r#####" r#####"
fn frobnicate(x: i32<|>) {} fn frobnicate(x: i32$0) {}
fn main() { fn main() {
frobnicate(92); frobnicate(92);
@ -886,7 +886,7 @@ fn doctest_reorder_fields() {
"reorder_fields", "reorder_fields",
r#####" r#####"
struct Foo {foo: i32, bar: i32}; struct Foo {foo: i32, bar: i32};
const test: Foo = <|>Foo {bar: 0, foo: 1} const test: Foo = $0Foo {bar: 0, foo: 1}
"#####, "#####,
r#####" r#####"
struct Foo {foo: i32, bar: i32}; struct Foo {foo: i32, bar: i32};
@ -901,7 +901,7 @@ fn doctest_replace_derive_with_manual_impl() {
"replace_derive_with_manual_impl", "replace_derive_with_manual_impl",
r#####" r#####"
trait Debug { fn fmt(&self, f: &mut Formatter) -> Result<()>; } trait Debug { fn fmt(&self, f: &mut Formatter) -> Result<()>; }
#[derive(Deb<|>ug, Display)] #[derive(Deb$0ug, Display)]
struct S; struct S;
"#####, "#####,
r#####" r#####"
@ -926,7 +926,7 @@ fn doctest_replace_if_let_with_match() {
enum Action { Move { distance: u32 }, Stop } enum Action { Move { distance: u32 }, Stop }
fn handle(action: Action) { fn handle(action: Action) {
<|>if let Action::Move { distance } = action { $0if let Action::Move { distance } = action {
foo(distance) foo(distance)
} else { } else {
bar() bar()
@ -951,7 +951,7 @@ fn doctest_replace_impl_trait_with_generic() {
check_doc_test( check_doc_test(
"replace_impl_trait_with_generic", "replace_impl_trait_with_generic",
r#####" r#####"
fn foo(bar: <|>impl Bar) {} fn foo(bar: $0impl Bar) {}
"#####, "#####,
r#####" r#####"
fn foo<B: Bar>(bar: B) {} fn foo<B: Bar>(bar: B) {}
@ -967,7 +967,7 @@ fn doctest_replace_let_with_if_let() {
enum Option<T> { Some(T), None } enum Option<T> { Some(T), None }
fn main(action: Action) { fn main(action: Action) {
<|>let x = compute(); $0let x = compute();
} }
fn compute() -> Option<i32> { None } fn compute() -> Option<i32> { None }
@ -993,7 +993,7 @@ fn doctest_replace_match_with_if_let() {
enum Action { Move { distance: u32 }, Stop } enum Action { Move { distance: u32 }, Stop }
fn handle(action: Action) { fn handle(action: Action) {
<|>match action { $0match action {
Action::Move { distance } => foo(distance), Action::Move { distance } => foo(distance),
_ => bar(), _ => bar(),
} }
@ -1018,7 +1018,7 @@ fn doctest_replace_qualified_name_with_use() {
check_doc_test( check_doc_test(
"replace_qualified_name_with_use", "replace_qualified_name_with_use",
r#####" r#####"
fn process(map: std::collections::<|>HashMap<String, String>) {} fn process(map: std::collections::$0HashMap<String, String>) {}
"#####, "#####,
r#####" r#####"
use std::collections::HashMap; use std::collections::HashMap;
@ -1034,7 +1034,7 @@ fn doctest_replace_string_with_char() {
"replace_string_with_char", "replace_string_with_char",
r#####" r#####"
fn main() { fn main() {
find("{<|>"); find("{$0");
} }
"#####, "#####,
r#####" r#####"
@ -1053,7 +1053,7 @@ fn doctest_replace_unwrap_with_match() {
enum Result<T, E> { Ok(T), Err(E) } enum Result<T, E> { Ok(T), Err(E) }
fn main() { fn main() {
let x: Result<i32, i32> = Result::Ok(92); let x: Result<i32, i32> = Result::Ok(92);
let y = x.<|>unwrap(); let y = x.$0unwrap();
} }
"#####, "#####,
r#####" r#####"
@ -1074,7 +1074,7 @@ fn doctest_split_import() {
check_doc_test( check_doc_test(
"split_import", "split_import",
r#####" r#####"
use std::<|>collections::HashMap; use std::$0collections::HashMap;
"#####, "#####,
r#####" r#####"
use std::{collections::HashMap}; use std::{collections::HashMap};
@ -1087,7 +1087,7 @@ fn doctest_toggle_ignore() {
check_doc_test( check_doc_test(
"toggle_ignore", "toggle_ignore",
r#####" r#####"
<|>#[test] $0#[test]
fn arithmetics { fn arithmetics {
assert_eq!(2 + 2, 5); assert_eq!(2 + 2, 5);
} }
@ -1108,7 +1108,7 @@ fn doctest_unwrap_block() {
"unwrap_block", "unwrap_block",
r#####" r#####"
fn foo() { fn foo() {
if true {<|> if true {$0
println!("foo"); println!("foo");
} }
} }
@ -1126,7 +1126,7 @@ fn doctest_wrap_return_type_in_result() {
check_doc_test( check_doc_test(
"wrap_return_type_in_result", "wrap_return_type_in_result",
r#####" r#####"
fn foo() -> i32<|> { 42i32 } fn foo() -> i32$0 { 42i32 }
"#####, "#####,
r#####" r#####"
fn foo() -> Result<i32, ${0:_}> { Ok(42i32) } fn foo() -> Result<i32, ${0:_}> { Ok(42i32) }

View file

@ -413,7 +413,7 @@ mod tests {
fn empty_derive_completion() { fn empty_derive_completion() {
check( check(
r#" r#"
#[derive(<|>)] #[derive($0)]
struct Test {} struct Test {}
"#, "#,
expect![[r#" expect![[r#"
@ -434,7 +434,7 @@ struct Test {}
fn no_completion_for_incorrect_derive() { fn no_completion_for_incorrect_derive() {
check( check(
r#" r#"
#[derive{<|>)] #[derive{$0)]
struct Test {} struct Test {}
"#, "#,
expect![[r#""#]], expect![[r#""#]],
@ -445,7 +445,7 @@ struct Test {}
fn derive_with_input_completion() { fn derive_with_input_completion() {
check( check(
r#" r#"
#[derive(serde::Serialize, PartialEq, <|>)] #[derive(serde::Serialize, PartialEq, $0)]
struct Test {} struct Test {}
"#, "#,
expect![[r#" expect![[r#"
@ -464,7 +464,7 @@ struct Test {}
#[test] #[test]
fn test_attribute_completion() { fn test_attribute_completion() {
check( check(
r#"#[<|>]"#, r#"#[$0]"#,
expect![[r#" expect![[r#"
at allow() at allow()
at automatically_derived at automatically_derived
@ -504,13 +504,13 @@ struct Test {}
#[test] #[test]
fn test_attribute_completion_inside_nested_attr() { fn test_attribute_completion_inside_nested_attr() {
check(r#"#[cfg(<|>)]"#, expect![[]]) check(r#"#[cfg($0)]"#, expect![[]])
} }
#[test] #[test]
fn test_inner_attribute_completion() { fn test_inner_attribute_completion() {
check( check(
r"#![<|>]", r"#![$0]",
expect![[r#" expect![[r#"
at allow() at allow()
at automatically_derived at automatically_derived

View file

@ -79,7 +79,7 @@ struct S { foo: u32 }
impl S { impl S {
fn bar(&self) {} fn bar(&self) {}
} }
fn foo(s: S) { s.<|> } fn foo(s: S) { s.$0 }
"#, "#,
expect![[r#" expect![[r#"
fd foo u32 fd foo u32
@ -94,7 +94,7 @@ fn foo(s: S) { s.<|> }
r#" r#"
struct S { the_field: (u32,) } struct S { the_field: (u32,) }
impl S { impl S {
fn foo(self) { self.<|> } fn foo(self) { self.$0 }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -110,7 +110,7 @@ impl S {
r#" r#"
struct A { the_field: (u32, i32) } struct A { the_field: (u32, i32) }
impl A { impl A {
fn foo(&self) { self.<|> } fn foo(&self) { self.$0 }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -126,7 +126,7 @@ impl A {
check( check(
r#" r#"
struct A { the_field: u32 } struct A { the_field: u32 }
fn foo(a: A) { a.<|>() } fn foo(a: A) { a.$0() }
"#, "#,
expect![[""]], expect![[""]],
); );
@ -144,7 +144,7 @@ mod inner {
pub(crate) super_field: u32, pub(crate) super_field: u32,
} }
} }
fn foo(a: inner::A) { a.<|> } fn foo(a: inner::A) { a.$0 }
"#, "#,
expect![[r#" expect![[r#"
fd pub_field u32 fd pub_field u32
@ -162,7 +162,7 @@ mod m {
pub(crate) fn the_method(&self) {} pub(crate) fn the_method(&self) {}
} }
} }
fn foo(a: A) { a.<|> } fn foo(a: A) { a.$0 }
"#, "#,
expect![[r#" expect![[r#"
me the_method() pub(crate) fn the_method(&self) me the_method() pub(crate) fn the_method(&self)
@ -175,7 +175,7 @@ fn foo(a: A) { a.<|> }
check( check(
r#" r#"
union U { field: u8, other: u16 } union U { field: u8, other: u16 }
fn foo(u: U) { u.<|> } fn foo(u: U) { u.$0 }
"#, "#,
expect![[r#" expect![[r#"
fd field u8 fd field u8
@ -195,7 +195,7 @@ impl A<u32> {
impl A<i32> { impl A<i32> {
fn the_other_method(&self) {} fn the_other_method(&self) {}
} }
fn foo(a: A<u32>) { a.<|> } fn foo(a: A<u32>) { a.$0 }
"#, "#,
expect![[r#" expect![[r#"
me the_method() fn the_method(&self) me the_method() fn the_method(&self)
@ -210,7 +210,7 @@ fn foo(a: A<u32>) { a.<|> }
struct A {} struct A {}
trait Trait { fn the_method(&self); } trait Trait { fn the_method(&self); }
impl Trait for A {} impl Trait for A {}
fn foo(a: A) { a.<|> } fn foo(a: A) { a.$0 }
"#, "#,
expect![[r#" expect![[r#"
me the_method() fn the_method(&self) me the_method() fn the_method(&self)
@ -225,7 +225,7 @@ fn foo(a: A) { a.<|> }
struct A {} struct A {}
trait Trait { fn the_method(&self); } trait Trait { fn the_method(&self); }
impl<T> Trait for T {} impl<T> Trait for T {}
fn foo(a: &A) { a.<|> } fn foo(a: &A) { a.$0 }
", ",
expect![[r#" expect![[r#"
me the_method() fn the_method(&self) me the_method() fn the_method(&self)
@ -243,7 +243,7 @@ mod m {
} }
use m::Trait; use m::Trait;
impl Trait for A {} impl Trait for A {}
fn foo(a: A) { a.<|> } fn foo(a: A) { a.$0 }
", ",
expect![[r#" expect![[r#"
me the_method() fn the_method(&self) me the_method() fn the_method(&self)
@ -260,7 +260,7 @@ impl A {
fn the_method() {} fn the_method() {}
} }
fn foo(a: A) { fn foo(a: A) {
a.<|> a.$0
} }
"#, "#,
expect![[""]], expect![[""]],
@ -273,7 +273,7 @@ fn foo(a: A) {
r#" r#"
fn foo() { fn foo() {
let b = (0, 3.14); let b = (0, 3.14);
b.<|> b.$0
} }
"#, "#,
expect![[r#" expect![[r#"
@ -295,7 +295,7 @@ struct T(S);
impl T { impl T {
fn foo(&self) { fn foo(&self) {
// FIXME: This doesn't work without the trailing `a` as `0.` is a float // FIXME: This doesn't work without the trailing `a` as `0.` is a float
self.0.a<|> self.0.a$0
} }
} }
"#, "#,
@ -311,7 +311,7 @@ impl T {
r#" r#"
struct A { the_field: u32 } struct A { the_field: u32 }
const X: u32 = { const X: u32 = {
A { the_field: 92 }.<|> A { the_field: 92 }.$0
}; };
"#, "#,
expect![[r#" expect![[r#"
@ -327,7 +327,7 @@ const X: u32 = {
macro_rules! m { ($e:expr) => { $e } } macro_rules! m { ($e:expr) => { $e } }
struct A { the_field: u32 } struct A { the_field: u32 }
fn foo(a: A) { fn foo(a: A) {
m!(a.x<|>) m!(a.x$0)
} }
"#, "#,
expect![[r#" expect![[r#"
@ -344,7 +344,7 @@ fn foo(a: A) {
macro_rules! m { ($e:expr) => { $e } } macro_rules! m { ($e:expr) => { $e } }
struct A { the_field: u32 } struct A { the_field: u32 }
fn foo(a: A) { fn foo(a: A) {
m!(a.<|>) m!(a.$0)
} }
"#, "#,
expect![[r#" expect![[r#"
@ -360,7 +360,7 @@ fn foo(a: A) {
macro_rules! m { ($e:expr) => { $e } } macro_rules! m { ($e:expr) => { $e } }
struct A { the_field: u32 } struct A { the_field: u32 }
fn foo(a: A) { fn foo(a: A) {
m!(m!(m!(a.x<|>))) m!(m!(m!(a.x$0)))
} }
"#, "#,
expect![[r#" expect![[r#"
@ -386,7 +386,7 @@ macro_rules! dbg {
} }
struct A { the_field: u32 } struct A { the_field: u32 }
fn foo(a: A) { fn foo(a: A) {
dbg!(a.<|>) dbg!(a.$0)
} }
"#, "#,
expect![[r#" expect![[r#"
@ -405,7 +405,7 @@ impl<T> HashSet<T> {
} }
fn foo() { fn foo() {
let s: HashSet<_>; let s: HashSet<_>;
s.<|> s.$0
} }
"#, "#,
expect![[r#" expect![[r#"
@ -421,7 +421,7 @@ fn foo() {
struct S; struct S;
impl S { fn foo(&self) {} } impl S { fn foo(&self) {} }
macro_rules! make_s { () => { S }; } macro_rules! make_s { () => { S }; }
fn main() { make_s!().f<|>; } fn main() { make_s!().f$0; }
"#, "#,
expect![[r#" expect![[r#"
me foo() fn foo(&self) me foo() fn foo(&self)

View file

@ -81,7 +81,7 @@ mod tests {
r#" r#"
fn foo(file_id: FileId) {} fn foo(file_id: FileId) {}
fn bar(file_id: FileId) {} fn bar(file_id: FileId) {}
fn baz(file<|>) {} fn baz(file$0) {}
"#, "#,
expect![[r#" expect![[r#"
bn file_id: FileId bn file_id: FileId
@ -94,7 +94,7 @@ fn baz(file<|>) {}
check( check(
r#" r#"
fn foo(file_id: FileId) {} fn foo(file_id: FileId) {}
fn baz(file<|>, x: i32) {} fn baz(file$0, x: i32) {}
"#, "#,
expect![[r#" expect![[r#"
bn file_id: FileId bn file_id: FileId
@ -110,7 +110,7 @@ pub(crate) trait SourceRoot {
pub fn contains(&self, file_id: FileId) -> bool; pub fn contains(&self, file_id: FileId) -> bool;
pub fn module_map(&self) -> &ModuleMap; pub fn module_map(&self) -> &ModuleMap;
pub fn lines(&self, file_id: FileId) -> &LineIndex; pub fn lines(&self, file_id: FileId) -> &LineIndex;
pub fn syntax(&self, file<|>) pub fn syntax(&self, file$0)
} }
"#, "#,
expect![[r#" expect![[r#"
@ -124,7 +124,7 @@ pub(crate) trait SourceRoot {
check( check(
r#" r#"
fn outer(text: String) { fn outer(text: String) {
fn inner(<|>) fn inner($0)
} }
"#, "#,
expect![[r#" expect![[r#"

View file

@ -193,7 +193,7 @@ mod tests {
#[test] #[test]
fn test_keywords_in_use_stmt() { fn test_keywords_in_use_stmt() {
check( check(
r"use <|>", r"use $0",
expect![[r#" expect![[r#"
kw crate:: kw crate::
kw self kw self
@ -202,7 +202,7 @@ mod tests {
); );
check( check(
r"use a::<|>", r"use a::$0",
expect![[r#" expect![[r#"
kw self kw self
kw super:: kw super::
@ -210,7 +210,7 @@ mod tests {
); );
check( check(
r"use a::{b, <|>}", r"use a::{b, $0}",
expect![[r#" expect![[r#"
kw self kw self
kw super:: kw super::
@ -221,7 +221,7 @@ mod tests {
#[test] #[test]
fn test_keywords_at_source_file_level() { fn test_keywords_at_source_file_level() {
check( check(
r"m<|>", r"m$0",
expect![[r#" expect![[r#"
kw fn kw fn
kw use kw use
@ -245,7 +245,7 @@ mod tests {
#[test] #[test]
fn test_keywords_in_function() { fn test_keywords_in_function() {
check( check(
r"fn quux() { <|> }", r"fn quux() { $0 }",
expect![[r#" expect![[r#"
kw fn kw fn
kw use kw use
@ -271,7 +271,7 @@ mod tests {
#[test] #[test]
fn test_keywords_inside_block() { fn test_keywords_inside_block() {
check( check(
r"fn quux() { if true { <|> } }", r"fn quux() { if true { $0 } }",
expect![[r#" expect![[r#"
kw fn kw fn
kw use kw use
@ -297,7 +297,7 @@ mod tests {
#[test] #[test]
fn test_keywords_after_if() { fn test_keywords_after_if() {
check( check(
r#"fn quux() { if true { () } <|> }"#, r#"fn quux() { if true { () } $0 }"#,
expect![[r#" expect![[r#"
kw fn kw fn
kw use kw use
@ -322,7 +322,7 @@ mod tests {
); );
check_edit( check_edit(
"else", "else",
r#"fn quux() { if true { () } <|> }"#, r#"fn quux() { if true { () } $0 }"#,
r#"fn quux() { if true { () } else {$0} }"#, r#"fn quux() { if true { () } else {$0} }"#,
); );
} }
@ -332,7 +332,7 @@ mod tests {
check( check(
r#" r#"
fn quux() -> i32 { fn quux() -> i32 {
match () { () => <|> } match () { () => $0 }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -350,7 +350,7 @@ fn quux() -> i32 {
#[test] #[test]
fn test_keywords_in_trait_def() { fn test_keywords_in_trait_def() {
check( check(
r"trait My { <|> }", r"trait My { $0 }",
expect![[r#" expect![[r#"
kw fn kw fn
kw const kw const
@ -363,7 +363,7 @@ fn quux() -> i32 {
#[test] #[test]
fn test_keywords_in_impl_def() { fn test_keywords_in_impl_def() {
check( check(
r"impl My { <|> }", r"impl My { $0 }",
expect![[r#" expect![[r#"
kw fn kw fn
kw const kw const
@ -378,7 +378,7 @@ fn quux() -> i32 {
#[test] #[test]
fn test_keywords_in_loop() { fn test_keywords_in_loop() {
check( check(
r"fn my() { loop { <|> } }", r"fn my() { loop { $0 } }",
expect![[r#" expect![[r#"
kw fn kw fn
kw use kw use
@ -406,7 +406,7 @@ fn quux() -> i32 {
#[test] #[test]
fn test_keywords_after_unsafe_in_item_list() { fn test_keywords_after_unsafe_in_item_list() {
check( check(
r"unsafe <|>", r"unsafe $0",
expect![[r#" expect![[r#"
kw fn kw fn
kw trait kw trait
@ -418,7 +418,7 @@ fn quux() -> i32 {
#[test] #[test]
fn test_keywords_after_unsafe_in_block_expr() { fn test_keywords_after_unsafe_in_block_expr() {
check( check(
r"fn my_fn() { unsafe <|> }", r"fn my_fn() { unsafe $0 }",
expect![[r#" expect![[r#"
kw fn kw fn
kw trait kw trait
@ -430,19 +430,19 @@ fn quux() -> i32 {
#[test] #[test]
fn test_mut_in_ref_and_in_fn_parameters_list() { fn test_mut_in_ref_and_in_fn_parameters_list() {
check( check(
r"fn my_fn(&<|>) {}", r"fn my_fn(&$0) {}",
expect![[r#" expect![[r#"
kw mut kw mut
"#]], "#]],
); );
check( check(
r"fn my_fn(<|>) {}", r"fn my_fn($0) {}",
expect![[r#" expect![[r#"
kw mut kw mut
"#]], "#]],
); );
check( check(
r"fn my_fn() { let &<|> }", r"fn my_fn() { let &$0 }",
expect![[r#" expect![[r#"
kw mut kw mut
"#]], "#]],
@ -452,13 +452,13 @@ fn quux() -> i32 {
#[test] #[test]
fn test_where_keyword() { fn test_where_keyword() {
check( check(
r"trait A <|>", r"trait A $0",
expect![[r#" expect![[r#"
kw where kw where
"#]], "#]],
); );
check( check(
r"impl A <|>", r"impl A $0",
expect![[r#" expect![[r#"
kw where kw where
"#]], "#]],
@ -471,7 +471,7 @@ fn quux() -> i32 {
check( check(
r#" r#"
fn test() { fn test() {
let x = 2; // A comment<|> let x = 2; // A comment$0
} }
"#, "#,
expect![[""]], expect![[""]],
@ -479,7 +479,7 @@ fn test() {
check( check(
r#" r#"
/* /*
Some multi-line comment<|> Some multi-line comment$0
*/ */
"#, "#,
expect![[""]], expect![[""]],
@ -487,7 +487,7 @@ Some multi-line comment<|>
check( check(
r#" r#"
/// Some doc comment /// Some doc comment
/// let test<|> = 1 /// let test$0 = 1
"#, "#,
expect![[""]], expect![[""]],
); );
@ -501,7 +501,7 @@ Some multi-line comment<|>
use std::future::*; use std::future::*;
struct A {} struct A {}
impl Future for A {} impl Future for A {}
fn foo(a: A) { a.<|> } fn foo(a: A) { a.$0 }
//- /std/lib.rs crate:std //- /std/lib.rs crate:std
pub mod future { pub mod future {
@ -520,7 +520,7 @@ pub mod future {
use std::future::*; use std::future::*;
fn foo() { fn foo() {
let a = async {}; let a = async {};
a.<|> a.$0
} }
//- /std/lib.rs crate:std //- /std/lib.rs crate:std
@ -540,7 +540,7 @@ pub mod future {
#[test] #[test]
fn after_let() { fn after_let() {
check( check(
r#"fn main() { let _ = <|> }"#, r#"fn main() { let _ = $0 }"#,
expect![[r#" expect![[r#"
kw match kw match
kw while kw while
@ -557,7 +557,7 @@ pub mod future {
check( check(
r#" r#"
struct Foo { struct Foo {
<|> $0
pub f: i32, pub f: i32,
} }
"#, "#,
@ -578,7 +578,7 @@ struct Foo {
} }
fn foo() { fn foo() {
Foo { Foo {
<|> $0
} }
} }
"#, "#,
@ -595,7 +595,7 @@ struct Foo {
} }
fn foo() { fn foo() {
Foo { Foo {
f: <|> f: $0
} }
} }
"#, "#,

View file

@ -31,7 +31,7 @@ mod tests {
macro_rules! foo { () => {} } macro_rules! foo { () => {} }
fn foo() {} fn foo() {}
<|> $0
"#, "#,
expect![[r#" expect![[r#"
ma foo!() macro_rules! foo ma foo!() macro_rules! foo

View file

@ -9,7 +9,7 @@ use crate::{CompletionItem, CompletionItemKind};
use crate::{context::CompletionContext, item::CompletionKind, Completions}; use crate::{context::CompletionContext, item::CompletionKind, Completions};
/// Complete mod declaration, i.e. `mod <|> ;` /// Complete mod declaration, i.e. `mod $0 ;`
pub(crate) fn complete_mod(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { pub(crate) fn complete_mod(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
let mod_under_caret = match &ctx.mod_declaration_under_caret { let mod_under_caret = match &ctx.mod_declaration_under_caret {
Some(mod_under_caret) if mod_under_caret.item_list().is_some() => return None, Some(mod_under_caret) if mod_under_caret.item_list().is_some() => return None,
@ -159,7 +159,7 @@ mod tests {
check( check(
r#" r#"
//- /lib.rs //- /lib.rs
mod <|> mod $0
//- /foo.rs //- /foo.rs
fn foo() {} fn foo() {}
//- /foo/ignored_foo.rs //- /foo/ignored_foo.rs
@ -181,7 +181,7 @@ mod tests {
check( check(
r#" r#"
//- /lib.rs //- /lib.rs
mod <|> { mod $0 {
} }
//- /foo.rs //- /foo.rs
@ -196,7 +196,7 @@ mod tests {
check( check(
r#" r#"
//- /main.rs //- /main.rs
mod <|> mod $0
//- /foo.rs //- /foo.rs
fn foo() {} fn foo() {}
//- /foo/ignored_foo.rs //- /foo/ignored_foo.rs
@ -219,7 +219,7 @@ mod tests {
r#" r#"
//- /main.rs //- /main.rs
mod tests { mod tests {
mod <|>; mod $0;
} }
//- /tests/foo.rs //- /tests/foo.rs
fn foo() {} fn foo() {}
@ -237,7 +237,7 @@ mod tests {
//- /lib.rs //- /lib.rs
mod foo; mod foo;
//- /foo.rs //- /foo.rs
mod <|>; mod $0;
//- /foo/bar.rs //- /foo/bar.rs
fn bar() {} fn bar() {}
//- /foo/bar/ignored_bar.rs //- /foo/bar/ignored_bar.rs
@ -262,7 +262,7 @@ mod tests {
mod foo; mod foo;
//- /foo.rs //- /foo.rs
mod bar { mod bar {
mod <|> mod $0
} }
//- /foo/bar/baz.rs //- /foo/bar/baz.rs
fn baz() {} fn baz() {}
@ -288,7 +288,7 @@ mod tests {
// //- /src/bin.rs // //- /src/bin.rs
// fn main() {} // fn main() {}
// //- /src/bin/foo.rs // //- /src/bin/foo.rs
// mod <|> // mod $0
// //- /src/bin/bar.rs // //- /src/bin/bar.rs
// fn bar() {} // fn bar() {}
// //- /src/bin/bar/bar_ignored.rs // //- /src/bin/bar/bar_ignored.rs
@ -307,7 +307,7 @@ mod tests {
//- /src/bin.rs crate:main //- /src/bin.rs crate:main
fn main() {} fn main() {}
//- /src/bin/foo.rs //- /src/bin/foo.rs
mod <|> mod $0
//- /src/bin/bar.rs //- /src/bin/bar.rs
mod foo; mod foo;
fn bar() {} fn bar() {}

View file

@ -71,7 +71,7 @@ static FOO: E = E::X;
struct Bar { f: u32 } struct Bar { f: u32 }
fn foo() { fn foo() {
match E::X { <|> } match E::X { $0 }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -92,7 +92,7 @@ macro_rules! m { ($e:expr) => { $e } }
enum E { X } enum E { X }
fn foo() { fn foo() {
m!(match E::X { <|> }) m!(match E::X { $0 })
} }
"#, "#,
expect![[r#" expect![[r#"
@ -115,7 +115,7 @@ static FOO: E = E::X;
struct Bar { f: u32 } struct Bar { f: u32 }
fn foo() { fn foo() {
let <|> let $0
} }
"#, "#,
expect![[r#" expect![[r#"
@ -133,7 +133,7 @@ enum E { X }
static FOO: E = E::X; static FOO: E = E::X;
struct Bar { f: u32 } struct Bar { f: u32 }
fn foo(<|>) { fn foo($0) {
} }
"#, "#,
expect![[r#" expect![[r#"
@ -149,7 +149,7 @@ fn foo(<|>) {
struct Bar { f: u32 } struct Bar { f: u32 }
fn foo() { fn foo() {
let <|> let $0
} }
"#, "#,
expect![[r#" expect![[r#"
@ -165,7 +165,7 @@ fn foo() {
struct Foo { bar: String, baz: String } struct Foo { bar: String, baz: String }
struct Bar(String, String); struct Bar(String, String);
struct Baz; struct Baz;
fn outer(<|>) {} fn outer($0) {}
"#, "#,
expect![[r#" expect![[r#"
bn Foo Foo { bar$1, baz$2 }: Foo$0 bn Foo Foo { bar$1, baz$2 }: Foo$0
@ -182,7 +182,7 @@ struct Foo { bar: String, baz: String }
struct Bar(String, String); struct Bar(String, String);
struct Baz; struct Baz;
fn outer() { fn outer() {
let <|> let $0
} }
"#, "#,
expect![[r#" expect![[r#"
@ -201,7 +201,7 @@ struct Bar(String, String);
struct Baz; struct Baz;
fn outer() { fn outer() {
match () { match () {
<|> $0
} }
} }
"#, "#,
@ -225,7 +225,7 @@ use foo::*;
fn outer() { fn outer() {
match () { match () {
<|> $0
} }
} }
"#, "#,
@ -244,7 +244,7 @@ fn outer() {
struct Foo(i32); struct Foo(i32);
fn main() { fn main() {
match Foo(92) { match Foo(92) {
<|>(92) => (), $0(92) => (),
} }
} }
"#, "#,

View file

@ -1,4 +1,4 @@
//! Postfix completions, like `Ok(10).ifl<|>` => `if let Ok() = Ok(10) { <|> }`. //! Postfix completions, like `Ok(10).ifl$0` => `if let Ok() = Ok(10) { $0 }`.
mod format_like; mod format_like;
@ -310,7 +310,7 @@ mod tests {
r#" r#"
fn main() { fn main() {
let bar = true; let bar = true;
bar.<|> bar.$0
} }
"#, "#,
expect![[r#" expect![[r#"
@ -342,7 +342,7 @@ fn foo(elt: bool) -> bool {
fn main() { fn main() {
let bar = true; let bar = true;
foo(bar.<|>) foo(bar.$0)
} }
"#, "#,
expect![[r#" expect![[r#"
@ -368,7 +368,7 @@ fn main() {
r#" r#"
fn main() { fn main() {
let bar: u8 = 12; let bar: u8 = 12;
bar.<|> bar.$0
} }
"#, "#,
expect![[r#" expect![[r#"
@ -392,7 +392,7 @@ fn main() {
check( check(
r#" r#"
fn main() { fn main() {
baz.l<|> baz.l$0
res res
} }
"#, "#,
@ -424,7 +424,7 @@ enum Option<T> { Some(T), None }
fn main() { fn main() {
let bar = Option::Some(true); let bar = Option::Some(true);
bar.<|> bar.$0
} }
"#, "#,
r#" r#"
@ -449,7 +449,7 @@ enum Result<T, E> { Ok(T), Err(E) }
fn main() { fn main() {
let bar = Result::Ok(true); let bar = Result::Ok(true);
bar.<|> bar.$0
} }
"#, "#,
r#" r#"
@ -468,7 +468,7 @@ fn main() {
#[test] #[test]
fn postfix_completion_works_for_ambiguous_float_literal() { fn postfix_completion_works_for_ambiguous_float_literal() {
check_edit("refm", r#"fn main() { 42.<|> }"#, r#"fn main() { &mut 42 }"#) check_edit("refm", r#"fn main() { 42.$0 }"#, r#"fn main() { &mut 42 }"#)
} }
#[test] #[test]
@ -479,7 +479,7 @@ fn main() {
macro_rules! m { ($e:expr) => { $e } } macro_rules! m { ($e:expr) => { $e } }
fn main() { fn main() {
let bar: u8 = 12; let bar: u8 = 12;
m!(bar.d<|>) m!(bar.d$0)
} }
"#, "#,
r#" r#"
@ -494,55 +494,47 @@ fn main() {
#[test] #[test]
fn postfix_completion_for_references() { fn postfix_completion_for_references() {
check_edit("dbg", r#"fn main() { &&42.<|> }"#, r#"fn main() { dbg!(&&42) }"#); check_edit("dbg", r#"fn main() { &&42.$0 }"#, r#"fn main() { dbg!(&&42) }"#);
check_edit("refm", r#"fn main() { &&42.<|> }"#, r#"fn main() { &&&mut 42 }"#); check_edit("refm", r#"fn main() { &&42.$0 }"#, r#"fn main() { &&&mut 42 }"#);
} }
#[test] #[test]
fn postfix_completion_for_format_like_strings() { fn postfix_completion_for_format_like_strings() {
check_edit( check_edit(
"format", "format",
r#"fn main() { "{some_var:?}".<|> }"#, r#"fn main() { "{some_var:?}".$0 }"#,
r#"fn main() { format!("{:?}", some_var) }"#, r#"fn main() { format!("{:?}", some_var) }"#,
); );
check_edit( check_edit(
"panic", "panic",
r#"fn main() { "Panic with {a}".<|> }"#, r#"fn main() { "Panic with {a}".$0 }"#,
r#"fn main() { panic!("Panic with {}", a) }"#, r#"fn main() { panic!("Panic with {}", a) }"#,
); );
check_edit( check_edit(
"println", "println",
r#"fn main() { "{ 2+2 } { SomeStruct { val: 1, other: 32 } :?}".<|> }"#, r#"fn main() { "{ 2+2 } { SomeStruct { val: 1, other: 32 } :?}".$0 }"#,
r#"fn main() { println!("{} {:?}", 2+2, SomeStruct { val: 1, other: 32 }) }"#, r#"fn main() { println!("{} {:?}", 2+2, SomeStruct { val: 1, other: 32 }) }"#,
); );
check_edit( check_edit(
"loge", "loge",
r#"fn main() { "{2+2}".<|> }"#, r#"fn main() { "{2+2}".$0 }"#,
r#"fn main() { log::error!("{}", 2+2) }"#, r#"fn main() { log::error!("{}", 2+2) }"#,
); );
check_edit( check_edit(
"logt", "logt",
r#"fn main() { "{2+2}".<|> }"#, r#"fn main() { "{2+2}".$0 }"#,
r#"fn main() { log::trace!("{}", 2+2) }"#, r#"fn main() { log::trace!("{}", 2+2) }"#,
); );
check_edit( check_edit(
"logd", "logd",
r#"fn main() { "{2+2}".<|> }"#, r#"fn main() { "{2+2}".$0 }"#,
r#"fn main() { log::debug!("{}", 2+2) }"#, r#"fn main() { log::debug!("{}", 2+2) }"#,
); );
check_edit( check_edit("logi", r#"fn main() { "{2+2}".$0 }"#, r#"fn main() { log::info!("{}", 2+2) }"#);
"logi", check_edit("logw", r#"fn main() { "{2+2}".$0 }"#, r#"fn main() { log::warn!("{}", 2+2) }"#);
r#"fn main() { "{2+2}".<|> }"#,
r#"fn main() { log::info!("{}", 2+2) }"#,
);
check_edit(
"logw",
r#"fn main() { "{2+2}".<|> }"#,
r#"fn main() { log::warn!("{}", 2+2) }"#,
);
check_edit( check_edit(
"loge", "loge",
r#"fn main() { "{2+2}".<|> }"#, r#"fn main() { "{2+2}".$0 }"#,
r#"fn main() { log::error!("{}", 2+2) }"#, r#"fn main() { log::error!("{}", 2+2) }"#,
); );
} }

View file

@ -1,4 +1,4 @@
//! Completion of paths, i.e. `some::prefix::<|>`. //! Completion of paths, i.e. `some::prefix::$0`.
use hir::{Adt, HasVisibility, PathResolution, ScopeDef}; use hir::{Adt, HasVisibility, PathResolution, ScopeDef};
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
@ -38,7 +38,7 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
if let ScopeDef::Unknown = def { if let ScopeDef::Unknown = def {
if let Some(name_ref) = ctx.name_ref_syntax.as_ref() { if let Some(name_ref) = ctx.name_ref_syntax.as_ref() {
if name_ref.syntax().text() == name.to_string().as_str() { if name_ref.syntax().text() == name.to_string().as_str() {
// for `use self::foo<|>`, don't suggest `foo` as a completion // for `use self::foo$0`, don't suggest `foo` as a completion
mark::hit!(dont_complete_current_use); mark::hit!(dont_complete_current_use);
continue; continue;
} }
@ -173,7 +173,7 @@ mod tests {
#[test] #[test]
fn dont_complete_current_use() { fn dont_complete_current_use() {
mark::check!(dont_complete_current_use); mark::check!(dont_complete_current_use);
check(r#"use self::foo<|>;"#, expect![[""]]); check(r#"use self::foo$0;"#, expect![[""]]);
} }
#[test] #[test]
@ -181,7 +181,7 @@ mod tests {
check( check(
r#" r#"
mod foo { pub struct S; } mod foo { pub struct S; }
use self::{foo::*, bar<|>}; use self::{foo::*, bar$0};
"#, "#,
expect![[r#" expect![[r#"
st S st S
@ -192,18 +192,18 @@ use self::{foo::*, bar<|>};
#[test] #[test]
fn dont_complete_primitive_in_use() { fn dont_complete_primitive_in_use() {
check_builtin(r#"use self::<|>;"#, expect![[""]]); check_builtin(r#"use self::$0;"#, expect![[""]]);
} }
#[test] #[test]
fn dont_complete_primitive_in_module_scope() { fn dont_complete_primitive_in_module_scope() {
check_builtin(r#"fn foo() { self::<|> }"#, expect![[""]]); check_builtin(r#"fn foo() { self::$0 }"#, expect![[""]]);
} }
#[test] #[test]
fn completes_primitives() { fn completes_primitives() {
check_builtin( check_builtin(
r#"fn main() { let _: <|> = 92; }"#, r#"fn main() { let _: $0 = 92; }"#,
expect![[r#" expect![[r#"
bt u32 bt u32
bt bool bt bool
@ -230,7 +230,7 @@ use self::{foo::*, bar<|>};
fn completes_mod_with_same_name_as_function() { fn completes_mod_with_same_name_as_function() {
check( check(
r#" r#"
use self::my::<|>; use self::my::$0;
mod my { pub struct Bar; } mod my { pub struct Bar; }
fn my() {} fn my() {}
@ -245,7 +245,7 @@ fn my() {}
fn filters_visibility() { fn filters_visibility() {
check( check(
r#" r#"
use self::my::<|>; use self::my::$0;
mod my { mod my {
struct Bar; struct Bar;
@ -264,7 +264,7 @@ mod my {
fn completes_use_item_starting_with_self() { fn completes_use_item_starting_with_self() {
check( check(
r#" r#"
use self::m::<|>; use self::m::$0;
mod m { pub struct Bar; } mod m { pub struct Bar; }
"#, "#,
@ -282,7 +282,7 @@ mod m { pub struct Bar; }
mod foo; mod foo;
struct Spam; struct Spam;
//- /foo.rs //- /foo.rs
use crate::Sp<|> use crate::Sp$0
"#, "#,
expect![[r#" expect![[r#"
md foo md foo
@ -299,7 +299,7 @@ use crate::Sp<|>
mod foo; mod foo;
struct Spam; struct Spam;
//- /foo.rs //- /foo.rs
use crate::{Sp<|>}; use crate::{Sp$0};
"#, "#,
expect![[r#" expect![[r#"
md foo md foo
@ -320,7 +320,7 @@ pub mod bar {
} }
} }
//- /foo.rs //- /foo.rs
use crate::{bar::{baz::Sp<|>}}; use crate::{bar::{baz::Sp$0}};
"#, "#,
expect![[r#" expect![[r#"
st Spam st Spam
@ -333,7 +333,7 @@ use crate::{bar::{baz::Sp<|>}};
check( check(
r#" r#"
enum E { Foo, Bar(i32) } enum E { Foo, Bar(i32) }
fn foo() { let _ = E::<|> } fn foo() { let _ = E::$0 }
"#, "#,
expect![[r#" expect![[r#"
ev Foo () ev Foo ()
@ -356,7 +356,7 @@ impl S {
type T = i32; type T = i32;
} }
fn foo() { let _ = S::<|> } fn foo() { let _ = S::$0 }
"#, "#,
expect![[r#" expect![[r#"
fn a() fn a() fn a() fn a()
@ -384,7 +384,7 @@ mod m {
} }
} }
fn foo() { let _ = S::<|> } fn foo() { let _ = S::$0 }
"#, "#,
expect![[r#" expect![[r#"
fn public_method() pub(crate) fn public_method() fn public_method() pub(crate) fn public_method()
@ -401,7 +401,7 @@ fn foo() { let _ = S::<|> }
enum E {}; enum E {};
impl E { fn m() { } } impl E { fn m() { } }
fn foo() { let _ = E::<|> } fn foo() { let _ = E::$0 }
"#, "#,
expect![[r#" expect![[r#"
fn m() fn m() fn m() fn m()
@ -416,7 +416,7 @@ fn foo() { let _ = E::<|> }
union U {}; union U {};
impl U { fn m() { } } impl U { fn m() { } }
fn foo() { let _ = U::<|> } fn foo() { let _ = U::$0 }
"#, "#,
expect![[r#" expect![[r#"
fn m() fn m() fn m() fn m()
@ -429,7 +429,7 @@ fn foo() { let _ = U::<|> }
check( check(
r#" r#"
//- /main.rs crate:main deps:foo //- /main.rs crate:main deps:foo
use foo::<|>; use foo::$0;
//- /foo/lib.rs crate:foo //- /foo/lib.rs crate:foo
pub mod bar { pub struct S; } pub mod bar { pub struct S; }
@ -446,7 +446,7 @@ pub mod bar { pub struct S; }
r#" r#"
trait Trait { fn m(); } trait Trait { fn m(); }
fn foo() { let _ = Trait::<|> } fn foo() { let _ = Trait::$0 }
"#, "#,
expect![[r#" expect![[r#"
fn m() fn m() fn m() fn m()
@ -463,7 +463,7 @@ trait Trait { fn m(); }
struct S; struct S;
impl Trait for S {} impl Trait for S {}
fn foo() { let _ = S::<|> } fn foo() { let _ = S::$0 }
"#, "#,
expect![[r#" expect![[r#"
fn m() fn m() fn m() fn m()
@ -480,7 +480,7 @@ trait Trait { fn m(); }
struct S; struct S;
impl Trait for S {} impl Trait for S {}
fn foo() { let _ = <S as Trait>::<|> } fn foo() { let _ = <S as Trait>::$0 }
"#, "#,
expect![[r#" expect![[r#"
fn m() fn m() fn m() fn m()
@ -506,7 +506,7 @@ trait Sub: Super {
fn submethod(&self) {} fn submethod(&self) {}
} }
fn foo<T: Sub>() { T::<|> } fn foo<T: Sub>() { T::$0 }
"#, "#,
expect![[r#" expect![[r#"
ta SubTy type SubTy; ta SubTy type SubTy;
@ -544,7 +544,7 @@ impl<T> Super for Wrap<T> {}
impl<T> Sub for Wrap<T> { impl<T> Sub for Wrap<T> {
fn subfunc() { fn subfunc() {
// Should be able to assume `Self: Sub + Super` // Should be able to assume `Self: Sub + Super`
Self::<|> Self::$0
} }
} }
"#, "#,
@ -570,7 +570,7 @@ impl S { fn foo() {} }
type T = S; type T = S;
impl T { fn bar() {} } impl T { fn bar() {} }
fn main() { T::<|>; } fn main() { T::$0; }
"#, "#,
expect![[r#" expect![[r#"
fn foo() fn foo() fn foo() fn foo()
@ -586,7 +586,7 @@ fn main() { T::<|>; }
#[macro_export] #[macro_export]
macro_rules! foo { () => {} } macro_rules! foo { () => {} }
fn main() { let _ = crate::<|> } fn main() { let _ = crate::$0 }
"#, "#,
expect![[r##" expect![[r##"
fn main() fn main() fn main() fn main()
@ -604,7 +604,7 @@ mod a {
const A: usize = 0; const A: usize = 0;
mod b { mod b {
const B: usize = 0; const B: usize = 0;
mod c { use super::super::<|> } mod c { use super::super::$0 }
} }
} }
"#, "#,
@ -619,7 +619,7 @@ mod a {
fn completes_reexported_items_under_correct_name() { fn completes_reexported_items_under_correct_name() {
check( check(
r#" r#"
fn foo() { self::m::<|> } fn foo() { self::m::$0 }
mod m { mod m {
pub use super::p::wrong_fn as right_fn; pub use super::p::wrong_fn as right_fn;
@ -642,7 +642,7 @@ mod p {
check_edit( check_edit(
"RightType", "RightType",
r#" r#"
fn foo() { self::m::<|> } fn foo() { self::m::$0 }
mod m { mod m {
pub use super::p::wrong_fn as right_fn; pub use super::p::wrong_fn as right_fn;
@ -677,7 +677,7 @@ mod p {
check( check(
r#" r#"
macro_rules! m { ($e:expr) => { $e } } macro_rules! m { ($e:expr) => { $e } }
fn main() { m!(self::f<|>); } fn main() { m!(self::f$0); }
fn foo() {} fn foo() {}
"#, "#,
expect![[r#" expect![[r#"
@ -691,7 +691,7 @@ fn foo() {}
fn function_mod_share_name() { fn function_mod_share_name() {
check( check(
r#" r#"
fn foo() { self::m::<|> } fn foo() { self::m::$0 }
mod m { mod m {
pub mod z {} pub mod z {}
@ -716,7 +716,7 @@ impl<K, V> HashMap<K, V, RandomState> {
pub fn new() -> HashMap<K, V, RandomState> { } pub fn new() -> HashMap<K, V, RandomState> { }
} }
fn foo() { fn foo() {
HashMap::<|> HashMap::$0
} }
"#, "#,
expect![[r#" expect![[r#"
@ -730,7 +730,7 @@ fn foo() {
check( check(
r#" r#"
mod foo { pub struct Foo; } mod foo { pub struct Foo; }
#[foo::<|>] #[foo::$0]
fn f() {} fn f() {}
"#, "#,
expect![[""]], expect![[""]],
@ -749,7 +749,7 @@ fn foo(
} }
fn main() { fn main() {
fo<|> fo$0
} }
"#, "#,
expect![[r#" expect![[r#"
@ -770,7 +770,7 @@ enum Foo {
impl Foo { impl Foo {
fn foo(self) { fn foo(self) {
Self::<|> Self::$0
} }
} }
"#, "#,

View file

@ -99,7 +99,7 @@ impl core::default::Default for S {
fn process(f: S) { fn process(f: S) {
let other = S { let other = S {
foo: 5, foo: 5,
.<|> .$0
}; };
} }
"#; "#;
@ -139,7 +139,7 @@ impl core::default::Default for S {
fn process(f: S) { fn process(f: S) {
let other = S { let other = S {
foo: 5, foo: 5,
.<|> .$0
}; };
} }
"#, "#,
@ -173,7 +173,7 @@ struct S { foo: u32, bar: usize }
fn process(f: S) { fn process(f: S) {
let other = S { let other = S {
foo: 5, foo: 5,
.<|> .$0
}; };
} }
"#; "#;
@ -201,7 +201,7 @@ struct S { foo: u32 }
fn process(f: S) { fn process(f: S) {
match f { match f {
S { f<|>: 92 } => (), S { f$0: 92 } => (),
} }
} }
"#, "#,
@ -219,7 +219,7 @@ enum E { S { foo: u32, bar: () } }
fn process(e: E) { fn process(e: E) {
match e { match e {
E::S { <|> } => (), E::S { $0 } => (),
} }
} }
"#, "#,
@ -239,7 +239,7 @@ struct S { foo: u32 }
fn process(f: S) { fn process(f: S) {
m!(match f { m!(match f {
S { f<|>: 92 } => (), S { f$0: 92 } => (),
}) })
} }
", ",
@ -263,7 +263,7 @@ fn main() {
foo1: 1, foo2: 2, foo1: 1, foo2: 2,
bar: 3, baz: 4, bar: 3, baz: 4,
}; };
if let S { foo1, foo2: a, <|> } = s {} if let S { foo1, foo2: a, $0 } = s {}
} }
"#, "#,
expect![[r#" expect![[r#"
@ -279,7 +279,7 @@ fn main() {
r#" r#"
struct A { the_field: u32 } struct A { the_field: u32 }
fn foo() { fn foo() {
A { the<|> } A { the$0 }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -294,7 +294,7 @@ fn foo() {
r#" r#"
enum E { A { a: u32 } } enum E { A { a: u32 } }
fn foo() { fn foo() {
let _ = E::A { <|> } let _ = E::A { $0 }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -311,7 +311,7 @@ struct A { a: u32 }
struct B { b: u32 } struct B { b: u32 }
fn foo() { fn foo() {
let _: A = B { <|> } let _: A = B { $0 }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -327,7 +327,7 @@ fn foo() {
struct A<T> { a: T } struct A<T> { a: T }
fn foo() { fn foo() {
let _: A<u32> = A { <|> } let _: A<u32> = A { $0 }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -343,7 +343,7 @@ fn foo() {
macro_rules! m { ($e:expr) => { $e } } macro_rules! m { ($e:expr) => { $e } }
struct A { the_field: u32 } struct A { the_field: u32 }
fn foo() { fn foo() {
m!(A { the<|> }) m!(A { the$0 })
} }
"#, "#,
expect![[r#" expect![[r#"
@ -363,7 +363,7 @@ struct S {
fn main() { fn main() {
let foo1 = 1; let foo1 = 1;
let s = S { foo1, foo2: 5, <|> } let s = S { foo1, foo2: 5, $0 }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -381,7 +381,7 @@ struct S { foo1: u32, foo2: u32 }
fn main() { fn main() {
let foo1 = 1; let foo1 = 1;
let s = S { foo1, <|> .. loop {} } let s = S { foo1, $0 .. loop {} }
} }
"#, "#,
expect![[r#" expect![[r#"

View file

@ -83,7 +83,7 @@ mod tests {
#[test] #[test]
fn completes_snippets_in_expressions() { fn completes_snippets_in_expressions() {
check( check(
r#"fn foo(x: i32) { <|> }"#, r#"fn foo(x: i32) { $0 }"#,
expect![[r#" expect![[r#"
sn pd sn pd
sn ppd sn ppd
@ -93,8 +93,8 @@ mod tests {
#[test] #[test]
fn should_not_complete_snippets_in_path() { fn should_not_complete_snippets_in_path() {
check(r#"fn foo(x: i32) { ::foo<|> }"#, expect![[""]]); check(r#"fn foo(x: i32) { ::foo$0 }"#, expect![[""]]);
check(r#"fn foo(x: i32) { ::<|> }"#, expect![[""]]); check(r#"fn foo(x: i32) { ::$0 }"#, expect![[""]]);
} }
#[test] #[test]
@ -103,7 +103,7 @@ mod tests {
r#" r#"
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
<|> $0
} }
"#, "#,
expect![[r#" expect![[r#"

View file

@ -15,7 +15,7 @@
//! } //! }
//! //!
//! impl SomeTrait for () { //! impl SomeTrait for () {
//! fn f<|> //! fn f$0
//! } //! }
//! ``` //! ```
//! //!
@ -27,7 +27,7 @@
//! # } //! # }
//! //!
//! impl SomeTrait for () { //! impl SomeTrait for () {
//! fn foo() {}<|> //! fn foo() {}$0
//! } //! }
//! ``` //! ```
@ -82,7 +82,7 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
fn completion_match(ctx: &CompletionContext) -> Option<(ImplCompletionKind, SyntaxNode, Impl)> { fn completion_match(ctx: &CompletionContext) -> Option<(ImplCompletionKind, SyntaxNode, Impl)> {
let mut token = ctx.token.clone(); let mut token = ctx.token.clone();
// For keywork without name like `impl .. { fn <|> }`, the current position is inside // For keywork without name like `impl .. { fn $0 }`, the current position is inside
// the whitespace token, which is outside `FN` syntax node. // the whitespace token, which is outside `FN` syntax node.
// We need to follow the previous token in this case. // We need to follow the previous token in this case.
if token.kind() == SyntaxKind::WHITESPACE { if token.kind() == SyntaxKind::WHITESPACE {
@ -90,20 +90,20 @@ fn completion_match(ctx: &CompletionContext) -> Option<(ImplCompletionKind, Synt
} }
let impl_item_offset = match token.kind() { let impl_item_offset = match token.kind() {
// `impl .. { const <|> }` // `impl .. { const $0 }`
// ERROR 0 // ERROR 0
// CONST_KW <- * // CONST_KW <- *
SyntaxKind::CONST_KW => 0, SyntaxKind::CONST_KW => 0,
// `impl .. { fn/type <|> }` // `impl .. { fn/type $0 }`
// FN/TYPE_ALIAS 0 // FN/TYPE_ALIAS 0
// FN_KW <- * // FN_KW <- *
SyntaxKind::FN_KW | SyntaxKind::TYPE_KW => 0, SyntaxKind::FN_KW | SyntaxKind::TYPE_KW => 0,
// `impl .. { fn/type/const foo<|> }` // `impl .. { fn/type/const foo$0 }`
// FN/TYPE_ALIAS/CONST 1 // FN/TYPE_ALIAS/CONST 1
// NAME 0 // NAME 0
// IDENT <- * // IDENT <- *
SyntaxKind::IDENT if token.parent().kind() == SyntaxKind::NAME => 1, SyntaxKind::IDENT if token.parent().kind() == SyntaxKind::NAME => 1,
// `impl .. { foo<|> }` // `impl .. { foo$0 }`
// MACRO_CALL 3 // MACRO_CALL 3
// PATH 2 // PATH 2
// PATH_SEGMENT 1 // PATH_SEGMENT 1
@ -120,7 +120,7 @@ fn completion_match(ctx: &CompletionContext) -> Option<(ImplCompletionKind, Synt
// <item> // <item>
let impl_def = ast::Impl::cast(impl_item.parent()?.parent()?)?; let impl_def = ast::Impl::cast(impl_item.parent()?.parent()?)?;
let kind = match impl_item.kind() { let kind = match impl_item.kind() {
// `impl ... { const <|> fn/type/const }` // `impl ... { const $0 fn/type/const }`
_ if token.kind() == SyntaxKind::CONST_KW => ImplCompletionKind::Const, _ if token.kind() == SyntaxKind::CONST_KW => ImplCompletionKind::Const,
SyntaxKind::CONST | SyntaxKind::ERROR => ImplCompletionKind::Const, SyntaxKind::CONST | SyntaxKind::ERROR => ImplCompletionKind::Const,
SyntaxKind::TYPE_ALIAS => ImplCompletionKind::TypeAlias, SyntaxKind::TYPE_ALIAS => ImplCompletionKind::TypeAlias,
@ -267,7 +267,7 @@ trait Test {
struct T; struct T;
impl Test for T { impl Test for T {
t<|> t$0
} }
"#, "#,
expect![[" expect![["
@ -287,7 +287,7 @@ struct T;
impl Test for T { impl Test for T {
fn test() { fn test() {
t<|> t$0
} }
} }
", ",
@ -301,7 +301,7 @@ struct T;
impl Test for T { impl Test for T {
fn test() { fn test() {
fn t<|> fn t$0
} }
} }
", ",
@ -315,7 +315,7 @@ struct T;
impl Test for T { impl Test for T {
fn test() { fn test() {
fn <|> fn $0
} }
} }
", ",
@ -330,7 +330,7 @@ struct T;
impl Test for T { impl Test for T {
fn test() { fn test() {
foo.<|> foo.$0
} }
} }
", ",
@ -343,7 +343,7 @@ trait Test { fn test(_: i32); fn test2(); }
struct T; struct T;
impl Test for T { impl Test for T {
fn test(t<|>) fn test(t$0)
} }
", ",
expect![[""]], expect![[""]],
@ -355,7 +355,7 @@ trait Test { fn test(_: fn()); fn test2(); }
struct T; struct T;
impl Test for T { impl Test for T {
fn test(f: fn <|>) fn test(f: fn $0)
} }
", ",
expect![[""]], expect![[""]],
@ -370,7 +370,7 @@ trait Test { const TEST: fn(); const TEST2: u32; type Test; fn test(); }
struct T; struct T;
impl Test for T { impl Test for T {
const TEST: fn <|> const TEST: fn $0
} }
", ",
expect![[""]], expect![[""]],
@ -382,7 +382,7 @@ trait Test { const TEST: u32; const TEST2: u32; type Test; fn test(); }
struct T; struct T;
impl Test for T { impl Test for T {
const TEST: T<|> const TEST: T$0
} }
", ",
expect![[""]], expect![[""]],
@ -394,7 +394,7 @@ trait Test { const TEST: u32; const TEST2: u32; type Test; fn test(); }
struct T; struct T;
impl Test for T { impl Test for T {
const TEST: u32 = f<|> const TEST: u32 = f$0
} }
", ",
expect![[""]], expect![[""]],
@ -407,7 +407,7 @@ struct T;
impl Test for T { impl Test for T {
const TEST: u32 = { const TEST: u32 = {
t<|> t$0
}; };
} }
", ",
@ -421,7 +421,7 @@ struct T;
impl Test for T { impl Test for T {
const TEST: u32 = { const TEST: u32 = {
fn <|> fn $0
}; };
} }
", ",
@ -435,7 +435,7 @@ struct T;
impl Test for T { impl Test for T {
const TEST: u32 = { const TEST: u32 = {
fn t<|> fn t$0
}; };
} }
", ",
@ -451,7 +451,7 @@ trait Test { type Test; type Test2; fn test(); }
struct T; struct T;
impl Test for T { impl Test for T {
type Test = T<|>; type Test = T$0;
} }
", ",
expect![[""]], expect![[""]],
@ -463,7 +463,7 @@ trait Test { type Test; type Test2; fn test(); }
struct T; struct T;
impl Test for T { impl Test for T {
type Test = fn <|>; type Test = fn $0;
} }
", ",
expect![[""]], expect![[""]],
@ -481,7 +481,7 @@ trait Test {
struct T; struct T;
impl Test for T { impl Test for T {
t<|> t$0
} }
"#, "#,
r#" r#"
@ -510,7 +510,7 @@ trait Test {
struct T; struct T;
impl Test for T { impl Test for T {
fn t<|> fn t$0
} }
"#, "#,
r#" r#"
@ -540,7 +540,7 @@ struct T;
impl Test for T { impl Test for T {
fn foo() {} fn foo() {}
fn f<|> fn f$0
} }
"#, "#,
expect![[r#" expect![[r#"
@ -560,7 +560,7 @@ trait Test {
struct T; struct T;
impl Test for T { impl Test for T {
fn f<|> fn f$0
} }
"#, "#,
r#" r#"
@ -585,7 +585,7 @@ trait Test {
struct T; struct T;
impl Test for T { impl Test for T {
fn f<|> fn f$0
} }
"#, "#,
r#" r#"
@ -614,7 +614,7 @@ trait Test {
} }
impl Test for () { impl Test for () {
type S<|> type S$0
} }
"#, "#,
" "
@ -639,7 +639,7 @@ trait Test {
} }
impl Test for () { impl Test for () {
const S<|> const S$0
} }
"#, "#,
" "
@ -661,7 +661,7 @@ trait Test {
} }
impl Test for () { impl Test for () {
const S<|> const S$0
} }
"#, "#,
" "
@ -724,7 +724,7 @@ impl Test for T {{
// Enumerate some possible next siblings. // Enumerate some possible next siblings.
for next_sibling in &[ for next_sibling in &[
"", "",
"fn other_fn() {}", // `const <|> fn` -> `const fn` "fn other_fn() {}", // `const $0 fn` -> `const fn`
"type OtherType = i32;", "type OtherType = i32;",
"const OTHER_CONST: i32 = 0;", "const OTHER_CONST: i32 = 0;",
"async fn other_fn() {}", "async fn other_fn() {}",
@ -733,9 +733,9 @@ impl Test for T {{
"default type OtherType = i32;", "default type OtherType = i32;",
"default const OTHER_CONST: i32 = 0;", "default const OTHER_CONST: i32 = 0;",
] { ] {
test("bar", "fn <|>", "fn bar() {\n $0\n}", next_sibling); test("bar", "fn $0", "fn bar() {\n $0\n}", next_sibling);
test("Foo", "type <|>", "type Foo = ", next_sibling); test("Foo", "type $0", "type Foo = ", next_sibling);
test("CONST", "const <|>", "const CONST: u16 = ", next_sibling); test("CONST", "const $0", "const CONST: u16 = ", next_sibling);
} }
} }
} }

View file

@ -85,7 +85,7 @@ fn complete_enum_variants(acc: &mut Completions, ctx: &CompletionContext, ty: &T
// //
// ``` // ```
// fn main() { // fn main() {
// pda<|> // pda$0
// } // }
// # pub mod std { pub mod marker { pub struct PhantomData { } } } // # pub mod std { pub mod marker { pub struct PhantomData { } } }
// ``` // ```
@ -212,7 +212,7 @@ mod tests {
mark::check!(self_fulfilling_completion); mark::check!(self_fulfilling_completion);
check( check(
r#" r#"
use foo<|> use foo$0
use std::collections; use std::collections;
"#, "#,
expect![[r#" expect![[r#"
@ -229,7 +229,7 @@ enum Enum { A, B }
fn quux(x: Option<Enum>) { fn quux(x: Option<Enum>) {
match x { match x {
None => (), None => (),
Some(en<|> @ Enum::A) => (), Some(en$0 @ Enum::A) => (),
} }
} }
"#, "#,
@ -245,7 +245,7 @@ enum Enum { A, B }
fn quux(x: Option<Enum>) { fn quux(x: Option<Enum>) {
match x { match x {
None => (), None => (),
Some(ref en<|>) => (), Some(ref en$0) => (),
} }
} }
"#, "#,
@ -261,7 +261,7 @@ enum Enum { A, B }
fn quux(x: Option<Enum>) { fn quux(x: Option<Enum>) {
match x { match x {
None => (), None => (),
Some(En<|>) => (), Some(En$0) => (),
} }
} }
"#, "#,
@ -277,7 +277,7 @@ fn quux(x: Option<Enum>) {
r#" r#"
fn quux(x: i32) { fn quux(x: i32) {
let y = 92; let y = 92;
1 + <|>; 1 + $0;
let z = (); let z = ();
} }
"#, "#,
@ -299,7 +299,7 @@ fn quux() {
}; };
if let Some(a) = bar() { if let Some(a) = bar() {
let b = 62; let b = 62;
1 + <|> 1 + $0
} }
} }
"#, "#,
@ -316,7 +316,7 @@ fn quux() {
check( check(
r#" r#"
fn quux() { fn quux() {
for x in &[1, 2, 3] { <|> } for x in &[1, 2, 3] { $0 }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -334,7 +334,7 @@ fn quux() {
r#" r#"
fn main() { fn main() {
let wherewolf = 92; let wherewolf = 92;
drop(where<|>) drop(where$0)
} }
"#, "#,
r#" r#"
@ -349,7 +349,7 @@ fn main() {
#[test] #[test]
fn completes_generic_params() { fn completes_generic_params() {
check( check(
r#"fn quux<T>() { <|> }"#, r#"fn quux<T>() { $0 }"#,
expect![[r#" expect![[r#"
tp T tp T
fn quux() fn quux<T>() fn quux() fn quux<T>()
@ -360,7 +360,7 @@ fn main() {
#[test] #[test]
fn completes_generic_params_in_struct() { fn completes_generic_params_in_struct() {
check( check(
r#"struct S<T> { x: <|>}"#, r#"struct S<T> { x: $0}"#,
expect![[r#" expect![[r#"
tp Self tp Self
tp T tp T
@ -372,7 +372,7 @@ fn main() {
#[test] #[test]
fn completes_self_in_enum() { fn completes_self_in_enum() {
check( check(
r#"enum X { Y(<|>) }"#, r#"enum X { Y($0) }"#,
expect![[r#" expect![[r#"
tp Self tp Self
en X en X
@ -386,7 +386,7 @@ fn main() {
r#" r#"
struct S; struct S;
enum E {} enum E {}
fn quux() { <|> } fn quux() { $0 }
"#, "#,
expect![[r#" expect![[r#"
st S st S
@ -403,7 +403,7 @@ fn quux() { <|> }
"_alpha", "_alpha",
r#" r#"
fn main() { fn main() {
_<|> _$0
} }
fn _alpha() {} fn _alpha() {}
"#, "#,
@ -421,7 +421,7 @@ fn _alpha() {}
check( check(
r#" r#"
//- /lib.rs crate:main deps:other_crate //- /lib.rs crate:main deps:other_crate
use <|>; use $0;
//- /other_crate/lib.rs crate:other_crate //- /other_crate/lib.rs crate:other_crate
// nothing here // nothing here
@ -439,7 +439,7 @@ use <|>;
struct Foo; struct Foo;
mod m { mod m {
struct Bar; struct Bar;
fn quux() { <|> } fn quux() { $0 }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -454,7 +454,7 @@ mod m {
check( check(
r#" r#"
struct Foo; struct Foo;
fn x() -> <|> fn x() -> $0
"#, "#,
expect![[r#" expect![[r#"
st Foo st Foo
@ -471,7 +471,7 @@ fn foo() {
let bar = 92; let bar = 92;
{ {
let bar = 62; let bar = 62;
drop(<|>) drop($0)
} }
} }
"#, "#,
@ -487,7 +487,7 @@ fn foo() {
#[test] #[test]
fn completes_self_in_methods() { fn completes_self_in_methods() {
check( check(
r#"impl S { fn foo(&self) { <|> } }"#, r#"impl S { fn foo(&self) { $0 } }"#,
expect![[r#" expect![[r#"
bn self &{unknown} bn self &{unknown}
tp Self tp Self
@ -500,7 +500,7 @@ fn foo() {
check( check(
r#" r#"
//- /main.rs crate:main deps:std //- /main.rs crate:main deps:std
fn foo() { let x: <|> } fn foo() { let x: $0 }
//- /std/lib.rs crate:std //- /std/lib.rs crate:std
#[prelude_import] #[prelude_import]
@ -521,7 +521,7 @@ mod prelude { struct Option; }
check( check(
r#" r#"
//- /main.rs crate:main deps:core,std //- /main.rs crate:main deps:core,std
fn foo() { let x: <|> } fn foo() { let x: $0 }
//- /core/lib.rs crate:core //- /core/lib.rs crate:core
#[prelude_import] #[prelude_import]
@ -562,7 +562,7 @@ mod m2 {
macro_rules! baz { () => {} } macro_rules! baz { () => {} }
} }
fn main() { let v = <|> } fn main() { let v = $0 }
"#, "#,
expect![[r##" expect![[r##"
md m1 md m1
@ -581,7 +581,7 @@ fn main() { let v = <|> }
check( check(
r#" r#"
macro_rules! foo { () => {} } macro_rules! foo { () => {} }
fn foo() { <|> } fn foo() { $0 }
"#, "#,
expect![[r#" expect![[r#"
fn foo() fn foo() fn foo() fn foo()
@ -595,7 +595,7 @@ fn foo() { <|> }
check( check(
r#" r#"
macro_rules! foo { () => {} } macro_rules! foo { () => {} }
fn main() { let x: <|> } fn main() { let x: $0 }
"#, "#,
expect![[r#" expect![[r#"
fn main() fn main() fn main() fn main()
@ -609,7 +609,7 @@ fn main() { let x: <|> }
check( check(
r#" r#"
macro_rules! foo { () => {} } macro_rules! foo { () => {} }
fn main() { <|> } fn main() { $0 }
"#, "#,
expect![[r#" expect![[r#"
fn main() fn main() fn main() fn main()
@ -623,7 +623,7 @@ fn main() { <|> }
check( check(
r#" r#"
fn main() { fn main() {
return f<|>; return f$0;
fn frobnicate() {} fn frobnicate() {}
} }
"#, "#,
@ -641,7 +641,7 @@ fn main() {
macro_rules! m { ($e:expr) => { $e } } macro_rules! m { ($e:expr) => { $e } }
fn quux(x: i32) { fn quux(x: i32) {
let y = 92; let y = 92;
m!(<|>); m!($0);
} }
"#, "#,
expect![[r#" expect![[r#"
@ -660,7 +660,7 @@ fn quux(x: i32) {
macro_rules! m { ($e:expr) => { $e } } macro_rules! m { ($e:expr) => { $e } }
fn quux(x: i32) { fn quux(x: i32) {
let y = 92; let y = 92;
m!(x<|>); m!(x$0);
} }
", ",
expect![[r#" expect![[r#"
@ -679,7 +679,7 @@ fn quux(x: i32) {
macro_rules! m { ($e:expr) => { $e } } macro_rules! m { ($e:expr) => { $e } }
fn quux(x: i32) { fn quux(x: i32) {
let y = 92; let y = 92;
m!(x<|> m!(x$0
} }
"#, "#,
expect![[r#" expect![[r#"
@ -697,7 +697,7 @@ fn quux(x: i32) {
r#" r#"
use spam::Quux; use spam::Quux;
fn main() { <|> } fn main() { $0 }
"#, "#,
expect![[r#" expect![[r#"
fn main() fn main() fn main() fn main()
@ -714,7 +714,7 @@ enum Foo { Bar, Baz, Quux }
fn main() { fn main() {
let foo = Foo::Quux; let foo = Foo::Quux;
match foo { Qu<|> } match foo { Qu$0 }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -734,7 +734,7 @@ enum Foo { Bar, Baz, Quux }
fn main() { fn main() {
let foo = Foo::Quux; let foo = Foo::Quux;
match &foo { Qu<|> } match &foo { Qu$0 }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -754,7 +754,7 @@ enum Foo { Bar, Baz, Quux }
fn main() { fn main() {
let foo = Foo::Quux; let foo = Foo::Quux;
if let Qu<|> = foo { } if let Qu$0 = foo { }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -771,7 +771,7 @@ fn main() {
check( check(
r#" r#"
enum Foo { Bar, Baz, Quux } enum Foo { Bar, Baz, Quux }
fn main() { let foo: Foo = Q<|> } fn main() { let foo: Foo = Q$0 }
"#, "#,
expect![[r#" expect![[r#"
ev Foo::Bar () ev Foo::Bar ()
@ -788,7 +788,7 @@ fn main() { let foo: Foo = Q<|> }
check( check(
r#" r#"
mod m { pub enum E { V } } mod m { pub enum E { V } }
fn f() -> m::E { V<|> } fn f() -> m::E { V$0 }
"#, "#,
expect![[r#" expect![[r#"
ev m::E::V () ev m::E::V ()
@ -803,7 +803,7 @@ fn f() -> m::E { V<|> }
check( check(
r#" r#"
struct Foo; struct Foo;
#[<|>] #[$0]
fn f() {} fn f() {}
"#, "#,
expect![[""]], expect![[""]],
@ -817,7 +817,7 @@ fn f() {}
trait MyTrait {} trait MyTrait {}
struct MyStruct {} struct MyStruct {}
impl My<|> impl My$0
"#, "#,
expect![[r#" expect![[r#"
tp Self tp Self
@ -840,7 +840,7 @@ pub mod io {
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
stdi<|> stdi$0
} }
"#, "#,
r#" r#"
@ -868,7 +868,7 @@ macro_rules! macro_with_curlies {
//- /main.rs crate:main deps:dep //- /main.rs crate:main deps:dep
fn main() { fn main() {
curli<|> curli$0
} }
"#, "#,
r#" r#"
@ -898,7 +898,7 @@ pub mod some_module {
use dep::{FirstStruct, some_module::SecondStruct}; use dep::{FirstStruct, some_module::SecondStruct};
fn main() { fn main() {
this<|> this$0
} }
"#, "#,
r#" r#"
@ -936,7 +936,7 @@ pub mod some_module {
use dep::{FirstStruct, some_module::SecondStruct}; use dep::{FirstStruct, some_module::SecondStruct};
fn main() { fn main() {
hir<|> hir$0
} }
"#, "#,
expect![[r#" expect![[r#"

View file

@ -63,7 +63,7 @@ pub(crate) struct CompletionContext<'a> {
pub(super) is_expr: bool, pub(super) is_expr: bool,
/// Something is typed at the "top" level, in module or impl/trait. /// Something is typed at the "top" level, in module or impl/trait.
pub(super) is_new_item: bool, pub(super) is_new_item: bool,
/// The receiver if this is a field or method access, i.e. writing something.<|> /// The receiver if this is a field or method access, i.e. writing something.$0
pub(super) dot_receiver: Option<ast::Expr>, pub(super) dot_receiver: Option<ast::Expr>,
pub(super) dot_receiver_is_ambiguous_float_literal: bool, pub(super) dot_receiver_is_ambiguous_float_literal: bool,
/// If this is a call (method or function) in particular, i.e. the () are already there. /// If this is a call (method or function) in particular, i.e. the () are already there.
@ -228,9 +228,9 @@ impl<'a> CompletionContext<'a> {
/// Checks whether completions in that particular case don't make much sense. /// Checks whether completions in that particular case don't make much sense.
/// Examples: /// Examples:
/// - `fn <|>` -- we expect function name, it's unlikely that "hint" will be helpful. /// - `fn $0` -- we expect function name, it's unlikely that "hint" will be helpful.
/// Exception for this case is `impl Trait for Foo`, where we would like to hint trait method names. /// Exception for this case is `impl Trait for Foo`, where we would like to hint trait method names.
/// - `for _ i<|>` -- obviously, it'll be "in" keyword. /// - `for _ i$0` -- obviously, it'll be "in" keyword.
pub(crate) fn no_completion_required(&self) -> bool { pub(crate) fn no_completion_required(&self) -> bool {
(self.fn_is_prev && !self.inside_impl_trait_block) || self.for_is_prev2 (self.fn_is_prev && !self.inside_impl_trait_block) || self.for_is_prev2
} }
@ -279,7 +279,7 @@ impl<'a> CompletionContext<'a> {
offset: TextSize, offset: TextSize,
) { ) {
// FIXME: this is wrong in at least two cases: // FIXME: this is wrong in at least two cases:
// * when there's no token `foo(<|>)` // * when there's no token `foo($0)`
// * when there is a token, but it happens to have type of it's own // * when there is a token, but it happens to have type of it's own
self.expected_type = self self.expected_type = self
.token .token

View file

@ -43,7 +43,7 @@ pub struct CompletionItem {
/// Lookup is used to check if completion item indeed can complete current /// Lookup is used to check if completion item indeed can complete current
/// ident. /// ident.
/// ///
/// That is, in `foo.bar<|>` lookup of `abracadabra` will be accepted (it /// That is, in `foo.bar$0` lookup of `abracadabra` will be accepted (it
/// contains `bar` sub sequence), and `quux` will rejected. /// contains `bar` sub sequence), and `quux` will rejected.
lookup: Option<String>, lookup: Option<String>,

View file

@ -47,8 +47,8 @@ pub use crate::{
// - `expr.while` -> `while expr {}` or `while let ... {}` for `Option` or `Result` // - `expr.while` -> `while expr {}` or `while let ... {}` for `Option` or `Result`
// - `expr.ref` -> `&expr` // - `expr.ref` -> `&expr`
// - `expr.refm` -> `&mut expr` // - `expr.refm` -> `&mut expr`
// - `expr.let` -> `let <|> = expr;` // - `expr.let` -> `let $0 = expr;`
// - `expr.letm` -> `let mut <|> = expr;` // - `expr.letm` -> `let mut $0 = expr;`
// - `expr.not` -> `!expr` // - `expr.not` -> `!expr`
// - `expr.dbg` -> `dbg!(expr)` // - `expr.dbg` -> `dbg!(expr)`
// - `expr.dbgr` -> `dbg!(&expr)` // - `expr.dbgr` -> `dbg!(&expr)`
@ -92,7 +92,7 @@ pub use crate::{
/// ```no_run /// ```no_run
/// fn f() { /// fn f() {
/// let foo = 92; /// let foo = 92;
/// let _ = bar<|> /// let _ = bar$0
/// } /// }
/// ``` /// ```
/// ///
@ -220,7 +220,7 @@ mod tests {
fn foo() { fn foo() {
let bar = Bar; let bar = Bar;
bar.fo<|>; bar.fo$0;
} }
"#, "#,
DetailAndDocumentation { detail: "fn foo(&self)", documentation: "Do the foo" }, DetailAndDocumentation { detail: "fn foo(&self)", documentation: "Do the foo" },
@ -246,7 +246,7 @@ mod tests {
fn foo() { fn foo() {
let bar = Bar; let bar = Bar;
bar.fo<|>; bar.fo$0;
} }
"#, "#,
DetailAndDocumentation { detail: "fn foo(&self)", documentation: " Do the foo" }, DetailAndDocumentation { detail: "fn foo(&self)", documentation: " Do the foo" },
@ -259,7 +259,7 @@ mod tests {
check_no_completion( check_no_completion(
r#" r#"
fn foo() { fn foo() {
for i i<|> for i i$0
} }
"#, "#,
); );
@ -270,7 +270,7 @@ mod tests {
fn foo() -> &'static str { "foo" } fn foo() -> &'static str { "foo" }
fn bar() { fn bar() {
for c in fo<|> for c in fo$0
} }
"#, "#,
DetailAndDocumentation { DetailAndDocumentation {

View file

@ -20,7 +20,7 @@ pub(crate) fn has_trait_parent(element: SyntaxElement) -> bool {
} }
#[test] #[test]
fn test_has_trait_parent() { fn test_has_trait_parent() {
check_pattern_is_applicable(r"trait A { f<|> }", has_trait_parent); check_pattern_is_applicable(r"trait A { f$0 }", has_trait_parent);
} }
pub(crate) fn has_impl_parent(element: SyntaxElement) -> bool { pub(crate) fn has_impl_parent(element: SyntaxElement) -> bool {
@ -32,7 +32,7 @@ pub(crate) fn has_impl_parent(element: SyntaxElement) -> bool {
} }
#[test] #[test]
fn test_has_impl_parent() { fn test_has_impl_parent() {
check_pattern_is_applicable(r"impl A { f<|> }", has_impl_parent); check_pattern_is_applicable(r"impl A { f$0 }", has_impl_parent);
} }
pub(crate) fn inside_impl_trait_block(element: SyntaxElement) -> bool { pub(crate) fn inside_impl_trait_block(element: SyntaxElement) -> bool {
@ -47,10 +47,10 @@ pub(crate) fn inside_impl_trait_block(element: SyntaxElement) -> bool {
} }
#[test] #[test]
fn test_inside_impl_trait_block() { fn test_inside_impl_trait_block() {
check_pattern_is_applicable(r"impl Foo for Bar { f<|> }", inside_impl_trait_block); check_pattern_is_applicable(r"impl Foo for Bar { f$0 }", inside_impl_trait_block);
check_pattern_is_applicable(r"impl Foo for Bar { fn f<|> }", inside_impl_trait_block); check_pattern_is_applicable(r"impl Foo for Bar { fn f$0 }", inside_impl_trait_block);
check_pattern_is_not_applicable(r"impl A { f<|> }", inside_impl_trait_block); check_pattern_is_not_applicable(r"impl A { f$0 }", inside_impl_trait_block);
check_pattern_is_not_applicable(r"impl A { fn f<|> }", inside_impl_trait_block); check_pattern_is_not_applicable(r"impl A { fn f$0 }", inside_impl_trait_block);
} }
pub(crate) fn has_field_list_parent(element: SyntaxElement) -> bool { pub(crate) fn has_field_list_parent(element: SyntaxElement) -> bool {
@ -58,8 +58,8 @@ pub(crate) fn has_field_list_parent(element: SyntaxElement) -> bool {
} }
#[test] #[test]
fn test_has_field_list_parent() { fn test_has_field_list_parent() {
check_pattern_is_applicable(r"struct Foo { f<|> }", has_field_list_parent); check_pattern_is_applicable(r"struct Foo { f$0 }", has_field_list_parent);
check_pattern_is_applicable(r"struct Foo { f<|> pub f: i32}", has_field_list_parent); check_pattern_is_applicable(r"struct Foo { f$0 pub f: i32}", has_field_list_parent);
} }
pub(crate) fn has_block_expr_parent(element: SyntaxElement) -> bool { pub(crate) fn has_block_expr_parent(element: SyntaxElement) -> bool {
@ -67,7 +67,7 @@ pub(crate) fn has_block_expr_parent(element: SyntaxElement) -> bool {
} }
#[test] #[test]
fn test_has_block_expr_parent() { fn test_has_block_expr_parent() {
check_pattern_is_applicable(r"fn my_fn() { let a = 2; f<|> }", has_block_expr_parent); check_pattern_is_applicable(r"fn my_fn() { let a = 2; f$0 }", has_block_expr_parent);
} }
pub(crate) fn has_bind_pat_parent(element: SyntaxElement) -> bool { pub(crate) fn has_bind_pat_parent(element: SyntaxElement) -> bool {
@ -75,8 +75,8 @@ pub(crate) fn has_bind_pat_parent(element: SyntaxElement) -> bool {
} }
#[test] #[test]
fn test_has_bind_pat_parent() { fn test_has_bind_pat_parent() {
check_pattern_is_applicable(r"fn my_fn(m<|>) {}", has_bind_pat_parent); check_pattern_is_applicable(r"fn my_fn(m$0) {}", has_bind_pat_parent);
check_pattern_is_applicable(r"fn my_fn() { let m<|> }", has_bind_pat_parent); check_pattern_is_applicable(r"fn my_fn() { let m$0 }", has_bind_pat_parent);
} }
pub(crate) fn has_ref_parent(element: SyntaxElement) -> bool { pub(crate) fn has_ref_parent(element: SyntaxElement) -> bool {
@ -86,8 +86,8 @@ pub(crate) fn has_ref_parent(element: SyntaxElement) -> bool {
} }
#[test] #[test]
fn test_has_ref_parent() { fn test_has_ref_parent() {
check_pattern_is_applicable(r"fn my_fn(&m<|>) {}", has_ref_parent); check_pattern_is_applicable(r"fn my_fn(&m$0) {}", has_ref_parent);
check_pattern_is_applicable(r"fn my() { let &m<|> }", has_ref_parent); check_pattern_is_applicable(r"fn my() { let &m$0 }", has_ref_parent);
} }
pub(crate) fn has_item_list_or_source_file_parent(element: SyntaxElement) -> bool { pub(crate) fn has_item_list_or_source_file_parent(element: SyntaxElement) -> bool {
@ -99,8 +99,8 @@ pub(crate) fn has_item_list_or_source_file_parent(element: SyntaxElement) -> boo
} }
#[test] #[test]
fn test_has_item_list_or_source_file_parent() { fn test_has_item_list_or_source_file_parent() {
check_pattern_is_applicable(r"i<|>", has_item_list_or_source_file_parent); check_pattern_is_applicable(r"i$0", has_item_list_or_source_file_parent);
check_pattern_is_applicable(r"mod foo { f<|> }", has_item_list_or_source_file_parent); check_pattern_is_applicable(r"mod foo { f$0 }", has_item_list_or_source_file_parent);
} }
pub(crate) fn is_match_arm(element: SyntaxElement) -> bool { pub(crate) fn is_match_arm(element: SyntaxElement) -> bool {
@ -112,7 +112,7 @@ pub(crate) fn is_match_arm(element: SyntaxElement) -> bool {
} }
#[test] #[test]
fn test_is_match_arm() { fn test_is_match_arm() {
check_pattern_is_applicable(r"fn my_fn() { match () { () => m<|> } }", is_match_arm); check_pattern_is_applicable(r"fn my_fn() { match () { () => m$0 } }", is_match_arm);
} }
pub(crate) fn unsafe_is_prev(element: SyntaxElement) -> bool { pub(crate) fn unsafe_is_prev(element: SyntaxElement) -> bool {
@ -124,7 +124,7 @@ pub(crate) fn unsafe_is_prev(element: SyntaxElement) -> bool {
} }
#[test] #[test]
fn test_unsafe_is_prev() { fn test_unsafe_is_prev() {
check_pattern_is_applicable(r"unsafe i<|>", unsafe_is_prev); check_pattern_is_applicable(r"unsafe i$0", unsafe_is_prev);
} }
pub(crate) fn if_is_prev(element: SyntaxElement) -> bool { pub(crate) fn if_is_prev(element: SyntaxElement) -> bool {
@ -144,11 +144,11 @@ pub(crate) fn fn_is_prev(element: SyntaxElement) -> bool {
} }
#[test] #[test]
fn test_fn_is_prev() { fn test_fn_is_prev() {
check_pattern_is_applicable(r"fn l<|>", fn_is_prev); check_pattern_is_applicable(r"fn l$0", fn_is_prev);
} }
/// Check if the token previous to the previous one is `for`. /// Check if the token previous to the previous one is `for`.
/// For example, `for _ i<|>` => true. /// For example, `for _ i$0` => true.
pub(crate) fn for_is_prev2(element: SyntaxElement) -> bool { pub(crate) fn for_is_prev2(element: SyntaxElement) -> bool {
element element
.into_token() .into_token()
@ -159,12 +159,12 @@ pub(crate) fn for_is_prev2(element: SyntaxElement) -> bool {
} }
#[test] #[test]
fn test_for_is_prev2() { fn test_for_is_prev2() {
check_pattern_is_applicable(r"for i i<|>", for_is_prev2); check_pattern_is_applicable(r"for i i$0", for_is_prev2);
} }
#[test] #[test]
fn test_if_is_prev() { fn test_if_is_prev() {
check_pattern_is_applicable(r"if l<|>", if_is_prev); check_pattern_is_applicable(r"if l$0", if_is_prev);
} }
pub(crate) fn has_trait_as_prev_sibling(element: SyntaxElement) -> bool { pub(crate) fn has_trait_as_prev_sibling(element: SyntaxElement) -> bool {
@ -172,7 +172,7 @@ pub(crate) fn has_trait_as_prev_sibling(element: SyntaxElement) -> bool {
} }
#[test] #[test]
fn test_has_trait_as_prev_sibling() { fn test_has_trait_as_prev_sibling() {
check_pattern_is_applicable(r"trait A w<|> {}", has_trait_as_prev_sibling); check_pattern_is_applicable(r"trait A w$0 {}", has_trait_as_prev_sibling);
} }
pub(crate) fn has_impl_as_prev_sibling(element: SyntaxElement) -> bool { pub(crate) fn has_impl_as_prev_sibling(element: SyntaxElement) -> bool {
@ -180,7 +180,7 @@ pub(crate) fn has_impl_as_prev_sibling(element: SyntaxElement) -> bool {
} }
#[test] #[test]
fn test_has_impl_as_prev_sibling() { fn test_has_impl_as_prev_sibling() {
check_pattern_is_applicable(r"impl A w<|> {}", has_impl_as_prev_sibling); check_pattern_is_applicable(r"impl A w$0 {}", has_impl_as_prev_sibling);
} }
pub(crate) fn is_in_loop_body(element: SyntaxElement) -> bool { pub(crate) fn is_in_loop_body(element: SyntaxElement) -> bool {

View file

@ -358,7 +358,7 @@ mod tests {
r#" r#"
enum Foo { Foo { x: i32, y: i32 } } enum Foo { Foo { x: i32, y: i32 } }
fn main() { Foo::Fo<|> } fn main() { Foo::Fo$0 }
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -381,7 +381,7 @@ fn main() { Foo::Fo<|> }
r#" r#"
enum Foo { Foo (i32, i32) } enum Foo { Foo (i32, i32) }
fn main() { Foo::Fo<|> } fn main() { Foo::Fo$0 }
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -406,7 +406,7 @@ fn main() { Foo::Fo<|> }
r#" r#"
enum Foo { Foo } enum Foo { Foo }
fn main() { Foo::Fo<|> } fn main() { Foo::Fo$0 }
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -430,7 +430,7 @@ fn main() { Foo::Fo<|> }
mod m { mod m {
pub enum Spam { Foo, Bar(i32) } pub enum Spam { Foo, Bar(i32) }
} }
fn main() { let _: m::Spam = S<|> } fn main() { let _: m::Spam = S$0 }
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -483,7 +483,7 @@ fn something_deprecated() {}
#[deprecated(since = "1.0.0")] #[deprecated(since = "1.0.0")]
fn something_else_deprecated() {} fn something_else_deprecated() {}
fn main() { som<|> } fn main() { som$0 }
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -523,7 +523,7 @@ fn main() { som<|> }
check( check(
r#" r#"
struct A { #[deprecated] the_field: u32 } struct A { #[deprecated] the_field: u32 }
fn foo() { A { the<|> } } fn foo() { A { the$0 } }
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -551,7 +551,7 @@ struct S {
} }
impl S { impl S {
/// Method docs /// Method docs
fn bar(self) { self.<|> } fn bar(self) { self.$0 }
}"#, }"#,
expect![[r#" expect![[r#"
[ [
@ -584,7 +584,7 @@ impl S {
check( check(
r#" r#"
use self::my<|>; use self::my$0;
/// mod docs /// mod docs
mod my { } mod my { }
@ -643,7 +643,7 @@ impl S {
#[inline] #[inline]
fn the_method(&self) { } fn the_method(&self) { }
} }
fn foo(s: S) { s.<|> } fn foo(s: S) { s.$0 }
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -671,7 +671,7 @@ fn foo(foo: u8, bar: u8) {}
struct ManualVtable { f: fn(u8, u8) } struct ManualVtable { f: fn(u8, u8) }
fn main() -> ManualVtable { fn main() -> ManualVtable {
ManualVtable { f: f<|> } ManualVtable { f: f$0 }
} }
"#, "#,
r#" r#"
@ -692,7 +692,7 @@ fn main() -> ManualVtable {
"foo", "foo",
r#" r#"
mod m { pub fn foo() {} } mod m { pub fn foo() {} }
use crate::m::f<|>; use crate::m::f$0;
"#, "#,
r#" r#"
mod m { pub fn foo() {} } mod m { pub fn foo() {} }
@ -707,7 +707,7 @@ use crate::m::foo;
"foo", "foo",
r#" r#"
fn foo(x: i32) {} fn foo(x: i32) {}
fn main() { f<|>(); } fn main() { f$0(); }
"#, "#,
r#" r#"
fn foo(x: i32) {} fn foo(x: i32) {}
@ -719,7 +719,7 @@ fn main() { foo(); }
r#" r#"
struct Foo; struct Foo;
impl Foo { fn foo(&self){} } impl Foo { fn foo(&self){} }
fn f(foo: &Foo) { foo.f<|>(); } fn f(foo: &Foo) { foo.f$0(); }
"#, "#,
r#" r#"
struct Foo; struct Foo;
@ -736,7 +736,7 @@ fn f(foo: &Foo) { foo.foo(); }
"Vec", "Vec",
r#" r#"
struct Vec<T> {} struct Vec<T> {}
fn foo(xs: Ve<|>) fn foo(xs: Ve$0)
"#, "#,
r#" r#"
struct Vec<T> {} struct Vec<T> {}
@ -747,7 +747,7 @@ fn foo(xs: Vec<$0>)
"Vec", "Vec",
r#" r#"
type Vec<T> = (T,); type Vec<T> = (T,);
fn foo(xs: Ve<|>) fn foo(xs: Ve$0)
"#, "#,
r#" r#"
type Vec<T> = (T,); type Vec<T> = (T,);
@ -758,7 +758,7 @@ fn foo(xs: Vec<$0>)
"Vec", "Vec",
r#" r#"
struct Vec<T = i128> {} struct Vec<T = i128> {}
fn foo(xs: Ve<|>) fn foo(xs: Ve$0)
"#, "#,
r#" r#"
struct Vec<T = i128> {} struct Vec<T = i128> {}
@ -769,7 +769,7 @@ fn foo(xs: Vec)
"Vec", "Vec",
r#" r#"
struct Vec<T> {} struct Vec<T> {}
fn foo(xs: Ve<|><i128>) fn foo(xs: Ve$0<i128>)
"#, "#,
r#" r#"
struct Vec<T> {} struct Vec<T> {}
@ -785,7 +785,7 @@ fn foo(xs: Vec<i128>)
r#" r#"
struct S { foo: i64, bar: u32, baz: u32 } struct S { foo: i64, bar: u32, baz: u32 }
fn test(bar: u32) { } fn test(bar: u32) { }
fn foo(s: S) { test(s.<|>) } fn foo(s: S) { test(s.$0) }
"#, "#,
expect![[r#" expect![[r#"
fd bar [type+name] fd bar [type+name]
@ -802,7 +802,7 @@ fn foo(s: S) { test(s.<|>) }
r#" r#"
struct A { foo: i64, bar: u32, baz: u32 } struct A { foo: i64, bar: u32, baz: u32 }
struct B { x: (), y: f32, bar: u32 } struct B { x: (), y: f32, bar: u32 }
fn foo(a: A) { B { bar: a.<|> }; } fn foo(a: A) { B { bar: a.$0 }; }
"#, "#,
expect![[r#" expect![[r#"
fd bar [type+name] fd bar [type+name]
@ -819,7 +819,7 @@ fn foo(a: A) { B { bar: a.<|> }; }
struct A { foo: i64, bar: u32, baz: u32 } struct A { foo: i64, bar: u32, baz: u32 }
struct B { x: (), y: f32, bar: u32 } struct B { x: (), y: f32, bar: u32 }
fn f(foo: i64) { } fn f(foo: i64) { }
fn foo(a: A) { B { bar: f(a.<|>) }; } fn foo(a: A) { B { bar: f(a.$0) }; }
"#, "#,
expect![[r#" expect![[r#"
fd foo [type+name] fd foo [type+name]
@ -832,7 +832,7 @@ fn foo(a: A) { B { bar: f(a.<|>) }; }
struct A { foo: i64, bar: u32, baz: u32 } struct A { foo: i64, bar: u32, baz: u32 }
struct B { x: (), y: f32, bar: u32 } struct B { x: (), y: f32, bar: u32 }
fn f(foo: i64) { } fn f(foo: i64) { }
fn foo(a: A) { f(B { bar: a.<|> }); } fn foo(a: A) { f(B { bar: a.$0 }); }
"#, "#,
expect![[r#" expect![[r#"
fd bar [type+name] fd bar [type+name]
@ -847,7 +847,7 @@ fn foo(a: A) { f(B { bar: a.<|> }); }
check_scores( check_scores(
r#" r#"
struct WorldSnapshot { _f: () }; struct WorldSnapshot { _f: () };
fn go(world: &WorldSnapshot) { go(w<|>) } fn go(world: &WorldSnapshot) { go(w$0) }
"#, "#,
expect![[r#" expect![[r#"
bn world [type+name] bn world [type+name]
@ -862,7 +862,7 @@ fn go(world: &WorldSnapshot) { go(w<|>) }
check_scores( check_scores(
r#" r#"
struct Foo; struct Foo;
fn f(foo: &Foo) { f(foo, w<|>) } fn f(foo: &Foo) { f(foo, w$0) }
"#, "#,
expect![[r#" expect![[r#"
st Foo [] st Foo []

View file

@ -115,7 +115,7 @@ mod tests {
enum Option<T> { Some(T), None } enum Option<T> { Some(T), None }
use Option::*; use Option::*;
fn main() -> Option<i32> { fn main() -> Option<i32> {
Som<|> Som$0
} }
"#, "#,
r#" r#"

View file

@ -124,7 +124,7 @@ mod tests {
"no_args", "no_args",
r#" r#"
fn no_args() {} fn no_args() {}
fn main() { no_<|> } fn main() { no_$0 }
"#, "#,
r#" r#"
fn no_args() {} fn no_args() {}
@ -136,7 +136,7 @@ fn main() { no_args()$0 }
"with_args", "with_args",
r#" r#"
fn with_args(x: i32, y: String) {} fn with_args(x: i32, y: String) {}
fn main() { with_<|> } fn main() { with_$0 }
"#, "#,
r#" r#"
fn with_args(x: i32, y: String) {} fn with_args(x: i32, y: String) {}
@ -151,7 +151,7 @@ struct S;
impl S { impl S {
fn foo(&self) {} fn foo(&self) {}
} }
fn bar(s: &S) { s.f<|> } fn bar(s: &S) { s.f$0 }
"#, "#,
r#" r#"
struct S; struct S;
@ -170,7 +170,7 @@ impl S {
fn foo(&self, x: i32) {} fn foo(&self, x: i32) {}
} }
fn bar(s: &S) { fn bar(s: &S) {
s.f<|> s.f$0
} }
"#, "#,
r#" r#"
@ -195,7 +195,7 @@ struct S;
impl S { impl S {
fn foo(&self) {} fn foo(&self) {}
} }
fn main() { S::f<|> } fn main() { S::f$0 }
"#, "#,
r#" r#"
struct S; struct S;
@ -215,7 +215,7 @@ fn main() { S::foo(${1:&self})$0 }
"with_args", "with_args",
r#" r#"
fn with_args(x: i32, y: String) {} fn with_args(x: i32, y: String) {}
fn main() { with_<|> } fn main() { with_$0 }
"#, "#,
r#" r#"
fn with_args(x: i32, y: String) {} fn with_args(x: i32, y: String) {}
@ -230,7 +230,7 @@ fn main() { with_args($0) }
"foo", "foo",
r#" r#"
fn foo(_foo: i32, ___bar: bool, ho_ge_: String) {} fn foo(_foo: i32, ___bar: bool, ho_ge_: String) {}
fn main() { f<|> } fn main() { f$0 }
"#, "#,
r#" r#"
fn foo(_foo: i32, ___bar: bool, ho_ge_: String) {} fn foo(_foo: i32, ___bar: bool, ho_ge_: String) {}
@ -248,7 +248,7 @@ struct Foo {}
fn ref_arg(x: &Foo) {} fn ref_arg(x: &Foo) {}
fn main() { fn main() {
let x = Foo {}; let x = Foo {};
ref_ar<|> ref_ar$0
} }
"#, "#,
r#" r#"
@ -271,7 +271,7 @@ struct Foo {}
fn ref_arg(x: &mut Foo) {} fn ref_arg(x: &mut Foo) {}
fn main() { fn main() {
let x = Foo {}; let x = Foo {};
ref_ar<|> ref_ar$0
} }
"#, "#,
r#" r#"
@ -299,7 +299,7 @@ impl Bar {
fn main() { fn main() {
let x = Foo {}; let x = Foo {};
let y = Bar {}; let y = Bar {};
y.<|> y.$0
} }
"#, "#,
r#" r#"
@ -326,7 +326,7 @@ fn main() {
fn take_mutably(mut x: &i32) {} fn take_mutably(mut x: &i32) {}
fn main() { fn main() {
take_m<|> take_m$0
} }
"#, "#,
r#" r#"

View file

@ -135,7 +135,7 @@ mod tests {
"frobnicate!", "frobnicate!",
r#" r#"
//- /main.rs crate:main deps:foo //- /main.rs crate:main deps:foo
use foo::<|>; use foo::$0;
//- /foo/lib.rs crate:foo //- /foo/lib.rs crate:foo
#[macro_export] #[macro_export]
macro_rules! frobnicate { () => () } macro_rules! frobnicate { () => () }
@ -149,7 +149,7 @@ use foo::frobnicate;
"frobnicate!", "frobnicate!",
r#" r#"
macro_rules! frobnicate { () => () } macro_rules! frobnicate { () => () }
fn main() { frob<|>!(); } fn main() { frob$0!(); }
"#, "#,
r#" r#"
macro_rules! frobnicate { () => () } macro_rules! frobnicate { () => () }
@ -173,7 +173,7 @@ fn main() { frobnicate!(); }
/// ``` /// ```
macro_rules! vec { () => {} } macro_rules! vec { () => {} }
fn fn main() { v<|> } fn fn main() { v$0 }
"#, "#,
r#" r#"
/// Creates a [`Vec`] containing the arguments. /// Creates a [`Vec`] containing the arguments.
@ -198,7 +198,7 @@ fn fn main() { vec![$0] }
/// Don't call `fooo!()` `fooo!()`, or `_foo![]` `_foo![]`, /// Don't call `fooo!()` `fooo!()`, or `_foo![]` `_foo![]`,
/// call as `let _=foo! { hello world };` /// call as `let _=foo! { hello world };`
macro_rules! foo { () => {} } macro_rules! foo { () => {} }
fn main() { <|> } fn main() { $0 }
"#, "#,
r#" r#"
/// Foo /// Foo

View file

@ -22,12 +22,12 @@ pub(crate) const TEST_CONFIG: CompletionConfig = CompletionConfig {
merge: Some(MergeBehavior::Full), merge: Some(MergeBehavior::Full),
}; };
/// Creates analysis from a multi-file fixture, returns positions marked with <|>. /// Creates analysis from a multi-file fixture, returns positions marked with $0.
pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) { pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) {
let change_fixture = ChangeFixture::parse(ra_fixture); let change_fixture = ChangeFixture::parse(ra_fixture);
let mut database = RootDatabase::default(); let mut database = RootDatabase::default();
database.apply_change(change_fixture.change); database.apply_change(change_fixture.change);
let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker (<|>)"); let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
let offset = match range_or_offset { let offset = match range_or_offset {
RangeOrOffset::Range(_) => panic!(), RangeOrOffset::Range(_) => panic!(),
RangeOrOffset::Offset(it) => it, RangeOrOffset::Offset(it) => it,

View file

@ -194,7 +194,7 @@ mod tests {
let mut buf = String::new(); let mut buf = String::new();
let off: usize = offset.into(); let off: usize = offset.into();
buf.push_str(&code[..off]); buf.push_str(&code[..off]);
buf.push_str("<|>marker"); buf.push_str("$0marker");
buf.push_str(&code[off..]); buf.push_str(&code[off..]);
buf buf
}; };
@ -231,7 +231,7 @@ mod tests {
r" r"
fn quux(foo: i32) { fn quux(foo: i32) {
let f = |bar, baz: i32| { let f = |bar, baz: i32| {
<|> $0
}; };
}", }",
&["bar", "baz", "foo"], &["bar", "baz", "foo"],
@ -243,7 +243,7 @@ mod tests {
do_check( do_check(
r" r"
fn quux() { fn quux() {
f(|x| <|> ); f(|x| $0 );
}", }",
&["x"], &["x"],
); );
@ -254,7 +254,7 @@ mod tests {
do_check( do_check(
r" r"
fn quux() { fn quux() {
z.f(|x| <|> ); z.f(|x| $0 );
}", }",
&["x"], &["x"],
); );
@ -267,7 +267,7 @@ mod tests {
fn quux() { fn quux() {
loop { loop {
let x = (); let x = ();
<|> $0
}; };
}", }",
&["x"], &["x"],
@ -281,7 +281,7 @@ mod tests {
fn quux() { fn quux() {
match () { match () {
Some(x) => { Some(x) => {
<|> $0
} }
}; };
}", }",
@ -294,7 +294,7 @@ mod tests {
do_check( do_check(
r" r"
fn foo(x: String) { fn foo(x: String) {
let x : &str = &x<|>; let x : &str = &x$0;
}", }",
&["x"], &["x"],
); );
@ -307,7 +307,7 @@ mod tests {
fn foo() { fn foo() {
match Some(()) { match Some(()) {
opt @ Some(unit) => { opt @ Some(unit) => {
<|> $0
} }
_ => {} _ => {}
} }
@ -330,7 +330,7 @@ fn foo() {
fn foo() { fn foo() {
mac!(); mac!();
<|> $0
} }
", ",
&[], &[],
@ -343,7 +343,7 @@ fn foo() {
r" r"
fn foo() { fn foo() {
trait {} trait {}
<|> $0
} }
", ",
&[], &[],
@ -391,7 +391,7 @@ fn foo(x: i32, y: u32) {
let z = x * 2; let z = x * 2;
} }
{ {
let t = x<|> * 3; let t = x$0 * 3;
} }
} }
"#, "#,
@ -404,7 +404,7 @@ fn foo(x: i32, y: u32) {
do_check_local_name( do_check_local_name(
r#" r#"
fn foo(x: String) { fn foo(x: String) {
let x : &str = &x<|>; let x : &str = &x$0;
} }
"#, "#,
7, 7,
@ -417,7 +417,7 @@ fn foo(x: String) {
r" r"
fn foo(x: String) { fn foo(x: String) {
let x : &str = &x; let x : &str = &x;
x<|> x$0
} }
", ",
28, 28,
@ -430,7 +430,7 @@ fn foo(x: String) {
r" r"
fn foo() { fn foo() {
if let Some(&from) = bar() { if let Some(&from) = bar() {
from<|>; from$0;
} }
} }
", ",
@ -446,7 +446,7 @@ fn foo() {
fn test() { fn test() {
let foo: Option<f32> = None; let foo: Option<f32> = None;
while let Option::Some(spam) = foo { while let Option::Some(spam) = foo {
spam<|> spam$0
} }
} }
"#, "#,

View file

@ -410,7 +410,7 @@ mod tests {
let code = r#" let code = r#"
//- /main.rs //- /main.rs
struct S; struct S;
<|> $0
"#; "#;
check_found_path(code, "S", "S", "crate::S", "self::S"); check_found_path(code, "S", "S", "crate::S", "self::S");
} }
@ -420,7 +420,7 @@ mod tests {
let code = r#" let code = r#"
//- /main.rs //- /main.rs
enum E { A } enum E { A }
<|> $0
"#; "#;
check_found_path(code, "E::A", "E::A", "E::A", "E::A"); check_found_path(code, "E::A", "E::A", "E::A", "E::A");
} }
@ -432,7 +432,7 @@ mod tests {
mod foo { mod foo {
pub struct S; pub struct S;
} }
<|> $0
"#; "#;
check_found_path(code, "foo::S", "foo::S", "crate::foo::S", "self::foo::S"); check_found_path(code, "foo::S", "foo::S", "crate::foo::S", "self::foo::S");
} }
@ -446,7 +446,7 @@ mod tests {
mod bar; mod bar;
struct S; struct S;
//- /foo/bar.rs //- /foo/bar.rs
<|> $0
"#; "#;
check_found_path(code, "super::S", "super::S", "crate::foo::S", "super::S"); check_found_path(code, "super::S", "super::S", "crate::foo::S", "super::S");
} }
@ -457,7 +457,7 @@ mod tests {
//- /main.rs //- /main.rs
mod foo; mod foo;
//- /foo.rs //- /foo.rs
<|> $0
"#; "#;
check_found_path(code, "self", "self", "crate::foo", "self"); check_found_path(code, "self", "self", "crate::foo", "self");
} }
@ -468,7 +468,7 @@ mod tests {
//- /main.rs //- /main.rs
mod foo; mod foo;
//- /foo.rs //- /foo.rs
<|> $0
"#; "#;
check_found_path(code, "crate", "crate", "crate", "crate"); check_found_path(code, "crate", "crate", "crate", "crate");
} }
@ -480,7 +480,7 @@ mod tests {
mod foo; mod foo;
struct S; struct S;
//- /foo.rs //- /foo.rs
<|> $0
"#; "#;
check_found_path(code, "crate::S", "crate::S", "crate::S", "crate::S"); check_found_path(code, "crate::S", "crate::S", "crate::S", "crate::S");
} }
@ -489,7 +489,7 @@ mod tests {
fn different_crate() { fn different_crate() {
let code = r#" let code = r#"
//- /main.rs crate:main deps:std //- /main.rs crate:main deps:std
<|> $0
//- /std.rs crate:std //- /std.rs crate:std
pub struct S; pub struct S;
"#; "#;
@ -501,7 +501,7 @@ mod tests {
let code = r#" let code = r#"
//- /main.rs crate:main deps:std //- /main.rs crate:main deps:std
extern crate std as std_renamed; extern crate std as std_renamed;
<|> $0
//- /std.rs crate:std //- /std.rs crate:std
pub struct S; pub struct S;
"#; "#;
@ -523,7 +523,7 @@ mod tests {
//- /main.rs crate:main deps:syntax //- /main.rs crate:main deps:syntax
use syntax::ast; use syntax::ast;
<|> $0
//- /lib.rs crate:syntax //- /lib.rs crate:syntax
pub mod ast { pub mod ast {
@ -543,7 +543,7 @@ mod tests {
let code = r#" let code = r#"
//- /main.rs crate:main deps:syntax //- /main.rs crate:main deps:syntax
<|> $0
//- /lib.rs crate:syntax //- /lib.rs crate:syntax
pub mod ast { pub mod ast {
@ -569,7 +569,7 @@ mod tests {
mod foo { pub(super) struct S; } mod foo { pub(super) struct S; }
pub(crate) use foo::*; pub(crate) use foo::*;
} }
<|> $0
"#; "#;
check_found_path(code, "bar::S", "bar::S", "crate::bar::S", "self::bar::S"); check_found_path(code, "bar::S", "bar::S", "crate::bar::S", "self::bar::S");
} }
@ -582,7 +582,7 @@ mod tests {
mod foo { pub(super) struct S; } mod foo { pub(super) struct S; }
pub(crate) use foo::S as U; pub(crate) use foo::S as U;
} }
<|> $0
"#; "#;
check_found_path(code, "bar::U", "bar::U", "crate::bar::U", "self::bar::U"); check_found_path(code, "bar::U", "bar::U", "crate::bar::U", "self::bar::U");
} }
@ -591,7 +591,7 @@ mod tests {
fn different_crate_reexport() { fn different_crate_reexport() {
let code = r#" let code = r#"
//- /main.rs crate:main deps:std //- /main.rs crate:main deps:std
<|> $0
//- /std.rs crate:std deps:core //- /std.rs crate:std deps:core
pub use core::S; pub use core::S;
//- /core.rs crate:core //- /core.rs crate:core
@ -604,7 +604,7 @@ mod tests {
fn prelude() { fn prelude() {
let code = r#" let code = r#"
//- /main.rs crate:main deps:std //- /main.rs crate:main deps:std
<|> $0
//- /std.rs crate:std //- /std.rs crate:std
pub mod prelude { pub struct S; } pub mod prelude { pub struct S; }
#[prelude_import] #[prelude_import]
@ -617,7 +617,7 @@ mod tests {
fn enum_variant_from_prelude() { fn enum_variant_from_prelude() {
let code = r#" let code = r#"
//- /main.rs crate:main deps:std //- /main.rs crate:main deps:std
<|> $0
//- /std.rs crate:std //- /std.rs crate:std
pub mod prelude { pub mod prelude {
pub enum Option<T> { Some(T), None } pub enum Option<T> { Some(T), None }
@ -637,7 +637,7 @@ mod tests {
pub mod foo; pub mod foo;
pub mod baz; pub mod baz;
struct S; struct S;
<|> $0
//- /foo.rs //- /foo.rs
pub mod bar { pub struct S; } pub mod bar { pub struct S; }
//- /baz.rs //- /baz.rs
@ -654,7 +654,7 @@ mod tests {
pub mod bar { pub struct S; } pub mod bar { pub struct S; }
use bar::S; use bar::S;
//- /foo.rs //- /foo.rs
<|> $0
"#; "#;
// crate::S would be shorter, but using private imports seems wrong // crate::S would be shorter, but using private imports seems wrong
check_found_path(code, "crate::bar::S", "crate::bar::S", "crate::bar::S", "crate::bar::S"); check_found_path(code, "crate::bar::S", "crate::bar::S", "crate::bar::S", "crate::bar::S");
@ -668,7 +668,7 @@ mod tests {
pub mod bar; pub mod bar;
pub mod baz; pub mod baz;
//- /bar.rs //- /bar.rs
<|> $0
//- /foo.rs //- /foo.rs
pub use super::baz; pub use super::baz;
pub struct S; pub struct S;
@ -683,7 +683,7 @@ mod tests {
mark::check!(prefer_std_paths); mark::check!(prefer_std_paths);
let code = r#" let code = r#"
//- /main.rs crate:main deps:alloc,std //- /main.rs crate:main deps:alloc,std
<|> $0
//- /std.rs crate:std deps:alloc //- /std.rs crate:std deps:alloc
pub mod sync { pub mod sync {
@ -711,7 +711,7 @@ mod tests {
//- /main.rs crate:main deps:core,std //- /main.rs crate:main deps:core,std
#![no_std] #![no_std]
<|> $0
//- /std.rs crate:std deps:core //- /std.rs crate:std deps:core
@ -740,7 +740,7 @@ mod tests {
//- /main.rs crate:main deps:alloc,std //- /main.rs crate:main deps:alloc,std
#![no_std] #![no_std]
<|> $0
//- /std.rs crate:std deps:alloc //- /std.rs crate:std deps:alloc
@ -767,7 +767,7 @@ mod tests {
fn prefer_shorter_paths_if_not_alloc() { fn prefer_shorter_paths_if_not_alloc() {
let code = r#" let code = r#"
//- /main.rs crate:main deps:megaalloc,std //- /main.rs crate:main deps:megaalloc,std
<|> $0
//- /std.rs crate:std deps:megaalloc //- /std.rs crate:std deps:megaalloc
pub mod sync { pub mod sync {
@ -790,7 +790,7 @@ mod tests {
fn builtins_are_in_scope() { fn builtins_are_in_scope() {
let code = r#" let code = r#"
//- /main.rs //- /main.rs
<|> $0
pub mod primitive { pub mod primitive {
pub use u8; pub use u8;

View file

@ -28,7 +28,7 @@ fn typing_inside_a_function_should_not_invalidate_def_map() {
check_def_map_is_not_recomputed( check_def_map_is_not_recomputed(
r" r"
//- /lib.rs //- /lib.rs
mod foo;<|> mod foo;$0
use crate::foo::bar::Baz; use crate::foo::bar::Baz;
@ -81,7 +81,7 @@ fn typing_inside_a_macro_should_not_invalidate_def_map() {
pub mod bar; pub mod bar;
//- /foo/bar.rs //- /foo/bar.rs
<|> $0
m!(X); m!(X);
", ",
); );

View file

@ -277,7 +277,7 @@ mod tests {
let expander = BuiltinDeriveExpander::find_by_name(&name).unwrap(); let expander = BuiltinDeriveExpander::find_by_name(&name).unwrap();
let fixture = format!( let fixture = format!(
r#"//- /main.rs crate:main deps:core r#"//- /main.rs crate:main deps:core
<|> $0
{} {}
//- /lib.rs crate:core //- /lib.rs crate:core
// empty // empty

View file

@ -314,7 +314,7 @@ fn typing_whitespace_inside_a_function_should_not_invalidate_types() {
" "
//- /lib.rs //- /lib.rs
fn foo() -> i32 { fn foo() -> i32 {
<|>1 + 1 $01 + 1
} }
", ",
); );

View file

@ -178,7 +178,7 @@ mod tests {
//- /lib.rs //- /lib.rs
fn callee() {} fn callee() {}
fn caller() { fn caller() {
call<|>ee(); call$0ee();
} }
"#, "#,
"callee Function FileId(0) 0..14 3..9", "callee Function FileId(0) 0..14 3..9",
@ -192,7 +192,7 @@ fn caller() {
check_hierarchy( check_hierarchy(
r#" r#"
//- /lib.rs //- /lib.rs
fn call<|>ee() {} fn call$0ee() {}
fn caller() { fn caller() {
callee(); callee();
} }
@ -210,7 +210,7 @@ fn caller() {
//- /lib.rs //- /lib.rs
fn callee() {} fn callee() {}
fn caller() { fn caller() {
call<|>ee(); call$0ee();
callee(); callee();
} }
"#, "#,
@ -227,7 +227,7 @@ fn caller() {
//- /lib.rs //- /lib.rs
fn callee() {} fn callee() {}
fn caller1() { fn caller1() {
call<|>ee(); call$0ee();
} }
fn caller2() { fn caller2() {
@ -250,7 +250,7 @@ fn caller2() {
//- /lib.rs cfg:test //- /lib.rs cfg:test
fn callee() {} fn callee() {}
fn caller1() { fn caller1() {
call<|>ee(); call$0ee();
} }
#[cfg(test)] #[cfg(test)]
@ -281,7 +281,7 @@ mod foo;
use foo::callee; use foo::callee;
fn caller() { fn caller() {
call<|>ee(); call$0ee();
} }
//- /foo/mod.rs //- /foo/mod.rs
@ -299,7 +299,7 @@ pub fn callee() {}
r#" r#"
//- /lib.rs //- /lib.rs
fn callee() {} fn callee() {}
fn call<|>er() { fn call$0er() {
callee(); callee();
callee(); callee();
} }
@ -318,7 +318,7 @@ fn call<|>er() {
mod foo; mod foo;
use foo::callee; use foo::callee;
fn call<|>er() { fn call$0er() {
callee(); callee();
} }
@ -337,7 +337,7 @@ pub fn callee() {}
r#" r#"
//- /lib.rs //- /lib.rs
fn caller1() { fn caller1() {
call<|>er2(); call$0er2();
} }
fn caller2() { fn caller2() {
@ -365,7 +365,7 @@ fn a() {
fn b() {} fn b() {}
fn main() { fn main() {
a<|>() a$0()
} }
"#, "#,
"a Function FileId(0) 0..18 3..4", "a Function FileId(0) 0..18 3..4",
@ -376,7 +376,7 @@ fn main() {
check_hierarchy( check_hierarchy(
r#" r#"
fn a() { fn a() {
b<|>() b$0()
} }
fn b() {} fn b() {}

View file

@ -315,7 +315,7 @@ fn div(x: i32, y: i32) -> Result<i32, ()> {
if y == 0 { if y == 0 {
return Err(()); return Err(());
} }
x / y<|> x / y$0
} }
//- /core/lib.rs crate:core //- /core/lib.rs crate:core
pub mod result { pub mod result {
@ -346,7 +346,7 @@ fn div<T>(x: T) -> Result<T, i32> {
if x == 0 { if x == 0 {
return Err(7); return Err(7);
} }
<|>x $0x
} }
//- /core/lib.rs crate:core //- /core/lib.rs crate:core
pub mod result { pub mod result {
@ -379,7 +379,7 @@ fn div(x: i32, y: i32) -> MyResult<i32> {
if y == 0 { if y == 0 {
return Err(()); return Err(());
} }
x <|>/ y x $0/ y
} }
//- /core/lib.rs crate:core //- /core/lib.rs crate:core
pub mod result { pub mod result {
@ -444,7 +444,7 @@ pub mod result {
struct TestStruct { one: i32, two: i64 } struct TestStruct { one: i32, two: i64 }
fn test_fn() { fn test_fn() {
let s = TestStruct {<|>}; let s = TestStruct {$0};
} }
"#, "#,
r#" r#"
@ -464,7 +464,7 @@ fn test_fn() {
struct TestStruct { one: i32 } struct TestStruct { one: i32 }
impl TestStruct { impl TestStruct {
fn test_fn() { let s = Self {<|>}; } fn test_fn() { let s = Self {$0}; }
} }
"#, "#,
r#" r#"
@ -487,7 +487,7 @@ enum Expr {
impl Expr { impl Expr {
fn new_bin(lhs: Box<Expr>, rhs: Box<Expr>) -> Expr { fn new_bin(lhs: Box<Expr>, rhs: Box<Expr>) -> Expr {
Expr::Bin {<|> } Expr::Bin {$0 }
} }
} }
"#, "#,
@ -512,7 +512,7 @@ impl Expr {
struct TestStruct { one: i32, two: i64 } struct TestStruct { one: i32, two: i64 }
fn test_fn() { fn test_fn() {
let s = TestStruct{ two: 2<|> }; let s = TestStruct{ two: 2$0 };
} }
"#, "#,
r" r"
@ -608,7 +608,7 @@ fn here() {}
macro_rules! id { ($($tt:tt)*) => { $($tt)*}; } macro_rules! id { ($($tt:tt)*) => { $($tt)*}; }
fn main() { fn main() {
let _x = id![Foo { a: <|>42 }]; let _x = id![Foo { a: $042 }];
} }
pub struct Foo { pub a: i32, pub b: i32 } pub struct Foo { pub a: i32, pub b: i32 }
@ -663,7 +663,7 @@ mod a {
check_fix( check_fix(
r" r"
mod b {} mod b {}
use {<|>b}; use {$0b};
", ",
r" r"
mod b {} mod b {}
@ -673,7 +673,7 @@ mod a {
check_fix( check_fix(
r" r"
mod b {} mod b {}
use {b<|>}; use {b$0};
", ",
r" r"
mod b {} mod b {}
@ -683,7 +683,7 @@ mod a {
check_fix( check_fix(
r" r"
mod a { mod c {} } mod a { mod c {} }
use a::{c<|>}; use a::{c$0};
", ",
r" r"
mod a { mod c {} } mod a { mod c {} }
@ -693,7 +693,7 @@ mod a {
check_fix( check_fix(
r" r"
mod a {} mod a {}
use a::{self<|>}; use a::{self$0};
", ",
r" r"
mod a {} mod a {}
@ -703,7 +703,7 @@ mod a {
check_fix( check_fix(
r" r"
mod a { mod c {} mod d { mod e {} } } mod a { mod c {} mod d { mod e {} } }
use a::{c, d::{e<|>}}; use a::{c, d::{e$0}};
", ",
r" r"
mod a { mod c {} mod d { mod e {} } } mod a { mod c {} mod d { mod e {} } }
@ -717,7 +717,7 @@ mod a {
check_fix( check_fix(
r" r"
fn main() { fn main() {
Foo { bar: 3, baz<|>: false}; Foo { bar: 3, baz$0: false};
} }
struct Foo { struct Foo {
bar: i32 bar: i32
@ -743,7 +743,7 @@ struct Foo {
mod foo; mod foo;
fn main() { fn main() {
foo::Foo { bar: 3, <|>baz: false}; foo::Foo { bar: 3, $0baz: false};
} }
//- /foo.rs //- /foo.rs
struct Foo { struct Foo {
@ -777,7 +777,7 @@ struct Foo {
fn test_rename_incorrect_case() { fn test_rename_incorrect_case() {
check_fix( check_fix(
r#" r#"
pub struct test_struct<|> { one: i32 } pub struct test_struct$0 { one: i32 }
pub fn some_fn(val: test_struct) -> test_struct { pub fn some_fn(val: test_struct) -> test_struct {
test_struct { one: val.one + 1 } test_struct { one: val.one + 1 }
@ -794,7 +794,7 @@ pub fn some_fn(val: TestStruct) -> TestStruct {
check_fix( check_fix(
r#" r#"
pub fn some_fn(NonSnakeCase<|>: u8) -> u8 { pub fn some_fn(NonSnakeCase$0: u8) -> u8 {
NonSnakeCase NonSnakeCase
} }
"#, "#,
@ -807,7 +807,7 @@ pub fn some_fn(non_snake_case: u8) -> u8 {
check_fix( check_fix(
r#" r#"
pub fn SomeFn<|>(val: u8) -> u8 { pub fn SomeFn$0(val: u8) -> u8 {
if val != 0 { SomeFn(val - 1) } else { val } if val != 0 { SomeFn(val - 1) } else { val }
} }
"#, "#,
@ -821,7 +821,7 @@ pub fn some_fn(val: u8) -> u8 {
check_fix( check_fix(
r#" r#"
fn some_fn() { fn some_fn() {
let whatAWeird_Formatting<|> = 10; let whatAWeird_Formatting$0 = 10;
another_func(whatAWeird_Formatting); another_func(whatAWeird_Formatting);
} }
"#, "#,
@ -839,7 +839,7 @@ fn some_fn() {
check_no_diagnostics( check_no_diagnostics(
r#" r#"
fn foo() { fn foo() {
const ANOTHER_ITEM<|>: &str = "some_item"; const ANOTHER_ITEM$0: &str = "some_item";
} }
"#, "#,
); );
@ -852,7 +852,7 @@ fn foo() {
pub struct TestStruct; pub struct TestStruct;
impl TestStruct { impl TestStruct {
pub fn SomeFn<|>() -> TestStruct { pub fn SomeFn$0() -> TestStruct {
TestStruct TestStruct
} }
} }
@ -871,7 +871,7 @@ impl TestStruct {
#[test] #[test]
fn test_single_incorrect_case_diagnostic_in_function_name_issue_6970() { fn test_single_incorrect_case_diagnostic_in_function_name_issue_6970() {
let input = r#"fn FOO<|>() {}"#; let input = r#"fn FOO$0() {}"#;
let expected = r#"fn foo() {}"#; let expected = r#"fn foo() {}"#;
let (analysis, file_position) = fixture::position(input); let (analysis, file_position) = fixture::position(input);

View file

@ -120,7 +120,7 @@ fn main() { A { 0: 0 } }
struct A { a: &'static str } struct A { a: &'static str }
fn main() { fn main() {
let a = "haha"; let a = "haha";
A { a<|>: a } A { a$0: a }
} }
"#, "#,
r#" r#"
@ -138,7 +138,7 @@ struct A { a: &'static str, b: &'static str }
fn main() { fn main() {
let a = "haha"; let a = "haha";
let b = "bb"; let b = "bb";
A { a<|>: a, b } A { a$0: a, b }
} }
"#, "#,
r#" r#"
@ -171,7 +171,7 @@ fn f(a: A) { let A { 0: 0 } = a; }
r#" r#"
struct A { a: &'static str } struct A { a: &'static str }
fn f(a: A) { fn f(a: A) {
let A { a<|>: a } = a; let A { a$0: a } = a;
} }
"#, "#,
r#" r#"
@ -186,7 +186,7 @@ fn f(a: A) {
r#" r#"
struct A { a: &'static str, b: &'static str } struct A { a: &'static str, b: &'static str }
fn f(a: A) { fn f(a: A) {
let A { a<|>: a, b } = a; let A { a$0: a, b } = a;
} }
"#, "#,
r#" r#"

View file

@ -464,7 +464,7 @@ mod tests {
fn test_doc_url_struct() { fn test_doc_url_struct() {
check( check(
r#" r#"
pub struct Fo<|>o; pub struct Fo$0o;
"#, "#,
expect![[r#"https://docs.rs/test/*/test/struct.Foo.html"#]], expect![[r#"https://docs.rs/test/*/test/struct.Foo.html"#]],
); );
@ -474,7 +474,7 @@ pub struct Fo<|>o;
fn test_doc_url_fn() { fn test_doc_url_fn() {
check( check(
r#" r#"
pub fn fo<|>o() {} pub fn fo$0o() {}
"#, "#,
expect![[r##"https://docs.rs/test/*/test/fn.foo.html#method.foo"##]], expect![[r##"https://docs.rs/test/*/test/fn.foo.html#method.foo"##]],
); );
@ -487,7 +487,7 @@ pub fn fo<|>o() {}
pub struct Foo; pub struct Foo;
impl Foo { impl Foo {
pub fn met<|>hod() {} pub fn met$0hod() {}
} }
"#, "#,
@ -500,7 +500,7 @@ impl Foo {
check( check(
r#" r#"
pub trait Bar { pub trait Bar {
fn met<|>hod() {} fn met$0hod() {}
} }
"#, "#,
@ -513,7 +513,7 @@ pub trait Bar {
check( check(
r#" r#"
pub trait Foo { pub trait Foo {
fn met<|>hod(); fn met$0hod();
} }
"#, "#,
@ -526,7 +526,7 @@ pub trait Foo {
check( check(
r#" r#"
pub struct Foo { pub struct Foo {
pub fie<|>ld: () pub fie$0ld: ()
} }
"#, "#,
@ -539,7 +539,7 @@ pub struct Foo {
check( check(
r#" r#"
pub mod foo { pub mod foo {
pub mod ba<|>r {} pub mod ba$0r {}
} }
"#, "#,
expect![[r#"https://docs.rs/test/*/test/foo/bar/index.html"#]], expect![[r#"https://docs.rs/test/*/test/foo/bar/index.html"#]],
@ -564,7 +564,7 @@ pub mod wrapper {
} }
fn foo() { fn foo() {
let bar: wrapper::It<|>em; let bar: wrapper::It$0em;
} }
"#, "#,
expect![[r#"https://docs.rs/test/*/test/wrapper/module/struct.Item.html"#]], expect![[r#"https://docs.rs/test/*/test/wrapper/module/struct.Item.html"#]],

View file

@ -144,7 +144,7 @@ macro_rules! foo {
macro_rules! baz { macro_rules! baz {
() => { foo!(); } () => { foo!(); }
} }
f<|>oo!(); f$0oo!();
"#, "#,
expect![[r#" expect![[r#"
foo foo
@ -165,7 +165,7 @@ macro_rules! foo {
} }
} }
} }
f<|>oo!(); f$0oo!();
"#, "#,
expect![[r#" expect![[r#"
foo foo
@ -192,7 +192,7 @@ macro_rules! match_ast {
} }
fn main() { fn main() {
mat<|>ch_ast! { mat$0ch_ast! {
match container { match container {
ast::TraitDef(it) => {}, ast::TraitDef(it) => {},
ast::ImplDef(it) => {}, ast::ImplDef(it) => {},
@ -226,7 +226,7 @@ macro_rules! match_ast {
fn main() { fn main() {
let p = f(|it| { let p = f(|it| {
let res = mat<|>ch_ast! { match c {}}; let res = mat$0ch_ast! { match c {}};
Some(res) Some(res)
})?; })?;
} }
@ -250,7 +250,7 @@ macro_rules! foo {
} }
fn main() { fn main() {
let res = fo<|>o!(); let res = fo$0o!();
} }
"#, "#,
expect![[r#" expect![[r#"
@ -272,7 +272,7 @@ macro_rules! foo {
} }
fn main() { fn main() {
let res = fo<|>o!(); let res = fo$0o!();
} }
"#, "#,
expect![[r#" expect![[r#"

View file

@ -334,29 +334,29 @@ mod tests {
#[test] #[test]
fn test_extend_selection_arith() { fn test_extend_selection_arith() {
do_check(r#"fn foo() { <|>1 + 1 }"#, &["1", "1 + 1", "{ 1 + 1 }"]); do_check(r#"fn foo() { $01 + 1 }"#, &["1", "1 + 1", "{ 1 + 1 }"]);
} }
#[test] #[test]
fn test_extend_selection_list() { fn test_extend_selection_list() {
do_check(r#"fn foo(<|>x: i32) {}"#, &["x", "x: i32"]); do_check(r#"fn foo($0x: i32) {}"#, &["x", "x: i32"]);
do_check(r#"fn foo(<|>x: i32, y: i32) {}"#, &["x", "x: i32", "x: i32, "]); do_check(r#"fn foo($0x: i32, y: i32) {}"#, &["x", "x: i32", "x: i32, "]);
do_check(r#"fn foo(<|>x: i32,y: i32) {}"#, &["x", "x: i32", "x: i32,", "(x: i32,y: i32)"]); do_check(r#"fn foo($0x: i32,y: i32) {}"#, &["x", "x: i32", "x: i32,", "(x: i32,y: i32)"]);
do_check(r#"fn foo(x: i32, <|>y: i32) {}"#, &["y", "y: i32", ", y: i32"]); do_check(r#"fn foo(x: i32, $0y: i32) {}"#, &["y", "y: i32", ", y: i32"]);
do_check(r#"fn foo(x: i32, <|>y: i32, ) {}"#, &["y", "y: i32", "y: i32, "]); do_check(r#"fn foo(x: i32, $0y: i32, ) {}"#, &["y", "y: i32", "y: i32, "]);
do_check(r#"fn foo(x: i32,<|>y: i32) {}"#, &["y", "y: i32", ",y: i32"]); do_check(r#"fn foo(x: i32,$0y: i32) {}"#, &["y", "y: i32", ",y: i32"]);
do_check(r#"const FOO: [usize; 2] = [ 22<|> , 33];"#, &["22", "22 , "]); do_check(r#"const FOO: [usize; 2] = [ 22$0 , 33];"#, &["22", "22 , "]);
do_check(r#"const FOO: [usize; 2] = [ 22 , 33<|>];"#, &["33", ", 33"]); do_check(r#"const FOO: [usize; 2] = [ 22 , 33$0];"#, &["33", ", 33"]);
do_check(r#"const FOO: [usize; 2] = [ 22 , 33<|> ,];"#, &["33", "33 ,", "[ 22 , 33 ,]"]); do_check(r#"const FOO: [usize; 2] = [ 22 , 33$0 ,];"#, &["33", "33 ,", "[ 22 , 33 ,]"]);
do_check(r#"fn main() { (1, 2<|>) }"#, &["2", ", 2", "(1, 2)"]); do_check(r#"fn main() { (1, 2$0) }"#, &["2", ", 2", "(1, 2)"]);
do_check( do_check(
r#" r#"
const FOO: [usize; 2] = [ const FOO: [usize; 2] = [
22, 22,
<|>33, $033,
]"#, ]"#,
&["33", "33,"], &["33", "33,"],
); );
@ -365,7 +365,7 @@ const FOO: [usize; 2] = [
r#" r#"
const FOO: [usize; 2] = [ const FOO: [usize; 2] = [
22 22
, 33<|>, , 33$0,
]"#, ]"#,
&["33", "33,"], &["33", "33,"],
); );
@ -376,7 +376,7 @@ const FOO: [usize; 2] = [
do_check( do_check(
r#" r#"
impl S { impl S {
<|> fn foo() { $0 fn foo() {
} }
}"#, }"#,
@ -393,7 +393,7 @@ struct A;
/// bla /// bla
/// bla /// bla
struct B { struct B {
<|> $0
} }
"#, "#,
&["\n \n", "{\n \n}", "/// bla\n/// bla\nstruct B {\n \n}"], &["\n \n", "{\n \n}", "/// bla\n/// bla\nstruct B {\n \n}"],
@ -407,7 +407,7 @@ struct B {
fn bar(){} fn bar(){}
// fn foo() { // fn foo() {
// 1 + <|>1 // 1 + $01
// } // }
// fn foo(){} // fn foo(){}
@ -419,7 +419,7 @@ fn bar(){}
r#" r#"
// #[derive(Debug, Clone, Copy, PartialEq, Eq)] // #[derive(Debug, Clone, Copy, PartialEq, Eq)]
// pub enum Direction { // pub enum Direction {
// <|> Next, // $0 Next,
// Prev // Prev
// } // }
"#, "#,
@ -433,27 +433,27 @@ fn bar(){}
r#" r#"
/* /*
foo foo
_bar1<|>*/ _bar1$0*/
"#, "#,
&["_bar1", "/*\nfoo\n_bar1*/"], &["_bar1", "/*\nfoo\n_bar1*/"],
); );
do_check(r#"//!<|>foo_2 bar"#, &["foo_2", "//!foo_2 bar"]); do_check(r#"//!$0foo_2 bar"#, &["foo_2", "//!foo_2 bar"]);
do_check(r#"/<|>/foo bar"#, &["//foo bar"]); do_check(r#"/$0/foo bar"#, &["//foo bar"]);
} }
#[test] #[test]
fn test_extend_selection_prefer_idents() { fn test_extend_selection_prefer_idents() {
do_check( do_check(
r#" r#"
fn main() { foo<|>+bar;} fn main() { foo$0+bar;}
"#, "#,
&["foo", "foo+bar"], &["foo", "foo+bar"],
); );
do_check( do_check(
r#" r#"
fn main() { foo+<|>bar;} fn main() { foo+$0bar;}
"#, "#,
&["bar", "foo+bar"], &["bar", "foo+bar"],
); );
@ -461,18 +461,18 @@ fn main() { foo+<|>bar;}
#[test] #[test]
fn test_extend_selection_prefer_lifetimes() { fn test_extend_selection_prefer_lifetimes() {
do_check(r#"fn foo<<|>'a>() {}"#, &["'a", "<'a>"]); do_check(r#"fn foo<$0'a>() {}"#, &["'a", "<'a>"]);
do_check(r#"fn foo<'a<|>>() {}"#, &["'a", "<'a>"]); do_check(r#"fn foo<'a$0>() {}"#, &["'a", "<'a>"]);
} }
#[test] #[test]
fn test_extend_selection_select_first_word() { fn test_extend_selection_select_first_word() {
do_check(r#"// foo bar b<|>az quxx"#, &["baz", "// foo bar baz quxx"]); do_check(r#"// foo bar b$0az quxx"#, &["baz", "// foo bar baz quxx"]);
do_check( do_check(
r#" r#"
impl S { impl S {
fn foo() { fn foo() {
// hel<|>lo world // hel$0lo world
} }
} }
"#, "#,
@ -486,7 +486,7 @@ fn foo() {
r#" r#"
fn bar(){} fn bar(){}
" fn f<|>oo() {" " fn f$0oo() {"
"#, "#,
&["foo", "\" fn foo() {\""], &["foo", "\" fn foo() {\""],
); );
@ -499,7 +499,7 @@ fn bar(){}
fn foo<R>() fn foo<R>()
where where
R: req::Request + 'static, R: req::Request + 'static,
R::Params: DeserializeOwned<|> + panic::UnwindSafe + 'static, R::Params: DeserializeOwned$0 + panic::UnwindSafe + 'static,
R::Result: Serialize + 'static, R::Result: Serialize + 'static,
"#, "#,
&[ &[
@ -510,26 +510,26 @@ fn foo<R>()
"R::Params: DeserializeOwned + panic::UnwindSafe + 'static,", "R::Params: DeserializeOwned + panic::UnwindSafe + 'static,",
], ],
); );
do_check(r#"fn foo<T>() where T: <|>Copy"#, &["Copy"]); do_check(r#"fn foo<T>() where T: $0Copy"#, &["Copy"]);
do_check(r#"fn foo<T>() where T: <|>Copy + Display"#, &["Copy", "Copy + "]); do_check(r#"fn foo<T>() where T: $0Copy + Display"#, &["Copy", "Copy + "]);
do_check(r#"fn foo<T>() where T: <|>Copy +Display"#, &["Copy", "Copy +"]); do_check(r#"fn foo<T>() where T: $0Copy +Display"#, &["Copy", "Copy +"]);
do_check(r#"fn foo<T>() where T: <|>Copy+Display"#, &["Copy", "Copy+"]); do_check(r#"fn foo<T>() where T: $0Copy+Display"#, &["Copy", "Copy+"]);
do_check(r#"fn foo<T>() where T: Copy + <|>Display"#, &["Display", "+ Display"]); do_check(r#"fn foo<T>() where T: Copy + $0Display"#, &["Display", "+ Display"]);
do_check(r#"fn foo<T>() where T: Copy + <|>Display + Sync"#, &["Display", "Display + "]); do_check(r#"fn foo<T>() where T: Copy + $0Display + Sync"#, &["Display", "Display + "]);
do_check(r#"fn foo<T>() where T: Copy +<|>Display"#, &["Display", "+Display"]); do_check(r#"fn foo<T>() where T: Copy +$0Display"#, &["Display", "+Display"]);
} }
#[test] #[test]
fn test_extend_trait_bounds_list_inline() { fn test_extend_trait_bounds_list_inline() {
do_check(r#"fn foo<T: <|>Copy>() {}"#, &["Copy"]); do_check(r#"fn foo<T: $0Copy>() {}"#, &["Copy"]);
do_check(r#"fn foo<T: <|>Copy + Display>() {}"#, &["Copy", "Copy + "]); do_check(r#"fn foo<T: $0Copy + Display>() {}"#, &["Copy", "Copy + "]);
do_check(r#"fn foo<T: <|>Copy +Display>() {}"#, &["Copy", "Copy +"]); do_check(r#"fn foo<T: $0Copy +Display>() {}"#, &["Copy", "Copy +"]);
do_check(r#"fn foo<T: <|>Copy+Display>() {}"#, &["Copy", "Copy+"]); do_check(r#"fn foo<T: $0Copy+Display>() {}"#, &["Copy", "Copy+"]);
do_check(r#"fn foo<T: Copy + <|>Display>() {}"#, &["Display", "+ Display"]); do_check(r#"fn foo<T: Copy + $0Display>() {}"#, &["Display", "+ Display"]);
do_check(r#"fn foo<T: Copy + <|>Display + Sync>() {}"#, &["Display", "Display + "]); do_check(r#"fn foo<T: Copy + $0Display + Sync>() {}"#, &["Display", "Display + "]);
do_check(r#"fn foo<T: Copy +<|>Display>() {}"#, &["Display", "+Display"]); do_check(r#"fn foo<T: Copy +$0Display>() {}"#, &["Display", "+Display"]);
do_check( do_check(
r#"fn foo<T: Copy<|> + Display, U: Copy>() {}"#, r#"fn foo<T: Copy$0 + Display, U: Copy>() {}"#,
&[ &[
"Copy", "Copy",
"Copy + ", "Copy + ",
@ -544,19 +544,19 @@ fn foo<R>()
#[test] #[test]
fn test_extend_selection_on_tuple_in_type() { fn test_extend_selection_on_tuple_in_type() {
do_check( do_check(
r#"fn main() { let _: (krate, <|>_crate_def_map, module_id) = (); }"#, r#"fn main() { let _: (krate, $0_crate_def_map, module_id) = (); }"#,
&["_crate_def_map", "_crate_def_map, ", "(krate, _crate_def_map, module_id)"], &["_crate_def_map", "_crate_def_map, ", "(krate, _crate_def_map, module_id)"],
); );
// white space variations // white space variations
do_check( do_check(
r#"fn main() { let _: (krate,<|>_crate_def_map,module_id) = (); }"#, r#"fn main() { let _: (krate,$0_crate_def_map,module_id) = (); }"#,
&["_crate_def_map", "_crate_def_map,", "(krate,_crate_def_map,module_id)"], &["_crate_def_map", "_crate_def_map,", "(krate,_crate_def_map,module_id)"],
); );
do_check( do_check(
r#" r#"
fn main() { let _: ( fn main() { let _: (
krate, krate,
_crate<|>_def_map, _crate$0_def_map,
module_id module_id
) = (); }"#, ) = (); }"#,
&[ &[
@ -570,19 +570,19 @@ fn main() { let _: (
#[test] #[test]
fn test_extend_selection_on_tuple_in_rvalue() { fn test_extend_selection_on_tuple_in_rvalue() {
do_check( do_check(
r#"fn main() { let var = (krate, _crate_def_map<|>, module_id); }"#, r#"fn main() { let var = (krate, _crate_def_map$0, module_id); }"#,
&["_crate_def_map", "_crate_def_map, ", "(krate, _crate_def_map, module_id)"], &["_crate_def_map", "_crate_def_map, ", "(krate, _crate_def_map, module_id)"],
); );
// white space variations // white space variations
do_check( do_check(
r#"fn main() { let var = (krate,_crate<|>_def_map,module_id); }"#, r#"fn main() { let var = (krate,_crate$0_def_map,module_id); }"#,
&["_crate_def_map", "_crate_def_map,", "(krate,_crate_def_map,module_id)"], &["_crate_def_map", "_crate_def_map,", "(krate,_crate_def_map,module_id)"],
); );
do_check( do_check(
r#" r#"
fn main() { let var = ( fn main() { let var = (
krate, krate,
_crate_def_map<|>, _crate_def_map$0,
module_id module_id
); }"#, ); }"#,
&[ &[
@ -596,19 +596,19 @@ fn main() { let var = (
#[test] #[test]
fn test_extend_selection_on_tuple_pat() { fn test_extend_selection_on_tuple_pat() {
do_check( do_check(
r#"fn main() { let (krate, _crate_def_map<|>, module_id) = var; }"#, r#"fn main() { let (krate, _crate_def_map$0, module_id) = var; }"#,
&["_crate_def_map", "_crate_def_map, ", "(krate, _crate_def_map, module_id)"], &["_crate_def_map", "_crate_def_map, ", "(krate, _crate_def_map, module_id)"],
); );
// white space variations // white space variations
do_check( do_check(
r#"fn main() { let (krate,_crate<|>_def_map,module_id) = var; }"#, r#"fn main() { let (krate,_crate$0_def_map,module_id) = var; }"#,
&["_crate_def_map", "_crate_def_map,", "(krate,_crate_def_map,module_id)"], &["_crate_def_map", "_crate_def_map,", "(krate,_crate_def_map,module_id)"],
); );
do_check( do_check(
r#" r#"
fn main() { let ( fn main() { let (
krate, krate,
_crate_def_map<|>, _crate_def_map$0,
module_id module_id
) = var; }"#, ) = var; }"#,
&[ &[
@ -623,7 +623,7 @@ fn main() { let (
fn extend_selection_inside_macros() { fn extend_selection_inside_macros() {
do_check( do_check(
r#"macro_rules! foo { ($item:item) => {$item} } r#"macro_rules! foo { ($item:item) => {$item} }
foo!{fn hello(na<|>me:usize){}}"#, foo!{fn hello(na$0me:usize){}}"#,
&[ &[
"name", "name",
"name:usize", "name:usize",
@ -640,7 +640,7 @@ fn main() { let (
do_check( do_check(
r#" macro_rules! foo2 { ($item:item) => {$item} } r#" macro_rules! foo2 { ($item:item) => {$item} }
macro_rules! foo { ($item:item) => {foo2!($item);} } macro_rules! foo { ($item:item) => {foo2!($item);} }
foo!{fn hello(na<|>me:usize){}}"#, foo!{fn hello(na$0me:usize){}}"#,
&[ &[
"name", "name",
"name:usize", "name:usize",

View file

@ -20,12 +20,12 @@ pub(crate) fn files(ra_fixture: &str) -> (Analysis, Vec<FileId>) {
(host.analysis(), change_fixture.files) (host.analysis(), change_fixture.files)
} }
/// Creates analysis from a multi-file fixture, returns positions marked with <|>. /// Creates analysis from a multi-file fixture, returns positions marked with $0.
pub(crate) fn position(ra_fixture: &str) -> (Analysis, FilePosition) { pub(crate) fn position(ra_fixture: &str) -> (Analysis, FilePosition) {
let mut host = AnalysisHost::default(); let mut host = AnalysisHost::default();
let change_fixture = ChangeFixture::parse(ra_fixture); let change_fixture = ChangeFixture::parse(ra_fixture);
host.db.apply_change(change_fixture.change); host.db.apply_change(change_fixture.change);
let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker (<|>)"); let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
let offset = match range_or_offset { let offset = match range_or_offset {
RangeOrOffset::Range(_) => panic!(), RangeOrOffset::Range(_) => panic!(),
RangeOrOffset::Offset(it) => it, RangeOrOffset::Offset(it) => it,
@ -33,12 +33,12 @@ pub(crate) fn position(ra_fixture: &str) -> (Analysis, FilePosition) {
(host.analysis(), FilePosition { file_id, offset }) (host.analysis(), FilePosition { file_id, offset })
} }
/// Creates analysis for a single file, returns range marked with a pair of <|>. /// Creates analysis for a single file, returns range marked with a pair of $0.
pub(crate) fn range(ra_fixture: &str) -> (Analysis, FileRange) { pub(crate) fn range(ra_fixture: &str) -> (Analysis, FileRange) {
let mut host = AnalysisHost::default(); let mut host = AnalysisHost::default();
let change_fixture = ChangeFixture::parse(ra_fixture); let change_fixture = ChangeFixture::parse(ra_fixture);
host.db.apply_change(change_fixture.change); host.db.apply_change(change_fixture.change);
let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker (<|>)"); let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
let range = match range_or_offset { let range = match range_or_offset {
RangeOrOffset::Range(it) => it, RangeOrOffset::Range(it) => it,
RangeOrOffset::Offset(_) => panic!(), RangeOrOffset::Offset(_) => panic!(),
@ -46,12 +46,12 @@ pub(crate) fn range(ra_fixture: &str) -> (Analysis, FileRange) {
(host.analysis(), FileRange { file_id, range }) (host.analysis(), FileRange { file_id, range })
} }
/// Creates analysis from a multi-file fixture, returns positions marked with <|>. /// Creates analysis from a multi-file fixture, returns positions marked with $0.
pub(crate) fn annotations(ra_fixture: &str) -> (Analysis, FilePosition, Vec<(FileRange, String)>) { pub(crate) fn annotations(ra_fixture: &str) -> (Analysis, FilePosition, Vec<(FileRange, String)>) {
let mut host = AnalysisHost::default(); let mut host = AnalysisHost::default();
let change_fixture = ChangeFixture::parse(ra_fixture); let change_fixture = ChangeFixture::parse(ra_fixture);
host.db.apply_change(change_fixture.change); host.db.apply_change(change_fixture.change);
let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker (<|>)"); let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
let offset = match range_or_offset { let offset = match range_or_offset {
RangeOrOffset::Range(_) => panic!(), RangeOrOffset::Range(_) => panic!(),
RangeOrOffset::Offset(it) => it, RangeOrOffset::Offset(it) => it,

View file

@ -34,7 +34,7 @@ mod tests {
fn test_find_all_methods() { fn test_find_all_methods() {
let (analysis, pos) = fixture::position( let (analysis, pos) = fixture::position(
r#" r#"
fn private_fn() {<|>} fn private_fn() {$0}
pub fn pub_fn() {} pub fn pub_fn() {}
@ -51,7 +51,7 @@ mod tests {
let (analysis, pos) = fixture::position( let (analysis, pos) = fixture::position(
r#" r#"
trait Foo { trait Foo {
fn bar() {<|>} fn bar() {$0}
fn baz() {} fn baz() {}
} }
"#, "#,
@ -67,7 +67,7 @@ mod tests {
r#" r#"
//- /lib.rs //- /lib.rs
#[test] #[test]
fn foo() {<|>} fn foo() {$0}
pub fn pub_fn() {} pub fn pub_fn() {}

View file

@ -166,7 +166,7 @@ mod tests {
check( check(
r#" r#"
//- /main.rs crate:main deps:std //- /main.rs crate:main deps:std
extern crate std<|>; extern crate std$0;
//- /std/lib.rs crate:std //- /std/lib.rs crate:std
// empty // empty
//^ file //^ file
@ -179,7 +179,7 @@ mod tests {
check( check(
r#" r#"
//- /main.rs crate:main deps:std //- /main.rs crate:main deps:std
extern crate std as abc<|>; extern crate std as abc$0;
//- /std/lib.rs crate:std //- /std/lib.rs crate:std
// empty // empty
//^ file //^ file
@ -193,7 +193,7 @@ mod tests {
r#" r#"
struct Foo; struct Foo;
//^^^ //^^^
enum E { X(Foo<|>) } enum E { X(Foo$0) }
"#, "#,
); );
} }
@ -204,7 +204,7 @@ enum E { X(Foo<|>) }
r#" r#"
struct Foo; struct Foo;
//^^^ //^^^
enum E { X(<|>Foo) } enum E { X($0Foo) }
"#, "#,
); );
} }
@ -217,7 +217,7 @@ enum E { X(<|>Foo) }
use a::Foo; use a::Foo;
mod a; mod a;
mod b; mod b;
enum E { X(Foo<|>) } enum E { X(Foo$0) }
//- /a.rs //- /a.rs
struct Foo; struct Foo;
@ -233,7 +233,7 @@ struct Foo;
check( check(
r#" r#"
//- /lib.rs //- /lib.rs
mod <|>foo; mod $0foo;
//- /foo.rs //- /foo.rs
// empty // empty
@ -244,7 +244,7 @@ mod <|>foo;
check( check(
r#" r#"
//- /lib.rs //- /lib.rs
mod <|>foo; mod $0foo;
//- /foo/mod.rs //- /foo/mod.rs
// empty // empty
@ -260,7 +260,7 @@ mod <|>foo;
macro_rules! foo { () => { () } } macro_rules! foo { () => { () } }
//^^^ //^^^
fn bar() { fn bar() {
<|>foo!(); $0foo!();
} }
"#, "#,
); );
@ -273,7 +273,7 @@ fn bar() {
//- /lib.rs //- /lib.rs
use foo::foo; use foo::foo;
fn bar() { fn bar() {
<|>foo!(); $0foo!();
} }
//- /foo/lib.rs //- /foo/lib.rs
@ -289,7 +289,7 @@ macro_rules! foo { () => { () } }
check( check(
r#" r#"
//- /lib.rs //- /lib.rs
use foo::foo<|>; use foo::foo$0;
//- /foo/lib.rs //- /foo/lib.rs
#[macro_export] #[macro_export]
@ -312,7 +312,7 @@ define_fn!(foo);
//^^^ //^^^
fn bar() { fn bar() {
<|>foo(); $0foo();
} }
"#, "#,
); );
@ -331,7 +331,7 @@ macro_rules! define_fn {
//^^^^^^^^^^^^^ //^^^^^^^^^^^^^
fn bar() { fn bar() {
<|>foo(); $0foo();
} }
"#, "#,
); );
@ -347,7 +347,7 @@ macro_rules! foo {() => {0}}
fn bar() { fn bar() {
match (0,1) { match (0,1) {
(<|>foo!(), _) => {} ($0foo!(), _) => {}
} }
} }
"#, "#,
@ -363,7 +363,7 @@ macro_rules! foo {() => {0}}
//^^^ //^^^
fn bar() { fn bar() {
match 0 { match 0 {
<|>foo!() => {} $0foo!() => {}
} }
} }
"#, "#,
@ -375,7 +375,7 @@ fn bar() {
check( check(
r#" r#"
//- /lib.rs crate:main deps:foo //- /lib.rs crate:main deps:foo
use foo as bar<|>; use foo as bar$0;
//- /foo/lib.rs crate:foo //- /foo/lib.rs crate:foo
// empty // empty
@ -389,7 +389,7 @@ use foo as bar<|>;
check( check(
r#" r#"
//- /lib.rs crate:main deps:foo //- /lib.rs crate:main deps:foo
use foo::foo as bar<|>; use foo::foo as bar$0;
//- /foo/lib.rs crate:foo //- /foo/lib.rs crate:foo
#[macro_export] #[macro_export]
@ -410,7 +410,7 @@ impl Foo {
} }
fn bar(foo: &Foo) { fn bar(foo: &Foo) {
foo.frobnicate<|>(); foo.frobnicate$0();
} }
"#, "#,
); );
@ -425,7 +425,7 @@ struct Foo {
} //^^^^ } //^^^^
fn bar(foo: &Foo) { fn bar(foo: &Foo) {
foo.spam<|>; foo.spam$0;
} }
"#, "#,
); );
@ -442,7 +442,7 @@ struct Foo {
fn bar() -> Foo { fn bar() -> Foo {
Foo { Foo {
spam<|>: 0, spam$0: 0,
} }
} }
"#, "#,
@ -459,7 +459,7 @@ struct Foo {
} //^^^^ } //^^^^
fn bar(foo: Foo) -> Foo { fn bar(foo: Foo) -> Foo {
let Foo { spam<|>: _, } = foo let Foo { spam$0: _, } = foo
} }
"#, "#,
); );
@ -474,7 +474,7 @@ struct Foo { spam: u32 }
//^^^^ //^^^^
fn bar() -> Foo { fn bar() -> Foo {
Foo { spam<|>: m!() } Foo { spam$0: m!() }
} }
", ",
); );
@ -489,7 +489,7 @@ struct Foo(u32);
fn bar() { fn bar() {
let foo = Foo(0); let foo = Foo(0);
foo.<|>0; foo.$00;
} }
"#, "#,
); );
@ -505,7 +505,7 @@ impl Foo {
} //^^^^^^^^^^ } //^^^^^^^^^^
fn bar(foo: &Foo) { fn bar(foo: &Foo) {
Foo::frobnicate<|>(); Foo::frobnicate$0();
} }
"#, "#,
); );
@ -520,7 +520,7 @@ trait Foo {
} //^^^^^^^^^^ } //^^^^^^^^^^
fn bar() { fn bar() {
Foo::frobnicate<|>(); Foo::frobnicate$0();
} }
"#, "#,
); );
@ -537,7 +537,7 @@ trait Trait {
impl Trait for Foo {} impl Trait for Foo {}
fn bar() { fn bar() {
Foo::frobnicate<|>(); Foo::frobnicate$0();
} }
"#, "#,
); );
@ -551,7 +551,7 @@ struct Foo;
impl Foo { impl Foo {
//^^^ //^^^
pub fn new() -> Self { pub fn new() -> Self {
Self<|> {} Self$0 {}
} }
} }
"#, "#,
@ -561,7 +561,7 @@ impl Foo {
struct Foo; struct Foo;
impl Foo { impl Foo {
//^^^ //^^^
pub fn new() -> Self<|> { pub fn new() -> Self$0 {
Self {} Self {}
} }
} }
@ -573,7 +573,7 @@ impl Foo {
enum Foo { A } enum Foo { A }
impl Foo { impl Foo {
//^^^ //^^^
pub fn new() -> Self<|> { pub fn new() -> Self$0 {
Foo::A Foo::A
} }
} }
@ -585,7 +585,7 @@ impl Foo {
enum Foo { A } enum Foo { A }
impl Foo { impl Foo {
//^^^ //^^^
pub fn thing(a: &Self<|>) { pub fn thing(a: &Self$0) {
} }
} }
"#, "#,
@ -603,7 +603,7 @@ trait Make {
impl Make for Foo { impl Make for Foo {
//^^^ //^^^
fn new() -> Self { fn new() -> Self {
Self<|> {} Self$0 {}
} }
} }
"#, "#,
@ -617,7 +617,7 @@ trait Make {
} }
impl Make for Foo { impl Make for Foo {
//^^^ //^^^
fn new() -> Self<|> { fn new() -> Self$0 {
Self {} Self {}
} }
} }
@ -629,7 +629,7 @@ impl Make for Foo {
fn goto_def_when_used_on_definition_name_itself() { fn goto_def_when_used_on_definition_name_itself() {
check( check(
r#" r#"
struct Foo<|> { value: u32 } struct Foo$0 { value: u32 }
//^^^ //^^^
"#, "#,
); );
@ -637,21 +637,21 @@ struct Foo<|> { value: u32 }
check( check(
r#" r#"
struct Foo { struct Foo {
field<|>: string, field$0: string,
} //^^^^^ } //^^^^^
"#, "#,
); );
check( check(
r#" r#"
fn foo_test<|>() { } fn foo_test$0() { }
//^^^^^^^^ //^^^^^^^^
"#, "#,
); );
check( check(
r#" r#"
enum Foo<|> { Variant } enum Foo$0 { Variant }
//^^^ //^^^
"#, "#,
); );
@ -660,7 +660,7 @@ enum Foo<|> { Variant }
r#" r#"
enum Foo { enum Foo {
Variant1, Variant1,
Variant2<|>, Variant2$0,
//^^^^^^^^ //^^^^^^^^
Variant3, Variant3,
} }
@ -669,35 +669,35 @@ enum Foo {
check( check(
r#" r#"
static INNER<|>: &str = ""; static INNER$0: &str = "";
//^^^^^ //^^^^^
"#, "#,
); );
check( check(
r#" r#"
const INNER<|>: &str = ""; const INNER$0: &str = "";
//^^^^^ //^^^^^
"#, "#,
); );
check( check(
r#" r#"
type Thing<|> = Option<()>; type Thing$0 = Option<()>;
//^^^^^ //^^^^^
"#, "#,
); );
check( check(
r#" r#"
trait Foo<|> { } trait Foo$0 { }
//^^^ //^^^
"#, "#,
); );
check( check(
r#" r#"
mod bar<|> { } mod bar$0 { }
//^^^ //^^^
"#, "#,
); );
@ -714,7 +714,7 @@ fn foo() {}
//^^^ //^^^
id! { id! {
fn bar() { fn bar() {
fo<|>o(); fo$0o();
} }
} }
mod confuse_index { fn foo(); } mod confuse_index { fn foo(); }
@ -743,7 +743,7 @@ pub mod __export {
fn foo() -> i8 {} fn foo() -> i8 {}
//^^^ //^^^
fn test() { fn test() {
format!("{}", fo<|>o()) format!("{}", fo$0o())
} }
"#, "#,
); );
@ -761,7 +761,7 @@ macro_rules! include {}
//^^^^^^^^^^^^^^^^^^^ //^^^^^^^^^^^^^^^^^^^
fn f() { fn f() {
foo<|>(); foo$0();
} }
mod confuse_index { mod confuse_index {
@ -778,7 +778,7 @@ fn foo() {}
fn goto_for_type_param() { fn goto_for_type_param() {
check( check(
r#" r#"
struct Foo<T: Clone> { t: <|>T } struct Foo<T: Clone> { t: $0T }
//^ //^
"#, "#,
); );
@ -796,7 +796,7 @@ fn foo() {
let x = 1; let x = 1;
//^ //^
id!({ id!({
let y = <|>x; let y = $0x;
let z = y; let z = y;
}); });
} }
@ -814,7 +814,7 @@ fn foo() {
id!({ id!({
let y = x; let y = x;
//^ //^
let z = <|>y; let z = $0y;
}); });
} }
"#, "#,
@ -829,7 +829,7 @@ fn main() {
fn foo() { fn foo() {
let x = 92; let x = 92;
//^ //^
<|>x; $0x;
} }
} }
"#, "#,
@ -843,7 +843,7 @@ fn main() {
fn bar() { fn bar() {
macro_rules! foo { () => { () } } macro_rules! foo { () => { () } }
//^^^ //^^^
<|>foo!(); $0foo!();
} }
"#, "#,
); );
@ -857,7 +857,7 @@ struct Foo { x: i32 }
fn main() { fn main() {
let x = 92; let x = 92;
//^ //^
Foo { x<|> }; Foo { x$0 };
} }
"#, "#,
) )
@ -872,7 +872,7 @@ enum Foo {
} //^ } //^
fn baz(foo: Foo) { fn baz(foo: Foo) {
match foo { match foo {
Foo::Bar { x<|> } => x Foo::Bar { x$0 } => x
}; };
} }
"#, "#,
@ -887,7 +887,7 @@ enum Foo { Bar }
//^^^ //^^^
impl Foo { impl Foo {
fn baz(self) { fn baz(self) {
match self { Self::Bar<|> => {} } match self { Self::Bar$0 => {} }
} }
} }
"#, "#,
@ -902,7 +902,7 @@ enum Foo { Bar { val: i32 } }
//^^^ //^^^
impl Foo { impl Foo {
fn baz(self) -> i32 { fn baz(self) -> i32 {
match self { Self::Bar<|> { val } => {} } match self { Self::Bar$0 { val } => {} }
} }
} }
"#, "#,
@ -916,7 +916,7 @@ impl Foo {
enum Foo { Bar } enum Foo { Bar }
//^^^ //^^^
impl Foo { impl Foo {
fn baz(self) { Self::Bar<|>; } fn baz(self) { Self::Bar$0; }
} }
"#, "#,
); );
@ -929,7 +929,7 @@ impl Foo {
enum Foo { Bar { val: i32 } } enum Foo { Bar { val: i32 } }
//^^^ //^^^
impl Foo { impl Foo {
fn baz(self) { Self::Bar<|> {val: 4}; } fn baz(self) { Self::Bar$0 {val: 4}; }
} }
"#, "#,
); );
@ -939,7 +939,7 @@ impl Foo {
fn goto_def_for_type_alias_generic_parameter() { fn goto_def_for_type_alias_generic_parameter() {
check( check(
r#" r#"
type Alias<T> = T<|>; type Alias<T> = T$0;
//^ //^
"#, "#,
) )
@ -950,7 +950,7 @@ type Alias<T> = T<|>;
check( check(
r#" r#"
//- /lib.rs //- /lib.rs
foo::module<|>::mac!(); foo::module$0::mac!();
//- /foo/lib.rs //- /foo/lib.rs
pub mod module { pub mod module {
@ -972,7 +972,7 @@ trait Iterator {
//^^^^ //^^^^
} }
fn f() -> impl Iterator<Item<|> = u8> {} fn f() -> impl Iterator<Item$0 = u8> {}
"#, "#,
); );
} }
@ -987,7 +987,7 @@ trait Iterator {
type B; type B;
} }
fn f() -> impl Iterator<A<|> = u8, B = ()> {} fn f() -> impl Iterator<A$0 = u8, B = ()> {}
"#, "#,
); );
check( check(
@ -998,7 +998,7 @@ trait Iterator {
//^ //^
} }
fn f() -> impl Iterator<A = u8, B<|> = ()> {} fn f() -> impl Iterator<A = u8, B$0 = ()> {}
"#, "#,
); );
} }
@ -1012,7 +1012,7 @@ trait Iterator {
//^^^^ //^^^^
} }
fn g() -> <() as Iterator<Item<|> = ()>>::Item {} fn g() -> <() as Iterator<Item$0 = ()>>::Item {}
"#, "#,
); );
} }
@ -1027,7 +1027,7 @@ trait Iterator {
type B; type B;
} }
fn g() -> <() as Iterator<A<|> = (), B = u8>>::B {} fn g() -> <() as Iterator<A$0 = (), B = u8>>::B {}
"#, "#,
); );
check( check(
@ -1038,7 +1038,7 @@ trait Iterator {
//^ //^
} }
fn g() -> <() as Iterator<A = (), B<|> = u8>>::A {} fn g() -> <() as Iterator<A = (), B$0 = u8>>::A {}
"#, "#,
); );
} }
@ -1052,7 +1052,7 @@ struct Foo {}
impl Foo { impl Foo {
fn bar(self: &Foo) { fn bar(self: &Foo) {
//^^^^ //^^^^
let foo = sel<|>f; let foo = sel$0f;
} }
}"#, }"#,
) )
@ -1065,7 +1065,7 @@ impl Foo {
struct Foo {} struct Foo {}
impl Foo { impl Foo {
fn bar(&self<|>) { fn bar(&self$0) {
//^^^^ //^^^^
} }
}"#, }"#,
@ -1076,7 +1076,7 @@ impl Foo {
fn goto_lifetime_param_on_decl() { fn goto_lifetime_param_on_decl() {
check( check(
r#" r#"
fn foo<'foobar<|>>(_: &'foobar ()) { fn foo<'foobar$0>(_: &'foobar ()) {
//^^^^^^^ //^^^^^^^
}"#, }"#,
) )
@ -1086,7 +1086,7 @@ fn foo<'foobar<|>>(_: &'foobar ()) {
fn goto_lifetime_param_decl() { fn goto_lifetime_param_decl() {
check( check(
r#" r#"
fn foo<'foobar>(_: &'foobar<|> ()) { fn foo<'foobar>(_: &'foobar$0 ()) {
//^^^^^^^ //^^^^^^^
}"#, }"#,
) )
@ -1097,7 +1097,7 @@ fn foo<'foobar>(_: &'foobar<|> ()) {
check( check(
r#" r#"
fn foo<'foobar>(_: &'foobar ()) { fn foo<'foobar>(_: &'foobar ()) {
fn foo<'foobar>(_: &'foobar<|> ()) {} fn foo<'foobar>(_: &'foobar$0 ()) {}
//^^^^^^^ //^^^^^^^
}"#, }"#,
) )
@ -1108,13 +1108,13 @@ fn foo<'foobar>(_: &'foobar ()) {
fn goto_lifetime_hrtb() { fn goto_lifetime_hrtb() {
check( check(
r#"trait Foo<T> {} r#"trait Foo<T> {}
fn foo<T>() where for<'a> T: Foo<&'a<|> (u8, u16)>, {} fn foo<T>() where for<'a> T: Foo<&'a$0 (u8, u16)>, {}
//^^ //^^
"#, "#,
); );
check( check(
r#"trait Foo<T> {} r#"trait Foo<T> {}
fn foo<T>() where for<'a<|>> T: Foo<&'a (u8, u16)>, {} fn foo<T>() where for<'a$0> T: Foo<&'a (u8, u16)>, {}
//^^ //^^
"#, "#,
); );
@ -1125,7 +1125,7 @@ fn foo<T>() where for<'a<|>> T: Foo<&'a (u8, u16)>, {}
fn goto_lifetime_hrtb_for_type() { fn goto_lifetime_hrtb_for_type() {
check( check(
r#"trait Foo<T> {} r#"trait Foo<T> {}
fn foo<T>() where T: for<'a> Foo<&'a<|> (u8, u16)>, {} fn foo<T>() where T: for<'a> Foo<&'a$0 (u8, u16)>, {}
//^^ //^^
"#, "#,
); );
@ -1139,7 +1139,7 @@ fn foo<'foo>(_: &'foo ()) {
'foo: { 'foo: {
//^^^^ //^^^^
'bar: loop { 'bar: loop {
break 'foo<|>; break 'foo$0;
} }
} }
}"#, }"#,

View file

@ -107,7 +107,7 @@ mod tests {
fn goto_implementation_works() { fn goto_implementation_works() {
check( check(
r#" r#"
struct Foo<|>; struct Foo$0;
impl Foo {} impl Foo {}
//^^^ //^^^
"#, "#,
@ -118,7 +118,7 @@ impl Foo {}
fn goto_implementation_works_multiple_blocks() { fn goto_implementation_works_multiple_blocks() {
check( check(
r#" r#"
struct Foo<|>; struct Foo$0;
impl Foo {} impl Foo {}
//^^^ //^^^
impl Foo {} impl Foo {}
@ -131,7 +131,7 @@ impl Foo {}
fn goto_implementation_works_multiple_mods() { fn goto_implementation_works_multiple_mods() {
check( check(
r#" r#"
struct Foo<|>; struct Foo$0;
mod a { mod a {
impl super::Foo {} impl super::Foo {}
//^^^^^^^^^^ //^^^^^^^^^^
@ -149,7 +149,7 @@ mod b {
check( check(
r#" r#"
//- /lib.rs //- /lib.rs
struct Foo<|>; struct Foo$0;
mod a; mod a;
mod b; mod b;
//- /a.rs //- /a.rs
@ -166,7 +166,7 @@ impl crate::Foo {}
fn goto_implementation_for_trait() { fn goto_implementation_for_trait() {
check( check(
r#" r#"
trait T<|> {} trait T$0 {}
struct Foo; struct Foo;
impl T for Foo {} impl T for Foo {}
//^^^ //^^^
@ -179,7 +179,7 @@ impl T for Foo {}
check( check(
r#" r#"
//- /lib.rs //- /lib.rs
trait T<|> {}; trait T$0 {};
struct Foo; struct Foo;
mod a; mod a;
mod b; mod b;
@ -199,7 +199,7 @@ impl crate::T for crate::Foo {}
r#" r#"
//- /lib.rs //- /lib.rs
trait T {} trait T {}
struct Foo<|>; struct Foo$0;
impl Foo {} impl Foo {}
//^^^ //^^^
impl T for Foo {} impl T for Foo {}
@ -216,7 +216,7 @@ impl T for &Foo {}
r#" r#"
#[derive(Copy)] #[derive(Copy)]
//^^^^^^^^^^^^^^^ //^^^^^^^^^^^^^^^
struct Foo<|>; struct Foo$0;
mod marker { mod marker {
trait Copy {} trait Copy {}

View file

@ -76,7 +76,7 @@ mod tests {
struct Foo; struct Foo;
//^^^ //^^^
fn foo() { fn foo() {
let f: Foo; f<|> let f: Foo; f$0
} }
"#, "#,
); );
@ -89,7 +89,7 @@ fn foo() {
struct Foo; struct Foo;
//^^^ //^^^
fn foo() { fn foo() {
let f: &Foo; f<|> let f: &Foo; f$0
} }
"#, "#,
); );
@ -103,7 +103,7 @@ macro_rules! id { ($($tt:tt)*) => { $($tt)* } }
struct Foo {} struct Foo {}
//^^^ //^^^
id! { id! {
fn bar() { let f<|> = Foo {}; } fn bar() { let f$0 = Foo {}; }
} }
"#, "#,
); );
@ -115,7 +115,7 @@ id! {
r#" r#"
struct Foo; struct Foo;
//^^^ //^^^
fn foo(<|>f: Foo) {} fn foo($0f: Foo) {}
"#, "#,
); );
} }
@ -129,7 +129,7 @@ struct Foo;
struct Bar(Foo); struct Bar(Foo);
fn foo() { fn foo() {
let bar = Bar(Foo); let bar = Bar(Foo);
bar.<|>0; bar.$00;
} }
"#, "#,
); );
@ -142,7 +142,7 @@ fn foo() {
struct Foo; struct Foo;
//^^^ //^^^
impl Foo { impl Foo {
fn f(&self<|>) {} fn f(&self$0) {}
} }
"#, "#,
) )

View file

@ -457,7 +457,7 @@ mod tests {
pub fn foo() -> u32 { 1 } pub fn foo() -> u32 { 1 }
fn main() { fn main() {
let foo_test = foo()<|>; let foo_test = foo()$0;
} }
"#, "#,
expect![[r#" expect![[r#"
@ -476,7 +476,7 @@ fn main() {
pub fn foo() -> u32 { 1 } pub fn foo() -> u32 { 1 }
fn main() { fn main() {
let foo_test = foo()<|>; let foo_test = foo()$0;
} }
"#, "#,
expect![[r#" expect![[r#"
@ -506,7 +506,7 @@ fn main() {
Option::Some(*memo + value) Option::Some(*memo + value)
}; };
let number = 5u32; let number = 5u32;
let mut iter<|> = scan(OtherStruct { i: num }, closure, number); let mut iter$0 = scan(OtherStruct { i: num }, closure, number);
} }
"#, "#,
expect![[r#" expect![[r#"
@ -526,7 +526,7 @@ fn main() {
r#" r#"
pub fn foo() -> u32 { 1 } pub fn foo() -> u32 { 1 }
fn main() { let foo_test = fo<|>o(); } fn main() { let foo_test = fo$0o(); }
"#, "#,
expect![[r#" expect![[r#"
*foo* *foo*
@ -558,7 +558,7 @@ mod a;
mod b; mod b;
mod c; mod c;
fn main() { let foo_test = fo<|>o(); } fn main() { let foo_test = fo$0o(); }
"#, "#,
expect![[r#" expect![[r#"
*foo* *foo*
@ -575,7 +575,7 @@ fn main() { let foo_test = fo<|>o(); }
r#" r#"
pub fn foo<'a, T: AsRef<str>>(b: &'a T) -> &'a str { } pub fn foo<'a, T: AsRef<str>>(b: &'a T) -> &'a str { }
fn main() { let foo_test = fo<|>o(); } fn main() { let foo_test = fo$0o(); }
"#, "#,
expect![[r#" expect![[r#"
*foo* *foo*
@ -595,7 +595,7 @@ fn main() { let foo_test = fo<|>o(); }
fn hover_shows_fn_signature_on_fn_name() { fn hover_shows_fn_signature_on_fn_name() {
check( check(
r#" r#"
pub fn foo<|>(a: u32, b: u32) -> u32 {} pub fn foo$0(a: u32, b: u32) -> u32 {}
fn main() { } fn main() { }
"#, "#,
@ -623,7 +623,7 @@ fn main() { }
/// # /// #
/// foo(Path::new("hello, world!")) /// foo(Path::new("hello, world!"))
/// ``` /// ```
pub fn foo<|>(_: &Path) {} pub fn foo$0(_: &Path) {}
fn main() { } fn main() { }
"#, "#,
@ -656,7 +656,7 @@ fn main() { }
check( check(
r##" r##"
#[doc = r#"Raw string doc attr"#] #[doc = r#"Raw string doc attr"#]
pub fn foo<|>(_: &Path) {} pub fn foo$0(_: &Path) {}
fn main() { } fn main() { }
"##, "##,
@ -686,7 +686,7 @@ fn main() { }
struct Foo { field_a: u32 } struct Foo { field_a: u32 }
fn main() { fn main() {
let foo = Foo { field_a<|>: 0, }; let foo = Foo { field_a$0: 0, };
} }
"#, "#,
expect![[r#" expect![[r#"
@ -705,7 +705,7 @@ fn main() {
// Hovering over the field in the definition // Hovering over the field in the definition
check( check(
r#" r#"
struct Foo { field_a<|>: u32 } struct Foo { field_a$0: u32 }
fn main() { fn main() {
let foo = Foo { field_a: 0 }; let foo = Foo { field_a: 0 };
@ -728,7 +728,7 @@ fn main() {
#[test] #[test]
fn hover_const_static() { fn hover_const_static() {
check( check(
r#"const foo<|>: u32 = 123;"#, r#"const foo$0: u32 = 123;"#,
expect![[r#" expect![[r#"
*foo* *foo*
@ -742,7 +742,7 @@ fn main() {
"#]], "#]],
); );
check( check(
r#"static foo<|>: u32 = 456;"#, r#"static foo$0: u32 = 456;"#,
expect![[r#" expect![[r#"
*foo* *foo*
@ -764,7 +764,7 @@ fn main() {
struct Test<K, T = u8> { k: K, t: T } struct Test<K, T = u8> { k: K, t: T }
fn main() { fn main() {
let zz<|> = Test { t: 23u8, k: 33 }; let zz$0 = Test { t: 23u8, k: 33 };
}"#, }"#,
expect![[r#" expect![[r#"
*zz* *zz*
@ -783,7 +783,7 @@ fn main() {
enum Option<T> { Some(T) } enum Option<T> { Some(T) }
use Option::Some; use Option::Some;
fn main() { So<|>me(12); } fn main() { So$0me(12); }
"#, "#,
expect![[r#" expect![[r#"
*Some* *Some*
@ -803,7 +803,7 @@ fn main() { So<|>me(12); }
enum Option<T> { Some(T) } enum Option<T> { Some(T) }
use Option::Some; use Option::Some;
fn main() { let b<|>ar = Some(12); } fn main() { let b$0ar = Some(12); }
"#, "#,
expect![[r#" expect![[r#"
*bar* *bar*
@ -821,7 +821,7 @@ fn main() { let b<|>ar = Some(12); }
r#" r#"
enum Option<T> { enum Option<T> {
/// The None variant /// The None variant
Non<|>e Non$0e
} }
"#, "#,
expect![[r#" expect![[r#"
@ -848,7 +848,7 @@ enum Option<T> {
Some(T) Some(T)
} }
fn main() { fn main() {
let s = Option::Som<|>e(12); let s = Option::Som$0e(12);
} }
"#, "#,
expect![[r#" expect![[r#"
@ -872,7 +872,7 @@ fn main() {
#[test] #[test]
fn hover_for_local_variable() { fn hover_for_local_variable() {
check( check(
r#"fn func(foo: i32) { fo<|>o; }"#, r#"fn func(foo: i32) { fo$0o; }"#,
expect![[r#" expect![[r#"
*foo* *foo*
@ -886,7 +886,7 @@ fn main() {
#[test] #[test]
fn hover_for_local_variable_pat() { fn hover_for_local_variable_pat() {
check( check(
r#"fn func(fo<|>o: i32) {}"#, r#"fn func(fo$0o: i32) {}"#,
expect![[r#" expect![[r#"
*foo* *foo*
@ -900,7 +900,7 @@ fn main() {
#[test] #[test]
fn hover_local_var_edge() { fn hover_local_var_edge() {
check( check(
r#"fn func(foo: i32) { if true { <|>foo; }; }"#, r#"fn func(foo: i32) { if true { $0foo; }; }"#,
expect![[r#" expect![[r#"
*foo* *foo*
@ -914,7 +914,7 @@ fn main() {
#[test] #[test]
fn hover_for_param_edge() { fn hover_for_param_edge() {
check( check(
r#"fn func(<|>foo: i32) {}"#, r#"fn func($0foo: i32) {}"#,
expect![[r#" expect![[r#"
*foo* *foo*
@ -934,7 +934,7 @@ fn main() {
trait DerefMut { trait DerefMut {
type Target: ?Sized; type Target: ?Sized;
} }
fn f(_x<|>: impl Deref<Target=u8> + DerefMut<Target=u8>) {}"#, fn f(_x$0: impl Deref<Target=u8> + DerefMut<Target=u8>) {}"#,
expect![[r#" expect![[r#"
*_x* *_x*
@ -955,7 +955,7 @@ impl Thing {
fn new() -> Thing { Thing { x: 0 } } fn new() -> Thing { Thing { x: 0 } }
} }
fn main() { let foo_<|>test = Thing::new(); } fn main() { let foo_$0test = Thing::new(); }
"#, "#,
expect![[r#" expect![[r#"
*foo_test* *foo_test*
@ -979,7 +979,7 @@ mod wrapper {
} }
} }
fn main() { let foo_test = wrapper::Thing::new<|>(); } fn main() { let foo_test = wrapper::Thing::new$0(); }
"#, "#,
expect![[r#" expect![[r#"
*new* *new*
@ -1006,7 +1006,7 @@ impl X {
fn main() { fn main() {
match 1 { match 1 {
X::C<|> => {}, X::C$0 => {},
2 => {}, 2 => {},
_ => {} _ => {}
}; };
@ -1032,7 +1032,7 @@ fn main() {
r#" r#"
struct Thing { x: u32 } struct Thing { x: u32 }
impl Thing { impl Thing {
fn new() -> Self { Self<|> { x: 0 } } fn new() -> Self { Self$0 { x: 0 } }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -1051,7 +1051,7 @@ impl Thing {
r#" r#"
struct Thing { x: u32 } struct Thing { x: u32 }
impl Thing { impl Thing {
fn new() -> Self<|> { Self { x: 0 } } fn new() -> Self$0 { Self { x: 0 } }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -1070,7 +1070,7 @@ impl Thing {
r#" r#"
enum Thing { A } enum Thing { A }
impl Thing { impl Thing {
pub fn new() -> Self<|> { Thing::A } pub fn new() -> Self$0 { Thing::A }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -1089,7 +1089,7 @@ impl Thing {
r#" r#"
enum Thing { A } enum Thing { A }
impl Thing { impl Thing {
pub fn thing(a: Self<|>) {} pub fn thing(a: Self$0) {}
} }
"#, "#,
expect![[r#" expect![[r#"
@ -1114,7 +1114,7 @@ fn x() {}
fn y() { fn y() {
let x = 0i32; let x = 0i32;
x<|>; x$0;
} }
"#, "#,
expect![[r#" expect![[r#"
@ -1133,7 +1133,7 @@ fn y() {
r#" r#"
macro_rules! foo { () => {} } macro_rules! foo { () => {} }
fn f() { fo<|>o!(); } fn f() { fo$0o!(); }
"#, "#,
expect![[r#" expect![[r#"
*foo* *foo*
@ -1152,7 +1152,7 @@ fn f() { fo<|>o!(); }
#[test] #[test]
fn test_hover_tuple_field() { fn test_hover_tuple_field() {
check( check(
r#"struct TS(String, i32<|>);"#, r#"struct TS(String, i32$0);"#,
expect![[r#" expect![[r#"
*i32* *i32*
@ -1170,7 +1170,7 @@ fn f() { fo<|>o!(); }
macro_rules! id { ($($tt:tt)*) => { $($tt)* } } macro_rules! id { ($($tt:tt)*) => { $($tt)* } }
fn foo() {} fn foo() {}
id! { id! {
fn bar() { fo<|>o(); } fn bar() { fo$0o(); }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -1192,7 +1192,7 @@ id! {
check( check(
r#" r#"
macro_rules! id { ($($tt:tt)*) => { $($tt)* } } macro_rules! id { ($($tt:tt)*) => { $($tt)* } }
fn foo(bar:u32) { let a = id!(ba<|>r); } fn foo(bar:u32) { let a = id!(ba$0r); }
"#, "#,
expect![[r#" expect![[r#"
*bar* *bar*
@ -1210,7 +1210,7 @@ fn foo(bar:u32) { let a = id!(ba<|>r); }
r#" r#"
macro_rules! id_deep { ($($tt:tt)*) => { $($tt)* } } macro_rules! id_deep { ($($tt:tt)*) => { $($tt)* } }
macro_rules! id { ($($tt:tt)*) => { id_deep!($($tt)*) } } macro_rules! id { ($($tt:tt)*) => { id_deep!($($tt)*) } }
fn foo(bar:u32) { let a = id!(ba<|>r); } fn foo(bar:u32) { let a = id!(ba$0r); }
"#, "#,
expect![[r#" expect![[r#"
*bar* *bar*
@ -1229,7 +1229,7 @@ fn foo(bar:u32) { let a = id!(ba<|>r); }
macro_rules! id_deep { ($($tt:tt)*) => { $($tt)* } } macro_rules! id_deep { ($($tt:tt)*) => { $($tt)* } }
macro_rules! id { ($($tt:tt)*) => { id_deep!($($tt)*) } } macro_rules! id { ($($tt:tt)*) => { id_deep!($($tt)*) } }
fn bar() -> u32 { 0 } fn bar() -> u32 { 0 }
fn foo() { let a = id!([0u32, bar(<|>)] ); } fn foo() { let a = id!([0u32, bar($0)] ); }
"#, "#,
expect![[r#" expect![[r#"
*bar()* *bar()*
@ -1247,7 +1247,7 @@ fn foo() { let a = id!([0u32, bar(<|>)] ); }
macro_rules! arr { ($($tt:tt)*) => { [$($tt)*)] } } macro_rules! arr { ($($tt:tt)*) => { [$($tt)*)] } }
fn foo() { fn foo() {
let mastered_for_itunes = ""; let mastered_for_itunes = "";
let _ = arr!("Tr<|>acks", &mastered_for_itunes); let _ = arr!("Tr$0acks", &mastered_for_itunes);
} }
"#, "#,
expect![[r#" expect![[r#"
@ -1268,7 +1268,7 @@ macro_rules! assert {}
fn bar() -> bool { true } fn bar() -> bool { true }
fn foo() { fn foo() {
assert!(ba<|>r()); assert!(ba$0r());
} }
"#, "#,
expect![[r#" expect![[r#"
@ -1293,7 +1293,7 @@ fn foo() {
macro_rules! format {} macro_rules! format {}
fn foo() { fn foo() {
format!("hel<|>lo {}", 0); format!("hel$0lo {}", 0);
} }
"#, "#,
); );
@ -1306,7 +1306,7 @@ fn foo() {
/// <- `\u{3000}` here /// <- `\u{3000}` here
fn foo() { } fn foo() { }
fn bar() { fo<|>o(); } fn bar() { fo$0o(); }
", ",
expect![[r#" expect![[r#"
*foo* *foo*
@ -1329,7 +1329,7 @@ fn bar() { fo<|>o(); }
#[test] #[test]
fn test_hover_function_show_qualifiers() { fn test_hover_function_show_qualifiers() {
check( check(
r#"async fn foo<|>() {}"#, r#"async fn foo$0() {}"#,
expect![[r#" expect![[r#"
*foo* *foo*
@ -1343,7 +1343,7 @@ fn bar() { fo<|>o(); }
"#]], "#]],
); );
check( check(
r#"pub const unsafe fn foo<|>() {}"#, r#"pub const unsafe fn foo$0() {}"#,
expect![[r#" expect![[r#"
*foo* *foo*
@ -1357,7 +1357,7 @@ fn bar() { fo<|>o(); }
"#]], "#]],
); );
check( check(
r#"pub(crate) async unsafe extern "C" fn foo<|>() {}"#, r#"pub(crate) async unsafe extern "C" fn foo$0() {}"#,
expect![[r#" expect![[r#"
*foo* *foo*
@ -1375,7 +1375,7 @@ fn bar() { fo<|>o(); }
#[test] #[test]
fn test_hover_trait_show_qualifiers() { fn test_hover_trait_show_qualifiers() {
check_actions( check_actions(
r"unsafe trait foo<|>() {}", r"unsafe trait foo$0() {}",
expect![[r#" expect![[r#"
[ [
Implementation( Implementation(
@ -1396,7 +1396,7 @@ fn bar() { fo<|>o(); }
check( check(
r#" r#"
//- /main.rs crate:main deps:std //- /main.rs crate:main deps:std
extern crate st<|>d; extern crate st$0d;
//- /std/lib.rs crate:std //- /std/lib.rs crate:std
//! Standard library for this test //! Standard library for this test
//! //!
@ -1414,7 +1414,7 @@ extern crate st<|>d;
check( check(
r#" r#"
//- /main.rs crate:main deps:std //- /main.rs crate:main deps:std
extern crate std as ab<|>c; extern crate std as ab$0c;
//- /std/lib.rs crate:std //- /std/lib.rs crate:std
//! Standard library for this test //! Standard library for this test
//! //!
@ -1435,7 +1435,7 @@ extern crate std as ab<|>c;
fn test_hover_mod_with_same_name_as_function() { fn test_hover_mod_with_same_name_as_function() {
check( check(
r#" r#"
use self::m<|>y::Bar; use self::m$0y::Bar;
mod my { pub struct Bar; } mod my { pub struct Bar; }
fn my() {} fn my() {}
@ -1461,7 +1461,7 @@ fn my() {}
/// bar docs /// bar docs
struct Bar; struct Bar;
fn foo() { let bar = Ba<|>r; } fn foo() { let bar = Ba$0r; }
"#, "#,
expect![[r#" expect![[r#"
*Bar* *Bar*
@ -1488,7 +1488,7 @@ fn foo() { let bar = Ba<|>r; }
#[doc = "bar docs"] #[doc = "bar docs"]
struct Bar; struct Bar;
fn foo() { let bar = Ba<|>r; } fn foo() { let bar = Ba$0r; }
"#, "#,
expect![[r#" expect![[r#"
*Bar* *Bar*
@ -1517,7 +1517,7 @@ fn foo() { let bar = Ba<|>r; }
#[doc = "bar docs 2"] #[doc = "bar docs 2"]
struct Bar; struct Bar;
fn foo() { let bar = Ba<|>r; } fn foo() { let bar = Ba$0r; }
"#, "#,
expect![[r#" expect![[r#"
*Bar* *Bar*
@ -1545,7 +1545,7 @@ fn foo() { let bar = Ba<|>r; }
r#" r#"
pub struct Foo; pub struct Foo;
/// [Foo](struct.Foo.html) /// [Foo](struct.Foo.html)
pub struct B<|>ar pub struct B$0ar
"#, "#,
expect![[r#" expect![[r#"
*Bar* *Bar*
@ -1571,7 +1571,7 @@ pub struct B<|>ar
r#" r#"
pub struct Foo; pub struct Foo;
/// [struct Foo](struct.Foo.html) /// [struct Foo](struct.Foo.html)
pub struct B<|>ar pub struct B$0ar
"#, "#,
expect![[r#" expect![[r#"
*Bar* *Bar*
@ -1599,7 +1599,7 @@ pub struct B<|>ar
pub struct Foo; pub struct Foo;
pub struct Bar { pub struct Bar {
/// [Foo](struct.Foo.html) /// [Foo](struct.Foo.html)
fie<|>ld: () fie$0ld: ()
} }
"#, "#,
expect![[r#" expect![[r#"
@ -1628,7 +1628,7 @@ pub mod foo {
pub struct Foo; pub struct Foo;
} }
/// [Foo](foo::Foo) /// [Foo](foo::Foo)
pub struct B<|>ar pub struct B$0ar
"#, "#,
expect![[r#" expect![[r#"
*Bar* *Bar*
@ -1658,7 +1658,7 @@ pub mod foo {
pub struct Foo; pub struct Foo;
} }
/// [Foo](foo::Foo) /// [Foo](foo::Foo)
pub struct B<|>ar pub struct B$0ar
"#, "#,
expect![[r#" expect![[r#"
*Bar* *Bar*
@ -1684,7 +1684,7 @@ pub struct B<|>ar
r#" r#"
pub struct Foo; pub struct Foo;
/// [Foo] /// [Foo]
pub struct B<|>ar pub struct B$0ar
"#, "#,
expect![[r#" expect![[r#"
*Bar* *Bar*
@ -1710,7 +1710,7 @@ pub struct B<|>ar
r#" r#"
pub struct Foo; pub struct Foo;
/// [`Foo`] /// [`Foo`]
pub struct B<|>ar pub struct B$0ar
"#, "#,
expect![[r#" expect![[r#"
*Bar* *Bar*
@ -1737,7 +1737,7 @@ pub struct B<|>ar
pub struct Foo; pub struct Foo;
fn Foo() {} fn Foo() {}
/// [Foo()] /// [Foo()]
pub struct B<|>ar pub struct B$0ar
"#, "#,
expect![[r#" expect![[r#"
*Bar* *Bar*
@ -1763,7 +1763,7 @@ pub struct B<|>ar
r#" r#"
pub struct Foo; pub struct Foo;
/// [`struct Foo`] /// [`struct Foo`]
pub struct B<|>ar pub struct B$0ar
"#, "#,
expect![[r#" expect![[r#"
*Bar* *Bar*
@ -1789,7 +1789,7 @@ pub struct B<|>ar
r#" r#"
pub struct Foo; pub struct Foo;
/// [`struct@Foo`] /// [`struct@Foo`]
pub struct B<|>ar pub struct B$0ar
"#, "#,
expect![[r#" expect![[r#"
*Bar* *Bar*
@ -1817,7 +1817,7 @@ pub struct Foo;
/// [my Foo][foo] /// [my Foo][foo]
/// ///
/// [foo]: Foo /// [foo]: Foo
pub struct B<|>ar pub struct B$0ar
"#, "#,
expect![[r#" expect![[r#"
*Bar* *Bar*
@ -1843,7 +1843,7 @@ pub struct B<|>ar
r#" r#"
pub struct Foo; pub struct Foo;
/// [external](https://www.google.com) /// [external](https://www.google.com)
pub struct B<|>ar pub struct B$0ar
"#, "#,
expect![[r#" expect![[r#"
*Bar* *Bar*
@ -1870,7 +1870,7 @@ pub struct B<|>ar
r#" r#"
pub struct Foo; pub struct Foo;
/// [baz](Baz) /// [baz](Baz)
pub struct B<|>ar pub struct B$0ar
"#, "#,
expect![[r#" expect![[r#"
*Bar* *Bar*
@ -1896,7 +1896,7 @@ pub struct B<|>ar
r#" r#"
enum E { enum E {
/// [E] /// [E]
V<|> { field: i32 } V$0 { field: i32 }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -1923,7 +1923,7 @@ enum E {
r#" r#"
struct S { struct S {
/// [`S`] /// [`S`]
field<|>: i32 field$0: i32
} }
"#, "#,
expect![[r#" expect![[r#"
@ -1969,7 +1969,7 @@ struct S {
/// ///
/// [`Result`]: ../../std/result/enum.Result.html /// [`Result`]: ../../std/result/enum.Result.html
/// [^example]: https://www.example.com/ /// [^example]: https://www.example.com/
pub fn fo<|>o() {} pub fn fo$0o() {}
"#, "#,
expect![[r#" expect![[r#"
*foo* *foo*
@ -2026,7 +2026,7 @@ macro_rules! bar {
bar!(); bar!();
fn foo() { let bar = Bar; bar.fo<|>o(); } fn foo() { let bar = Bar; bar.fo$0o(); }
"#, "#,
expect![[r#" expect![[r#"
*foo* *foo*
@ -2064,7 +2064,7 @@ macro_rules! bar {
bar!(); bar!();
fn foo() { let bar = Bar; bar.fo<|>o(); } fn foo() { let bar = Bar; bar.fo$0o(); }
"#, "#,
expect![[r#" expect![[r#"
*foo* *foo*
@ -2087,7 +2087,7 @@ fn foo() { let bar = Bar; bar.fo<|>o(); }
#[test] #[test]
fn test_hover_trait_has_impl_action() { fn test_hover_trait_has_impl_action() {
check_actions( check_actions(
r#"trait foo<|>() {}"#, r#"trait foo$0() {}"#,
expect![[r#" expect![[r#"
[ [
Implementation( Implementation(
@ -2106,7 +2106,7 @@ fn foo() { let bar = Bar; bar.fo<|>o(); }
#[test] #[test]
fn test_hover_struct_has_impl_action() { fn test_hover_struct_has_impl_action() {
check_actions( check_actions(
r"struct foo<|>() {}", r"struct foo$0() {}",
expect![[r#" expect![[r#"
[ [
Implementation( Implementation(
@ -2125,7 +2125,7 @@ fn foo() { let bar = Bar; bar.fo<|>o(); }
#[test] #[test]
fn test_hover_union_has_impl_action() { fn test_hover_union_has_impl_action() {
check_actions( check_actions(
r#"union foo<|>() {}"#, r#"union foo$0() {}"#,
expect![[r#" expect![[r#"
[ [
Implementation( Implementation(
@ -2144,7 +2144,7 @@ fn foo() { let bar = Bar; bar.fo<|>o(); }
#[test] #[test]
fn test_hover_enum_has_impl_action() { fn test_hover_enum_has_impl_action() {
check_actions( check_actions(
r"enum foo<|>() { A, B }", r"enum foo$0() { A, B }",
expect![[r#" expect![[r#"
[ [
Implementation( Implementation(
@ -2163,7 +2163,7 @@ fn foo() { let bar = Bar; bar.fo<|>o(); }
#[test] #[test]
fn test_hover_self_has_impl_action() { fn test_hover_self_has_impl_action() {
check_actions( check_actions(
r#"struct foo where Self<|>:;"#, r#"struct foo where Self$0:;"#,
expect![[r#" expect![[r#"
[ [
Implementation( Implementation(
@ -2184,7 +2184,7 @@ fn foo() { let bar = Bar; bar.fo<|>o(); }
check_actions( check_actions(
r#" r#"
#[test] #[test]
fn foo_<|>test() {} fn foo_$0test() {}
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -2219,7 +2219,7 @@ fn foo_<|>test() {}
fn test_hover_test_mod_has_action() { fn test_hover_test_mod_has_action() {
check_actions( check_actions(
r#" r#"
mod tests<|> { mod tests$0 {
#[test] #[test]
fn foo_test() {} fn foo_test() {}
} }
@ -2254,7 +2254,7 @@ mod tests<|> {
r#" r#"
struct S{ f1: u32 } struct S{ f1: u32 }
fn main() { let s<|>t = S{ f1:0 }; } fn main() { let s$0t = S{ f1:0 }; }
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -2287,7 +2287,7 @@ fn main() { let s<|>t = S{ f1:0 }; }
struct Arg(u32); struct Arg(u32);
struct S<T>{ f1: T } struct S<T>{ f1: T }
fn main() { let s<|>t = S{ f1:Arg(0) }; } fn main() { let s$0t = S{ f1:Arg(0) }; }
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -2333,7 +2333,7 @@ fn main() { let s<|>t = S{ f1:Arg(0) }; }
struct Arg(u32); struct Arg(u32);
struct S<T>{ f1: T } struct S<T>{ f1: T }
fn main() { let s<|>t = S{ f1: S{ f1: Arg(0) } }; } fn main() { let s$0t = S{ f1: S{ f1: Arg(0) } }; }
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -2382,7 +2382,7 @@ mod M {
pub struct C(u32); pub struct C(u32);
} }
fn main() { let s<|>t = (A(1), B(2), M::C(3) ); } fn main() { let s$0t = (A(1), B(2), M::C(3) ); }
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -2441,7 +2441,7 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); }
trait Foo {} trait Foo {}
fn foo() -> impl Foo {} fn foo() -> impl Foo {}
fn main() { let s<|>t = foo(); } fn main() { let s$0t = foo(); }
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -2475,7 +2475,7 @@ trait Foo<T> {}
struct S; struct S;
fn foo() -> impl Foo<S> {} fn foo() -> impl Foo<S> {}
fn main() { let s<|>t = foo(); } fn main() { let s$0t = foo(); }
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -2522,7 +2522,7 @@ trait Foo {}
trait Bar {} trait Bar {}
fn foo() -> impl Foo + Bar {} fn foo() -> impl Foo + Bar {}
fn main() { let s<|>t = foo(); } fn main() { let s$0t = foo(); }
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -2572,7 +2572,7 @@ struct S2 {}
fn foo() -> impl Foo<S1> + Bar<S2> {} fn foo() -> impl Foo<S1> + Bar<S2> {}
fn main() { let s<|>t = foo(); } fn main() { let s$0t = foo(); }
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -2642,7 +2642,7 @@ fn main() { let s<|>t = foo(); }
check_actions( check_actions(
r#" r#"
trait Foo {} trait Foo {}
fn foo(ar<|>g: &impl Foo) {} fn foo(ar$0g: &impl Foo) {}
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -2676,7 +2676,7 @@ trait Foo {}
trait Bar<T> {} trait Bar<T> {}
struct S{} struct S{}
fn foo(ar<|>g: &impl Foo + Bar<S>) {} fn foo(ar$0g: &impl Foo + Bar<S>) {}
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -2734,7 +2734,7 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
r#" r#"
struct S; struct S;
fn foo() { fn foo() {
let fo<|>o = async { S }; let fo$0o = async { S };
} }
#[prelude_import] use future::*; #[prelude_import] use future::*;
@ -2786,7 +2786,7 @@ mod future {
r#" r#"
trait Foo<T> {} trait Foo<T> {}
struct S {} struct S {}
fn foo(ar<|>g: &impl Foo<S>) {} fn foo(ar$0g: &impl Foo<S>) {}
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -2836,7 +2836,7 @@ impl Foo for S {}
struct B<T>{} struct B<T>{}
fn foo() -> B<dyn Foo> {} fn foo() -> B<dyn Foo> {}
fn main() { let s<|>t = foo(); } fn main() { let s$0t = foo(); }
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -2880,7 +2880,7 @@ fn main() { let s<|>t = foo(); }
check_actions( check_actions(
r#" r#"
trait Foo {} trait Foo {}
fn foo(ar<|>g: &dyn Foo) {} fn foo(ar$0g: &dyn Foo) {}
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -2912,7 +2912,7 @@ fn foo(ar<|>g: &dyn Foo) {}
r#" r#"
trait Foo<T> {} trait Foo<T> {}
struct S {} struct S {}
fn foo(ar<|>g: &dyn Foo<S>) {} fn foo(ar$0g: &dyn Foo<S>) {}
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -2960,7 +2960,7 @@ trait DynTrait<T> {}
struct B<T> {} struct B<T> {}
struct S {} struct S {}
fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {} fn foo(a$0rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -3041,7 +3041,7 @@ impl Foo for S { type Item = Bar; }
fn test() -> impl Foo { S {} } fn test() -> impl Foo { S {} }
fn main() { let s<|>t = test().get(); } fn main() { let s$0t = test().get(); }
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -3074,7 +3074,7 @@ fn main() { let s<|>t = test().get(); }
struct Bar; struct Bar;
struct Foo<const BAR: Bar>; struct Foo<const BAR: Bar>;
impl<const BAR: Bar> Foo<BAR<|>> {} impl<const BAR: Bar> Foo<BAR$0> {}
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -3106,7 +3106,7 @@ impl<const BAR: Bar> Foo<BAR<|>> {}
r#" r#"
trait Foo {} trait Foo {}
fn foo<T: Foo>(t: T<|>){} fn foo<T: Foo>(t: T$0){}
"#, "#,
expect![[r#" expect![[r#"
[ [
@ -3146,7 +3146,7 @@ pub mod wrapper {
} }
//- /main.rs crate:main deps:name-with-dashes //- /main.rs crate:main deps:name-with-dashes
fn main() { let foo_test = name_with_dashes::wrapper::Thing::new<|>(); } fn main() { let foo_test = name_with_dashes::wrapper::Thing::new$0(); }
"#, "#,
expect![[r#" expect![[r#"
*new* *new*
@ -3172,7 +3172,7 @@ struct S {
fn main() { fn main() {
let s = S { f: 0 }; let s = S { f: 0 };
let S { f<|> } = &s; let S { f$0 } = &s;
} }
"#, "#,
expect![[r#" expect![[r#"
@ -3191,7 +3191,7 @@ fn main() {
r#" r#"
struct Foo {} struct Foo {}
impl Foo { impl Foo {
fn bar(&sel<|>f) {} fn bar(&sel$0f) {}
} }
"#, "#,
expect![[r#" expect![[r#"
@ -3210,7 +3210,7 @@ impl Foo {
struct Arc<T>(T); struct Arc<T>(T);
struct Foo {} struct Foo {}
impl Foo { impl Foo {
fn bar(sel<|>f: Arc<Foo>) {} fn bar(sel$0f: Arc<Foo>) {}
} }
"#, "#,
expect![[r#" expect![[r#"
@ -3227,7 +3227,7 @@ impl Foo {
check( check(
r#" r#"
/// Be quick; /// Be quick;
mod Foo<|> { mod Foo$0 {
//! time is mana //! time is mana
/// This comment belongs to the function /// This comment belongs to the function
@ -3258,7 +3258,7 @@ mod Foo<|> {
check( check(
r#" r#"
#[doc = "Be quick;"] #[doc = "Be quick;"]
mod Foo<|> { mod Foo$0 {
#![doc = "time is mana"] #![doc = "time is mana"]
#[doc = "This comment belongs to the function"] #[doc = "This comment belongs to the function"]
@ -3289,7 +3289,7 @@ mod Foo<|> {
check_hover_no_result( check_hover_no_result(
r#" r#"
fn no_hover() { fn no_hover() {
// no<|>hover // no$0hover
} }
"#, "#,
); );
@ -3300,7 +3300,7 @@ fn no_hover() {
check( check(
r#" r#"
fn foo() { fn foo() {
'label<|>: loop {} 'label$0: loop {}
} }
"#, "#,
expect![[r#" expect![[r#"
@ -3316,7 +3316,7 @@ fn foo() {
#[test] #[test]
fn hover_lifetime() { fn hover_lifetime() {
check( check(
r#"fn foo<'lifetime>(_: &'lifetime<|> ()) {}"#, r#"fn foo<'lifetime>(_: &'lifetime$0 ()) {}"#,
expect![[r#" expect![[r#"
*'lifetime* *'lifetime*
@ -3335,7 +3335,7 @@ struct Foo<T>(T);
trait Copy {} trait Copy {}
trait Clone {} trait Clone {}
trait Sized {} trait Sized {}
impl<T: Copy + Clone> Foo<T<|>> where T: Sized {} impl<T: Copy + Clone> Foo<T$0> where T: Sized {}
"#, "#,
expect![[r#" expect![[r#"
*T* *T*
@ -3348,7 +3348,7 @@ impl<T: Copy + Clone> Foo<T<|>> where T: Sized {}
check( check(
r#" r#"
struct Foo<T>(T); struct Foo<T>(T);
impl<T> Foo<T<|>> {} impl<T> Foo<T$0> {}
"#, "#,
expect![[r#" expect![[r#"
*T* *T*
@ -3362,7 +3362,7 @@ impl<T> Foo<T<|>> {}
check( check(
r#" r#"
struct Foo<T>(T); struct Foo<T>(T);
impl<T: 'static> Foo<T<|>> {} impl<T: 'static> Foo<T$0> {}
"#, "#,
expect![[r#" expect![[r#"
*T* *T*
@ -3379,7 +3379,7 @@ impl<T: 'static> Foo<T<|>> {}
check( check(
r#" r#"
struct Foo<const LEN: usize>; struct Foo<const LEN: usize>;
impl<const LEN: usize> Foo<LEN<|>> {} impl<const LEN: usize> Foo<LEN$0> {}
"#, "#,
expect![[r#" expect![[r#"
*LEN* *LEN*

View file

@ -104,7 +104,7 @@ fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextS
// Special case that turns something like: // Special case that turns something like:
// //
// ``` // ```
// my_function({<|> // my_function({$0
// <some-expr> // <some-expr>
// }) // })
// ``` // ```
@ -116,7 +116,7 @@ fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextS
// ditto for // ditto for
// //
// ``` // ```
// use foo::{<|> // use foo::{$0
// bar // bar
// }; // };
// ``` // ```
@ -222,13 +222,13 @@ mod tests {
check_join_lines( check_join_lines(
r" r"
fn foo() { fn foo() {
<|>foo(1, $0foo(1,
) )
} }
", ",
r" r"
fn foo() { fn foo() {
<|>foo(1) $0foo(1)
} }
", ",
); );
@ -239,14 +239,14 @@ fn foo() {
check_join_lines( check_join_lines(
r" r"
pub fn reparse(&self, edit: &AtomTextEdit) -> File { pub fn reparse(&self, edit: &AtomTextEdit) -> File {
<|>self.incremental_reparse(edit).unwrap_or_else(|| { $0self.incremental_reparse(edit).unwrap_or_else(|| {
self.full_reparse(edit) self.full_reparse(edit)
}) })
} }
", ",
r" r"
pub fn reparse(&self, edit: &AtomTextEdit) -> File { pub fn reparse(&self, edit: &AtomTextEdit) -> File {
<|>self.incremental_reparse(edit).unwrap_or_else(|| self.full_reparse(edit)) $0self.incremental_reparse(edit).unwrap_or_else(|| self.full_reparse(edit))
} }
", ",
); );
@ -257,13 +257,13 @@ pub fn reparse(&self, edit: &AtomTextEdit) -> File {
check_join_lines( check_join_lines(
r" r"
fn foo() { fn foo() {
foo(<|>{ foo($0{
92 92
}) })
}", }",
r" r"
fn foo() { fn foo() {
foo(<|>92) foo($092)
}", }",
); );
} }
@ -274,7 +274,7 @@ fn foo() {
fn foo() { fn foo() {
loop { loop {
match x { match x {
92 => <|>{ 92 => $0{
continue; continue;
} }
} }
@ -285,7 +285,7 @@ fn foo() {
fn foo() { fn foo() {
loop { loop {
match x { match x {
92 => <|>continue, 92 => $0continue,
} }
} }
} }
@ -299,7 +299,7 @@ fn foo() {
r" r"
fn foo(e: Result<U, V>) { fn foo(e: Result<U, V>) {
match e { match e {
Ok(u) => <|>{ Ok(u) => $0{
u.foo() u.foo()
} }
Err(v) => v, Err(v) => v,
@ -308,7 +308,7 @@ fn foo(e: Result<U, V>) {
r" r"
fn foo(e: Result<U, V>) { fn foo(e: Result<U, V>) {
match e { match e {
Ok(u) => <|>u.foo(), Ok(u) => $0u.foo(),
Err(v) => v, Err(v) => v,
} }
}", }",
@ -321,7 +321,7 @@ fn foo(e: Result<U, V>) {
r" r"
fn foo() { fn foo() {
match ty { match ty {
<|> Some(ty) => { $0 Some(ty) => {
match ty { match ty {
_ => false, _ => false,
} }
@ -333,7 +333,7 @@ fn foo() {
r" r"
fn foo() { fn foo() {
match ty { match ty {
<|> Some(ty) => match ty { $0 Some(ty) => match ty {
_ => false, _ => false,
}, },
_ => true, _ => true,
@ -350,7 +350,7 @@ fn foo() {
r" r"
fn foo(e: Result<U, V>) { fn foo(e: Result<U, V>) {
match e { match e {
Ok(u) => <|>{ Ok(u) => $0{
u.foo() u.foo()
}, },
Err(v) => v, Err(v) => v,
@ -359,7 +359,7 @@ fn foo(e: Result<U, V>) {
r" r"
fn foo(e: Result<U, V>) { fn foo(e: Result<U, V>) {
match e { match e {
Ok(u) => <|>u.foo(), Ok(u) => $0u.foo(),
Err(v) => v, Err(v) => v,
} }
}", }",
@ -370,7 +370,7 @@ fn foo(e: Result<U, V>) {
r" r"
fn foo(e: Result<U, V>) { fn foo(e: Result<U, V>) {
match e { match e {
Ok(u) => <|>{ Ok(u) => $0{
u.foo() u.foo()
} , } ,
Err(v) => v, Err(v) => v,
@ -379,7 +379,7 @@ fn foo(e: Result<U, V>) {
r" r"
fn foo(e: Result<U, V>) { fn foo(e: Result<U, V>) {
match e { match e {
Ok(u) => <|>u.foo() , Ok(u) => $0u.foo() ,
Err(v) => v, Err(v) => v,
} }
}", }",
@ -390,7 +390,7 @@ fn foo(e: Result<U, V>) {
r" r"
fn foo(e: Result<U, V>) { fn foo(e: Result<U, V>) {
match e { match e {
Ok(u) => <|>{ Ok(u) => $0{
u.foo() u.foo()
} }
, ,
@ -400,7 +400,7 @@ fn foo(e: Result<U, V>) {
r" r"
fn foo(e: Result<U, V>) { fn foo(e: Result<U, V>) {
match e { match e {
Ok(u) => <|>u.foo() Ok(u) => $0u.foo()
, ,
Err(v) => v, Err(v) => v,
} }
@ -414,13 +414,13 @@ fn foo(e: Result<U, V>) {
check_join_lines( check_join_lines(
r" r"
fn foo() { fn foo() {
let x = (<|>{ let x = ($0{
4 4
},); },);
}", }",
r" r"
fn foo() { fn foo() {
let x = (<|>4,); let x = ($04,);
}", }",
); );
@ -428,13 +428,13 @@ fn foo() {
check_join_lines( check_join_lines(
r" r"
fn foo() { fn foo() {
let x = (<|>{ let x = ($0{
4 4
} ,); } ,);
}", }",
r" r"
fn foo() { fn foo() {
let x = (<|>4 ,); let x = ($04 ,);
}", }",
); );
@ -442,14 +442,14 @@ fn foo() {
check_join_lines( check_join_lines(
r" r"
fn foo() { fn foo() {
let x = (<|>{ let x = ($0{
4 4
} }
,); ,);
}", }",
r" r"
fn foo() { fn foo() {
let x = (<|>4 let x = ($04
,); ,);
}", }",
); );
@ -460,11 +460,11 @@ fn foo() {
// No space after the '{' // No space after the '{'
check_join_lines( check_join_lines(
r" r"
<|>use syntax::{ $0use syntax::{
TextSize, TextRange, TextSize, TextRange,
};", };",
r" r"
<|>use syntax::{TextSize, TextRange, $0use syntax::{TextSize, TextRange,
};", };",
); );
} }
@ -475,11 +475,11 @@ fn foo() {
check_join_lines( check_join_lines(
r" r"
use syntax::{ use syntax::{
<|> TextSize, TextRange $0 TextSize, TextRange
};", };",
r" r"
use syntax::{ use syntax::{
<|> TextSize, TextRange};", $0 TextSize, TextRange};",
); );
} }
@ -489,11 +489,11 @@ use syntax::{
check_join_lines( check_join_lines(
r" r"
use syntax::{ use syntax::{
<|> TextSize, TextRange, $0 TextSize, TextRange,
};", };",
r" r"
use syntax::{ use syntax::{
<|> TextSize, TextRange};", $0 TextSize, TextRange};",
); );
} }
@ -502,14 +502,14 @@ use syntax::{
check_join_lines( check_join_lines(
r" r"
use syntax::{ use syntax::{
algo::<|>{ algo::$0{
find_token_at_offset, find_token_at_offset,
}, },
ast, ast,
};", };",
r" r"
use syntax::{ use syntax::{
algo::<|>find_token_at_offset, algo::$0find_token_at_offset,
ast, ast,
};", };",
); );
@ -520,13 +520,13 @@ use syntax::{
check_join_lines( check_join_lines(
r" r"
fn foo() { fn foo() {
// Hello<|> // Hello$0
// world! // world!
} }
", ",
r" r"
fn foo() { fn foo() {
// Hello<|> world! // Hello$0 world!
} }
", ",
); );
@ -537,13 +537,13 @@ fn foo() {
check_join_lines( check_join_lines(
r" r"
fn foo() { fn foo() {
/// Hello<|> /// Hello$0
/// world! /// world!
} }
", ",
r" r"
fn foo() { fn foo() {
/// Hello<|> world! /// Hello$0 world!
} }
", ",
); );
@ -554,13 +554,13 @@ fn foo() {
check_join_lines( check_join_lines(
r" r"
fn foo() { fn foo() {
//! Hello<|> //! Hello$0
//! world! //! world!
} }
", ",
r" r"
fn foo() { fn foo() {
//! Hello<|> world! //! Hello$0 world!
} }
", ",
); );
@ -571,13 +571,13 @@ fn foo() {
check_join_lines( check_join_lines(
r" r"
fn foo() { fn foo() {
// Hello<|> // Hello$0
/* world! */ /* world! */
} }
", ",
r" r"
fn foo() { fn foo() {
// Hello<|> world! */ // Hello$0 world! */
} }
", ",
); );
@ -588,7 +588,7 @@ fn foo() {
check_join_lines( check_join_lines(
r" r"
fn foo() { fn foo() {
// The<|> // The$0
/* quick /* quick
brown brown
fox! */ fox! */
@ -596,7 +596,7 @@ fn foo() {
", ",
r" r"
fn foo() { fn foo() {
// The<|> quick // The$0 quick
brown brown
fox! */ fox! */
} }
@ -621,10 +621,10 @@ fn foo() {
check_join_lines_sel( check_join_lines_sel(
r" r"
fn foo() { fn foo() {
<|>foo(1, $0foo(1,
2, 2,
3, 3,
<|>) $0)
} }
", ",
r" r"
@ -639,9 +639,9 @@ fn foo() {
fn test_join_lines_selection_struct() { fn test_join_lines_selection_struct() {
check_join_lines_sel( check_join_lines_sel(
r" r"
struct Foo <|>{ struct Foo $0{
f: u32, f: u32,
}<|> }$0
", ",
r" r"
struct Foo { f: u32 } struct Foo { f: u32 }
@ -654,9 +654,9 @@ struct Foo { f: u32 }
check_join_lines_sel( check_join_lines_sel(
r" r"
fn foo() { fn foo() {
join(<|>type_params.type_params() join($0type_params.type_params()
.filter_map(|it| it.name()) .filter_map(|it| it.name())
.map(|it| it.text())<|>) .map(|it| it.text())$0)
}", }",
r" r"
fn foo() { fn foo() {
@ -671,9 +671,9 @@ fn foo() {
r" r"
pub fn handle_find_matching_brace() { pub fn handle_find_matching_brace() {
params.offsets params.offsets
.map(|offset| <|>{ .map(|offset| $0{
world.analysis().matching_brace(&file, offset).unwrap_or(offset) world.analysis().matching_brace(&file, offset).unwrap_or(offset)
}<|>) }$0)
.collect(); .collect();
}", }",
r" r"
@ -691,7 +691,7 @@ pub fn handle_find_matching_brace() {
r" r"
fn main() { fn main() {
let _ = { let _ = {
// <|>foo // $0foo
// bar // bar
92 92
}; };
@ -700,7 +700,7 @@ fn main() {
r" r"
fn main() { fn main() {
let _ = { let _ = {
// <|>foo bar // $0foo bar
92 92
}; };
} }
@ -712,12 +712,12 @@ fn main() {
fn join_lines_mandatory_blocks_block() { fn join_lines_mandatory_blocks_block() {
check_join_lines( check_join_lines(
r" r"
<|>fn foo() { $0fn foo() {
92 92
} }
", ",
r" r"
<|>fn foo() { 92 $0fn foo() { 92
} }
", ",
); );
@ -725,14 +725,14 @@ fn main() {
check_join_lines( check_join_lines(
r" r"
fn foo() { fn foo() {
<|>if true { $0if true {
92 92
} }
} }
", ",
r" r"
fn foo() { fn foo() {
<|>if true { 92 $0if true { 92
} }
} }
", ",
@ -741,14 +741,14 @@ fn foo() {
check_join_lines( check_join_lines(
r" r"
fn foo() { fn foo() {
<|>loop { $0loop {
92 92
} }
} }
", ",
r" r"
fn foo() { fn foo() {
<|>loop { 92 $0loop { 92
} }
} }
", ",
@ -757,14 +757,14 @@ fn foo() {
check_join_lines( check_join_lines(
r" r"
fn foo() { fn foo() {
<|>unsafe { $0unsafe {
92 92
} }
} }
", ",
r" r"
fn foo() { fn foo() {
<|>unsafe { 92 $0unsafe { 92
} }
} }
", ",

View file

@ -58,15 +58,15 @@ mod tests {
assert_eq_text!(after, &actual); assert_eq_text!(after, &actual);
} }
do_check("struct Foo { a: i32, }<|>", "struct Foo <|>{ a: i32, }"); do_check("struct Foo { a: i32, }$0", "struct Foo $0{ a: i32, }");
do_check("fn main() { |x: i32|<|> x * 2;}", "fn main() { <|>|x: i32| x * 2;}"); do_check("fn main() { |x: i32|$0 x * 2;}", "fn main() { $0|x: i32| x * 2;}");
do_check("fn main() { <|>|x: i32| x * 2;}", "fn main() { |x: i32<|>| x * 2;}"); do_check("fn main() { $0|x: i32| x * 2;}", "fn main() { |x: i32$0| x * 2;}");
{ {
mark::check!(pipes_not_braces); mark::check!(pipes_not_braces);
do_check( do_check(
"fn main() { match 92 { 1 | 2 |<|> 3 => 92 } }", "fn main() { match 92 { 1 | 2 |$0 3 => 92 } }",
"fn main() { match 92 { 1 | 2 |<|> 3 => 92 } }", "fn main() { match 92 { 1 | 2 |$0 3 => 92 } }",
); );
} }
} }

View file

@ -74,7 +74,7 @@ mod tests {
//- /lib.rs //- /lib.rs
mod foo; mod foo;
//- /foo.rs //- /foo.rs
<|>// empty $0// empty
", ",
); );
let nav = analysis.parent_module(pos).unwrap().pop().unwrap(); let nav = analysis.parent_module(pos).unwrap().pop().unwrap();
@ -90,7 +90,7 @@ mod tests {
mod foo; mod foo;
//- /foo.rs //- /foo.rs
mod <|>bar; mod $0bar;
//- /foo/bar.rs //- /foo/bar.rs
// empty // empty
@ -107,7 +107,7 @@ mod tests {
//- /lib.rs //- /lib.rs
mod foo { mod foo {
mod bar { mod bar {
mod baz { <|> } mod baz { $0 }
} }
} }
", ",
@ -123,7 +123,7 @@ mod tests {
//- /main.rs //- /main.rs
mod foo; mod foo;
//- /foo.rs //- /foo.rs
<|> $0
"#, "#,
); );
assert_eq!(analysis.crate_for(file_id).unwrap().len(), 1); assert_eq!(analysis.crate_for(file_id).unwrap().len(), 1);

View file

@ -331,7 +331,7 @@ mod tests {
fn test_struct_literal_after_space() { fn test_struct_literal_after_space() {
check( check(
r#" r#"
struct Foo <|>{ struct Foo $0{
a: i32, a: i32,
} }
impl Foo { impl Foo {
@ -354,7 +354,7 @@ fn main() {
fn test_struct_literal_before_space() { fn test_struct_literal_before_space() {
check( check(
r#" r#"
struct Foo<|> {} struct Foo$0 {}
fn main() { fn main() {
let f: Foo; let f: Foo;
f = Foo {}; f = Foo {};
@ -373,7 +373,7 @@ struct Foo<|> {}
fn test_struct_literal_with_generic_type() { fn test_struct_literal_with_generic_type() {
check( check(
r#" r#"
struct Foo<T> <|>{} struct Foo<T> $0{}
fn main() { fn main() {
let f: Foo::<i32>; let f: Foo::<i32>;
f = Foo {}; f = Foo {};
@ -391,7 +391,7 @@ struct Foo<T> <|>{}
fn test_struct_literal_for_tuple() { fn test_struct_literal_for_tuple() {
check( check(
r#" r#"
struct Foo<|>(i32); struct Foo$0(i32);
fn main() { fn main() {
let f: Foo; let f: Foo;
@ -410,7 +410,7 @@ fn main() {
fn test_enum_after_space() { fn test_enum_after_space() {
check( check(
r#" r#"
enum Foo <|>{ enum Foo $0{
A, A,
B, B,
} }
@ -431,7 +431,7 @@ fn main() {
fn test_enum_before_space() { fn test_enum_before_space() {
check( check(
r#" r#"
enum Foo<|> { enum Foo$0 {
A, A,
B, B,
} }
@ -453,7 +453,7 @@ fn main() {
fn test_enum_with_generic_type() { fn test_enum_with_generic_type() {
check( check(
r#" r#"
enum Foo<T> <|>{ enum Foo<T> $0{
A(T), A(T),
B, B,
} }
@ -474,7 +474,7 @@ fn main() {
fn test_enum_for_tuple() { fn test_enum_for_tuple() {
check( check(
r#" r#"
enum Foo<|>{ enum Foo$0{
A(i8), A(i8),
B(i8), B(i8),
} }
@ -498,7 +498,7 @@ fn main() {
fn main() { fn main() {
let mut i = 1; let mut i = 1;
let j = 1; let j = 1;
i = i<|> + j; i = i$0 + j;
{ {
i = 0; i = 0;
@ -522,7 +522,7 @@ fn main() {
check( check(
r#" r#"
fn foo() { fn foo() {
let spam<|> = 92; let spam$0 = 92;
spam + spam spam + spam
} }
fn bar() { fn bar() {
@ -543,7 +543,7 @@ fn bar() {
fn test_find_all_refs_for_param_inside() { fn test_find_all_refs_for_param_inside() {
check( check(
r#" r#"
fn foo(i : u32) -> u32 { i<|> } fn foo(i : u32) -> u32 { i$0 }
"#, "#,
expect![[r#" expect![[r#"
i ValueParam FileId(0) 7..8 Other i ValueParam FileId(0) 7..8 Other
@ -557,7 +557,7 @@ fn foo(i : u32) -> u32 { i<|> }
fn test_find_all_refs_for_fn_param() { fn test_find_all_refs_for_fn_param() {
check( check(
r#" r#"
fn foo(i<|> : u32) -> u32 { i } fn foo(i$0 : u32) -> u32 { i }
"#, "#,
expect![[r#" expect![[r#"
i ValueParam FileId(0) 7..8 Other i ValueParam FileId(0) 7..8 Other
@ -573,7 +573,7 @@ fn foo(i<|> : u32) -> u32 { i }
r#" r#"
//- /lib.rs //- /lib.rs
struct Foo { struct Foo {
pub spam<|>: u32, pub spam$0: u32,
} }
fn main(s: Foo) { fn main(s: Foo) {
@ -594,7 +594,7 @@ fn main(s: Foo) {
r#" r#"
struct Foo; struct Foo;
impl Foo { impl Foo {
fn f<|>(&self) { } fn f$0(&self) { }
} }
"#, "#,
expect![[r#" expect![[r#"
@ -610,7 +610,7 @@ impl Foo {
r#" r#"
enum Foo { enum Foo {
A, A,
B<|>, B$0,
C, C,
} }
"#, "#,
@ -627,7 +627,7 @@ enum Foo {
r#" r#"
enum Foo { enum Foo {
A, A,
B { field<|>: u8 }, B { field$0: u8 },
C, C,
} }
"#, "#,
@ -669,7 +669,7 @@ pub struct Bar {
} }
fn f() { fn f() {
let i = foo::Foo<|> { n: 5 }; let i = foo::Foo$0 { n: 5 };
} }
"#, "#,
expect![[r#" expect![[r#"
@ -689,7 +689,7 @@ fn f() {
check( check(
r#" r#"
//- /lib.rs //- /lib.rs
mod foo<|>; mod foo$0;
use foo::Foo; use foo::Foo;
@ -726,7 +726,7 @@ fn f() {
} }
//- /foo/some.rs //- /foo/some.rs
pub(super) struct Foo<|> { pub(super) struct Foo$0 {
pub n: u32, pub n: u32,
} }
"#, "#,
@ -746,7 +746,7 @@ pub(super) struct Foo<|> {
mod foo; mod foo;
mod bar; mod bar;
pub fn quux<|>() {} pub fn quux$0() {}
//- /foo.rs //- /foo.rs
fn f() { super::quux(); } fn f() { super::quux(); }
@ -782,7 +782,7 @@ pub(super) struct Foo<|> {
check( check(
r#" r#"
#[macro_export] #[macro_export]
macro_rules! m1<|> { () => (()) } macro_rules! m1$0 { () => (()) }
fn foo() { fn foo() {
m1(); m1();
@ -803,7 +803,7 @@ fn foo() {
check( check(
r#" r#"
fn foo() { fn foo() {
let mut i<|> = 0; let mut i$0 = 0;
i = i + 1; i = i + 1;
} }
"#, "#,
@ -826,7 +826,7 @@ struct S {
fn foo() { fn foo() {
let mut s = S{f: 0}; let mut s = S{f: 0};
s.f<|> = 0; s.f$0 = 0;
} }
"#, "#,
expect![[r#" expect![[r#"
@ -843,7 +843,7 @@ fn foo() {
check( check(
r#" r#"
fn foo() { fn foo() {
let i<|>; let i$0;
i = 1; i = 1;
} }
"#, "#,
@ -863,7 +863,7 @@ mod foo {
pub struct Foo; pub struct Foo;
impl Foo { impl Foo {
pub fn new<|>() -> Foo { Foo } pub fn new$0() -> Foo { Foo }
} }
} }
@ -886,7 +886,7 @@ fn main() {
//- /lib.rs //- /lib.rs
mod foo { mod bar; } mod foo { mod bar; }
fn f<|>() {} fn f$0() {}
//- /foo/bar.rs //- /foo/bar.rs
use crate::f; use crate::f;
@ -907,7 +907,7 @@ fn g() { f(); }
check( check(
r#" r#"
struct S { struct S {
field<|>: u8, field$0: u8,
} }
fn f(s: S) { fn f(s: S) {
@ -930,7 +930,7 @@ fn f(s: S) {
r#" r#"
enum En { enum En {
Variant { Variant {
field<|>: u8, field$0: u8,
} }
} }
@ -955,7 +955,7 @@ fn f(e: En) {
mod m { mod m {
pub enum En { pub enum En {
Variant { Variant {
field<|>: u8, field$0: u8,
} }
} }
} }
@ -980,7 +980,7 @@ struct Foo { bar: i32 }
impl Foo { impl Foo {
fn foo(self) { fn foo(self) {
let x = self<|>.bar; let x = self$0.bar;
if true { if true {
let _ = match () { let _ = match () {
() => self, () => self,
@ -1032,7 +1032,7 @@ impl Foo {
r#" r#"
trait Foo<'a> {} trait Foo<'a> {}
impl<'a> Foo<'a> for &'a () {} impl<'a> Foo<'a> for &'a () {}
fn foo<'a, 'b: 'a>(x: &'a<|> ()) -> &'a () where &'a (): Foo<'a> { fn foo<'a, 'b: 'a>(x: &'a$0 ()) -> &'a () where &'a (): Foo<'a> {
fn bar<'a>(_: &'a ()) {} fn bar<'a>(_: &'a ()) {}
x x
} }
@ -1053,7 +1053,7 @@ fn foo<'a, 'b: 'a>(x: &'a<|> ()) -> &'a () where &'a (): Foo<'a> {
fn test_find_lifetimes_type_alias() { fn test_find_lifetimes_type_alias() {
check( check(
r#" r#"
type Foo<'a, T> where T: 'a<|> = &'a T; type Foo<'a, T> where T: 'a$0 = &'a T;
"#, "#,
expect![[r#" expect![[r#"
'a LifetimeParam FileId(0) 9..11 9..11 Lifetime 'a LifetimeParam FileId(0) 9..11 9..11 Lifetime
@ -1072,7 +1072,7 @@ trait Foo<'a> {
fn foo() -> &'a (); fn foo() -> &'a ();
} }
impl<'a> Foo<'a> for &'a () { impl<'a> Foo<'a> for &'a () {
fn foo() -> &'a<|> () { fn foo() -> &'a$0 () {
unimplemented!() unimplemented!()
} }
} }
@ -1093,7 +1093,7 @@ impl<'a> Foo<'a> for &'a () {
r#" r#"
macro_rules! foo {($i:ident) => {$i} } macro_rules! foo {($i:ident) => {$i} }
fn main() { fn main() {
let a<|> = "test"; let a$0 = "test";
foo!(a); foo!(a);
} }
"#, "#,
@ -1112,7 +1112,7 @@ fn main() {
macro_rules! foo {($i:ident) => {$i} } macro_rules! foo {($i:ident) => {$i} }
fn main() { fn main() {
let a = "test"; let a = "test";
foo!(a<|>); foo!(a$0);
} }
"#, "#,
expect![[r#" expect![[r#"
@ -1130,7 +1130,7 @@ fn main() {
fn foo<'a>() -> &'a () { fn foo<'a>() -> &'a () {
'a: loop { 'a: loop {
'b: loop { 'b: loop {
continue 'a<|>; continue 'a$0;
} }
break 'a; break 'a;
} }
@ -1149,7 +1149,7 @@ fn foo<'a>() -> &'a () {
fn test_find_const_param() { fn test_find_const_param() {
check( check(
r#" r#"
fn foo<const FOO<|>: usize>() -> usize { fn foo<const FOO$0: usize>() -> usize {
FOO FOO
} }
"#, "#,

View file

@ -493,19 +493,19 @@ mod tests {
#[test] #[test]
fn test_rename_to_underscore() { fn test_rename_to_underscore() {
check("_", r#"fn main() { let i<|> = 1; }"#, r#"fn main() { let _ = 1; }"#); check("_", r#"fn main() { let i$0 = 1; }"#, r#"fn main() { let _ = 1; }"#);
} }
#[test] #[test]
fn test_rename_to_raw_identifier() { fn test_rename_to_raw_identifier() {
check("r#fn", r#"fn main() { let i<|> = 1; }"#, r#"fn main() { let r#fn = 1; }"#); check("r#fn", r#"fn main() { let i$0 = 1; }"#, r#"fn main() { let r#fn = 1; }"#);
} }
#[test] #[test]
fn test_rename_to_invalid_identifier1() { fn test_rename_to_invalid_identifier1() {
check( check(
"invalid!", "invalid!",
r#"fn main() { let i<|> = 1; }"#, r#"fn main() { let i$0 = 1; }"#,
"error: Invalid name `invalid!`: not an identifier", "error: Invalid name `invalid!`: not an identifier",
); );
} }
@ -514,7 +514,7 @@ mod tests {
fn test_rename_to_invalid_identifier2() { fn test_rename_to_invalid_identifier2() {
check( check(
"multiple tokens", "multiple tokens",
r#"fn main() { let i<|> = 1; }"#, r#"fn main() { let i$0 = 1; }"#,
"error: Invalid name `multiple tokens`: not an identifier", "error: Invalid name `multiple tokens`: not an identifier",
); );
} }
@ -523,7 +523,7 @@ mod tests {
fn test_rename_to_invalid_identifier3() { fn test_rename_to_invalid_identifier3() {
check( check(
"let", "let",
r#"fn main() { let i<|> = 1; }"#, r#"fn main() { let i$0 = 1; }"#,
"error: Invalid name `let`: not an identifier", "error: Invalid name `let`: not an identifier",
); );
} }
@ -532,7 +532,7 @@ mod tests {
fn test_rename_to_invalid_identifier_lifetime() { fn test_rename_to_invalid_identifier_lifetime() {
check( check(
"'foo", "'foo",
r#"fn main() { let i<|> = 1; }"#, r#"fn main() { let i$0 = 1; }"#,
"error: Invalid name `'foo`: not an identifier", "error: Invalid name `'foo`: not an identifier",
); );
} }
@ -541,7 +541,7 @@ mod tests {
fn test_rename_to_invalid_identifier_lifetime2() { fn test_rename_to_invalid_identifier_lifetime2() {
check( check(
"foo", "foo",
r#"fn main<'a>(_: &'a<|> ()) {}"#, r#"fn main<'a>(_: &'a$0 ()) {}"#,
"error: Invalid name `foo`: not a lifetime identifier", "error: Invalid name `foo`: not a lifetime identifier",
); );
} }
@ -554,7 +554,7 @@ mod tests {
fn main() { fn main() {
let mut i = 1; let mut i = 1;
let j = 1; let j = 1;
i = i<|> + j; i = i$0 + j;
{ i = 0; } { i = 0; }
@ -579,7 +579,7 @@ fn main() {
fn test_rename_unresolved_reference() { fn test_rename_unresolved_reference() {
check( check(
"new_name", "new_name",
r#"fn main() { let _ = unresolved_ref<|>; }"#, r#"fn main() { let _ = unresolved_ref$0; }"#,
"error: No references found at position", "error: No references found at position",
); );
} }
@ -591,7 +591,7 @@ fn main() {
r#" r#"
macro_rules! foo {($i:ident) => {$i} } macro_rules! foo {($i:ident) => {$i} }
fn main() { fn main() {
let a<|> = "test"; let a$0 = "test";
foo!(a); foo!(a);
} }
"#, "#,
@ -613,7 +613,7 @@ fn main() {
macro_rules! foo {($i:ident) => {$i} } macro_rules! foo {($i:ident) => {$i} }
fn main() { fn main() {
let a = "test"; let a = "test";
foo!(a<|>); foo!(a$0);
} }
"#, "#,
r#" r#"
@ -634,7 +634,7 @@ fn main() {
macro_rules! define_fn {($id:ident) => { fn $id{} }} macro_rules! define_fn {($id:ident) => { fn $id{} }}
define_fn!(foo); define_fn!(foo);
fn main() { fn main() {
fo<|>o(); fo$0o();
} }
"#, "#,
r#" r#"
@ -653,7 +653,7 @@ fn main() {
"bar", "bar",
r#" r#"
macro_rules! define_fn {($id:ident) => { fn $id{} }} macro_rules! define_fn {($id:ident) => { fn $id{} }}
define_fn!(fo<|>o); define_fn!(fo$0o);
fn main() { fn main() {
foo(); foo();
} }
@ -670,17 +670,17 @@ fn main() {
#[test] #[test]
fn test_rename_for_param_inside() { fn test_rename_for_param_inside() {
check("j", r#"fn foo(i : u32) -> u32 { i<|> }"#, r#"fn foo(j : u32) -> u32 { j }"#); check("j", r#"fn foo(i : u32) -> u32 { i$0 }"#, r#"fn foo(j : u32) -> u32 { j }"#);
} }
#[test] #[test]
fn test_rename_refs_for_fn_param() { fn test_rename_refs_for_fn_param() {
check("j", r#"fn foo(i<|> : u32) -> u32 { i }"#, r#"fn foo(j : u32) -> u32 { j }"#); check("j", r#"fn foo(i$0 : u32) -> u32 { i }"#, r#"fn foo(j : u32) -> u32 { j }"#);
} }
#[test] #[test]
fn test_rename_for_mut_param() { fn test_rename_for_mut_param() {
check("j", r#"fn foo(mut i<|> : u32) -> u32 { i }"#, r#"fn foo(mut j : u32) -> u32 { j }"#); check("j", r#"fn foo(mut i$0 : u32) -> u32 { i }"#, r#"fn foo(mut j : u32) -> u32 { j }"#);
} }
#[test] #[test]
@ -688,7 +688,7 @@ fn main() {
check( check(
"j", "j",
r#" r#"
struct Foo { i<|>: i32 } struct Foo { i$0: i32 }
impl Foo { impl Foo {
fn new(i: i32) -> Self { fn new(i: i32) -> Self {
@ -714,7 +714,7 @@ impl Foo {
check( check(
"j", "j",
r#" r#"
struct Foo { i<|>: i32 } struct Foo { i$0: i32 }
impl Foo { impl Foo {
fn new(i: i32) -> Self { fn new(i: i32) -> Self {
@ -743,7 +743,7 @@ impl Foo {
struct Foo { i: i32 } struct Foo { i: i32 }
impl Foo { impl Foo {
fn new(i<|>: i32) -> Self { fn new(i$0: i32) -> Self {
Self { i } Self { i }
} }
} }
@ -765,7 +765,7 @@ impl Foo {
check( check(
"j", "j",
r#" r#"
struct Foo { i<|>: i32 } struct Foo { i$0: i32 }
struct Bar { i: i32 } struct Bar { i: i32 }
impl Bar { impl Bar {
@ -794,7 +794,7 @@ impl Bar {
r#" r#"
struct Foo { i: i32 } struct Foo { i: i32 }
fn baz(i<|>: i32) -> Self { fn baz(i$0: i32) -> Self {
let x = Foo { i }; let x = Foo { i };
{ {
let i = 0; let i = 0;
@ -825,7 +825,7 @@ fn baz(j: i32) -> Self {
mod bar; mod bar;
//- /bar.rs //- /bar.rs
mod foo<|>; mod foo$0;
//- /bar/foo.rs //- /bar/foo.rs
// empty // empty
@ -883,7 +883,7 @@ fn main() {}
pub struct FooContent; pub struct FooContent;
//- /bar.rs //- /bar.rs
use crate::foo<|>::FooContent; use crate::foo$0::FooContent;
"#, "#,
expect![[r#" expect![[r#"
RangeInfo { RangeInfo {
@ -943,7 +943,7 @@ use crate::foo<|>::FooContent;
"foo2", "foo2",
r#" r#"
//- /lib.rs //- /lib.rs
mod fo<|>o; mod fo$0o;
//- /foo/mod.rs //- /foo/mod.rs
// emtpy // emtpy
"#, "#,
@ -992,7 +992,7 @@ mod fo<|>o;
"bar", "bar",
r#" r#"
//- /lib.rs //- /lib.rs
mod outer { mod fo<|>o; } mod outer { mod fo$0o; }
//- /outer/foo.rs //- /outer/foo.rs
// emtpy // emtpy
@ -1041,7 +1041,7 @@ mod outer { mod fo<|>o; }
check( check(
"baz", "baz",
r#" r#"
mod <|>foo { pub fn bar() {} } mod $0foo { pub fn bar() {} }
fn main() { foo::bar(); } fn main() { foo::bar(); }
"#, "#,
@ -1065,7 +1065,7 @@ fn f() {
} }
//- /bar.rs //- /bar.rs
pub mod foo<|>; pub mod foo$0;
//- /bar/foo.rs //- /bar/foo.rs
// pub fn fun() {} // pub fn fun() {}
@ -1128,7 +1128,7 @@ pub mod foo<|>;
"Baz", "Baz",
r#" r#"
mod foo { mod foo {
pub enum Foo { Bar<|> } pub enum Foo { Bar$0 }
} }
fn func(f: foo::Foo) { fn func(f: foo::Foo) {
@ -1157,7 +1157,7 @@ fn func(f: foo::Foo) {
"baz", "baz",
r#" r#"
mod foo { mod foo {
pub struct Foo { pub bar<|>: uint } pub struct Foo { pub bar$0: uint }
} }
fn foo(f: foo::Foo) { fn foo(f: foo::Foo) {
@ -1184,7 +1184,7 @@ fn foo(f: foo::Foo) {
struct Foo { i: i32 } struct Foo { i: i32 }
impl Foo { impl Foo {
fn f(foo<|>: &mut Foo) -> i32 { fn f(foo$0: &mut Foo) -> i32 {
foo.i foo.i
} }
} }
@ -1205,7 +1205,7 @@ impl Foo {
struct Foo { i: i32 } struct Foo { i: i32 }
impl Foo { impl Foo {
fn f(foo<|>: Foo) -> i32 { fn f(foo$0: Foo) -> i32 {
foo.i foo.i
} }
} }
@ -1229,7 +1229,7 @@ impl Foo {
r#" r#"
struct Foo { i: i32 } struct Foo { i: i32 }
fn f(foo<|>: &mut Foo) -> i32 { fn f(foo$0: &mut Foo) -> i32 {
foo.i foo.i
} }
"#, "#,
@ -1242,7 +1242,7 @@ struct Foo { i: i32 }
struct Bar; struct Bar;
impl Bar { impl Bar {
fn f(foo<|>: &mut Foo) -> i32 { fn f(foo$0: &mut Foo) -> i32 {
foo.i foo.i
} }
} }
@ -1258,7 +1258,7 @@ impl Bar {
r#" r#"
struct Foo { i: i32 } struct Foo { i: i32 }
impl Foo { impl Foo {
fn f(x: (), foo<|>: &mut Foo) -> i32 { fn f(x: (), foo$0: &mut Foo) -> i32 {
foo.i foo.i
} }
} }
@ -1274,7 +1274,7 @@ impl Foo {
r#" r#"
struct Foo { i: i32 } struct Foo { i: i32 }
impl &Foo { impl &Foo {
fn f(foo<|>: &Foo) -> i32 { fn f(foo$0: &Foo) -> i32 {
foo.i foo.i
} }
} }
@ -1298,7 +1298,7 @@ impl &Foo {
struct Foo { i: i32 } struct Foo { i: i32 }
impl Foo { impl Foo {
fn f(&mut <|>self) -> i32 { fn f(&mut $0self) -> i32 {
self.i self.i
} }
} }
@ -1323,7 +1323,7 @@ impl Foo {
struct Foo { i: i32 } struct Foo { i: i32 }
impl Foo { impl Foo {
fn f(<|>self) -> i32 { fn f($0self) -> i32 {
self.i self.i
} }
} }
@ -1350,7 +1350,7 @@ struct Foo { i: i32 }
impl Foo { impl Foo {
fn f(&self) -> i32 { fn f(&self) -> i32 {
let self_var = 1; let self_var = 1;
self<|>.i self$0.i
} }
} }
"#, "#,
@ -1373,7 +1373,7 @@ impl Foo {
check( check(
"bar", "bar",
r#" r#"
struct Foo { i<|>: i32 } struct Foo { i$0: i32 }
fn foo(bar: i32) -> Foo { fn foo(bar: i32) -> Foo {
Foo { i: bar } Foo { i: bar }
@ -1394,7 +1394,7 @@ fn foo(bar: i32) -> Foo {
check( check(
"baz", "baz",
r#" r#"
struct Foo { i<|>: i32 } struct Foo { i$0: i32 }
fn foo(foo: Foo) { fn foo(foo: Foo) {
let Foo { i: baz } = foo; let Foo { i: baz } = foo;
@ -1433,7 +1433,7 @@ struct Foo {
fn foo(foo: Foo) { fn foo(foo: Foo) {
let Foo { i: b } = foo; let Foo { i: b } = foo;
let _ = b<|>; let _ = b$0;
} }
"#, "#,
expected_fixture, expected_fixture,
@ -1447,7 +1447,7 @@ struct Foo {
fn foo(foo: Foo) { fn foo(foo: Foo) {
let Foo { i } = foo; let Foo { i } = foo;
let _ = i<|>; let _ = i$0;
} }
"#, "#,
expected_fixture, expected_fixture,
@ -1464,7 +1464,7 @@ struct Foo {
} }
fn foo(Foo { i }: foo) -> i32 { fn foo(Foo { i }: foo) -> i32 {
i<|> i$0
} }
"#, "#,
r#" r#"
@ -1488,7 +1488,7 @@ trait Foo<'a> {
fn foo() -> &'a (); fn foo() -> &'a ();
} }
impl<'a> Foo<'a> for &'a () { impl<'a> Foo<'a> for &'a () {
fn foo() -> &'a<|> () { fn foo() -> &'a$0 () {
unimplemented!() unimplemented!()
} }
} }
@ -1520,7 +1520,7 @@ fn main() {
let test_variable = CustomOption::Some(22); let test_variable = CustomOption::Some(22);
match test_variable { match test_variable {
CustomOption::Some(foo<|>) if foo == 11 => {} CustomOption::Some(foo$0) if foo == 11 => {}
_ => (), _ => (),
} }
}"#, }"#,
@ -1549,7 +1549,7 @@ fn main() {
fn foo<'a>() -> &'a () { fn foo<'a>() -> &'a () {
'a: { 'a: {
'b: loop { 'b: loop {
break 'a<|>; break 'a$0;
} }
} }
} }

View file

@ -329,7 +329,7 @@ mod tests {
check( check(
r#" r#"
//- /lib.rs //- /lib.rs
<|> $0
fn main() {} fn main() {}
#[test] #[test]
@ -425,7 +425,7 @@ fn bench() {}
check( check(
r#" r#"
//- /lib.rs //- /lib.rs
<|> $0
fn main() {} fn main() {}
/// ``` /// ```
@ -573,7 +573,7 @@ struct StructWithRunnable(String);
check( check(
r#" r#"
//- /lib.rs //- /lib.rs
<|> $0
fn main() {} fn main() {}
struct Data; struct Data;
@ -625,7 +625,7 @@ impl Data {
check( check(
r#" r#"
//- /lib.rs //- /lib.rs
<|> $0
mod test_mod { mod test_mod {
#[test] #[test]
fn test_foo1() {} fn test_foo1() {}
@ -679,7 +679,7 @@ mod test_mod {
check( check(
r#" r#"
//- /lib.rs //- /lib.rs
<|> $0
mod root_tests { mod root_tests {
mod nested_tests_0 { mod nested_tests_0 {
mod nested_tests_1 { mod nested_tests_1 {
@ -819,7 +819,7 @@ mod root_tests {
check( check(
r#" r#"
//- /lib.rs crate:foo cfg:feature=foo //- /lib.rs crate:foo cfg:feature=foo
<|> $0
#[test] #[test]
#[cfg(feature = "foo")] #[cfg(feature = "foo")]
fn test_foo1() {} fn test_foo1() {}
@ -864,7 +864,7 @@ fn test_foo1() {}
check( check(
r#" r#"
//- /lib.rs crate:foo cfg:feature=foo,feature=bar //- /lib.rs crate:foo cfg:feature=foo,feature=bar
<|> $0
#[test] #[test]
#[cfg(all(feature = "foo", feature = "bar"))] #[cfg(all(feature = "foo", feature = "bar"))]
fn test_foo1() {} fn test_foo1() {}
@ -919,7 +919,7 @@ fn test_foo1() {}
check( check(
r#" r#"
//- /lib.rs //- /lib.rs
<|> $0
mod test_mod { mod test_mod {
fn foo1() {} fn foo1() {}
} }
@ -938,7 +938,7 @@ mod test_mod {
//- /lib.rs //- /lib.rs
mod foo; mod foo;
//- /foo.rs //- /foo.rs
struct Foo;<|> struct Foo;$0
impl Foo { impl Foo {
/// ``` /// ```
/// let x = 5; /// let x = 5;

View file

@ -85,7 +85,7 @@ fn syntax_tree_for_token(node: &SyntaxToken, text_range: TextRange) -> Option<St
.trim_end_matches('"') .trim_end_matches('"')
.trim() .trim()
// Remove custom markers // Remove custom markers
.replace("<|>", ""); .replace("$0", "");
let parsed = SourceFile::parse(&text); let parsed = SourceFile::parse(&text);
@ -182,7 +182,7 @@ SOURCE_FILE@0..60
#[test] #[test]
fn test_syntax_tree_with_range() { fn test_syntax_tree_with_range() {
let (analysis, range) = fixture::range(r#"<|>fn foo() {}<|>"#.trim()); let (analysis, range) = fixture::range(r#"$0fn foo() {}$0"#.trim());
let syn = analysis.syntax_tree(range.file_id, Some(range.range)).unwrap(); let syn = analysis.syntax_tree(range.file_id, Some(range.range)).unwrap();
assert_eq_text!( assert_eq_text!(
@ -206,10 +206,10 @@ FN@0..11
let (analysis, range) = fixture::range( let (analysis, range) = fixture::range(
r#"fn test() { r#"fn test() {
<|>assert!(" $0assert!("
fn foo() { fn foo() {
} }
", "");<|> ", "");$0
}"# }"#
.trim(), .trim(),
); );
@ -243,8 +243,8 @@ EXPR_STMT@16..58
let (analysis, range) = fixture::range( let (analysis, range) = fixture::range(
r#"fn test() { r#"fn test() {
assert!(" assert!("
<|>fn foo() { $0fn foo() {
}<|> }$0
fn bar() { fn bar() {
} }
", ""); ", "");
@ -277,8 +277,8 @@ SOURCE_FILE@0..12
let (analysis, range) = fixture::range( let (analysis, range) = fixture::range(
r###"fn test() { r###"fn test() {
assert!(r#" assert!(r#"
<|>fn foo() { $0fn foo() {
}<|> }$0
fn bar() { fn bar() {
} }
"#, ""); "#, "");
@ -310,11 +310,11 @@ SOURCE_FILE@0..12
// With a raw string // With a raw string
let (analysis, range) = fixture::range( let (analysis, range) = fixture::range(
r###"fn test() { r###"fn test() {
assert!(r<|>#" assert!(r$0#"
fn foo() { fn foo() {
} }
fn bar() { fn bar() {
}"<|>#, ""); }"$0#, "");
}"### }"###
.trim(), .trim(),
); );

View file

@ -170,7 +170,7 @@ mod tests {
fn test_on_eq_typed() { fn test_on_eq_typed() {
// do_check(r" // do_check(r"
// fn foo() { // fn foo() {
// let foo =<|> // let foo =$0
// } // }
// ", r" // ", r"
// fn foo() { // fn foo() {
@ -181,7 +181,7 @@ mod tests {
'=', '=',
r" r"
fn foo() { fn foo() {
let foo <|> 1 + 1 let foo $0 1 + 1
} }
", ",
r" r"
@ -192,7 +192,7 @@ fn foo() {
); );
// do_check(r" // do_check(r"
// fn foo() { // fn foo() {
// let foo =<|> // let foo =$0
// let bar = 1; // let bar = 1;
// } // }
// ", r" // ", r"
@ -210,7 +210,7 @@ fn foo() {
r" r"
fn main() { fn main() {
xs.foo() xs.foo()
<|> $0
} }
", ",
r" r"
@ -225,7 +225,7 @@ fn foo() {
r" r"
fn main() { fn main() {
xs.foo() xs.foo()
<|> $0
} }
", ",
) )
@ -238,7 +238,7 @@ fn foo() {
r" r"
fn main() { fn main() {
xs.foo() xs.foo()
<|>; $0;
} }
", ",
r" r"
@ -253,7 +253,7 @@ fn foo() {
r" r"
fn main() { fn main() {
xs.foo() xs.foo()
<|>; $0;
} }
", ",
) )
@ -266,7 +266,7 @@ fn foo() {
r#" r#"
fn main() { fn main() {
let _ = foo let _ = foo
<|> $0
bar() bar()
} }
"#, "#,
@ -288,7 +288,7 @@ fn main() {
fn main() { fn main() {
xs.foo() xs.foo()
.first() .first()
<|> $0
} }
", ",
r" r"
@ -305,7 +305,7 @@ fn main() {
fn main() { fn main() {
xs.foo() xs.foo()
.first() .first()
<|> $0
} }
", ",
); );
@ -318,7 +318,7 @@ fn main() {
r" r"
fn source_impl() { fn source_impl() {
let var = enum_defvariant_list().unwrap() let var = enum_defvariant_list().unwrap()
<|> $0
.nth(92) .nth(92)
.unwrap(); .unwrap();
} }
@ -337,7 +337,7 @@ fn main() {
r" r"
fn source_impl() { fn source_impl() {
let var = enum_defvariant_list().unwrap() let var = enum_defvariant_list().unwrap()
<|> $0
.nth(92) .nth(92)
.unwrap(); .unwrap();
} }
@ -351,7 +351,7 @@ fn main() {
'.', '.',
r" r"
fn main() { fn main() {
<|> $0
} }
", ",
); );
@ -359,7 +359,7 @@ fn main() {
'.', '.',
r" r"
fn main() { fn main() {
<|> $0
} }
", ",
); );
@ -367,6 +367,6 @@ fn main() {
#[test] #[test]
fn adds_space_after_return_type() { fn adds_space_after_return_type() {
type_char('>', "fn foo() -<|>{ 92 }", "fn foo() -> { 92 }") type_char('>', "fn foo() -$0{ 92 }", "fn foo() -> { 92 }")
} }
} }

View file

@ -136,7 +136,7 @@ mod tests {
fn continues_doc_comment() { fn continues_doc_comment() {
do_check( do_check(
r" r"
/// Some docs<|> /// Some docs$0
fn foo() { fn foo() {
} }
", ",
@ -151,7 +151,7 @@ fn foo() {
do_check( do_check(
r" r"
impl S { impl S {
/// Some<|> docs. /// Some$0 docs.
fn foo() {} fn foo() {}
} }
", ",
@ -166,7 +166,7 @@ impl S {
do_check( do_check(
r" r"
///<|> Some docs ///$0 Some docs
fn foo() { fn foo() {
} }
", ",
@ -181,7 +181,7 @@ fn foo() {
#[test] #[test]
fn does_not_continue_before_doc_comment() { fn does_not_continue_before_doc_comment() {
do_check_noop(r"<|>//! docz"); do_check_noop(r"$0//! docz");
} }
#[test] #[test]
@ -189,7 +189,7 @@ fn foo() {
do_check( do_check(
r" r"
fn main() { fn main() {
// Fix<|> me // Fix$0 me
let x = 1 + 1; let x = 1 + 1;
} }
", ",
@ -208,7 +208,7 @@ fn main() {
do_check( do_check(
r" r"
fn main() { fn main() {
// Fix<|> // Fix$0
// me // me
let x = 1 + 1; let x = 1 + 1;
} }
@ -229,7 +229,7 @@ fn main() {
do_check_noop( do_check_noop(
r" r"
fn main() { fn main() {
// Fix me<|> // Fix me$0
let x = 1 + 1; let x = 1 + 1;
} }
", ",
@ -242,7 +242,7 @@ fn main() {
do_check( do_check(
r#" r#"
fn main() { fn main() {
// Fix me <|> // Fix me $0
let x = 1 + 1; let x = 1 + 1;
} }
"#, "#,
@ -261,7 +261,7 @@ fn main() {
do_check( do_check(
" "
fn main() { fn main() {
// Fix me \t\t <|> // Fix me \t\t $0
let x = 1 + 1; let x = 1 + 1;
} }
", ",

Some files were not shown because too many files have changed in this diff Show more