That is not your code erroring. Is your ~/.cargo directory or any subdirectory or file within it owned by root by any chance? Cargo and rust-analyzer should never be run as root. Instead you should do cargo build and then run the build output as root yourself.
My system is macOS, and ls seems cannot work to list all privileges the directories have. The rust-analyzer tries to build the code and causes the permission error, which interrupts the type prompt in the vscode.