-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
This is from linefeed:
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.
Metadata
Metadata
Assignees
Labels
No labels