Skip to content

Add recursion limit to inhabitedness check #39680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 12, 2017

Conversation

canndrew
Copy link
Contributor

@canndrew canndrew commented Feb 9, 2017

Fixes #39489.
Add test aswell.

@rust-highfive
Copy link
Contributor

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

tcx: TyCtxt<'a, 'gcx, 'tcx>) -> DefIdForest
{
recursion_depth += 1;
if recursion_depth >= ARBITRARY_RECURSION_LIMIT {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We normally use the tcx.sess.recursion_limit and emit a fatal error when it is exceeded (grep for that for usage examples).

@canndrew
Copy link
Contributor Author

canndrew commented Feb 9, 2017

I've refactored the inhabitedness checking code a bit because there seemed to be a fairly narrow band of appropriate values for the recursion limit if it was implemented naively. recursion_limit / 4 would cause perfectly sensible code to hit the limit, recursion_limit / 2 wouldn't kick in soon enough and the testcase would crash the compiler. Instead now we look at how deep we've recursed through a specific adt, if that number gets big then we're likely in an infinite loop.

@eddyb
Copy link
Member

eddyb commented Feb 9, 2017

r? @arielb1

@rust-highfive rust-highfive assigned arielb1 and unassigned eddyb Feb 9, 2017
@arielb1
Copy link
Contributor

arielb1 commented Feb 11, 2017

@bors r+

@bors
Copy link
Collaborator

bors commented Feb 11, 2017

📌 Commit 347bc77 has been approved by arielb1

@bors
Copy link
Collaborator

bors commented Feb 11, 2017

⌛ Testing commit 347bc77 with merge 0584f00...

@bors
Copy link
Collaborator

bors commented Feb 11, 2017

💔 Test failed - status-travis

@alexcrichton
Copy link
Member

alexcrichton commented Feb 11, 2017 via email

@bors
Copy link
Collaborator

bors commented Feb 11, 2017

⌛ Testing commit 347bc77 with merge 94ea562...

@bors
Copy link
Collaborator

bors commented Feb 11, 2017

💔 Test failed - status-appveyor

@alexcrichton
Copy link
Member

alexcrichton commented Feb 11, 2017 via email

@bors
Copy link
Collaborator

bors commented Feb 12, 2017

⌛ Testing commit 347bc77 with merge 282fa87...

bors added a commit that referenced this pull request Feb 12, 2017
…elb1

Add recursion limit to inhabitedness check

Fixes #39489.
Add test aswell.
@bors
Copy link
Collaborator

bors commented Feb 12, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: arielb1
Pushing 282fa87 to master...

@bors bors merged commit 347bc77 into rust-lang:master Feb 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants