Move mem-categorization more things to use TYPER for the method origin
This commit is contained in:
parent
a583ba2fa0
commit
4856456dd7
@ -654,22 +654,19 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
||||
}
|
||||
_ => {
|
||||
let overloaded_call_type =
|
||||
match self.tcx()
|
||||
.method_map
|
||||
.borrow()
|
||||
.get(&MethodCall::expr(call.id)) {
|
||||
Some(ref method_callee) => {
|
||||
OverloadedCallType::from_method_origin(
|
||||
self.tcx(),
|
||||
&method_callee.origin)
|
||||
}
|
||||
None => {
|
||||
self.tcx().sess.span_bug(
|
||||
callee.span,
|
||||
format!("unexpected callee type {}",
|
||||
callee_ty.repr(self.tcx()))[])
|
||||
}
|
||||
};
|
||||
match self.typer.node_method_origin(MethodCall::expr(call.id)) {
|
||||
Some(method_origin) => {
|
||||
OverloadedCallType::from_method_origin(
|
||||
self.tcx(),
|
||||
&method_origin)
|
||||
}
|
||||
None => {
|
||||
self.tcx().sess.span_bug(
|
||||
callee.span,
|
||||
format!("unexpected callee type {}",
|
||||
callee_ty.repr(self.tcx())).as_slice())
|
||||
}
|
||||
};
|
||||
match overloaded_call_type {
|
||||
FnMutOverloadedCall => {
|
||||
self.borrow_expr(callee,
|
||||
|
@ -285,6 +285,8 @@ pub trait Typer<'tcx> {
|
||||
fn node_ty(&self, id: ast::NodeId) -> Ty<'tcx>;
|
||||
fn expr_ty_adjusted(&self, expr: &ast::Expr) -> Ty<'tcx>;
|
||||
fn node_method_ty(&self, method_call: ty::MethodCall) -> Option<Ty<'tcx>>;
|
||||
fn node_method_origin(&self, method_call: ty::MethodCall)
|
||||
-> Option<ty::MethodOrigin<'tcx>>;
|
||||
fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment<'tcx>>>;
|
||||
fn is_method_call(&self, id: ast::NodeId) -> bool;
|
||||
fn temporary_scope(&self, rvalue_id: ast::NodeId) -> Option<region::CodeExtent>;
|
||||
|
@ -3003,9 +3003,9 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
|
||||
// FIXME(#14449): `borrowed_contents` below assumes `&mut`
|
||||
// unboxed closure.
|
||||
let upvars = unboxed_closure_upvars(cx, did, substs);
|
||||
TypeContents::union(upvars[],
|
||||
|f| tc_ty(cx, f.ty, cache)) |
|
||||
borrowed_contents(r, MutMutable)
|
||||
TypeContents::union(upvars.as_slice(),
|
||||
|f| tc_ty(cx, f.ty, cache))
|
||||
| borrowed_contents(r, MutMutable)
|
||||
}
|
||||
|
||||
ty_tup(ref tys) => {
|
||||
@ -6177,6 +6177,12 @@ impl<'tcx> mc::Typer<'tcx> for ty::ctxt<'tcx> {
|
||||
self.method_map.borrow().get(&method_call).map(|method| method.ty)
|
||||
}
|
||||
|
||||
fn node_method_origin(&self, method_call: ty::MethodCall)
|
||||
-> Option<ty::MethodOrigin<'tcx>>
|
||||
{
|
||||
self.method_map.borrow().get(&method_call).map(|method| method.origin.clone())
|
||||
}
|
||||
|
||||
fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment<'tcx>>> {
|
||||
&self.adjustments
|
||||
}
|
||||
|
@ -479,6 +479,16 @@ impl<'blk, 'tcx> mc::Typer<'tcx> for BlockS<'blk, 'tcx> {
|
||||
.map(|method| monomorphize_type(self, method.ty))
|
||||
}
|
||||
|
||||
fn node_method_origin(&self, method_call: ty::MethodCall)
|
||||
-> Option<ty::MethodOrigin<'tcx>>
|
||||
{
|
||||
self.tcx()
|
||||
.method_map
|
||||
.borrow()
|
||||
.get(&method_call)
|
||||
.map(|method| method.origin.clone())
|
||||
}
|
||||
|
||||
fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment<'tcx>>> {
|
||||
&self.tcx().adjustments
|
||||
}
|
||||
|
@ -301,6 +301,13 @@ impl<'a, 'tcx> mc::Typer<'tcx> for FnCtxt<'a, 'tcx> {
|
||||
.map(|method| method.ty)
|
||||
.map(|ty| self.infcx().resolve_type_vars_if_possible(&ty))
|
||||
}
|
||||
fn node_method_origin(&self, method_call: ty::MethodCall)
|
||||
-> Option<ty::MethodOrigin<'tcx>>
|
||||
{
|
||||
self.inh.method_map.borrow()
|
||||
.get(&method_call)
|
||||
.map(|method| method.origin.clone())
|
||||
}
|
||||
fn adjustments(&self) -> &RefCell<NodeMap<ty::AutoAdjustment<'tcx>>> {
|
||||
&self.inh.adjustments
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user