Closed
Description
I tried this code:
let conn = format!("{conn}/sql");
// Create a new terminal REPL
let mut rl = Editor::<()>::new().unwrap();
// Load the command-line history
let _ = rl.load_history("history.txt");
// Loop over each command-line input
loop {
// Prompt the user to input SQL
let readline = rl.readline("> ");
// Check the user input
match readline {
// The user typed a query
Ok(line) => {
// Ignore all empty lines
if line.is_empty() {
continue;
}
// Add the entry to the history
rl.add_history_entry(line.as_str());
// Make a new remote request
let res = Client::new()
.post(&conn)
.header(ACCEPT, "application/json")
.basic_auth(user, Some(pass));
// Add NS header if specified
let res = match ns {
Some(ns) => res.header("NS", ns),
None => res,
};
// Add DB header if specified
let res = match db {
Some(db) => res.header("DB", db),
None => res,
};
// Complete request
let res = res.body(line).send();
// Get the request response
match process(pretty, res) {
Ok(v) => println!("{}", v),
Err(e) => eprintln!("{}", e),
}
}
// The user types CTRL-C
Err(ReadlineError::Interrupted) => {
break;
}
// The user typed CTRL-D
Err(ReadlineError::Eof) => {
break;
}
// There was en error
Err(err) => {
eprintln!("Error: {:?}", err);
break;
}
}
}
This block of code (43):
let res = Client::new()
.post(&conn) // HERE.
.header(ACCEPT, "application/json")
I expected to see this happen:
I used cargo clippy --fix --allow-dirty
and everything fixes correct.
Instead, this happened:
warning: `surrealdb` (lib) generated 6 warnings
warning: failed to automatically apply fixes suggested by rustc to crate `surreal`
after fixes were automatically applied the compiler reported errors within these files:
* src\cli\sql.rs
This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag
The following errors were reported:
error[E0382]: use of moved value: `conn`
--> src\cli\sql.rs:43:12
|
22 | let conn = format!("{conn}/sql");
| ---- move occurs because `conn` has type `std::string::String`, which does not implement the `Copy` trait
...
43 | .post(conn)
| ^^^^ value moved here, in previous iteration of loop
error: aborting due to previous error
For more information about this error, try `rustc --explain E0382`.
Original diagnostics will follow.
Meta
rustc --version --verbose
:
rustc 1.66.0-nightly (1898c34e9 2022-10-26)
binary: rustc
commit-hash: 1898c34e923bad763e723c68dd9f23a09f9eb0fc
commit-date: 2022-10-26
host: x86_64-pc-windows-msvc
release: 1.66.0-nightly
LLVM version: 15.0.2
Backtrace
// NO BACKTRACE IT JUST FALES TO FIX.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Category: This is a bug.Diagnostics: A structured suggestion resulting in incorrect code.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.