From this code ,paste here
hir::ExprKind::Index(ref lhs, ref index) => {
if cx.typeck_results().is_method_call(expr) {
overloaded_place(cx, expr, expr_ty, None, vec![lhs.to_ref(), index.to_ref()])
} else {
ExprKind::Index { lhs: lhs.to_ref(), index: index.to_ref() }
}
}
And from here , an hir::Index
expression must implement Index
trait to pass the check.
So my question is how to make compiler go through the else part? That is to mirror hir::Index
to thir::Index
instead of thir::Call
?
I guess there must some thing happening (for example delete the method call from the type check results) between after type check and the mirroring. Many thanks!