Skip to content

Commit

Permalink
Merge #6946
Browse files Browse the repository at this point in the history
6946: Better fuzzy heuristics r=matklad a=SomeoneToIgnore

Continuation of the #6922, mainly created for a test.

Turns out our current completions tests were sorting the completions by label, I had to remove that to test the order properly and update this order in a bunch of tests (ergo the changes)

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
  • Loading branch information
bors[bot] and SomeoneToIgnore authored Dec 19, 2020
2 parents 8b73135 + b45ec84 commit 052e722
Show file tree
Hide file tree
Showing 12 changed files with 263 additions and 216 deletions.
16 changes: 8 additions & 8 deletions crates/completion/src/completions/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ struct Test {}
at Hash
at PartialEq
at PartialEq, Eq
at PartialEq, Eq, PartialOrd, Ord
at PartialEq, PartialOrd
at PartialEq, Eq, PartialOrd, Ord
"#]],
);
}
Expand Down Expand Up @@ -457,10 +457,10 @@ struct Test {}
at Clone, Copy
at Debug
at Default
at Eq
at Eq, PartialOrd, Ord
at Hash
at Eq
at PartialOrd
at Eq, PartialOrd, Ord
"#]],
)
}
Expand All @@ -472,14 +472,14 @@ struct Test {}
expect![[r#"
at allow(…)
at automatically_derived
at cfg(…)
at cfg_attr(…)
at cfg(…)
at cold
at deny(…)
at deprecated = "…"
at derive(…)
at doc = "…"
at export_name = "…"
at doc = "…"
at forbid(…)
at ignore = "…"
at inline(…)
Expand Down Expand Up @@ -518,15 +518,15 @@ struct Test {}
expect![[r#"
at allow(…)
at automatically_derived
at cfg(…)
at cfg_attr(…)
at cfg(…)
at cold
at crate_name = ""
at deny(…)
at deprecated = "…"
at derive(…)
at doc = "…"
at export_name = "…"
at doc = "…"
at feature(…)
at forbid(…)
at global_allocator
Expand All @@ -538,8 +538,8 @@ struct Test {}
at macro_export
at macro_use
at must_use = "…"
at no_implicit_prelude
at no_link
at no_implicit_prelude
at no_main
at no_mangle
at no_std
Expand Down
8 changes: 4 additions & 4 deletions crates/completion/src/completions/dot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ impl S {
fn foo(s: S) { s.<|> }
"#,
expect![[r#"
me bar() fn bar(&self)
fd foo u32
me bar() fn bar(&self)
"#]],
);
}
Expand All @@ -98,8 +98,8 @@ impl S {
}
"#,
expect![[r#"
me foo() fn foo(self)
fd the_field (u32,)
me foo() fn foo(self)
"#]],
)
}
Expand All @@ -114,8 +114,8 @@ impl A {
}
"#,
expect![[r#"
me foo() fn foo(&self)
fd the_field (u32, i32)
me foo() fn foo(&self)
"#]],
)
}
Expand Down Expand Up @@ -147,8 +147,8 @@ mod inner {
fn foo(a: inner::A) { a.<|> }
"#,
expect![[r#"
fd crate_field u32
fd pub_field u32
fd crate_field u32
fd super_field u32
"#]],
);
Expand Down
142 changes: 71 additions & 71 deletions crates/completion/src/completions/keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,21 +223,21 @@ mod tests {
check(
r"m<|>",
expect![[r#"
kw const
kw enum
kw extern
kw fn
kw use
kw impl
kw mod
kw pub
kw pub(crate)
kw static
kw struct
kw trait
kw type
kw enum
kw struct
kw union
kw mod
kw const
kw type
kw static
kw extern
kw unsafe
kw use
kw pub(crate)
kw pub
"#]],
);
}
Expand All @@ -247,23 +247,23 @@ mod tests {
check(
r"fn quux() { <|> }",
expect![[r#"
kw const
kw extern
kw fn
kw use
kw impl
kw trait
kw match
kw while
kw loop
kw if
kw if let
kw impl
kw let
kw loop
kw match
kw mod
kw return
kw static
kw trait
kw const
kw type
kw static
kw extern
kw unsafe
kw use
kw while
kw return
"#]],
);
}
Expand All @@ -273,23 +273,23 @@ mod tests {
check(
r"fn quux() { if true { <|> } }",
expect![[r#"
kw const
kw extern
kw fn
kw use
kw impl
kw trait
kw match
kw while
kw loop
kw if
kw if let
kw impl
kw let
kw loop
kw match
kw mod
kw return
kw static
kw trait
kw const
kw type
kw static
kw extern
kw unsafe
kw use
kw while
kw return
"#]],
);
}
Expand All @@ -299,25 +299,25 @@ mod tests {
check(
r#"fn quux() { if true { () } <|> }"#,
expect![[r#"
kw const
kw else
kw else if
kw extern
kw fn
kw use
kw impl
kw trait
kw match
kw while
kw loop
kw if
kw if let
kw impl
kw let
kw loop
kw match
kw else
kw else if
kw mod
kw return
kw static
kw trait
kw const
kw type
kw static
kw extern
kw unsafe
kw use
kw while
kw return
"#]],
);
check_edit(
Expand All @@ -336,13 +336,13 @@ fn quux() -> i32 {
}
"#,
expect![[r#"
kw match
kw while
kw loop
kw if
kw if let
kw loop
kw match
kw return
kw unsafe
kw while
kw return
"#]],
);
}
Expand All @@ -352,8 +352,8 @@ fn quux() -> i32 {
check(
r"trait My { <|> }",
expect![[r#"
kw const
kw fn
kw const
kw type
kw unsafe
"#]],
Expand All @@ -365,12 +365,12 @@ fn quux() -> i32 {
check(
r"impl My { <|> }",
expect![[r#"
kw const
kw fn
kw pub
kw pub(crate)
kw const
kw type
kw unsafe
kw pub(crate)
kw pub
"#]],
);
}
Expand All @@ -380,25 +380,25 @@ fn quux() -> i32 {
check(
r"fn my() { loop { <|> } }",
expect![[r#"
kw break
kw const
kw continue
kw extern
kw fn
kw use
kw impl
kw trait
kw match
kw while
kw loop
kw if
kw if let
kw impl
kw let
kw loop
kw match
kw mod
kw return
kw static
kw trait
kw const
kw type
kw static
kw extern
kw unsafe
kw use
kw while
kw continue
kw break
kw return
"#]],
);
}
Expand All @@ -409,8 +409,8 @@ fn quux() -> i32 {
r"unsafe <|>",
expect![[r#"
kw fn
kw impl
kw trait
kw impl
"#]],
);
}
Expand All @@ -421,8 +421,8 @@ fn quux() -> i32 {
r"fn my_fn() { unsafe <|> }",
expect![[r#"
kw fn
kw impl
kw trait
kw impl
"#]],
);
}
Expand Down Expand Up @@ -542,12 +542,12 @@ pub mod future {
check(
r#"fn main() { let _ = <|> }"#,
expect![[r#"
kw match
kw while
kw loop
kw if
kw if let
kw loop
kw match
kw return
kw while
"#]],
)
}
Expand All @@ -562,8 +562,8 @@ struct Foo {
}
"#,
expect![[r#"
kw pub
kw pub(crate)
kw pub
"#]],
)
}
Expand Down Expand Up @@ -600,12 +600,12 @@ fn foo() {
}
"#,
expect![[r#"
kw match
kw while
kw loop
kw if
kw if let
kw loop
kw match
kw return
kw while
"#]],
);
}
Expand Down
Loading

0 comments on commit 052e722

Please sign in to comment.