diff options
| author | kennytm <kennytm@gmail.com> | 2018-03-01 05:16:44 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-03-24 06:55:06 +0800 |
| commit | 1731bf8049258e63257f6dde48b375acafaeb4ef (patch) | |
| tree | 671c64e5436031da012e0b693e1cc3b6f56ca9a4 /src | |
| parent | c08480fce0f39f5c9c6db6dde0dccb375ca0ab14 (diff) | |
| download | rust-1731bf8049258e63257f6dde48b375acafaeb4ef.tar.gz rust-1731bf8049258e63257f6dde48b375acafaeb4ef.zip | |
Provide a proper span when demanding for the return type of `box x`.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_typeck/check/demand.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/did_you_mean/recursion_limit_deref.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/did_you_mean/recursion_limit_deref.stderr | 10 |
3 files changed, 7 insertions, 13 deletions
diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 701b896b905..e8b953d40d7 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -16,7 +16,7 @@ use rustc::traits::ObligationCause; 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 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { 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 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { (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, diff --git a/src/test/ui/did_you_mean/recursion_limit_deref.rs b/src/test/ui/did_you_mean/recursion_limit_deref.rs index 3e261ec636c..f5e75f40fca 100644 --- a/src/test/ui/did_you_mean/recursion_limit_deref.rs +++ b/src/test/ui/did_you_mean/recursion_limit_deref.rs @@ -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. diff --git a/src/test/ui/did_you_mean/recursion_limit_deref.stderr b/src/test/ui/did_you_mean/recursion_limit_deref.stderr index 2c803961557..20a94f7aac1 100644 --- a/src/test/ui/did_you_mean/recursion_limit_deref.stderr +++ b/src/test/ui/did_you_mean/recursion_limit_deref.stderr @@ -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`. |
