Skip to content

Commit 3b0cafb

Browse files
committed
tests: update expected recursion limit errors for the temporary lack of spans.
1 parent 7a8a517 commit 3b0cafb

File tree

3 files changed

+29
-16
lines changed

3 files changed

+29
-16
lines changed

src/librustc_trans/trans/common.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,16 @@ pub fn erase_regions<'tcx,T>(cx: &ty::ctxt<'tcx>, value: &T) -> T
120120
// Is the type's representation size known at compile time?
121121
pub fn type_is_sized<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
122122
let param_env = ty::empty_parameter_environment(tcx);
123-
ty::type_is_sized(&param_env, DUMMY_SP, ty)
123+
// FIXME(#4287) This can cause errors due to polymorphic recursion,
124+
// a better span should be provided, if available.
125+
let err_count = tcx.sess.err_count();
126+
let is_sized = ty::type_is_sized(&param_env, DUMMY_SP, ty);
127+
// Those errors aren't fatal, but an incorrect result can later
128+
// trip over asserts in both rustc's trans and LLVM.
129+
if err_count < tcx.sess.err_count() {
130+
tcx.sess.abort_if_errors();
131+
}
132+
is_sized
124133
}
125134

126135
pub fn type_is_fat_ptr<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {

src/test/compile-fail/infinite-instantiation.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,28 +8,34 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern: reached the recursion limit during monomorphization
12-
// issue 2258
11+
//~^^^^^^^^^^ ERROR overflow
12+
//
13+
// We get an error message at the top of file (dummy span).
14+
// This is not helpful, but also kind of annoying to prevent,
15+
// so for now just live with it.
16+
// This test case was originally for issue #2258.
1317

14-
trait to_opt {
18+
trait ToOpt {
1519
fn to_option(&self) -> Option<Self>;
1620
}
1721

18-
impl to_opt for usize {
22+
impl ToOpt for usize {
1923
fn to_option(&self) -> Option<usize> {
2024
Some(*self)
2125
}
2226
}
2327

24-
impl<T:Clone> to_opt for Option<T> {
28+
impl<T:Clone> ToOpt for Option<T> {
2529
fn to_option(&self) -> Option<Option<T>> {
2630
Some((*self).clone())
2731
}
2832
}
2933

30-
fn function<T:to_opt + Clone>(counter: usize, t: T) {
34+
fn function<T:ToOpt + Clone>(counter: usize, t: T) {
3135
if counter > 0_usize {
3236
function(counter - 1_usize, t.to_option());
37+
// FIXME(#4287) Error message should be here. It should be
38+
// a type error to instantiate `test` at a type other than T.
3339
}
3440
}
3541

src/test/compile-fail/recursion.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -10,10 +10,9 @@
1010

1111
//~^^^^^^^^^^ ERROR overflow
1212
//
13-
// We also get a second error message at the top of file (dummy
14-
// span). This is not helpful, but also kind of annoying to prevent,
15-
// so for now just live with it, since we also get a second message
16-
// that is more helpful.
13+
// We get an error message at the top of file (dummy span).
14+
// This is not helpful, but also kind of annoying to prevent,
15+
// so for now just live with it.
1716

1817
enum Nil {NilValue}
1918
struct Cons<T> {head:isize, tail:T}
@@ -28,9 +27,8 @@ impl<T:Dot> Dot for Cons<T> {
2827
}
2928
fn test<T:Dot> (n:isize, i:isize, first:T, second:T) ->isize {
3029
match n { 0 => {first.dot(second)}
31-
//~^ ERROR: reached the recursion limit during monomorphization
32-
// Error message should be here. It should be a type error
33-
// to instantiate `test` at a type other than T. (See #4287)
30+
// FIXME(#4287) Error message should be here. It should be
31+
// a type error to instantiate `test` at a type other than T.
3432
_ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})}
3533
}
3634
}

0 commit comments

Comments
 (0)