Uh oh!
There was an error while loading. Please reload this page.
Abort on potential infinite recursion in type_must_outlive (#25954) - #26489
Abort on potential infinite recursion in type_must_outlive (#25954)#26489robertg wants to merge 3 commits into
Conversation
Display E0399 and stop recursing in type_must_outlive if a previous function application was encountered.
rust-highfive
commented
Jun 22, 2015
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pcwalton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
arielb1
commented
Jun 22, 2015
Test please. I'm quite sure you need a recursion limit, not a loop check (the example creates a non-regular type via upvars). |
robertg
commented
Jun 22, 2015
@arielb1 I added a compile-fail-test. Are there some examples in the codebase utilizing recursion limits (does it use a function depth constant?). I think figuring out how to detect a loop in the 'region type graph' should be our goal, with using a recursion limit as a last resort. |
alexcrichton
commented
Jun 23, 2015
r? @nikomatsakis or @arielb1 |
There was a problem hiding this comment.
Nit: use FnvHashSet (that's util::nodemap::FnvHashSet).
arielb1
commented
Jun 24, 2015
As an approach, I would prefer to check for closure representability (see
structB<'a,F:Fn()+'a>(&'aF);fnmain(){letmut p = B(std::mem::zeroed());
p.0 = &||{p.0;};}as it is a non-borrowcking sugaring of #![feature(unboxed_closures,core)]use std::cell::Cell;structB<'a,F:FnOnce()+'a>(Cell<Option<&'aF>>);structClosure<'a>{arg:B<'a,Closure<'a>>}impl<'a>FnOnce<()>forClosure<'a>{typeOutput = ();extern"rust-call"fncall_once(self,args:()){}}fnmain(){let(mut p,mut cls);
p = B(Cell::new(None));
cls = Closure{arg: p };
cls.arg.0.set(Some(&cls));} |
bors
commented
Jun 27, 2015
☔ The latest upstream changes (presumably #26575) made this pull request unmergeable. Please resolve the merge conflicts. |
nikomatsakis
commented
Jun 29, 2015
Sorry, last week was the work week, and this week I'm on vacation. I'll try to read over the code/comments this week though. I will say that one of the RFCs I am hoping to propose once I get back makes this point about recursion moot. |
nikomatsakis
commented
Jul 8, 2015
So, I'm in the process of preparing an RFC and PR that does a big overhaul to |
robertg
commented
Jul 9, 2015
Yes. |
nikomatsakis
commented
Jul 17, 2015
Hmm, actually, I was mistaken. The problem this PR aims to correct is not fixed by the patches I've been working on, or at least not the ones I was thining of. However, it IS fixed by a separate PR: |
Display E0399 and stop recursing in
type_must_outliveif a previous duplicate function application was encountered, to prevent a stack overflow.This is my initial approach: Declare
(ty, region, origin.span())to define a distincttype_must_outlivefunction application, and use aHashSetto ensure no duplicate function applications occur.Closes: #25954