Skip to content

Checking doesn't work for workspace projects. #61

Closed
@radupopescu

Description

@radupopescu

Hi there!

I have a Rust project organized as a workspace - in the root of the project, there are two other sub-crates which are part of the workspace.

When editing the main file of the root project (<PROJECT_ROOT>/src/main.rs) or even the library part of the root project ('<PROJECT_ROOT>/src/lib.rs`) there are no issues with flycheck.

When editing the contents of any of the sub-crates (i.e. <PROJECT_ROOT>/<SUBCRATE>/src/lib.rs) there is no checking happening.

I suspect that flycheck isn't aware of workspace projects. When checking my code from the command line, I usually have to specify the --all parameter to the check command to instruct it to recurse into sub-crates. For example:

$ cargo check --all --tests

I don't know how this is done with cargo rustc.

Here are some diagnostics/output from my computer:

Syntax checkers for buffer mod.rs in rust-mode:                                                                                                                                    
                                                                                                                                                                                    
  rust-cargo                                                                                                                                                                       
    - may enable:  yes                                                                                                                                                             
    - predicate:   t                                                                                                                                                               
    - executable:  Found at /Users/radu/.cargo/bin/cargo                                                                                                                           
    - Cargo.toml:  Found                                                                                                                                                           
    - Crate type:  lib                                                                                                                                                             
    - Binary name: Not required                                                                                                                                                    
                                                                                                                                                                                    
  rust                                                                                                                                                                             
    - may enable: yes                                                                                                                                                              
    - predicate:  t                                                                                                                                                                
    - executable: Found at /Users/radu/.cargo/bin/rustc                                                                                                                            
                                                                                                                                                                                   
Flycheck Mode is enabled.  Use C-u C-c ! x to enable disabled                                                                                                                      
checkers.                                                                                                                                                                          
                                                                                                                                                                                   
--------------------                                                                                                                                                               
                                                                                                                                                                                   
Flycheck version: 32snapshot (package: 20180116.147)                                                                                                                               
Emacs version:    25.3.1                                                                                                                                                           
System:           x86_64-apple-darwin13.4.0                                                                                                                                        
Window system:    nil

This is how I configure Flycheck in my Emacs' init.el:

;;; Rust ;;;                                                                                                                                                                      
;;;;;;;;;;;;                                                                                                                                                                      
(use-package racer                                                                                                                                                                
  :init                                                                                                                                                                           
  (setq racer-cmd "~/.cargo/bin/racer")                                                                                                                                           
  :config                                                                                                                                                                         
  (use-package company-racer)                                                                                                                                                     
  (use-package cargo)                                                                                                                                                             
  (use-package flycheck-rust)                                                                                                                                                     
  (add-hook 'rust-mode-hook 'cargo-minor-mode)                                                                                                                                    
  (add-hook 'rust-mode-hook #'racer-mode)                                                                                                                                         
  (add-hook 'rust-mode-hook                                                                                                                                                       
            (lambda ()                                                                                                                                                            
              (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)))                                                                                                              
  (add-hook 'racer-mode-hook #'eldoc-mode)                                                                                                                                        
  (add-hook 'racer-mode-hook #'company-mode))                                                                                                                                     

It would be really useful to have flycheck support in workspace projects.

Thanks for the great work on Flycheck, this is the first issue I've encountered for Rust, it works great otherwise!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions