GithubHelp home page GithubHelp logo

polonius's Introduction

This is a core library that models the borrow check. It implements the analysis described in this blogpost.

How to use

First off, you must use the nightly channel. To build, do something like this:

cargo +nightly build --release

You can try it on one our input tests like so:

cargo +nightly run --release -- inputs/issue-47680/nll-facts/main

This will generate a bunch of output tuples:

# borrow_live_at

"Mid(bb3[2])"   "bw0"
"Mid(bb3[2])"   "bw2"
"Mid(bb10[2])"  "bw0"
...

Want to see something slow?

One of the goals with this repo is to experiment and compare different implementations of the same algorithm. The repo includes one particularly egregious case where we currently perform poorly, and you can test it against it like so:

> cargo +nightly run --release -- inputs/clap-rs/app-parser-{{impl}}-add_defaults/ | head
    Finished release [optimized] target(s) in 0.05 secs
     Running `target/release/borrow-check 'inputs/clap-rs/app-parser-{{impl}}-add_defaults/'`
--------------------------------------------------
Directory: inputs/clap-rs/app-parser-{{impl}}-add_defaults/
Time: 113.316s

(You can see it is pretty dang slow on my machine!)

How to generate your own inputs

To run the borrow checker on an input, you first need to generate the input facts. For that, you will need to run rustc with the -Znll-facts option (note: PR #50370 adds the -Znll-facts option, and it has not landed at the time of this writing, so you may need to build rustc yourself):

> rustc -Znll-facts inputs/issue-47680/issue-47680.rs

This will generate a nll-facts directory with one subdirectory per function:

> ls -F nll-facts
{{impl}}-maybe_next/  main/

You can then run on these directories.

polonius's People

Contributors

nikomatsakis avatar qmx avatar sapphire-arches avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.