mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Decouple DummyAstNode
and DummyResult
.
They are two different ways of creating dummy results, with two different purposes. Their implementations are separate except for crates, where `DummyResult` depends on `DummyAstNode`. This commit removes that dependency, so they are now fully separate. It also expands the comment on `DummyAstNode`.
This commit is contained in:
parent
279c9ba260
commit
b5d7da878f
@ -1604,7 +1604,10 @@ pub fn noop_visit_capture_by<T: MutVisitor>(capture_by: &mut CaptureBy, vis: &mu
|
||||
}
|
||||
}
|
||||
|
||||
/// Some value for the AST node that is valid but possibly meaningless.
|
||||
/// Some value for the AST node that is valid but possibly meaningless. Similar
|
||||
/// to `Default` but not intended for wide use. The value will never be used
|
||||
/// meaningfully, it exists just to support unwinding in `visit_clobber` in the
|
||||
/// case where its closure panics.
|
||||
pub trait DummyAstNode {
|
||||
fn dummy() -> Self;
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ use crate::expand::{self, AstFragment, Invocation};
|
||||
use crate::module::DirOwnership;
|
||||
|
||||
use rustc_ast::attr::MarkedAttrs;
|
||||
use rustc_ast::mut_visit::DummyAstNode;
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::token::{self, Nonterminal};
|
||||
use rustc_ast::tokenstream::TokenStream;
|
||||
@ -582,6 +581,17 @@ impl DummyResult {
|
||||
tokens: None,
|
||||
})
|
||||
}
|
||||
|
||||
/// A plain dummy crate.
|
||||
pub fn raw_crate() -> ast::Crate {
|
||||
ast::Crate {
|
||||
attrs: Default::default(),
|
||||
items: Default::default(),
|
||||
spans: Default::default(),
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
is_placeholder: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MacResult for DummyResult {
|
||||
@ -650,7 +660,7 @@ impl MacResult for DummyResult {
|
||||
}
|
||||
|
||||
fn make_crate(self: Box<DummyResult>) -> Option<ast::Crate> {
|
||||
Some(DummyAstNode::dummy())
|
||||
Some(DummyResult::raw_crate())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user