-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #86645 - FabianWolff:issue-82328, r=LeSeulArtichaut
Fix ICE with `-Zunpretty=hir,typed` This PR fixes #82328. The `-Zunpretty=hir,typed` pretty-printer maintains an `Option` with type-checking results and sets the `Option` to `Some` when entering a body. However, this leads to an ICE if an expression occurs in a function signature (i.e. outside of a body), such as `128` in ```rust fn foo(-128..=127: i8) {} ``` This PR fixes the ICE by checking (if necessary) whether the expression's owner has a body, and retrieving type-checking results for that on the fly.
- Loading branch information
Showing
3 changed files
with
44 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Regression test for the ICE described in #82328. The pretty-printer for | ||
// `-Zunpretty=hir,typed` would previously retrieve type-checking results | ||
// when entering a body, which means that type information was not available | ||
// for expressions occurring in function signatures, as in the `foo` example | ||
// below, leading to an ICE. | ||
|
||
// check-pass | ||
// compile-flags: -Zunpretty=hir,typed | ||
#![allow(dead_code)] | ||
|
||
fn main() {} | ||
|
||
fn foo(-128..=127: i8) {} |
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 @@ | ||
// Regression test for the ICE described in #82328. The pretty-printer for | ||
// `-Zunpretty=hir,typed` would previously retrieve type-checking results | ||
// when entering a body, which means that type information was not available | ||
// for expressions occurring in function signatures, as in the `foo` example | ||
// below, leading to an ICE. | ||
|
||
// check-pass | ||
// compile-flags: -Zunpretty=hir,typed | ||
#![allow(dead_code)] | ||
#[prelude_import] | ||
use ::std::prelude::rust_2015::*; | ||
#[macro_use] | ||
extern crate std; | ||
|
||
fn main() ({ } as ()) | ||
|
||
fn foo((-(128 as i8) as i8) ...(127 as i8): i8) ({ } as ()) |