blob: 1f8febb50f2a524afa078930af81e984fce76fba [file] [log] [blame]
{
"$message_type": "diagnostic",
"children": [
{
"children": [],
"code": null,
"level": "help",
"message": "consider changing this to be mutable",
"rendered": null,
"spans": [
{
"byte_end": 167,
"byte_start": 167,
"column_end": 9,
"column_start": 9,
"expansion": null,
"file_name": "./tests/everything/closure-immutable-outer-variable.rs",
"is_primary": true,
"label": null,
"line_end": 11,
"line_start": 11,
"suggested_replacement": "mut ",
"suggestion_applicability": "MachineApplicable",
"text": [
{
"highlight_end": 9,
"highlight_start": 9,
"text": " let y = true;"
}
]
}
]
}
],
"code": {
"code": "E0594",
"explanation": "A non-mutable value was assigned a value./n/nErroneous code example:/n/n```compile_fail,E0594/nstruct SolarSystem {/n earth: i32,/n}/n/nlet ss = SolarSystem { earth: 3 };/nss.earth = 2; // error!/n```/n/nTo fix this error, declare `ss` as mutable by using the `mut` keyword:/n/n```/nstruct SolarSystem {/n earth: i32,/n}/n/nlet mut ss = SolarSystem { earth: 3 }; // declaring `ss` as mutable/nss.earth = 2; // ok!/n```/n"
},
"level": "error",
"message": "cannot assign to `y`, as it is not declared as mutable",
"rendered": "error[E0594]: cannot assign to `y`, as it is not declared as mutable/n --> ./tests/everything/closure-immutable-outer-variable.rs:12:26/n |/n12 | foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable/n | ^^^^^^^^^ cannot assign/n |/nhelp: consider changing this to be mutable/n |/n11 | let mut y = true;/n | +++/n/n",
"spans": [
{
"byte_end": 211,
"byte_start": 202,
"column_end": 35,
"column_start": 26,
"expansion": null,
"file_name": "./tests/everything/closure-immutable-outer-variable.rs",
"is_primary": true,
"label": "cannot assign",
"line_end": 12,
"line_start": 12,
"suggested_replacement": null,
"suggestion_applicability": null,
"text": [
{
"highlight_end": 35,
"highlight_start": 26,
"text": " foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable"
}
]
}
]
}
{
"$message_type": "diagnostic",
"children": [],
"code": null,
"level": "error",
"message": "aborting due to 1 previous error",
"rendered": "error: aborting due to 1 previous error/n/n",
"spans": []
}
{
"$message_type": "diagnostic",
"children": [],
"code": null,
"level": "failure-note",
"message": "For more information about this error, try `rustc --explain E0594`.",
"rendered": "For more information about this error, try `rustc --explain E0594`./n",
"spans": []
}