StaticForeignItem and StaticItem are the same
This commit is contained in:
parent
cb8a7ea0ed
commit
3e59f0c3c5
9 changed files with 10 additions and 67 deletions
|
@ -3184,38 +3184,6 @@ pub struct StaticItem {
|
|||
pub expr: Option<P<Expr>>,
|
||||
}
|
||||
|
||||
/// A static item in `extern` block.
|
||||
// This struct is identical to StaticItem for now but it's going to have a safety attribute.
|
||||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
pub struct StaticForeignItem {
|
||||
pub ty: P<Ty>,
|
||||
pub safety: Safety,
|
||||
pub mutability: Mutability,
|
||||
pub expr: Option<P<Expr>>,
|
||||
}
|
||||
|
||||
impl From<StaticItem> for StaticForeignItem {
|
||||
fn from(static_item: StaticItem) -> StaticForeignItem {
|
||||
StaticForeignItem {
|
||||
ty: static_item.ty,
|
||||
safety: static_item.safety,
|
||||
mutability: static_item.mutability,
|
||||
expr: static_item.expr,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StaticForeignItem> for StaticItem {
|
||||
fn from(static_item: StaticForeignItem) -> StaticItem {
|
||||
StaticItem {
|
||||
ty: static_item.ty,
|
||||
safety: static_item.safety,
|
||||
mutability: static_item.mutability,
|
||||
expr: static_item.expr,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
pub struct ConstItem {
|
||||
pub defaultness: Defaultness,
|
||||
|
@ -3430,7 +3398,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
|
|||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
pub enum ForeignItemKind {
|
||||
/// A foreign static item (`static FOO: u8`).
|
||||
Static(Box<StaticForeignItem>),
|
||||
Static(Box<StaticItem>),
|
||||
/// An foreign function.
|
||||
Fn(Box<Fn>),
|
||||
/// An foreign type.
|
||||
|
|
|
@ -1310,12 +1310,7 @@ pub fn noop_flat_map_item<K: NoopVisitItemKind>(
|
|||
impl NoopVisitItemKind for ForeignItemKind {
|
||||
fn noop_visit(&mut self, visitor: &mut impl MutVisitor) {
|
||||
match self {
|
||||
ForeignItemKind::Static(box StaticForeignItem {
|
||||
ty,
|
||||
mutability: _,
|
||||
expr,
|
||||
safety: _,
|
||||
}) => {
|
||||
ForeignItemKind::Static(box StaticItem { ty, mutability: _, expr, safety: _ }) => {
|
||||
visitor.visit_ty(ty);
|
||||
visit_opt(expr, |expr| visitor.visit_expr(expr));
|
||||
}
|
||||
|
|
|
@ -672,12 +672,7 @@ impl WalkItemKind for ForeignItemKind {
|
|||
) -> V::Result {
|
||||
let &Item { id, span, ident, ref vis, .. } = item;
|
||||
match self {
|
||||
ForeignItemKind::Static(box StaticForeignItem {
|
||||
ty,
|
||||
mutability: _,
|
||||
expr,
|
||||
safety: _,
|
||||
}) => {
|
||||
ForeignItemKind::Static(box StaticItem { ty, mutability: _, expr, safety: _ }) => {
|
||||
try_visit!(visitor.visit_ty(ty));
|
||||
visit_opt!(visitor, visit_expr, expr);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue