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() {}
```
This commit is contained in:
Michael Hewson 2017-11-10 10:30:30 -05:00
parent 083635eab2
commit e7d1542a52

View File

@ -321,9 +321,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// a real method lookup, this is a hard error (it's an
// ambiguity and we can't make progress).
if !is_suggestion.0 {
let t = self.structurally_resolved_type(span, final_ty);
assert_eq!(t, self.tcx.types.err);
return None
// don't report a type error if we dereferenced a raw pointer,
// because that would break backwards compatibility in certain cases
if !reached_raw_pointer {
let t = self.structurally_resolved_type(span, final_ty);
assert_eq!(t, self.tcx.types.err);
return None
}
} else {
// If we're just looking for suggestions,
// though, ambiguity is no big thing, we can