question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rust Enhanced chokes on "possible candidate is found in another module"

See original GitHub issue
error: src\main.rs:205: cannot find type `PluginInstance` in this scope
error: src\main.rs:205: not found in this scope
help: src\main.rs:139: possible candidate is found in another module, you can import it into scope
Rust Enhanced Internal Error: Traceback (most recent call last):
  File "rust.rust_proc in C:\Users\me\AppData\Roaming\Sublime Text 3\Installed Packages\Rust Enhanced.sublime-package", line 300, in _read_stdout
  File "rust.opanel in C:\Users\me\AppData\Roaming\Sublime Text 3\Installed Packages\Rust Enhanced.sublime-package", line 109, in on_json
  File "rust.messages in C:\Users\me\AppData\Roaming\Sublime Text 3\Installed Packages\Rust Enhanced.sublime-package", line 587, in add_rust_messages
  File "./python3.3/re.py", line 191, in split
TypeError: expected string or buffer

On the cmd line, it looks like this:

{
  "message": {
    "children": [
      {
        "children": [],
        "code": null,
        "level": "help",
        "message": "possible candidate is found in another module, you can import it into scope",
        "rendered": null,
        "spans": [
          {
            "byte_end": 4399,
            "byte_start": 4399,
            "column_end": 1,
            "column_start": 1,
            "expansion": null,
            "file_name": "main.rs",
            "is_primary": true,
            "label": null,
            "line_end": 139,
            "line_start": 139,
            "suggested_replacement": "use vst2::host::PluginInstance;\n",
            "text": [
              {
                "highlight_end": 1,
                "highlight_start": 1,
                "text": "use vst2::plugin::{Info, Plugin};"
              }
            ]
          }
        ]
      }
    ],
    "code": {
      "code": "E0412",
      "explanation": "\nThe type name used is not in scope.\n\nErroneous code examples:\n\n```compile_fail,E0412\nimpl Something {} // error: type name `Something` is not in scope\n\n// or:\n\ntrait Foo {\n    fn bar(N); // error: type name `N` is not in scope\n}\n\n// or:\n\nfnfoo(x: T) {} // type name `T` is not in scope\n```\n\nTo fix this error, pleaseverify you didn't misspell the type name, you did\ndeclare it or imported it into the scope. Examples:\n\n```\nstruct Something;\n\nimpl Something {} // ok!\n\n// or:\n\ntrait Foo {\n    type N;\n\n    fn bar(_: Self::N); // ok!\n}\n\n// or:\n\nfn foo<T>(x: T) {} // ok!\n```\n\nAnother case that causes this error is when a type is imported into a parent\nmodule. To fix this, you can follow the suggestion and use File directly or\n`use super::File;` which will import the types from the parent namespace. An\nexample that causes this error is below:\n\n```compile_fail,E0412\nuse std::fs::File;\n\nmod foo {\n    fn some_function(f: File) {}\n}\n```\n\n```\nuse std::fs::File;\n\nmod foo {\n    // either\n    use super::File;\n    // or\n    // use std::fs::File;\n    fn foo(f: File) {}\n}\n# fn main() {} // don't insert it for us; that'll break imports\n```\n"
    },
    "level": "error",
    "message": "cannot find type `PluginInstance` in this scope",
    "rendered": null,
    "spans": [
      {
        "byte_end": 9662,
        "byte_start": 9648,
        "column_end": 55,
        "column_start": 41,
        "expansion": null,
        "file_name": "main.rs",
        "is_primary": true,
        "label": "not found in this scope",
        "line_end": 261,
        "line_start": 261,
        "suggested_replacement": null,
        "text": [
          {
            "highlight_end": 55,
            "highlight_start": 41,
            "text": "\tpub fn process(&mut self, plugin: &mut PluginInstance) {"
          }
        ]
      }
    ]
  },
  "package_id": "foo 0.1.0 (path+file:///D:/projects/foo)",
  "reason": "compiler-message",
  "target": {
    "crate_types": [
      "bin"
    ],
    "kind": [
      "bin"
    ],
    "name": "foo",
    "src_path": "D:\\projects\\foo\\src\\main.rs"
  }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ehusscommented, Dec 5, 2017

I’m working on a fix. There has been some recent refactoring for how suggestions are handled in rustc, which has changed the way they are stored in the JSON output.

0reactions
jasonwilliamscommented, Dec 7, 2017

@Boscop are you able to try out https://github.com/rust-lang/rust-enhanced/pull/228 and let us know if it works for you?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use one module from another module in a Rust cargo ...
My example has three files inside the src folder. Modules a and b are at the same level. One is not a submodule...
Read more >
If everyone hates it, why is OOP still so widespread?
In any case, it is not uniquely a OOP feature and can be done with modules isolating a system function or a set...
Read more >
Bug listing with status RESOLVED with resolution TEST ...
Bug:233 - "Emacs segfaults when merged through the sandbox." status:RESOLVED resolution:TEST-REQUEST severity:critical · Bug:3888 - "yenta_socket module not ...
Read more >
The Book Thief - SharpSchool
but a foster home had apparently been found, and if nothing else, the new family could at least feed the girl and the...
Read more >
Chapter 11: Interim Controls - HUD
be notified for interim control or other renovation work in target ... to the substrate should be enhanced by chemical etching, applying rust...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found