Annotate some bugs
This commit is contained in:
parent
96df494340
commit
70b9dad3dc
34 changed files with 295 additions and 197 deletions
|
@ -477,7 +477,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
ty::Const::new_misc_error(tcx, ty).into()
|
||||
}
|
||||
}
|
||||
_ => unreachable!(),
|
||||
(kind, arg) => span_bug!(
|
||||
self.span,
|
||||
"mismatched path argument for kind {kind:?}: found arg {arg:?}"
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1946,7 +1949,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
"s",
|
||||
),
|
||||
[only] => (only.to_string(), ""),
|
||||
[] => unreachable!(),
|
||||
[] => unreachable!("expected at least one generic to prohibit"),
|
||||
};
|
||||
let last_span = *arg_spans.last().unwrap();
|
||||
let span: MultiSpan = arg_spans.into();
|
||||
|
@ -2555,8 +2558,19 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
if let Some(i) = (param.index as usize).checked_sub(generics.count() - lifetimes.len())
|
||||
{
|
||||
// Resolve our own lifetime parameters.
|
||||
let GenericParamDefKind::Lifetime { .. } = param.kind else { bug!() };
|
||||
let hir::GenericArg::Lifetime(lifetime) = &lifetimes[i] else { bug!() };
|
||||
let GenericParamDefKind::Lifetime { .. } = param.kind else {
|
||||
span_bug!(
|
||||
tcx.def_span(param.def_id),
|
||||
"only expected lifetime for opaque's own generics, got {:?}",
|
||||
param.kind
|
||||
);
|
||||
};
|
||||
let hir::GenericArg::Lifetime(lifetime) = &lifetimes[i] else {
|
||||
bug!(
|
||||
"expected lifetime argument for param {param:?}, found {:?}",
|
||||
&lifetimes[i]
|
||||
)
|
||||
};
|
||||
self.ast_region_to_region(lifetime, None).into()
|
||||
} else {
|
||||
tcx.mk_param_from_def(param)
|
||||
|
|
|
@ -73,7 +73,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
| ty::ClauseKind::ConstArgHasType(..)
|
||||
| ty::ClauseKind::WellFormed(_)
|
||||
| ty::ClauseKind::ConstEvaluatable(_) => {
|
||||
bug!()
|
||||
span_bug!(span, "did not expect {pred} clause in object bounds");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1086,8 +1086,14 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
|
|||
_ => return Ok(region),
|
||||
}
|
||||
|
||||
let e = if let Some(region) = self.map.get(®ion) {
|
||||
if let ty::ReEarlyParam(e) = region.kind() { e } else { bug!() }
|
||||
let e = if let Some(id_region) = self.map.get(®ion) {
|
||||
if let ty::ReEarlyParam(e) = id_region.kind() {
|
||||
e
|
||||
} else {
|
||||
bug!(
|
||||
"expected to map region {region} to early-bound identity region, but got {id_region}"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
let guar = match region.kind() {
|
||||
ty::ReEarlyParam(ty::EarlyParamRegion { def_id, .. })
|
||||
|
@ -1710,92 +1716,87 @@ fn compare_synthetic_generics<'tcx>(
|
|||
trait_m.name
|
||||
);
|
||||
err.span_label(trait_span, "declaration in trait here");
|
||||
match (impl_synthetic, trait_synthetic) {
|
||||
if impl_synthetic {
|
||||
// The case where the impl method uses `impl Trait` but the trait method uses
|
||||
// explicit generics
|
||||
(true, false) => {
|
||||
err.span_label(impl_span, "expected generic parameter, found `impl Trait`");
|
||||
let _: Option<_> = try {
|
||||
// try taking the name from the trait impl
|
||||
// FIXME: this is obviously suboptimal since the name can already be used
|
||||
// as another generic argument
|
||||
let new_name = tcx.opt_item_name(trait_def_id)?;
|
||||
let trait_m = trait_m.def_id.as_local()?;
|
||||
let trait_m = tcx.hir().expect_trait_item(trait_m);
|
||||
err.span_label(impl_span, "expected generic parameter, found `impl Trait`");
|
||||
let _: Option<_> = try {
|
||||
// try taking the name from the trait impl
|
||||
// FIXME: this is obviously suboptimal since the name can already be used
|
||||
// as another generic argument
|
||||
let new_name = tcx.opt_item_name(trait_def_id)?;
|
||||
let trait_m = trait_m.def_id.as_local()?;
|
||||
let trait_m = tcx.hir().expect_trait_item(trait_m);
|
||||
|
||||
let impl_m = impl_m.def_id.as_local()?;
|
||||
let impl_m = tcx.hir().expect_impl_item(impl_m);
|
||||
let impl_m = impl_m.def_id.as_local()?;
|
||||
let impl_m = tcx.hir().expect_impl_item(impl_m);
|
||||
|
||||
// in case there are no generics, take the spot between the function name
|
||||
// and the opening paren of the argument list
|
||||
let new_generics_span = tcx.def_ident_span(impl_def_id)?.shrink_to_hi();
|
||||
// in case there are generics, just replace them
|
||||
let generics_span =
|
||||
impl_m.generics.span.substitute_dummy(new_generics_span);
|
||||
// replace with the generics from the trait
|
||||
let new_generics =
|
||||
tcx.sess.source_map().span_to_snippet(trait_m.generics.span).ok()?;
|
||||
// in case there are no generics, take the spot between the function name
|
||||
// and the opening paren of the argument list
|
||||
let new_generics_span = tcx.def_ident_span(impl_def_id)?.shrink_to_hi();
|
||||
// in case there are generics, just replace them
|
||||
let generics_span = impl_m.generics.span.substitute_dummy(new_generics_span);
|
||||
// replace with the generics from the trait
|
||||
let new_generics =
|
||||
tcx.sess.source_map().span_to_snippet(trait_m.generics.span).ok()?;
|
||||
|
||||
err.multipart_suggestion(
|
||||
"try changing the `impl Trait` argument to a generic parameter",
|
||||
vec![
|
||||
// replace `impl Trait` with `T`
|
||||
(impl_span, new_name.to_string()),
|
||||
// replace impl method generics with trait method generics
|
||||
// This isn't quite right, as users might have changed the names
|
||||
// of the generics, but it works for the common case
|
||||
(generics_span, new_generics),
|
||||
],
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
};
|
||||
}
|
||||
err.multipart_suggestion(
|
||||
"try changing the `impl Trait` argument to a generic parameter",
|
||||
vec![
|
||||
// replace `impl Trait` with `T`
|
||||
(impl_span, new_name.to_string()),
|
||||
// replace impl method generics with trait method generics
|
||||
// This isn't quite right, as users might have changed the names
|
||||
// of the generics, but it works for the common case
|
||||
(generics_span, new_generics),
|
||||
],
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
};
|
||||
} else {
|
||||
// The case where the trait method uses `impl Trait`, but the impl method uses
|
||||
// explicit generics.
|
||||
(false, true) => {
|
||||
err.span_label(impl_span, "expected `impl Trait`, found generic parameter");
|
||||
let _: Option<_> = try {
|
||||
let impl_m = impl_m.def_id.as_local()?;
|
||||
let impl_m = tcx.hir().expect_impl_item(impl_m);
|
||||
let (sig, _) = impl_m.expect_fn();
|
||||
let input_tys = sig.decl.inputs;
|
||||
err.span_label(impl_span, "expected `impl Trait`, found generic parameter");
|
||||
let _: Option<_> = try {
|
||||
let impl_m = impl_m.def_id.as_local()?;
|
||||
let impl_m = tcx.hir().expect_impl_item(impl_m);
|
||||
let (sig, _) = impl_m.expect_fn();
|
||||
let input_tys = sig.decl.inputs;
|
||||
|
||||
struct Visitor(Option<Span>, hir::def_id::LocalDefId);
|
||||
impl<'v> intravisit::Visitor<'v> for Visitor {
|
||||
fn visit_ty(&mut self, ty: &'v hir::Ty<'v>) {
|
||||
intravisit::walk_ty(self, ty);
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(None, path)) = ty.kind
|
||||
&& let Res::Def(DefKind::TyParam, def_id) = path.res
|
||||
&& def_id == self.1.to_def_id()
|
||||
{
|
||||
self.0 = Some(ty.span);
|
||||
}
|
||||
struct Visitor(Option<Span>, hir::def_id::LocalDefId);
|
||||
impl<'v> intravisit::Visitor<'v> for Visitor {
|
||||
fn visit_ty(&mut self, ty: &'v hir::Ty<'v>) {
|
||||
intravisit::walk_ty(self, ty);
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(None, path)) = ty.kind
|
||||
&& let Res::Def(DefKind::TyParam, def_id) = path.res
|
||||
&& def_id == self.1.to_def_id()
|
||||
{
|
||||
self.0 = Some(ty.span);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut visitor = Visitor(None, impl_def_id);
|
||||
for ty in input_tys {
|
||||
intravisit::Visitor::visit_ty(&mut visitor, ty);
|
||||
}
|
||||
let span = visitor.0?;
|
||||
let mut visitor = Visitor(None, impl_def_id);
|
||||
for ty in input_tys {
|
||||
intravisit::Visitor::visit_ty(&mut visitor, ty);
|
||||
}
|
||||
let span = visitor.0?;
|
||||
|
||||
let bounds = impl_m.generics.bounds_for_param(impl_def_id).next()?.bounds;
|
||||
let bounds = bounds.first()?.span().to(bounds.last()?.span());
|
||||
let bounds = tcx.sess.source_map().span_to_snippet(bounds).ok()?;
|
||||
let bounds = impl_m.generics.bounds_for_param(impl_def_id).next()?.bounds;
|
||||
let bounds = bounds.first()?.span().to(bounds.last()?.span());
|
||||
let bounds = tcx.sess.source_map().span_to_snippet(bounds).ok()?;
|
||||
|
||||
err.multipart_suggestion(
|
||||
"try removing the generic parameter and using `impl Trait` instead",
|
||||
vec![
|
||||
// delete generic parameters
|
||||
(impl_m.generics.span, String::new()),
|
||||
// replace param usage with `impl Trait`
|
||||
(span, format!("impl {bounds}")),
|
||||
],
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
};
|
||||
}
|
||||
_ => unreachable!(),
|
||||
err.multipart_suggestion(
|
||||
"try removing the generic parameter and using `impl Trait` instead",
|
||||
vec![
|
||||
// delete generic parameters
|
||||
(impl_m.generics.span, String::new()),
|
||||
// replace param usage with `impl Trait`
|
||||
(span, format!("impl {bounds}")),
|
||||
],
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
};
|
||||
}
|
||||
error_found = Some(err.emit_unless(delay));
|
||||
}
|
||||
|
@ -1859,7 +1860,9 @@ fn compare_generic_param_kinds<'tcx>(
|
|||
// this is exhaustive so that anyone adding new generic param kinds knows
|
||||
// to make sure this error is reported for them.
|
||||
(Const { .. }, Const { .. }) | (Type { .. }, Type { .. }) => false,
|
||||
(Lifetime { .. }, _) | (_, Lifetime { .. }) => unreachable!(),
|
||||
(Lifetime { .. }, _) | (_, Lifetime { .. }) => {
|
||||
bug!("lifetime params are expected to be filtered by `ty_const_params_of`")
|
||||
}
|
||||
} {
|
||||
let param_impl_span = tcx.def_span(param_impl.def_id);
|
||||
let param_trait_span = tcx.def_span(param_trait.def_id);
|
||||
|
@ -1883,7 +1886,10 @@ fn compare_generic_param_kinds<'tcx>(
|
|||
)
|
||||
}
|
||||
Type { .. } => format!("{prefix} type parameter"),
|
||||
Lifetime { .. } => unreachable!(),
|
||||
Lifetime { .. } => span_bug!(
|
||||
tcx.def_span(param.def_id),
|
||||
"lifetime params are expected to be filtered by `ty_const_params_of`"
|
||||
),
|
||||
};
|
||||
|
||||
let trait_header_span = tcx.def_ident_span(tcx.parent(trait_item.def_id)).unwrap();
|
||||
|
@ -2187,7 +2193,10 @@ pub(super) fn check_type_bounds<'tcx>(
|
|||
..
|
||||
}) => ty.span,
|
||||
hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Type(ty), .. }) => ty.span,
|
||||
_ => bug!(),
|
||||
item => span_bug!(
|
||||
tcx.def_span(impl_ty_def_id),
|
||||
"cannot call `check_type_bounds` on item: {item:?}",
|
||||
),
|
||||
}
|
||||
};
|
||||
let assumed_wf_types = ocx.assumed_wf_types_and_report_errors(param_env, impl_ty_def_id)?;
|
||||
|
|
|
@ -262,7 +262,10 @@ fn report_mismatched_rpitit_signature<'tcx>(
|
|||
|
||||
if tcx.asyncness(impl_m_def_id).is_async() && tcx.asyncness(trait_m_def_id).is_async() {
|
||||
let ty::Alias(ty::Projection, future_ty) = return_ty.kind() else {
|
||||
bug!();
|
||||
span_bug!(
|
||||
tcx.def_span(trait_m_def_id),
|
||||
"expected return type of async fn in trait to be a AFIT projection"
|
||||
);
|
||||
};
|
||||
let Some(future_output_ty) = tcx
|
||||
.explicit_item_bounds(future_ty.def_id)
|
||||
|
@ -272,7 +275,7 @@ fn report_mismatched_rpitit_signature<'tcx>(
|
|||
_ => None,
|
||||
})
|
||||
else {
|
||||
bug!()
|
||||
span_bug!(tcx.def_span(trait_m_def_id), "expected `Future` projection bound in AFIT");
|
||||
};
|
||||
return_ty = future_output_ty;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
16 => InlineAsmType::I16,
|
||||
32 => InlineAsmType::I32,
|
||||
64 => InlineAsmType::I64,
|
||||
_ => unreachable!(),
|
||||
width => bug!("unsupported pointer width: {width}"),
|
||||
};
|
||||
|
||||
match *ty.kind() {
|
||||
|
@ -101,7 +101,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
16 => InlineAsmType::VecI16(size),
|
||||
32 => InlineAsmType::VecI32(size),
|
||||
64 => InlineAsmType::VecI64(size),
|
||||
_ => unreachable!(),
|
||||
width => bug!("unsupported pointer width: {width}"),
|
||||
})
|
||||
}
|
||||
ty::Float(FloatTy::F32) => Some(InlineAsmType::VecF32(size)),
|
||||
|
@ -109,7 +109,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
_ => None,
|
||||
}
|
||||
}
|
||||
ty::Infer(_) => unreachable!(),
|
||||
ty::Infer(_) => bug!("unexpected infer ty in asm operand"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -136,8 +136,15 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
ty::Adt(adt, args) if Some(adt.did()) == self.tcx.lang_items().maybe_uninit() => {
|
||||
let fields = &adt.non_enum_variant().fields;
|
||||
let ty = fields[FieldIdx::from_u32(1)].ty(self.tcx, args);
|
||||
let ty::Adt(ty, args) = ty.kind() else { unreachable!() };
|
||||
assert!(ty.is_manually_drop());
|
||||
// FIXME: Are we just trying to map to the `T` in `MaybeUninit<T>`?
|
||||
// If so, just get it from the args.
|
||||
let ty::Adt(ty, args) = ty.kind() else {
|
||||
unreachable!("expected first field of `MaybeUninit` to be an ADT")
|
||||
};
|
||||
assert!(
|
||||
ty.is_manually_drop(),
|
||||
"expected first field of `MaybeUnit` to be `ManuallyDrop`"
|
||||
);
|
||||
let fields = &ty.non_enum_variant().fields;
|
||||
let ty = fields[FieldIdx::from_u32(0)].ty(self.tcx, args);
|
||||
self.get_asm_ty(ty)
|
||||
|
|
|
@ -204,11 +204,14 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
|
|||
res = Err(err.emit());
|
||||
}
|
||||
// We match on both `ty::ImplPolarity` and `ast::ImplPolarity` just to get the `!` span.
|
||||
match (tcx.impl_polarity(def_id), impl_.polarity) {
|
||||
(ty::ImplPolarity::Positive, _) => {
|
||||
match tcx.impl_polarity(def_id) {
|
||||
ty::ImplPolarity::Positive => {
|
||||
res = res.and(check_impl(tcx, item, impl_.self_ty, &impl_.of_trait));
|
||||
}
|
||||
(ty::ImplPolarity::Negative, ast::ImplPolarity::Negative(span)) => {
|
||||
ty::ImplPolarity::Negative => {
|
||||
let ast::ImplPolarity::Negative(span) = impl_.polarity else {
|
||||
bug!("impl_polarity query disagrees with impl's polarity in AST");
|
||||
};
|
||||
// FIXME(#27579): what amount of WF checking do we need for neg impls?
|
||||
if let hir::Defaultness::Default { .. } = impl_.defaultness {
|
||||
let mut spans = vec![span];
|
||||
|
@ -222,10 +225,9 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
|
|||
.emit());
|
||||
}
|
||||
}
|
||||
(ty::ImplPolarity::Reservation, _) => {
|
||||
ty::ImplPolarity::Reservation => {
|
||||
// FIXME: what amount of WF checking do we need for reservation impls?
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
res
|
||||
}
|
||||
|
@ -1068,9 +1070,14 @@ fn check_type_defn<'tcx>(
|
|||
hir_ty.span,
|
||||
wfcx.body_def_id,
|
||||
traits::FieldSized {
|
||||
adt_kind: match item_adt_kind(&item.kind) {
|
||||
Some(i) => i,
|
||||
None => bug!(),
|
||||
adt_kind: match &item.kind {
|
||||
ItemKind::Struct(..) => AdtKind::Struct,
|
||||
ItemKind::Union(..) => AdtKind::Union,
|
||||
ItemKind::Enum(..) => AdtKind::Enum,
|
||||
kind => span_bug!(
|
||||
item.span,
|
||||
"should be wfchecking an ADT, got {kind:?}"
|
||||
),
|
||||
},
|
||||
span: hir_ty.span,
|
||||
last,
|
||||
|
@ -1302,7 +1309,9 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
|
|||
| GenericParamDefKind::Const { has_default, .. } => {
|
||||
has_default && def.index >= generics.parent_count as u32
|
||||
}
|
||||
GenericParamDefKind::Lifetime => unreachable!(),
|
||||
GenericParamDefKind::Lifetime => {
|
||||
span_bug!(tcx.def_span(def.def_id), "lifetime params can have no default")
|
||||
}
|
||||
};
|
||||
|
||||
// Check that concrete defaults are well-formed. See test `type-check-defaults.rs`.
|
||||
|
@ -1750,15 +1759,15 @@ fn check_variances_for_type_defn<'tcx>(
|
|||
}
|
||||
}
|
||||
ItemKind::TyAlias(..) => {
|
||||
if tcx.type_alias_is_lazy(item.owner_id) {
|
||||
if tcx.type_of(item.owner_id).skip_binder().references_error() {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
bug!();
|
||||
assert!(
|
||||
tcx.type_alias_is_lazy(item.owner_id),
|
||||
"should not be computing variance of non-weak type alias"
|
||||
);
|
||||
if tcx.type_of(item.owner_id).skip_binder().references_error() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
_ => bug!(),
|
||||
kind => span_bug!(item.span, "cannot compute the variances of {kind:?}"),
|
||||
}
|
||||
|
||||
let ty_predicates = tcx.predicates_of(item.owner_id);
|
||||
|
|
|
@ -836,7 +836,7 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> {
|
|||
use rustc_hir::*;
|
||||
|
||||
let Node::Item(item) = tcx.hir_node_by_def_id(def_id) else {
|
||||
bug!();
|
||||
bug!("expected ADT to be an item");
|
||||
};
|
||||
|
||||
let repr = tcx.repr_options_of_def(def_id.to_def_id());
|
||||
|
@ -887,7 +887,7 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> {
|
|||
|
||||
(adt_kind, variants)
|
||||
}
|
||||
_ => bug!(),
|
||||
_ => bug!("{:?} is not an ADT", item.owner_id.def_id),
|
||||
};
|
||||
tcx.mk_adt_def(def_id.to_def_id(), kind, variants, repr)
|
||||
}
|
||||
|
|
|
@ -97,8 +97,10 @@ pub(super) fn explicit_item_bounds(
|
|||
item.span,
|
||||
));
|
||||
}
|
||||
// These should have been fed!
|
||||
Some(ty::ImplTraitInTraitData::Impl { .. }) => unreachable!(),
|
||||
Some(ty::ImplTraitInTraitData::Impl { .. }) => span_bug!(
|
||||
tcx.def_span(def_id),
|
||||
"item bounds for RPITIT in impl to be fed on def-id creation"
|
||||
),
|
||||
None => {}
|
||||
}
|
||||
|
||||
|
@ -128,7 +130,7 @@ pub(super) fn explicit_item_bounds(
|
|||
let (hir::OpaqueTyOrigin::FnReturn(fn_def_id)
|
||||
| hir::OpaqueTyOrigin::AsyncFn(fn_def_id)) = *origin
|
||||
else {
|
||||
bug!()
|
||||
span_bug!(*span, "RPITIT cannot be a TAIT, but got origin {origin:?}");
|
||||
};
|
||||
let args = GenericArgs::identity_for_item(tcx, def_id);
|
||||
let item_ty = Ty::new_opaque(tcx, def_id.to_def_id(), args);
|
||||
|
|
|
@ -296,7 +296,12 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
|||
hir::GenericBound::Outlives(lt) => {
|
||||
(icx.astconv().ast_region_to_region(lt, None), lt.ident.span)
|
||||
}
|
||||
_ => bug!(),
|
||||
bound => {
|
||||
span_bug!(
|
||||
bound.span(),
|
||||
"lifetime param bounds must be outlives, but found {bound:?}"
|
||||
)
|
||||
}
|
||||
};
|
||||
let pred = ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(r1, r2))
|
||||
.to_predicate(tcx);
|
||||
|
|
|
@ -1300,7 +1300,11 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
what,
|
||||
})
|
||||
}
|
||||
_ => unreachable!(),
|
||||
kind => span_bug!(
|
||||
use_span,
|
||||
"did not expect to resolve lifetime to {}",
|
||||
kind.descr(param_def_id)
|
||||
),
|
||||
};
|
||||
def = ResolvedArg::Error(guar);
|
||||
} else if let Some(body_id) = outermost_body {
|
||||
|
@ -1441,7 +1445,11 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
what,
|
||||
})
|
||||
}
|
||||
_ => unreachable!(),
|
||||
kind => span_bug!(
|
||||
use_span,
|
||||
"did not expect to resolve non-lifetime param to {}",
|
||||
kind.descr(param_def_id.to_def_id())
|
||||
),
|
||||
};
|
||||
self.map.defs.insert(hir_id, ResolvedArg::Error(guar));
|
||||
} else {
|
||||
|
@ -2123,7 +2131,7 @@ pub fn deny_non_region_late_bound(
|
|||
|
||||
for (var, arg) in bound_vars {
|
||||
let Node::GenericParam(param) = tcx.hir_node_by_def_id(*var) else {
|
||||
bug!();
|
||||
span_bug!(tcx.def_span(*var), "expected bound-var def-id to resolve to param");
|
||||
};
|
||||
|
||||
let what = match param.kind {
|
||||
|
|
|
@ -20,7 +20,13 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
|
|||
use rustc_middle::ty::Ty;
|
||||
let hir_id = tcx.local_def_id_to_hir_id(def_id);
|
||||
|
||||
let Node::AnonConst(_) = tcx.hir_node(hir_id) else { panic!() };
|
||||
let node = tcx.hir_node(hir_id);
|
||||
let Node::AnonConst(_) = node else {
|
||||
span_bug!(
|
||||
tcx.def_span(def_id),
|
||||
"expected anon const in `anon_const_type_of`, got {node:?}"
|
||||
);
|
||||
};
|
||||
|
||||
let parent_node_id = tcx.hir().parent_id(hir_id);
|
||||
let parent_node = tcx.hir_node(parent_node_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue