1
Fork 0

Migrate some rustc_builtin_macros to SessionDiagnostic

Signed-off-by: he1pa <18012015693@163.com>
This commit is contained in:
he1pa 2024-06-25 18:04:21 +08:00
parent 3d5d7a24f7
commit a82f70eeee
5 changed files with 76 additions and 23 deletions

View file

@ -1,3 +1,4 @@
use crate::errors;
use crate::util::{
check_zero_tts, get_single_str_from_tts, get_single_str_spanned_from_tts, parse_expr,
};
@ -165,9 +166,13 @@ pub(crate) fn expand_include<'cx>(
Ok(Some(item)) => ret.push(item),
Ok(None) => {
if self.p.token != token::Eof {
let token = pprust::token_to_string(&self.p.token);
let msg = format!("expected item, found `{token}`");
self.p.dcx().span_err(self.p.token.span, msg);
self.p
.dcx()
.create_err(errors::ExpectedItem {
span: self.p.token.span,
token: &pprust::token_to_string(&self.p.token),
})
.emit();
}
break;