-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
I have an alternative approach that does the location adjustment in the |
@matthewjasper would you like me to compare the two branches, then? |
Yes, or suggest a third approach if you feel neither is satisfactory. |
ca095d9
to
78f9515
Compare
I've pushed (yet) another version that avoids changing other parts of typeck. |
NLL triage. Assigning to self for review. |
let mut constraints = Default::default(); | ||
let mut closure_bounds = Default::default(); | ||
if let Some(ref mut bcx) = self.cx.borrowck_context { | ||
// Don't try to add borrow_region facts for the promted MIR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: promted
#![feature(nll)] | ||
|
||
fn foo(x: &i32) -> &i32 { | ||
let z = 4; | ||
let f = &|y| y; | ||
let k = f(&z); | ||
f(x) | ||
f(x) //~ cannot return value referencing local variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh.... uh oh?
Is this because we aren't inferring a sufficiently general type for the closure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I guess the "good" news is that AST-borrowck also rejects this code, so the impact of this "regression" will be limited... maybe...?
@bors r+ |
📌 Commit 78f9515b2c6de76dd1f51c36199bca590bd93cd7 has been approved by |
I'm r+'ing this but I'm also nominating it for discussion at the NLL meeting. In particular, I want us to make sure we're all okay with the change from accepting the test from #48697 to rejecting it. (My current hypothesis is that its being rejected because of known issues with inferring higher-ranked lifetime for closures; see also discussion on #58052.) |
oh and I'm also beta nominating, since this is fixing a soundness issue and is relatively straight-forward. |
78f9515
to
b45e5ba
Compare
@bors r=pnkfelix |
📌 Commit b45e5bac88971bbb7e81d4ea613318d829068ddb has been approved by |
This comment has been minimized.
This comment has been minimized.
@bors r+ |
📌 Commit 255d36208a22a420776ec3ca43a63b2e3c634d7a has been approved by |
@matthewjasper if you get a chance it might be nice to make a unit test for whatever problem was uncovered by the ICE during bootstrap? |
discussed at T-compiler meeting. We'll revisit the question of whether or not to backport this to beta next week. (@nikomatsakis wants to review the approach.) |
255d362
to
4b1b357
Compare
@bors r=pnkfelix |
📌 Commit 4b1b357568cdf9f1c0bf964309c2e1d4088d72c6 has been approved by |
☔ The latest upstream changes (presumably #58631) made this pull request unmergeable. Please resolve the merge conflicts. |
Previously, a promoted that contains a function item wouldn't have the function items bounds propagated to the main function body.
Type annotations are shared between the MIR of a function and the promoted constants for that function, so keep them in the type checker when we check the promoted MIR.
4b1b357
to
3b93d71
Compare
@bors r=pnkfelix |
📌 Commit 3b93d71 has been approved by |
Include bounds from promoted constants in NLL Previously a promoted function wouldn't have its bound propagated out to the main function body. When we visit a promoted, we now type check the MIR of the promoted and transfer any lifetime constraints to back to the main function's MIR. Fixes #57170 r? @nikomatsakis
☀️ Test successful - checks-travis, status-appveyor |
discussed at T-compiler meeting. beta-accepting. |
[beta] Rollup backports Cherry-picked: * Include bounds from promoted constants in NLL #57202 * Warning period for detecting nested impl trait #58608 * Don't promote function calls to nonpromotable things #58784 * Make migrate mode work at item level granularity #58788 * Expand where negative supertrait specific error is shown #58861 * Expand where negative supertrait specific error is shown #58861 Rolled up: * [BETA] Update cargo #59217 r? @ghost
Previously a promoted function wouldn't have its bound propagated out to
the main function body.
When we visit a promoted, we now type check the MIR of the promoted
and transfer any lifetime constraints to back to the main function's MIR.
Fixes #57170
r? @nikomatsakis