summaryrefslogtreecommitdiffstats
path: root/src/test/ui/infinite/infinite-instantiation.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/infinite/infinite-instantiation.rs')
-rw-r--r--src/test/ui/infinite/infinite-instantiation.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/ui/infinite/infinite-instantiation.rs b/src/test/ui/infinite/infinite-instantiation.rs
new file mode 100644
index 000000000..9b9f332ca
--- /dev/null
+++ b/src/test/ui/infinite/infinite-instantiation.rs
@@ -0,0 +1,29 @@
+// build-fail
+// normalize-stderr-test: ".nll/" -> "/"
+
+trait ToOpt: Sized {
+ fn to_option(&self) -> Option<Self>;
+}
+
+impl ToOpt for usize {
+ fn to_option(&self) -> Option<usize> {
+ Some(*self)
+ }
+}
+
+impl<T:Clone> ToOpt for Option<T> {
+ fn to_option(&self) -> Option<Option<T>> {
+ Some((*self).clone())
+ }
+}
+
+fn function<T:ToOpt + Clone>(counter: usize, t: T) {
+ if counter > 0 {
+ function(counter - 1, t.to_option());
+ //~^ ERROR reached the recursion limit while instantiating `function::<Option<
+ }
+}
+
+fn main() {
+ function(22, 22);
+}