Auto merge of #15627 - jmintb:sort_imports, r=Veykril

feat: Prioritize import suggestions based on the expected type

Hi, this is a draft PR to solve #15384. `Adt` types work and now I have a few questions :)

1. What other types make sense in this context? Looking at [ModuleDef](05666441ba/crates/hir/src/lib.rs (L275)) I am thinking everything except Modules.
2. Is there an existing way of converting between `ModeuleDef` and `hir::Type` in the rustanalyzer code base?
3. Does this approach seem sound to you?

Ups: Upon writing this I just realised that the enum test is invalided as there are no enum variants and this no variant is passed as a function argument.
This commit is contained in:
bors 2023-12-08 12:39:23 +00:00
commit b03a0bda18
15 changed files with 845 additions and 477 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, HasAttrs, HirDisplay, ScopeDef};
use hir::{AsAssocItem, HasAttrs, HirDisplay, ModuleDef, ScopeDef, Type};
use ide_db::{
documentation::{Documentation, HasDocs},
helpers::item_name,
@ -340,6 +340,7 @@ fn render_resolution_path(
let cap = ctx.snippet_cap();
let db = completion.db;
let config = completion.config;
let requires_import = import_to_add.is_some();
let name = local_name.to_smol_str();
let mut item = render_resolution_simple_(ctx, &local_name, import_to_add, resolution);
@ -370,8 +371,8 @@ fn render_resolution_path(
}
}
}
if let ScopeDef::Local(local) = resolution {
let ty = local.ty(db);
let mut set_item_relevance = |ty: Type| {
if !ty.is_unknown() {
item.detail(ty.display(db).to_string());
}
@ -379,12 +380,38 @@ fn render_resolution_path(
item.set_relevance(CompletionRelevance {
type_match: compute_type_match(completion, &ty),
exact_name_match: compute_exact_name_match(completion, &name),
is_local: true,
is_local: matches!(resolution, ScopeDef::Local(_)),
requires_import,
..CompletionRelevance::default()
});
path_ref_match(completion, path_ctx, &ty, &mut item);
};
match resolution {
ScopeDef::Local(local) => set_item_relevance(local.ty(db)),
ScopeDef::ModuleDef(ModuleDef::Adt(adt)) | ScopeDef::AdtSelfType(adt) => {
set_item_relevance(adt.ty(db))
}
// 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)),
ScopeDef::ImplSelfType(imp) => set_item_relevance(imp.self_ty(db)),
ScopeDef::GenericParam(_)
| ScopeDef::Label(_)
| ScopeDef::Unknown
| ScopeDef::ModuleDef(
ModuleDef::Trait(_)
| ModuleDef::TraitAlias(_)
| ModuleDef::Module(_)
| ModuleDef::TypeAlias(_),
) => (),
};
item
}
@ -471,6 +498,21 @@ 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,
ty2: &hir::Type,
) -> Option<CompletionRelevanceTypeMatch> {
if ty1 == ty2 {
Some(CompletionRelevanceTypeMatch::Exact)
} else if ty1.could_unify_with(ctx.db, ty2) {
Some(CompletionRelevanceTypeMatch::CouldUnify)
} else {
None
}
}
fn compute_type_match(
ctx: &CompletionContext<'_>,
completion_ty: &hir::Type,
@ -483,13 +525,7 @@ fn compute_type_match(
return None;
}
if completion_ty == expected_type {
Some(CompletionRelevanceTypeMatch::Exact)
} else if expected_type.could_unify_with(ctx.db, completion_ty) {
Some(CompletionRelevanceTypeMatch::CouldUnify)
} else {
None
}
match_types(ctx, expected_type, completion_ty)
}
fn compute_exact_name_match(ctx: &CompletionContext<'_>, completion_name: &str) -> bool {
@ -635,6 +671,330 @@ mod tests {
}
}
#[test]
fn set_struct_type_completion_info() {
check_relevance(
r#"
//- /lib.rs crate:dep
pub mod test_mod_b {
pub struct Struct {}
}
pub mod test_mod_a {
pub struct Struct {}
}
//- /main.rs crate:main deps:dep
fn test(input: dep::test_mod_b::Struct) { }
fn main() {
test(Struct$0);
}
"#,
expect![[r#"
st dep::test_mod_b::Struct {} [type_could_unify]
st Struct (use dep::test_mod_b::Struct) [type_could_unify+requires_import]
fn main() []
fn test() []
md dep []
st Struct (use dep::test_mod_a::Struct) [requires_import]
"#]],
);
}
#[test]
fn set_union_type_completion_info() {
check_relevance(
r#"
//- /lib.rs crate:dep
pub mod test_mod_b {
pub union Union {
a: i32,
b: i32
}
}
pub mod test_mod_a {
pub enum Union {
a: i32,
b: i32
}
}
//- /main.rs crate:main deps:dep
fn test(input: dep::test_mod_b::Union) { }
fn main() {
test(Union$0);
}
"#,
expect![[r#"
un Union (use dep::test_mod_b::Union) [type_could_unify+requires_import]
fn main() []
fn test() []
md dep []
en Union (use dep::test_mod_a::Union) [requires_import]
"#]],
);
}
#[test]
fn set_enum_type_completion_info() {
check_relevance(
r#"
//- /lib.rs crate:dep
pub mod test_mod_b {
pub enum Enum {
variant
}
}
pub mod test_mod_a {
pub enum Enum {
variant
}
}
//- /main.rs crate:main deps:dep
fn test(input: dep::test_mod_b::Enum) { }
fn main() {
test(Enum$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]
"#]],
);
}
#[test]
fn set_enum_variant_type_completion_info() {
check_relevance(
r#"
//- /lib.rs crate:dep
pub mod test_mod_b {
pub enum Enum {
Variant
}
}
pub mod test_mod_a {
pub enum Enum {
Variant
}
}
//- /main.rs crate:main deps:dep
fn test(input: dep::test_mod_b::Enum) { }
fn main() {
test(Variant$0);
}
"#,
expect![[r#"
ev dep::test_mod_b::Enum::Variant [type_could_unify]
fn main() []
fn test() []
md dep []
"#]],
);
}
#[test]
fn set_fn_type_completion_info() {
check_relevance(
r#"
//- /lib.rs crate:dep
pub mod test_mod_b {
pub fn function(j: isize) -> i32 {}
}
pub mod test_mod_a {
pub fn function(i: usize) -> i32 {}
}
//- /main.rs crate:main deps:dep
fn test(input: fn(usize) -> i32) { }
fn main() {
test(function$0);
}
"#,
expect![[r#"
fn main []
fn test []
md dep []
fn function (use dep::test_mod_a::function) [requires_import]
fn function (use dep::test_mod_b::function) [requires_import]
"#]],
);
}
#[test]
fn set_const_type_completion_info() {
check_relevance(
r#"
//- /lib.rs crate:dep
pub mod test_mod_b {
pub const CONST: i32 = 1;
}
pub mod test_mod_a {
pub const CONST: i64 = 2;
}
//- /main.rs crate:main deps:dep
fn test(input: i32) { }
fn main() {
test(CONST$0);
}
"#,
expect![[r#"
ct CONST (use dep::test_mod_b::CONST) [type_could_unify+requires_import]
fn main() []
fn test() []
md dep []
ct CONST (use dep::test_mod_a::CONST) [requires_import]
"#]],
);
}
#[test]
fn set_static_type_completion_info() {
check_relevance(
r#"
//- /lib.rs crate:dep
pub mod test_mod_b {
pub static STATIC: i32 = 5;
}
pub mod test_mod_a {
pub static STATIC: i64 = 5;
}
//- /main.rs crate:main deps:dep
fn test(input: i32) { }
fn main() {
test(STATIC$0);
}
"#,
expect![[r#"
sc STATIC (use dep::test_mod_b::STATIC) [type_could_unify+requires_import]
fn main() []
fn test() []
md dep []
sc STATIC (use dep::test_mod_a::STATIC) [requires_import]
"#]],
);
}
#[test]
fn set_self_type_completion_info_with_params() {
check_relevance(
r#"
//- /lib.rs crate:dep
pub struct Struct;
impl Struct {
pub fn Function(&self, input: i32) -> bool {
false
}
}
//- /main.rs crate:main deps:dep
use dep::Struct;
fn test(input: fn(&dep::Struct, i32) -> bool) { }
fn main() {
test(Struct::Function$0);
}
"#,
expect![[r#"
me Function []
"#]],
);
}
#[test]
fn set_self_type_completion_info() {
check_relevance(
r#"
//- /main.rs crate:main
struct Struct;
impl Struct {
fn test(&self) {
func(Self$0);
}
}
fn func(input: Struct) { }
"#,
expect![[r#"
st Struct [type]
st Self [type]
sp Self [type]
st Struct [type]
lc self [local]
fn func() []
me self.test() []
"#]],
);
}
#[test]
fn set_builtin_type_completion_info() {
check_relevance(
r#"
//- /main.rs crate:main
fn test(input: bool) { }
pub Input: bool = false;
fn main() {
let input = false;
let inputbad = 3;
test(inp$0);
}
"#,
expect![[r#"
lc input [type+name+local]
lc inputbad [local]
fn main() []
fn test() []
"#]],
);
}
#[test]
fn enum_detail_includes_record_fields() {
check(
@ -1026,6 +1386,7 @@ use self::E::*;
kind: SymbolKind(
Enum,
),
detail: "E",
documentation: Documentation(
"enum docs",
),
@ -1270,6 +1631,7 @@ fn go(world: &WorldSnapshot) { go(w$0) }
st WorldSnapshot {} []
st &WorldSnapshot {} [type]
st WorldSnapshot []
st &WorldSnapshot [type]
fn go() []
"#]],
);
@ -1369,6 +1731,7 @@ fn main() {
st S []
st &mut S [type]
st S []
st &mut S [type]
fn foo() []
fn main() []
"#]],
@ -1385,7 +1748,7 @@ fn main() {
expect![[r#"
lc s [type+name+local]
st S [type]
st S []
st S [type]
fn foo() []
fn main() []
"#]],
@ -1402,7 +1765,7 @@ fn main() {
expect![[r#"
lc ssss [type+local]
st S [type]
st S []
st S [type]
fn foo() []
fn main() []
"#]],
@ -1441,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 []
@ -1487,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 []
@ -1526,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() []
"#]],
@ -1549,6 +1916,7 @@ fn bar(t: &Foo) {}
ev Foo::B []
ev &Foo::B [type]
en Foo []
en &Foo [type]
fn bar() []
fn foo() []
"#]],
@ -1582,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() []
@ -1791,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

@ -62,6 +62,7 @@ fn render(
),
_ => (name.unescaped().to_smol_str(), name.to_smol_str()),
};
let mut item = CompletionItem::new(
if func.self_param(db).is_some() {
CompletionItemKind::Method
@ -77,8 +78,31 @@ fn render(
.as_assoc_item(ctx.db())
.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_type_match(completion, &ret_type),
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()
@ -108,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,10 +227,10 @@ 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,8 +803,8 @@ fn main() {
check(
fixture,
expect![[r#"
ct TEST_ASSOC (use foo::bar::Item)
"#]],
ct TEST_ASSOC (use foo::bar::Item) usize
"#]],
);
check_edit(
@ -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,8 +1138,8 @@ 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

@ -84,10 +84,10 @@ pub mod prelude {
}
"#,
expect![[r#"
md std
st Option
bt u32
"#]],
md std
st Option Option
bt u32 u32
"#]],
);
}
@ -112,11 +112,11 @@ mod macros {
}
"#,
expect![[r#"
fn f() fn()
ma concat!() macro_rules! concat
md std
bt u32
"#]],
fn f() fn()
ma concat!() macro_rules! concat
md std
bt u32 u32
"#]],
);
}
@ -142,11 +142,11 @@ pub mod prelude {
}
"#,
expect![[r#"
md core
md std
st String
bt u32
"#]],
md core
md std
st String String
bt u32 u32
"#]],
);
}
@ -171,10 +171,10 @@ pub mod prelude {
}
"#,
expect![[r#"
fn f() fn()
md std
bt u32
"#]],
fn f() fn()
md std
bt u32 u32
"#]],
);
}
@ -446,10 +446,10 @@ mod p {
}
"#,
expect![[r#"
ct RIGHT_CONST
fn right_fn() fn()
st RightType
"#]],
ct RIGHT_CONST u32
fn right_fn() fn()
st RightType WrongType
"#]],
);
check_edit(
@ -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
@ -1433,7 +1433,7 @@ fn foo() {
Some('_'),
expect![[r#"
fn foo() fn()
bt u32
bt u32 u32
kw const
kw crate::
kw enum
@ -1485,7 +1485,7 @@ fn foo(_: a_$0) { }
"#,
Some('_'),
expect![[r#"
bt u32
bt u32 u32
kw crate::
kw self::
"#]],
@ -1499,7 +1499,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,19 +100,19 @@ fn foo() -> B$0 {
}
"#,
expect![[r#"
en Enum
ma makro!() macro_rules! makro
md module
st Record
st Tuple
st Unit
tt Trait
un Union
bt u32
it ()
kw crate::
kw self::
"#]],
en Enum Enum
ma makro!() macro_rules! makro
md module
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
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,19 +739,19 @@ fn completes_const_and_type_generics_separately() {
}
"#,
expect![[r#"
en Enum
ma makro!() macro_rules! makro
md module
st Foo
st Record
st Tuple
st Unit
tt Trait
un Union
bt u32
kw crate::
kw self::
"#]],
en Enum Enum
ma makro!() macro_rules! makro
md module
st Foo Foo
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
);
// FIXME: This should probably also suggest completions for types, at least those that have
// associated constants usable in this position. For example, a user could be typing
@ -766,12 +766,12 @@ fn completes_const_and_type_generics_separately() {
}
"#,
expect![[r#"
ct CONST
ct X
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
ct CONST Unit
ct X usize
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
);
// Method generic params
@ -785,19 +785,19 @@ fn completes_const_and_type_generics_separately() {
}
"#,
expect![[r#"
en Enum
ma makro!() macro_rules! makro
md module
st Foo
st Record
st Tuple
st Unit
tt Trait
un Union
bt u32
kw crate::
kw self::
"#]],
en Enum Enum
ma makro!() macro_rules! makro
md module
st Foo Foo
st Record Record
st Tuple Tuple
st Unit Unit
tt Trait
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
);
check(
r#"
@ -809,12 +809,12 @@ fn completes_const_and_type_generics_separately() {
}
"#,
expect![[r#"
ct CONST
ct X
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
ct CONST Unit
ct X usize
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
);
// Associated type generic params
@ -828,20 +828,20 @@ fn completes_const_and_type_generics_separately() {
fn foo(_: impl Bar<Baz<F$0, 0> = ()>) {}
"#,
expect![[r#"
en Enum
ma makro!() macro_rules! makro
md module
st Foo
st Record
st Tuple
st Unit
tt Bar
tt Trait
un Union
bt u32
kw crate::
kw self::
"#]],
en Enum Enum
ma makro!() macro_rules! makro
md module
st Foo Foo
st Record Record
st Tuple Tuple
st Unit Unit
tt Bar
tt Trait
un Union Union
bt u32 u32
kw crate::
kw self::
"#]],
);
check(
r#"
@ -853,12 +853,12 @@ fn completes_const_and_type_generics_separately() {
fn foo<T: Bar<Baz<(), $0> = ()>>() {}
"#,
expect![[r#"
ct CONST
ct X
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
ct CONST Unit
ct X usize
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
);
// Type generic params
@ -871,12 +871,12 @@ fn completes_const_and_type_generics_separately() {
}
"#,
expect![[r#"
ct CONST
ct X
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
ct CONST Unit
ct X usize
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
);
// Type alias generic params
@ -890,12 +890,12 @@ fn completes_const_and_type_generics_separately() {
}
"#,
expect![[r#"
ct CONST
ct X
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
ct CONST Unit
ct X usize
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
);
// Enum variant params
@ -908,12 +908,12 @@ fn completes_const_and_type_generics_separately() {
}
"#,
expect![[r#"
ct CONST
ct X
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
ct CONST Unit
ct X usize
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
);
// Trait params
@ -924,12 +924,12 @@ fn completes_const_and_type_generics_separately() {
impl Foo<(), $0> for () {}
"#,
expect![[r#"
ct CONST
ct X
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
ct CONST Unit
ct X usize
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
);
// Trait alias params
@ -942,12 +942,12 @@ fn completes_const_and_type_generics_separately() {
fn foo<T: Bar<X$0, ()>>() {}
"#,
expect![[r#"
ct CONST
ct X
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
ct CONST Unit
ct X usize
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
);
// Omitted lifetime params
@ -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
"#]],
);
}