/// The segments in the path: the things separated by `::`.
/// Global paths begin with `kw::PathRoot`.
pub segments: Vec<PathSegment>,
+ pub tokens: Option<TokenStream>,
}
impl PartialEq<Symbol> for Path {
// Convert a span and an identifier to the corresponding
// one-segment path.
pub fn from_ident(ident: Ident) -> Path {
- Path { segments: vec![PathSegment::from_ident(ident)], span: ident.span }
+ Path { segments: vec![PathSegment::from_ident(ident)], span: ident.span, tokens: None }
}
pub fn is_global(&self) -> bool {
/// Distinguishes between `unsafe { ... }` and `{ ... }`.
pub rules: BlockCheckMode,
pub span: Span,
+ pub tokens: Option<TokenStream>,
}
/// A match pattern.
_ => return None,
};
- Some(P(Ty { kind, id: self.id, span: self.span }))
+ Some(P(Ty { kind, id: self.id, span: self.span, tokens: None }))
}
/// Walk top-down and call `it` in each place where a pattern occurs
pub id: NodeId,
pub kind: StmtKind,
pub span: Span,
+ pub tokens: Option<TokenStream>,
}
impl Stmt {
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
-rustc_data_structures::static_assert_size!(Expr, 104);
+rustc_data_structures::static_assert_size!(Expr, 112);
impl Expr {
/// Returns `true` if this expression would be valid somewhere that expects a value;
_ => return None,
};
- Some(P(Ty { kind, id: self.id, span: self.span }))
+ Some(P(Ty { kind, id: self.id, span: self.span, tokens: None }))
}
pub fn precedence(&self) -> ExprPrecedence {
pub id: NodeId,
pub kind: TyKind,
pub span: Span,
+ pub tokens: Option<TokenStream>,
}
#[derive(Clone, Encodable, Decodable, Debug)]
impl TyKind {
pub fn is_implicit_self(&self) -> bool {
- if let TyKind::ImplicitSelf = *self { true } else { false }
+ matches!(self, TyKind::ImplicitSelf)
}
pub fn is_unit(&self) -> bool {
/// Builds a `Param` object from `ExplicitSelf`.
pub fn from_self(attrs: AttrVec, eself: ExplicitSelf, eself_ident: Ident) -> Param {
let span = eself.span.to(eself_ident.span);
- let infer_ty = P(Ty { id: DUMMY_NODE_ID, kind: TyKind::ImplicitSelf, span });
+ let infer_ty = P(Ty { id: DUMMY_NODE_ID, kind: TyKind::ImplicitSelf, span, tokens: None });
let param = |mutbl, ty| Param {
attrs,
pat: P(Pat {
id: DUMMY_NODE_ID,
kind: TyKind::Rptr(lt, MutTy { ty: infer_ty, mutbl }),
span,
+ tokens: None,
}),
),
}
impl Async {
pub fn is_async(self) -> bool {
- if let Async::Yes { .. } = self { true } else { false }
+ matches!(self, Async::Yes { .. })
}
/// In this case this is an `async` return, the `NodeId` for the generated `impl Trait` item.
/// Module declaration.
///
/// E.g., `mod foo;` or `mod foo { .. }`.
-#[derive(Clone, Encodable, Decodable, Debug, Default)]
+#[derive(Clone, Encodable, Decodable, Debug)]
pub struct Mod {
/// A span from the first token past `{` to the last token until `}`.
/// For `mod foo;`, the inner span ranges from the first token
/// to the last token in the external file.
pub inner: Span,
+ /// `unsafe` keyword accepted syntactically for macro DSLs, but not
+ /// semantically by Rust.
+ pub unsafety: Unsafe,
pub items: Vec<P<Item>>,
/// `true` for `mod foo { .. }`; `false` for `mod foo;`.
pub inline: bool,
/// Foreign module declaration.
///
-/// E.g., `extern { .. }` or `extern C { .. }`.
+/// E.g., `extern { .. }` or `extern "C" { .. }`.
#[derive(Clone, Encodable, Decodable, Debug)]
pub struct ForeignMod {
+ /// `unsafe` keyword accepted syntactically for macro DSLs, but not
+ /// semantically by Rust.
+ pub unsafety: Unsafe,
pub abi: Option<StrLit>,
pub items: Vec<P<ForeignItem>>,
}
pub struct AttrItem {
pub path: Path,
pub args: MacArgs,
+ pub tokens: Option<TokenStream>,
}
/// A list of attributes.
JustCrate,
}
-pub type Visibility = Spanned<VisibilityKind>;
+#[derive(Clone, Encodable, Decodable, Debug)]
+pub struct Visibility {
+ pub kind: VisibilityKind,
+ pub span: Span,
+ pub tokens: Option<TokenStream>,
+}
#[derive(Clone, Encodable, Decodable, Debug)]
pub enum VisibilityKind {
impl VisibilityKind {
pub fn is_pub(&self) -> bool {
- if let VisibilityKind::Public = *self { true } else { false }
+ matches!(self, VisibilityKind::Public)
}
}