Skip to content

Commit 250a3e4

Browse files
committed
Resolve issue 85066
Fix : use struct_dummy Fix different os messages
1 parent 2b5ddf3 commit 250a3e4

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

compiler/rustc_parse/src/parser/expr.rs

+14
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,20 @@ impl<'a> Parser<'a> {
14931493

14941494
pub(super) fn parse_lit(&mut self) -> PResult<'a, Lit> {
14951495
self.parse_opt_lit().ok_or_else(|| {
1496+
if let token::Interpolated(inner) = &self.token.kind {
1497+
let expr = match inner.as_ref() {
1498+
token::NtExpr(expr) => Some(expr),
1499+
token::NtLiteral(expr) => Some(expr),
1500+
_ => None,
1501+
};
1502+
if let Some(expr) = expr {
1503+
if matches!(expr.kind, ExprKind::Err) {
1504+
self.diagnostic()
1505+
.delay_span_bug(self.token.span, &"invalid interpolated expression");
1506+
return self.diagnostic().struct_dummy();
1507+
}
1508+
}
1509+
}
14961510
let msg = format!("unexpected token: {}", super::token_descr(&self.token));
14971511
self.struct_span_err(self.token.span, &msg)
14981512
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// normalize-stderr-test: "couldn't read.*" -> "couldn't read the file"
2+
3+
#![feature(extended_key_value_attributes)]
4+
#![doc = include_str!("../not_existing_file.md")]
5+
struct Documented {}
6+
//~^^ ERROR couldn't read
7+
8+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: couldn't read the file
2+
--> $DIR/extented-attribute-macro-error.rs:4: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)