Fix breakage due to rust-lang/rust#57651
This commit is contained in:
parent
8747691bea
commit
a747dbb04f
2 changed files with 8 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ use std::convert::TryInto;
|
|||
use std::hash::{Hash, Hasher};
|
||||
use syntax::ast::{FloatTy, LitKind};
|
||||
use syntax::ptr::P;
|
||||
use syntax_pos::symbol::Symbol;
|
||||
|
||||
/// A `LitKind`-like enum to fold constant `Expr`s into.
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -38,6 +39,8 @@ pub enum Constant {
|
|||
Repeat(Box<Constant>, u64),
|
||||
/// a tuple of constants
|
||||
Tuple(Vec<Constant>),
|
||||
/// a literal with syntax error
|
||||
Err(Symbol),
|
||||
}
|
||||
|
||||
impl PartialEq for Constant {
|
||||
|
|
@ -103,6 +106,9 @@ impl Hash for Constant {
|
|||
c.hash(state);
|
||||
l.hash(state);
|
||||
},
|
||||
Constant::Err(ref s) => {
|
||||
s.hash(state);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -155,6 +161,7 @@ pub fn lit_to_constant<'tcx>(lit: &LitKind, ty: Ty<'tcx>) -> Constant {
|
|||
_ => bug!(),
|
||||
},
|
||||
LitKind::Bool(b) => Constant::Bool(b),
|
||||
LitKind::Err(s) => Constant::Err(s),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -260,6 +260,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
|
|||
match lit.node {
|
||||
LitKind::Bool(val) => println!(" if let LitKind::Bool({:?}) = {}.node;", val, lit_pat),
|
||||
LitKind::Char(c) => println!(" if let LitKind::Char({:?}) = {}.node;", c, lit_pat),
|
||||
LitKind::Err(val) => println!(" if let LitKind::Err({}) = {}.node;", val, lit_pat),
|
||||
LitKind::Byte(b) => println!(" if let LitKind::Byte({}) = {}.node;", b, lit_pat),
|
||||
// FIXME: also check int type
|
||||
LitKind::Int(i, _) => println!(" if let LitKind::Int({}, _) = {}.node;", i, lit_pat),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue