Skip to content

Commit bc0439b

Browse files
committed
Warn about inference variables behind raw pointers in method lookup
1 parent 428b025 commit bc0439b

File tree

1 file changed

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

1 file changed

+10
-3
lines changed

src/librustc_typeck/check/method/probe.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
321321
// a real method lookup, this is a hard error (it's an
322322
// ambiguity and we can't make progress).
323323
if !is_suggestion.0 {
324-
// don't report a type error if we dereferenced a raw pointer,
325-
// because that would break backwards compatibility in certain cases
326-
if !reached_raw_pointer {
324+
if reached_raw_pointer
325+
&& !self.tcx.sess.features.borrow().arbitrary_self_types {
326+
// only produce a warning in this case, because inference variables used to
327+
// be allowed here in some cases for raw pointers
328+
struct_span_warn!(self.tcx.sess, span, E0619,
329+
"the type of this value must be known in this context")
330+
.note("this will be made into a hard error in a future version of \
331+
the compiler")
332+
.emit();
333+
} else {
327334
let t = self.structurally_resolved_type(span, final_ty);
328335
assert_eq!(t, self.tcx.types.err);
329336
return None

0 commit comments

Comments
 (0)