Migrate some rustc_builtin_macros to SessionDiagnostic
Signed-off-by: he1pa <18012015693@163.com>
This commit is contained in:
parent
3d5d7a24f7
commit
a82f70eeee
5 changed files with 76 additions and 23 deletions
|
@ -214,12 +214,12 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
|
|||
};
|
||||
|
||||
if !is_fn {
|
||||
let msg = format!(
|
||||
"the `#[{}]` attribute may only be used on bare functions",
|
||||
pprust::path_to_string(&attr.get_normal_item().path),
|
||||
);
|
||||
|
||||
self.dcx.span_err(attr.span, msg);
|
||||
self.dcx
|
||||
.create_err(errors::AttributeOnlyBeUsedOnBareFunctions {
|
||||
span: attr.span,
|
||||
path: &pprust::path_to_string(&attr.get_normal_item().path),
|
||||
})
|
||||
.emit();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -228,12 +228,12 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
|
|||
}
|
||||
|
||||
if !self.is_proc_macro_crate {
|
||||
let msg = format!(
|
||||
"the `#[{}]` attribute is only usable with crates of the `proc-macro` crate type",
|
||||
pprust::path_to_string(&attr.get_normal_item().path),
|
||||
);
|
||||
|
||||
self.dcx.span_err(attr.span, msg);
|
||||
self.dcx
|
||||
.create_err(errors::AttributeOnlyUsableWithCrateType {
|
||||
span: attr.span,
|
||||
path: &pprust::path_to_string(&attr.get_normal_item().path),
|
||||
})
|
||||
.emit();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue