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

Include bounds from promoted constants in NLL #57202

Open
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@matthewjasper
Copy link
Contributor

matthewjasper commented Dec 29, 2018

Previously a promoted function wouldn't have its bound propagated out to
the main function body.

This is a quicker and less clean fix than the one suggested fix in the FIXME in the code. We just visit the MIR of all of the promoted constants as part of typeck, treating all relations as happening at the point where the promoted is used. This saves us from having to work out the constraints for each promoted item individually and propagating them outwards.

Fixes #57170

r? @nikomatsakis

@matthewjasper

This comment has been minimized.

Copy link
Contributor

matthewjasper commented Dec 30, 2018

I have an alternative approach that does the location adjustment in the BorrowCheckContext which can be seen here: https://github.com/matthewjasper/rust/tree/nll-typeck-promoteds-alternative. This feels a bit more principled, and ends up being a smaller diff.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Jan 2, 2019

@matthewjasper would you like me to compare the two branches, then?

@matthewjasper

This comment has been minimized.

Copy link
Contributor

matthewjasper commented Jan 2, 2019

Yes, or suggest a third approach if you feel neither is satisfactory.

@matthewjasper matthewjasper force-pushed the matthewjasper:nll-typeck-promoteds branch from bef3ed1 to ca095d9 Jan 17, 2019

matthewjasper added some commits Jan 17, 2019

Include bounds from promoted constants in NLL
Previously, a promoted that contains a function item wouldn't have the
function items bounds propagated to
the main function body.

@matthewjasper matthewjasper force-pushed the matthewjasper:nll-typeck-promoteds branch from ca095d9 to 78f9515 Jan 17, 2019

@matthewjasper

This comment has been minimized.

Copy link
Contributor

matthewjasper commented Jan 17, 2019

I've pushed (yet) another version that avoids changing other parts of typeck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment