2021-01-05 18:53:07 +00:00
|
|
|
#![feature(associated_type_defaults)]
|
|
|
|
#![feature(bool_to_option)]
|
|
|
|
#![feature(box_patterns)]
|
|
|
|
#![feature(box_syntax)]
|
|
|
|
#![feature(const_panic)]
|
|
|
|
#![feature(exact_size_is_empty)]
|
|
|
|
#![feature(in_band_lifetimes)]
|
|
|
|
#![feature(iter_zip)]
|
|
|
|
#![feature(min_specialization)]
|
|
|
|
#![feature(once_cell)]
|
|
|
|
#![feature(stmt_expr_attributes)]
|
|
|
|
#![feature(trusted_step)]
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
extern crate tracing;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate rustc_middle;
|
|
|
|
|
2020-04-27 17:56:11 +00:00
|
|
|
use rustc_ast::{self as ast, MetaItem};
|
2020-03-29 15:19:48 +00:00
|
|
|
use rustc_middle::ty;
|
2020-07-30 01:27:50 +00:00
|
|
|
use rustc_session::Session;
|
2020-03-11 11:49:08 +00:00
|
|
|
use rustc_span::symbol::{sym, Symbol};
|
Revised mir-dataflow.
Incorporates many fixes contributed by arielb1.
----
revise borrowck::mir::dataflow code to allow varying domain for bitvectors.
This particular code implements the `BitDenotation` trait for three
analyses:
* `MovingOutStatements`, which, like `borrowck::move_data`, maps each
bit-index to a move instruction, and a 1 means "the effect of this
move reaches this point" (and the assigned l-value, if a scoped
declaration, is still in scope).
* `MaybeInitializedLvals`, which maps each bit-index to an l-value.
A 1 means "there exists a control flow path to this point that
initializes the associated l-value."
* `MaybeUninitializedLvals`, which maps each bit-index to an l-value
A 1 means "there exists a control flow path to this point that
de-initializes the associated l-value."
----
Revised `graphviz` dataflow-rendering support in `borrowck::mir`.
One big difference is that this code is now parameterized over the
`BitDenotation`, so that it can be used to render dataflow results
independent of how the dataflow bitvectors are interpreted; see where
reference to `MoveOut` is replaced by the type parameter `D`.
----
Factor out routine to query subattributes in `#[rustc_mir(..)]`.
(Later commits build upon this for some unit testing and instrumentation.)
----
thread through a tcx so that I can query types of lvalues as part of analysis.
----
Revised `BitDenotation::Ctxt`, allowing variation beyond `MoveData`.
The main motivation is to ease threading through a `TyCtxt`.
(In hindsight it might have been better to instead attach the `TyCtxt`
to each of the different dataflow implementations, but that would
require e.g. switching away from having a `Default` impl, so I am
leaving that experiment for another time.)
2016-05-02 13:50:27 +00:00
|
|
|
|
2021-01-01 00:53:25 +00:00
|
|
|
pub use self::drop_flag_effects::{
|
|
|
|
drop_flag_effects_for_function_entry, drop_flag_effects_for_location,
|
|
|
|
move_path_children_matching, on_all_children_bits, on_all_drop_children_bits,
|
|
|
|
on_lookup_result_bits,
|
|
|
|
};
|
2020-02-29 05:55:41 +00:00
|
|
|
pub use self::framework::{
|
2020-12-30 17:48:40 +00:00
|
|
|
fmt, lattice, visit_results, Analysis, AnalysisDomain, Backward, Direction, Engine, Forward,
|
|
|
|
GenKill, GenKillAnalysis, JoinSemiLattice, Results, ResultsCursor, ResultsRefCursor,
|
|
|
|
ResultsVisitable, ResultsVisitor,
|
2020-02-29 05:55:41 +00:00
|
|
|
};
|
2017-06-26 12:57:26 +00:00
|
|
|
|
2017-07-04 10:38:48 +00:00
|
|
|
use self::move_paths::MoveData;
|
|
|
|
|
2018-08-30 21:54:32 +00:00
|
|
|
pub mod drop_flag_effects;
|
2021-01-05 18:53:07 +00:00
|
|
|
pub mod elaborate_drops;
|
2020-03-02 17:43:18 +00:00
|
|
|
mod framework;
|
2020-05-04 19:50:36 +00:00
|
|
|
pub mod impls;
|
2017-06-26 12:57:26 +00:00
|
|
|
pub mod move_paths;
|
2021-01-05 18:53:07 +00:00
|
|
|
pub mod rustc_peek;
|
|
|
|
pub mod storage;
|
2017-06-26 12:57:26 +00:00
|
|
|
|
2019-04-01 18:38:00 +00:00
|
|
|
pub(crate) mod indexes {
|
2020-12-30 17:48:40 +00:00
|
|
|
pub(crate) use super::move_paths::MovePathIndex;
|
2019-04-01 18:38:00 +00:00
|
|
|
}
|
2017-06-26 12:57:26 +00:00
|
|
|
|
2020-02-29 05:47:36 +00:00
|
|
|
pub struct MoveDataParamEnv<'tcx> {
|
2020-12-30 17:48:40 +00:00
|
|
|
pub move_data: MoveData<'tcx>,
|
|
|
|
pub param_env: ty::ParamEnv<'tcx>,
|
2020-02-29 05:47:36 +00:00
|
|
|
}
|
|
|
|
|
2021-01-01 00:53:25 +00:00
|
|
|
pub fn has_rustc_mir_with(
|
2021-07-29 17:00:41 +00:00
|
|
|
_sess: &Session,
|
2020-07-30 01:27:50 +00:00
|
|
|
attrs: &[ast::Attribute],
|
|
|
|
name: Symbol,
|
|
|
|
) -> Option<MetaItem> {
|
2017-07-04 10:38:48 +00:00
|
|
|
for attr in attrs {
|
2021-07-29 17:00:41 +00:00
|
|
|
if attr.has_name(sym::rustc_mir) {
|
2017-07-04 10:38:48 +00:00
|
|
|
let items = attr.meta_item_list();
|
|
|
|
for item in items.iter().flat_map(|l| l.iter()) {
|
|
|
|
match item.meta_item() {
|
2020-08-02 10:17:20 +00:00
|
|
|
Some(mi) if mi.has_name(name) => return Some(mi.clone()),
|
2019-12-22 22:42:04 +00:00
|
|
|
_ => continue,
|
2017-07-04 10:38:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-20 14:03:11 +00:00
|
|
|
None
|
2017-07-04 10:38:48 +00:00
|
|
|
}
|