Annotate some bugs
This commit is contained in:
parent
96df494340
commit
70b9dad3dc
34 changed files with 295 additions and 197 deletions
|
@ -203,7 +203,11 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
|
|||
)
|
||||
.into(),
|
||||
ty::AssocKind::Type => Ty::new_error(tcx, guar).into(),
|
||||
ty::AssocKind::Fn => unreachable!(),
|
||||
// This makes no sense...
|
||||
ty::AssocKind::Fn => span_bug!(
|
||||
tcx.def_span(assoc_def.item.def_id),
|
||||
"cannot project to an associated function"
|
||||
),
|
||||
};
|
||||
ecx.eq(goal.param_env, goal.predicate.term, error_term)
|
||||
.expect("expected goal term to be fully unconstrained");
|
||||
|
|
|
@ -256,7 +256,10 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
|
|||
Err(NoSolution)
|
||||
}
|
||||
}
|
||||
ty::ImplPolarity::Reservation => bug!(),
|
||||
// FIXME: Goal polarity should be split from impl polarity
|
||||
ty::ImplPolarity::Reservation => {
|
||||
bug!("we never expect a `Reservation` polarity in a trait goal")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -487,7 +487,7 @@ fn plug_infer_with_placeholders<'tcx>(
|
|||
),
|
||||
)
|
||||
else {
|
||||
bug!()
|
||||
bug!("we always expect to be able to plug an infer var with placeholder")
|
||||
};
|
||||
assert_eq!(obligations, &[]);
|
||||
ControlFlow::Continue(())
|
||||
|
@ -510,7 +510,7 @@ fn plug_infer_with_placeholders<'tcx>(
|
|||
),
|
||||
)
|
||||
else {
|
||||
bug!()
|
||||
bug!("we always expect to be able to plug an infer var with placeholder")
|
||||
};
|
||||
assert_eq!(obligations, &[]);
|
||||
ControlFlow::Continue(())
|
||||
|
@ -544,7 +544,7 @@ fn plug_infer_with_placeholders<'tcx>(
|
|||
),
|
||||
)
|
||||
else {
|
||||
bug!()
|
||||
bug!("we always expect to be able to plug an infer var with placeholder")
|
||||
};
|
||||
assert_eq!(obligations, &[]);
|
||||
}
|
||||
|
|
|
@ -250,7 +250,12 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
err.emit();
|
||||
|
||||
self.tcx.sess.abort_if_errors();
|
||||
bug!();
|
||||
// FIXME: this should be something like `build_overflow_error_fatal`, which returns
|
||||
// `DiagnosticBuilder<', !>`. Then we don't even need anything after that `emit()`.
|
||||
unreachable!(
|
||||
"did not expect compilation to continue after `abort_if_errors`, \
|
||||
since an error was definitely emitted!"
|
||||
);
|
||||
}
|
||||
|
||||
fn build_overflow_error<T>(
|
||||
|
|
|
@ -191,7 +191,9 @@ impl<'tcx> ProjectionCandidateSet<'tcx> {
|
|||
match (current, candidate) {
|
||||
(ParamEnv(..), ParamEnv(..)) => convert_to_ambiguous = (),
|
||||
(ParamEnv(..), _) => return false,
|
||||
(_, ParamEnv(..)) => unreachable!(),
|
||||
(_, ParamEnv(..)) => bug!(
|
||||
"should never prefer non-param-env candidates over param-env candidates"
|
||||
),
|
||||
(_, _) => convert_to_ambiguous = (),
|
||||
}
|
||||
}
|
||||
|
@ -2080,10 +2082,11 @@ fn confirm_coroutine_candidate<'cx, 'tcx>(
|
|||
obligation: &ProjectionTyObligation<'tcx>,
|
||||
nested: Vec<PredicateObligation<'tcx>>,
|
||||
) -> Progress<'tcx> {
|
||||
let ty::Coroutine(_, args, _) =
|
||||
selcx.infcx.shallow_resolve(obligation.predicate.self_ty()).kind()
|
||||
else {
|
||||
unreachable!()
|
||||
let self_ty = selcx.infcx.shallow_resolve(obligation.predicate.self_ty());
|
||||
let ty::Coroutine(_, args, _) = self_ty.kind() else {
|
||||
unreachable!(
|
||||
"expected coroutine self type for built-in coroutine candidate, found {self_ty}"
|
||||
)
|
||||
};
|
||||
let coroutine_sig = args.as_coroutine().sig();
|
||||
let Normalized { value: coroutine_sig, obligations } = normalize_with_depth(
|
||||
|
@ -2113,7 +2116,10 @@ fn confirm_coroutine_candidate<'cx, 'tcx>(
|
|||
} else if name == sym::Yield {
|
||||
yield_ty
|
||||
} else {
|
||||
bug!()
|
||||
span_bug!(
|
||||
tcx.def_span(obligation.predicate.def_id),
|
||||
"unexpected associated type: `Coroutine::{name}`"
|
||||
);
|
||||
};
|
||||
|
||||
let predicate = ty::ProjectionPredicate {
|
||||
|
@ -2131,10 +2137,11 @@ fn confirm_future_candidate<'cx, 'tcx>(
|
|||
obligation: &ProjectionTyObligation<'tcx>,
|
||||
nested: Vec<PredicateObligation<'tcx>>,
|
||||
) -> Progress<'tcx> {
|
||||
let ty::Coroutine(_, args, _) =
|
||||
selcx.infcx.shallow_resolve(obligation.predicate.self_ty()).kind()
|
||||
else {
|
||||
unreachable!()
|
||||
let self_ty = selcx.infcx.shallow_resolve(obligation.predicate.self_ty());
|
||||
let ty::Coroutine(_, args, _) = self_ty.kind() else {
|
||||
unreachable!(
|
||||
"expected coroutine self type for built-in async future candidate, found {self_ty}"
|
||||
)
|
||||
};
|
||||
let coroutine_sig = args.as_coroutine().sig();
|
||||
let Normalized { value: coroutine_sig, obligations } = normalize_with_depth(
|
||||
|
@ -2174,10 +2181,9 @@ fn confirm_iterator_candidate<'cx, 'tcx>(
|
|||
obligation: &ProjectionTyObligation<'tcx>,
|
||||
nested: Vec<PredicateObligation<'tcx>>,
|
||||
) -> Progress<'tcx> {
|
||||
let ty::Coroutine(_, args, _) =
|
||||
selcx.infcx.shallow_resolve(obligation.predicate.self_ty()).kind()
|
||||
else {
|
||||
unreachable!()
|
||||
let self_ty = selcx.infcx.shallow_resolve(obligation.predicate.self_ty());
|
||||
let ty::Coroutine(_, args, _) = self_ty.kind() else {
|
||||
unreachable!("expected coroutine self type for built-in gen candidate, found {self_ty}")
|
||||
};
|
||||
let gen_sig = args.as_coroutine().sig();
|
||||
let Normalized { value: gen_sig, obligations } = normalize_with_depth(
|
||||
|
@ -2341,9 +2347,9 @@ fn confirm_closure_candidate<'cx, 'tcx>(
|
|||
obligation: &ProjectionTyObligation<'tcx>,
|
||||
nested: Vec<PredicateObligation<'tcx>>,
|
||||
) -> Progress<'tcx> {
|
||||
let ty::Closure(_, args) = selcx.infcx.shallow_resolve(obligation.predicate.self_ty()).kind()
|
||||
else {
|
||||
unreachable!()
|
||||
let self_ty = selcx.infcx.shallow_resolve(obligation.predicate.self_ty());
|
||||
let ty::Closure(_, args) = self_ty.kind() else {
|
||||
unreachable!("expected closure self type for closure candidate, found {self_ty}")
|
||||
};
|
||||
let closure_sig = args.as_closure().sig();
|
||||
let Normalized { value: closure_sig, obligations } = normalize_with_depth(
|
||||
|
|
|
@ -285,7 +285,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx>
|
|||
ty::Projection => tcx.normalize_projection_ty(c_data),
|
||||
ty::Weak => tcx.normalize_weak_ty(c_data),
|
||||
ty::Inherent => tcx.normalize_inherent_projection_ty(c_data),
|
||||
_ => unreachable!(),
|
||||
kind => unreachable!("did not expect {kind:?} due to match arm above"),
|
||||
}?;
|
||||
// We don't expect ambiguity.
|
||||
if !result.value.is_proven() {
|
||||
|
|
|
@ -184,7 +184,9 @@ pub fn compute_implied_outlives_bounds_inner<'tcx>(
|
|||
push_outlives_components(tcx, ty_a, &mut components);
|
||||
implied_bounds.extend(implied_bounds_from_components(r_b, components))
|
||||
}
|
||||
ty::GenericArgKind::Const(_) => unreachable!(),
|
||||
ty::GenericArgKind::Const(_) => {
|
||||
unreachable!("consts do not participate in outlives bounds")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -942,8 +942,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let a_ty = self.infcx.shallow_resolve(predicate.self_ty());
|
||||
let b_ty = self.infcx.shallow_resolve(predicate.trait_ref.args.type_at(1));
|
||||
|
||||
let ty::Dynamic(a_data, a_region, ty::Dyn) = *a_ty.kind() else { bug!() };
|
||||
let ty::Dynamic(b_data, b_region, ty::Dyn) = *b_ty.kind() else { bug!() };
|
||||
let ty::Dynamic(a_data, a_region, ty::Dyn) = *a_ty.kind() else {
|
||||
bug!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`")
|
||||
};
|
||||
let ty::Dynamic(b_data, b_region, ty::Dyn) = *b_ty.kind() else {
|
||||
bug!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`")
|
||||
};
|
||||
|
||||
let source_principal = a_data.principal().unwrap().with_self_ty(tcx, a_ty);
|
||||
let unnormalized_upcast_principal =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue