From 28b7460db18d965d80e14637e62981892a05721e Mon Sep 17 00:00:00 2001 From: gftea Date: Mon, 30 Jan 2023 17:57:27 +0100 Subject: [PATCH 1/5] fix negative trait bound in outline view (#14044) --- crates/ide/src/file_structure.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/ide/src/file_structure.rs b/crates/ide/src/file_structure.rs index 68fd0952b48..ab1365e3174 100644 --- a/crates/ide/src/file_structure.rs +++ b/crates/ide/src/file_structure.rs @@ -160,7 +160,10 @@ fn collapse_ws(node: &SyntaxNode, output: &mut String) { let label = match target_trait { None => format!("impl {}", target_type.syntax().text()), Some(t) => { - format!("impl {} for {}", t.syntax().text(), target_type.syntax().text(),) + format!("impl {}{} for {}", + it.excl_token().map(|x| x.to_string()).unwrap_or_default(), + t.syntax().text(), + target_type.syntax().text(),) } }; @@ -213,6 +216,26 @@ fn check(ra_fixture: &str, expect: Expect) { expect.assert_debug_eq(&structure) } + #[test] + fn test_nagative_trait_bound() { + let txt = r#"impl !Unpin for Test {}"#; + check(txt, expect![[r#" + [ + StructureNode { + parent: None, + label: "impl !Unpin for Test", + navigation_range: 16..20, + node_range: 0..23, + kind: SymbolKind( + Impl, + ), + detail: None, + deprecated: false, + }, + ] + "#]]); + } + #[test] fn test_file_structure() { check( From 75676ebe86703efbdaf00c5586ed6208bbd7ad9b Mon Sep 17 00:00:00 2001 From: gftea <1705787+gftea@users.noreply.github.com> Date: Mon, 30 Jan 2023 19:17:48 +0100 Subject: [PATCH 2/5] Update crates/ide/src/file_structure.rs Co-authored-by: Jonas Schievink --- crates/ide/src/file_structure.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/ide/src/file_structure.rs b/crates/ide/src/file_structure.rs index ab1365e3174..afcdf7b5983 100644 --- a/crates/ide/src/file_structure.rs +++ b/crates/ide/src/file_structure.rs @@ -161,9 +161,10 @@ fn collapse_ws(node: &SyntaxNode, output: &mut String) { None => format!("impl {}", target_type.syntax().text()), Some(t) => { format!("impl {}{} for {}", - it.excl_token().map(|x| x.to_string()).unwrap_or_default(), - t.syntax().text(), - target_type.syntax().text(),) + it.excl_token().map(|x| x.to_string()).unwrap_or_default(), + t.syntax().text(), + target_type.syntax().text(), + ) } }; From 5356a8b1575514ba2a51d54e0e5565d9c001bd18 Mon Sep 17 00:00:00 2001 From: gftea Date: Mon, 30 Jan 2023 20:03:44 +0100 Subject: [PATCH 3/5] trim trailing whitespaces (#14044) --- crates/ide/src/file_structure.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/ide/src/file_structure.rs b/crates/ide/src/file_structure.rs index afcdf7b5983..dcca3d323e8 100644 --- a/crates/ide/src/file_structure.rs +++ b/crates/ide/src/file_structure.rs @@ -160,9 +160,9 @@ fn collapse_ws(node: &SyntaxNode, output: &mut String) { let label = match target_trait { None => format!("impl {}", target_type.syntax().text()), Some(t) => { - format!("impl {}{} for {}", - it.excl_token().map(|x| x.to_string()).unwrap_or_default(), - t.syntax().text(), + format!("impl {}{} for {}", + it.excl_token().map(|x| x.to_string()).unwrap_or_default(), + t.syntax().text(), target_type.syntax().text(), ) } From 04a4ac1cffd3acb9361b63221cec76eae3694e11 Mon Sep 17 00:00:00 2001 From: gftea Date: Mon, 30 Jan 2023 20:17:12 +0100 Subject: [PATCH 4/5] trim trailing whitespaces --- crates/ide/src/file_structure.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ide/src/file_structure.rs b/crates/ide/src/file_structure.rs index dcca3d323e8..5303590f7fd 100644 --- a/crates/ide/src/file_structure.rs +++ b/crates/ide/src/file_structure.rs @@ -235,7 +235,7 @@ fn test_nagative_trait_bound() { }, ] "#]]); - } + } #[test] fn test_file_structure() { From fd1a9a93fee829ea471601bd932385a4ab4ac4d2 Mon Sep 17 00:00:00 2001 From: gftea Date: Mon, 30 Jan 2023 20:34:07 +0100 Subject: [PATCH 5/5] tidy by rustfmt --- crates/ide/src/file_structure.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/ide/src/file_structure.rs b/crates/ide/src/file_structure.rs index 5303590f7fd..b23763dce86 100644 --- a/crates/ide/src/file_structure.rs +++ b/crates/ide/src/file_structure.rs @@ -220,7 +220,9 @@ fn check(ra_fixture: &str, expect: Expect) { #[test] fn test_nagative_trait_bound() { let txt = r#"impl !Unpin for Test {}"#; - check(txt, expect![[r#" + check( + txt, + expect![[r#" [ StructureNode { parent: None, @@ -234,7 +236,8 @@ fn test_nagative_trait_bound() { deprecated: false, }, ] - "#]]); + "#]], + ); } #[test]