Eclipse Corrosion

Supporting the Future of Reliable Infrastructure

Eclipse Corrosion is the Eclipse IDE-based development environment for the Rust programming language. The Rust programming language is gaining popularity, ranking as the “most loved” language on stackoverflow‘s developer survey three years in a row. The language is so interesting, it’s even finding its way into the projects of tech giants, such as Amazon, Google, Microsoft, and Facebook.

Rust Offers Key Language Features

Rust is a relatively new contender in the realm of so-called “systems programming” languages.

The language allows fine-grained control of memory usage and layout, which makes it suitable for low-level tasks. The compiled programs usually have low memory overhead and fast execution times. These benefits allow Rust to compete with C and C++, the longstanding predominant languages in systems programming. There are also important differentiators that can make Rust a better choice for certain use cases, rather than the ubiquitous C and C++ languages.

Rust’s key language features are:

  • Compile-time-guaranteed memory safety (no null-reference access, no use-after-free, no double-free, no buffer over- or underflows)
  • Data race freedom

These features eliminate a range of problems commonly associated with languages that use manual memory management. As a result, Rust is ideal for implementing critical infrastructure components and programs that need performance as well as a high standard of safety and security. However, the compiler is strict and allows fewer patterns of data flow and memory access than are allowed in C and C++.

The following simple code example (Figure 1) illustrates a case where the Rust compiler has identified a potential use-after-free error.

Figure 1: Potential Use-After-Free Error Flagged by the Rust Compiler

Rust’s Toolchain Also Offers Advantages

But, Rust has more to offer than plain language features. The toolchain is lauded for being easy to use and offering simple dependency management compared to C and C++. Rust offers a toolchain version manager, called Rustup, and a default build tool, called Cargo, that is installed with the compiler. Cargo also manages Rust projects dependencies. It can easily fetch dependencies (so-called crates) from the central package repository crates.io.

Concrete examples of projects that are a great fit for Rust include:

  • Fast command line tools, such as Ripgrep
  • Databases, such as TiKV
  • Virtualization technologies, such as Amazon’s Firecracker
  • Embedded and Internet of Things (IoT) systems, such as parts of Microsoft’s Azure IoT Edge technology
  • Operating systems, such as Tock OS or Redox OS
  • Network applications with very low overhead, such as Linkerd Proxy
  • Parts of safety and security sensitive applications, such as the Firefox browser

To become familiar with the Rust language, reading the free Rust Book is a great way to start. 

Getting Started With Corrosion and Rust

The Eclipse IDE has supported systems programming for a long time. The Eclipse CDT project is a widely used C and C++ programming plug-in for the Eclipse IDE. The Eclipse Corrosion plug-in follows a similar path, providing an integrated environment for developing Rust applications within the Eclipse IDE.

To start writing Rust programs with Corrosion, the easiest approach is to download the Eclipse IDE for Rust Developers. If you use the Eclipse installer, you can install the package from there as well.

To start using the Rust toolchain, most people use Rust's toolchain version manager, Rustup.

For more information about installing and using Corrosion, visit the Corrosion GitHub Page

A Comprehensive Feature Set

Corrosion supports most of the features one would expect from a modern IDE:

  • Syntax highlighting
  • Code completion (with code templates)
  • Outline view
  • Compile error and warning diagnostics, shown in the editor
  • Quick fixes
  • Compiling and running programs and tests with cargo
  • Debugging programs using GDB (Figure 2)
  • Code formatting
  • Jump-to-definition (using Ctrl+Click in the code editor)
  • Find references
  • Documentation pop-up when hovering over elements
  • Toggle comment  

Figure 2: Debugging in Corrosion

And there are more features to explore.

The secret to Corrosion is that this rich feature set is, at its core, not implemented in the Corrosion project itself. Many puzzle pieces make up the software that is shipped as Eclipse Corrosion. 

Standing on the Shoulders of Giants

It is remarkable how compact the Corrosion plug-in actually is. This is accomplished by building on top of the great work in the Eclipse technologies Corrosion depends on, as well as a relatively new concept: The language server protocol (LSP) (Figure 3).

Figure 3: The Stack Corrosion Is Built on

The language server protocol provides an API between an IDE and a backend to ensure the language is understood by a frontend IDE or editor. For Rust, this server is the Rust Language Server (RLS) that can be installed using the Rustup tool.

To leverage the RLS from the Eclipse IDE, the Eclipse LSP4J project provides a Java implementation of the LSP for language servers and language server clients. The Eclipse LSP4E project sits on top of LSP4J to generically integrate the protocol with the Eclipse IDE.

The Eclipse TM4E project provides the ability to perform syntax highlighting based on TextMate grammar definitions. Corrosion uses this framework to perform syntax highlighting based on an existing TextMate grammar file. 

The Rust toolchain does not currently come with a Debug Adapter Protocol (DAP) server. The DAP is a sister protocol to the LSP, allowing IDEs to start and debug applications. The lack of a DAP server means debugging support in Corrosion must be accomplished in a different way.

The Eclipse CDT project allows native applications to be debugged using the GDB debugger. Corrosion reuses this functionality to support debugging of Rust applications.

Using these existing technologies is a mutually beneficial relationship. To improve Corrosion, committers are contributing to the Eclipse CDT, LSP4E, and Mylyn projects. These efforts improve Corrosion, as well as the upstream Eclipse technologies.

Improvements Are Ongoing

The development pace in Corrosion is steady as we eliminate minor issues in Rust development one by one. For example, the upcoming version will support a CodeLense for running single test cases directly from their definition (Figure 4). It will also come with diagnostics in the debug launch configuration to indicate any problems with the debugger configuration (Figure 5).

Figure 4: Starting a Test From Its Definition

Figure 5: Debugger Errors Shown in the Launch Dialog

Other improvements will be available in Corrosion through improvements to the underlying components, which are evolving as well.

When RLS v2.0 is completed, Corrosion will gain many great features, including more intelligent (postfix) code completions and much more. For a glimpse into the future of RLS, take a look at the rust-analyzer project.

Get Involved in Corrosion

We always welcome contributions to Corrosion and are keen to know how we can improve the project as well as which features are most important to our users.

To report issues, make a feature request, comment on existing issues, or discuss contributions, please visit the Corrosion issue tracker.

About the Author

Max Bureck

Max Bureck

Senior Researcher
Fraunhofer Institute for Open Communication Systems (FOKUS)