mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 02:03:53 +00:00
Use AllFacts from polonius-engine
This commit is contained in:
parent
07465222ca
commit
8429d11a0b
@ -1424,6 +1424,11 @@ name = "pkg-config"
|
|||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "polonius-engine"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "precomputed-hash"
|
name = "precomputed-hash"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
@ -1745,6 +1750,7 @@ dependencies = [
|
|||||||
"jobserver 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"jobserver 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"polonius-engine 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"proc_macro 0.0.0",
|
"proc_macro 0.0.0",
|
||||||
"rustc_apfloat 0.0.0",
|
"rustc_apfloat 0.0.0",
|
||||||
"rustc_data_structures 0.0.0",
|
"rustc_data_structures 0.0.0",
|
||||||
@ -2111,6 +2117,7 @@ dependencies = [
|
|||||||
"graphviz 0.0.0",
|
"graphviz 0.0.0",
|
||||||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log_settings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log_settings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"polonius-engine 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc 0.0.0",
|
"rustc 0.0.0",
|
||||||
"rustc_apfloat 0.0.0",
|
"rustc_apfloat 0.0.0",
|
||||||
"rustc_data_structures 0.0.0",
|
"rustc_data_structures 0.0.0",
|
||||||
@ -3107,6 +3114,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
"checksum phf_generator 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6b07ffcc532ccc85e3afc45865469bf5d9e4ef5bfcf9622e3cfe80c2d275ec03"
|
"checksum phf_generator 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6b07ffcc532ccc85e3afc45865469bf5d9e4ef5bfcf9622e3cfe80c2d275ec03"
|
||||||
"checksum phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "07e24b0ca9643bdecd0632f2b3da6b1b89bbb0030e0b992afc1113b23a7bc2f2"
|
"checksum phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "07e24b0ca9643bdecd0632f2b3da6b1b89bbb0030e0b992afc1113b23a7bc2f2"
|
||||||
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
|
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
|
||||||
|
"checksum polonius-engine 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6201ffe79e3da53bd065fbec2a9b391e5a0dc21038b39bb300612ddc658eb7ee"
|
||||||
"checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
|
"checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
|
||||||
"checksum pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a029430f0d744bc3d15dd474d591bed2402b645d024583082b9f63bb936dac6"
|
"checksum pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a029430f0d744bc3d15dd474d591bed2402b645d024583082b9f63bb936dac6"
|
||||||
"checksum proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "49b6a521dc81b643e9a51e0d1cf05df46d5a2f3c0280ea72bcb68276ba64a118"
|
"checksum proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "49b6a521dc81b643e9a51e0d1cf05df46d5a2f3c0280ea72bcb68276ba64a118"
|
||||||
|
@ -16,6 +16,7 @@ graphviz = { path = "../libgraphviz" }
|
|||||||
jobserver = "0.1"
|
jobserver = "0.1"
|
||||||
lazy_static = "1.0.0"
|
lazy_static = "1.0.0"
|
||||||
log = { version = "0.4", features = ["release_max_level_info", "std"] }
|
log = { version = "0.4", features = ["release_max_level_info", "std"] }
|
||||||
|
polonius-engine = "0.1.1"
|
||||||
proc_macro = { path = "../libproc_macro" }
|
proc_macro = { path = "../libproc_macro" }
|
||||||
rustc_apfloat = { path = "../librustc_apfloat" }
|
rustc_apfloat = { path = "../librustc_apfloat" }
|
||||||
rustc_target = { path = "../librustc_target" }
|
rustc_target = { path = "../librustc_target" }
|
||||||
|
@ -80,6 +80,7 @@ extern crate graphviz;
|
|||||||
#[macro_use] extern crate lazy_static;
|
#[macro_use] extern crate lazy_static;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
extern crate polonius_engine;
|
||||||
extern crate rustc_target;
|
extern crate rustc_target;
|
||||||
#[macro_use] extern crate rustc_data_structures;
|
#[macro_use] extern crate rustc_data_structures;
|
||||||
extern crate serialize;
|
extern crate serialize;
|
||||||
|
@ -14,6 +14,7 @@ use hir::def_id::DefId;
|
|||||||
|
|
||||||
use middle::const_val::ConstVal;
|
use middle::const_val::ConstVal;
|
||||||
use middle::region;
|
use middle::region;
|
||||||
|
use polonius_engine::Atom;
|
||||||
use rustc_data_structures::indexed_vec::Idx;
|
use rustc_data_structures::indexed_vec::Idx;
|
||||||
use ty::subst::{Substs, Subst, Kind, UnpackedKind};
|
use ty::subst::{Substs, Subst, Kind, UnpackedKind};
|
||||||
use ty::{self, AdtDef, TypeFlags, Ty, TyCtxt, TypeFoldable};
|
use ty::{self, AdtDef, TypeFlags, Ty, TyCtxt, TypeFoldable};
|
||||||
@ -1169,6 +1170,24 @@ newtype_index!(RegionVid
|
|||||||
DEBUG_FORMAT = custom,
|
DEBUG_FORMAT = custom,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
impl Atom for RegionVid {
|
||||||
|
fn index(self) -> usize {
|
||||||
|
Idx::index(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<usize> for RegionVid {
|
||||||
|
fn from(i: usize) -> RegionVid {
|
||||||
|
RegionVid::new(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<RegionVid> for usize {
|
||||||
|
fn from(vid: RegionVid) -> usize {
|
||||||
|
Idx::index(vid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
|
||||||
pub enum InferTy {
|
pub enum InferTy {
|
||||||
TyVar(TyVid),
|
TyVar(TyVid),
|
||||||
|
@ -14,6 +14,7 @@ bitflags = "1.0"
|
|||||||
graphviz = { path = "../libgraphviz" }
|
graphviz = { path = "../libgraphviz" }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
log_settings = "0.1.1"
|
log_settings = "0.1.1"
|
||||||
|
polonius-engine = "0.1.1"
|
||||||
rustc = { path = "../librustc" }
|
rustc = { path = "../librustc" }
|
||||||
rustc_target = { path = "../librustc_target" }
|
rustc_target = { path = "../librustc_target" }
|
||||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||||
|
@ -10,41 +10,28 @@
|
|||||||
|
|
||||||
use borrow_check::location::{LocationIndex, LocationTable};
|
use borrow_check::location::{LocationIndex, LocationTable};
|
||||||
use dataflow::indexes::BorrowIndex;
|
use dataflow::indexes::BorrowIndex;
|
||||||
|
use polonius_engine::AllFacts as PoloniusAllFacts;
|
||||||
|
use polonius_engine::Atom;
|
||||||
use rustc::ty::RegionVid;
|
use rustc::ty::RegionVid;
|
||||||
|
use rustc_data_structures::indexed_vec::Idx;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
/// The "facts" which are the basis of the NLL borrow analysis.
|
crate type AllFacts = PoloniusAllFacts<RegionVid, BorrowIndex, LocationIndex>;
|
||||||
#[derive(Default)]
|
|
||||||
crate struct AllFacts {
|
|
||||||
// `borrow_region(R, B, P)` -- the region R may refer to data from borrow B
|
|
||||||
// starting at the point P (this is usually the point *after* a borrow rvalue)
|
|
||||||
crate borrow_region: Vec<(RegionVid, BorrowIndex, LocationIndex)>,
|
|
||||||
|
|
||||||
// universal_region(R) -- this is a "free region" within fn body
|
crate trait AllFactsExt {
|
||||||
crate universal_region: Vec<RegionVid>,
|
fn write_to_dir(
|
||||||
|
&self,
|
||||||
// `cfg_edge(P,Q)` for each edge P -> Q in the control flow
|
dir: impl AsRef<Path>,
|
||||||
crate cfg_edge: Vec<(LocationIndex, LocationIndex)>,
|
location_table: &LocationTable,
|
||||||
|
) -> Result<(), Box<dyn Error>>;
|
||||||
// `killed(B,P)` when some prefix of the path borrowed at B is assigned at point P
|
|
||||||
crate killed: Vec<(BorrowIndex, LocationIndex)>,
|
|
||||||
|
|
||||||
// `outlives(R1, R2, P)` when we require `R1@P: R2@P`
|
|
||||||
crate outlives: Vec<(RegionVid, RegionVid, LocationIndex)>,
|
|
||||||
|
|
||||||
// `region_live_at(R, P)` when the region R appears in a live variable at P
|
|
||||||
crate region_live_at: Vec<(RegionVid, LocationIndex)>,
|
|
||||||
|
|
||||||
// `invalidates(P, B)` when the borrow B is invalidated at point P
|
|
||||||
crate invalidates: Vec<(LocationIndex, BorrowIndex)>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AllFacts {
|
impl AllFactsExt for AllFacts {
|
||||||
crate fn write_to_dir(
|
fn write_to_dir(
|
||||||
&self,
|
&self,
|
||||||
dir: impl AsRef<Path>,
|
dir: impl AsRef<Path>,
|
||||||
location_table: &LocationTable,
|
location_table: &LocationTable,
|
||||||
@ -79,6 +66,42 @@ impl AllFacts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Atom for BorrowIndex {
|
||||||
|
fn index(self) -> usize {
|
||||||
|
Idx::index(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<usize> for BorrowIndex {
|
||||||
|
fn from(i: usize) -> BorrowIndex {
|
||||||
|
BorrowIndex::new(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<BorrowIndex> for usize {
|
||||||
|
fn from(vid: BorrowIndex) -> usize {
|
||||||
|
Idx::index(vid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Atom for LocationIndex {
|
||||||
|
fn index(self) -> usize {
|
||||||
|
Idx::index(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<usize> for LocationIndex {
|
||||||
|
fn from(i: usize) -> LocationIndex {
|
||||||
|
LocationIndex::new(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<LocationIndex> for usize {
|
||||||
|
fn from(vid: LocationIndex) -> usize {
|
||||||
|
Idx::index(vid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct FactWriter<'w> {
|
struct FactWriter<'w> {
|
||||||
location_table: &'w LocationTable,
|
location_table: &'w LocationTable,
|
||||||
dir: &'w Path,
|
dir: &'w Path,
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
use borrow_check::borrow_set::BorrowSet;
|
use borrow_check::borrow_set::BorrowSet;
|
||||||
use borrow_check::location::LocationTable;
|
use borrow_check::location::LocationTable;
|
||||||
|
use borrow_check::nll::facts::AllFactsExt;
|
||||||
use dataflow::move_paths::MoveData;
|
use dataflow::move_paths::MoveData;
|
||||||
use dataflow::FlowAtLocation;
|
use dataflow::FlowAtLocation;
|
||||||
use dataflow::MaybeInitializedPlaces;
|
use dataflow::MaybeInitializedPlaces;
|
||||||
|
@ -34,7 +34,7 @@ pub(crate) mod indexes {
|
|||||||
|
|
||||||
macro_rules! new_index {
|
macro_rules! new_index {
|
||||||
($Index:ident, $debug_name:expr) => {
|
($Index:ident, $debug_name:expr) => {
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||||
pub struct $Index(NonZeroUsize);
|
pub struct $Index(NonZeroUsize);
|
||||||
|
|
||||||
impl Idx for $Index {
|
impl Idx for $Index {
|
||||||
|
@ -39,6 +39,7 @@ extern crate arena;
|
|||||||
extern crate bitflags;
|
extern crate bitflags;
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
extern crate graphviz as dot;
|
extern crate graphviz as dot;
|
||||||
|
extern crate polonius_engine;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rustc;
|
extern crate rustc;
|
||||||
#[macro_use] extern crate rustc_data_structures;
|
#[macro_use] extern crate rustc_data_structures;
|
||||||
|
@ -94,6 +94,7 @@ static WHITELIST: &'static [Crate] = &[
|
|||||||
Crate("owning_ref"),
|
Crate("owning_ref"),
|
||||||
Crate("parking_lot"),
|
Crate("parking_lot"),
|
||||||
Crate("parking_lot_core"),
|
Crate("parking_lot_core"),
|
||||||
|
Crate("polonius-engine"),
|
||||||
Crate("quick-error"),
|
Crate("quick-error"),
|
||||||
Crate("rand"),
|
Crate("rand"),
|
||||||
Crate("redox_syscall"),
|
Crate("redox_syscall"),
|
||||||
|
Loading…
Reference in New Issue
Block a user