-
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.
Do not ICE on field access check on expr with
ty::Error
Fix #123428
- Loading branch information
Showing
3 changed files
with
51 additions
and
1 deletion.
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,27 @@ | ||
use std::mem; | ||
|
||
trait Foo { | ||
fn foo(&self) -> usize; | ||
} | ||
impl<T> Foo for T { | ||
fn foo(&self) -> usize { | ||
mem::size_of::<T>() | ||
} | ||
} | ||
|
||
fn main_ref() { | ||
let array = [(); { | ||
let mut n = 0; | ||
while n < 5 {} //~ ERROR constant evaluation is taking a long time | ||
0 | ||
}]; | ||
|
||
let u8_ = (7, 1u8); | ||
let u32_ = (4u32, 5u32); | ||
|
||
let buf: &mut [*const dyn Foo] = &mut [&u8_, &u8_.0, &u32_, &u32_.0]; | ||
} | ||
|
||
fn main() { | ||
main_ref(); | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/ui/consts/do-not-ice-on-field-access-of-err-type.stderr
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,22 @@ | ||
error: constant evaluation is taking a long time | ||
--> $DIR/do-not-ice-on-field-access-of-err-type.rs:15:9 | ||
| | ||
LL | while n < 5 {} | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. | ||
If your compilation actually takes a long time, you can safely allow the lint. | ||
help: the constant being evaluated | ||
--> $DIR/do-not-ice-on-field-access-of-err-type.rs:13:22 | ||
| | ||
LL | let array = [(); { | ||
| ______________________^ | ||
LL | | let mut n = 0; | ||
LL | | while n < 5 {} | ||
LL | | 0 | ||
LL | | }]; | ||
| |_____^ | ||
= note: `#[deny(long_running_const_eval)]` on by default | ||
|
||
error: aborting due to 1 previous error | ||
|