Auto merge of #113218 - lqd:polonius-scopes, r=jackh726
Compute NLL loan scopes using the polonius model For a *location-insensitive* analysis (that is, without expressiveness improvements for users yet), this PR implements loans going out of scope using reachability and liveness, rather than checking if the issuing region's values contain a given CFG point. This is equivalent to NLL scopes and computes the same data. r? `@matthewjasper` A couple of notes: - there are some assumptions about SCC representatives, placeholders, free regions, and member constraints that I believe hold, and they're documented in the code - this passes all the UI tests with `-Zpolonius=next` -- the perf is [not terrible](https://github.com/rust-lang/rust/pull/112432#issuecomment-1749685862) and there are a bunch of ways to improve it in the future. - there's a fixme left, hopefully Matthew you know a clean way to get the information it mentions.
This commit is contained in:
commit
c1691db366
10 changed files with 413 additions and 36 deletions
|
@ -3172,6 +3172,7 @@ impl PpMode {
|
|||
/// we have an opt-in scheme here, so one is hopefully forced to think about
|
||||
/// how the hash should be calculated when adding a new command-line argument.
|
||||
pub(crate) mod dep_tracking {
|
||||
use super::Polonius;
|
||||
use super::{
|
||||
BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, DebugInfoCompression,
|
||||
ErrorOutputType, InstrumentCoverage, InstrumentXRay, LinkerPluginLto, LocationDetail,
|
||||
|
@ -3281,6 +3282,7 @@ pub(crate) mod dep_tracking {
|
|||
OomStrategy,
|
||||
LanguageIdentifier,
|
||||
TraitSolver,
|
||||
Polonius,
|
||||
);
|
||||
|
||||
impl<T1, T2> DepTrackingHash for (T1, T2)
|
||||
|
@ -3419,3 +3421,35 @@ impl DumpMonoStatsFormat {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `-Zpolonius` values, enabling the borrow checker polonius analysis, and which version: legacy,
|
||||
/// or future prototype.
|
||||
#[derive(Clone, Copy, PartialEq, Hash, Debug)]
|
||||
pub enum Polonius {
|
||||
/// The default value: disabled.
|
||||
Off,
|
||||
|
||||
/// Legacy version, using datalog and the `polonius-engine` crate. Historical value for `-Zpolonius`.
|
||||
Legacy,
|
||||
|
||||
/// In-tree prototype, extending the NLL infrastructure.
|
||||
Next,
|
||||
}
|
||||
|
||||
impl Default for Polonius {
|
||||
fn default() -> Self {
|
||||
Polonius::Off
|
||||
}
|
||||
}
|
||||
|
||||
impl Polonius {
|
||||
/// Returns whether the legacy version of polonius is enabled
|
||||
pub fn is_legacy_enabled(&self) -> bool {
|
||||
matches!(self, Polonius::Legacy)
|
||||
}
|
||||
|
||||
/// Returns whether the "next" version of polonius is enabled
|
||||
pub fn is_next_enabled(&self) -> bool {
|
||||
matches!(self, Polonius::Next)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue