-
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
ICE with NLL #46628
Comments
Thanks for the report! |
FYI here is a version that doesn't rely on reading from stdin (and thus may serve as a better basis for a unit test when this is fixed): use std::io::*;
fn main() {
let in_buf: &[u8] = b"a\nb\nc";
let mut reader = BufReader::with_capacity(2, in_buf);
let elem = first_line(&mut reader);
assert_eq!(elem, "a");
}
fn first_line<R: Read>(reader: &mut BufReader<R>) -> String {
let elem = reader.lines().next().unwrap().unwrap();
elem
} (I factored it into two methods because the error here is arising from |
Works on nll-master (i.e., the code found here #46862). |
However, the error message on the original example is not quite what I had hoped for:
gives
|
Thanks for the fix! I confirm that the ICE has disappeared in nightly. Should we close the issue? (Or keep it open for the weird.rs case since I would expect this example to type-check?) |
Oh, that's an ICE when the code executes. The example that @pnkfelix gave compiles successfully. |
@ia0 the code now type-checks and executes, so I'm going to close the issue. |
Yes, in the playground stdin seems to be empty, so the first unwrap is wrong (there are no lines to read). Thanks again for the work on this! |
I tried this code (in a file named
ice.rs
):I expected
RUST_BACKTRACE=1 rustc -Z nll ice.rs
to succeed. Instead, I got the following error:My output of
rustc --version --verbose
is:Probably related context
I tried the following example (in a file named
weird.rs
):I expected
rustc -Z borrowck=compare weird.rs
to succeed. Instead, I got the following error:I tried to understand why the borrow checker does not understand that the lock is dropped before the temporary is dropped. So I wrote the following example (in a file named
test.rs
):I expected
rustc -Z borrowck=compare test.rs
to succeed for all versions. Instead, only the last 2 versions succeeded. The first 3 versions failed. Notice how the 3rd and 4th versions just differ by assigning the result value into a variable.Then, I stepped on #21114 and considered using NLL and discovered that
rustc -Z nll -Z borrowck=compare test.rs
only fails for AST and not for MIR for the first 3 versions. It still succeeds for the last 2 versions. In particular, for the first 3 versions,rustc -Z nll -Z borrowck=mir test.rs
succeeds whilerustc -Z nll -Z borrowck=ast test.rs
fails.The text was updated successfully, but these errors were encountered: