-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It infers the wrong file path from json error msg #234
Comments
Hm, I can't seem to recreate this. Sorry, I may need a bunch of information from you to figure it out:
|
I did "Open Folder" on the workspace folder. |
OK, I have reproduced it. This seems to be a change on Rust nightly. I will need to investigate more to figure out a fix. |
I'm curious, what was the actual change to the json msg format? #[allow(non_camel_case_types)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum Level
error
warning
note
help
#[serde(tag = "reason")]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum Msg
#[serde(rename = "compiler-message")]
CompilerMessage
message: Message
package_id: String
target: Target
#[serde(rename = "compiler-artifact")]
CompilerArtifact
features: Vec<::serde_json::Value>
filenames: Vec<String>
fresh: bool
package_id: String
profile: Profile
target: Target
#[serde(rename = "build-script-executed")]
BuildScriptExecuted
cfgs: Vec<::serde_json::Value>
env: Vec<::serde_json::Value>
linked_libs: Vec<String>
linked_paths: Vec<::serde_json::Value>
package_id: String
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Message
pub children: Vec<Message>
pub code: Option<Code>
pub level: Level
pub message: String
pub rendered: ::serde_json::Value
pub spans: Vec<Span>
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Code
pub code: String
pub explanation: String
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Span
pub byte_end: usize
pub byte_start: usize
pub column_end: usize
pub column_start: usize
pub expansion: ::serde_json::Value
pub file_name: String
pub is_primary: bool
pub label: ::serde_json::Value
pub line_end: usize
pub line_start: usize
pub suggested_replacement: ::serde_json::Value
pub text: Vec<Text>
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Text
pub highlight_end: usize
pub highlight_start: usize
pub text: String
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Target
pub crate_types: Vec<String>
pub kind: Vec<String>
pub name: String
pub src_path: String
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Profile
pub debug_assertions: bool
pub debuginfo: i64
pub opt_level: String
pub overflow_checks: bool
pub test: bool |
rust-lang/cargo#4788 changed it so that all packages are compiled relative to the workspace root instead of the directory where
AFAIK, it is not explicitly documented. I have just been reading the rust source code to figure things out. My notes on the format are here. The JSON structures are defined in libsyntax/json.rs, and there are some comments in there. The code that formats compiler messages into ASCII art is in librustc_errors/emitter.rs. There is not an exact 1:1 relationship between the internal Rust data structures and the JSON format, but it is usually close enough. Let me know if you have any specific questions, since I've had to look at this a lot. |
When I get an error like:
When I click on it, it opens a non-existing file
<project_root>\server\server\src\controllers\driver.rs
but it should instead open the right file at
<project_root>\server\src\controllers\driver.rs
.(Btw, this project is in a workspace, of which
server
is one crate.)The text was updated successfully, but these errors were encountered: