forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Guard against infinitely expanding generic/inline functions
Closes rust-lang#2220 Test case disabled until a memory-leak issue is resolved.
- Loading branch information
Showing
3 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// error-pattern: overly deep expansion | ||
// issue 2258 | ||
// This is currently exposing a memory leak, and xfailed for that reason | ||
// xfail-test | ||
|
||
iface to_opt { | ||
fn to_option() -> option<self>; | ||
} | ||
|
||
impl of to_opt for uint { | ||
fn to_option() -> option<uint> { | ||
some(self) | ||
} | ||
} | ||
|
||
impl<T:copy> of to_opt for option<T> { | ||
fn to_option() -> option<option<T>> { | ||
some(self) | ||
} | ||
} | ||
|
||
fn function<T:to_opt>(counter: uint, t: T) { | ||
if counter > 0u { | ||
function(counter - 1u, t.to_option()); | ||
} | ||
} | ||
|
||
fn main() { | ||
function(22u, 22u); | ||
} |