Basic compiler infra
This commit is contained in:
parent
5e6bb83268
commit
aa115eba12
7 changed files with 129 additions and 25 deletions
44
compiler/rustc_builtin_macros/src/assert/context.rs
Normal file
44
compiler/rustc_builtin_macros/src/assert/context.rs
Normal file
|
@ -0,0 +1,44 @@
|
|||
use rustc_ast::{ptr::P, Expr, Path};
|
||||
use rustc_expand::base::ExtCtxt;
|
||||
use rustc_span::Span;
|
||||
|
||||
pub(super) struct Context<'cx, 'a> {
|
||||
cx: &'cx ExtCtxt<'a>,
|
||||
span: Span,
|
||||
}
|
||||
|
||||
impl<'cx, 'a> Context<'cx, 'a> {
|
||||
pub(super) fn new(cx: &'cx ExtCtxt<'a>, span: Span) -> Self {
|
||||
Self { cx, span }
|
||||
}
|
||||
|
||||
/// Builds the whole `assert!` expression.
|
||||
///
|
||||
/// {
|
||||
/// use ::core::asserting::{ ... };
|
||||
///
|
||||
/// let mut __capture0 = Capture::new();
|
||||
/// ...
|
||||
/// ...
|
||||
/// ...
|
||||
///
|
||||
/// if !{
|
||||
/// ...
|
||||
/// ...
|
||||
/// ...
|
||||
/// } {
|
||||
/// panic!(
|
||||
/// "Assertion failed: ... \n With expansion: ...",
|
||||
/// __capture0,
|
||||
/// ...
|
||||
/// ...
|
||||
/// ...
|
||||
/// );
|
||||
/// }
|
||||
/// }
|
||||
pub(super) fn build(self, _cond_expr: P<Expr>, _panic_path: Path) -> P<Expr> {
|
||||
let Self { cx, span, .. } = self;
|
||||
let stmts = Vec::new();
|
||||
cx.expr_block(cx.block(span, stmts))
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue