]> git.lizzy.rs Git - rust.git/commitdiff
Provide a proper span when demanding for the return type of `box x`.
authorkennytm <kennytm@gmail.com>
Wed, 28 Feb 2018 21:16:44 +0000 (05:16 +0800)
committerkennytm <kennytm@gmail.com>
Fri, 23 Mar 2018 22:55:06 +0000 (06:55 +0800)
src/librustc_typeck/check/demand.rs
src/test/ui/did_you_mean/recursion_limit_deref.rs
src/test/ui/did_you_mean/recursion_limit_deref.stderr

index 701b896b9057bc8b07c3853df3e053845abb6745..e8b953d40d7a1ae7ee2664acfc9a719f7f155f30 100644 (file)
@@ -16,7 +16,7 @@
 
 use syntax::ast;
 use syntax::util::parser::PREC_POSTFIX;
-use syntax_pos::{self, Span};
+use syntax_pos::Span;
 use rustc::hir;
 use rustc::hir::def::Def;
 use rustc::hir::map::NodeItem;
@@ -140,7 +140,7 @@ pub fn demand_coerce_diag(&self,
         if let Some((msg, suggestion)) = self.check_ref(expr, checked_ty, expected) {
             err.span_suggestion(expr.span, msg, suggestion);
         } else if !self.check_for_cast(&mut err, expr, expr_ty, expected) {
-            let methods = self.get_conversion_methods(expected, checked_ty);
+            let methods = self.get_conversion_methods(expr.span, expected, checked_ty);
             if let Ok(expr_text) = self.tcx.sess.codemap().span_to_snippet(expr.span) {
                 let suggestions = iter::repeat(expr_text).zip(methods.iter())
                     .map(|(receiver, method)| format!("{}.{}()", receiver, method.name))
@@ -155,9 +155,9 @@ pub fn demand_coerce_diag(&self,
         (expected, Some(err))
     }
 
-    fn get_conversion_methods(&self, expected: Ty<'tcx>, checked_ty: Ty<'tcx>)
+    fn get_conversion_methods(&self, span: Span, expected: Ty<'tcx>, checked_ty: Ty<'tcx>)
                               -> Vec<AssociatedItem> {
-        let mut methods = self.probe_for_return_type(syntax_pos::DUMMY_SP,
+        let mut methods = self.probe_for_return_type(span,
                                                      probe::Mode::MethodCall,
                                                      expected,
                                                      checked_ty,
index 3e261ec636c0801f3b6ff90fa37aef80d5af84d3..f5e75f40fca087ed0bd22779aad8a9a0e7e06d7d 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//~^^^^^^^^^^ ERROR reached the recursion limit
-
 // Test that the recursion limit can be changed and that the compiler
 // suggests a fix. In this case, we have a long chain of Deref impls
 // which will cause an overflow during the autoderef loop.
index 2c8039615572c87d4eee41822eaec45de8d6dbd5..20a94f7aac196121b9a92deee1db7354b1ac7435 100644 (file)
@@ -1,17 +1,13 @@
 error[E0055]: reached the recursion limit while auto-dereferencing I
-  --> $DIR/recursion_limit_deref.rs:62:22
+  --> $DIR/recursion_limit_deref.rs:60:22
    |
 LL |     let x: &Bottom = &t; //~ ERROR mismatched types
    |                      ^^ deref recursion limit reached
    |
    = help: consider adding a `#![recursion_limit="20"]` attribute to your crate
 
-error[E0055]: reached the recursion limit while auto-dereferencing I
-   |
-   = help: consider adding a `#![recursion_limit="20"]` attribute to your crate
-
 error[E0308]: mismatched types
-  --> $DIR/recursion_limit_deref.rs:62:22
+  --> $DIR/recursion_limit_deref.rs:60:22
    |
 LL |     let x: &Bottom = &t; //~ ERROR mismatched types
    |                      ^^ expected struct `Bottom`, found struct `Top`
@@ -19,7 +15,7 @@ LL |     let x: &Bottom = &t; //~ ERROR mismatched types
    = note: expected type `&Bottom`
               found type `&Top`
 
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
 
 Some errors occurred: E0055, E0308.
 For more information about an error, try `rustc --explain E0055`.