Provide a proper span when demanding for the return type of box x
.
This commit is contained in:
parent
c08480fce0
commit
1731bf8049
3 changed files with 7 additions and 13 deletions
|
@ -16,7 +16,7 @@ use rustc::traits::ObligationCause;
|
||||||
|
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::util::parser::PREC_POSTFIX;
|
use syntax::util::parser::PREC_POSTFIX;
|
||||||
use syntax_pos::{self, Span};
|
use syntax_pos::Span;
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use rustc::hir::def::Def;
|
use rustc::hir::def::Def;
|
||||||
use rustc::hir::map::NodeItem;
|
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) {
|
if let Some((msg, suggestion)) = self.check_ref(expr, checked_ty, expected) {
|
||||||
err.span_suggestion(expr.span, msg, suggestion);
|
err.span_suggestion(expr.span, msg, suggestion);
|
||||||
} else if !self.check_for_cast(&mut err, expr, expr_ty, expected) {
|
} 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) {
|
if let Ok(expr_text) = self.tcx.sess.codemap().span_to_snippet(expr.span) {
|
||||||
let suggestions = iter::repeat(expr_text).zip(methods.iter())
|
let suggestions = iter::repeat(expr_text).zip(methods.iter())
|
||||||
.map(|(receiver, method)| format!("{}.{}()", receiver, method.name))
|
.map(|(receiver, method)| format!("{}.{}()", receiver, method.name))
|
||||||
|
@ -155,9 +155,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
(expected, Some(err))
|
(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> {
|
-> 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,
|
probe::Mode::MethodCall,
|
||||||
expected,
|
expected,
|
||||||
checked_ty,
|
checked_ty,
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
//~^^^^^^^^^^ ERROR reached the recursion limit
|
|
||||||
|
|
||||||
// Test that the recursion limit can be changed and that the compiler
|
// 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
|
// suggests a fix. In this case, we have a long chain of Deref impls
|
||||||
// which will cause an overflow during the autoderef loop.
|
// which will cause an overflow during the autoderef loop.
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
error[E0055]: reached the recursion limit while auto-dereferencing I
|
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
|
LL | let x: &Bottom = &t; //~ ERROR mismatched types
|
||||||
| ^^ deref recursion limit reached
|
| ^^ deref recursion limit reached
|
||||||
|
|
|
|
||||||
= help: consider adding a `#![recursion_limit="20"]` attribute to your crate
|
= 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
|
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
|
LL | let x: &Bottom = &t; //~ ERROR mismatched types
|
||||||
| ^^ expected struct `Bottom`, found struct `Top`
|
| ^^ expected struct `Bottom`, found struct `Top`
|
||||||
|
@ -19,7 +15,7 @@ LL | let x: &Bottom = &t; //~ ERROR mismatched types
|
||||||
= note: expected type `&Bottom`
|
= note: expected type `&Bottom`
|
||||||
found type `&Top`
|
found type `&Top`
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
Some errors occurred: E0055, E0308.
|
Some errors occurred: E0055, E0308.
|
||||||
For more information about an error, try `rustc --explain E0055`.
|
For more information about an error, try `rustc --explain E0055`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue