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:
bors[bot] 2020-05-20 20:56:28 +00:00 committed by GitHub
commit ee9cec56c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 96 additions and 117 deletions

View file

@ -86,11 +86,7 @@ mod tests {
#[test] #[test]
fn add_explicit_type_works_for_simple_expr() { fn add_explicit_type_works_for_simple_expr() {
check_assist( check_assist(add_explicit_type, "fn f() { let a<|> = 1; }", "fn f() { let a: i32 = 1; }");
add_explicit_type,
"fn f() { let a<|> = 1; }",
"fn f() { let a<|>: i32 = 1; }",
);
} }
#[test] #[test]
@ -98,7 +94,7 @@ mod tests {
check_assist( check_assist(
add_explicit_type, add_explicit_type,
"fn f() { let a<|>: _ = 1; }", "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() { fn f() {
let a<|>: Option<i32> = Option::Some(1); let a: Option<i32> = Option::Some(1);
}"#, }"#,
); );
} }
@ -132,7 +128,7 @@ mod tests {
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<|> = 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() { fn add_explicit_type_works_for_macro_call_recursive() {
check_assist( check_assist(
add_explicit_type, add_explicit_type,
"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<|> = 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: u64 = v!(); }"#,
); );
} }
@ -208,7 +204,7 @@ struct Test<K, T = u8> {
} }
fn main() { fn main() {
let test<|>: Test<i32> = Test { t: 23, k: 33 }; let test: Test<i32> = Test { t: 23, k: 33 };
}"#, }"#,
); );
} }

View file

@ -101,7 +101,7 @@ mod tests {
check_assist( check_assist(
add_from_impl_for_enum, add_from_impl_for_enum,
"enum A { <|>One(u32) }", "enum A { <|>One(u32) }",
r#"enum A { <|>One(u32) } r#"enum A { One(u32) }
impl From<u32> for A { impl From<u32> for A {
fn from(v: u32) -> Self { fn from(v: u32) -> Self {
@ -116,7 +116,7 @@ impl From<u32> for A {
check_assist( check_assist(
add_from_impl_for_enum, 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) } r#"enum A { One(foo::bar::baz::Boo) }
impl From<foo::bar::baz::Boo> for A { impl From<foo::bar::baz::Boo> for A {
fn from(v: foo::bar::baz::Boo) -> Self { fn from(v: foo::bar::baz::Boo) -> Self {
@ -178,7 +178,7 @@ impl From<String> for A {
pub trait From<T> { pub trait From<T> {
fn from(T) -> Self; fn from(T) -> Self;
}"#, }"#,
r#"enum A { <|>One(u32), Two(String), } r#"enum A { One(u32), Two(String), }
impl From<u32> for A { impl From<u32> for A {
fn from(v: u32) -> Self { fn from(v: u32) -> Self {

View file

@ -63,22 +63,22 @@ 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 &&<|> !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 ||<|> !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 ||<|> !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 ||<|> x }", "fn f() { !(!x && !x) }")
} }
#[test] #[test]

View file

@ -298,7 +298,7 @@ mod tests {
} }
", ",
r" r"
<|>use PubMod::PubStruct; use PubMod::PubStruct;
PubStruct PubStruct
@ -329,7 +329,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!(PubStruct);
pub mod PubMod { pub mod PubMod {
pub struct PubStruct; pub struct PubStruct;
@ -360,7 +360,7 @@ mod tests {
use PubMod::{PubStruct2, PubStruct1}; use PubMod::{PubStruct2, PubStruct1};
struct Test { struct Test {
test: Pub<|>Struct2<u8>, test: PubStruct2<u8>,
} }
pub mod PubMod { pub mod PubMod {
@ -393,7 +393,7 @@ mod tests {
r" r"
use PubMod3::PubStruct; use PubMod3::PubStruct;
PubSt<|>ruct PubStruct
pub mod PubMod1 { pub mod PubMod1 {
pub struct PubStruct; pub struct PubStruct;
@ -474,7 +474,7 @@ mod tests {
r" r"
use PubMod::test_function; use PubMod::test_function;
test_function<|> test_function
pub mod PubMod { pub mod PubMod {
pub fn test_function() {}; pub fn test_function() {};
@ -501,7 +501,7 @@ mod tests {
r"use crate_with_macro::foo; r"use crate_with_macro::foo;
fn main() { fn main() {
foo<|> foo
} }
", ",
); );
@ -587,7 +587,7 @@ fn main() {
} }
fn main() { fn main() {
TestStruct::test_function<|> TestStruct::test_function
} }
", ",
); );
@ -620,7 +620,7 @@ fn main() {
} }
fn main() { fn main() {
TestStruct::TEST_CONST<|> TestStruct::TEST_CONST
} }
", ",
); );
@ -659,7 +659,7 @@ fn main() {
} }
fn main() { fn main() {
test_mod::TestStruct::test_function<|> test_mod::TestStruct::test_function
} }
", ",
); );
@ -730,7 +730,7 @@ fn main() {
} }
fn main() { fn main() {
test_mod::TestStruct::TEST_CONST<|> test_mod::TestStruct::TEST_CONST
} }
", ",
); );
@ -803,7 +803,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_method()
} }
", ",
); );

View file

@ -118,17 +118,13 @@ 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, "<|>fn foo() {}", "pub(crate) fn foo() {}");
check_assist(change_visibility, "f<|>n foo() {}", "pub(crate) f<|>n 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, "<|>struct Foo {}", "pub(crate) struct Foo {}");
check_assist(change_visibility, "<|>mod foo {}", "<|>pub(crate) mod 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, "<|>trait Foo {}", "pub(crate) trait Foo {}");
check_assist(change_visibility, "m<|>od {}", "pub(crate) m<|>od {}"); check_assist(change_visibility, "m<|>od {}", "pub(crate) mod {}");
check_assist( check_assist(change_visibility, "unsafe f<|>n foo() {}", "pub(crate) unsafe fn foo() {}");
change_visibility,
"unsafe f<|>n foo() {}",
"pub(crate) unsafe f<|>n foo() {}",
);
} }
#[test] #[test]
@ -136,9 +132,9 @@ mod tests {
check_assist( check_assist(
change_visibility, change_visibility,
r"struct S { <|>field: u32 }", 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] #[test]
@ -152,17 +148,17 @@ mod tests {
#[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, "<|>pub 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, "<|>pub(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, "<|>const FOO = 3u8;", "pub(crate) const FOO = 3u8;");
} }
#[test] #[test]
@ -183,7 +179,7 @@ mod tests {
// comments // comments
#[derive(Debug)] #[derive(Debug)]
<|>pub(crate) struct Foo; pub(crate) struct Foo;
", ",
) )
} }

View file

@ -85,17 +85,13 @@ mod tests {
check_assist( check_assist(
flip_binexpr, flip_binexpr,
"fn f() { let res = 1 ==<|> 2; }", "fn f() { let res = 1 ==<|> 2; }",
"fn f() { let res = 2 ==<|> 1; }", "fn f() { let res = 2 == 1; }",
) )
} }
#[test] #[test]
fn flip_binexpr_works_for_gt() { fn flip_binexpr_works_for_gt() {
check_assist( check_assist(flip_binexpr, "fn f() { let res = 1 ><|> 2; }", "fn f() { let res = 2 < 1; }")
flip_binexpr,
"fn f() { let res = 1 ><|> 2; }",
"fn f() { let res = 2 <<|> 1; }",
)
} }
#[test] #[test]
@ -103,7 +99,7 @@ mod tests {
check_assist( check_assist(
flip_binexpr, flip_binexpr,
"fn f() { let res = 1 <=<|> 2; }", "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( check_assist(
flip_binexpr, flip_binexpr,
"fn f() { let res = (1 + 1) ==<|> (2 + 2); }", "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 { fn dyn_eq(&self, other: &dyn Diagnostic) -> bool {
match other.downcast_ref::<Self>() { match other.downcast_ref::<Self>() {
None => false, None => false,
Some(it) => self ==<|> it, Some(it) => self == it,
} }
} }
"#, "#,

View file

@ -45,7 +45,7 @@ mod tests {
check_assist( check_assist(
flip_comma, flip_comma,
"fn foo(x: i32,<|> y: Result<(), ()>) {}", "fn foo(x: i32,<|> y: Result<(), ()>) {}",
"fn foo(y: Result<(), ()>,<|> x: i32) {}", "fn foo(y: Result<(), ()>, x: i32) {}",
) )
} }

View file

@ -60,7 +60,7 @@ mod tests {
check_assist( check_assist(
flip_trait_bound, flip_trait_bound,
"struct S<T> where T: A <|>+ B { }", "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( 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 +<|> 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 <|>+ B>(t: T) { }", "fn f<T: B + A>(t: T) { }")
} }
#[test] #[test]
@ -83,7 +83,7 @@ mod tests {
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 +<|> 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( 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 <|>+ '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( 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> <|>+ 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( 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 +<|> 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

@ -72,7 +72,7 @@ mod tests {
check_assist( check_assist(
invert_if, invert_if,
"fn f() { i<|>f x != 3 { 1 } else { 3 + 2 } }", "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( check_assist(
invert_if, invert_if,
"fn f() { <|>if !cond { 3 * 2 } else { 1 } }", "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( check_assist(
invert_if, invert_if,
"fn f() { i<|>f cond { 3 * 2 } else { 1 } }", "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 } }",
) )
} }

View file

@ -99,7 +99,7 @@ mod tests {
fn foo<T: u32, <|>F: FnOnce(T) -> T>() {} fn foo<T: u32, <|>F: 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 {}
"#, "#,
); );
} }
@ -112,7 +112,7 @@ mod tests {
impl<U: u32, <|>T> A<U, T> {} impl<U: u32, <|>T> A<U, T> {}
"#, "#,
r#" 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>> {} struct A<<|>T: Iterator<Item = u32>> {}
"#, "#,
r#" 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); struct Pair<<|>T: u32>(T, T);
"#, "#,
r#" r#"
struct Pair<<|>T>(T, T) where T: u32; struct Pair<T>(T, T) where T: u32;
"#, "#,
); );
} }

View file

@ -164,7 +164,7 @@ mod test {
"#, "#,
r##" r##"
fn f() { fn f() {
let s = <|>r#"random let s = r#"random
string"#; string"#;
} }
"##, "##,
@ -182,7 +182,7 @@ string"#;
"#, "#,
r##" r##"
fn f() { fn f() {
format!(<|>r#"x = {}"#, 92) format!(r#"x = {}"#, 92)
} }
"##, "##,
) )
@ -199,7 +199,7 @@ string"#;
"###, "###,
r####" r####"
fn f() { fn f() {
let s = <|>r#"#random## let s = r#"#random##
string"#; string"#;
} }
"####, "####,
@ -217,7 +217,7 @@ string"#;
"###, "###,
r####" r####"
fn f() { fn f() {
let s = <|>r###"#random"## let s = r###"#random"##
string"###; string"###;
} }
"####, "####,
@ -235,7 +235,7 @@ string"###;
"#, "#,
r##" r##"
fn f() { fn f() {
let s = <|>r#"random string"#; let s = r#"random string"#;
} }
"##, "##,
) )
@ -289,7 +289,7 @@ string"###;
"#, "#,
r##" r##"
fn f() { fn f() {
let s = <|>r#"random string"#; let s = r#"random string"#;
} }
"##, "##,
) )
@ -306,7 +306,7 @@ string"###;
"##, "##,
r###" r###"
fn f() { fn f() {
let s = <|>r##"random"string"##; let s = r##"random"string"##;
} }
"###, "###,
) )
@ -348,7 +348,7 @@ string"###;
"##, "##,
r#" r#"
fn f() { fn f() {
let s = <|>r"random string"; let s = r"random string";
} }
"#, "#,
) )
@ -365,7 +365,7 @@ string"###;
"##, "##,
r#" r#"
fn f() { fn f() {
let s = <|>r"random\"str\"ing"; let s = r"random\"str\"ing";
} }
"#, "#,
) )
@ -382,7 +382,7 @@ string"###;
"###, "###,
r##" r##"
fn f() { fn f() {
let s = <|>r#"random string"#; let s = r#"random string"#;
} }
"##, "##,
) )
@ -436,7 +436,7 @@ string"###;
"##, "##,
r#" r#"
fn f() { fn f() {
let s = <|>"random string"; let s = "random string";
} }
"#, "#,
) )
@ -453,7 +453,7 @@ string"###;
"##, "##,
r#" r#"
fn f() { fn f() {
let s = <|>"random\"str\"ing"; let s = "random\"str\"ing";
} }
"#, "#,
) )
@ -470,7 +470,7 @@ string"###;
"###, "###,
r##" r##"
fn f() { fn f() {
let s = <|>"random string"; let s = "random string";
} }
"##, "##,
) )

View file

@ -140,7 +140,7 @@ mod tests {
"#, "#,
r#" r#"
struct Foo {foo: i32, bar: i32}; 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) -> { fn f(f: Foo) -> {
match f { match f {
<|>Foo { ref mut bar, baz: 0, .. } => (), Foo { ref mut bar, baz: 0, .. } => (),
_ => () _ => ()
} }
} }
@ -202,7 +202,7 @@ mod tests {
impl Foo { impl Foo {
fn new() -> Foo { fn new() -> Foo {
let foo = String::new(); let foo = String::new();
<|>Foo { Foo {
foo, foo,
bar: foo.clone(), bar: foo.clone(),
extra: "Extra field", extra: "Extra field",

View file

@ -89,7 +89,7 @@ std::fmt::Debug<|>
" "
use std::fmt::Debug; use std::fmt::Debug;
Debug<|> Debug
", ",
); );
} }
@ -106,7 +106,7 @@ fn main() {
" "
use std::fmt::Debug; use std::fmt::Debug;
Debug<|> Debug
fn main() { fn main() {
} }
@ -130,7 +130,7 @@ use std::fmt::Debug;
fn main() { fn main() {
} }
Debug<|> Debug
", ",
); );
} }
@ -145,7 +145,7 @@ std::fmt<|>::Debug
" "
use std::fmt; use std::fmt;
fmt<|>::Debug fmt::Debug
", ",
); );
} }
@ -164,7 +164,7 @@ impl std::fmt::Debug<|> for Foo {
use stdx; use stdx;
use std::fmt::Debug; 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; use std::fmt::Debug;
impl Debug<|> for Foo { impl Debug for Foo {
} }
", ",
); );
@ -198,7 +198,7 @@ impl Debug<|> for Foo {
" "
use std::fmt::Debug; 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}; 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, }; 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}; 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}}; 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}}; 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}}; 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}; 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}; use std::fmt::{Display, nested::Debug};
impl Display<|> for Foo { impl Display for Foo {
} }
", ",
); );
@ -374,7 +374,7 @@ use crate::{
AssocItem, 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; use std::fmt as foo;
impl Debug<|> for Foo { impl Debug for Foo {
} }
", ",
); );
@ -435,7 +435,7 @@ mod foo {
mod bar { mod bar {
use std::fmt::Debug; use std::fmt::Debug;
Debug<|> Debug
} }
} }
", ",
@ -458,7 +458,7 @@ fn main() {
use std::fmt::Debug; use std::fmt::Debug;
fn main() { fn main() {
Debug<|> Debug
} }
", ",
); );

View file

@ -105,18 +105,9 @@ fn check(handler: Handler, before: &str, expected: ExpectedResult) {
change.edit.apply(&mut actual); change.edit.apply(&mut actual);
if !source_change.is_snippet { if !source_change.is_snippet {
match source_change.cursor_position { if let Some(off) = source_change.cursor_position {
None => { actual = add_cursor(&actual, off.offset)
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),
};
} }
assert_eq_text!(after, &actual); assert_eq_text!(after, &actual);
} }