about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-02-01 20:00:19 +0000
committerbors <bors@rust-lang.org>2023-02-01 20:00:19 +0000
commitccd142c6163c992dfb482b85bbddbb7b3370c9c8 (patch)
tree12bb9401982bea71c0918e43b8fca87b97ecae52
parenta257a58f2466958dd905da13e47fae904212a15d (diff)
parentfd1a9a93fee829ea471601bd932385a4ab4ac4d2 (diff)
downloadrust-ccd142c6163c992dfb482b85bbddbb7b3370c9c8.tar.gz
rust-ccd142c6163c992dfb482b85bbddbb7b3370c9c8.zip
Auto merge of #14058 - gftea:master, r=Veykril
fix negative trait bound in outline view (#14044)

try to fix and close #14044
-rw-r--r--crates/ide/src/file_structure.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/crates/ide/src/file_structure.rs b/crates/ide/src/file_structure.rs
index 68fd0952b48..b23763dce86 100644
--- a/crates/ide/src/file_structure.rs
+++ b/crates/ide/src/file_structure.rs
@@ -160,7 +160,11 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
                 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(),
+                        )
                     }
                 };
 
@@ -214,6 +218,29 @@ mod tests {
     }
 
     #[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(
             r#"