}
/// A statement.
-#[derive(RustcEncodable, RustcDecodable)]
+#[derive(RustcEncodable, RustcDecodable, HashStable)]
pub struct Stmt {
pub hir_id: HirId,
pub kind: StmtKind,
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
-static_assert_size!(Expr, 72);
+static_assert_size!(Expr, 64);
impl Expr {
pub fn precedence(&self) -> ExprPrecedence {
Ret(Option<P<Expr>>),
/// Inline assembly (from `asm!`), with its outputs and inputs.
- InlineAsm(P<InlineAsm>, HirVec<Expr>, HirVec<Expr>),
+ InlineAsm(P<InlineAsm>),
/// A struct or struct-like variant literal expression.
///
AwaitDesugar,
}
+impl MatchSource {
+ pub fn name(self) -> &'static str {
+ use MatchSource::*;
+ match self {
+ Normal => "match",
+ IfDesugar { .. } | IfLetDesugar { .. } => "if",
+ WhileDesugar | WhileLetDesugar => "while",
+ ForLoopDesugar => "for",
+ TryDesugar => "?",
+ AwaitDesugar => ".await",
+ }
+ }
+}
+
/// The loop type that yielded an `ExprKind::Loop`.
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
pub enum LoopSource {
pub fn name(self) -> &'static str {
match self {
LoopSource::Loop => "loop",
- LoopSource::While => "while",
- LoopSource::WhileLet => "while let",
+ LoopSource::While | LoopSource::WhileLet => "while",
LoopSource::ForLoop => "for",
}
}
/// Bindings like `A: Debug` are represented as a special type `A =
/// $::Debug` that is understood by the astconv code.
///
-/// FIXME(alexreg) -- why have a separate type for the binding case,
-/// wouldn't it be better to make the `ty` field an enum like:
+/// FIXME(alexreg): why have a separate type for the binding case,
+/// wouldn't it be better to make the `ty` field an enum like the
+/// following?
///
/// ```
/// enum TypeBindingKind {
Err,
}
-#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
+#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, HashStable, PartialEq)]
pub struct InlineAsmOutput {
pub constraint: Symbol,
pub is_rw: bool,
// NOTE(eddyb) This is used within MIR as well, so unlike the rest of the HIR,
// it needs to be `Clone` and use plain `Vec<T>` instead of `HirVec<T>`.
-#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
-pub struct InlineAsm {
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable, PartialEq)]
+pub struct InlineAsmInner {
pub asm: Symbol,
pub asm_str_style: StrStyle,
pub outputs: Vec<InlineAsmOutput>,
pub dialect: AsmDialect,
}
+#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
+pub struct InlineAsm {
+ pub inner: InlineAsmInner,
+ pub outputs_exprs: HirVec<Expr>,
+ pub inputs_exprs: HirVec<Expr>,
+}
+
/// Represents a parameter in a function header.
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
pub struct Param {