No more ret_type_span
This commit is contained in:
parent
98e1f041b6
commit
0a605d33cd
@ -137,9 +137,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
Some(&arm.body),
|
||||
arm_ty,
|
||||
Some(&mut |err| {
|
||||
let Some(ret) = self.ret_type_span else {
|
||||
return;
|
||||
};
|
||||
let Some(ret) = self
|
||||
.tcx
|
||||
.hir()
|
||||
.find_by_def_id(self.body_id.owner)
|
||||
.and_then(|owner| owner.fn_decl())
|
||||
.map(|decl| decl.output.span())
|
||||
else { return; };
|
||||
let Expectation::IsLast(stmt) = orig_expected else {
|
||||
return
|
||||
};
|
||||
@ -517,9 +521,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
}
|
||||
// If all the obligations hold (or there are no obligations) the tail expression
|
||||
// we can suggest to return a boxed trait object instead of an opaque type.
|
||||
if suggest_box { self.ret_type_span } else { None }
|
||||
if suggest_box {
|
||||
self.tcx
|
||||
.hir()
|
||||
.find_by_def_id(self.body_id.owner)
|
||||
.and_then(|owner| owner.fn_decl())
|
||||
.map(|decl| decl.output.span())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
|
@ -106,7 +106,6 @@ pub(super) fn check_fn<'a, 'tcx>(
|
||||
fcx.return_type_has_opaque = ret_ty != declared_ret_ty;
|
||||
|
||||
fcx.ret_coercion = Some(RefCell::new(CoerceMany::new(ret_ty)));
|
||||
fcx.ret_type_span = Some(decl.output.span());
|
||||
|
||||
let span = body.value.span;
|
||||
|
||||
|
@ -68,8 +68,6 @@ pub struct FnCtxt<'a, 'tcx> {
|
||||
/// any).
|
||||
pub(super) ret_coercion: Option<RefCell<DynamicCoerceMany<'tcx>>>,
|
||||
|
||||
pub(super) ret_type_span: Option<Span>,
|
||||
|
||||
/// Used exclusively to reduce cost of advanced evaluation used for
|
||||
/// more helpful diagnostics.
|
||||
pub(super) in_tail_expr: bool,
|
||||
@ -142,7 +140,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
param_env,
|
||||
err_count_on_creation: inh.tcx.sess.err_count(),
|
||||
ret_coercion: None,
|
||||
ret_type_span: None,
|
||||
in_tail_expr: false,
|
||||
ret_coercion_span: Cell::new(None),
|
||||
resume_yield_tys: None,
|
||||
|
Loading…
x
Reference in New Issue
Block a user