Rollup merge of #121829 - nnethercote:dummy-tweaks-2, r=petrochenkov
Dummy tweaks (attempt 2) r? `````@petrochenkov`````
This commit is contained in:
commit
0783a63d34
@ -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 {
|
pub trait DummyAstNode {
|
||||||
fn dummy() -> Self;
|
fn dummy() -> Self;
|
||||||
}
|
}
|
||||||
@ -1679,19 +1682,6 @@ impl DummyAstNode for Stmt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DummyAstNode for Block {
|
|
||||||
fn dummy() -> Self {
|
|
||||||
Block {
|
|
||||||
stmts: Default::default(),
|
|
||||||
id: DUMMY_NODE_ID,
|
|
||||||
rules: BlockCheckMode::Default,
|
|
||||||
span: Default::default(),
|
|
||||||
tokens: Default::default(),
|
|
||||||
could_be_bare_literal: Default::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DummyAstNode for Crate {
|
impl DummyAstNode for Crate {
|
||||||
fn dummy() -> Self {
|
fn dummy() -> Self {
|
||||||
Crate {
|
Crate {
|
||||||
|
@ -4,7 +4,6 @@ use crate::expand::{self, AstFragment, Invocation};
|
|||||||
use crate::module::DirOwnership;
|
use crate::module::DirOwnership;
|
||||||
|
|
||||||
use rustc_ast::attr::MarkedAttrs;
|
use rustc_ast::attr::MarkedAttrs;
|
||||||
use rustc_ast::mut_visit::DummyAstNode;
|
|
||||||
use rustc_ast::ptr::P;
|
use rustc_ast::ptr::P;
|
||||||
use rustc_ast::token::{self, Nonterminal};
|
use rustc_ast::token::{self, Nonterminal};
|
||||||
use rustc_ast::tokenstream::TokenStream;
|
use rustc_ast::tokenstream::TokenStream;
|
||||||
@ -582,6 +581,17 @@ impl DummyResult {
|
|||||||
tokens: None,
|
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 {
|
impl MacResult for DummyResult {
|
||||||
@ -650,7 +660,7 @@ impl MacResult for DummyResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn make_crate(self: Box<DummyResult>) -> Option<ast::Crate> {
|
fn make_crate(self: Box<DummyResult>) -> Option<ast::Crate> {
|
||||||
Some(DummyAstNode::dummy())
|
Some(DummyResult::raw_crate())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user