use crate::print::pprust;
use crate::ptr::P;
use crate::source_map::{dummy_spanned, respan, Spanned};
-use crate::symbol::{keywords, Symbol};
+use crate::symbol::{kw, sym, Symbol};
use crate::tokenstream::TokenStream;
use crate::ThinVec;
pub struct Path {
pub span: Span,
/// The segments in the path: the things separated by `::`.
- /// Global paths begin with `keywords::PathRoot`.
+ /// Global paths begin with `kw::PathRoot`.
pub segments: Vec<PathSegment>,
}
}
pub fn is_global(&self) -> bool {
- !self.segments.is_empty() && self.segments[0].ident.name == keywords::PathRoot.name()
+ !self.segments.is_empty() && self.segments[0].ident.name == kw::PathRoot
}
}
PathSegment { ident, id: DUMMY_NODE_ID, args: None }
}
pub fn path_root(span: Span) -> Self {
- PathSegment::from_ident(Ident::new(keywords::PathRoot.name(), span))
+ PathSegment::from_ident(Ident::new(kw::PathRoot, span))
}
}
pub fn precedence(&self) -> ExprPrecedence {
match self.node {
ExprKind::Box(_) => ExprPrecedence::Box,
- ExprKind::ObsoleteInPlace(..) => ExprPrecedence::ObsoleteInPlace,
ExprKind::Array(_) => ExprPrecedence::Array,
ExprKind::Call(..) => ExprPrecedence::Call,
ExprKind::MethodCall(..) => ExprPrecedence::MethodCall,
pub enum ExprKind {
/// A `box x` expression.
Box(P<Expr>),
- /// First expr is the place; second expr is the value.
- ObsoleteInPlace(P<Expr>, P<Expr>),
/// An array (`[a, b, c, d]`)
Array(Vec<P<Expr>>),
/// A function call
pub struct Lit {
/// The original literal token as written in source code.
pub token: token::Lit,
- /// The original literal suffix as written in source code.
- pub suffix: Option<Symbol>,
/// The "semantic" representation of the literal lowered from the original tokens.
/// Strings are unescaped, hexadecimal forms are eliminated, etc.
/// FIXME: Remove this and only create the semantic representation during lowering to HIR.
}
}
+ pub fn to_symbol(&self) -> Symbol {
+ match *self {
+ IntTy::Isize => sym::isize,
+ IntTy::I8 => sym::i8,
+ IntTy::I16 => sym::i16,
+ IntTy::I32 => sym::i32,
+ IntTy::I64 => sym::i64,
+ IntTy::I128 => sym::i128,
+ }
+ }
+
pub fn val_to_string(&self, val: i128) -> String {
// Cast to a `u128` so we can correctly print `INT128_MIN`. All integral types
// are parsed as `u128`, so we wouldn't want to print an extra negative
}
}
+ pub fn to_symbol(&self) -> Symbol {
+ match *self {
+ UintTy::Usize => sym::usize,
+ UintTy::U8 => sym::u8,
+ UintTy::U16 => sym::u16,
+ UintTy::U32 => sym::u32,
+ UintTy::U64 => sym::u64,
+ UintTy::U128 => sym::u128,
+ }
+ }
+
pub fn val_to_string(&self, val: u128) -> String {
format!("{}{}", val, self.ty_to_string())
}
impl Arg {
pub fn to_self(&self) -> Option<ExplicitSelf> {
if let PatKind::Ident(BindingMode::ByValue(mutbl), ident, _) = self.pat.node {
- if ident.name == keywords::SelfLower.name() {
+ if ident.name == kw::SelfLower {
return match self.ty.node {
TyKind::ImplicitSelf => Some(respan(self.pat.span, SelfKind::Value(mutbl))),
TyKind::Rptr(lt, MutTy { ref ty, mutbl }) if ty.node.is_implicit_self() => {
pub fn is_self(&self) -> bool {
if let PatKind::Ident(_, ident, _) = self.pat.node {
- ident.name == keywords::SelfLower.name()
+ ident.name == kw::SelfLower
} else {
false
}
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct PolyTraitRef {
- /// The `'a` in `<'a> Foo<&'a T>`
+ /// The `'a` in `<'a> Foo<&'a T>`.
pub bound_generic_params: Vec<GenericParam>,
- /// The `Foo<&'a T>` in `<'a> Foo<&'a T>`
+ /// The `Foo<&'a T>` in `<'a> Foo<&'a T>`.
pub trait_ref: TraitRef,
pub span: Span,