Skip to content

Commit 33603a6

Browse files
committed
Add ErrorGuaranteed to ast::LitKind::Err, token::LitKind::Err.
This mostly works well, and eliminates a couple of delayed bugs. One annoying thing is that we should really also add an `ErrorGuaranteed` to `proc_macro::bridge::LitKind::Err`. But that's difficult because `proc_macro` doesn't have access to `ErrorGuaranteed`, so we have to fake it.
1 parent b3b9f31 commit 33603a6

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

clippy_lints/src/matches/match_same_arms.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ impl<'a> NormalizedPat<'a> {
295295
LitKind::Char(val) => Self::LitInt(val.into()),
296296
LitKind::Int(val, _) => Self::LitInt(val.get()),
297297
LitKind::Bool(val) => Self::LitBool(val),
298-
LitKind::Float(..) | LitKind::Err => Self::Wild,
298+
LitKind::Float(..) => Self::Wild,
299+
LitKind::Err(guar) => Self::Err(guar),
299300
},
300301
_ => Self::Wild,
301302
},

clippy_lints/src/redundant_type_annotations.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl LateLintPass<'_> for RedundantTypeAnnotations {
200200
span_lint(cx, REDUNDANT_TYPE_ANNOTATIONS, local.span, "redundant type annotation");
201201
}
202202
},
203-
LitKind::Err => (),
203+
LitKind::Err(_) => (),
204204
LitKind::ByteStr(..) => {
205205
// We only lint if the type annotation is an array type (e.g. &[u8; 4]).
206206
// If instead it is a slice (e.g. &[u8]) it may not be redundant, so we

clippy_lints/src/utils/author.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
279279
match lit.value.node {
280280
LitKind::Bool(val) => kind!("Bool({val:?})"),
281281
LitKind::Char(c) => kind!("Char({c:?})"),
282-
LitKind::Err => kind!("Err"),
282+
LitKind::Err(_) => kind!("Err"),
283283
LitKind::Byte(b) => kind!("Byte({b})"),
284284
LitKind::Int(i, suffix) => {
285285
let int_ty = match suffix {

clippy_utils/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ pub fn lit_to_mir_constant<'tcx>(lit: &LitKind, ty: Option<Ty<'tcx>>) -> Constan
286286
_ => bug!(),
287287
},
288288
LitKind::Bool(b) => Constant::Bool(b),
289-
LitKind::Err => Constant::Err,
289+
LitKind::Err(_) => Constant::Err,
290290
}
291291
}
292292

0 commit comments

Comments
 (0)