Skip to content

Commit 833312b

Browse files
authored
Rollup merge of rust-lang#89023 - Wardenfar:issue-85066, r=nagisa
Resolve issue 85066 Fixes rust-lang#85066
2 parents c58c4b0 + 59d5eb2 commit 833312b

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,6 +1563,20 @@ impl<'a> Parser<'a> {
15631563

15641564
pub(super) fn parse_lit(&mut self) -> PResult<'a, Lit> {
15651565
self.parse_opt_lit().ok_or_else(|| {
1566+
if let token::Interpolated(inner) = &self.token.kind {
1567+
let expr = match inner.as_ref() {
1568+
token::NtExpr(expr) => Some(expr),
1569+
token::NtLiteral(expr) => Some(expr),
1570+
_ => None,
1571+
};
1572+
if let Some(expr) = expr {
1573+
if matches!(expr.kind, ExprKind::Err) {
1574+
self.diagnostic()
1575+
.delay_span_bug(self.token.span, &"invalid interpolated expression");
1576+
return self.diagnostic().struct_dummy();
1577+
}
1578+
}
1579+
}
15661580
let msg = format!("unexpected token: {}", super::token_descr(&self.token));
15671581
self.struct_span_err(self.token.span, &msg)
15681582
})
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#![feature(extended_key_value_attributes)]
2+
#![doc = include_str!("../not_existing_file.md")]
3+
struct Documented {}
4+
//~^^ ERROR No such file or directory
5+
6+
fn main() {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: couldn't read $DIR/../not_existing_file.md: No such file or directory (os error 2)
2+
--> $DIR/extented-attribute-macro-error.rs:2:10
3+
|
4+
LL | #![doc = include_str!("../not_existing_file.md")]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info)
8+
9+
error: aborting due to previous error
10+

0 commit comments

Comments
 (0)