Auto merge of #14058 - gftea:master, r=Veykril

fix negative trait bound in outline view (#14044)

try to fix and close #14044
This commit is contained in:
bors 2023-02-01 20:00:19 +00:00
commit ccd142c616

View File

@ -160,7 +160,11 @@ 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 +217,29 @@ 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(