mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Remove TypeRef
from item opts which implement TypeAscriptionOwner
This commit is contained in:
parent
52054e1140
commit
d3ce69aee3
6 changed files with 24 additions and 43 deletions
|
@ -6,7 +6,7 @@ use std::sync::Arc;
|
||||||
use ra_arena::{RawId, Arena, impl_arena_id};
|
use ra_arena::{RawId, Arena, impl_arena_id};
|
||||||
use ra_syntax::{
|
use ra_syntax::{
|
||||||
TreeArc,
|
TreeArc,
|
||||||
ast::{self, NameOwner, StructFlavor}
|
ast::{self, NameOwner, StructFlavor, TypeAscriptionOwner}
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -164,7 +164,7 @@ impl VariantData {
|
||||||
.fields()
|
.fields()
|
||||||
.map(|fd| StructFieldData {
|
.map(|fd| StructFieldData {
|
||||||
name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing),
|
name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing),
|
||||||
type_ref: TypeRef::from_ast_opt(fd.type_ref()),
|
type_ref: TypeRef::from_ast_opt(fd.ascribed_type()),
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
VariantDataInner::Struct(fields)
|
VariantDataInner::Struct(fields)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use ra_syntax::ast::{self, NameOwner};
|
use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Name, AsName, Function, FnSignature,
|
Name, AsName, Function, FnSignature,
|
||||||
|
@ -19,7 +19,7 @@ impl FnSignature {
|
||||||
let mut has_self_param = false;
|
let mut has_self_param = false;
|
||||||
if let Some(param_list) = node.param_list() {
|
if let Some(param_list) = node.param_list() {
|
||||||
if let Some(self_param) = param_list.self_param() {
|
if let Some(self_param) = param_list.self_param() {
|
||||||
let self_type = if let Some(type_ref) = self_param.type_ref() {
|
let self_type = if let Some(type_ref) = self_param.ascribed_type() {
|
||||||
TypeRef::from_ast(type_ref)
|
TypeRef::from_ast(type_ref)
|
||||||
} else {
|
} else {
|
||||||
let self_type = TypeRef::Path(Name::self_type().into());
|
let self_type = TypeRef::Path(Name::self_type().into());
|
||||||
|
@ -37,7 +37,7 @@ impl FnSignature {
|
||||||
has_self_param = true;
|
has_self_param = true;
|
||||||
}
|
}
|
||||||
for param in param_list.params() {
|
for param in param_list.params() {
|
||||||
let type_ref = TypeRef::from_ast_opt(param.type_ref());
|
let type_ref = TypeRef::from_ast_opt(param.ascribed_type());
|
||||||
params.push(type_ref);
|
params.push(type_ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use rustc_hash::FxHashMap;
|
||||||
use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap};
|
use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap};
|
||||||
use ra_syntax::{
|
use ra_syntax::{
|
||||||
SyntaxNodePtr, AstNode,
|
SyntaxNodePtr, AstNode,
|
||||||
ast::{self, LoopBodyOwner, ArgListOwner, NameOwner, LiteralFlavor}
|
ast::{self, LoopBodyOwner, ArgListOwner, NameOwner, LiteralFlavor, TypeAscriptionOwner}
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -709,7 +709,7 @@ impl ExprCollector {
|
||||||
if let Some(pl) = e.param_list() {
|
if let Some(pl) = e.param_list() {
|
||||||
for param in pl.params() {
|
for param in pl.params() {
|
||||||
let pat = self.collect_pat_opt(param.pat());
|
let pat = self.collect_pat_opt(param.pat());
|
||||||
let type_ref = param.type_ref().map(TypeRef::from_ast);
|
let type_ref = param.ascribed_type().map(TypeRef::from_ast);
|
||||||
args.push(pat);
|
args.push(pat);
|
||||||
arg_types.push(type_ref);
|
arg_types.push(type_ref);
|
||||||
}
|
}
|
||||||
|
@ -790,7 +790,7 @@ impl ExprCollector {
|
||||||
.map(|s| match s.kind() {
|
.map(|s| match s.kind() {
|
||||||
ast::StmtKind::LetStmt(stmt) => {
|
ast::StmtKind::LetStmt(stmt) => {
|
||||||
let pat = self.collect_pat_opt(stmt.pat());
|
let pat = self.collect_pat_opt(stmt.pat());
|
||||||
let type_ref = stmt.type_ref().map(TypeRef::from_ast);
|
let type_ref = stmt.ascribed_type().map(TypeRef::from_ast);
|
||||||
let initializer = stmt.initializer().map(|e| self.collect_expr(e));
|
let initializer = stmt.initializer().map(|e| self.collect_expr(e));
|
||||||
Statement::Let { pat, type_ref, initializer }
|
Statement::Let { pat, type_ref, initializer }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! HIR for references to types. Paths in these are not yet resolved. They can
|
//! HIR for references to types. Paths in these are not yet resolved. They can
|
||||||
//! be directly created from an ast::TypeRef, without further queries.
|
//! be directly created from an ast::TypeRef, without further queries.
|
||||||
|
|
||||||
use ra_syntax::ast;
|
use ra_syntax::ast::{self, TypeAscriptionOwner};
|
||||||
|
|
||||||
use crate::Path;
|
use crate::Path;
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ impl TypeRef {
|
||||||
FnPointerType(inner) => {
|
FnPointerType(inner) => {
|
||||||
let ret_ty = TypeRef::from_ast_opt(inner.ret_type().and_then(|rt| rt.type_ref()));
|
let ret_ty = TypeRef::from_ast_opt(inner.ret_type().and_then(|rt| rt.type_ref()));
|
||||||
let mut params = if let Some(pl) = inner.param_list() {
|
let mut params = if let Some(pl) = inner.param_list() {
|
||||||
pl.params().map(|p| p.type_ref()).map(TypeRef::from_ast_opt).collect()
|
pl.params().map(|p| p.ascribed_type()).map(TypeRef::from_ast_opt).collect()
|
||||||
} else {
|
} else {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
};
|
};
|
||||||
|
|
|
@ -629,11 +629,7 @@ impl ast::TypeParamsOwner for ConstDef {}
|
||||||
impl ast::AttrsOwner for ConstDef {}
|
impl ast::AttrsOwner for ConstDef {}
|
||||||
impl ast::DocCommentsOwner for ConstDef {}
|
impl ast::DocCommentsOwner for ConstDef {}
|
||||||
impl ast::TypeAscriptionOwner for ConstDef {}
|
impl ast::TypeAscriptionOwner for ConstDef {}
|
||||||
impl ConstDef {
|
impl ConstDef {}
|
||||||
pub fn type_ref(&self) -> Option<&TypeRef> {
|
|
||||||
super::child_opt(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ContinueExpr
|
// ContinueExpr
|
||||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||||
|
@ -1774,10 +1770,6 @@ impl LetStmt {
|
||||||
super::child_opt(self)
|
super::child_opt(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn type_ref(&self) -> Option<&TypeRef> {
|
|
||||||
super::child_opt(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn initializer(&self) -> Option<&Expr> {
|
pub fn initializer(&self) -> Option<&Expr> {
|
||||||
super::child_opt(self)
|
super::child_opt(self)
|
||||||
}
|
}
|
||||||
|
@ -2595,11 +2587,7 @@ impl ast::NameOwner for NamedFieldDef {}
|
||||||
impl ast::AttrsOwner for NamedFieldDef {}
|
impl ast::AttrsOwner for NamedFieldDef {}
|
||||||
impl ast::DocCommentsOwner for NamedFieldDef {}
|
impl ast::DocCommentsOwner for NamedFieldDef {}
|
||||||
impl ast::TypeAscriptionOwner for NamedFieldDef {}
|
impl ast::TypeAscriptionOwner for NamedFieldDef {}
|
||||||
impl NamedFieldDef {
|
impl NamedFieldDef {}
|
||||||
pub fn type_ref(&self) -> Option<&TypeRef> {
|
|
||||||
super::child_opt(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NamedFieldDefList
|
// NamedFieldDefList
|
||||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||||
|
@ -2782,10 +2770,6 @@ impl Param {
|
||||||
pub fn pat(&self) -> Option<&Pat> {
|
pub fn pat(&self) -> Option<&Pat> {
|
||||||
super::child_opt(self)
|
super::child_opt(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn type_ref(&self) -> Option<&TypeRef> {
|
|
||||||
super::child_opt(self)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParamList
|
// ParamList
|
||||||
|
@ -3691,10 +3675,6 @@ impl ToOwned for SelfParam {
|
||||||
|
|
||||||
impl ast::TypeAscriptionOwner for SelfParam {}
|
impl ast::TypeAscriptionOwner for SelfParam {}
|
||||||
impl SelfParam {
|
impl SelfParam {
|
||||||
pub fn type_ref(&self) -> Option<&TypeRef> {
|
|
||||||
super::child_opt(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn self_kw(&self) -> Option<&SelfKw> {
|
pub fn self_kw(&self) -> Option<&SelfKw> {
|
||||||
super::child_opt(self)
|
super::child_opt(self)
|
||||||
}
|
}
|
||||||
|
@ -3826,11 +3806,7 @@ impl ast::TypeParamsOwner for StaticDef {}
|
||||||
impl ast::AttrsOwner for StaticDef {}
|
impl ast::AttrsOwner for StaticDef {}
|
||||||
impl ast::DocCommentsOwner for StaticDef {}
|
impl ast::DocCommentsOwner for StaticDef {}
|
||||||
impl ast::TypeAscriptionOwner for StaticDef {}
|
impl ast::TypeAscriptionOwner for StaticDef {}
|
||||||
impl StaticDef {
|
impl StaticDef {}
|
||||||
pub fn type_ref(&self) -> Option<&TypeRef> {
|
|
||||||
super::child_opt(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stmt
|
// Stmt
|
||||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||||
|
|
|
@ -271,7 +271,15 @@ Grammar(
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
"NamedFieldDefList": (collections: [["fields", "NamedFieldDef"]]),
|
"NamedFieldDefList": (collections: [["fields", "NamedFieldDef"]]),
|
||||||
"NamedFieldDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner", "TypeAscriptionOwner"], options: ["TypeRef"] ),
|
"NamedFieldDef": (
|
||||||
|
traits: [
|
||||||
|
"VisibilityOwner",
|
||||||
|
"NameOwner",
|
||||||
|
"AttrsOwner",
|
||||||
|
"DocCommentsOwner",
|
||||||
|
"TypeAscriptionOwner"
|
||||||
|
]
|
||||||
|
),
|
||||||
"PosFieldDefList": (collections: [["fields", "PosFieldDef"]]),
|
"PosFieldDefList": (collections: [["fields", "PosFieldDef"]]),
|
||||||
"PosFieldDef": ( traits: ["VisibilityOwner", "AttrsOwner"], options: ["TypeRef"]),
|
"PosFieldDef": ( traits: ["VisibilityOwner", "AttrsOwner"], options: ["TypeRef"]),
|
||||||
"EnumDef": ( traits: [
|
"EnumDef": ( traits: [
|
||||||
|
@ -301,7 +309,6 @@ Grammar(
|
||||||
"DocCommentsOwner",
|
"DocCommentsOwner",
|
||||||
"TypeAscriptionOwner",
|
"TypeAscriptionOwner",
|
||||||
],
|
],
|
||||||
options: ["TypeRef"]
|
|
||||||
),
|
),
|
||||||
"StaticDef": (
|
"StaticDef": (
|
||||||
traits: [
|
traits: [
|
||||||
|
@ -312,7 +319,6 @@ Grammar(
|
||||||
"DocCommentsOwner",
|
"DocCommentsOwner",
|
||||||
"TypeAscriptionOwner",
|
"TypeAscriptionOwner",
|
||||||
],
|
],
|
||||||
options: ["TypeRef"]
|
|
||||||
),
|
),
|
||||||
"TypeAliasDef": (
|
"TypeAliasDef": (
|
||||||
traits: [
|
traits: [
|
||||||
|
@ -574,7 +580,6 @@ Grammar(
|
||||||
"LetStmt": (
|
"LetStmt": (
|
||||||
options: [
|
options: [
|
||||||
["pat", "Pat"],
|
["pat", "Pat"],
|
||||||
["type_ref", "TypeRef"],
|
|
||||||
["initializer", "Expr"],
|
["initializer", "Expr"],
|
||||||
],
|
],
|
||||||
traits: [
|
traits: [
|
||||||
|
@ -603,14 +608,14 @@ Grammar(
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
"SelfParam": (
|
"SelfParam": (
|
||||||
options: ["TypeRef", "SelfKw"],
|
options: ["SelfKw"],
|
||||||
traits: [
|
traits: [
|
||||||
"TypeAscriptionOwner",
|
"TypeAscriptionOwner",
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
"SelfKw": (),
|
"SelfKw": (),
|
||||||
"Param": (
|
"Param": (
|
||||||
options: [ "Pat", "TypeRef" ],
|
options: [ "Pat" ],
|
||||||
traits: [
|
traits: [
|
||||||
"TypeAscriptionOwner",
|
"TypeAscriptionOwner",
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue