Skip to content

Commit a747dbb

Browse files
author
Michael Wright
committed
Fix breakage due to #57651
1 parent 8747691 commit a747dbb

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Diff for: clippy_lints/src/consts.rs

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::convert::TryInto;
1414
use std::hash::{Hash, Hasher};
1515
use syntax::ast::{FloatTy, LitKind};
1616
use syntax::ptr::P;
17+
use syntax_pos::symbol::Symbol;
1718

1819
/// A `LitKind`-like enum to fold constant `Expr`s into.
1920
#[derive(Debug, Clone)]
@@ -38,6 +39,8 @@ pub enum Constant {
3839
Repeat(Box<Constant>, u64),
3940
/// a tuple of constants
4041
Tuple(Vec<Constant>),
42+
/// a literal with syntax error
43+
Err(Symbol),
4144
}
4245

4346
impl PartialEq for Constant {
@@ -103,6 +106,9 @@ impl Hash for Constant {
103106
c.hash(state);
104107
l.hash(state);
105108
},
109+
Constant::Err(ref s) => {
110+
s.hash(state);
111+
},
106112
}
107113
}
108114
}
@@ -155,6 +161,7 @@ pub fn lit_to_constant<'tcx>(lit: &LitKind, ty: Ty<'tcx>) -> Constant {
155161
_ => bug!(),
156162
},
157163
LitKind::Bool(b) => Constant::Bool(b),
164+
LitKind::Err(s) => Constant::Err(s),
158165
}
159166
}
160167

Diff for: clippy_lints/src/utils/author.rs

+1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
260260
match lit.node {
261261
LitKind::Bool(val) => println!(" if let LitKind::Bool({:?}) = {}.node;", val, lit_pat),
262262
LitKind::Char(c) => println!(" if let LitKind::Char({:?}) = {}.node;", c, lit_pat),
263+
LitKind::Err(val) => println!(" if let LitKind::Err({}) = {}.node;", val, lit_pat),
263264
LitKind::Byte(b) => println!(" if let LitKind::Byte({}) = {}.node;", b, lit_pat),
264265
// FIXME: also check int type
265266
LitKind::Int(i, _) => println!(" if let LitKind::Int({}, _) = {}.node;", i, lit_pat),

0 commit comments

Comments
 (0)