Fix new problem from rebase and a little cleanup
This commit is contained in:
parent
6d5efa9f04
commit
8ad7e5685e
3 changed files with 14 additions and 10 deletions
|
@ -820,7 +820,8 @@ impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> {
|
|||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
match r {
|
||||
ty::ReLateBound(index, _br) if *index == self.binder_index => {
|
||||
bug!("{:?} {:?}", index, _br)
|
||||
// If you hit this, you should be using `Binder::bind_with_vars` or `Binder::rebind`
|
||||
bug!("Trying to collect bound vars with a bound region: {:?} {:?}", index, _br)
|
||||
}
|
||||
|
||||
_ => (),
|
||||
|
@ -870,19 +871,19 @@ impl<'tcx> TypeVisitor<'tcx> for ValidateBoundVars<'tcx> {
|
|||
match *t.kind() {
|
||||
ty::Bound(debruijn, bound_ty) if debruijn == self.binder_index => {
|
||||
if self.bound_vars.len() <= bound_ty.var.as_usize() {
|
||||
panic!("Not enough bound vars: {:?} not found in {:?}", t, self.bound_vars);
|
||||
bug!("Not enough bound vars: {:?} not found in {:?}", t, self.bound_vars);
|
||||
}
|
||||
let list_var = self.bound_vars[bound_ty.var.as_usize()];
|
||||
match list_var {
|
||||
ty::BoundVariableKind::Ty(kind) => {
|
||||
if kind != bound_ty.kind {
|
||||
panic!(
|
||||
bug!(
|
||||
"Mismatched type kinds: {:?} doesn't var in list {:?}",
|
||||
bound_ty.kind, list_var
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => panic!(
|
||||
_ => bug!(
|
||||
"Mismatched bound variable kinds! Expected type, found {:?}",
|
||||
list_var
|
||||
),
|
||||
|
@ -899,19 +900,19 @@ impl<'tcx> TypeVisitor<'tcx> for ValidateBoundVars<'tcx> {
|
|||
match r {
|
||||
ty::ReLateBound(index, br) if *index == self.binder_index => {
|
||||
if self.bound_vars.len() <= br.var.as_usize() {
|
||||
panic!("Not enough bound vars: {:?} not found in {:?}", *br, self.bound_vars);
|
||||
bug!("Not enough bound vars: {:?} not found in {:?}", *br, self.bound_vars);
|
||||
}
|
||||
let list_var = self.bound_vars[br.var.as_usize()];
|
||||
match list_var {
|
||||
ty::BoundVariableKind::Region(kind) => {
|
||||
if kind != br.kind {
|
||||
panic!(
|
||||
bug!(
|
||||
"Mismatched region kinds: {:?} doesn't match var ({:?}) in list ({:?})",
|
||||
br.kind, list_var, self.bound_vars
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => panic!(
|
||||
_ => bug!(
|
||||
"Mismatched bound variable kinds! Expected region, found {:?}",
|
||||
list_var
|
||||
),
|
||||
|
|
|
@ -1487,7 +1487,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
|||
if let (Some((expr, _)), Some((fn_decl, _, _))) =
|
||||
(expression, fcx.get_node_fn_decl(parent_item))
|
||||
{
|
||||
fcx.suggest_missing_return_expr(&mut err, expr, fn_decl, expected, found);
|
||||
fcx.suggest_missing_return_expr(&mut err, expr, fn_decl, expected, found, parent_id);
|
||||
}
|
||||
|
||||
if let (Some(sp), Some(fn_output)) = (fcx.ret_coercion_span.get(), fn_output) {
|
||||
|
|
|
@ -55,7 +55,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
if let Some((fn_decl, can_suggest)) = self.get_fn_decl(blk_id) {
|
||||
pointing_at_return_type =
|
||||
self.suggest_missing_return_type(err, &fn_decl, expected, found, can_suggest);
|
||||
self.suggest_missing_return_expr(err, expr, &fn_decl, expected, found);
|
||||
let fn_id = self.tcx.hir().get_return_block(blk_id).unwrap();
|
||||
self.suggest_missing_return_expr(err, expr, &fn_decl, expected, found, fn_id);
|
||||
}
|
||||
pointing_at_return_type
|
||||
}
|
||||
|
@ -479,6 +480,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
fn_decl: &hir::FnDecl<'_>,
|
||||
expected: Ty<'tcx>,
|
||||
found: Ty<'tcx>,
|
||||
id: hir::HirId,
|
||||
) {
|
||||
if !expected.is_unit() {
|
||||
return;
|
||||
|
@ -486,7 +488,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let found = self.resolve_vars_with_obligations(found);
|
||||
if let hir::FnRetTy::Return(ty) = fn_decl.output {
|
||||
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(self, ty);
|
||||
let ty = self.tcx.erase_late_bound_regions(Binder::bind(ty, self.tcx));
|
||||
let bound_vars = self.tcx.late_bound_vars(id);
|
||||
let ty = self.tcx.erase_late_bound_regions(Binder::bind_with_vars(ty, bound_vars));
|
||||
let ty = self.normalize_associated_types_in(expr.span, ty);
|
||||
if self.can_coerce(found, ty) {
|
||||
err.multipart_suggestion(
|
||||
|
|
Loading…
Add table
Reference in a new issue