Skip to content

Commit 65b44db

Browse files
committed
fixup
1 parent dd9f4e5 commit 65b44db

File tree

1 file changed

+10
-9
lines changed
  • src/librustc_typeck/check/method

1 file changed

+10
-9
lines changed

src/librustc_typeck/check/method/probe.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
278278
})
279279
};
280280

281+
// If we encountered an `_` type or an error type during autoderef, this is
282+
// ambiguous.
281283
if let Some(CreateStepsBadTy { reached_raw_pointer, ty }) = &steps.opt_bad_ty {
282-
// Ended in an inference variable. If we are doing
283-
// a real method lookup, this is a hard error because it's
284-
// possible that there will be multiple applicable methods.
285-
if !is_suggestion.0
286-
&& *reached_raw_pointer
287-
&& !self.tcx.features().arbitrary_self_types
288-
{
284+
if is_suggestion.0 {
285+
// Ambiguity was encountered during a suggestion. Just keep going.
286+
debug!("ProbeContext: encountered ambiguity in suggestion");
287+
} else if *reached_raw_pointer && !self.tcx.features().arbitrary_self_types {
289288
// this case used to be allowed by the compiler,
290289
// so we do a future-compat lint here for the 2015 edition
291290
// (see https://github.com/rust-lang/rust/issues/46906)
@@ -301,6 +300,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
301300
"type annotations needed");
302301
}
303302
} else {
303+
// Encountered a real ambiguity, so abort the lookup. If `ty` is not
304+
// an `Err`, report the right "type annotations needed" error pointing
305+
// to it.
304306
let ty = do_instantiate_query_result(self, span, &orig_values, ty)
305307
.unwrap_or_else(|_| span_bug!(span, "instantiating {:?} failed?", ty));
306308
let t = self.structurally_resolved_type(span, ty.value);
@@ -310,7 +312,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
310312
Vec::new(),
311313
None,
312314
mode)));
313-
314315
}
315316
}
316317

@@ -392,7 +393,7 @@ fn create_steps_inner<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
392393
let mut steps: Vec<_> = autoderef.by_ref()
393394
.map(|(ty, d)| {
394395
let step = CandidateStep {
395-
self_ty: do_make_query_result(infcx, &inference_vars, infcx.tcx.mk_slice(ty)),
396+
self_ty: do_make_query_result(infcx, &inference_vars, ty),
396397
autoderefs: d,
397398
from_unsafe_deref: reached_raw_pointer,
398399
unsize: false,

0 commit comments

Comments
 (0)