mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 01:38:13 +00:00
Merge #4539
4539: Relax cursor position tests in assists r=matklad a=matklad
Those will be replaced with snippets anyway
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
ee9cec56c8
14 changed files with 96 additions and 117 deletions
|
@ -86,11 +86,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
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<|> = 1; }", "fn f() { let a: i32 = 1; }");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -98,7 +94,7 @@ mod tests {
|
|||
check_assist(
|
||||
add_explicit_type,
|
||||
"fn f() { let a<|>: _ = 1; }",
|
||||
"fn f() { let a<|>: i32 = 1; }",
|
||||
"fn f() { let a: i32 = 1; }",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -122,7 +118,7 @@ mod tests {
|
|||
}
|
||||
|
||||
fn f() {
|
||||
let a<|>: Option<i32> = Option::Some(1);
|
||||
let a: Option<i32> = Option::Some(1);
|
||||
}"#,
|
||||
);
|
||||
}
|
||||
|
@ -132,7 +128,7 @@ mod tests {
|
|||
check_assist(
|
||||
add_explicit_type,
|
||||
r"macro_rules! v { () => {0u64} } fn f() { let a<|> = v!(); }",
|
||||
r"macro_rules! v { () => {0u64} } fn f() { let a<|>: u64 = v!(); }",
|
||||
r"macro_rules! v { () => {0u64} } fn f() { let a: u64 = v!(); }",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -140,8 +136,8 @@ mod tests {
|
|||
fn add_explicit_type_works_for_macro_call_recursive() {
|
||||
check_assist(
|
||||
add_explicit_type,
|
||||
"macro_rules! u { () => {0u64} } macro_rules! v { () => {u!()} } fn f() { let a<|> = v!(); }",
|
||||
"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<|> = v!(); }"#,
|
||||
r#"macro_rules! u { () => {0u64} } macro_rules! v { () => {u!()} } fn f() { let a: u64 = v!(); }"#,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -208,7 +204,7 @@ struct Test<K, T = u8> {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let test<|>: Test<i32> = Test { t: 23, k: 33 };
|
||||
let test: Test<i32> = Test { t: 23, k: 33 };
|
||||
}"#,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ mod tests {
|
|||
check_assist(
|
||||
add_from_impl_for_enum,
|
||||
"enum A { <|>One(u32) }",
|
||||
r#"enum A { <|>One(u32) }
|
||||
r#"enum A { One(u32) }
|
||||
|
||||
impl From<u32> for A {
|
||||
fn from(v: u32) -> Self {
|
||||
|
@ -116,7 +116,7 @@ impl From<u32> for A {
|
|||
check_assist(
|
||||
add_from_impl_for_enum,
|
||||
r#"enum A { <|>One(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 {
|
||||
fn from(v: foo::bar::baz::Boo) -> Self {
|
||||
|
@ -178,7 +178,7 @@ impl From<String> for A {
|
|||
pub trait From<T> {
|
||||
fn from(T) -> Self;
|
||||
}"#,
|
||||
r#"enum A { <|>One(u32), Two(String), }
|
||||
r#"enum A { One(u32), Two(String), }
|
||||
|
||||
impl From<u32> for A {
|
||||
fn from(v: u32) -> Self {
|
||||
|
|
|
@ -63,22 +63,22 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
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 &&<|> !x }", "fn f() { !(x || x) }")
|
||||
}
|
||||
|
||||
#[test]
|
||||
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 ||<|> !x }", "fn f() { !(x && x) }")
|
||||
}
|
||||
|
||||
#[test]
|
||||
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 ||<|> !x }", "fn f() { !(x == x && x) }")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn demorgan_general_case() {
|
||||
check_assist(apply_demorgan, "fn f() { x ||<|> x }", "fn f() { !(!x &&<|> !x) }")
|
||||
check_assist(apply_demorgan, "fn f() { x ||<|> x }", "fn f() { !(!x && !x) }")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -298,7 +298,7 @@ mod tests {
|
|||
}
|
||||
",
|
||||
r"
|
||||
<|>use PubMod::PubStruct;
|
||||
use PubMod::PubStruct;
|
||||
|
||||
PubStruct
|
||||
|
||||
|
@ -329,7 +329,7 @@ mod tests {
|
|||
macro_rules! foo {
|
||||
($i:ident) => { fn foo(a: $i) {} }
|
||||
}
|
||||
foo!(Pub<|>Struct);
|
||||
foo!(PubStruct);
|
||||
|
||||
pub mod PubMod {
|
||||
pub struct PubStruct;
|
||||
|
@ -360,7 +360,7 @@ mod tests {
|
|||
use PubMod::{PubStruct2, PubStruct1};
|
||||
|
||||
struct Test {
|
||||
test: Pub<|>Struct2<u8>,
|
||||
test: PubStruct2<u8>,
|
||||
}
|
||||
|
||||
pub mod PubMod {
|
||||
|
@ -393,7 +393,7 @@ mod tests {
|
|||
r"
|
||||
use PubMod3::PubStruct;
|
||||
|
||||
PubSt<|>ruct
|
||||
PubStruct
|
||||
|
||||
pub mod PubMod1 {
|
||||
pub struct PubStruct;
|
||||
|
@ -474,7 +474,7 @@ mod tests {
|
|||
r"
|
||||
use PubMod::test_function;
|
||||
|
||||
test_function<|>
|
||||
test_function
|
||||
|
||||
pub mod PubMod {
|
||||
pub fn test_function() {};
|
||||
|
@ -501,7 +501,7 @@ mod tests {
|
|||
r"use crate_with_macro::foo;
|
||||
|
||||
fn main() {
|
||||
foo<|>
|
||||
foo
|
||||
}
|
||||
",
|
||||
);
|
||||
|
@ -587,7 +587,7 @@ fn main() {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
TestStruct::test_function<|>
|
||||
TestStruct::test_function
|
||||
}
|
||||
",
|
||||
);
|
||||
|
@ -620,7 +620,7 @@ fn main() {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
TestStruct::TEST_CONST<|>
|
||||
TestStruct::TEST_CONST
|
||||
}
|
||||
",
|
||||
);
|
||||
|
@ -659,7 +659,7 @@ fn main() {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
test_mod::TestStruct::test_function<|>
|
||||
test_mod::TestStruct::test_function
|
||||
}
|
||||
",
|
||||
);
|
||||
|
@ -730,7 +730,7 @@ fn main() {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
test_mod::TestStruct::TEST_CONST<|>
|
||||
test_mod::TestStruct::TEST_CONST
|
||||
}
|
||||
",
|
||||
);
|
||||
|
@ -803,7 +803,7 @@ fn main() {
|
|||
|
||||
fn main() {
|
||||
let test_struct = test_mod::TestStruct {};
|
||||
test_struct.test_meth<|>od()
|
||||
test_struct.test_method()
|
||||
}
|
||||
",
|
||||
);
|
||||
|
|
|
@ -118,17 +118,13 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn change_visibility_adds_pub_crate_to_items() {
|
||||
check_assist(change_visibility, "<|>fn foo() {}", "<|>pub(crate) fn foo() {}");
|
||||
check_assist(change_visibility, "f<|>n foo() {}", "pub(crate) f<|>n foo() {}");
|
||||
check_assist(change_visibility, "<|>struct Foo {}", "<|>pub(crate) struct Foo {}");
|
||||
check_assist(change_visibility, "<|>mod foo {}", "<|>pub(crate) mod foo {}");
|
||||
check_assist(change_visibility, "<|>trait Foo {}", "<|>pub(crate) trait Foo {}");
|
||||
check_assist(change_visibility, "m<|>od {}", "pub(crate) m<|>od {}");
|
||||
check_assist(
|
||||
change_visibility,
|
||||
"unsafe f<|>n foo() {}",
|
||||
"pub(crate) unsafe f<|>n foo() {}",
|
||||
);
|
||||
check_assist(change_visibility, "<|>fn foo() {}", "pub(crate) fn foo() {}");
|
||||
check_assist(change_visibility, "f<|>n foo() {}", "pub(crate) fn foo() {}");
|
||||
check_assist(change_visibility, "<|>struct Foo {}", "pub(crate) struct Foo {}");
|
||||
check_assist(change_visibility, "<|>mod foo {}", "pub(crate) mod foo {}");
|
||||
check_assist(change_visibility, "<|>trait Foo {}", "pub(crate) trait Foo {}");
|
||||
check_assist(change_visibility, "m<|>od {}", "pub(crate) mod {}");
|
||||
check_assist(change_visibility, "unsafe f<|>n foo() {}", "pub(crate) unsafe fn foo() {}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -136,9 +132,9 @@ mod tests {
|
|||
check_assist(
|
||||
change_visibility,
|
||||
r"struct S { <|>field: 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 ( <|>u32 )", r"struct S ( pub(crate) u32 )");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -152,17 +148,17 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn change_visibility_pub_to_pub_crate() {
|
||||
check_assist(change_visibility, "<|>pub fn foo() {}", "<|>pub(crate) fn foo() {}")
|
||||
check_assist(change_visibility, "<|>pub fn foo() {}", "pub(crate) fn foo() {}")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn change_visibility_pub_crate_to_pub() {
|
||||
check_assist(change_visibility, "<|>pub(crate) fn foo() {}", "<|>pub fn foo() {}")
|
||||
check_assist(change_visibility, "<|>pub(crate) fn foo() {}", "pub fn foo() {}")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn change_visibility_const() {
|
||||
check_assist(change_visibility, "<|>const FOO = 3u8;", "<|>pub(crate) const FOO = 3u8;");
|
||||
check_assist(change_visibility, "<|>const FOO = 3u8;", "pub(crate) const FOO = 3u8;");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -183,7 +179,7 @@ mod tests {
|
|||
// comments
|
||||
|
||||
#[derive(Debug)]
|
||||
<|>pub(crate) struct Foo;
|
||||
pub(crate) struct Foo;
|
||||
",
|
||||
)
|
||||
}
|
||||
|
|
|
@ -85,17 +85,13 @@ mod tests {
|
|||
check_assist(
|
||||
flip_binexpr,
|
||||
"fn f() { let res = 1 ==<|> 2; }",
|
||||
"fn f() { let res = 2 ==<|> 1; }",
|
||||
"fn f() { let res = 2 == 1; }",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
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 ><|> 2; }", "fn f() { let res = 2 < 1; }")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -103,7 +99,7 @@ mod tests {
|
|||
check_assist(
|
||||
flip_binexpr,
|
||||
"fn f() { let res = 1 <=<|> 2; }",
|
||||
"fn f() { let res = 2 >=<|> 1; }",
|
||||
"fn f() { let res = 2 >= 1; }",
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -112,7 +108,7 @@ mod tests {
|
|||
check_assist(
|
||||
flip_binexpr,
|
||||
"fn f() { let res = (1 + 1) ==<|> (2 + 2); }",
|
||||
"fn f() { let res = (2 + 2) ==<|> (1 + 1); }",
|
||||
"fn f() { let res = (2 + 2) == (1 + 1); }",
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -132,7 +128,7 @@ mod tests {
|
|||
fn dyn_eq(&self, other: &dyn Diagnostic) -> bool {
|
||||
match other.downcast_ref::<Self>() {
|
||||
None => false,
|
||||
Some(it) => self ==<|> it,
|
||||
Some(it) => self == it,
|
||||
}
|
||||
}
|
||||
"#,
|
||||
|
|
|
@ -45,7 +45,7 @@ mod tests {
|
|||
check_assist(
|
||||
flip_comma,
|
||||
"fn foo(x: i32,<|> y: Result<(), ()>) {}",
|
||||
"fn foo(y: Result<(), ()>,<|> x: i32) {}",
|
||||
"fn foo(y: Result<(), ()>, x: i32) {}",
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ mod tests {
|
|||
check_assist(
|
||||
flip_trait_bound,
|
||||
"struct S<T> where T: A <|>+ B { }",
|
||||
"struct S<T> where T: B <|>+ A { }",
|
||||
"struct S<T> where T: B + A { }",
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -69,13 +69,13 @@ mod tests {
|
|||
check_assist(
|
||||
flip_trait_bound,
|
||||
"impl X for S<T> where T: A +<|> B { }",
|
||||
"impl X for S<T> where T: B +<|> A { }",
|
||||
"impl X for S<T> where T: B + A { }",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
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 <|>+ B>(t: T) { }", "fn f<T: B + A>(t: T) { }")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -83,7 +83,7 @@ mod tests {
|
|||
check_assist(
|
||||
flip_trait_bound,
|
||||
"fn f<T>(t: T) where T: A +<|> B { }",
|
||||
"fn f<T>(t: T) where T: B +<|> A { }",
|
||||
"fn f<T>(t: T) where T: B + A { }",
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ mod tests {
|
|||
check_assist(
|
||||
flip_trait_bound,
|
||||
"fn f<T>(t: T) where T: A <|>+ 'static { }",
|
||||
"fn f<T>(t: T) where T: 'static <|>+ A { }",
|
||||
"fn f<T>(t: T) where T: 'static + A { }",
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ mod tests {
|
|||
check_assist(
|
||||
flip_trait_bound,
|
||||
"struct S<T> where T: A<T> <|>+ 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> { }",
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ mod tests {
|
|||
check_assist(
|
||||
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 + G +<|> F + H + I + J { }",
|
||||
"struct S<T> where T: A + B + C + D + E + G + F + H + I + J { }",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ mod tests {
|
|||
check_assist(
|
||||
invert_if,
|
||||
"fn f() { i<|>f x != 3 { 1 } else { 3 + 2 } }",
|
||||
"fn f() { i<|>f x == 3 { 3 + 2 } else { 1 } }",
|
||||
"fn f() { if x == 3 { 3 + 2 } else { 1 } }",
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ mod tests {
|
|||
check_assist(
|
||||
invert_if,
|
||||
"fn f() { <|>if !cond { 3 * 2 } else { 1 } }",
|
||||
"fn f() { <|>if cond { 1 } else { 3 * 2 } }",
|
||||
"fn f() { if cond { 1 } else { 3 * 2 } }",
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ mod tests {
|
|||
check_assist(
|
||||
invert_if,
|
||||
"fn f() { i<|>f cond { 3 * 2 } else { 1 } }",
|
||||
"fn f() { i<|>f !cond { 1 } else { 3 * 2 } }",
|
||||
"fn f() { if !cond { 1 } else { 3 * 2 } }",
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ mod tests {
|
|||
fn foo<T: u32, <|>F: FnOnce(T) -> T>() {}
|
||||
"#,
|
||||
r#"
|
||||
fn foo<T, <|>F>() where T: u32, F: FnOnce(T) -> T {}
|
||||
fn foo<T, F>() where T: u32, F: FnOnce(T) -> T {}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ mod tests {
|
|||
impl<U: u32, <|>T> A<U, T> {}
|
||||
"#,
|
||||
r#"
|
||||
impl<U, <|>T> A<U, T> where U: u32 {}
|
||||
impl<U, T> A<U, T> where U: u32 {}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ mod tests {
|
|||
struct A<<|>T: Iterator<Item = u32>> {}
|
||||
"#,
|
||||
r#"
|
||||
struct A<<|>T> where T: Iterator<Item = u32> {}
|
||||
struct A<T> where T: Iterator<Item = u32> {}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ mod tests {
|
|||
struct Pair<<|>T: u32>(T, T);
|
||||
"#,
|
||||
r#"
|
||||
struct Pair<<|>T>(T, T) where T: u32;
|
||||
struct Pair<T>(T, T) where T: u32;
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ mod test {
|
|||
"#,
|
||||
r##"
|
||||
fn f() {
|
||||
let s = <|>r#"random
|
||||
let s = r#"random
|
||||
string"#;
|
||||
}
|
||||
"##,
|
||||
|
@ -182,7 +182,7 @@ string"#;
|
|||
"#,
|
||||
r##"
|
||||
fn f() {
|
||||
format!(<|>r#"x = {}"#, 92)
|
||||
format!(r#"x = {}"#, 92)
|
||||
}
|
||||
"##,
|
||||
)
|
||||
|
@ -199,7 +199,7 @@ string"#;
|
|||
"###,
|
||||
r####"
|
||||
fn f() {
|
||||
let s = <|>r#"#random##
|
||||
let s = r#"#random##
|
||||
string"#;
|
||||
}
|
||||
"####,
|
||||
|
@ -217,7 +217,7 @@ string"#;
|
|||
"###,
|
||||
r####"
|
||||
fn f() {
|
||||
let s = <|>r###"#random"##
|
||||
let s = r###"#random"##
|
||||
string"###;
|
||||
}
|
||||
"####,
|
||||
|
@ -235,7 +235,7 @@ string"###;
|
|||
"#,
|
||||
r##"
|
||||
fn f() {
|
||||
let s = <|>r#"random string"#;
|
||||
let s = r#"random string"#;
|
||||
}
|
||||
"##,
|
||||
)
|
||||
|
@ -289,7 +289,7 @@ string"###;
|
|||
"#,
|
||||
r##"
|
||||
fn f() {
|
||||
let s = <|>r#"random string"#;
|
||||
let s = r#"random string"#;
|
||||
}
|
||||
"##,
|
||||
)
|
||||
|
@ -306,7 +306,7 @@ string"###;
|
|||
"##,
|
||||
r###"
|
||||
fn f() {
|
||||
let s = <|>r##"random"string"##;
|
||||
let s = r##"random"string"##;
|
||||
}
|
||||
"###,
|
||||
)
|
||||
|
@ -348,7 +348,7 @@ string"###;
|
|||
"##,
|
||||
r#"
|
||||
fn f() {
|
||||
let s = <|>r"random string";
|
||||
let s = r"random string";
|
||||
}
|
||||
"#,
|
||||
)
|
||||
|
@ -365,7 +365,7 @@ string"###;
|
|||
"##,
|
||||
r#"
|
||||
fn f() {
|
||||
let s = <|>r"random\"str\"ing";
|
||||
let s = r"random\"str\"ing";
|
||||
}
|
||||
"#,
|
||||
)
|
||||
|
@ -382,7 +382,7 @@ string"###;
|
|||
"###,
|
||||
r##"
|
||||
fn f() {
|
||||
let s = <|>r#"random string"#;
|
||||
let s = r#"random string"#;
|
||||
}
|
||||
"##,
|
||||
)
|
||||
|
@ -436,7 +436,7 @@ string"###;
|
|||
"##,
|
||||
r#"
|
||||
fn f() {
|
||||
let s = <|>"random string";
|
||||
let s = "random string";
|
||||
}
|
||||
"#,
|
||||
)
|
||||
|
@ -453,7 +453,7 @@ string"###;
|
|||
"##,
|
||||
r#"
|
||||
fn f() {
|
||||
let s = <|>"random\"str\"ing";
|
||||
let s = "random\"str\"ing";
|
||||
}
|
||||
"#,
|
||||
)
|
||||
|
@ -470,7 +470,7 @@ string"###;
|
|||
"###,
|
||||
r##"
|
||||
fn f() {
|
||||
let s = <|>"random string";
|
||||
let s = "random string";
|
||||
}
|
||||
"##,
|
||||
)
|
||||
|
|
|
@ -140,7 +140,7 @@ mod tests {
|
|||
"#,
|
||||
r#"
|
||||
struct Foo {foo: i32, bar: i32};
|
||||
const test: Foo = <|>Foo {foo: 1, bar: 0}
|
||||
const test: Foo = Foo {foo: 1, bar: 0}
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ mod tests {
|
|||
|
||||
fn f(f: Foo) -> {
|
||||
match f {
|
||||
<|>Foo { ref mut bar, baz: 0, .. } => (),
|
||||
Foo { ref mut bar, baz: 0, .. } => (),
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ mod tests {
|
|||
impl Foo {
|
||||
fn new() -> Foo {
|
||||
let foo = String::new();
|
||||
<|>Foo {
|
||||
Foo {
|
||||
foo,
|
||||
bar: foo.clone(),
|
||||
extra: "Extra field",
|
||||
|
|
|
@ -89,7 +89,7 @@ std::fmt::Debug<|>
|
|||
"
|
||||
use std::fmt::Debug;
|
||||
|
||||
Debug<|>
|
||||
Debug
|
||||
",
|
||||
);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ fn main() {
|
|||
"
|
||||
use std::fmt::Debug;
|
||||
|
||||
Debug<|>
|
||||
Debug
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ use std::fmt::Debug;
|
|||
fn main() {
|
||||
}
|
||||
|
||||
Debug<|>
|
||||
Debug
|
||||
",
|
||||
);
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ std::fmt<|>::Debug
|
|||
"
|
||||
use std::fmt;
|
||||
|
||||
fmt<|>::Debug
|
||||
fmt::Debug
|
||||
",
|
||||
);
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ impl std::fmt::Debug<|> for Foo {
|
|||
use stdx;
|
||||
use std::fmt::Debug;
|
||||
|
||||
impl Debug<|> for Foo {
|
||||
impl Debug for Foo {
|
||||
}
|
||||
",
|
||||
);
|
||||
|
@ -181,7 +181,7 @@ impl std::fmt::Debug<|> for Foo {
|
|||
"
|
||||
use std::fmt::Debug;
|
||||
|
||||
impl Debug<|> for Foo {
|
||||
impl Debug for Foo {
|
||||
}
|
||||
",
|
||||
);
|
||||
|
@ -198,7 +198,7 @@ impl Debug<|> for Foo {
|
|||
"
|
||||
use std::fmt::Debug;
|
||||
|
||||
impl Debug<|> for Foo {
|
||||
impl Debug for Foo {
|
||||
}
|
||||
",
|
||||
);
|
||||
|
@ -217,7 +217,7 @@ impl std::io<|> for Foo {
|
|||
"
|
||||
use std::{io, fmt};
|
||||
|
||||
impl io<|> for Foo {
|
||||
impl io for Foo {
|
||||
}
|
||||
",
|
||||
);
|
||||
|
@ -236,7 +236,7 @@ impl std::fmt::Debug<|> for Foo {
|
|||
"
|
||||
use std::fmt::{self, Debug, };
|
||||
|
||||
impl Debug<|> for Foo {
|
||||
impl Debug for Foo {
|
||||
}
|
||||
",
|
||||
);
|
||||
|
@ -255,7 +255,7 @@ impl std::fmt<|> for Foo {
|
|||
"
|
||||
use std::fmt::{self, Debug};
|
||||
|
||||
impl fmt<|> for Foo {
|
||||
impl fmt for Foo {
|
||||
}
|
||||
",
|
||||
);
|
||||
|
@ -274,7 +274,7 @@ impl std::fmt::nested<|> for Foo {
|
|||
"
|
||||
use std::fmt::{Debug, nested::{Display, self}};
|
||||
|
||||
impl nested<|> for Foo {
|
||||
impl nested for Foo {
|
||||
}
|
||||
",
|
||||
);
|
||||
|
@ -293,7 +293,7 @@ impl std::fmt::nested<|> for Foo {
|
|||
"
|
||||
use std::fmt::{Debug, nested::{self, Display}};
|
||||
|
||||
impl nested<|> for Foo {
|
||||
impl nested for Foo {
|
||||
}
|
||||
",
|
||||
);
|
||||
|
@ -312,7 +312,7 @@ impl std::fmt::nested::Debug<|> for Foo {
|
|||
"
|
||||
use std::fmt::{Debug, nested::{Display, Debug}};
|
||||
|
||||
impl Debug<|> for Foo {
|
||||
impl Debug for Foo {
|
||||
}
|
||||
",
|
||||
);
|
||||
|
@ -331,7 +331,7 @@ impl std::fmt::nested::Display<|> for Foo {
|
|||
"
|
||||
use std::fmt::{nested::Display, Debug};
|
||||
|
||||
impl Display<|> for Foo {
|
||||
impl Display for Foo {
|
||||
}
|
||||
",
|
||||
);
|
||||
|
@ -350,7 +350,7 @@ impl std::fmt::Display<|> for Foo {
|
|||
"
|
||||
use std::fmt::{Display, nested::Debug};
|
||||
|
||||
impl Display<|> for Foo {
|
||||
impl Display for Foo {
|
||||
}
|
||||
",
|
||||
);
|
||||
|
@ -374,7 +374,7 @@ use crate::{
|
|||
AssocItem,
|
||||
};
|
||||
|
||||
fn foo() { lower<|>::trait_env() }
|
||||
fn foo() { lower::trait_env() }
|
||||
",
|
||||
);
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ impl foo::Debug<|> for Foo {
|
|||
"
|
||||
use std::fmt as foo;
|
||||
|
||||
impl Debug<|> for Foo {
|
||||
impl Debug for Foo {
|
||||
}
|
||||
",
|
||||
);
|
||||
|
@ -435,7 +435,7 @@ mod foo {
|
|||
mod bar {
|
||||
use std::fmt::Debug;
|
||||
|
||||
Debug<|>
|
||||
Debug
|
||||
}
|
||||
}
|
||||
",
|
||||
|
@ -458,7 +458,7 @@ fn main() {
|
|||
use std::fmt::Debug;
|
||||
|
||||
fn main() {
|
||||
Debug<|>
|
||||
Debug
|
||||
}
|
||||
",
|
||||
);
|
||||
|
|
|
@ -105,18 +105,9 @@ fn check(handler: Handler, before: &str, expected: ExpectedResult) {
|
|||
change.edit.apply(&mut actual);
|
||||
|
||||
if !source_change.is_snippet {
|
||||
match source_change.cursor_position {
|
||||
None => {
|
||||
if let RangeOrOffset::Offset(before_cursor_pos) = range_or_offset {
|
||||
let off = change
|
||||
.edit
|
||||
.apply_to_offset(before_cursor_pos)
|
||||
.expect("cursor position is affected by the edit");
|
||||
actual = add_cursor(&actual, off)
|
||||
}
|
||||
}
|
||||
Some(off) => actual = add_cursor(&actual, off.offset),
|
||||
};
|
||||
if let Some(off) = source_change.cursor_position {
|
||||
actual = add_cursor(&actual, off.offset)
|
||||
}
|
||||
}
|
||||
assert_eq_text!(after, &actual);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue