From 5734b347ddfff0d285d3eecf5735cac30271696c Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 17 Mar 2021 16:10:58 +0100 Subject: Fix incorrect newline emission in Attrs::docs --- crates/ide_db/src/call_info.rs | 6 +-- crates/ide_db/src/call_info/tests.rs | 82 ++++++++++++++++++------------------ 2 files changed, 44 insertions(+), 44 deletions(-) (limited to 'crates/ide_db') diff --git a/crates/ide_db/src/call_info.rs b/crates/ide_db/src/call_info.rs index d4016973c..7e26c3ccf 100644 --- a/crates/ide_db/src/call_info.rs +++ b/crates/ide_db/src/call_info.rs @@ -53,15 +53,15 @@ pub fn call_info(db: &RootDatabase, position: FilePosition) -> Option match callable.kind() { hir::CallableKind::Function(func) => { - res.doc = func.docs(db).map(|it| it.as_str().to_string()); + res.doc = func.docs(db).map(|it| it.into()); format_to!(res.signature, "fn {}", func.name(db)); } hir::CallableKind::TupleStruct(strukt) => { - res.doc = strukt.docs(db).map(|it| it.as_str().to_string()); + res.doc = strukt.docs(db).map(|it| it.into()); format_to!(res.signature, "struct {}", strukt.name(db)); } hir::CallableKind::TupleEnumVariant(variant) => { - res.doc = variant.docs(db).map(|it| it.as_str().to_string()); + res.doc = variant.docs(db).map(|it| it.into()); format_to!( res.signature, "enum {}::{}", diff --git a/crates/ide_db/src/call_info/tests.rs b/crates/ide_db/src/call_info/tests.rs index 9f84c253c..75ab3eb6e 100644 --- a/crates/ide_db/src/call_info/tests.rs +++ b/crates/ide_db/src/call_info/tests.rs @@ -220,11 +220,11 @@ fn bar() { } "#, expect![[r#" - test - ------ - fn foo(j: u32) -> u32 - () - "#]], + test + ------ + fn foo(j: u32) -> u32 + () + "#]], ); } @@ -249,19 +249,19 @@ pub fn do() { add_one($0 }"#, expect![[r##" - Adds one to the number given. + Adds one to the number given. - # Examples + # Examples - ``` - let five = 5; + ``` + let five = 5; - assert_eq!(6, my_crate::add_one(5)); - ``` - ------ - fn add_one(x: i32) -> i32 - () - "##]], + assert_eq!(6, my_crate::add_one(5)); + ``` + ------ + fn add_one(x: i32) -> i32 + () + "##]], ); } @@ -291,19 +291,19 @@ pub fn do_it() { } "#, expect![[r##" - Adds one to the number given. + Adds one to the number given. - # Examples + # Examples - ``` - let five = 5; + ``` + let five = 5; - assert_eq!(6, my_crate::add_one(5)); - ``` - ------ - fn add_one(x: i32) -> i32 - () - "##]], + assert_eq!(6, my_crate::add_one(5)); + ``` + ------ + fn add_one(x: i32) -> i32 + () + "##]], ); } @@ -335,13 +335,13 @@ pub fn foo(mut r: WriteHandler<()>) { } "#, expect![[r#" - Method is called when writer finishes. + Method is called when writer finishes. - By default this method stops actor's `Context`. - ------ - fn finished(&mut self, ctx: &mut {unknown}) - () - "#]], + By default this method stops actor's `Context`. + ------ + fn finished(&mut self, ctx: &mut {unknown}) + () + "#]], ); } @@ -389,11 +389,11 @@ fn main() { } "#, expect![[r#" - A cool tuple struct - ------ - struct S(u32, i32) - (u32, ) - "#]], + A cool tuple struct + ------ + struct S(u32, i32) + (u32, ) + "#]], ); } @@ -431,11 +431,11 @@ fn main() { } "#, expect![[r#" - A Variant - ------ - enum E::A(i32) - () - "#]], + A Variant + ------ + enum E::A(i32) + () + "#]], ); } -- cgit v1.2.3