initial working state
This commit is contained in:
parent
2c69266c06
commit
d327fa112b
8 changed files with 313 additions and 13 deletions
15
compiler/rustc_middle/src/mir/abstract_const.rs
Normal file
15
compiler/rustc_middle/src/mir/abstract_const.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
//! A subset of a mir body used for const evaluatability checking.
|
||||
use crate::mir;
|
||||
use crate::ty;
|
||||
|
||||
/// An index into an `AbstractConst`.
|
||||
pub type NodeId = usize;
|
||||
|
||||
/// A node of an `AbstractConst`.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, HashStable)]
|
||||
pub enum Node<'tcx> {
|
||||
Leaf(&'tcx ty::Const<'tcx>),
|
||||
Binop(mir::BinOp, NodeId, NodeId),
|
||||
UnaryOp(mir::UnOp, NodeId),
|
||||
FunctionCall(NodeId, &'tcx [NodeId]),
|
||||
}
|
|
@ -40,6 +40,7 @@ use std::{iter, mem, option};
|
|||
use self::predecessors::{PredecessorCache, Predecessors};
|
||||
pub use self::query::*;
|
||||
|
||||
pub mod abstract_const;
|
||||
pub mod coverage;
|
||||
pub mod interpret;
|
||||
pub mod mono;
|
||||
|
|
|
@ -244,6 +244,25 @@ rustc_queries! {
|
|||
no_hash
|
||||
}
|
||||
|
||||
/// Try to build an abstract representation of the given constant.
|
||||
query mir_abstract_const(
|
||||
key: DefId
|
||||
) -> Option<&'tcx [mir::abstract_const::Node<'tcx>]> {
|
||||
desc {
|
||||
|tcx| "building an abstract representation for {}", tcx.def_path_str(key),
|
||||
}
|
||||
}
|
||||
/// Try to build an abstract representation of the given constant.
|
||||
query mir_abstract_const_of_const_arg(
|
||||
key: (LocalDefId, DefId)
|
||||
) -> Option<&'tcx [mir::abstract_const::Node<'tcx>]> {
|
||||
desc {
|
||||
|tcx|
|
||||
"building an abstract representation for the const argument {}",
|
||||
tcx.def_path_str(key.0.to_def_id()),
|
||||
}
|
||||
}
|
||||
|
||||
query mir_drops_elaborated_and_const_checked(
|
||||
key: ty::WithOptConstParam<LocalDefId>
|
||||
) -> &'tcx Steal<mir::Body<'tcx>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue