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