forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid unbounded O(n^2) when parsing nested type args
When encountering code like `f::<f::<f::<f::<f::<f::<f::<f::<...` with unmatched closing angle brackets, add a linear check that avoids the exponential behavior of the parse recovery mechanism. Fix rust-lang#117080.
- Loading branch information
Showing
4 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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::<>(); | ||
//~^ ERROR expected one of `!`, `+`, `,`, `::`, or `>`, found `(` | ||
} | ||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error: expected one of `!`, `+`, `,`, `::`, or `>`, found `(` | ||
--> $DIR/deep-unmatched-angle-brackets.rs:14:63 | ||
| | ||
LL | <f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<>(); | ||
| ^ expected one of `!`, `+`, `,`, `::`, or `>` | ||
| | ||
help: you might have meant to end the type parameters here | ||
| | ||
LL | <f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<f::<>>(); | ||
| + | ||
|
||
error: aborting due to previous error | ||
|