From d80729a8e409e9c58472cecc99923fa4f440f486 Mon Sep 17 00:00:00 2001 From: Nathan Typanski Date: Sun, 7 Sep 2014 01:43:02 -0400 Subject: [PATCH] Add ICE regression test for issue #16218. This code used to produce an ICE on the definition of trait Bar with the following message: Type parameter out of range when substituting in region 'a (root type=fn(Self) -> 'astr) (space=FnSpace, index=0) Closes #16218. --- .../generic-lifetime-trait-impl.rs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/test/compile-fail/generic-lifetime-trait-impl.rs diff --git a/src/test/compile-fail/generic-lifetime-trait-impl.rs b/src/test/compile-fail/generic-lifetime-trait-impl.rs new file mode 100644 index 0000000000000..8b52324848bf4 --- /dev/null +++ b/src/test/compile-fail/generic-lifetime-trait-impl.rs @@ -0,0 +1,30 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This code used to produce an ICE on the definition of trait Bar +// with the following message: +// +// Type parameter out of range when substituting in region 'a (root +// type=fn(Self) -> 'astr) (space=FnSpace, index=0) +// +// Regression test for issue #16218. + +trait Bar<'a> {} + +trait Foo<'a> { + fn bar<'a, T: Bar<'a>>(self) -> &'a str; +} + +impl<'a> Foo<'a> for &'a str { + fn bar>(self) -> &'a str { fail!() } //~ ERROR lifetime +} + +fn main() { +}