Rust-Rust enhanced: rust-enhanced — official Rust package

Rust Enhanced


This is a Sublime Text 3 package which supports Rust starting with version 1.0, it makes no attempt at supporting earlier incompatible versions.

This package used to be called 'Rust', but as of version 3, Sublime now comes with Rust built-in. The built-in version on Sublime is actually just a snapshot of this package with some fixes from quite some time ago. This package is still active and will continue to update and release, so if you want up to date features, and extra tools (such as syntax checking or building) we recommend using this package. It does not automatically override the built-in Rust package so you will have to disable it, and check "Rust Enhanced" is set. There is currently no plan to push upstream changes back into the Sublime Core Packages repo, and extra features will stay here.

For syntax highlighting for Cargo files. Its recommended installing this with the TOML package.

Running Tests with Rust Enhanced Highlighting errors and warnings with Rust Enhanced


Install the Package Control package if you haven't got it yet. Package Control is the best way to install packages for Sublime Text. See for instructions.

Open the palette (control+shift+P or command+shift+P) in Sublime Text and select Package Control: Install Package and then select Rust Enhanced from the list. That's it. If you can't see Rust Enhanced its most likely because you're using Sublime Text 2.


Go To Definition

Cargo Build

Rust Enhanced has a custom build system tailored for running Cargo. It will display errors and warnings in line using Sublime's phantoms (see Messages for settings to control how messages are displayed). It also supports a variety of configuration options to control how Cargo is run.


See the build docs for more information.

Cargo tests with highlighting

Thanks to urschrei we have Highlighting for:

  • passed test
  • failed test
  • failed test source line (clickable)
  • total number of passed tests
  • total number of failed tests > 0
  • total number of ignored tests > 0
  • total number of measured tests > 0



Syntax Checking

Rust Enhanced will automatically perform syntax checking each time you save a file. Errors and warnings are displayed in line the same way as the build system. This relies on Cargo and Rust (>= 1.8.0) being installed and on your system path. Plus Sublime Text >= 3118.

Settings for controlling the on-save syntax checking:

Setting Default Description
rust_syntax_checking true Enable the on-save syntax checking.
rust_syntax_checking_method "check" The method used for checking your code (see below).
rust_syntax_checking_include_tests true Enable checking of test code within #[cfg(test)] sections.
rust_syntax_hide_warnings false Don't show warnings when syntax checking

The available checking methods are:

Method Description
check Uses cargo check (requires at least Rust 1.16).
clippy Uses cargo clippy. This requires Clippy to be installed. This also may be a little slower since it must check every target in your package.

This will use the same configuration options as the "Check" and "Clippy" build variants (for example, extra environment variables, or checking with different features). See the build docs for more information.

Projects with multiple build targets are supported too (--lib, --bin, --example, etc.). If a cargo project has several build targets, it will attempt to automatically detect the correct target. In some rare cases, you may need to manually specify which target a file belongs to. This can be done by adding a "projects" setting in Rust.sublime-settings with the following format:

    "projects": {
       // One entry per project. Keys are project names.
       "my_cool_stuff": {
           // Path to the project root dir without trailing /src.
           "root": "/path/to/my/cool/stuff/project",

           // Targets will be used to replace {target} part in the command.
           // If no one target matches an, empty string will be used.
           "targets": {
               "bin/": "--bin foo",  // format is "source_code_filename -> target_name"
               "bin/": "--bin bar",
               "_default": "--lib"         // or "--bin main"

RLS Support

RLS (Rust Language Server) support is experimental, because RLS is still in Alpha and the Sublime LSP plugin is work in progress. However, it's quite usable, and trying it is easy:

  • Set up RLS - follow the instructions, using the Nightly toolchain
  • Check that RLS is working correctly by running rustup run nightly rls --version. If you get a version back RLS is installed
  • Install LSP using Package Control
  • Enable LSP for Rust:
    • Open a Rust project, and open its or file
    • Open the Command Palette, and select the LSP: Enable Language Server Globally | Project command
  • RLS should then initialise: you'll see a message in the status bar, and once the initial build has completed (this can be slow initially, as the RLS has to build your project), it is ready to use.

Note that as well as error checking, code-completion, and renaming, RLS can run rustfmt on your code: right-click, and select Format Document or Format Selection in a Rust source file.

You can keep RLS updated by running rustup update nightly, which will ensure that you get the latest features. LSP is also developing quickly, so it's worth checking package control for updates.

Context Menu

The Sublime context menu includes a Rust entry with a variety of commands. See context menu docs for more information.


To customize the settings, use the command from the Sublime menu:

Preferences > Package Settings > Rust Enhanced > Settings - User

Additionally, you can customize settings per-project by adding settings to your .sublime-project file under the "settings" key.


Development is quite simple, just check out this project to your Sublime Text 3 packages folder, and switch to using this one. Syntax definitions are defined in the RustEnhanced.sublime-syntax file.


Created 2012 by Daniel Patterson, as a near complete from scratch rewrite of a package by Felix Martini.

This project is currently maintained by Jason Williams


This package is licensed under the MIT License.


  • Fix type scoping in various circumstances
    Fix type scoping in various circumstances

    Mar 2, 2020

    This properly assigns storage.type.source.rust to type signatures in method parameters (see lines 30, 81, 88, 94, 101, etc.), generic types (see lines 13, 21, etc.), and possibly other places.

  • Fix scoping for qualified function names
    Fix scoping for qualified function names

    Mar 2, 2020

    This correctly assigns support.function.rust scope to qualified function names (e.g. my_function in my_module::my_function(arg1, arg2)). It might break something else, although a quick glance through the test files suggests it's fine.

  • Highlight function name in `modname::function`
    Highlight function name in `modname::function`

    Mar 22, 2020

    Sublime Text Version

    Sublime Text Build 3211

    Rust Enhanced Version


    Operating system

    OS Name : ArchLinux Version: Linux rust 5.4.26-1-lts #1 SMP Wed, 18 Mar 2020 08:40:46 +0000 x86_64 GNU/Linux

    Expected behavior

    I would like to highlight create_dir_all in this block:

            let dirname = dirname.into();

    Actual behavior

  • Synchronize syntax with sublime hq.
    Synchronize syntax with sublime hq.

    Apr 1, 2020

    This is an attempt to sync the syntax definition with the changes made in Corresponding PR:

  • Remove override advice on
    Remove override advice on

    Jun 14, 2020

    The function plugin_loaded in already does the checks and set the default Rust package to the list "ignored_packages" inside of the settings JSON file, so the advice is misleading.

    No need to manually ignore the default Rust package.

  • Add build entries that run rustc similar to the default package.
    Add build entries that run rustc similar to the default package.

    Jun 14, 2020

    I'm learning Rust, and was using the sublime's default Rust package, it allows me to run rustc and then, run the executable, here's the command.

    "shell_cmd": "rustc \"$file\" && \"./$file_base_name\"",

    After installing Rust Enhanced, I'm unable to run like this.

    I can make a little hack here editing the .build file, but my proposal is to add the equivalent command to this package.

  • New Cargo build system.
    New Cargo build system.

    Mar 12, 2017

    I wanted to share a WIP of a new, enhanced build system for Cargo. I was wondering:

    1. Would you would be willing to merge something like this?
    2. Test it out and let me know what you think (any issues, ideas for improvements, etc.)

    The main improvements are:

    • Shows inline phantoms for errors/warnings when building.
    • Properly handles cancelling/stopping a build.
    • Pulls in the user's shell environment to make it less likely to have problems.
    • Supports custom environment variables.
    • Interacts more nicely with the on-save syntax checking.
    • Allows you to configure settings for builds (see docs/
    • Command to assist configuring custom build variants.
    • On-save syntax checking supports different methods (rustc no-trans, cargo check, clippy)

    This also closes a few issues: #182, #170, #162, #154, #146, #109

    It should be fully functional in its current state, but I still have a long todo/improvement list. Here's a copy in case you are curious:

    • [x] Support custom build variants (passing in any and all settings).
      • [x] Also include interactive command to configure a new variant.
      • [x] Include "environment", and "path"
      • [x] Any custom arguments.
      • [x] working_dir
    • [x] Set "default" project path/package.
    • [x] Cargo "Automatic"
    • [x] Add "--features" support.
    • [x] cargo check
    • [x] test: Message-order: Next/Prev testing Test with a variety of message types (to ensure is_main is good) Test with already open files and files that need to be opened.
    • [x] Test without cargo manifest
    • [x] Test without sublime project
    • ~~[ ] Run with multiple executables displays this error: error: cargo run requires that a project only have one executable; use the --bin option to specify which one to run Should we detect this, and bring a popup to select a target?~~ Deferred
    • [ ] Clippy: Should it automatically use nightly toolchain?
      • [ ] Same with Bench?
    • [x] Make links in clippy output clickable.
    • [x] Deal with duplicate messages generated by clippy (filter duplicate messages in general)
    • [x] Make clippy an option for on-save checking.
    • [x] Should the cargo settings be used for SyntaxCheck somehow?
    • ~~[ ] I think the build-language could be improved (coloring file filenames, numbers, etc.)~~ Deferred
    • ~~[ ] Something similar to Anaconda Show Errors (popup with list of errors)~~ Deferred
    • ~~[ ] Other cargo test options?: --doc --no-run --no-fail-fast~~ Deferred
    • [x] Is term "Target" too confusing? Filter or Kind? Internally Cargo uses various terms (CompilerFilter, Kind, Target)
    • [x] Update README
    • [x] Fix called with multiple buffers (views) into same file. (Terminates, but otherwise runs correctly. This is something that really needs to be fixed in Sublime.)
    • [x] Check setting "show_errors_inline"? In case someone doesn't like the phantom style.
    • [x] Possibly consolidate the configuration commands into a single command?
    • [x] Add command to configure environment variables (in particular, make it easy to add RUST_BACKTRACE=1).

    One last thing, this replaces the "rustc" build variants. I'm not sure what the use case is for those, and whether or not "cargo script" is a sufficient replacement.

  • Experimental support for the new error format
    Experimental support for the new error format

    Aug 23, 2016

    This is mostly a result of me playing around with the new json formatted error messages but I decided to PR it to see what was thought of it.

    It requires the latest dev build of Sublime Text 3 so I don't really expect this to be pulled as it stands.

    This uses the phantom system to display error messages and hints inline with the code, i'm not sure how much I like this system but it seemed to be the nicest way I could think of displaying them.

    I don't really do python so i'm sorry about the code

  •  Update message handling for Rust 1.24.
    Update message handling for Rust 1.24.

    Jan 20, 2018

    Rust 1.24 introduces some breaking changes, in particular:

    • All paths are now relative to the workspace root instead of the package root.
    • Columns reported in macros are now 1-based (affects test output).

    Fixes #234.

  • Add highlighting and jumping to test failures for test output
    Add highlighting and jumping to test failures for test output

    Mar 5, 2016

    This PR adds

    cargo test output highlighting:

    • note:
    • test result:
    • a passed test
    • a failed test
    • failed test source line (this is clickable, jumps to source)
    • summary line, total number of passed tests
    • summary line, total number of failed tests if > 0
    • summary line, total number of ignored tests if > 0
    • summary line, total number of measured tests if > 0

    New build commands:

    • cargo build --release
    • cargo clippy

    Bug fixes:

    • Don't treat <std macros> as a file name.

    My choice of entity to trigger various highlights is probably questionable, but they're a complete ?? anyway. @dten what do you think?

  • Sublime Text opens empty non-existent file when error originates in macro
    Sublime Text opens empty non-existent file when error originates in macro

    Nov 4, 2016

    Whenever an error is caused by a derive macro, sublime opens a non-existent file with the name of the macro when pressing F4 to jump to the error: E.g.

    error[E0412]: type name `Foo` is undefined or not in scope
     --> <proc-macro source code>:1:4261

    When I press F4 it opens a new empty file named . This is undesirable. Btw, in this case the error was caused by using #[derive(Serialize)] on an enum with a member that uses an undefined type:

    #[derive(Serialize, Deserialize)]
    pub enum Bar {
  • Syntax changes with aim of improving consitency
    Syntax changes with aim of improving consitency

    Nov 7, 2016

    #113 raises a good point about consitency so I've made some changes but would like some feed back. (don't merge this without discussion please)

    if @boscop or @petrochenkov would like to give comment that would be appreciated

    currently function calls aren't highlighted, i got stuck trying to make generic function calls match the non generic ones so gave up and went with white for all functions calls for consitency