mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
tests: update expected recursion limit errors for the temporary lack of spans.
This commit is contained in:
parent
7a8a5172a5
commit
3b0cafbcd7
@ -120,7 +120,16 @@ pub fn erase_regions<'tcx,T>(cx: &ty::ctxt<'tcx>, value: &T) -> T
|
|||||||
// Is the type's representation size known at compile time?
|
// Is the type's representation size known at compile time?
|
||||||
pub fn type_is_sized<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
|
pub fn type_is_sized<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||||
let param_env = ty::empty_parameter_environment(tcx);
|
let param_env = ty::empty_parameter_environment(tcx);
|
||||||
ty::type_is_sized(¶m_env, DUMMY_SP, ty)
|
// FIXME(#4287) This can cause errors due to polymorphic recursion,
|
||||||
|
// a better span should be provided, if available.
|
||||||
|
let err_count = tcx.sess.err_count();
|
||||||
|
let is_sized = ty::type_is_sized(¶m_env, DUMMY_SP, ty);
|
||||||
|
// Those errors aren't fatal, but an incorrect result can later
|
||||||
|
// trip over asserts in both rustc's trans and LLVM.
|
||||||
|
if err_count < tcx.sess.err_count() {
|
||||||
|
tcx.sess.abort_if_errors();
|
||||||
|
}
|
||||||
|
is_sized
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn type_is_fat_ptr<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
|
pub fn type_is_fat_ptr<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
|
||||||
// file at the top-level directory of this distribution and at
|
// file at the top-level directory of this distribution and at
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
//
|
//
|
||||||
@ -8,28 +8,34 @@
|
|||||||
// 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-pattern: reached the recursion limit during monomorphization
|
//~^^^^^^^^^^ ERROR overflow
|
||||||
// issue 2258
|
//
|
||||||
|
// We get an error message at the top of file (dummy span).
|
||||||
|
// This is not helpful, but also kind of annoying to prevent,
|
||||||
|
// so for now just live with it.
|
||||||
|
// This test case was originally for issue #2258.
|
||||||
|
|
||||||
trait to_opt {
|
trait ToOpt {
|
||||||
fn to_option(&self) -> Option<Self>;
|
fn to_option(&self) -> Option<Self>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_opt for usize {
|
impl ToOpt for usize {
|
||||||
fn to_option(&self) -> Option<usize> {
|
fn to_option(&self) -> Option<usize> {
|
||||||
Some(*self)
|
Some(*self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T:Clone> to_opt for Option<T> {
|
impl<T:Clone> ToOpt for Option<T> {
|
||||||
fn to_option(&self) -> Option<Option<T>> {
|
fn to_option(&self) -> Option<Option<T>> {
|
||||||
Some((*self).clone())
|
Some((*self).clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn function<T:to_opt + Clone>(counter: usize, t: T) {
|
fn function<T:ToOpt + Clone>(counter: usize, t: T) {
|
||||||
if counter > 0_usize {
|
if counter > 0_usize {
|
||||||
function(counter - 1_usize, t.to_option());
|
function(counter - 1_usize, t.to_option());
|
||||||
|
// FIXME(#4287) Error message should be here. It should be
|
||||||
|
// a type error to instantiate `test` at a type other than T.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
|
||||||
// file at the top-level directory of this distribution and at
|
// file at the top-level directory of this distribution and at
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
//
|
//
|
||||||
@ -10,10 +10,9 @@
|
|||||||
|
|
||||||
//~^^^^^^^^^^ ERROR overflow
|
//~^^^^^^^^^^ ERROR overflow
|
||||||
//
|
//
|
||||||
// We also get a second error message at the top of file (dummy
|
// We get an error message at the top of file (dummy span).
|
||||||
// span). This is not helpful, but also kind of annoying to prevent,
|
// This is not helpful, but also kind of annoying to prevent,
|
||||||
// so for now just live with it, since we also get a second message
|
// so for now just live with it.
|
||||||
// that is more helpful.
|
|
||||||
|
|
||||||
enum Nil {NilValue}
|
enum Nil {NilValue}
|
||||||
struct Cons<T> {head:isize, tail:T}
|
struct Cons<T> {head:isize, tail:T}
|
||||||
@ -28,9 +27,8 @@ impl<T:Dot> Dot for Cons<T> {
|
|||||||
}
|
}
|
||||||
fn test<T:Dot> (n:isize, i:isize, first:T, second:T) ->isize {
|
fn test<T:Dot> (n:isize, i:isize, first:T, second:T) ->isize {
|
||||||
match n { 0 => {first.dot(second)}
|
match n { 0 => {first.dot(second)}
|
||||||
//~^ ERROR: reached the recursion limit during monomorphization
|
// FIXME(#4287) Error message should be here. It should be
|
||||||
// Error message should be here. It should be a type error
|
// a type error to instantiate `test` at a type other than T.
|
||||||
// to instantiate `test` at a type other than T. (See #4287)
|
|
||||||
_ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})}
|
_ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user