Git Product home page Git Product logo

rust-reduce's Introduction

rust-reduce

rust-reduce will try to make the source file smaller by interpreting it as valid Rust code and intelligently removing parts of the code. After each removal, the given command will be run but passing a path to a file containing the reduced code. The command should return 0 if run on the original input, and also if the reduced code is interesting, non-0 otherwise.

The original file will be overwritten with the smallest interesting reduced version, if found. This happens while rust-reduce is running. The original file will be backed up with the .orig suffix. If rustfmt is found, it will be used to clean up the output.

A common way to use rust-reduce is to write a short shell script that runs rustc and greps the compiler output for a particular error message. NB. you will want to look for a specific error message because while rust-reduce will generate syntactically correct code, it's not guaranteed to compile.

The original file may refer to modules in different files, these will be inlined and reduced along with the main file.

C-reduce

This project is inspired by, and should be used in conjuniction with C-reduce.

Although Rust and C syntax are different, they are similar enough that running C-reduce on Rust source code can be very effective! However, C-reduce only works with single input files, whereas Rust has a module system. rust-reduce can be run on an entire crate and will produce a single reduced output file. rust-reduce only implements a few reduction passes that are designed to remove large chunks of code, after which C-reduce can take over the reduction.

When using C-reduce and rust-reduce in the same project, please take note that rust-reduce will change the command line of the test command whereas C-reduce won't.

Passes

Take a look at src/transforms to see the kind of reductions rust-reduce can do.

Examples

Take a look at the test suite in tests/suite for example usage.

rust-reduce's People

Contributors

gilescope avatar

Stargazers

 avatar

Watchers

 avatar

rust-reduce's Issues

Not yet implemented

http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/

We should do lots of these:

  • Reduce the driving code first
  • Mod-inlining
  • Decommentification
  • Body Loopification
  • Suffix-bisection
  • Unusedification
  • Demodulification
  • ADT-reduction (simple done, generics todo)
  • Deimplificiation
  • Dep-reduction
  • Depublification
  • Simpl-impl
  • Type-trivialization
  • Bisecting the module tree
  • Reduction via Bisection
  • Popping the stack
  • RHS-inlining
  • Defaultification
  • Genertrification
  • Param-elimination
  • Ret-elimination
  • None-defaulting
  • Cut-spaghetti-imports
  • Deobjectification
  • Ret-ascription

Tracking issue: cargo-reduce

It should be possible to reduce simple setups without needing to write a test.cmd / test.sh file.

Ideally we should be able to do something like this:

cargo install cargo-reduce
cargo reduce "some output to find" cargo test

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.