Skip to content

Commit 1731bf8

Browse files
committed
Provide a proper span when demanding for the return type of box x.
1 parent c08480f commit 1731bf8

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

src/librustc_typeck/check/demand.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc::traits::ObligationCause;
1616

1717
use syntax::ast;
1818
use syntax::util::parser::PREC_POSTFIX;
19-
use syntax_pos::{self, Span};
19+
use syntax_pos::Span;
2020
use rustc::hir;
2121
use rustc::hir::def::Def;
2222
use rustc::hir::map::NodeItem;
@@ -140,7 +140,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
140140
if let Some((msg, suggestion)) = self.check_ref(expr, checked_ty, expected) {
141141
err.span_suggestion(expr.span, msg, suggestion);
142142
} else if !self.check_for_cast(&mut err, expr, expr_ty, expected) {
143-
let methods = self.get_conversion_methods(expected, checked_ty);
143+
let methods = self.get_conversion_methods(expr.span, expected, checked_ty);
144144
if let Ok(expr_text) = self.tcx.sess.codemap().span_to_snippet(expr.span) {
145145
let suggestions = iter::repeat(expr_text).zip(methods.iter())
146146
.map(|(receiver, method)| format!("{}.{}()", receiver, method.name))
@@ -155,9 +155,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
155155
(expected, Some(err))
156156
}
157157

158-
fn get_conversion_methods(&self, expected: Ty<'tcx>, checked_ty: Ty<'tcx>)
158+
fn get_conversion_methods(&self, span: Span, expected: Ty<'tcx>, checked_ty: Ty<'tcx>)
159159
-> Vec<AssociatedItem> {
160-
let mut methods = self.probe_for_return_type(syntax_pos::DUMMY_SP,
160+
let mut methods = self.probe_for_return_type(span,
161161
probe::Mode::MethodCall,
162162
expected,
163163
checked_ty,

src/test/ui/did_you_mean/recursion_limit_deref.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//~^^^^^^^^^^ ERROR reached the recursion limit
12-
1311
// Test that the recursion limit can be changed and that the compiler
1412
// suggests a fix. In this case, we have a long chain of Deref impls
1513
// which will cause an overflow during the autoderef loop.
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
error[E0055]: reached the recursion limit while auto-dereferencing I
2-
--> $DIR/recursion_limit_deref.rs:62:22
2+
--> $DIR/recursion_limit_deref.rs:60:22
33
|
44
LL | let x: &Bottom = &t; //~ ERROR mismatched types
55
| ^^ deref recursion limit reached
66
|
77
= help: consider adding a `#![recursion_limit="20"]` attribute to your crate
88

9-
error[E0055]: reached the recursion limit while auto-dereferencing I
10-
|
11-
= help: consider adding a `#![recursion_limit="20"]` attribute to your crate
12-
139
error[E0308]: mismatched types
14-
--> $DIR/recursion_limit_deref.rs:62:22
10+
--> $DIR/recursion_limit_deref.rs:60:22
1511
|
1612
LL | let x: &Bottom = &t; //~ ERROR mismatched types
1713
| ^^ expected struct `Bottom`, found struct `Top`
1814
|
1915
= note: expected type `&Bottom`
2016
found type `&Top`
2117

22-
error: aborting due to 3 previous errors
18+
error: aborting due to 2 previous errors
2319

2420
Some errors occurred: E0055, E0308.
2521
For more information about an error, try `rustc --explain E0055`.

0 commit comments

Comments
 (0)