Skip to content

Commit e7d1542

Browse files
committed
don't emit a type error if autoderef ends in an inference variable, as long as we went through a raw pointer
This avoids a break in backward compatibility in the following case: ``` let ptr = std::ptr::null(); let _ = &data as *const *const (); if data.null() {} ```
1 parent 083635e commit e7d1542

File tree

1 file changed

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

1 file changed

+7
-3
lines changed

src/librustc_typeck/check/method/probe.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,13 @@ 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-
let t = self.structurally_resolved_type(span, final_ty);
325-
assert_eq!(t, self.tcx.types.err);
326-
return None
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 {
327+
let t = self.structurally_resolved_type(span, final_ty);
328+
assert_eq!(t, self.tcx.types.err);
329+
return None
330+
}
327331
} else {
328332
// If we're just looking for suggestions,
329333
// though, ambiguity is no big thing, we can

0 commit comments

Comments
 (0)