]> git.lizzy.rs Git - rust.git/commitdiff
Warn about inference variables behind raw pointers in method lookup
authorMichael Hewson <michael@michaelhewson.ca>
Thu, 14 Dec 2017 17:42:40 +0000 (18:42 +0100)
committerMichael Hewson <michael@michaelhewson.ca>
Sun, 17 Dec 2017 09:13:09 +0000 (10:13 +0100)
src/librustc_typeck/check/method/probe.rs

index 141f0eea1fbe5ae1dd228826bacb1097a6a9d555..fe30ffb3cfccde1788650231515fdf788f9b2582 100644 (file)
@@ -321,9 +321,16 @@ fn create_steps(&self,
                 // a real method lookup, this is a hard error (it's an
                 // ambiguity and we can't make progress).
                 if !is_suggestion.0 {
-                    // 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 {
+                    if reached_raw_pointer
+                    && !self.tcx.sess.features.borrow().arbitrary_self_types {
+                        // only produce a warning in this case, because inference variables used to
+                        // be allowed here in some cases for raw pointers
+                        struct_span_warn!(self.tcx.sess, span, E0619,
+                            "the type of this value must be known in this context")
+                        .note("this will be made into a hard error in a future version of \
+                               the compiler")
+                        .emit();
+                    } else {
                         let t = self.structurally_resolved_type(span, final_ty);
                         assert_eq!(t, self.tcx.types.err);
                         return None