Closed
Description
Code
Note that ../README.md
must not exist in order to reproduce this error:
#![feature(extended_key_value_attributes)]
#![doc = include_str!("../README.md")]
Output
The first error is what I would expect, but the second is a bit confusing and weird:
error: couldn't read src/../README.md: No such file or directory (os error 2)
--> src/lib.rs:2:10
|
2 | #![doc = include_str!("../README.md")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: unexpected token: `(/*ERROR*/)`
--> src/lib.rs:2:10
|
2 | #![doc = include_str!("../README.md")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
Perhaps instead of emitting unexpected token: `(/*ERROR*/)`
when an error token is encountered, we could use a delay_span_bug
since an error should have already occurred.
If for some reason an error had not already been emitted, the compiler would crash; otherwise, it would just show the original error.
Originally posted by @camelid in #83366 (comment)
Metadata
Metadata
Assignees
Labels
Area: Attributes (`#[…]`, `#![…]`)Area: Messages for errors, warnings, and lintsArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Category: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint that should be reworked.Diagnostics: Too much output caused by a single piece of incorrect code.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.`#![feature(extended_key_value_attributes)]Relevant to the compiler team, which will review and decide on the PR/issue.