Rollup merge of #121120 - nnethercote:LitKind-Err-guar, r=fmease

Add `ErrorGuaranteed` to `ast::LitKind::Err`, `token::LitKind::Err`.

Similar to recent work doing the same for `ExprKind::Err` (#120586) and `TyKind::Err` (#121109).

r? `@oli-obk`
This commit is contained in:
Guillaume Gomez 2024-02-15 14:33:03 +01:00 committed by GitHub
commit f9b867207e
4 changed files with 5 additions and 4 deletions

View File

@ -295,7 +295,8 @@ impl<'a> NormalizedPat<'a> {
LitKind::Char(val) => Self::LitInt(val.into()),
LitKind::Int(val, _) => Self::LitInt(val.get()),
LitKind::Bool(val) => Self::LitBool(val),
LitKind::Float(..) | LitKind::Err => Self::Wild,
LitKind::Float(..) => Self::Wild,
LitKind::Err(guar) => Self::Err(guar),
},
_ => Self::Wild,
},

View File

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

View File

@ -279,7 +279,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
match lit.value.node {
LitKind::Bool(val) => kind!("Bool({val:?})"),
LitKind::Char(c) => kind!("Char({c:?})"),
LitKind::Err => kind!("Err"),
LitKind::Err(_) => kind!("Err"),
LitKind::Byte(b) => kind!("Byte({b})"),
LitKind::Int(i, suffix) => {
let int_ty = match suffix {

View File

@ -286,7 +286,7 @@ pub fn lit_to_mir_constant<'tcx>(lit: &LitKind, ty: Option<Ty<'tcx>>) -> Constan
_ => bug!(),
},
LitKind::Bool(b) => Constant::Bool(b),
LitKind::Err => Constant::Err,
LitKind::Err(_) => Constant::Err,
}
}