mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-04 17:40:50 +00:00
Merge #1076
1076: Const body inference r=flodiebold a=Lapz This is the second part of #887. I've added type inference on const bodies and introduced the DefWithBody containing Function, Const and Static. I want to add tests but im unsure on how I would go about testing that completions work. Co-authored-by: Lenard Pratt <l3np27@gmail.com>
This commit is contained in:
commit
fdbebccd71
10 changed files with 231 additions and 49 deletions
|
@ -513,7 +513,11 @@ impl ast::TypeParamsOwner for ConstDef {}
|
|||
impl ast::AttrsOwner for ConstDef {}
|
||||
impl ast::DocCommentsOwner for ConstDef {}
|
||||
impl ast::TypeAscriptionOwner for ConstDef {}
|
||||
impl ConstDef {}
|
||||
impl ConstDef {
|
||||
pub fn body(&self) -> Option<&Expr> {
|
||||
super::child_opt(self)
|
||||
}
|
||||
}
|
||||
|
||||
// ContinueExpr
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
|
@ -3364,7 +3368,11 @@ impl ast::TypeParamsOwner for StaticDef {}
|
|||
impl ast::AttrsOwner for StaticDef {}
|
||||
impl ast::DocCommentsOwner for StaticDef {}
|
||||
impl ast::TypeAscriptionOwner for StaticDef {}
|
||||
impl StaticDef {}
|
||||
impl StaticDef {
|
||||
pub fn body(&self) -> Option<&Expr> {
|
||||
super::child_opt(self)
|
||||
}
|
||||
}
|
||||
|
||||
// Stmt
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -315,6 +315,7 @@ Grammar(
|
|||
"DocCommentsOwner",
|
||||
"TypeAscriptionOwner",
|
||||
],
|
||||
options: [ ["body","Expr"]],
|
||||
),
|
||||
"StaticDef": (
|
||||
traits: [
|
||||
|
@ -325,6 +326,7 @@ Grammar(
|
|||
"DocCommentsOwner",
|
||||
"TypeAscriptionOwner",
|
||||
],
|
||||
options: [ ["body","Expr"]],
|
||||
),
|
||||
"TypeAliasDef": (
|
||||
traits: [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue