Annotate some more bugs
This commit is contained in:
parent
70b9dad3dc
commit
1cc0d7d56c
9 changed files with 24 additions and 26 deletions
|
@ -336,7 +336,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
hir::InlineAsmOperand::Const { .. }
|
hir::InlineAsmOperand::Const { .. }
|
||||||
| hir::InlineAsmOperand::SymFn { .. }
|
| hir::InlineAsmOperand::SymFn { .. }
|
||||||
| hir::InlineAsmOperand::SymStatic { .. } => {
|
| 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()
|
reg_sym.as_str()
|
||||||
} else {
|
} else {
|
||||||
unreachable!();
|
unreachable!("{op:?} is not a register operand");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -421,8 +421,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
}
|
}
|
||||||
ItemKind::MacroDef(MacroDef { body, macro_rules }) => {
|
ItemKind::MacroDef(MacroDef { body, macro_rules }) => {
|
||||||
let body = P(self.lower_delim_args(body));
|
let body = P(self.lower_delim_args(body));
|
||||||
let DefKind::Macro(macro_kind) = self.tcx.def_kind(self.local_def_id(id)) else {
|
let def_id = self.local_def_id(id);
|
||||||
unreachable!()
|
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 });
|
let macro_def = self.arena.alloc(ast::MacroDef { body, macro_rules: *macro_rules });
|
||||||
hir::ItemKind::Macro(macro_def, macro_kind)
|
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.
|
/// In a type definition, we check that to ensure that the types of the fields are well-formed.
|
||||||
fn check_type_defn<'tcx>(
|
fn check_type_defn<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
|
|
|
@ -149,7 +149,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum CastError {
|
pub enum CastError {
|
||||||
ErrorGuaranteed(ErrorGuaranteed),
|
ErrorGuaranteed(ErrorGuaranteed),
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ impl std::fmt::Debug for ConstInt {
|
||||||
(4, _) => write!(fmt, "_i32")?,
|
(4, _) => write!(fmt, "_i32")?,
|
||||||
(8, _) => write!(fmt, "_i64")?,
|
(8, _) => write!(fmt, "_i64")?,
|
||||||
(16, _) => write!(fmt, "_i128")?,
|
(16, _) => write!(fmt, "_i128")?,
|
||||||
_ => bug!(),
|
(sz, _) => bug!("unexpected int size i{sz}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -105,7 +105,7 @@ impl std::fmt::Debug for ConstInt {
|
||||||
(4, _) => write!(fmt, "_u32")?,
|
(4, _) => write!(fmt, "_u32")?,
|
||||||
(8, _) => write!(fmt, "_u64")?,
|
(8, _) => write!(fmt, "_u64")?,
|
||||||
(16, _) => write!(fmt, "_u128")?,
|
(16, _) => write!(fmt, "_u128")?,
|
||||||
_ => bug!(),
|
(sz, _) => bug!("unexpected unsigned int size u{sz}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -421,13 +421,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
|
|
||||||
let impl_args = match *self.type_of(impl_def_id).instantiate_identity().kind() {
|
let impl_args = match *self.type_of(impl_def_id).instantiate_identity().kind() {
|
||||||
ty::Adt(def_, args) if def_ == def => args,
|
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() {
|
let item_args = ty::GenericArgs::identity_for_item(self, def.did());
|
||||||
ty::Adt(def_, args) if def_ == def => args,
|
|
||||||
_ => bug!(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let result = iter::zip(item_args, impl_args)
|
let result = iter::zip(item_args, impl_args)
|
||||||
.filter(|&(_, k)| {
|
.filter(|&(_, k)| {
|
||||||
|
|
|
@ -640,7 +640,9 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -
|
||||||
}
|
}
|
||||||
DefKind::Closure if coroutine_kind.is_some() => {
|
DefKind::Closure if coroutine_kind.is_some() => {
|
||||||
let coroutine_ty = tcx.type_of(def_id).instantiate_identity();
|
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 args = args.as_coroutine();
|
||||||
let yield_ty = args.yield_ty();
|
let yield_ty = args.yield_ty();
|
||||||
let return_ty = args.return_ty();
|
let return_ty = args.return_ty();
|
||||||
|
@ -648,7 +650,9 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -
|
||||||
}
|
}
|
||||||
DefKind::Closure => {
|
DefKind::Closure => {
|
||||||
let closure_ty = tcx.type_of(def_id).instantiate_identity();
|
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 args = args.as_closure();
|
||||||
let sig = tcx.liberate_late_bound_regions(def_id.to_def_id(), args.sig());
|
let sig = tcx.liberate_late_bound_regions(def_id.to_def_id(), args.sig());
|
||||||
let self_ty = match args.kind() {
|
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::Tup(fields) => ExprKind::Tuple { fields: self.mirror_exprs(fields) },
|
||||||
|
|
||||||
hir::ExprKind::Yield(v, _) => ExprKind::Yield { value: self.mirror_expr(v) },
|
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 }
|
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)) }
|
PatKind::Constant { value: mir::Const::Ty(ty::Const::new_value(tcx, cv, ty)) }
|
||||||
}
|
}
|
||||||
ty::FnPtr(..) => {
|
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 };
|
let err = InvalidPattern { span, non_sm_ty: ty };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue