You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fn read_init(&mut self) {
if let Some(path) = env_init_file() {
// If `INPUTRC` is present, even if invalid, parse nothing else.
// Thus, an empty `INPUTRC` will inhibit loading configuration.
self.read_init_file_if_exists(Some(path));
} else {
if !self.read_init_file_if_exists(user_init_file()) {
self.read_init_file_if_exists(system_init_file());
}
}
}
If you try to collapse this, rustc won't have it:
error[E0301]: cannot mutably borrow in a pattern guard
--> src/reader.rs:2116:20
|
2116 | } else if !self.read_init_file_if_exists(user_init_file()) {
| ^^^^ borrowed mutably in pattern guard
error: aborting due to previous error
The difference appears to be that the else if part of an if let desugars to a guard. And guards appear to have different borrowing rules than simple if expressions (I'm not sure why). Perhaps that is a bug in borrowck, but as long as it is there, we should at least note it in the docs.
The text was updated successfully, but these errors were encountered:
There isn't much explanation about why this is done that way. But it certainly seems surprising because it leads to very unintuitive errors. I think we should report that on rustc's issue tracker.
See also rust-lang/rust#28449.
This is from linefeed:
If you try to collapse this, rustc won't have it:
The difference appears to be that the
else if
part of anif let
desugars to a guard. And guards appear to have different borrowing rules than simpleif
expressions (I'm not sure why). Perhaps that is a bug in borrowck, but as long as it is there, we should at least note it in the docs.The text was updated successfully, but these errors were encountered: