prefer lifetimes in extend selection

This commit is contained in:
Aleksey Kladov 2018-09-19 13:55:47 +03:00
parent 5901e98116
commit 4d5cfd7229

View file

@ -64,7 +64,7 @@ fn pick_best<'a>(l: SyntaxNodeRef<'a>, r: SyntaxNodeRef<'a>) -> SyntaxNodeRef<'a
fn priority(n: SyntaxNodeRef) -> usize { fn priority(n: SyntaxNodeRef) -> usize {
match n.kind() { match n.kind() {
WHITESPACE => 0, WHITESPACE => 0,
IDENT | SELF_KW | SUPER_KW | CRATE_KW => 2, IDENT | SELF_KW | SUPER_KW | CRATE_KW | LIFETIME => 2,
_ => 1, _ => 1,
} }
} }
@ -164,4 +164,16 @@ fn main() { foo+<|>bar;}
&["bar", "foo+bar"] &["bar", "foo+bar"]
); );
} }
#[test]
fn test_extend_selection_prefer_lifetimes() {
do_check(
r#"fn foo<<|>'a>() {}"#,
&["'a", "<'a>"]
);
do_check(
r#"fn foo<'a<|>>() {}"#,
&["'a", "<'a>"]
);
}
} }