Suggest using integration tests for proc-macros
This commit is contained in:
parent
0d7ed3ba84
commit
f7581d8d21
5 changed files with 43 additions and 5 deletions
|
@ -508,3 +508,12 @@ pub(crate) struct RemoveSurroundingDerive {
|
|||
pub(crate) struct AddAsNonDerive<'a> {
|
||||
pub(crate) macro_path: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(resolve_proc_macro_same_crate)]
|
||||
pub(crate) struct ProcMacroSameCrate {
|
||||
#[primary_span]
|
||||
pub(crate) span: Span,
|
||||
#[help]
|
||||
pub(crate) is_test: bool,
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! A bunch of methods and structures more or less related to resolving macros and
|
||||
//! interface provided by `Resolver` to macro expander.
|
||||
|
||||
use crate::errors::{AddAsNonDerive, MacroExpectedFound, RemoveSurroundingDerive};
|
||||
use crate::errors::{self, AddAsNonDerive, MacroExpectedFound, RemoveSurroundingDerive};
|
||||
use crate::Namespace::*;
|
||||
use crate::{BuiltinMacroState, Determinacy};
|
||||
use crate::{DeriveData, Finalize, ParentScope, ResolutionError, Resolver, ScopeSet};
|
||||
|
@ -513,10 +513,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
if let Some(def_id) = def_id.as_local() {
|
||||
self.unused_macros.remove(&def_id);
|
||||
if self.proc_macro_stubs.contains(&def_id) {
|
||||
self.tcx.sess.span_err(
|
||||
path.span,
|
||||
"can't use a procedural macro from the same crate that defines it",
|
||||
);
|
||||
self.tcx.sess.emit_err(errors::ProcMacroSameCrate {
|
||||
span: path.span,
|
||||
is_test: self.tcx.sess.is_test_crate(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue