-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
internal compiler error: no enclosing scope with id XY #3860
Comments
I was asked to add the following, which exhibits the same or a similar problem, encountered using: use std::net_url;
use core::result;
fn main() {
let urlstr = "test";
// this works without error or warning
let r: &result::Result<net_url::Url,~str> = &net_url::from_str(urlstr);
result::get_ref( r );
// this gives me:
// error: illegal borrow: borrowed value does not live long enough
// note: borrowed pointer must be valid for unknown scope: 59. Please report a bug....
result::get_ref( &net_url::from_str(urlstr) );
} |
Reproduced as of d2ad028 |
I have a fix; running tests. |
This is for consistency with borrowck. Changing borrowck would also be an alternative, but I found it easier to change trans :-) This eliminates an ICE in trans where the scope for a particular borrow was a statement ID, but the code in trans that does cleanups wasn't finding the block with that scope. As per rust-lang#3860
I just ran into a similar error with this code:
That resulted in this error:
I haven't been able to reduce it down beyond this. |
I know what the bug is here, and had a fix in #4192, but the problem was that it degraded performance. I can probably come up with a fix to borrowck instead of trans that won't degrade performance. Just letting you know, @erickt , that the bug is still being worked on (I've been on leave so I didn't get to it sooner). |
…opes This eliminates an ICE in trans where the scope for a particular borrow was a statement ID, but the code in trans that does cleanups wasn't finding the block with that scope. As per rust-lang#3860 preserve looks at a node ID to see if it's for a statement -- if it is, it uses the enclosing scope instead when updating the map that trans looks at later.
…opes This eliminates an ICE in trans where the scope for a particular borrow was a statement ID, but the code in trans that does cleanups wasn't finding the block with that scope. As per #3860 preserve looks at a node ID to see if it's for a statement -- if it is, it uses the enclosing scope instead when updating the map that trans looks at later. I added a comment noting that this is not the best fix (since it may cause boxes to be frozen for longer than necessary) and referring to #3511. r=nmatsakis
Fixed in 9d67267 -- but see the comments in borrowck::preserve from that commit for a warning. |
When a method returns an &self/mut Foo, and the caller doesn't store the returned value somewhere, there's an internal compiler error. See the following code. Note how when storing the result of
x.stuff()
in a variable makes it work.The text was updated successfully, but these errors were encountered: