mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-29 06:23:25 +00:00
Split SymbolKind::Function into Function and Method
This commit is contained in:
parent
c8f6655327
commit
23fff55f0c
20 changed files with 150 additions and 124 deletions
|
@ -961,11 +961,11 @@ struct Foo { field: i32 }
|
||||||
impl Foo { fn foo(&self) { $0 } }"#,
|
impl Foo { fn foo(&self) { $0 } }"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
fd self.field i32
|
fd self.field i32
|
||||||
|
me self.foo() fn(&self)
|
||||||
lc self &Foo
|
lc self &Foo
|
||||||
sp Self Foo
|
sp Self Foo
|
||||||
st Foo Foo
|
st Foo Foo
|
||||||
bt u32 u32
|
bt u32 u32
|
||||||
me self.foo() fn(&self)
|
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check(
|
||||||
|
@ -975,11 +975,11 @@ struct Foo(i32);
|
||||||
impl Foo { fn foo(&mut self) { $0 } }"#,
|
impl Foo { fn foo(&mut self) { $0 } }"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
fd self.0 i32
|
fd self.0 i32
|
||||||
|
me self.foo() fn(&mut self)
|
||||||
lc self &mut Foo
|
lc self &mut Foo
|
||||||
sp Self Foo
|
sp Self Foo
|
||||||
st Foo Foo
|
st Foo Foo
|
||||||
bt u32 u32
|
bt u32 u32
|
||||||
me self.foo() fn(&mut self)
|
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,11 +186,11 @@ fn add_function_impl(
|
||||||
if func.assoc_fn_params(ctx.db).is_empty() { "" } else { ".." }
|
if func.assoc_fn_params(ctx.db).is_empty() { "" } else { ".." }
|
||||||
);
|
);
|
||||||
|
|
||||||
let completion_kind = if func.has_self_param(ctx.db) {
|
let completion_kind = CompletionItemKind::SymbolKind(if func.has_self_param(ctx.db) {
|
||||||
CompletionItemKind::Method
|
SymbolKind::Method
|
||||||
} else {
|
} else {
|
||||||
CompletionItemKind::SymbolKind(SymbolKind::Function)
|
SymbolKind::Function
|
||||||
};
|
});
|
||||||
|
|
||||||
let mut item = CompletionItem::new(completion_kind, replacement_range, label);
|
let mut item = CompletionItem::new(completion_kind, replacement_range, label);
|
||||||
item.lookup_by(format!("fn {}", fn_name.display(ctx.db)))
|
item.lookup_by(format!("fn {}", fn_name.display(ctx.db)))
|
||||||
|
|
|
@ -75,8 +75,8 @@ impl Future for A {}
|
||||||
fn foo(a: A) { a.$0 }
|
fn foo(a: A) { a.$0 }
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw await expr.await
|
|
||||||
me into_future() (as IntoFuture) fn(self) -> <Self as IntoFuture>::IntoFuture
|
me into_future() (as IntoFuture) fn(self) -> <Self as IntoFuture>::IntoFuture
|
||||||
|
kw await expr.await
|
||||||
sn box Box::new(expr)
|
sn box Box::new(expr)
|
||||||
sn call function(expr)
|
sn call function(expr)
|
||||||
sn dbg dbg!(expr)
|
sn dbg dbg!(expr)
|
||||||
|
@ -102,8 +102,8 @@ fn foo() {
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw await expr.await
|
|
||||||
me into_future() (use core::future::IntoFuture) fn(self) -> <Self as IntoFuture>::IntoFuture
|
me into_future() (use core::future::IntoFuture) fn(self) -> <Self as IntoFuture>::IntoFuture
|
||||||
|
kw await expr.await
|
||||||
sn box Box::new(expr)
|
sn box Box::new(expr)
|
||||||
sn call function(expr)
|
sn call function(expr)
|
||||||
sn dbg dbg!(expr)
|
sn dbg dbg!(expr)
|
||||||
|
@ -131,8 +131,8 @@ impl IntoFuture for A {}
|
||||||
fn foo(a: A) { a.$0 }
|
fn foo(a: A) { a.$0 }
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw await expr.await
|
|
||||||
me into_future() (as IntoFuture) fn(self) -> <Self as IntoFuture>::IntoFuture
|
me into_future() (as IntoFuture) fn(self) -> <Self as IntoFuture>::IntoFuture
|
||||||
|
kw await expr.await
|
||||||
sn box Box::new(expr)
|
sn box Box::new(expr)
|
||||||
sn call function(expr)
|
sn call function(expr)
|
||||||
sn dbg dbg!(expr)
|
sn dbg dbg!(expr)
|
||||||
|
|
|
@ -342,7 +342,6 @@ pub enum CompletionItemKind {
|
||||||
BuiltinType,
|
BuiltinType,
|
||||||
InferredType,
|
InferredType,
|
||||||
Keyword,
|
Keyword,
|
||||||
Method,
|
|
||||||
Snippet,
|
Snippet,
|
||||||
UnresolvedReference,
|
UnresolvedReference,
|
||||||
Expression,
|
Expression,
|
||||||
|
@ -369,6 +368,7 @@ impl CompletionItemKind {
|
||||||
SymbolKind::LifetimeParam => "lt",
|
SymbolKind::LifetimeParam => "lt",
|
||||||
SymbolKind::Local => "lc",
|
SymbolKind::Local => "lc",
|
||||||
SymbolKind::Macro => "ma",
|
SymbolKind::Macro => "ma",
|
||||||
|
SymbolKind::Method => "me",
|
||||||
SymbolKind::ProcMacro => "pm",
|
SymbolKind::ProcMacro => "pm",
|
||||||
SymbolKind::Module => "md",
|
SymbolKind::Module => "md",
|
||||||
SymbolKind::SelfParam => "sp",
|
SymbolKind::SelfParam => "sp",
|
||||||
|
@ -388,7 +388,6 @@ impl CompletionItemKind {
|
||||||
CompletionItemKind::BuiltinType => "bt",
|
CompletionItemKind::BuiltinType => "bt",
|
||||||
CompletionItemKind::InferredType => "it",
|
CompletionItemKind::InferredType => "it",
|
||||||
CompletionItemKind::Keyword => "kw",
|
CompletionItemKind::Keyword => "kw",
|
||||||
CompletionItemKind::Method => "me",
|
|
||||||
CompletionItemKind::Snippet => "sn",
|
CompletionItemKind::Snippet => "sn",
|
||||||
CompletionItemKind::UnresolvedReference => "??",
|
CompletionItemKind::UnresolvedReference => "??",
|
||||||
CompletionItemKind::Expression => "ex",
|
CompletionItemKind::Expression => "ex",
|
||||||
|
|
|
@ -677,7 +677,8 @@ mod tests {
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn check_function_relevance(ra_fixture: &str, expect: Expect) {
|
fn check_function_relevance(ra_fixture: &str, expect: Expect) {
|
||||||
let actual: Vec<_> = do_completion(ra_fixture, CompletionItemKind::Method)
|
let actual: Vec<_> =
|
||||||
|
do_completion(ra_fixture, CompletionItemKind::SymbolKind(SymbolKind::Method))
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|item| (item.detail.unwrap_or_default(), item.relevance.function))
|
.map(|item| (item.detail.unwrap_or_default(), item.relevance.function))
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -1392,7 +1393,10 @@ impl S {
|
||||||
/// Method docs
|
/// Method docs
|
||||||
fn bar(self) { self.$0 }
|
fn bar(self) { self.$0 }
|
||||||
}"#,
|
}"#,
|
||||||
&[CompletionItemKind::Method, CompletionItemKind::SymbolKind(SymbolKind::Field)],
|
&[
|
||||||
|
CompletionItemKind::SymbolKind(SymbolKind::Method),
|
||||||
|
CompletionItemKind::SymbolKind(SymbolKind::Field),
|
||||||
|
],
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
[
|
[
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
|
@ -1400,7 +1404,9 @@ impl S {
|
||||||
source_range: 94..94,
|
source_range: 94..94,
|
||||||
delete: 94..94,
|
delete: 94..94,
|
||||||
insert: "bar()$0",
|
insert: "bar()$0",
|
||||||
kind: Method,
|
kind: SymbolKind(
|
||||||
|
Method,
|
||||||
|
),
|
||||||
lookup: "bar",
|
lookup: "bar",
|
||||||
detail: "fn(self)",
|
detail: "fn(self)",
|
||||||
documentation: Documentation(
|
documentation: Documentation(
|
||||||
|
@ -1520,7 +1526,7 @@ impl S {
|
||||||
}
|
}
|
||||||
fn foo(s: S) { s.$0 }
|
fn foo(s: S) { s.$0 }
|
||||||
"#,
|
"#,
|
||||||
CompletionItemKind::Method,
|
CompletionItemKind::SymbolKind(SymbolKind::Method),
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
[
|
[
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
|
@ -1528,7 +1534,9 @@ fn foo(s: S) { s.$0 }
|
||||||
source_range: 81..81,
|
source_range: 81..81,
|
||||||
delete: 81..81,
|
delete: 81..81,
|
||||||
insert: "the_method()$0",
|
insert: "the_method()$0",
|
||||||
kind: Method,
|
kind: SymbolKind(
|
||||||
|
Method,
|
||||||
|
),
|
||||||
lookup: "the_method",
|
lookup: "the_method",
|
||||||
detail: "fn(&self)",
|
detail: "fn(&self)",
|
||||||
relevance: CompletionRelevance {
|
relevance: CompletionRelevance {
|
||||||
|
@ -2408,7 +2416,10 @@ impl Foo { fn baz(&self) -> u32 { 0 } }
|
||||||
|
|
||||||
fn foo(f: Foo) { let _: &u32 = f.b$0 }
|
fn foo(f: Foo) { let _: &u32 = f.b$0 }
|
||||||
"#,
|
"#,
|
||||||
&[CompletionItemKind::Method, CompletionItemKind::SymbolKind(SymbolKind::Field)],
|
&[
|
||||||
|
CompletionItemKind::SymbolKind(SymbolKind::Method),
|
||||||
|
CompletionItemKind::SymbolKind(SymbolKind::Field),
|
||||||
|
],
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
[
|
[
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
|
@ -2416,7 +2427,9 @@ fn foo(f: Foo) { let _: &u32 = f.b$0 }
|
||||||
source_range: 109..110,
|
source_range: 109..110,
|
||||||
delete: 109..110,
|
delete: 109..110,
|
||||||
insert: "baz()$0",
|
insert: "baz()$0",
|
||||||
kind: Method,
|
kind: SymbolKind(
|
||||||
|
Method,
|
||||||
|
),
|
||||||
lookup: "baz",
|
lookup: "baz",
|
||||||
detail: "fn(&self) -> u32",
|
detail: "fn(&self) -> u32",
|
||||||
relevance: CompletionRelevance {
|
relevance: CompletionRelevance {
|
||||||
|
@ -2631,7 +2644,7 @@ fn main() {
|
||||||
let _: bool = (9 > 2).not$0;
|
let _: bool = (9 > 2).not$0;
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
&[CompletionItemKind::Snippet, CompletionItemKind::Method],
|
&[CompletionItemKind::Snippet, CompletionItemKind::SymbolKind(SymbolKind::Method)],
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
sn not [snippet]
|
sn not [snippet]
|
||||||
me not() (use ops::Not) [type_could_unify+requires_import]
|
me not() (use ops::Not) [type_could_unify+requires_import]
|
||||||
|
@ -2664,7 +2677,7 @@ fn main() {
|
||||||
S.$0
|
S.$0
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
&[CompletionItemKind::Snippet, CompletionItemKind::Method],
|
&[CompletionItemKind::Snippet, CompletionItemKind::SymbolKind(SymbolKind::Method)],
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
me f() []
|
me f() []
|
||||||
sn ref []
|
sn ref []
|
||||||
|
@ -2907,7 +2920,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
&[
|
&[
|
||||||
CompletionItemKind::Method,
|
CompletionItemKind::SymbolKind(SymbolKind::Method),
|
||||||
CompletionItemKind::SymbolKind(SymbolKind::Field),
|
CompletionItemKind::SymbolKind(SymbolKind::Field),
|
||||||
CompletionItemKind::SymbolKind(SymbolKind::Function),
|
CompletionItemKind::SymbolKind(SymbolKind::Function),
|
||||||
],
|
],
|
||||||
|
@ -2918,7 +2931,9 @@ fn main() {
|
||||||
source_range: 193..193,
|
source_range: 193..193,
|
||||||
delete: 193..193,
|
delete: 193..193,
|
||||||
insert: "flush()$0",
|
insert: "flush()$0",
|
||||||
kind: Method,
|
kind: SymbolKind(
|
||||||
|
Method,
|
||||||
|
),
|
||||||
lookup: "flush",
|
lookup: "flush",
|
||||||
detail: "fn(&self)",
|
detail: "fn(&self)",
|
||||||
relevance: CompletionRelevance {
|
relevance: CompletionRelevance {
|
||||||
|
@ -2941,7 +2956,9 @@ fn main() {
|
||||||
source_range: 193..193,
|
source_range: 193..193,
|
||||||
delete: 193..193,
|
delete: 193..193,
|
||||||
insert: "write()$0",
|
insert: "write()$0",
|
||||||
kind: Method,
|
kind: SymbolKind(
|
||||||
|
Method,
|
||||||
|
),
|
||||||
lookup: "write",
|
lookup: "write",
|
||||||
detail: "fn(&self)",
|
detail: "fn(&self)",
|
||||||
relevance: CompletionRelevance {
|
relevance: CompletionRelevance {
|
||||||
|
|
|
@ -68,11 +68,11 @@ fn render(
|
||||||
};
|
};
|
||||||
let has_self_param = func.self_param(db).is_some();
|
let has_self_param = func.self_param(db).is_some();
|
||||||
let mut item = CompletionItem::new(
|
let mut item = CompletionItem::new(
|
||||||
if has_self_param {
|
CompletionItemKind::SymbolKind(if has_self_param {
|
||||||
CompletionItemKind::Method
|
SymbolKind::Method
|
||||||
} else {
|
} else {
|
||||||
CompletionItemKind::SymbolKind(SymbolKind::Function)
|
SymbolKind::Function
|
||||||
},
|
}),
|
||||||
ctx.source_range(),
|
ctx.source_range(),
|
||||||
call.clone(),
|
call.clone(),
|
||||||
);
|
);
|
||||||
|
|
|
@ -127,6 +127,7 @@ impl Unit {
|
||||||
en Enum Enum
|
en Enum Enum
|
||||||
fn function() fn()
|
fn function() fn()
|
||||||
fn local_func() fn()
|
fn local_func() fn()
|
||||||
|
me self.foo() fn(self)
|
||||||
lc self Unit
|
lc self Unit
|
||||||
ma makro!(…) macro_rules! makro
|
ma makro!(…) macro_rules! makro
|
||||||
md module
|
md module
|
||||||
|
@ -166,7 +167,6 @@ impl Unit {
|
||||||
kw use
|
kw use
|
||||||
kw while
|
kw while
|
||||||
kw while let
|
kw while let
|
||||||
me self.foo() fn(self)
|
|
||||||
sn macro_rules
|
sn macro_rules
|
||||||
sn pd
|
sn pd
|
||||||
sn ppd
|
sn ppd
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
//! Tests that don't fit into a specific category.
|
//! Tests that don't fit into a specific category.
|
||||||
|
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::{expect, Expect};
|
||||||
|
use ide_db::SymbolKind;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
tests::{
|
tests::{
|
||||||
|
@ -320,10 +321,10 @@ fn foo<T: Sub>() { T::$0 }
|
||||||
ct CONST (as Super) const CONST: u8
|
ct CONST (as Super) const CONST: u8
|
||||||
fn func() (as Super) fn()
|
fn func() (as Super) fn()
|
||||||
fn subfunc() (as Sub) fn()
|
fn subfunc() (as Sub) fn()
|
||||||
ta SubTy (as Sub) type SubTy
|
|
||||||
ta Ty (as Super) type Ty
|
|
||||||
me method(…) (as Super) fn(&self)
|
me method(…) (as Super) fn(&self)
|
||||||
me submethod(…) (as Sub) fn(&self)
|
me submethod(…) (as Sub) fn(&self)
|
||||||
|
ta SubTy (as Sub) type SubTy
|
||||||
|
ta Ty (as Super) type Ty
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -360,10 +361,10 @@ impl<T> Sub for Wrap<T> {
|
||||||
ct CONST (as Super) const CONST: u8
|
ct CONST (as Super) const CONST: u8
|
||||||
fn func() (as Super) fn()
|
fn func() (as Super) fn()
|
||||||
fn subfunc() (as Sub) fn()
|
fn subfunc() (as Sub) fn()
|
||||||
ta SubTy (as Sub) type SubTy
|
|
||||||
ta Ty (as Super) type Ty
|
|
||||||
me method(…) (as Super) fn(&self)
|
me method(…) (as Super) fn(&self)
|
||||||
me submethod(…) (as Sub) fn(&self)
|
me submethod(…) (as Sub) fn(&self)
|
||||||
|
ta SubTy (as Sub) type SubTy
|
||||||
|
ta Ty (as Super) type Ty
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -555,9 +556,9 @@ impl Foo {
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
|
me foo(…) fn(self)
|
||||||
ev Bar Bar
|
ev Bar Bar
|
||||||
ev Baz Baz
|
ev Baz Baz
|
||||||
me foo(…) fn(self)
|
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1399,7 +1400,7 @@ fn main() {
|
||||||
bar.b$0
|
bar.b$0
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
CompletionItemKind::Method,
|
CompletionItemKind::SymbolKind(SymbolKind::Method),
|
||||||
expect!("const fn(&'foo mut self, &Foo) -> !"),
|
expect!("const fn(&'foo mut self, &Foo) -> !"),
|
||||||
expect!("pub const fn baz<'foo>(&'foo mut self, x: &'foo Foo) -> !"),
|
expect!("pub const fn baz<'foo>(&'foo mut self, x: &'foo Foo) -> !"),
|
||||||
);
|
);
|
||||||
|
|
|
@ -346,6 +346,7 @@ pub enum SymbolKind {
|
||||||
Enum,
|
Enum,
|
||||||
Field,
|
Field,
|
||||||
Function,
|
Function,
|
||||||
|
Method,
|
||||||
Impl,
|
Impl,
|
||||||
Label,
|
Label,
|
||||||
LifetimeParam,
|
LifetimeParam,
|
||||||
|
|
|
@ -134,15 +134,22 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
|
||||||
if let Some(type_param_list) = it.generic_param_list() {
|
if let Some(type_param_list) = it.generic_param_list() {
|
||||||
collapse_ws(type_param_list.syntax(), &mut detail);
|
collapse_ws(type_param_list.syntax(), &mut detail);
|
||||||
}
|
}
|
||||||
if let Some(param_list) = it.param_list() {
|
let has_self_param = if let Some(param_list) = it.param_list() {
|
||||||
collapse_ws(param_list.syntax(), &mut detail);
|
collapse_ws(param_list.syntax(), &mut detail);
|
||||||
}
|
param_list.self_param().is_some()
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
};
|
||||||
if let Some(ret_type) = it.ret_type() {
|
if let Some(ret_type) = it.ret_type() {
|
||||||
detail.push(' ');
|
detail.push(' ');
|
||||||
collapse_ws(ret_type.syntax(), &mut detail);
|
collapse_ws(ret_type.syntax(), &mut detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
decl_with_detail(&it, Some(detail), StructureNodeKind::SymbolKind(SymbolKind::Function))
|
decl_with_detail(&it, Some(detail), StructureNodeKind::SymbolKind(if has_self_param {
|
||||||
|
SymbolKind::Method
|
||||||
|
} else {
|
||||||
|
SymbolKind::Function
|
||||||
|
}))
|
||||||
},
|
},
|
||||||
ast::Struct(it) => decl(it, StructureNodeKind::SymbolKind(SymbolKind::Struct)),
|
ast::Struct(it) => decl(it, StructureNodeKind::SymbolKind(SymbolKind::Struct)),
|
||||||
ast::Union(it) => decl(it, StructureNodeKind::SymbolKind(SymbolKind::Union)),
|
ast::Union(it) => decl(it, StructureNodeKind::SymbolKind(SymbolKind::Union)),
|
||||||
|
|
|
@ -378,14 +378,17 @@ pub(super) fn highlight_def(
|
||||||
if let Some(item) = func.as_assoc_item(db) {
|
if let Some(item) = func.as_assoc_item(db) {
|
||||||
h |= HlMod::Associated;
|
h |= HlMod::Associated;
|
||||||
match func.self_param(db) {
|
match func.self_param(db) {
|
||||||
Some(sp) => match sp.access(db) {
|
Some(sp) => {
|
||||||
|
h.tag = HlTag::Symbol(SymbolKind::Method);
|
||||||
|
match sp.access(db) {
|
||||||
hir::Access::Exclusive => {
|
hir::Access::Exclusive => {
|
||||||
h |= HlMod::Mutable;
|
h |= HlMod::Mutable;
|
||||||
h |= HlMod::Reference;
|
h |= HlMod::Reference;
|
||||||
}
|
}
|
||||||
hir::Access::Shared => h |= HlMod::Reference,
|
hir::Access::Shared => h |= HlMod::Reference,
|
||||||
hir::Access::Owned => h |= HlMod::Consuming,
|
hir::Access::Owned => h |= HlMod::Consuming,
|
||||||
},
|
}
|
||||||
|
}
|
||||||
None => h |= HlMod::Static,
|
None => h |= HlMod::Static,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,6 +431,7 @@ pub(super) fn highlight_def(
|
||||||
|
|
||||||
if let Some(item) = konst.as_assoc_item(db) {
|
if let Some(item) = konst.as_assoc_item(db) {
|
||||||
h |= HlMod::Associated;
|
h |= HlMod::Associated;
|
||||||
|
h |= HlMod::Static;
|
||||||
match item.container(db) {
|
match item.container(db) {
|
||||||
hir::AssocItemContainer::Impl(i) => {
|
hir::AssocItemContainer::Impl(i) => {
|
||||||
if i.trait_(db).is_some() {
|
if i.trait_(db).is_some() {
|
||||||
|
@ -449,6 +453,7 @@ pub(super) fn highlight_def(
|
||||||
|
|
||||||
if let Some(item) = type_.as_assoc_item(db) {
|
if let Some(item) = type_.as_assoc_item(db) {
|
||||||
h |= HlMod::Associated;
|
h |= HlMod::Associated;
|
||||||
|
h |= HlMod::Static;
|
||||||
match item.container(db) {
|
match item.container(db) {
|
||||||
hir::AssocItemContainer::Impl(i) => {
|
hir::AssocItemContainer::Impl(i) => {
|
||||||
if i.trait_(db).is_some() {
|
if i.trait_(db).is_some() {
|
||||||
|
@ -465,8 +470,7 @@ pub(super) fn highlight_def(
|
||||||
}
|
}
|
||||||
Definition::BuiltinType(_) => Highlight::new(HlTag::BuiltinType),
|
Definition::BuiltinType(_) => Highlight::new(HlTag::BuiltinType),
|
||||||
Definition::Static(s) => {
|
Definition::Static(s) => {
|
||||||
let mut h =
|
let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Static));
|
||||||
Highlight::new(HlTag::Symbol(SymbolKind::Static)) | HlMod::Static | HlMod::Const;
|
|
||||||
|
|
||||||
if s.is_mut(db) {
|
if s.is_mut(db) {
|
||||||
h |= HlMod::Mutable;
|
h |= HlMod::Mutable;
|
||||||
|
@ -555,8 +559,7 @@ fn highlight_method_call(
|
||||||
) -> Option<Highlight> {
|
) -> Option<Highlight> {
|
||||||
let func = sema.resolve_method_call(method_call)?;
|
let func = sema.resolve_method_call(method_call)?;
|
||||||
|
|
||||||
let mut h = SymbolKind::Function.into();
|
let mut h = SymbolKind::Method.into();
|
||||||
h |= HlMod::Associated;
|
|
||||||
|
|
||||||
if func.is_unsafe_to_call(sema.db) || sema.is_unsafe_method_call(method_call) {
|
if func.is_unsafe_to_call(sema.db) || sema.is_unsafe_method_call(method_call) {
|
||||||
h |= HlMod::Unsafe;
|
h |= HlMod::Unsafe;
|
||||||
|
@ -652,7 +655,7 @@ fn highlight_name_ref_by_syntax(
|
||||||
match parent.kind() {
|
match parent.kind() {
|
||||||
METHOD_CALL_EXPR => ast::MethodCallExpr::cast(parent)
|
METHOD_CALL_EXPR => ast::MethodCallExpr::cast(parent)
|
||||||
.and_then(|it| highlight_method_call(sema, krate, &it))
|
.and_then(|it| highlight_method_call(sema, krate, &it))
|
||||||
.unwrap_or_else(|| SymbolKind::Function.into()),
|
.unwrap_or_else(|| SymbolKind::Method.into()),
|
||||||
FIELD_EXPR => {
|
FIELD_EXPR => {
|
||||||
let h = HlTag::Symbol(SymbolKind::Field);
|
let h = HlTag::Symbol(SymbolKind::Field);
|
||||||
let is_union = ast::FieldExpr::cast(parent)
|
let is_union = ast::FieldExpr::cast(parent)
|
||||||
|
|
|
@ -46,7 +46,7 @@ pub enum HlTag {
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum HlMod {
|
pub enum HlMod {
|
||||||
/// Used for items in traits and impls.
|
/// Used for associated items.
|
||||||
Associated = 0,
|
Associated = 0,
|
||||||
/// Used with keywords like `async` and `await`.
|
/// Used with keywords like `async` and `await`.
|
||||||
Async,
|
Async,
|
||||||
|
@ -84,7 +84,7 @@ pub enum HlMod {
|
||||||
Public,
|
Public,
|
||||||
/// Immutable reference.
|
/// Immutable reference.
|
||||||
Reference,
|
Reference,
|
||||||
/// Used for associated functions.
|
/// Used for associated items, except Methods. (Some languages call these static members)
|
||||||
Static,
|
Static,
|
||||||
/// Used for items in traits and trait impls.
|
/// Used for items in traits and trait impls.
|
||||||
Trait,
|
Trait,
|
||||||
|
@ -149,6 +149,7 @@ impl HlTag {
|
||||||
SymbolKind::LifetimeParam => "lifetime",
|
SymbolKind::LifetimeParam => "lifetime",
|
||||||
SymbolKind::Local => "variable",
|
SymbolKind::Local => "variable",
|
||||||
SymbolKind::Macro => "macro",
|
SymbolKind::Macro => "macro",
|
||||||
|
SymbolKind::Method => "method",
|
||||||
SymbolKind::ProcMacro => "proc_macro",
|
SymbolKind::ProcMacro => "proc_macro",
|
||||||
SymbolKind::Module => "module",
|
SymbolKind::Module => "module",
|
||||||
SymbolKind::SelfParam => "self_keyword",
|
SymbolKind::SelfParam => "self_keyword",
|
||||||
|
|
|
@ -50,15 +50,15 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
|
|
||||||
<span class="keyword">impl</span> <span class="struct">foo</span> <span class="brace">{</span>
|
<span class="keyword">impl</span> <span class="struct">foo</span> <span class="brace">{</span>
|
||||||
<span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function associated declaration public static">is_static</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
<span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function associated declaration public static">is_static</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
||||||
<span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function associated declaration public reference">is_not_static</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
<span class="keyword">pub</span> <span class="keyword">fn</span> <span class="method associated declaration public reference">is_not_static</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
|
||||||
<span class="keyword">trait</span> <span class="trait declaration">t</span> <span class="brace">{</span>
|
<span class="keyword">trait</span> <span class="trait declaration">t</span> <span class="brace">{</span>
|
||||||
<span class="keyword">fn</span> <span class="function associated declaration static trait">t_is_static</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
<span class="keyword">fn</span> <span class="function associated declaration static trait">t_is_static</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
||||||
<span class="keyword">fn</span> <span class="function associated declaration reference trait">t_is_not_static</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
<span class="keyword">fn</span> <span class="method associated declaration reference trait">t_is_not_static</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
|
||||||
<span class="keyword">impl</span> <span class="trait">t</span> <span class="keyword">for</span> <span class="struct">foo</span> <span class="brace">{</span>
|
<span class="keyword">impl</span> <span class="trait">t</span> <span class="keyword">for</span> <span class="struct">foo</span> <span class="brace">{</span>
|
||||||
<span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function associated declaration public static trait">is_static</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
<span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function associated declaration public static trait">is_static</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
||||||
<span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function associated declaration public reference trait">is_not_static</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
<span class="keyword">pub</span> <span class="keyword">fn</span> <span class="method associated declaration public reference trait">is_not_static</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
||||||
<span class="brace">}</span></code></pre>
|
<span class="brace">}</span></code></pre>
|
|
@ -48,5 +48,5 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
|
|
||||||
<span class="keyword">fn</span> <span class="function declaration">main</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span>
|
<span class="keyword">fn</span> <span class="function declaration">main</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span>
|
||||||
<span class="keyword">let</span> <span class="variable declaration">foo</span> <span class="operator">=</span> <span class="enum_variant default_library library">Some</span><span class="parenthesis">(</span><span class="numeric_literal">92</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
<span class="keyword">let</span> <span class="variable declaration">foo</span> <span class="operator">=</span> <span class="enum_variant default_library library">Some</span><span class="parenthesis">(</span><span class="numeric_literal">92</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||||
<span class="keyword">let</span> <span class="variable declaration">nums</span> <span class="operator">=</span> <span class="module default_library library">iter</span><span class="operator">::</span><span class="function default_library library">repeat</span><span class="parenthesis">(</span><span class="variable">foo</span><span class="operator">.</span><span class="function associated consuming default_library library">unwrap</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
<span class="keyword">let</span> <span class="variable declaration">nums</span> <span class="operator">=</span> <span class="module default_library library">iter</span><span class="operator">::</span><span class="function default_library library">repeat</span><span class="parenthesis">(</span><span class="variable">foo</span><span class="operator">.</span><span class="method consuming default_library library">unwrap</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||||
<span class="brace">}</span></code></pre>
|
<span class="brace">}</span></code></pre>
|
|
@ -71,7 +71,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
<span class="comment">// KILLER WHALE</span>
|
<span class="comment">// KILLER WHALE</span>
|
||||||
<span class="comment documentation">///</span><span class="comment documentation"> </span><span class="string_literal injected"> Ishmael."</span><span class="semicolon injected">;</span>
|
<span class="comment documentation">///</span><span class="comment documentation"> </span><span class="string_literal injected"> Ishmael."</span><span class="semicolon injected">;</span>
|
||||||
<span class="comment documentation">/// ```</span>
|
<span class="comment documentation">/// ```</span>
|
||||||
<span class="keyword">pub</span> <span class="keyword const">const</span> <span class="constant associated const declaration public">bar</span><span class="colon">:</span> <span class="builtin_type">bool</span> <span class="operator">=</span> <span class="bool_literal">true</span><span class="semicolon">;</span>
|
<span class="keyword">pub</span> <span class="keyword const">const</span> <span class="constant associated const declaration public static">bar</span><span class="colon">:</span> <span class="builtin_type">bool</span> <span class="operator">=</span> <span class="bool_literal">true</span><span class="semicolon">;</span>
|
||||||
|
|
||||||
<span class="comment documentation">/// Constructs a new `Foo`.</span>
|
<span class="comment documentation">/// Constructs a new `Foo`.</span>
|
||||||
<span class="comment documentation">///</span>
|
<span class="comment documentation">///</span>
|
||||||
|
@ -109,12 +109,12 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
<span class="comment documentation">/// ```</span>
|
<span class="comment documentation">/// ```</span>
|
||||||
<span class="comment documentation">///</span>
|
<span class="comment documentation">///</span>
|
||||||
<span class="comment documentation">/// ```rust,no_run</span>
|
<span class="comment documentation">/// ```rust,no_run</span>
|
||||||
<span class="comment documentation">///</span><span class="comment documentation"> </span><span class="keyword injected">let</span><span class="none injected"> </span><span class="variable declaration injected">foobar</span><span class="none injected"> </span><span class="operator injected">=</span><span class="none injected"> </span><span class="struct injected">Foo</span><span class="operator injected">::</span><span class="function injected">new</span><span class="parenthesis injected">(</span><span class="parenthesis injected">)</span><span class="operator injected">.</span><span class="function injected">bar</span><span class="parenthesis injected">(</span><span class="parenthesis injected">)</span><span class="semicolon injected">;</span>
|
<span class="comment documentation">///</span><span class="comment documentation"> </span><span class="keyword injected">let</span><span class="none injected"> </span><span class="variable declaration injected">foobar</span><span class="none injected"> </span><span class="operator injected">=</span><span class="none injected"> </span><span class="struct injected">Foo</span><span class="operator injected">::</span><span class="function injected">new</span><span class="parenthesis injected">(</span><span class="parenthesis injected">)</span><span class="operator injected">.</span><span class="method injected">bar</span><span class="parenthesis injected">(</span><span class="parenthesis injected">)</span><span class="semicolon injected">;</span>
|
||||||
<span class="comment documentation">/// ```</span>
|
<span class="comment documentation">/// ```</span>
|
||||||
<span class="comment documentation">///</span>
|
<span class="comment documentation">///</span>
|
||||||
<span class="comment documentation">/// ~~~rust,no_run</span>
|
<span class="comment documentation">/// ~~~rust,no_run</span>
|
||||||
<span class="comment documentation">///</span><span class="comment documentation"> </span><span class="comment injected">// code block with tilde.</span>
|
<span class="comment documentation">///</span><span class="comment documentation"> </span><span class="comment injected">// code block with tilde.</span>
|
||||||
<span class="comment documentation">///</span><span class="comment documentation"> </span><span class="keyword injected">let</span><span class="none injected"> </span><span class="variable declaration injected">foobar</span><span class="none injected"> </span><span class="operator injected">=</span><span class="none injected"> </span><span class="struct injected">Foo</span><span class="operator injected">::</span><span class="function injected">new</span><span class="parenthesis injected">(</span><span class="parenthesis injected">)</span><span class="operator injected">.</span><span class="function injected">bar</span><span class="parenthesis injected">(</span><span class="parenthesis injected">)</span><span class="semicolon injected">;</span>
|
<span class="comment documentation">///</span><span class="comment documentation"> </span><span class="keyword injected">let</span><span class="none injected"> </span><span class="variable declaration injected">foobar</span><span class="none injected"> </span><span class="operator injected">=</span><span class="none injected"> </span><span class="struct injected">Foo</span><span class="operator injected">::</span><span class="function injected">new</span><span class="parenthesis injected">(</span><span class="parenthesis injected">)</span><span class="operator injected">.</span><span class="method injected">bar</span><span class="parenthesis injected">(</span><span class="parenthesis injected">)</span><span class="semicolon injected">;</span>
|
||||||
<span class="comment documentation">/// ~~~</span>
|
<span class="comment documentation">/// ~~~</span>
|
||||||
<span class="comment documentation">///</span>
|
<span class="comment documentation">///</span>
|
||||||
<span class="comment documentation">/// ```</span>
|
<span class="comment documentation">/// ```</span>
|
||||||
|
@ -127,7 +127,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
<span class="comment documentation">/// ```sh</span>
|
<span class="comment documentation">/// ```sh</span>
|
||||||
<span class="comment documentation">/// echo 1</span>
|
<span class="comment documentation">/// echo 1</span>
|
||||||
<span class="comment documentation">/// ```</span>
|
<span class="comment documentation">/// ```</span>
|
||||||
<span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function associated declaration public reference">foo</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="builtin_type">bool</span> <span class="brace">{</span>
|
<span class="keyword">pub</span> <span class="keyword">fn</span> <span class="method associated declaration public reference">foo</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="builtin_type">bool</span> <span class="brace">{</span>
|
||||||
<span class="bool_literal">true</span>
|
<span class="bool_literal">true</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
|
|
@ -63,25 +63,25 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
|
||||||
<span class="keyword">trait</span> <span class="trait declaration">Bar</span> <span class="brace">{</span>
|
<span class="keyword">trait</span> <span class="trait declaration">Bar</span> <span class="brace">{</span>
|
||||||
<span class="keyword">fn</span> <span class="function associated declaration reference trait">bar</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span><span class="semicolon">;</span>
|
<span class="keyword">fn</span> <span class="method associated declaration reference trait">bar</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span><span class="semicolon">;</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
|
||||||
<span class="keyword">impl</span> <span class="trait">Bar</span> <span class="keyword">for</span> <span class="struct">Foo</span> <span class="brace">{</span>
|
<span class="keyword">impl</span> <span class="trait">Bar</span> <span class="keyword">for</span> <span class="struct">Foo</span> <span class="brace">{</span>
|
||||||
<span class="keyword">fn</span> <span class="function associated declaration reference trait">bar</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span> <span class="brace">{</span>
|
<span class="keyword">fn</span> <span class="method associated declaration reference trait">bar</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span> <span class="brace">{</span>
|
||||||
<span class="self_keyword reference">self</span><span class="operator">.</span><span class="field">x</span>
|
<span class="self_keyword reference">self</span><span class="operator">.</span><span class="field">x</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
|
||||||
<span class="keyword">impl</span> <span class="struct">Foo</span> <span class="brace">{</span>
|
<span class="keyword">impl</span> <span class="struct">Foo</span> <span class="brace">{</span>
|
||||||
<span class="keyword">fn</span> <span class="function associated consuming declaration">baz</span><span class="parenthesis">(</span><span class="keyword">mut</span> <span class="self_keyword declaration mutable">self</span><span class="comma">,</span> <span class="value_param declaration">f</span><span class="colon">:</span> <span class="struct">Foo</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span> <span class="brace">{</span>
|
<span class="keyword">fn</span> <span class="method associated consuming declaration">baz</span><span class="parenthesis">(</span><span class="keyword">mut</span> <span class="self_keyword declaration mutable">self</span><span class="comma">,</span> <span class="value_param declaration">f</span><span class="colon">:</span> <span class="struct">Foo</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span> <span class="brace">{</span>
|
||||||
<span class="value_param">f</span><span class="operator">.</span><span class="function associated consuming">baz</span><span class="parenthesis">(</span><span class="self_keyword consuming mutable">self</span><span class="parenthesis">)</span>
|
<span class="value_param">f</span><span class="operator">.</span><span class="method consuming">baz</span><span class="parenthesis">(</span><span class="self_keyword consuming mutable">self</span><span class="parenthesis">)</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
|
||||||
<span class="keyword">fn</span> <span class="function associated declaration mutable reference">qux</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="keyword">mut</span> <span class="self_keyword declaration mutable reference">self</span><span class="parenthesis">)</span> <span class="brace">{</span>
|
<span class="keyword">fn</span> <span class="method associated declaration mutable reference">qux</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="keyword">mut</span> <span class="self_keyword declaration mutable reference">self</span><span class="parenthesis">)</span> <span class="brace">{</span>
|
||||||
<span class="self_keyword mutable reference">self</span><span class="operator">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="semicolon">;</span>
|
<span class="self_keyword mutable reference">self</span><span class="operator">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="semicolon">;</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
|
||||||
<span class="keyword">fn</span> <span class="function associated declaration reference">quop</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span> <span class="brace">{</span>
|
<span class="keyword">fn</span> <span class="method associated declaration reference">quop</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span> <span class="brace">{</span>
|
||||||
<span class="self_keyword reference">self</span><span class="operator">.</span><span class="field">x</span>
|
<span class="self_keyword reference">self</span><span class="operator">.</span><span class="field">x</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
@ -94,15 +94,15 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
|
||||||
<span class="keyword">impl</span> <span class="struct">FooCopy</span> <span class="brace">{</span>
|
<span class="keyword">impl</span> <span class="struct">FooCopy</span> <span class="brace">{</span>
|
||||||
<span class="keyword">fn</span> <span class="function associated consuming declaration">baz</span><span class="parenthesis">(</span><span class="self_keyword declaration">self</span><span class="comma">,</span> <span class="value_param declaration">f</span><span class="colon">:</span> <span class="struct">FooCopy</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="builtin_type">u32</span> <span class="brace">{</span>
|
<span class="keyword">fn</span> <span class="method associated consuming declaration">baz</span><span class="parenthesis">(</span><span class="self_keyword declaration">self</span><span class="comma">,</span> <span class="value_param declaration">f</span><span class="colon">:</span> <span class="struct">FooCopy</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="builtin_type">u32</span> <span class="brace">{</span>
|
||||||
<span class="value_param">f</span><span class="operator">.</span><span class="function associated">baz</span><span class="parenthesis">(</span><span class="self_keyword">self</span><span class="parenthesis">)</span>
|
<span class="value_param">f</span><span class="operator">.</span><span class="method">baz</span><span class="parenthesis">(</span><span class="self_keyword">self</span><span class="parenthesis">)</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
|
||||||
<span class="keyword">fn</span> <span class="function associated declaration mutable reference">qux</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="keyword">mut</span> <span class="self_keyword declaration mutable reference">self</span><span class="parenthesis">)</span> <span class="brace">{</span>
|
<span class="keyword">fn</span> <span class="method associated declaration mutable reference">qux</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="keyword">mut</span> <span class="self_keyword declaration mutable reference">self</span><span class="parenthesis">)</span> <span class="brace">{</span>
|
||||||
<span class="self_keyword mutable reference">self</span><span class="operator">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="semicolon">;</span>
|
<span class="self_keyword mutable reference">self</span><span class="operator">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="semicolon">;</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
|
||||||
<span class="keyword">fn</span> <span class="function associated declaration reference">quop</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="builtin_type">u32</span> <span class="brace">{</span>
|
<span class="keyword">fn</span> <span class="method associated declaration reference">quop</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="builtin_type">u32</span> <span class="brace">{</span>
|
||||||
<span class="self_keyword reference">self</span><span class="operator">.</span><span class="field">x</span>
|
<span class="self_keyword reference">self</span><span class="operator">.</span><span class="field">x</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
@ -148,17 +148,17 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
|
|
||||||
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">foo</span> <span class="operator">=</span> <span class="struct">Foo</span> <span class="brace">{</span> <span class="field">x</span><span class="comma">,</span> <span class="unresolved_reference">y</span><span class="colon">:</span> <span class="variable mutable">x</span> <span class="brace">}</span><span class="semicolon">;</span>
|
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">foo</span> <span class="operator">=</span> <span class="struct">Foo</span> <span class="brace">{</span> <span class="field">x</span><span class="comma">,</span> <span class="unresolved_reference">y</span><span class="colon">:</span> <span class="variable mutable">x</span> <span class="brace">}</span><span class="semicolon">;</span>
|
||||||
<span class="keyword">let</span> <span class="variable declaration">foo2</span> <span class="operator">=</span> <span class="struct">Foo</span> <span class="brace">{</span> <span class="field">x</span><span class="comma">,</span> <span class="unresolved_reference">y</span><span class="colon">:</span> <span class="variable mutable">x</span> <span class="brace">}</span><span class="semicolon">;</span>
|
<span class="keyword">let</span> <span class="variable declaration">foo2</span> <span class="operator">=</span> <span class="struct">Foo</span> <span class="brace">{</span> <span class="field">x</span><span class="comma">,</span> <span class="unresolved_reference">y</span><span class="colon">:</span> <span class="variable mutable">x</span> <span class="brace">}</span><span class="semicolon">;</span>
|
||||||
<span class="variable mutable">foo</span><span class="operator">.</span><span class="function associated reference">quop</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
<span class="variable mutable">foo</span><span class="operator">.</span><span class="method reference">quop</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||||
<span class="variable mutable">foo</span><span class="operator">.</span><span class="function associated mutable reference">qux</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
<span class="variable mutable">foo</span><span class="operator">.</span><span class="method mutable reference">qux</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||||
<span class="variable mutable">foo</span><span class="operator">.</span><span class="function associated consuming">baz</span><span class="parenthesis">(</span><span class="variable consuming">foo2</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
<span class="variable mutable">foo</span><span class="operator">.</span><span class="method consuming">baz</span><span class="parenthesis">(</span><span class="variable consuming">foo2</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||||
|
|
||||||
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">copy</span> <span class="operator">=</span> <span class="struct">FooCopy</span> <span class="brace">{</span> <span class="field">x</span> <span class="brace">}</span><span class="semicolon">;</span>
|
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">copy</span> <span class="operator">=</span> <span class="struct">FooCopy</span> <span class="brace">{</span> <span class="field">x</span> <span class="brace">}</span><span class="semicolon">;</span>
|
||||||
<span class="variable mutable">copy</span><span class="operator">.</span><span class="function associated reference">quop</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
<span class="variable mutable">copy</span><span class="operator">.</span><span class="method reference">quop</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||||
<span class="variable mutable">copy</span><span class="operator">.</span><span class="function associated mutable reference">qux</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
<span class="variable mutable">copy</span><span class="operator">.</span><span class="method mutable reference">qux</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||||
<span class="variable mutable">copy</span><span class="operator">.</span><span class="function associated">baz</span><span class="parenthesis">(</span><span class="variable mutable">copy</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
<span class="variable mutable">copy</span><span class="operator">.</span><span class="method">baz</span><span class="parenthesis">(</span><span class="variable mutable">copy</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||||
|
|
||||||
<span class="keyword">let</span> <span class="variable callable declaration">a</span> <span class="operator">=</span> <span class="punctuation">|</span><span class="value_param declaration">x</span><span class="punctuation">|</span> <span class="value_param">x</span><span class="semicolon">;</span>
|
<span class="keyword">let</span> <span class="variable callable declaration">a</span> <span class="operator">=</span> <span class="punctuation">|</span><span class="value_param declaration">x</span><span class="punctuation">|</span> <span class="value_param">x</span><span class="semicolon">;</span>
|
||||||
<span class="keyword">let</span> <span class="variable callable declaration">bar</span> <span class="operator">=</span> <span class="struct">Foo</span><span class="operator">::</span><span class="function associated consuming">baz</span><span class="semicolon">;</span>
|
<span class="keyword">let</span> <span class="variable callable declaration">bar</span> <span class="operator">=</span> <span class="struct">Foo</span><span class="operator">::</span><span class="method associated consuming">baz</span><span class="semicolon">;</span>
|
||||||
|
|
||||||
<span class="keyword">let</span> <span class="variable declaration">baz</span> <span class="operator">=</span> <span class="parenthesis">(</span><span class="numeric_literal">-</span><span class="numeric_literal">42</span><span class="comma">,</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
<span class="keyword">let</span> <span class="variable declaration">baz</span> <span class="operator">=</span> <span class="parenthesis">(</span><span class="numeric_literal">-</span><span class="numeric_literal">42</span><span class="comma">,</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||||
<span class="keyword">let</span> <span class="variable declaration">baz</span> <span class="operator">=</span> <span class="operator">-</span><span class="variable">baz</span><span class="operator">.</span><span class="field">0</span><span class="semicolon">;</span>
|
<span class="keyword">let</span> <span class="variable declaration">baz</span> <span class="operator">=</span> <span class="operator">-</span><span class="variable">baz</span><span class="operator">.</span><span class="field">0</span><span class="semicolon">;</span>
|
||||||
|
@ -178,7 +178,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
<span class="keyword">use</span> <span class="enum">Option</span><span class="operator">::</span><span class="punctuation">*</span><span class="semicolon">;</span>
|
<span class="keyword">use</span> <span class="enum">Option</span><span class="operator">::</span><span class="punctuation">*</span><span class="semicolon">;</span>
|
||||||
|
|
||||||
<span class="keyword">impl</span><span class="angle"><</span><span class="type_param declaration">T</span><span class="angle">></span> <span class="enum">Option</span><span class="angle"><</span><span class="type_param">T</span><span class="angle">></span> <span class="brace">{</span>
|
<span class="keyword">impl</span><span class="angle"><</span><span class="type_param declaration">T</span><span class="angle">></span> <span class="enum">Option</span><span class="angle"><</span><span class="type_param">T</span><span class="angle">></span> <span class="brace">{</span>
|
||||||
<span class="keyword">fn</span> <span class="function associated consuming declaration">and</span><span class="angle"><</span><span class="type_param declaration">U</span><span class="angle">></span><span class="parenthesis">(</span><span class="self_keyword declaration">self</span><span class="comma">,</span> <span class="value_param declaration">other</span><span class="colon">:</span> <span class="enum">Option</span><span class="angle"><</span><span class="type_param">U</span><span class="angle">></span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="enum">Option</span><span class="angle"><</span><span class="parenthesis">(</span><span class="type_param">T</span><span class="comma">,</span> <span class="type_param">U</span><span class="parenthesis">)</span><span class="angle">></span> <span class="brace">{</span>
|
<span class="keyword">fn</span> <span class="method associated consuming declaration">and</span><span class="angle"><</span><span class="type_param declaration">U</span><span class="angle">></span><span class="parenthesis">(</span><span class="self_keyword declaration">self</span><span class="comma">,</span> <span class="value_param declaration">other</span><span class="colon">:</span> <span class="enum">Option</span><span class="angle"><</span><span class="type_param">U</span><span class="angle">></span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="enum">Option</span><span class="angle"><</span><span class="parenthesis">(</span><span class="type_param">T</span><span class="comma">,</span> <span class="type_param">U</span><span class="parenthesis">)</span><span class="angle">></span> <span class="brace">{</span>
|
||||||
<span class="keyword control">match</span> <span class="value_param">other</span> <span class="brace">{</span>
|
<span class="keyword control">match</span> <span class="value_param">other</span> <span class="brace">{</span>
|
||||||
<span class="enum_variant">None</span> <span class="operator">=></span> <span class="unresolved_reference">unimplemented</span><span class="macro_bang">!</span><span class="parenthesis macro">(</span><span class="parenthesis macro">)</span><span class="comma">,</span>
|
<span class="enum_variant">None</span> <span class="operator">=></span> <span class="unresolved_reference">unimplemented</span><span class="macro_bang">!</span><span class="parenthesis macro">(</span><span class="parenthesis macro">)</span><span class="comma">,</span>
|
||||||
<span class="variable declaration">Nope</span> <span class="operator">=></span> <span class="variable">Nope</span><span class="comma">,</span>
|
<span class="variable declaration">Nope</span> <span class="operator">=></span> <span class="variable">Nope</span><span class="comma">,</span>
|
||||||
|
@ -205,7 +205,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
|
|
||||||
<span class="keyword">let</span> <span class="variable declaration">control_flow</span> <span class="operator">=</span> <span class="module crate_root library">foo</span><span class="operator">::</span><span class="function library">identity</span><span class="parenthesis">(</span><span class="module crate_root library">foo</span><span class="operator">::</span><span class="enum library">ControlFlow</span><span class="operator">::</span><span class="enum_variant library">Continue</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
<span class="keyword">let</span> <span class="variable declaration">control_flow</span> <span class="operator">=</span> <span class="module crate_root library">foo</span><span class="operator">::</span><span class="function library">identity</span><span class="parenthesis">(</span><span class="module crate_root library">foo</span><span class="operator">::</span><span class="enum library">ControlFlow</span><span class="operator">::</span><span class="enum_variant library">Continue</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||||
|
|
||||||
<span class="keyword control">if</span> <span class="variable">control_flow</span><span class="operator">.</span><span class="function associated consuming library">should_die</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span>
|
<span class="keyword control">if</span> <span class="variable">control_flow</span><span class="operator">.</span><span class="method consuming library">should_die</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span>
|
||||||
<span class="module crate_root library">foo</span><span class="operator">::</span><span class="unresolved_reference">die</span><span class="macro_bang">!</span><span class="parenthesis macro">(</span><span class="parenthesis macro">)</span><span class="semicolon">;</span>
|
<span class="module crate_root library">foo</span><span class="operator">::</span><span class="unresolved_reference">die</span><span class="macro_bang">!</span><span class="parenthesis macro">(</span><span class="parenthesis macro">)</span><span class="semicolon">;</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
@ -213,23 +213,23 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
<span class="keyword">pub</span> <span class="keyword">enum</span> <span class="enum declaration public">Bool</span> <span class="brace">{</span> <span class="enum_variant declaration public">True</span><span class="comma">,</span> <span class="enum_variant declaration public">False</span> <span class="brace">}</span>
|
<span class="keyword">pub</span> <span class="keyword">enum</span> <span class="enum declaration public">Bool</span> <span class="brace">{</span> <span class="enum_variant declaration public">True</span><span class="comma">,</span> <span class="enum_variant declaration public">False</span> <span class="brace">}</span>
|
||||||
|
|
||||||
<span class="keyword">impl</span> <span class="enum public">Bool</span> <span class="brace">{</span>
|
<span class="keyword">impl</span> <span class="enum public">Bool</span> <span class="brace">{</span>
|
||||||
<span class="keyword">pub</span> <span class="keyword const">const</span> <span class="keyword">fn</span> <span class="function associated const consuming declaration public">to_primitive</span><span class="parenthesis">(</span><span class="self_keyword declaration">self</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="builtin_type">bool</span> <span class="brace">{</span>
|
<span class="keyword">pub</span> <span class="keyword const">const</span> <span class="keyword">fn</span> <span class="method associated const consuming declaration public">to_primitive</span><span class="parenthesis">(</span><span class="self_keyword declaration">self</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="builtin_type">bool</span> <span class="brace">{</span>
|
||||||
<span class="bool_literal">true</span>
|
<span class="bool_literal">true</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
<span class="keyword const">const</span> <span class="constant const declaration">USAGE_OF_BOOL</span><span class="colon">:</span><span class="builtin_type">bool</span> <span class="operator">=</span> <span class="enum public">Bool</span><span class="operator">::</span><span class="enum_variant public">True</span><span class="operator">.</span><span class="function associated consuming public">to_primitive</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
<span class="keyword const">const</span> <span class="constant const declaration">USAGE_OF_BOOL</span><span class="colon">:</span><span class="builtin_type">bool</span> <span class="operator">=</span> <span class="enum public">Bool</span><span class="operator">::</span><span class="enum_variant public">True</span><span class="operator">.</span><span class="method consuming public">to_primitive</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||||
|
|
||||||
<span class="keyword">trait</span> <span class="trait declaration">Baz</span> <span class="brace">{</span>
|
<span class="keyword">trait</span> <span class="trait declaration">Baz</span> <span class="brace">{</span>
|
||||||
<span class="keyword">type</span> <span class="type_alias associated declaration trait">Qux</span><span class="semicolon">;</span>
|
<span class="keyword">type</span> <span class="type_alias associated declaration static trait">Qux</span><span class="semicolon">;</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
|
||||||
<span class="keyword">fn</span> <span class="function declaration">baz</span><span class="angle"><</span><span class="type_param declaration">T</span><span class="angle">></span><span class="parenthesis">(</span><span class="value_param declaration">t</span><span class="colon">:</span> <span class="type_param">T</span><span class="parenthesis">)</span>
|
<span class="keyword">fn</span> <span class="function declaration">baz</span><span class="angle"><</span><span class="type_param declaration">T</span><span class="angle">></span><span class="parenthesis">(</span><span class="value_param declaration">t</span><span class="colon">:</span> <span class="type_param">T</span><span class="parenthesis">)</span>
|
||||||
<span class="keyword">where</span>
|
<span class="keyword">where</span>
|
||||||
<span class="type_param">T</span><span class="colon">:</span> <span class="trait">Baz</span><span class="comma">,</span>
|
<span class="type_param">T</span><span class="colon">:</span> <span class="trait">Baz</span><span class="comma">,</span>
|
||||||
<span class="angle"><</span><span class="type_param">T</span> <span class="keyword">as</span> <span class="trait">Baz</span><span class="angle">></span><span class="operator">::</span><span class="type_alias associated trait">Qux</span><span class="colon">:</span> <span class="trait">Bar</span> <span class="brace">{</span><span class="brace">}</span>
|
<span class="angle"><</span><span class="type_param">T</span> <span class="keyword">as</span> <span class="trait">Baz</span><span class="angle">></span><span class="operator">::</span><span class="type_alias associated static trait">Qux</span><span class="colon">:</span> <span class="trait">Bar</span> <span class="brace">{</span><span class="brace">}</span>
|
||||||
|
|
||||||
<span class="keyword">fn</span> <span class="function declaration">gp_shadows_trait</span><span class="angle"><</span><span class="type_param declaration">Baz</span><span class="colon">:</span> <span class="trait">Bar</span><span class="angle">></span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span>
|
<span class="keyword">fn</span> <span class="function declaration">gp_shadows_trait</span><span class="angle"><</span><span class="type_param declaration">Baz</span><span class="colon">:</span> <span class="trait">Bar</span><span class="angle">></span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span>
|
||||||
<span class="type_param">Baz</span><span class="operator">::</span><span class="function associated reference trait">bar</span><span class="semicolon">;</span>
|
<span class="type_param">Baz</span><span class="operator">::</span><span class="method associated reference trait">bar</span><span class="semicolon">;</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
|
||||||
</code></pre>
|
</code></pre>
|
|
@ -54,8 +54,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
<span class="punctuation">*</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="keyword">as</span> <span class="punctuation">*</span><span class="keyword const">const</span> <span class="parenthesis">(</span><span class="parenthesis">)</span><span class="parenthesis">)</span>
|
<span class="punctuation">*</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="keyword">as</span> <span class="punctuation">*</span><span class="keyword const">const</span> <span class="parenthesis">(</span><span class="parenthesis">)</span><span class="parenthesis">)</span>
|
||||||
<span class="brace">}</span><span class="semicolon">;</span>
|
<span class="brace">}</span><span class="semicolon">;</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
<span class="keyword">static</span> <span class="keyword">mut</span> <span class="static const declaration mutable static unsafe">MUT_GLOBAL</span><span class="colon">:</span> <span class="struct">Struct</span> <span class="operator">=</span> <span class="struct">Struct</span> <span class="brace">{</span> <span class="field">field</span><span class="colon">:</span> <span class="numeric_literal">0</span> <span class="brace">}</span><span class="semicolon">;</span>
|
<span class="keyword">static</span> <span class="keyword">mut</span> <span class="static declaration mutable unsafe">MUT_GLOBAL</span><span class="colon">:</span> <span class="struct">Struct</span> <span class="operator">=</span> <span class="struct">Struct</span> <span class="brace">{</span> <span class="field">field</span><span class="colon">:</span> <span class="numeric_literal">0</span> <span class="brace">}</span><span class="semicolon">;</span>
|
||||||
<span class="keyword">static</span> <span class="static const declaration static">GLOBAL</span><span class="colon">:</span> <span class="struct">Struct</span> <span class="operator">=</span> <span class="struct">Struct</span> <span class="brace">{</span> <span class="field">field</span><span class="colon">:</span> <span class="numeric_literal">0</span> <span class="brace">}</span><span class="semicolon">;</span>
|
<span class="keyword">static</span> <span class="static declaration">GLOBAL</span><span class="colon">:</span> <span class="struct">Struct</span> <span class="operator">=</span> <span class="struct">Struct</span> <span class="brace">{</span> <span class="field">field</span><span class="colon">:</span> <span class="numeric_literal">0</span> <span class="brace">}</span><span class="semicolon">;</span>
|
||||||
<span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="function declaration unsafe">unsafe_fn</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
<span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="function declaration unsafe">unsafe_fn</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
||||||
|
|
||||||
<span class="keyword">union</span> <span class="union declaration">Union</span> <span class="brace">{</span>
|
<span class="keyword">union</span> <span class="union declaration">Union</span> <span class="brace">{</span>
|
||||||
|
@ -65,7 +65,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
|
|
||||||
<span class="keyword">struct</span> <span class="struct declaration">Struct</span> <span class="brace">{</span> <span class="field declaration">field</span><span class="colon">:</span> <span class="builtin_type">i32</span> <span class="brace">}</span>
|
<span class="keyword">struct</span> <span class="struct declaration">Struct</span> <span class="brace">{</span> <span class="field declaration">field</span><span class="colon">:</span> <span class="builtin_type">i32</span> <span class="brace">}</span>
|
||||||
<span class="keyword">impl</span> <span class="struct">Struct</span> <span class="brace">{</span>
|
<span class="keyword">impl</span> <span class="struct">Struct</span> <span class="brace">{</span>
|
||||||
<span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="function associated declaration reference unsafe">unsafe_method</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
<span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="method associated declaration reference unsafe">unsafe_method</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
|
||||||
<span class="attribute_bracket attribute">#</span><span class="attribute_bracket attribute">[</span><span class="builtin_attr attribute library">repr</span><span class="parenthesis attribute">(</span><span class="none attribute">packed</span><span class="parenthesis attribute">)</span><span class="attribute_bracket attribute">]</span>
|
<span class="attribute_bracket attribute">#</span><span class="attribute_bracket attribute">[</span><span class="builtin_attr attribute library">repr</span><span class="parenthesis attribute">(</span><span class="none attribute">packed</span><span class="parenthesis attribute">)</span><span class="attribute_bracket attribute">]</span>
|
||||||
|
@ -80,11 +80,11 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
<span class="keyword">fn</span> <span class="function declaration">unsafe_trait_bound</span><span class="angle"><</span><span class="type_param declaration">T</span><span class="colon">:</span> <span class="trait">UnsafeTrait</span><span class="angle">></span><span class="parenthesis">(</span><span class="punctuation">_</span><span class="colon">:</span> <span class="type_param">T</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
<span class="keyword">fn</span> <span class="function declaration">unsafe_trait_bound</span><span class="angle"><</span><span class="type_param declaration">T</span><span class="colon">:</span> <span class="trait">UnsafeTrait</span><span class="angle">></span><span class="parenthesis">(</span><span class="punctuation">_</span><span class="colon">:</span> <span class="type_param">T</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
||||||
|
|
||||||
<span class="keyword">trait</span> <span class="trait declaration">DoTheAutoref</span> <span class="brace">{</span>
|
<span class="keyword">trait</span> <span class="trait declaration">DoTheAutoref</span> <span class="brace">{</span>
|
||||||
<span class="keyword">fn</span> <span class="function associated declaration reference trait">calls_autoref</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
<span class="keyword">fn</span> <span class="method associated declaration reference trait">calls_autoref</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
|
||||||
<span class="keyword">impl</span> <span class="trait">DoTheAutoref</span> <span class="keyword">for</span> <span class="builtin_type">u16</span> <span class="brace">{</span>
|
<span class="keyword">impl</span> <span class="trait">DoTheAutoref</span> <span class="keyword">for</span> <span class="builtin_type">u16</span> <span class="brace">{</span>
|
||||||
<span class="keyword">fn</span> <span class="function associated declaration reference trait">calls_autoref</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
<span class="keyword">fn</span> <span class="method associated declaration reference trait">calls_autoref</span><span class="parenthesis">(</span><span class="punctuation">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
|
|
||||||
<span class="keyword">fn</span> <span class="function declaration">main</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span>
|
<span class="keyword">fn</span> <span class="function declaration">main</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span>
|
||||||
|
@ -106,14 +106,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
<span class="union">Union</span> <span class="brace">{</span> <span class="field unsafe">b</span><span class="colon">:</span> <span class="numeric_literal">0</span> <span class="brace">}</span> <span class="operator">=></span> <span class="parenthesis">(</span><span class="parenthesis">)</span><span class="comma">,</span>
|
<span class="union">Union</span> <span class="brace">{</span> <span class="field unsafe">b</span><span class="colon">:</span> <span class="numeric_literal">0</span> <span class="brace">}</span> <span class="operator">=></span> <span class="parenthesis">(</span><span class="parenthesis">)</span><span class="comma">,</span>
|
||||||
<span class="union">Union</span> <span class="brace">{</span> <span class="field unsafe">a</span> <span class="brace">}</span> <span class="operator">=></span> <span class="parenthesis">(</span><span class="parenthesis">)</span><span class="comma">,</span>
|
<span class="union">Union</span> <span class="brace">{</span> <span class="field unsafe">a</span> <span class="brace">}</span> <span class="operator">=></span> <span class="parenthesis">(</span><span class="parenthesis">)</span><span class="comma">,</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
<span class="struct">Struct</span> <span class="brace">{</span> <span class="field">field</span><span class="colon">:</span> <span class="numeric_literal">0</span> <span class="brace">}</span><span class="operator">.</span><span class="function associated reference unsafe">unsafe_method</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
<span class="struct">Struct</span> <span class="brace">{</span> <span class="field">field</span><span class="colon">:</span> <span class="numeric_literal">0</span> <span class="brace">}</span><span class="operator">.</span><span class="method reference unsafe">unsafe_method</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||||
|
|
||||||
<span class="comment">// unsafe deref</span>
|
<span class="comment">// unsafe deref</span>
|
||||||
<span class="operator unsafe">*</span><span class="variable">x</span><span class="semicolon">;</span>
|
<span class="operator unsafe">*</span><span class="variable">x</span><span class="semicolon">;</span>
|
||||||
|
|
||||||
<span class="comment">// unsafe access to a static mut</span>
|
<span class="comment">// unsafe access to a static mut</span>
|
||||||
<span class="static const mutable static unsafe">MUT_GLOBAL</span><span class="operator">.</span><span class="field">field</span><span class="semicolon">;</span>
|
<span class="static mutable unsafe">MUT_GLOBAL</span><span class="operator">.</span><span class="field">field</span><span class="semicolon">;</span>
|
||||||
<span class="static const static">GLOBAL</span><span class="operator">.</span><span class="field">field</span><span class="semicolon">;</span>
|
<span class="static">GLOBAL</span><span class="operator">.</span><span class="field">field</span><span class="semicolon">;</span>
|
||||||
|
|
||||||
<span class="comment">// unsafe ref of packed fields</span>
|
<span class="comment">// unsafe ref of packed fields</span>
|
||||||
<span class="keyword">let</span> <span class="variable declaration">packed</span> <span class="operator">=</span> <span class="struct">Packed</span> <span class="brace">{</span> <span class="field">a</span><span class="colon">:</span> <span class="numeric_literal">0</span> <span class="brace">}</span><span class="semicolon">;</span>
|
<span class="keyword">let</span> <span class="variable declaration">packed</span> <span class="operator">=</span> <span class="struct">Packed</span> <span class="brace">{</span> <span class="field">a</span><span class="colon">:</span> <span class="numeric_literal">0</span> <span class="brace">}</span><span class="semicolon">;</span>
|
||||||
|
@ -123,6 +123,6 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
<span class="keyword">let</span> <span class="struct">Packed</span> <span class="brace">{</span> <span class="field">a</span><span class="colon">:</span> <span class="keyword unsafe">ref</span> <span class="variable declaration reference">_a</span> <span class="brace">}</span> <span class="operator">=</span> <span class="variable">packed</span><span class="semicolon">;</span>
|
<span class="keyword">let</span> <span class="struct">Packed</span> <span class="brace">{</span> <span class="field">a</span><span class="colon">:</span> <span class="keyword unsafe">ref</span> <span class="variable declaration reference">_a</span> <span class="brace">}</span> <span class="operator">=</span> <span class="variable">packed</span><span class="semicolon">;</span>
|
||||||
|
|
||||||
<span class="comment">// unsafe auto ref of packed field</span>
|
<span class="comment">// unsafe auto ref of packed field</span>
|
||||||
<span class="variable">packed</span><span class="operator">.</span><span class="field">a</span><span class="operator">.</span><span class="function associated reference trait unsafe">calls_autoref</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
<span class="variable">packed</span><span class="operator">.</span><span class="field">a</span><span class="operator">.</span><span class="method reference trait unsafe">calls_autoref</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||||
<span class="brace">}</span>
|
<span class="brace">}</span>
|
||||||
<span class="brace">}</span></code></pre>
|
<span class="brace">}</span></code></pre>
|
|
@ -1542,7 +1542,7 @@ pub(crate) fn handle_call_hierarchy_prepare(
|
||||||
let RangeInfo { range: _, info: navs } = nav_info;
|
let RangeInfo { range: _, info: navs } = nav_info;
|
||||||
let res = navs
|
let res = navs
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|it| it.kind == Some(SymbolKind::Function))
|
.filter(|it| matches!(it.kind, Some(SymbolKind::Function | SymbolKind::Method)))
|
||||||
.map(|it| to_proto::call_hierarchy_item(&snap, it))
|
.map(|it| to_proto::call_hierarchy_item(&snap, it))
|
||||||
.collect::<Cancellable<Vec<_>>>()?;
|
.collect::<Cancellable<Vec<_>>>()?;
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,7 @@ define_semantic_token_modifiers![
|
||||||
DEFAULT_LIBRARY,
|
DEFAULT_LIBRARY,
|
||||||
}
|
}
|
||||||
custom {
|
custom {
|
||||||
|
(ASSOCIATED, "associated"),
|
||||||
(ASYNC, "async"),
|
(ASYNC, "async"),
|
||||||
(ATTRIBUTE_MODIFIER, "attribute"),
|
(ATTRIBUTE_MODIFIER, "attribute"),
|
||||||
(CALLABLE, "callable"),
|
(CALLABLE, "callable"),
|
||||||
|
|
|
@ -52,6 +52,7 @@ pub(crate) fn range(line_index: &LineIndex, range: TextRange) -> lsp_types::Rang
|
||||||
pub(crate) fn symbol_kind(symbol_kind: SymbolKind) -> lsp_types::SymbolKind {
|
pub(crate) fn symbol_kind(symbol_kind: SymbolKind) -> lsp_types::SymbolKind {
|
||||||
match symbol_kind {
|
match symbol_kind {
|
||||||
SymbolKind::Function => lsp_types::SymbolKind::FUNCTION,
|
SymbolKind::Function => lsp_types::SymbolKind::FUNCTION,
|
||||||
|
SymbolKind::Method => lsp_types::SymbolKind::METHOD,
|
||||||
SymbolKind::Struct => lsp_types::SymbolKind::STRUCT,
|
SymbolKind::Struct => lsp_types::SymbolKind::STRUCT,
|
||||||
SymbolKind::Enum => lsp_types::SymbolKind::ENUM,
|
SymbolKind::Enum => lsp_types::SymbolKind::ENUM,
|
||||||
SymbolKind::Variant => lsp_types::SymbolKind::ENUM_MEMBER,
|
SymbolKind::Variant => lsp_types::SymbolKind::ENUM_MEMBER,
|
||||||
|
@ -122,12 +123,12 @@ pub(crate) fn completion_item_kind(
|
||||||
CompletionItemKind::BuiltinType => lsp_types::CompletionItemKind::STRUCT,
|
CompletionItemKind::BuiltinType => lsp_types::CompletionItemKind::STRUCT,
|
||||||
CompletionItemKind::InferredType => lsp_types::CompletionItemKind::SNIPPET,
|
CompletionItemKind::InferredType => lsp_types::CompletionItemKind::SNIPPET,
|
||||||
CompletionItemKind::Keyword => lsp_types::CompletionItemKind::KEYWORD,
|
CompletionItemKind::Keyword => lsp_types::CompletionItemKind::KEYWORD,
|
||||||
CompletionItemKind::Method => lsp_types::CompletionItemKind::METHOD,
|
|
||||||
CompletionItemKind::Snippet => lsp_types::CompletionItemKind::SNIPPET,
|
CompletionItemKind::Snippet => lsp_types::CompletionItemKind::SNIPPET,
|
||||||
CompletionItemKind::UnresolvedReference => lsp_types::CompletionItemKind::REFERENCE,
|
CompletionItemKind::UnresolvedReference => lsp_types::CompletionItemKind::REFERENCE,
|
||||||
CompletionItemKind::Expression => lsp_types::CompletionItemKind::SNIPPET,
|
CompletionItemKind::Expression => lsp_types::CompletionItemKind::SNIPPET,
|
||||||
CompletionItemKind::SymbolKind(symbol) => match symbol {
|
CompletionItemKind::SymbolKind(symbol) => match symbol {
|
||||||
SymbolKind::Attribute => lsp_types::CompletionItemKind::FUNCTION,
|
SymbolKind::Attribute => lsp_types::CompletionItemKind::FUNCTION,
|
||||||
|
SymbolKind::Method => lsp_types::CompletionItemKind::METHOD,
|
||||||
SymbolKind::Const => lsp_types::CompletionItemKind::CONSTANT,
|
SymbolKind::Const => lsp_types::CompletionItemKind::CONSTANT,
|
||||||
SymbolKind::ConstParam => lsp_types::CompletionItemKind::TYPE_PARAMETER,
|
SymbolKind::ConstParam => lsp_types::CompletionItemKind::TYPE_PARAMETER,
|
||||||
SymbolKind::Derive => lsp_types::CompletionItemKind::FUNCTION,
|
SymbolKind::Derive => lsp_types::CompletionItemKind::FUNCTION,
|
||||||
|
@ -636,7 +637,7 @@ pub(crate) fn semantic_token_delta(
|
||||||
fn semantic_token_type_and_modifiers(
|
fn semantic_token_type_and_modifiers(
|
||||||
highlight: Highlight,
|
highlight: Highlight,
|
||||||
) -> (lsp_types::SemanticTokenType, semantic_tokens::ModifierSet) {
|
) -> (lsp_types::SemanticTokenType, semantic_tokens::ModifierSet) {
|
||||||
let type_ = match highlight.tag {
|
let ty = match highlight.tag {
|
||||||
HlTag::Symbol(symbol) => match symbol {
|
HlTag::Symbol(symbol) => match symbol {
|
||||||
SymbolKind::Attribute => semantic_tokens::DECORATOR,
|
SymbolKind::Attribute => semantic_tokens::DECORATOR,
|
||||||
SymbolKind::Derive => semantic_tokens::DERIVE,
|
SymbolKind::Derive => semantic_tokens::DERIVE,
|
||||||
|
@ -652,13 +653,8 @@ fn semantic_token_type_and_modifiers(
|
||||||
SymbolKind::SelfParam => semantic_tokens::SELF_KEYWORD,
|
SymbolKind::SelfParam => semantic_tokens::SELF_KEYWORD,
|
||||||
SymbolKind::SelfType => semantic_tokens::SELF_TYPE_KEYWORD,
|
SymbolKind::SelfType => semantic_tokens::SELF_TYPE_KEYWORD,
|
||||||
SymbolKind::Local => semantic_tokens::VARIABLE,
|
SymbolKind::Local => semantic_tokens::VARIABLE,
|
||||||
SymbolKind::Function => {
|
SymbolKind::Method => semantic_tokens::METHOD,
|
||||||
if highlight.mods.contains(HlMod::Associated) {
|
SymbolKind::Function => semantic_tokens::FUNCTION,
|
||||||
semantic_tokens::METHOD
|
|
||||||
} else {
|
|
||||||
semantic_tokens::FUNCTION
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SymbolKind::Const => semantic_tokens::VARIABLE,
|
SymbolKind::Const => semantic_tokens::VARIABLE,
|
||||||
SymbolKind::Static => semantic_tokens::VARIABLE,
|
SymbolKind::Static => semantic_tokens::VARIABLE,
|
||||||
SymbolKind::Struct => semantic_tokens::STRUCT,
|
SymbolKind::Struct => semantic_tokens::STRUCT,
|
||||||
|
@ -710,7 +706,7 @@ fn semantic_token_type_and_modifiers(
|
||||||
let mut mods = semantic_tokens::ModifierSet::default();
|
let mut mods = semantic_tokens::ModifierSet::default();
|
||||||
for modifier in highlight.mods.iter() {
|
for modifier in highlight.mods.iter() {
|
||||||
let modifier = match modifier {
|
let modifier = match modifier {
|
||||||
HlMod::Associated => continue,
|
HlMod::Associated => semantic_tokens::ASSOCIATED,
|
||||||
HlMod::Async => semantic_tokens::ASYNC,
|
HlMod::Async => semantic_tokens::ASYNC,
|
||||||
HlMod::Attribute => semantic_tokens::ATTRIBUTE_MODIFIER,
|
HlMod::Attribute => semantic_tokens::ATTRIBUTE_MODIFIER,
|
||||||
HlMod::Callable => semantic_tokens::CALLABLE,
|
HlMod::Callable => semantic_tokens::CALLABLE,
|
||||||
|
@ -736,7 +732,7 @@ fn semantic_token_type_and_modifiers(
|
||||||
mods |= modifier;
|
mods |= modifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
(type_, mods)
|
(ty, mods)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn folding_range(
|
pub(crate) fn folding_range(
|
||||||
|
|
Loading…
Reference in a new issue