mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Annotate some more bugs
This commit is contained in:
parent
70b9dad3dc
commit
1cc0d7d56c
@ -336,7 +336,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
hir::InlineAsmOperand::Const { .. }
|
||||
| hir::InlineAsmOperand::SymFn { .. }
|
||||
| hir::InlineAsmOperand::SymStatic { .. } => {
|
||||
unreachable!()
|
||||
unreachable!("{op:?} is not a register operand");
|
||||
}
|
||||
};
|
||||
|
||||
@ -380,7 +380,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
{
|
||||
reg_sym.as_str()
|
||||
} else {
|
||||
unreachable!();
|
||||
unreachable!("{op:?} is not a register operand");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -421,8 +421,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
}
|
||||
ItemKind::MacroDef(MacroDef { body, macro_rules }) => {
|
||||
let body = P(self.lower_delim_args(body));
|
||||
let DefKind::Macro(macro_kind) = self.tcx.def_kind(self.local_def_id(id)) else {
|
||||
unreachable!()
|
||||
let def_id = self.local_def_id(id);
|
||||
let def_kind = self.tcx.def_kind(def_id);
|
||||
let DefKind::Macro(macro_kind) = def_kind else {
|
||||
unreachable!(
|
||||
"expected DefKind::Macro for macro item, found {}",
|
||||
def_kind.descr(def_id.to_def_id())
|
||||
);
|
||||
};
|
||||
let macro_def = self.arena.alloc(ast::MacroDef { body, macro_rules: *macro_rules });
|
||||
hir::ItemKind::Macro(macro_def, macro_kind)
|
||||
|
@ -994,15 +994,6 @@ fn check_associated_item(
|
||||
})
|
||||
}
|
||||
|
||||
fn item_adt_kind(kind: &ItemKind<'_>) -> Option<AdtKind> {
|
||||
match kind {
|
||||
ItemKind::Struct(..) => Some(AdtKind::Struct),
|
||||
ItemKind::Union(..) => Some(AdtKind::Union),
|
||||
ItemKind::Enum(..) => Some(AdtKind::Enum),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// In a type definition, we check that to ensure that the types of the fields are well-formed.
|
||||
fn check_type_defn<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
@ -149,7 +149,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum CastError {
|
||||
ErrorGuaranteed(ErrorGuaranteed),
|
||||
|
||||
|
@ -71,7 +71,7 @@ impl std::fmt::Debug for ConstInt {
|
||||
(4, _) => write!(fmt, "_i32")?,
|
||||
(8, _) => write!(fmt, "_i64")?,
|
||||
(16, _) => write!(fmt, "_i128")?,
|
||||
_ => bug!(),
|
||||
(sz, _) => bug!("unexpected int size i{sz}"),
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@ -105,7 +105,7 @@ impl std::fmt::Debug for ConstInt {
|
||||
(4, _) => write!(fmt, "_u32")?,
|
||||
(8, _) => write!(fmt, "_u64")?,
|
||||
(16, _) => write!(fmt, "_u128")?,
|
||||
_ => bug!(),
|
||||
(sz, _) => bug!("unexpected unsigned int size u{sz}"),
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -421,13 +421,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
|
||||
let impl_args = match *self.type_of(impl_def_id).instantiate_identity().kind() {
|
||||
ty::Adt(def_, args) if def_ == def => args,
|
||||
_ => bug!(),
|
||||
_ => span_bug!(self.def_span(impl_def_id), "expected ADT for self type of `Drop` impl"),
|
||||
};
|
||||
|
||||
let item_args = match *self.type_of(def.did()).instantiate_identity().kind() {
|
||||
ty::Adt(def_, args) if def_ == def => args,
|
||||
_ => bug!(),
|
||||
};
|
||||
let item_args = ty::GenericArgs::identity_for_item(self, def.did());
|
||||
|
||||
let result = iter::zip(item_args, impl_args)
|
||||
.filter(|&(_, k)| {
|
||||
|
@ -640,7 +640,9 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -
|
||||
}
|
||||
DefKind::Closure if coroutine_kind.is_some() => {
|
||||
let coroutine_ty = tcx.type_of(def_id).instantiate_identity();
|
||||
let ty::Coroutine(_, args, _) = coroutine_ty.kind() else { bug!() };
|
||||
let ty::Coroutine(_, args, _) = coroutine_ty.kind() else {
|
||||
bug!("expected type of coroutine-like closure to be a coroutine")
|
||||
};
|
||||
let args = args.as_coroutine();
|
||||
let yield_ty = args.yield_ty();
|
||||
let return_ty = args.return_ty();
|
||||
@ -648,7 +650,9 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -
|
||||
}
|
||||
DefKind::Closure => {
|
||||
let closure_ty = tcx.type_of(def_id).instantiate_identity();
|
||||
let ty::Closure(_, args) = closure_ty.kind() else { bug!() };
|
||||
let ty::Closure(_, args) = closure_ty.kind() else {
|
||||
bug!("expected type of closure to be a closure")
|
||||
};
|
||||
let args = args.as_closure();
|
||||
let sig = tcx.liberate_late_bound_regions(def_id.to_def_id(), args.sig());
|
||||
let self_ty = match args.kind() {
|
||||
|
@ -782,7 +782,7 @@ impl<'tcx> Cx<'tcx> {
|
||||
hir::ExprKind::Tup(fields) => ExprKind::Tuple { fields: self.mirror_exprs(fields) },
|
||||
|
||||
hir::ExprKind::Yield(v, _) => ExprKind::Yield { value: self.mirror_expr(v) },
|
||||
hir::ExprKind::Err(_) => unreachable!(),
|
||||
hir::ExprKind::Err(_) => unreachable!("cannot lower a `hir::ExprKind::Err` to THIR"),
|
||||
};
|
||||
|
||||
Expr { temp_lifetime, ty: expr_ty, span: expr.span, kind }
|
||||
|
@ -492,8 +492,9 @@ impl<'tcx> ConstToPat<'tcx> {
|
||||
PatKind::Constant { value: mir::Const::Ty(ty::Const::new_value(tcx, cv, ty)) }
|
||||
}
|
||||
ty::FnPtr(..) => {
|
||||
// Valtree construction would never succeed for these, so this is unreachable.
|
||||
unreachable!()
|
||||
unreachable!(
|
||||
"Valtree construction would never succeed for FnPtr, so this is unreachable."
|
||||
)
|
||||
}
|
||||
_ => {
|
||||
let err = InvalidPattern { span, non_sm_ty: ty };
|
||||
|
Loading…
Reference in New Issue
Block a user