Michael Müller
05 Dec, 2023

SemanticDiff 0.8.8: Support For Rust And More

The eight beta release of our VS Code extension / GitHub App SemanticDiff adds support for Rust, new invariances and other enhancements.

We have just released version 0.8.8 of SemanticDiff - our programming language aware diff for Visual Studio Code and GitHub. This update introduces support for diffing Rust files and provides minor improvements for other supported languages.

If you are using the GitHub App, all updates have already been rolled out and no action is required on your part. VS Code users should receive the update automatically when the editor checks for extension updates.

Rust Support

The most significant change in SemanticDiff 0.8.8 is that it can now generate programming language aware diffs for Rust. You can now reformat your code with rustfmt and SemanticDiff should display an empty diff as it ignores style-only changes. This is especially useful if your files also contain other modifications that would be easily missed in a standard diff amidst all the format changes.

Here are a some screenshots to demonstrate what it looks like. Let’s start with a very simple toy example:

Rust toy example in SemanticDiff
SemanticDiff detects how line 1 (old) was spread across the lines 1-5 (new) and highlights only the new parameter.

SemanticDiff can also distinguish between stylistic changes and logic changes in less obvious cases:

Rust invariances in SemanticDiff
SemanticDiff knows the priority of operands, can convert between different bases and understands character escaping.

The full list of invariances (i.e. changes that are not displayed in the diff) includes:

  • Adding/Removing whitespaces or line breaks outside of strings and comments
  • Adding/Removing optional commas
  • Adding/Removing unnecessary parenthesis
  • Exchanging numeric literals with equivalent ones in different bases
  • Exchanging escaped characters in a string/char with an equivalent representation (e.g. the literal)
  • Exchanging the deprecated ... range operator with ..=

As with any other supported language, SemanticDiff can also detect and highlight moved code blocks in Rust:

Moved Rust code in SemanticDiff
Ignore changes in code comments was enabled to keep the example small.

Since the Rust language syntax is still evolving, SemanticDiff may not yet support all recent additions. We focus on the stable syntax and only pull in a few selected RFCs from Rust nightly. If your project requires a language feature not yet supported, feel free to open an issue.

Other Changes

The addition of Rust was not the only language related change in SemanticDiff 0.8.8. Here is a list of the remaining changes:

  • Python: Improved handling of indentation changes
  • Support for base conversions of integer literals with a postfix (e.g. 13L)
  • C#: Treat swapping an explicit parameter list ((x) => x) with an implicit parameter (x => x) as invariant
  • Fixed a bug that aborted the diff computation when a certain type of change occurred in a moved code block
  • Fixed highlighting of characters in the supplementary Unicode planes
  • Improved detection of moved code blocks
  • CSS: Improved parsing

We have also improved the onboarding experience for our Visual Studio Code extension. The first time you install SemanticDiff, a step-by-step guide will open to help you get started. If you need more information, don’t forget to check out our documentation.

What’s next

If you follow our release announcements or scroll through the VS Code extension changelog, you may notice that the number of new features per release is currently decreasing. This is intentional as we prepare for the SemanticDiff 1.0.0 release and focus more on quality and performance improvements. We only have a few items left on our TODO list that we would like to finish before the release. So expect one or maybe two more beta releases.

We hope you enjoyed this update. If you encounter any issues, please let us know in our issue tracker.

Recent Articles

SemanticDiff vs. Difftastic: How do they differ?
SemanticDiff vs. Difftastic: How do they differ?

Both tools aim to provide a better diff, but which one fits your needs? We compared their inner workings, features, and workflow integration to help you decide.

Read More
Unicode tricks in pull requests: Do review tools warn us?
Unicode tricks in pull requests: Do review tools warn us?

How well do GitHub, GitLab and Bitbucket support reviewers in finding malicious code changes in pull requests? Let’s give it a test.

Read More
SemanticDiff 0.8.8: Support For Rust And More
SemanticDiff 0.8.8: Support For Rust And More

The eight beta release of our VS Code extension / GitHub App SemanticDiff adds support for Rust, new invariances and other enhancements.

Read More