Skip to content

Commit 9369a07

Browse files
committed
Tag some code duplication with FIXME for #18741.
1 parent 2d93af9 commit 9369a07

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/librustc/middle/typeck/check/method/mod.rs

+15
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,21 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
131131
opt_input_types: Option<Vec<ty::t>>)
132132
-> Option<MethodCallee>
133133
{
134+
/*!
135+
* `lookup_in_trait_adjusted` is used for overloaded operators. It
136+
* does a very narrow slice of what the normal probe/confirm path
137+
* does. In particular, it doesn't really do any probing: it
138+
* simply constructs an obligation for a particular trait with the
139+
* given self-type and checks whether that trait is implemented.
140+
*
141+
* FIXME(#18741) -- It seems likely that we can consolidate some of this
142+
* code with the other method-lookup code. In particular,
143+
* autoderef on index is basically identical to autoderef with
144+
* normal probes, except that the test also looks for built-in
145+
* indexing. Also, the second half of this method is basically
146+
* the same as confirmation.
147+
*/
148+
134149
debug!("lookup_in_trait_adjusted(self_ty={}, self_expr={}, m_name={}, trait_def_id={})",
135150
self_ty.repr(fcx.tcx()),
136151
self_expr.repr(fcx.tcx()),

src/librustc/middle/typeck/check/method/probe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub fn probe(fcx: &FnCtxt,
114114
method_name,
115115
call_expr_id);
116116

117-
// FIXME -- right now, creating the steps involves evaluating the
117+
// FIXME(#18741) -- right now, creating the steps involves evaluating the
118118
// `*` operator, which registers obligations that then escape into
119119
// the global fulfillment context and thus has global
120120
// side-effects. This is a bit of a pain to refactor. So just let

src/librustc/middle/typeck/check/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2265,6 +2265,10 @@ fn autoderef_for_index<T>(fcx: &FnCtxt,
22652265
step: |ty::t, ty::AutoDerefRef| -> Option<T>)
22662266
-> Option<T>
22672267
{
2268+
// FIXME(#18741) -- this is almost but not quite the same as the
2269+
// autoderef that normal method probing does. They could likely be
2270+
// consolidated.
2271+
22682272
let (ty, autoderefs, final_mt) =
22692273
autoderef(fcx, base_expr.span, base_ty, Some(base_expr.id), lvalue_pref, |adj_ty, idx| {
22702274
let autoderefref = ty::AutoDerefRef { autoderefs: idx, autoref: None };

0 commit comments

Comments
 (0)