Skip to content

Commit

Permalink
Update to latest rustc_plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
willcrichton committed Aug 26, 2023
1 parent 6fa1606 commit 093cf05
Show file tree
Hide file tree
Showing 18 changed files with 43 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2023-04-12
toolchain: nightly-2023-08-25
components: rust-src, rustc-dev, llvm-tools-preview
target: ${{ matrix.target }}
profile: minimal
Expand Down
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
[workspace]
members = ["crates/*"]
exclude = ["ide/src/tests/mock_project"]
resolver = "2"

[profile.bench]
debug = true

[patch.crates-io]
rustc_plugin = { git = "https://github.com/cognitive-engineering-lab/rustc_plugin", branch = "charpos-fix" }
rustc_utils = { git = "https://github.com/cognitive-engineering-lab/rustc_plugin", branch = "charpos-fix" }
debug = true
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ The documentation is published here: https://willcrichton.net/flowistry/flowistr
## Usage

Note that the latest Flowistry has a [**Maximum** Supported Rust Version](https://github.com/cognitive-engineering-lab/rustc_plugin/tree/main#maximum-supported-rust-version) of **Rust 1.69**.
Flowistry is not guaranteed to work with features implemented after 1.69.
Note that the latest Flowistry has a [**Maximum** Supported Rust Version](https://github.com/cognitive-engineering-lab/rustc_plugin/tree/main#maximum-supported-rust-version) of **Rust 1.73**.
Flowistry is not guaranteed to work with features implemented after 1.73.

### Startup

Expand Down
2 changes: 1 addition & 1 deletion crates/flowistry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ log = "0.4"
fluid-let = "1.0"
cfg-if = "1.0"
serde = {version = "1", features = ["derive"]}
rustc_utils = "0.6.3-nightly-2023-04-12"
rustc_utils = "0.7.0-nightly-2023-08-25"

# For local debugging
html-escape = {version = "0.2", optional = true}
Expand Down
2 changes: 1 addition & 1 deletion crates/flowistry/examples/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern crate rustc_span;
use std::process::Command;

use flowistry::{indexed::impls::LocationOrArg, infoflow::Direction};
use rustc_borrowck::BodyWithBorrowckFacts;
use rustc_borrowck::consumers::BodyWithBorrowckFacts;
use rustc_hir::{BodyId, ItemKind};
use rustc_middle::{
mir::{Local, Place},
Expand Down
7 changes: 2 additions & 5 deletions crates/flowistry/src/indexed/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! Therefore if we want to encode a set of locations (e.g. for the [`FlowDomain`](crate::infoflow::FlowDomain)),
//! then we can assign each `Location` a numeric index and use a compact bit-set instead of, say,
//! a hash set. Concretely, this means:
//! 1. Defining a type `LocationOrArgIndex` that implements the [`Idx`](rustc_index::vec::Idx) trait.
//! 1. Defining a type `LocationOrArgIndex` that implements the [`Idx`](rustc_index::Idx) trait.
//! 2. Creating a mapping ("domain") from `Location`s to `LocationOrArgIndex`.
//! 3. Constructing a `LocationSet` out of a [`BitSet`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_index/bit_set/struct.BitSet.html)`<LocationOrArgIndex>`.
//!
Expand All @@ -35,10 +35,7 @@ use std::{
};

use rustc_data_structures::fx::FxHashMap as HashMap;
use rustc_index::{
bit_set::BitSet,
vec::{Idx, IndexVec},
};
use rustc_index::{bit_set::BitSet, Idx, IndexVec};
use rustc_mir_dataflow::{fmt::DebugWithContext, JoinSemiLattice};

pub mod impls;
Expand Down
18 changes: 10 additions & 8 deletions crates/flowistry/src/infoflow/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ impl<'a, 'tcx> AnalysisDomain<'tcx> for FlowAnalysis<'a, 'tcx> {

impl<'a, 'tcx> Analysis<'tcx> for FlowAnalysis<'a, 'tcx> {
fn apply_statement_effect(
&self,
&mut self,
state: &mut Self::Domain,
statement: &Statement<'tcx>,
location: Location,
Expand All @@ -245,30 +245,32 @@ impl<'a, 'tcx> Analysis<'tcx> for FlowAnalysis<'a, 'tcx> {
.visit_statement(statement, location);
}

fn apply_terminator_effect(
&self,
fn apply_terminator_effect<'mir>(
&mut self,
state: &mut Self::Domain,
terminator: &Terminator<'tcx>,
terminator: &'mir Terminator<'tcx>,
location: Location,
) {
) -> TerminatorEdges<'mir, 'tcx> {
if matches!(terminator.kind, TerminatorKind::Call { .. })
&& is_extension_active(|mode| mode.context_mode == ContextMode::Recurse)
&& self.recurse_into_call(state, &terminator.kind, location)
{
return;
return terminator.edges();
}

ModularMutationVisitor::new(&self.place_info, |_, mutations| {
self.transfer_function(state, mutations, location)
})
.visit_terminator(terminator, location);

terminator.edges()
}

fn apply_call_return_effect(
&self,
&mut self,
_state: &mut Self::Domain,
_block: BasicBlock,
_return_places: rustc_mir_dataflow::CallReturnPlaces<'_, 'tcx>,
_return_places: CallReturnPlaces<'_, 'tcx>,
) {
}
}
2 changes: 1 addition & 1 deletion crates/flowistry/src/infoflow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use std::cell::RefCell;

use log::debug;
use rustc_borrowck::BodyWithBorrowckFacts;
use rustc_borrowck::consumers::BodyWithBorrowckFacts;
use rustc_hir::BodyId;
use rustc_middle::ty::TyCtxt;
use rustc_utils::{block_timer, BodyExt};
Expand Down
2 changes: 1 addition & 1 deletion crates/flowistry/src/infoflow/recursive.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use log::{debug, info};
use rustc_middle::{
mir::*,
ty::{subst::GenericArgKind, ClosureKind, TyKind},
ty::{ClosureKind, GenericArgKind, TyKind},
};
use rustc_mir_dataflow::JoinSemiLattice;
use rustc_utils::{mir::borrowck_facts::get_body_with_borrowck_facts, PlaceExt};
Expand Down
4 changes: 2 additions & 2 deletions crates/flowistry/src/mir/aliases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_data_structures::{
use rustc_hir::def_id::DefId;
use rustc_index::{
bit_set::{HybridBitSet, SparseBitMatrix},
vec::IndexVec,
IndexVec,
};
use rustc_middle::{
mir::{visit::Visitor, *},
Expand Down Expand Up @@ -87,7 +87,7 @@ impl<'a, 'tcx> Aliases<'a, 'tcx> {
let start = Instant::now();
let body = &body_with_facts.body;
let static_region = RegionVid::from_usize(0);
let subset_base = &body_with_facts.input_facts.subset_base;
let subset_base = &body_with_facts.input_facts.as_ref().unwrap().subset_base;

let all_pointers = body
.local_decls()
Expand Down
10 changes: 6 additions & 4 deletions crates/flowistry/src/mir/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::rc::Rc;

use either::Either;
use rustc_data_structures::{graph::WithSuccessors, work_queue::WorkQueue};
use rustc_index::vec::IndexVec;
use rustc_index::IndexVec;
use rustc_middle::{
mir::{traversal, Body, Location},
ty::TyCtxt,
Expand All @@ -39,7 +39,7 @@ pub struct AnalysisResults<'tcx, A: Analysis<'tcx>> {
impl<'tcx, A: Analysis<'tcx>> AnalysisResults<'tcx, A> {
pub fn visit_reachable_with<'mir, V>(&self, body: &'mir Body<'tcx>, visitor: &mut V)
where
V: ResultsVisitor<'mir, 'tcx, FlowState = A::Domain>,
V: ResultsVisitor<'mir, 'tcx, Self, FlowState = A::Domain>,
{
for (block, data) in traversal::reachable(body) {
for statement_index in 0 ..= data.statements.len() {
Expand All @@ -51,17 +51,19 @@ impl<'tcx, A: Analysis<'tcx>> AnalysisResults<'tcx, A> {
let state = &self.state[loc_index];

if statement_index == 0 {
visitor.visit_block_start(state, data, block);
visitor.visit_block_start(self, state, data, block);
}

if statement_index == data.statements.len() {
visitor.visit_terminator_after_primary_effect(
self,
state,
data.terminator(),
location,
)
} else {
visitor.visit_statement_after_primary_effect(
self,
state,
&data.statements[statement_index],
location,
Expand All @@ -85,7 +87,7 @@ pub fn iterate_to_fixpoint<'tcx, A: Analysis<'tcx>>(
_tcx: TyCtxt<'tcx>,
body: &Body<'tcx>,
location_domain: Rc<LocationOrArgDomain>,
analysis: A,
mut analysis: A,
) -> AnalysisResults<'tcx, A> {
let bottom_value = analysis.bottom_value(body);

Expand Down
4 changes: 1 addition & 3 deletions crates/flowistry/src/mir/placeinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ impl<'a, 'tcx> PlaceInfo<'a, 'tcx> {
fn collect_loans(&self, ty: Ty<'tcx>, mutability: Mutability) -> PlaceSet<'tcx> {
let mut collector = LoanCollector {
aliases: &self.aliases,
unknown_region: self
.tcx
.mk_region_from_kind(RegionKind::ReVar(UNKNOWN_REGION)),
unknown_region: Region::new_var(self.tcx, UNKNOWN_REGION),
target_mutability: mutability,
stack: vec![],
loans: PlaceSet::default(),
Expand Down
2 changes: 1 addition & 1 deletion crates/flowistry/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{fs, io, panic, path::Path};
use anyhow::Result;
use fluid_let::fluid_set;
use log::info;
use rustc_borrowck::BodyWithBorrowckFacts;
use rustc_borrowck::consumers::BodyWithBorrowckFacts;
use rustc_data_structures::fx::FxHashSet as HashSet;
use rustc_hir::BodyId;
use rustc_middle::ty::TyCtxt;
Expand Down
6 changes: 3 additions & 3 deletions crates/flowistry_ide/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ serde = {version = "1", features = ["derive"]}
serde_json = "1"
flate2 = "1"
base64 = "0.21"
rustc_utils = {version = "0.6.3-nightly-2023-04-12", features = ["serde"]}
rustc_plugin = "0.6.3-nightly-2023-04-12"
rustc_utils = {version = "0.7.0-nightly-2023-08-25", features = ["serde"]}
rustc_plugin = "0.7.0-nightly-2023-08-25"

# Decompose
petgraph = {version = "0.6", default-features = false, optional = true}
rayon = {version = "1.5", optional = true}

# For binaries
env_logger = {version = "0.9", default-features = false}
clap = {version = "4", default-features = false, features = ["std", "derive"]}
clap = {version = "4.4", default-features = false, features = ["std", "derive"]}
5 changes: 2 additions & 3 deletions crates/flowistry_ide/src/playground.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ pub fn playground(tcx: TyCtxt, body_id: BodyId) -> Result<PlaygroundOutput> {
let body = &body_with_facts.body;
debug!("{}", body.to_string(tcx).unwrap());

let outlives = body_with_facts
.input_facts
.subset_base
let subset_base = &body_with_facts.input_facts.as_ref().unwrap().subset_base;
let outlives = subset_base
.iter()
.map(|(sup, sub, _)| (format!("{sup:?}"), format!("{sub:?}")))
.collect::<HashSet<_>>();
Expand Down
9 changes: 4 additions & 5 deletions crates/flowistry_ide/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use rustc_hir::BodyId;
use rustc_interface::interface::Result as RustcResult;
use rustc_middle::ty::TyCtxt;
use rustc_plugin::{CrateFilter, RustcPlugin, RustcPluginArgs, Utf8Path};
use rustc_span::ErrorGuaranteed;
use rustc_utils::{
mir::borrowck_facts,
source_map::{
Expand Down Expand Up @@ -218,9 +219,7 @@ fn postprocess<T: Serialize>(result: FlowistryResult<T>) -> RustcResult<()> {
let result = match result {
Ok(output) => Ok(output),
Err(e) => match e {
FlowistryError::BuildError => {
return Err(rustc_errors::ErrorGuaranteed::unchecked_claim_error_was_emitted());
}
FlowistryError::BuildError(e) => return Err(e),
e => Err(e),
},
};
Expand Down Expand Up @@ -249,7 +248,7 @@ pub fn run_with_callbacks(
);

let compiler = rustc_driver::RunCompiler::new(&args, callbacks);
compiler.run().map_err(|_| FlowistryError::BuildError)
compiler.run().map_err(FlowistryError::BuildError)
}

fn run<A: FlowistryAnalysis, T: ToSpan>(
Expand Down Expand Up @@ -281,7 +280,7 @@ fn run<A: FlowistryAnalysis, T: ToSpan>(
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
pub enum FlowistryError {
BuildError,
BuildError(#[serde(skip_serializing)] ErrorGuaranteed),
AnalysisError { error: String },
FileNotFound,
}
Expand Down
4 changes: 2 additions & 2 deletions crates/flowistry_ifc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ env_logger = "0.9"
termcolor = "1.1"
anyhow = "1"
log = "0.4"
rustc_plugin = "0.6.3-nightly-2023-04-12"
rustc_utils = "0.6.3-nightly-2023-04-12"
rustc_plugin = "0.7.0-nightly-2023-08-25"
rustc_utils = "0.7.0-nightly-2023-08-25"
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2023-04-12"
channel = "nightly-2023-08-25"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

0 comments on commit 093cf05

Please sign in to comment.