-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-compilememIssue: Problems and improvements with respect to memory usage during compilation.Issue: Problems and improvements with respect to memory usage during compilation.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Description
Hi
Incorrectly closing the parentheses around an if expression causes the compiler to be stuck in endless recursion (probably), causing the computer to run out of memory.
I encountered this bug while trying to return Some(if cond { ... } else { ... })
from a function by accidentally placing the left parenthesis right after the if condition: Some(if ...) { } else { }
.
The code below is the minimal example I came up with that reproduces the bug. Please run it carefully since it rapidly consumes RAM (2 GB/s on my machine).
// t.rs
fn main() {
(if true)
}
Compiler output:
$ rustc t.rs
error: expected `{`, found `)`
--> t.rs:2:13
|
2 | (if true)
| -- ^ expected `{`
| |
| this `if` statement has a condition, but no block
error: expected expression, found `<eof>`
--> t.rs:3:1
|
3 | }
| ^ expected expression # at this point the compiler is stuck
^C
Meta
The bug is present in both available for me compilers:
$ rustc --version --verbose
rustc 1.37.0-nightly (7840a0b75 2019-05-31)
binary: rustc
commit-hash: 7840a0b753a065a41999f1fb6028f67d33e3fdd5
commit-date: 2019-05-31
host: x86_64-unknown-linux-gnu
release: 1.37.0-nightly
LLVM version: 8.0
and
$ rustc --version --verbose
rustc 1.35.0 (3c235d560 2019-05-20)
binary: rustc
commit-hash: 3c235d5600393dfe6c36eeed34042efad8d4f26e
commit-date: 2019-05-20
host: x86_64-unknown-linux-gnu
release: 1.35.0
LLVM version: 8.0
My OS is Arch Linux 5.1.11-arch1-1-ARCH
.
Stargateur and estebank
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-compilememIssue: Problems and improvements with respect to memory usage during compilation.Issue: Problems and improvements with respect to memory usage during compilation.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.