mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-02 09:47:57 +00:00
Include enclosing item's context on const errors
On const errors, when they occur on an item that might be relevant, like in an associated const, render the line of the enclosing item in the error:
```
error[E0080]: evaluation panicked: not yet implemented
--> $DIR/ice-normalize-inherent-assoc-const.rs:10:28
|
LL | impl Foo {
LL | const ASSOC_C: usize = todo!();
| ^^^^^^^ evaluation of `Foo::ASSOC_C` failed here
```
```
error[E0080]: writing to ALLOC$ID which is read-only
--> $DIR/issue-100313.rs:18:5
|
LL | const _: () = {
LL | let x = T::<{ &true }>;
LL | x.set_false();
| ^^^^^^^^^^^^^ evaluation of `_` failed inside this call
|
note: inside `T::<&true>::set_false`
--> $DIR/issue-100313.rs:11:13
|
LL | impl<const B: &'static bool> T<B> {
LL | const fn set_false(&self) {
LL | unsafe {
LL | *(B as *const bool as *mut bool) = false;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here
```