This commit is contained in:
Lukas Wirth 2023-12-08 13:19:34 +01:00
parent 6abba17a5b
commit 1475848250
15 changed files with 516 additions and 550 deletions

View file

@ -940,9 +940,9 @@ impl Foo { fn foo(&self) { $0 } }"#,
expect![[r#"
fd self.field i32
lc self &Foo
sp Self
st Foo
bt u32
sp Self Foo
st Foo Foo
bt u32 u32
me self.foo() fn(&self)
"#]],
);
@ -954,9 +954,9 @@ impl Foo { fn foo(&mut self) { $0 } }"#,
expect![[r#"
fd self.0 i32
lc self &mut Foo
sp Self
st Foo
bt u32
sp Self Foo
st Foo Foo
bt u32 u32
me self.foo() fn(&mut self)
"#]],
);

View file

@ -417,10 +417,10 @@ impl Test for T {
}
",
expect![[r#"
sp Self
st T
sp Self T
st T T
tt Test
bt u32
bt u32 u32
"#]],
);
@ -526,10 +526,10 @@ impl Test for T {
}
",
expect![[r#"
sp Self
st T
sp Self T
st T T
tt Test
bt u32
bt u32 u32
"#]],
);
@ -543,10 +543,10 @@ impl Test for T {
}
",
expect![[r#"
sp Self
st T
sp Self T
st T T
tt Test
bt u32
bt u32 u32
"#]],
);
@ -562,10 +562,10 @@ impl Test for T {
}
",
expect![[r#"
sp Self
st T
sp Self T
st T T
tt Test
bt u32
bt u32 u32
"#]],
);
@ -610,10 +610,10 @@ impl Test for T {
}
",
expect![[r#"
sp Self
st T
sp Self T
st T T
tt Test
bt u32
bt u32 u32
"#]],
);

View file

@ -71,9 +71,9 @@ pub(crate) fn complete_use_path(
if add_resolution {
let mut builder = Builder::from_resolution(ctx, path_ctx, name, def);
builder.set_relevance(CompletionRelevance {
builder.with_relevance(|r| CompletionRelevance {
is_name_already_imported,
..Default::default()
..r
});
acc.add(builder.build(ctx.db));
}

View file

@ -1,6 +1,6 @@
//! See `CompletionItem` structure.
use std::fmt;
use std::{fmt, mem};
use hir::Mutability;
use ide_db::{
@ -570,6 +570,13 @@ impl Builder {
self.relevance = relevance;
self
}
pub(crate) fn with_relevance(
&mut self,
relevance: impl FnOnce(CompletionRelevance) -> CompletionRelevance,
) -> &mut Builder {
self.relevance = relevance(mem::take(&mut self.relevance));
self
}
pub(crate) fn trigger_call_info(&mut self) -> &mut Builder {
self.trigger_call_info = true;
self

View file

@ -10,7 +10,7 @@ pub(crate) mod variant;
pub(crate) mod union_literal;
pub(crate) mod literal;
use hir::{AsAssocItem, Function, HasAttrs, HirDisplay, ModuleDef, ScopeDef, Type};
use hir::{AsAssocItem, HasAttrs, HirDisplay, ModuleDef, ScopeDef, Type};
use ide_db::{
documentation::{Documentation, HasDocs},
helpers::item_name,
@ -393,10 +393,10 @@ fn render_resolution_path(
ScopeDef::ModuleDef(ModuleDef::Adt(adt)) | ScopeDef::AdtSelfType(adt) => {
set_item_relevance(adt.ty(db))
}
// Functions are handled at the start of the function.
ScopeDef::ModuleDef(ModuleDef::Function(_)) => (), // TODO: Should merge with the match case earlier in the function?
// Enum variants are handled at the start of the function.
ScopeDef::ModuleDef(ModuleDef::Variant(_)) => (),
// Filtered out above
ScopeDef::ModuleDef(
ModuleDef::Function(_) | ModuleDef::Variant(_) | ModuleDef::Macro(_),
) => (),
ScopeDef::ModuleDef(ModuleDef::Const(konst)) => set_item_relevance(konst.ty(db)),
ScopeDef::ModuleDef(ModuleDef::Static(stat)) => set_item_relevance(stat.ty(db)),
ScopeDef::ModuleDef(ModuleDef::BuiltinType(bt)) => set_item_relevance(bt.ty(db)),
@ -404,11 +404,12 @@ fn render_resolution_path(
ScopeDef::GenericParam(_)
| ScopeDef::Label(_)
| ScopeDef::Unknown
| ScopeDef::ModuleDef(ModuleDef::Trait(_))
| ScopeDef::ModuleDef(ModuleDef::TraitAlias(_))
| ScopeDef::ModuleDef(ModuleDef::Macro(_))
| ScopeDef::ModuleDef(ModuleDef::Module(_))
| ScopeDef::ModuleDef(ModuleDef::TypeAlias(_)) => (),
| ScopeDef::ModuleDef(
ModuleDef::Trait(_)
| ModuleDef::TraitAlias(_)
| ModuleDef::Module(_)
| ModuleDef::TypeAlias(_),
) => (),
};
item
@ -497,6 +498,7 @@ fn scope_def_is_deprecated(ctx: &RenderContext<'_>, resolution: ScopeDef) -> boo
}
}
// FIXME: This checks types without possible coercions which some completions might want to do
fn match_types(
ctx: &CompletionContext<'_>,
ty1: &hir::Type,
@ -526,41 +528,6 @@ fn compute_type_match(
match_types(ctx, expected_type, completion_ty)
}
fn compute_function_type_match(
ctx: &CompletionContext<'_>,
func: &Function,
) -> Option<CompletionRelevanceTypeMatch> {
// We compute a vec of function parameters + the return type for the expected
// type as well as the function we are matching with. Doing this allows for
// matching all of the types in one iterator.
let expected_callable = ctx.expected_type.as_ref()?.as_callable(ctx.db)?;
let expected_types = expected_callable.params(ctx.db).into_iter().map(|param| param.1);
let actual_types =
func.ty(ctx.db).as_callable(ctx.db)?.params(ctx.db).into_iter().map(|param| param.1);
if expected_types.len() != actual_types.len() {
return None;
}
let mut matches = expected_types
.zip(actual_types)
.chain([(expected_callable.return_type(), func.ret_type(ctx.db))])
.map(|(expected_type, actual_type)| match_types(ctx, &expected_type, &actual_type));
// Any missing type match indicates that these types can not be unified.
if matches.any(|type_match| type_match.is_none()) {
return None;
}
// If any of the types are unifiable but not exact we consider the function types as a whole
// to be unifiable. Otherwise if every pair of types is an exact match the functions are an
// exact type match.
matches
.find(|type_match| matches!(type_match, Some(CompletionRelevanceTypeMatch::CouldUnify)))
.unwrap_or(Some(CompletionRelevanceTypeMatch::Exact))
}
fn compute_exact_name_match(ctx: &CompletionContext<'_>, completion_name: &str) -> bool {
ctx.expected_name.as_ref().map_or(false, |name| name.text() == completion_name)
}
@ -812,7 +779,6 @@ fn main() {
);
}
// TODO: How dowe test ModuleDef::Variant(Variant?)
#[test]
fn set_enum_variant_type_completion_info() {
check_relevance(
@ -836,16 +802,14 @@ pub mod test_mod_a {
fn test(input: dep::test_mod_b::Enum) { }
fn main() {
test(Enum::Variant$0);
test(Variant$0);
}
"#,
expect![[r#"
ev dep::test_mod_b::Enum::Variant [type_could_unify]
en Enum (use dep::test_mod_b::Enum) [type_could_unify+requires_import]
fn main() []
fn test() []
md dep []
en Enum (use dep::test_mod_a::Enum) [requires_import]
"#]],
);
}
@ -857,13 +821,11 @@ fn main() {
//- /lib.rs crate:dep
pub mod test_mod_b {
pub fn Function(j: isize) -> i32 {
}
pub fn function(j: isize) -> i32 {}
}
pub mod test_mod_a {
pub fn Function(i: usize) -> i32 {
}
pub fn function(i: usize) -> i32 {}
}
//- /main.rs crate:main deps:dep
@ -871,15 +833,15 @@ pub mod test_mod_b {
fn test(input: fn(usize) -> i32) { }
fn main() {
test(Function$0);
test(function$0);
}
"#,
expect![[r#"
fn Function (use dep::test_mod_a::Function) [type+requires_import]
fn main []
fn test []
md dep []
fn Function (use dep::test_mod_b::Function) [requires_import]
fn function (use dep::test_mod_a::function) [requires_import]
fn function (use dep::test_mod_b::function) [requires_import]
"#]],
);
}
@ -975,7 +937,7 @@ fn main() {
"#,
expect![[r#"
me Function [type]
me Function []
"#]],
);
}
@ -1424,6 +1386,7 @@ use self::E::*;
kind: SymbolKind(
Enum,
),
detail: "E",
documentation: Documentation(
"enum docs",
),
@ -1668,6 +1631,7 @@ fn go(world: &WorldSnapshot) { go(w$0) }
st WorldSnapshot {} []
st &WorldSnapshot {} [type]
st WorldSnapshot []
st &WorldSnapshot [type]
fn go() []
"#]],
);
@ -1767,6 +1731,7 @@ fn main() {
st S []
st &mut S [type]
st S []
st &mut S [type]
fn foo() []
fn main() []
"#]],
@ -1783,7 +1748,7 @@ fn main() {
expect![[r#"
lc s [type+name+local]
st S [type]
st S []
st S [type]
fn foo() []
fn main() []
"#]],
@ -1800,7 +1765,7 @@ fn main() {
expect![[r#"
lc ssss [type+local]
st S [type]
st S []
st S [type]
fn foo() []
fn main() []
"#]],
@ -1839,7 +1804,9 @@ fn main() {
st S []
st &S [type]
st S []
st &S [type]
st T []
st &T [type]
fn foo() []
fn main() []
md core []
@ -1885,7 +1852,9 @@ fn main() {
st S []
st &mut S [type]
st S []
st &mut S [type]
st T []
st &mut T [type]
fn foo() []
fn main() []
md core []
@ -1924,7 +1893,7 @@ fn bar(t: Foo) {}
expect![[r#"
ev Foo::A [type]
ev Foo::B [type]
en Foo []
en Foo [type]
fn bar() []
fn foo() []
"#]],
@ -1947,6 +1916,7 @@ fn bar(t: &Foo) {}
ev Foo::B []
ev &Foo::B [type]
en Foo []
en &Foo [type]
fn bar() []
fn foo() []
"#]],
@ -1980,7 +1950,9 @@ fn main() {
st S []
st &S [type]
st S []
st &S [type]
st T []
st &T [type]
fn bar() []
fn &bar() [type]
fn foo() []
@ -2189,8 +2161,8 @@ fn foo() {
lc foo [type+local]
ev Foo::A() [type_could_unify]
ev Foo::B [type_could_unify]
en Foo [type_could_unify]
fn foo() []
en Foo []
fn bar() []
fn baz() []
"#]],

View file

@ -9,9 +9,7 @@ use syntax::{AstNode, SmolStr};
use crate::{
context::{CompletionContext, DotAccess, DotAccessKind, PathCompletionCtx, PathKind},
item::{Builder, CompletionItem, CompletionItemKind, CompletionRelevance},
render::{
compute_exact_name_match, compute_function_type_match, compute_ref_match, RenderContext,
},
render::{compute_exact_name_match, compute_ref_match, compute_type_match, RenderContext},
CallableSnippets,
};
@ -81,8 +79,30 @@ fn render(
.and_then(|trait_| trait_.containing_trait_or_trait_impl(ctx.db()))
.map_or(false, |trait_| completion.is_ops_trait(trait_));
let (has_dot_receiver, has_call_parens, cap) = match func_kind {
FuncKind::Function(&PathCompletionCtx {
kind: PathKind::Expr { .. },
has_call_parens,
..
}) => (false, has_call_parens, ctx.completion.config.snippet_cap),
FuncKind::Method(&DotAccess { kind: DotAccessKind::Method { has_parens }, .. }, _) => {
(true, has_parens, ctx.completion.config.snippet_cap)
}
FuncKind::Method(DotAccess { kind: DotAccessKind::Field { .. }, .. }, _) => {
(true, false, ctx.completion.config.snippet_cap)
}
_ => (false, false, None),
};
let complete_call_parens = cap
.filter(|_| !has_call_parens)
.and_then(|cap| Some((cap, params(ctx.completion, func, &func_kind, has_dot_receiver)?)));
item.set_relevance(CompletionRelevance {
type_match: compute_function_type_match(completion, &func),
type_match: if has_call_parens || complete_call_parens.is_some() {
compute_type_match(completion, &ret_type)
} else {
compute_type_match(completion, &func.ty(db))
},
exact_name_match: compute_exact_name_match(completion, &call),
is_op_method,
..ctx.completion_relevance()
@ -112,42 +132,9 @@ fn render(
.detail(detail)
.lookup_by(name.unescaped().to_smol_str());
match ctx.completion.config.snippet_cap {
Some(cap) => {
let complete_params = match func_kind {
FuncKind::Function(PathCompletionCtx {
kind: PathKind::Expr { .. },
has_call_parens: false,
..
}) => Some(false),
FuncKind::Method(
DotAccess {
kind:
DotAccessKind::Method { has_parens: false } | DotAccessKind::Field { .. },
..
},
_,
) => Some(true),
_ => None,
};
if let Some(has_dot_receiver) = complete_params {
if let Some((self_param, params)) =
params(ctx.completion, func, &func_kind, has_dot_receiver)
{
add_call_parens(
&mut item,
completion,
cap,
call,
escaped_call,
self_param,
params,
);
if let Some((cap, (self_param, params))) = complete_call_parens {
add_call_parens(&mut item, completion, cap, call, escaped_call, self_param, params);
}
}
}
_ => (),
};
match ctx.import_to_add {
Some(import_to_add) => {

View file

@ -26,22 +26,22 @@ fn baz() {
"#,
// This should not contain `FooDesc {…}`.
expect![[r#"
ct CONST
en Enum
ct CONST Unit
en Enum Enum
fn baz() fn()
fn create_foo() fn(&FooDesc)
fn function() fn()
ma makro!() macro_rules! makro
md _69latrick
md module
sc STATIC
st FooDesc
st Record
st Tuple
st Unit
un Union
sc STATIC Unit
st FooDesc FooDesc
st Record Record
st Tuple Tuple
st Unit Unit
un Union Union
ev TupleV() TupleV(u32)
bt u32
bt u32 u32
kw crate::
kw false
kw for
@ -83,7 +83,7 @@ fn func(param0 @ (param1, param2): (i32, i32)) {
lc param0 (i32, i32)
lc param1 i32
lc param2 i32
bt u32
bt u32 u32
kw crate::
kw false
kw for
@ -117,24 +117,24 @@ impl Unit {
"#,
// `self` is in here twice, once as the module, once as the local
expect![[r#"
ct CONST
ct CONST Unit
cp CONST_PARAM
en Enum
en Enum Enum
fn function() fn()
fn local_func() fn()
lc self Unit
ma makro!() macro_rules! makro
md module
md qualified
sp Self
sc STATIC
st Record
st Tuple
st Unit
sp Self Unit
sc STATIC Unit
st Record Record
st Tuple Tuple
st Unit Unit
tp TypeParam
un Union
un Union Union
ev TupleV() TupleV(u32)
bt u32
bt u32 u32
kw const
kw crate::
kw enum
@ -181,18 +181,18 @@ impl Unit {
}
"#,
expect![[r#"
ct CONST
en Enum
ct CONST Unit
en Enum Enum
fn function() fn()
ma makro!() macro_rules! makro
md module
md qualified
sc STATIC
st Record
st Tuple
st Unit
sc STATIC Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
un Union
un Union Union
ev TupleV() TupleV(u32)
?? Unresolved
"#]],
@ -211,7 +211,7 @@ fn complete_in_block() {
"#,
expect![[r#"
fn foo() fn()
bt u32
bt u32 u32
kw const
kw crate::
kw enum
@ -256,7 +256,7 @@ fn complete_after_if_expr() {
"#,
expect![[r#"
fn foo() fn()
bt u32
bt u32 u32
kw const
kw crate::
kw else
@ -304,7 +304,7 @@ fn complete_in_match_arm() {
"#,
expect![[r#"
fn foo() fn()
bt u32
bt u32 u32
kw crate::
kw false
kw for
@ -328,7 +328,7 @@ fn completes_in_loop_ctx() {
r"fn my() { loop { $0 } }",
expect![[r#"
fn my() fn()
bt u32
bt u32 u32
kw break
kw const
kw continue
@ -370,7 +370,7 @@ fn completes_in_let_initializer() {
r#"fn main() { let _ = $0 }"#,
expect![[r#"
fn main() fn()
bt u32
bt u32 u32
kw crate::
kw false
kw for
@ -403,8 +403,8 @@ fn foo() {
"#,
expect![[r#"
fn foo() fn()
st Foo
bt u32
st Foo Foo
bt u32 u32
kw crate::
kw false
kw for
@ -439,7 +439,7 @@ fn foo() {
expect![[r#"
fn foo() fn()
lc bar i32
bt u32
bt u32 u32
kw crate::
kw false
kw for
@ -470,7 +470,7 @@ fn quux(x: i32) {
fn quux() fn(i32)
lc x i32
ma m!() macro_rules! m
bt u32
bt u32 u32
kw crate::
kw false
kw for
@ -497,7 +497,7 @@ fn quux(x: i32) {
fn quux() fn(i32)
lc x i32
ma m!() macro_rules! m
bt u32
bt u32 u32
kw crate::
kw false
kw for
@ -683,11 +683,11 @@ fn brr() {
}
"#,
expect![[r#"
en HH
en HH HH
fn brr() fn()
st YoloVariant
st YoloVariant YoloVariant
st YoloVariant {} YoloVariant { f: usize }
bt u32
bt u32 u32
kw crate::
kw false
kw for
@ -749,7 +749,7 @@ fn foo() { if foo {} $0 }
"#,
expect![[r#"
fn foo() fn()
bt u32
bt u32 u32
kw const
kw crate::
kw else
@ -789,7 +789,7 @@ fn foo() { if foo {} el$0 }
"#,
expect![[r#"
fn foo() fn()
bt u32
bt u32 u32
kw const
kw crate::
kw else
@ -829,7 +829,7 @@ fn foo() { bar(if foo {} $0) }
"#,
expect![[r#"
fn foo() fn()
bt u32
bt u32 u32
kw crate::
kw else
kw else if
@ -853,7 +853,7 @@ fn foo() { bar(if foo {} el$0) }
"#,
expect![[r#"
fn foo() fn()
bt u32
bt u32 u32
kw crate::
kw else
kw else if
@ -877,7 +877,7 @@ fn foo() { if foo {} $0 let x = 92; }
"#,
expect![[r#"
fn foo() fn()
bt u32
bt u32 u32
kw const
kw crate::
kw else
@ -917,7 +917,7 @@ fn foo() { if foo {} el$0 let x = 92; }
"#,
expect![[r#"
fn foo() fn()
bt u32
bt u32 u32
kw const
kw crate::
kw else
@ -957,7 +957,7 @@ fn foo() { if foo {} el$0 { let x = 92; } }
"#,
expect![[r#"
fn foo() fn()
bt u32
bt u32 u32
kw const
kw crate::
kw else
@ -1009,7 +1009,7 @@ pub struct UnstableThisShouldNotBeListed;
expect![[r#"
fn main() fn()
md std
bt u32
bt u32 u32
kw const
kw crate::
kw enum
@ -1060,8 +1060,8 @@ pub struct UnstableButWeAreOnNightlyAnyway;
expect![[r#"
fn main() fn()
md std
st UnstableButWeAreOnNightlyAnyway
bt u32
st UnstableButWeAreOnNightlyAnyway UnstableButWeAreOnNightlyAnyway
bt u32 u32
kw const
kw crate::
kw enum

View file

@ -139,10 +139,10 @@ fn main() {
}
"#,
expect![[r#"
st Rc (use dep::Rc)
st Rcar (use dep::Rcar)
st Rc (use dep::some_module::Rc)
st Rcar (use dep::some_module::Rcar)
st Rc (use dep::Rc) Rc
st Rcar (use dep::Rcar) Rcar
st Rc (use dep::some_module::Rc) Rc
st Rcar (use dep::some_module::Rcar) Rcar
"#]],
);
check(
@ -165,12 +165,12 @@ fn main() {
}
"#,
expect![[r#"
ct RC (use dep::RC)
st Rc (use dep::Rc)
st Rcar (use dep::Rcar)
ct RC (use dep::some_module::RC)
st Rc (use dep::some_module::Rc)
st Rcar (use dep::some_module::Rcar)
ct RC (use dep::RC) ()
st Rc (use dep::Rc) Rc
st Rcar (use dep::Rcar) Rcar
ct RC (use dep::some_module::RC) ()
st Rc (use dep::some_module::Rc) Rc
st Rcar (use dep::some_module::Rcar) Rcar
"#]],
);
check(
@ -193,8 +193,8 @@ fn main() {
}
"#,
expect![[r#"
ct RC (use dep::RC)
ct RC (use dep::some_module::RC)
ct RC (use dep::RC) ()
ct RC (use dep::some_module::RC) ()
"#]],
);
}
@ -227,9 +227,9 @@ fn main() {
}
"#,
expect![[r#"
st ThirdStruct (use dep::some_module::ThirdStruct)
st AfterThirdStruct (use dep::some_module::AfterThirdStruct)
st ThiiiiiirdStruct (use dep::some_module::ThiiiiiirdStruct)
st ThirdStruct (use dep::some_module::ThirdStruct) ThirdStruct
st AfterThirdStruct (use dep::some_module::AfterThirdStruct) AfterThirdStruct
st ThiiiiiirdStruct (use dep::some_module::ThiiiiiirdStruct) ThiiiiiirdStruct
"#]],
);
}
@ -309,7 +309,7 @@ fn trait_const_fuzzy_completion() {
check(
fixture,
expect![[r#"
ct SPECIAL_CONST (use dep::test_mod::TestTrait)
ct SPECIAL_CONST (use dep::test_mod::TestTrait) u8
"#]],
);
@ -597,7 +597,7 @@ fn main() {
}
"#,
expect![[r#"
ct SPECIAL_CONST (use dep::test_mod::TestTrait) DEPRECATED
ct SPECIAL_CONST (use dep::test_mod::TestTrait) u8 DEPRECATED
fn weird_function() (use dep::test_mod::TestTrait) fn() DEPRECATED
"#]],
);
@ -717,7 +717,7 @@ fn main() {
check(
fixture,
expect![[r#"
st Item (use foo::bar::baz::Item)
st Item (use foo::bar::baz::Item) Item
"#]],
);
@ -759,7 +759,7 @@ fn main() {
check(
fixture,
expect![[r#"
ct TEST_ASSOC (use foo::Item)
ct TEST_ASSOC (use foo::Item) usize
"#]],
);
@ -803,7 +803,7 @@ fn main() {
check(
fixture,
expect![[r#"
ct TEST_ASSOC (use foo::bar::Item)
ct TEST_ASSOC (use foo::bar::Item) usize
"#]],
);
@ -897,7 +897,7 @@ fn main() {
TES$0
}"#,
expect![[r#"
ct TEST_CONST (use foo::TEST_CONST)
ct TEST_CONST (use foo::TEST_CONST) usize
"#]],
);
@ -914,7 +914,7 @@ fn main() {
tes$0
}"#,
expect![[r#"
ct TEST_CONST (use foo::TEST_CONST)
ct TEST_CONST (use foo::TEST_CONST) usize
fn test_function() (use foo::test_function) fn() -> i32
"#]],
);
@ -1138,7 +1138,7 @@ mod mud {
}
"#,
expect![[r#"
st Struct (use crate::Struct)
st Struct (use crate::Struct) Struct
"#]],
);
}
@ -1250,7 +1250,7 @@ enum Foo {
}
}"#,
expect![[r#"
st Barbara (use foo::Barbara)
st Barbara (use foo::Barbara) Barbara
"#]],
)
}

View file

@ -18,15 +18,15 @@ fn target_type_or_trait_in_impl_block() {
impl Tra$0
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
@ -40,15 +40,15 @@ fn target_type_in_trait_impl_block() {
impl Trait for Str$0
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],

View file

@ -435,7 +435,7 @@ fn foo() {
}
"#,
expect![[r#"
st Bar
st Bar Bar
kw crate::
kw self::
"#]],
@ -450,7 +450,7 @@ fn foo() {
}
"#,
expect![[r#"
st Foo
st Foo Foo
kw crate::
kw self::
"#]],

View file

@ -16,16 +16,16 @@ fn predicate_start() {
struct Foo<'lt, T, const C: usize> where $0 {}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Foo<>
st Record
st Tuple
st Unit
st Foo<> Foo<'_, {unknown}, _>
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
@ -89,16 +89,16 @@ fn param_list_for_for_pred() {
struct Foo<'lt, T, const C: usize> where for<'a> $0 {}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Foo<>
st Record
st Tuple
st Unit
st Foo<> Foo<'_, {unknown}, _>
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
@ -114,16 +114,16 @@ impl Record {
}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
sp Self
st Record
st Tuple
st Unit
sp Self Record
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],

View file

@ -186,10 +186,10 @@ fn main() {
lc foo Foo
lc thing i32
md core
st Foo
st Foo Foo
st Foo {} Foo { foo1: u32, foo2: u32 }
tt Default
bt u32
bt u32 u32
kw crate::
kw self::
"#]],

View file

@ -85,8 +85,8 @@ pub mod prelude {
"#,
expect![[r#"
md std
st Option
bt u32
st Option Option
bt u32 u32
"#]],
);
}
@ -115,7 +115,7 @@ mod macros {
fn f() fn()
ma concat!() macro_rules! concat
md std
bt u32
bt u32 u32
"#]],
);
}
@ -144,8 +144,8 @@ pub mod prelude {
expect![[r#"
md core
md std
st String
bt u32
st String String
bt u32 u32
"#]],
);
}
@ -173,7 +173,7 @@ pub mod prelude {
expect![[r#"
fn f() fn()
md std
bt u32
bt u32 u32
"#]],
);
}
@ -446,9 +446,9 @@ mod p {
}
"#,
expect![[r#"
ct RIGHT_CONST
ct RIGHT_CONST u32
fn right_fn() fn()
st RightType
st RightType WrongType
"#]],
);
@ -881,7 +881,7 @@ fn main() {
fn main() fn()
lc foobar i32
ma x!() macro_rules! x
bt u32
bt u32 u32
"#]],
)
}
@ -1008,8 +1008,8 @@ fn here_we_go() {
"#,
expect![[r#"
fn here_we_go() fn()
st Foo (alias Bar)
bt u32
st Foo (alias Bar) Foo
bt u32 u32
kw const
kw crate::
kw enum
@ -1057,8 +1057,8 @@ fn here_we_go() {
"#,
expect![[r#"
fn here_we_go() fn()
st Foo (alias Bar, Qux, Baz)
bt u32
st Foo (alias Bar, Qux, Baz) Foo
bt u32 u32
kw const
kw crate::
kw enum
@ -1178,7 +1178,7 @@ fn bar() { qu$0 }
expect![[r#"
fn bar() fn()
fn foo() (alias qux) fn()
bt u32
bt u32 u32
kw const
kw crate::
kw enum
@ -1227,7 +1227,7 @@ fn here_we_go() {
}
"#,
expect![[r#"
st Bar (alias Qux)
st Bar (alias Qux) Bar
"#]],
);
}
@ -1246,7 +1246,7 @@ fn here_we_go() {
}
"#,
expect![[r#"
st Bar (alias Qux)
st Bar (alias Qux) Bar
"#]],
);
}
@ -1267,8 +1267,8 @@ fn here_we_go() {
expect![[r#"
fn here_we_go() fn()
md foo
st Bar (alias Qux) (use foo::Bar)
bt u32
st Bar (alias Qux) (use foo::Bar) Bar
bt u32 u32
kw crate::
kw false
kw for
@ -1409,7 +1409,7 @@ fn foo() {
Some('_'),
expect![[r#"
fn foo() fn()
bt u32
bt u32 u32
kw const
kw crate::
kw enum
@ -1461,7 +1461,7 @@ fn foo(_: a_$0) { }
"#,
Some('_'),
expect![[r#"
bt u32
bt u32 u32
kw crate::
kw self::
"#]],
@ -1475,7 +1475,7 @@ fn foo<T>() {
Some('_'),
expect![[r#"
tp T
bt u32
bt u32 u32
kw crate::
kw self::
"#]],

View file

@ -17,18 +17,18 @@ struct Foo<'lt, T, const C: usize> {
}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
sp Self
st Foo<>
st Record
st Tuple
st Unit
sp Self Foo<'_, {unknown}, _>
st Foo<> Foo<'_, {unknown}, _>
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
tp T
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
@ -42,18 +42,18 @@ fn tuple_struct_field() {
struct Foo<'lt, T, const C: usize>(f$0);
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
sp Self
st Foo<>
st Record
st Tuple
st Unit
sp Self Foo<'_, {unknown}, _>
st Foo<> Foo<'_, {unknown}, _>
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
tp T
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw pub
kw pub(crate)
@ -70,16 +70,16 @@ fn fn_return_type() {
fn x<'lt, T, const C: usize>() -> $0
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
tp T
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
@ -100,15 +100,15 @@ fn foo() -> B$0 {
}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
it ()
kw crate::
kw self::
@ -124,16 +124,16 @@ struct Foo<T>(T);
const FOO: $0 = Foo(2);
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Foo<>
st Record
st Tuple
st Unit
st Foo<> Foo<{unknown}>
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
it Foo<i32>
kw crate::
kw self::
@ -151,15 +151,15 @@ fn f2() {
}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
it i32
kw crate::
kw self::
@ -179,15 +179,15 @@ fn f2() {
}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
it u64
kw crate::
kw self::
@ -204,15 +204,15 @@ fn f2(x: u64) -> $0 {
}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
it u64
kw crate::
kw self::
@ -230,15 +230,15 @@ fn f2(x: $0) {
}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
it i32
kw crate::
kw self::
@ -262,17 +262,17 @@ fn foo<'lt, T, const C: usize>() {
}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md a
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
tp T
un Union
bt u32
un Union Union
bt u32 u32
it a::Foo<a::Foo<i32>>
kw crate::
kw self::
@ -291,17 +291,17 @@ fn foo<'lt, T, const C: usize>() {
}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Foo<>
st Record
st Tuple
st Unit
st Foo<> Foo<{unknown}>
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
tp T
un Union
bt u32
un Union Union
bt u32 u32
it Foo<i32>
kw crate::
kw self::
@ -319,16 +319,16 @@ fn foo<'lt, T, const C: usize>() {
}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
tp T
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
@ -341,14 +341,14 @@ fn foo<'lt, T, const C: usize>() {
}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
un Union
un Union Union
"#]],
);
}
@ -384,18 +384,18 @@ trait Trait2<T>: Trait1 {
fn foo<'lt, T: Trait2<$0>, const CONST_PARAM: usize>(_: T) {}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
tt Trait1
tt Trait2
tp T
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
@ -409,15 +409,15 @@ trait Trait2<T> {
fn foo<'lt, T: Trait2<self::$0>, const CONST_PARAM: usize>(_: T) {}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
tt Trait2
un Union
un Union Union
"#]],
);
}
@ -434,18 +434,18 @@ trait Tr<T> {
impl Tr<$0
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
sp Self
st Record
st S
st Tuple
st Unit
sp Self dyn Tr<{unknown}>
st Record Record
st S S
st Tuple Tuple
st Unit Unit
tt Tr
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
@ -481,16 +481,16 @@ trait MyTrait<T, U> {
fn f(t: impl MyTrait<u$0
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt MyTrait
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
@ -506,16 +506,16 @@ trait MyTrait<T, U> {
fn f(t: impl MyTrait<u8, u$0
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt MyTrait
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
@ -549,16 +549,16 @@ trait MyTrait<T, U = u8> {
fn f(t: impl MyTrait<u$0
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt MyTrait
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
@ -574,18 +574,18 @@ trait MyTrait<T, U = u8> {
fn f(t: impl MyTrait<u8, u$0
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt MyTrait
tt Trait
ta Item1 = (as MyTrait) type Item1
ta Item2 = (as MyTrait) type Item2
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
@ -619,16 +619,16 @@ trait MyTrait {
fn f(t: impl MyTrait<Item1 = $0
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt MyTrait
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
@ -644,16 +644,16 @@ trait MyTrait {
fn f(t: impl MyTrait<Item1 = u8, Item2 = $0
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
st Record Record
st Tuple Tuple
st Unit Unit
tt MyTrait
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
@ -668,7 +668,7 @@ trait MyTrait {
fn f(t: impl MyTrait<C = $0
"#,
expect![[r#"
ct CONST
ct CONST Unit
ma makro!() macro_rules! makro
kw crate::
kw self::
@ -691,9 +691,9 @@ pub struct S;
"#,
expect![[r#"
md std
sp Self
st Foo
bt u32
sp Self Foo
st Foo Foo
bt u32 u32
kw crate::
kw self::
"#]],
@ -716,10 +716,10 @@ pub struct S;
"#,
expect![[r#"
md std
sp Self
st Foo
st S
bt u32
sp Self Foo
st Foo Foo
st S S
bt u32 u32
kw crate::
kw self::
"#]],
@ -739,16 +739,16 @@ fn completes_const_and_type_generics_separately() {
}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Foo
st Record
st Tuple
st Unit
st Foo Foo
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
@ -766,8 +766,8 @@ fn completes_const_and_type_generics_separately() {
}
"#,
expect![[r#"
ct CONST
ct X
ct CONST Unit
ct X usize
ma makro!() macro_rules! makro
kw crate::
kw self::
@ -785,16 +785,16 @@ fn completes_const_and_type_generics_separately() {
}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Foo
st Record
st Tuple
st Unit
st Foo Foo
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
@ -809,8 +809,8 @@ fn completes_const_and_type_generics_separately() {
}
"#,
expect![[r#"
ct CONST
ct X
ct CONST Unit
ct X usize
ma makro!() macro_rules! makro
kw crate::
kw self::
@ -828,17 +828,17 @@ fn completes_const_and_type_generics_separately() {
fn foo(_: impl Bar<Baz<F$0, 0> = ()>) {}
"#,
expect![[r#"
en Enum
en Enum Enum
ma makro!() macro_rules! makro
md module
st Foo
st Record
st Tuple
st Unit
st Foo Foo
st Record Record
st Tuple Tuple
st Unit Unit
tt Bar
tt Trait
un Union
bt u32
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
@ -853,8 +853,8 @@ fn completes_const_and_type_generics_separately() {
fn foo<T: Bar<Baz<(), $0> = ()>>() {}
"#,
expect![[r#"
ct CONST
ct X
ct CONST Unit
ct X usize
ma makro!() macro_rules! makro
kw crate::
kw self::
@ -871,8 +871,8 @@ fn completes_const_and_type_generics_separately() {
}
"#,
expect![[r#"
ct CONST
ct X
ct CONST Unit
ct X usize
ma makro!() macro_rules! makro
kw crate::
kw self::
@ -890,8 +890,8 @@ fn completes_const_and_type_generics_separately() {
}
"#,
expect![[r#"
ct CONST
ct X
ct CONST Unit
ct X usize
ma makro!() macro_rules! makro
kw crate::
kw self::
@ -908,8 +908,8 @@ fn completes_const_and_type_generics_separately() {
}
"#,
expect![[r#"
ct CONST
ct X
ct CONST Unit
ct X usize
ma makro!() macro_rules! makro
kw crate::
kw self::
@ -924,8 +924,8 @@ fn completes_const_and_type_generics_separately() {
impl Foo<(), $0> for () {}
"#,
expect![[r#"
ct CONST
ct X
ct CONST Unit
ct X usize
ma makro!() macro_rules! makro
kw crate::
kw self::
@ -942,8 +942,8 @@ fn completes_const_and_type_generics_separately() {
fn foo<T: Bar<X$0, ()>>() {}
"#,
expect![[r#"
ct CONST
ct X
ct CONST Unit
ct X usize
ma makro!() macro_rules! makro
kw crate::
kw self::
@ -957,7 +957,7 @@ struct S<'a, 'b, const C: usize, T>(core::marker::PhantomData<&'a &'b T>);
fn foo<'a>() { S::<F$0, _>; }
"#,
expect![[r#"
ct CONST
ct CONST Unit
ma makro!() macro_rules! makro
kw crate::
kw self::
@ -970,7 +970,7 @@ struct S<'a, 'b, const C: usize, T>(core::marker::PhantomData<&'a &'b T>);
fn foo<'a>() { S::<'static, 'static, F$0, _>; }
"#,
expect![[r#"
ct CONST
ct CONST Unit
ma makro!() macro_rules! makro
kw crate::
kw self::

View file

@ -65,7 +65,7 @@ use self::{foo::*, bar$0};
"#,
expect![[r#"
md foo
st S
st S S
"#]],
);
}
@ -82,7 +82,7 @@ mod foo {
use foo::{bar::$0}
"#,
expect![[r#"
st FooBar
st FooBar FooBar
"#]],
);
check(
@ -115,7 +115,7 @@ mod foo {
use foo::{bar::{baz::$0}}
"#,
expect![[r#"
st FooBarBaz
st FooBarBaz FooBarBaz
"#]],
);
check(
@ -152,7 +152,7 @@ struct Bar;
"#,
expect![[r#"
ma foo macro_rules! foo_
st Foo
st Foo Foo
"#]],
);
}
@ -193,7 +193,7 @@ struct Bar;
"#,
expect![[r#"
md foo
st Bar
st Bar Bar
"#]],
);
}
@ -212,7 +212,7 @@ struct Bar;
expect![[r#"
md bar
md foo
st Bar
st Bar Bar
"#]],
);
}
@ -230,7 +230,7 @@ mod a {
}
"#,
expect![[r#"
ct A
ct A usize
md b
kw super::
"#]],
@ -248,7 +248,7 @@ struct Bar;
"#,
expect![[r#"
md foo
st Bar
st Bar Bar
"#]],
);
}
@ -265,7 +265,7 @@ pub mod foo {}
"#,
expect![[r#"
md foo
st Foo
st Foo Foo
"#]],
);
}
@ -425,7 +425,7 @@ marco_rules! m { () => {} }
expect![[r#"
fn foo fn()
md simd
st S
st S S
"#]],
);
}