mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Auto merge of #17243 - Veykril:static-lt-hir, r=Veykril
internal: Add StaticLifetime to hir API
This commit is contained in:
commit
83ba420431
14 changed files with 70 additions and 40 deletions
|
@ -2563,6 +2563,15 @@ impl HasVisibility for TypeAlias {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct StaticLifetime;
|
||||
|
||||
impl StaticLifetime {
|
||||
pub fn name(self) -> Name {
|
||||
known::STATIC_LIFETIME
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct BuiltinType {
|
||||
pub(crate) inner: hir_def::builtin_type::BuiltinType,
|
||||
|
|
|
@ -11,8 +11,8 @@ use hir::{
|
|||
Adt, AsAssocItem, AsExternAssocItem, AssocItem, AttributeTemplate, BuiltinAttr, BuiltinType,
|
||||
Const, Crate, DefWithBody, DeriveHelper, DocLinkDef, ExternAssocItem, ExternCrateDecl, Field,
|
||||
Function, GenericParam, HasVisibility, HirDisplay, Impl, Label, Local, Macro, Module,
|
||||
ModuleDef, Name, PathResolution, Semantics, Static, ToolModule, Trait, TraitAlias, TupleField,
|
||||
TypeAlias, Variant, VariantDef, Visibility,
|
||||
ModuleDef, Name, PathResolution, Semantics, Static, StaticLifetime, ToolModule, Trait,
|
||||
TraitAlias, TupleField, TypeAlias, Variant, VariantDef, Visibility,
|
||||
};
|
||||
use stdx::{format_to, impl_from};
|
||||
use syntax::{
|
||||
|
@ -39,12 +39,13 @@ pub enum Definition {
|
|||
Trait(Trait),
|
||||
TraitAlias(TraitAlias),
|
||||
TypeAlias(TypeAlias),
|
||||
BuiltinType(BuiltinType),
|
||||
SelfType(Impl),
|
||||
GenericParam(GenericParam),
|
||||
Local(Local),
|
||||
Label(Label),
|
||||
DeriveHelper(DeriveHelper),
|
||||
BuiltinType(BuiltinType),
|
||||
BuiltinLifetime(StaticLifetime),
|
||||
BuiltinAttr(BuiltinAttr),
|
||||
ToolModule(ToolModule),
|
||||
ExternCrateDecl(ExternCrateDecl),
|
||||
|
@ -83,6 +84,7 @@ impl Definition {
|
|||
Definition::DeriveHelper(it) => it.derive().module(db),
|
||||
Definition::BuiltinAttr(_)
|
||||
| Definition::BuiltinType(_)
|
||||
| Definition::BuiltinLifetime(_)
|
||||
| Definition::TupleField(_)
|
||||
| Definition::ToolModule(_) => return None,
|
||||
};
|
||||
|
@ -112,6 +114,7 @@ impl Definition {
|
|||
Definition::BuiltinType(_) | Definition::TupleField(_) => Visibility::Public,
|
||||
Definition::Macro(_) => return None,
|
||||
Definition::BuiltinAttr(_)
|
||||
| Definition::BuiltinLifetime(_)
|
||||
| Definition::ToolModule(_)
|
||||
| Definition::SelfType(_)
|
||||
| Definition::Local(_)
|
||||
|
@ -141,6 +144,7 @@ impl Definition {
|
|||
Definition::Local(it) => it.name(db),
|
||||
Definition::GenericParam(it) => it.name(db),
|
||||
Definition::Label(it) => it.name(db),
|
||||
Definition::BuiltinLifetime(StaticLifetime) => hir::known::STATIC_LIFETIME,
|
||||
Definition::BuiltinAttr(_) => return None, // FIXME
|
||||
Definition::ToolModule(_) => return None, // FIXME
|
||||
Definition::DeriveHelper(it) => it.name(db),
|
||||
|
@ -174,6 +178,7 @@ impl Definition {
|
|||
doc_owner.docs(fd.0.db)
|
||||
})
|
||||
}
|
||||
Definition::BuiltinLifetime(StaticLifetime) => None,
|
||||
Definition::Local(_) => None,
|
||||
Definition::SelfType(impl_def) => {
|
||||
impl_def.self_ty(db).as_adt().map(|adt| adt.docs(db))?
|
||||
|
@ -228,6 +233,7 @@ impl Definition {
|
|||
Definition::TraitAlias(it) => it.display(db).to_string(),
|
||||
Definition::TypeAlias(it) => it.display(db).to_string(),
|
||||
Definition::BuiltinType(it) => it.name().display(db).to_string(),
|
||||
Definition::BuiltinLifetime(it) => it.name().display(db).to_string(),
|
||||
Definition::Local(it) => {
|
||||
let ty = it.ty(db);
|
||||
let ty_display = ty.display_truncated(db, None);
|
||||
|
@ -693,6 +699,9 @@ impl NameRefClass {
|
|||
) -> Option<NameRefClass> {
|
||||
let _p = tracing::span!(tracing::Level::INFO, "NameRefClass::classify_lifetime", ?lifetime)
|
||||
.entered();
|
||||
if lifetime.text() == "'static" {
|
||||
return Some(NameRefClass::Definition(Definition::BuiltinLifetime(StaticLifetime)));
|
||||
}
|
||||
let parent = lifetime.syntax().parent()?;
|
||||
match parent.kind() {
|
||||
SyntaxKind::BREAK_EXPR | SyntaxKind::CONTINUE_EXPR => {
|
||||
|
|
|
@ -196,11 +196,12 @@ impl Definition {
|
|||
.and_then(syn_ctx_is_root)
|
||||
}
|
||||
}
|
||||
Definition::BuiltinType(_) => return None,
|
||||
Definition::SelfType(_) => return None,
|
||||
Definition::BuiltinAttr(_) => return None,
|
||||
Definition::ToolModule(_) => return None,
|
||||
Definition::TupleField(_) => return None,
|
||||
Definition::BuiltinType(_)
|
||||
| Definition::BuiltinLifetime(_)
|
||||
| Definition::BuiltinAttr(_)
|
||||
| Definition::SelfType(_)
|
||||
| Definition::ToolModule(_)
|
||||
| Definition::TupleField(_) => return None,
|
||||
// FIXME: This should be doable in theory
|
||||
Definition::DeriveHelper(_) => return None,
|
||||
};
|
||||
|
|
|
@ -214,8 +214,9 @@ pub(crate) fn resolve_doc_path_for_def(
|
|||
Definition::SelfType(it) => it.resolve_doc_path(db, link, ns),
|
||||
Definition::ExternCrateDecl(it) => it.resolve_doc_path(db, link, ns),
|
||||
Definition::BuiltinAttr(_)
|
||||
| Definition::ToolModule(_)
|
||||
| Definition::BuiltinType(_)
|
||||
| Definition::BuiltinLifetime(_)
|
||||
| Definition::ToolModule(_)
|
||||
| Definition::TupleField(_)
|
||||
| Definition::Local(_)
|
||||
| Definition::GenericParam(_)
|
||||
|
@ -648,6 +649,7 @@ fn filename_and_frag_for_def(
|
|||
| Definition::TupleField(_)
|
||||
| Definition::Label(_)
|
||||
| Definition::BuiltinAttr(_)
|
||||
| Definition::BuiltinLifetime(_)
|
||||
| Definition::ToolModule(_)
|
||||
| Definition::DeriveHelper(_) => return None,
|
||||
};
|
||||
|
|
|
@ -756,15 +756,7 @@ fn closure_ty(
|
|||
}
|
||||
|
||||
fn definition_mod_path(db: &RootDatabase, def: &Definition) -> Option<String> {
|
||||
if matches!(
|
||||
def,
|
||||
Definition::GenericParam(_)
|
||||
| Definition::BuiltinType(_)
|
||||
| Definition::Local(_)
|
||||
| Definition::Label(_)
|
||||
| Definition::BuiltinAttr(_)
|
||||
| Definition::ToolModule(_)
|
||||
) {
|
||||
if matches!(def, Definition::GenericParam(_) | Definition::Local(_) | Definition::Label(_)) {
|
||||
return None;
|
||||
}
|
||||
def.module(db).map(|module| path(db, module, definition_owner_name(db, def)))
|
||||
|
|
|
@ -4441,7 +4441,7 @@ fn foo() {
|
|||
```rust
|
||||
'label
|
||||
```
|
||||
"#]],
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -4455,7 +4455,17 @@ fn hover_lifetime() {
|
|||
```rust
|
||||
'lifetime
|
||||
```
|
||||
"#]],
|
||||
"#]],
|
||||
);
|
||||
check(
|
||||
r#"fn foo(_: &'static$0 ()) {}"#,
|
||||
expect![[r#"
|
||||
*'static*
|
||||
|
||||
```rust
|
||||
'static
|
||||
```
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -211,6 +211,7 @@ pub(crate) fn def_to_kind(db: &RootDatabase, def: Definition) -> SymbolInformati
|
|||
}
|
||||
}
|
||||
Definition::BuiltinType(..) => Type,
|
||||
Definition::BuiltinLifetime(_) => TypeParameter,
|
||||
Definition::SelfType(..) => TypeAlias,
|
||||
Definition::GenericParam(..) => TypeParameter,
|
||||
Definition::Local(it) => {
|
||||
|
@ -316,6 +317,7 @@ pub(crate) fn def_to_moniker(
|
|||
Definition::GenericParam(_)
|
||||
| Definition::Label(_)
|
||||
| Definition::DeriveHelper(_)
|
||||
| Definition::BuiltinLifetime(_)
|
||||
| Definition::BuiltinAttr(_)
|
||||
| Definition::ToolModule(_) => return None,
|
||||
|
||||
|
|
|
@ -235,9 +235,11 @@ impl TryToNav for Definition {
|
|||
Definition::TraitAlias(it) => it.try_to_nav(db),
|
||||
Definition::TypeAlias(it) => it.try_to_nav(db),
|
||||
Definition::ExternCrateDecl(it) => Some(it.try_to_nav(db)?),
|
||||
Definition::BuiltinType(_) | Definition::TupleField(_) => None,
|
||||
Definition::ToolModule(_) => None,
|
||||
Definition::BuiltinAttr(_) => None,
|
||||
Definition::BuiltinLifetime(_)
|
||||
| Definition::BuiltinType(_)
|
||||
| Definition::TupleField(_)
|
||||
| Definition::ToolModule(_)
|
||||
| Definition::BuiltinAttr(_) => None,
|
||||
// FIXME: The focus range should be set to the helper declaration
|
||||
Definition::DeriveHelper(it) => it.derive().try_to_nav(db),
|
||||
}
|
||||
|
|
|
@ -484,6 +484,7 @@ pub(super) fn highlight_def(
|
|||
h
|
||||
}
|
||||
Definition::BuiltinType(_) => Highlight::new(HlTag::BuiltinType),
|
||||
Definition::BuiltinLifetime(_) => Highlight::new(HlTag::Symbol(SymbolKind::LifetimeParam)),
|
||||
Definition::Static(s) => {
|
||||
let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Static));
|
||||
|
||||
|
@ -542,13 +543,14 @@ pub(super) fn highlight_def(
|
|||
let def_crate = def.krate(db);
|
||||
let is_from_other_crate = def_crate != Some(krate);
|
||||
let is_from_builtin_crate = def_crate.map_or(false, |def_crate| def_crate.is_builtin(db));
|
||||
let is_builtin_type = matches!(def, Definition::BuiltinType(_));
|
||||
let is_public = def.visibility(db) == Some(hir::Visibility::Public);
|
||||
|
||||
match (is_from_other_crate, is_builtin_type, is_public) {
|
||||
(true, false, _) => h |= HlMod::Library,
|
||||
(false, _, true) => h |= HlMod::Public,
|
||||
_ => {}
|
||||
let is_builtin = matches!(
|
||||
def,
|
||||
Definition::BuiltinType(_) | Definition::BuiltinLifetime(_) | Definition::BuiltinAttr(_)
|
||||
);
|
||||
match is_from_other_crate {
|
||||
true if !is_builtin => h |= HlMod::Library,
|
||||
false if def.visibility(db) == Some(hir::Visibility::Public) => h |= HlMod::Public,
|
||||
_ => (),
|
||||
}
|
||||
|
||||
if is_from_builtin_crate {
|
||||
|
|
|
@ -299,6 +299,7 @@ fn module_def_to_hl_tag(def: Definition) -> HlTag {
|
|||
Definition::Trait(_) => SymbolKind::Trait,
|
||||
Definition::TraitAlias(_) => SymbolKind::TraitAlias,
|
||||
Definition::TypeAlias(_) => SymbolKind::TypeAlias,
|
||||
Definition::BuiltinLifetime(_) => SymbolKind::LifetimeParam,
|
||||
Definition::BuiltinType(_) => return HlTag::BuiltinType,
|
||||
Definition::Macro(_) => SymbolKind::Macro,
|
||||
Definition::Field(_) | Definition::TupleField(_) => SymbolKind::Field,
|
||||
|
|
|
@ -45,7 +45,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
|||
.invalid_escape_sequence { color: #FC5555; text-decoration: wavy underline; }
|
||||
.unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
|
||||
</style>
|
||||
<pre><code><span class="attribute_bracket attribute">#</span><span class="attribute_bracket attribute">[</span><span class="builtin_attr attribute library">allow</span><span class="parenthesis attribute">(</span><span class="none attribute">dead_code</span><span class="parenthesis attribute">)</span><span class="attribute_bracket attribute">]</span>
|
||||
<pre><code><span class="attribute_bracket attribute">#</span><span class="attribute_bracket attribute">[</span><span class="builtin_attr attribute">allow</span><span class="parenthesis attribute">(</span><span class="none attribute">dead_code</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="tool_module attribute library">rustfmt</span><span class="operator attribute">::</span><span class="tool_module attribute library">skip</span><span class="attribute_bracket attribute">]</span>
|
||||
<span class="attribute_bracket attribute">#</span><span class="attribute_bracket attribute">[</span><span class="module attribute crate_root library">proc_macros</span><span class="operator attribute">::</span><span class="attribute attribute library">identity</span><span class="attribute_bracket attribute">]</span>
|
||||
<span class="attribute_bracket attribute">#</span><span class="attribute_bracket attribute">[</span><span class="attribute attribute default_library library">derive</span><span class="parenthesis attribute">(</span><span class="derive attribute default_library library">Default</span><span class="parenthesis attribute">)</span><span class="attribute_bracket attribute">]</span>
|
||||
|
|
|
@ -79,7 +79,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
|||
<span class="comment documentation">/// # Examples</span>
|
||||
<span class="comment documentation">///</span>
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="comment documentation">///</span><span class="comment documentation"> #</span><span class="none injected"> </span><span class="attribute_bracket attribute injected">#</span><span class="attribute_bracket attribute injected">!</span><span class="attribute_bracket attribute injected">[</span><span class="builtin_attr attribute injected library">allow</span><span class="parenthesis attribute injected">(</span><span class="none attribute injected">unused_mut</span><span class="parenthesis attribute injected">)</span><span class="attribute_bracket attribute injected">]</span>
|
||||
<span class="comment documentation">///</span><span class="comment documentation"> #</span><span class="none injected"> </span><span class="attribute_bracket attribute injected">#</span><span class="attribute_bracket attribute injected">!</span><span class="attribute_bracket attribute injected">[</span><span class="builtin_attr attribute injected">allow</span><span class="parenthesis attribute injected">(</span><span class="none attribute injected">unused_mut</span><span class="parenthesis attribute injected">)</span><span class="attribute_bracket attribute 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="keyword injected">mut</span><span class="none injected"> </span><span class="variable declaration injected mutable">foo</span><span class="colon injected">:</span><span class="none injected"> </span><span class="struct injected">Foo</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="semicolon injected">;</span>
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="keyword">pub</span> <span class="keyword const">const</span> <span class="keyword">fn</span> <span class="function associated const declaration public static">new</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="struct">Foo</span> <span class="brace">{</span>
|
||||
|
@ -162,12 +162,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="keyword control injected">loop</span><span class="none injected"> </span><span class="brace injected">{</span><span class="brace injected">}</span>
|
||||
<span class="attribute_bracket attribute">#</span><span class="attribute_bracket attribute">[</span><span class="builtin_attr attribute library">cfg_attr</span><span class="parenthesis attribute">(</span><span class="none attribute">not</span><span class="parenthesis attribute">(</span><span class="none attribute">feature</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"false"</span><span class="parenthesis attribute">)</span><span class="comma attribute">,</span> <span class="none attribute">doc</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"</span><span class="keyword control injected">loop</span><span class="none injected"> </span><span class="brace injected">{</span><span class="brace injected">}</span><span class="string_literal attribute">"</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">doc</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"</span><span class="keyword control injected">loop</span><span class="none injected"> </span><span class="brace injected">{</span><span class="brace injected">}</span><span class="string_literal 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">cfg_attr</span><span class="parenthesis attribute">(</span><span class="none attribute">not</span><span class="parenthesis attribute">(</span><span class="none attribute">feature</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"false"</span><span class="parenthesis attribute">)</span><span class="comma attribute">,</span> <span class="none attribute">doc</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"</span><span class="keyword control injected">loop</span><span class="none injected"> </span><span class="brace injected">{</span><span class="brace injected">}</span><span class="string_literal attribute">"</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">doc</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"</span><span class="keyword control injected">loop</span><span class="none injected"> </span><span class="brace injected">{</span><span class="brace injected">}</span><span class="string_literal attribute">"</span><span class="attribute_bracket attribute">]</span>
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="comment documentation">///</span>
|
||||
<span class="attribute_bracket attribute">#</span><span class="attribute_bracket attribute">[</span><span class="builtin_attr attribute library">cfg_attr</span><span class="parenthesis attribute">(</span><span class="none attribute">feature</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"alloc"</span><span class="comma attribute">,</span> <span class="none attribute">doc</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"```rust"</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">cfg_attr</span><span class="parenthesis attribute">(</span><span class="none attribute">not</span><span class="parenthesis attribute">(</span><span class="none attribute">feature</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"alloc"</span><span class="parenthesis attribute">)</span><span class="comma attribute">,</span> <span class="none attribute">doc</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"```ignore"</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">cfg_attr</span><span class="parenthesis attribute">(</span><span class="none attribute">feature</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"alloc"</span><span class="comma attribute">,</span> <span class="none attribute">doc</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"```rust"</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">cfg_attr</span><span class="parenthesis attribute">(</span><span class="none attribute">not</span><span class="parenthesis attribute">(</span><span class="none attribute">feature</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"alloc"</span><span class="parenthesis attribute">)</span><span class="comma attribute">,</span> <span class="none attribute">doc</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"```ignore"</span><span class="parenthesis attribute">)</span><span class="attribute_bracket attribute">]</span>
|
||||
<span class="comment documentation">///</span><span class="comment documentation"> </span><span class="keyword injected">let</span><span class="none injected"> </span><span class="punctuation injected">_</span><span class="none injected"> </span><span class="operator injected">=</span><span class="none injected"> </span><span class="function injected">example</span><span class="parenthesis injected">(</span><span class="operator injected">&</span><span class="module injected">alloc</span><span class="operator injected">::</span><span class="macro injected">vec</span><span class="macro_bang injected">!</span><span class="bracket injected macro">[</span><span class="numeric_literal injected macro">1</span><span class="comma injected macro">,</span><span class="none injected"> </span><span class="numeric_literal injected macro">2</span><span class="comma injected macro">,</span><span class="none injected"> </span><span class="numeric_literal injected macro">3</span><span class="bracket injected macro">]</span><span class="parenthesis injected">)</span><span class="semicolon injected">;</span>
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function declaration public">mix_and_match</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
||||
|
|
|
@ -49,13 +49,13 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
|||
<span class="keyword">mod</span> <span class="module declaration">inner</span> <span class="brace">{</span><span class="brace">}</span>
|
||||
|
||||
<span class="keyword">pub</span> <span class="keyword">mod</span> <span class="module declaration public">ops</span> <span class="brace">{</span>
|
||||
<span class="attribute_bracket attribute">#</span><span class="attribute_bracket attribute">[</span><span class="builtin_attr attribute library">lang</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"fn_once"</span><span class="attribute_bracket attribute">]</span>
|
||||
<span class="attribute_bracket attribute">#</span><span class="attribute_bracket attribute">[</span><span class="builtin_attr attribute">lang</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"fn_once"</span><span class="attribute_bracket attribute">]</span>
|
||||
<span class="keyword">pub</span> <span class="keyword">trait</span> <span class="trait declaration public">FnOnce</span><span class="angle"><</span><span class="type_param declaration">Args</span><span class="angle">></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">lang</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"fn_mut"</span><span class="attribute_bracket attribute">]</span>
|
||||
<span class="attribute_bracket attribute">#</span><span class="attribute_bracket attribute">[</span><span class="builtin_attr attribute">lang</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"fn_mut"</span><span class="attribute_bracket attribute">]</span>
|
||||
<span class="keyword">pub</span> <span class="keyword">trait</span> <span class="trait declaration public">FnMut</span><span class="angle"><</span><span class="type_param declaration">Args</span><span class="angle">></span><span class="colon">:</span> <span class="trait public">FnOnce</span><span class="angle"><</span><span class="type_param">Args</span><span class="angle">></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">lang</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"fn"</span><span class="attribute_bracket attribute">]</span>
|
||||
<span class="attribute_bracket attribute">#</span><span class="attribute_bracket attribute">[</span><span class="builtin_attr attribute">lang</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"fn"</span><span class="attribute_bracket attribute">]</span>
|
||||
<span class="keyword">pub</span> <span class="keyword">trait</span> <span class="trait declaration public">Fn</span><span class="angle"><</span><span class="type_param declaration">Args</span><span class="angle">></span><span class="colon">:</span> <span class="trait public">FnMut</span><span class="angle"><</span><span class="type_param">Args</span><span class="angle">></span> <span class="brace">{</span><span class="brace">}</span>
|
||||
<span class="brace">}</span>
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
|||
<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="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">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="keyword">struct</span> <span class="struct declaration">Packed</span> <span class="brace">{</span>
|
||||
<span class="field declaration">a</span><span class="colon">:</span> <span class="builtin_type">u16</span><span class="comma">,</span>
|
||||
<span class="brace">}</span>
|
||||
|
|
Loading…
Reference in a new issue