-
Notifications
You must be signed in to change notification settings - Fork 216
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
Add possibility to request compiler's JSON output #257
Comments
Do you know how stable the output of the JSON format is? It might be better for the playground itself to use it, instead of scraping the stdout/stderr. Then the next thing would be to figure out how to expose it. As a heads-up, the |
I'm not sure how stable the output format is, but the compiler let's you use it on the stable channel, so I hope it is? 🤞 {
"message": {
"children": [
{
"children": [],
"code": null,
"level": "note",
"message": "#[warn(dead_code)] on by default",
"rendered": null,
"spans": []
}
],
"code": {
"code": "dead_code",
"explanation": null
},
"level": "warning",
"message": "static item is never used: `X`",
"rendered": null,
"spans": [
{
"byte_end": 40,
"byte_start": 16,
"column_end": 29,
"column_start": 5,
"expansion": null,
"file_name": "src/main.rs",
"is_primary": true,
"label": null,
"line_end": 2,
"line_start": 2,
"suggested_replacement": null,
"text": [
{
"highlight_end": 29,
"highlight_start": 5,
"text": " static X: u8 = [1,2][4];"
}
]
}
]
},
"package_id": "foo 0.1.0 (path+file:///tmp/foo)",
"reason": "compiler-message",
"target": {
"crate_types": [
"bin"
],
"kind": [
"bin"
],
"name": "foo",
"src_path": "/tmp/foo/src/main.rs"
}
}
{
"message": {
"children": [],
"code": {
"code": "E0080",
"explanation": "\nThis error indicates that the compiler was unable to sensibly evaluate an\nconstant expression that had to be evaluated. Attempting to divide by 0\nor causing integer overflow are two ways to induce this error. For example:\n\n```compile_fail,E0080\nenum Enum {\n X = (1 << 500),\n Y = (1 / 0)\n}\n```\n\nEnsure that the expressions given can be evaluated as the desired integer type.\nSee the FFI section of the Reference for more information about using a custom\ninteger type:\n\nhttps://doc.rust-lang.org/reference.html#ffi-attributes\n"
},
"level": "error",
"message": "constant evaluation error",
"rendered": null,
"spans": [
{
"byte_end": 39,
"byte_start": 31,
"column_end": 28,
"column_start": 20,
"expansion": null,
"file_name": "src/main.rs",
"is_primary": true,
"label": "index out of bounds: the len is 2 but the index is 4",
"line_end": 2,
"line_start": 2,
"suggested_replacement": null,
"text": [
{
"highlight_end": 28,
"highlight_start": 20,
"text": " static X: u8 = [1,2][4];"
}
]
}
]
},
"package_id": "foo 0.1.0 (path+file:///tmp/foo)",
"reason": "compiler-message",
"target": {
"crate_types": [
"bin"
],
"kind": [
"bin"
],
"name": "foo",
"src_path": "/tmp/foo/src/main.rs"
}
} |
This seems to be the definition of format https://github.com/rust-lang/rust/blob/932c736479f43dc8893a924946e4335d8e308c2e/src/libsyntax/json.rs#L94 |
With the JSON output it would be possible to reorder / tweak messages if needed.
E.g. my IRC bot could use it to prefer showing error messages instead of warnings.
The text was updated successfully, but these errors were encountered: