rust-analyzer guided tuple field to named field
This commit is contained in:
parent
b08a557f80
commit
e3828777a6
16 changed files with 33 additions and 24 deletions
|
@ -2891,7 +2891,11 @@ pub struct Fn {
|
|||
}
|
||||
|
||||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
pub struct Static(pub P<Ty>, pub Mutability, pub Option<P<Expr>>);
|
||||
pub struct Static {
|
||||
pub ty: P<Ty>,
|
||||
pub mutability: Mutability,
|
||||
pub expr: Option<P<Expr>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
pub enum ItemKind {
|
||||
|
@ -2978,7 +2982,7 @@ impl ItemKind {
|
|||
match self {
|
||||
ItemKind::ExternCrate(..) => "extern crate",
|
||||
ItemKind::Use(..) => "`use` import",
|
||||
ItemKind::Static(Static(..)) => "static item",
|
||||
ItemKind::Static(..) => "static item",
|
||||
ItemKind::Const(..) => "constant item",
|
||||
ItemKind::Fn(..) => "function",
|
||||
ItemKind::Mod(..) => "module",
|
||||
|
@ -3087,7 +3091,9 @@ pub enum ForeignItemKind {
|
|||
impl From<ForeignItemKind> for ItemKind {
|
||||
fn from(foreign_item_kind: ForeignItemKind) -> ItemKind {
|
||||
match foreign_item_kind {
|
||||
ForeignItemKind::Static(a, b, c) => ItemKind::Static(Static(a, b, c)),
|
||||
ForeignItemKind::Static(a, b, c) => {
|
||||
ItemKind::Static(Static { ty: a, mutability: b, expr: c })
|
||||
}
|
||||
ForeignItemKind::Fn(fn_kind) => ItemKind::Fn(fn_kind),
|
||||
ForeignItemKind::TyAlias(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind),
|
||||
ForeignItemKind::MacCall(a) => ItemKind::MacCall(a),
|
||||
|
@ -3100,7 +3106,9 @@ impl TryFrom<ItemKind> for ForeignItemKind {
|
|||
|
||||
fn try_from(item_kind: ItemKind) -> Result<ForeignItemKind, ItemKind> {
|
||||
Ok(match item_kind {
|
||||
ItemKind::Static(Static(a, b, c)) => ForeignItemKind::Static(a, b, c),
|
||||
ItemKind::Static(Static { ty: a, mutability: b, expr: c }) => {
|
||||
ForeignItemKind::Static(a, b, c)
|
||||
}
|
||||
ItemKind::Fn(fn_kind) => ForeignItemKind::Fn(fn_kind),
|
||||
ItemKind::TyAlias(ty_alias_kind) => ForeignItemKind::TyAlias(ty_alias_kind),
|
||||
ItemKind::MacCall(a) => ForeignItemKind::MacCall(a),
|
||||
|
|
|
@ -1030,7 +1030,7 @@ pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) {
|
|||
match kind {
|
||||
ItemKind::ExternCrate(_orig_name) => {}
|
||||
ItemKind::Use(use_tree) => vis.visit_use_tree(use_tree),
|
||||
ItemKind::Static(Static(ty, _, expr)) => {
|
||||
ItemKind::Static(Static { ty, mutability: _, expr }) => {
|
||||
vis.visit_ty(ty);
|
||||
visit_opt(expr, |expr| vis.visit_expr(expr));
|
||||
}
|
||||
|
|
|
@ -305,7 +305,8 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
|
|||
match &item.kind {
|
||||
ItemKind::ExternCrate(_) => {}
|
||||
ItemKind::Use(use_tree) => visitor.visit_use_tree(use_tree, item.id, false),
|
||||
ItemKind::Static(Static(typ, _, expr)) | ItemKind::Const(_, typ, expr) => {
|
||||
ItemKind::Static(Static { ty: typ, mutability: _, expr })
|
||||
| ItemKind::Const(_, typ, expr) => {
|
||||
visitor.visit_ty(typ);
|
||||
walk_list!(visitor, visit_expr, expr);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue