Compilation Exhausts Memory Instead of Detecting Potential Syntax Error #117080
Closed
Description
I tried this code():
trait Mul<T> {
type Output;
}
trait Matrix: Mul<<Self as Matrix>::Row, Output = ()> {
type Row;
type Transpose: Matrix<Row = Self::Row>;
}
fn is_mul<S, T: Mul<S, Output = ()>>() {}
fn f<T: Matrix>() {
is_mul::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<>();
}
I expected to see this happen: the compiler to recognize a potential syntax error and provide an error report.
Instead, this happened: the compiler consumes all available memory and exits.
This code contains obvious syntax errors, so it doesn't seem reasonable for it to be compiled for a long time.
Meta
rustc --version --verbose
:
commit-hash: 1c05d50c8403c56d9a8b6fb871f15aaa26fb5d07
commit-date: 2023-10-21
host: x86_64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.3
The same problem is reproduced on the stable version(1.73 cc66ad4 2023-10-03)
Backtrace
<backtrace>
Metadata
Assignees
Labels
Area: The parsing of Rust source code to an ASTCategory: This is a bug.Issue: Problems and improvements with respect to memory usage during compilation.Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.Relevant to the compiler team, which will review and decide on the PR/issue.
Activity