μλ νμΈμ!
μ½λλ₯Ό νμννκΈ° μν΄ vscodeλ₯Ό κ°μ Έμ¬ μ μμ΅λλ€. μ€λ₯λ λ€μκ³Ό κ°μ΅λλ€.
[Trace - 9:32:34 PM] Received response 'textDocument/formatting - (15)' in 0ms. Request failed: Reformat failed to complete successfully (-32603).
[Error - 9:32:34 PM] Request textDocument/formatting failed.
Message: Reformat failed to complete successfully
Code: -32603
cmdλ₯Ό ν΅ν rustftmμ λμΌν νμΌμ ν¬λ§·ν©λλ€.
무μμ νμΈνκ±°λ ꡬμ±ν΄μΌν©λκΉ?
κ°μ¬ν©λλ€!
rustc 1.33.0 (2aa4c46cf 2019-02-28)
rustfmt 1.0.1- μμ (be13559 2018-12-10)
νλ¬Ό 1.33.0 (f099fe94b 2019-02-12)
rustup 1.17.0 (069c88ed6 2019-03-05)
λ°©κΈ VSCode λ° rls-vscode νλ¬κ·ΈμΈμΌλ‘ Rustλ₯Ό λ°°μ°κΈ° μμνκ³ κ°μ μ€λ₯κ° λ°μνμ΅λλ€. μ€λ₯ λ©μμ§λ₯Ό νμΈνλ €λ©΄λ³΄κΈ°>보기 μ΄κΈ°λ₯Ό ν΄λ¦νκ³ μΆλ ₯ (ν¨λ)μ μμ±ν λ€μ Enterλ₯Ό λλ₯΄μμμ€.
Ubuntu Budgie 18.04.2 LTS μ€ν
rustc 1.33.0 (2aa4c46cf 2019-02-28)
rustfmt 1.0.1- μμ (be13559 2018-12-10)
νλ¬Ό 1.33.0 (f099fe94b 2019-02-12)
rustup 1.17.0 (069c88ed6 2019-03-05)
λΆννλ μ΄κ²μ RLS μ체μ λ¬Έμ μ λλ€. λͺ©λ‘μμ λμ μμ€μ΄λ―λ‘ κ³§ ν΄κ²° λ κ²μ λλ€.
μ μ€νΈλ¦Ό λ¬Έμ κ° https://github.com/rust-lang/rls/issues/1397μ λκΉ?
μ΄ λ¬Έμ μ λν μ λ°μ΄νΈκ° μμ΅λκΉ?
μ€λ₯κ° λ°μνμ§ μμ§λ§ νμλ λ΄ μͺ½μμ μ무κ²λνμ§ μμ΅λλ€.
κ°μ μ€λ₯κ° λ°μνμ΅λλ€.
μλ
νλ‘μ νΈ λλ ν 리μμ "νλ¬Ό fmt"λ₯Ό λ°ννμμμ€. νμμ μ¬μ©ν μμλ μ΄μ μ λν μμΈν μ 보λ₯Ό μ 곡ν©λλ€.
μ κ²½μ°μλ ν΄μ²΄μΈμ΄ cargo-fmt.exeλ₯Ό λμ³€μ΅λλ€. κ·Έ ν λͺ
λ Ή μ€κ³Ό vscode λ΄μμ μλνμ΅λλ€.
λλ κ°μ λ¬Έμ κ° μκ³ "cargo fmt"κ° μ μλνκ³ λͺ λ Ή μ€μμ μ€νν λ μ€λ₯κ° μμ΅λλ€. VSCode λ΄μμλ λ§€μ° μ΅κ·ΌκΉμ§ μλνμ§λ§ μ΄μ λ λ§€λ² μμ μ€λ₯κ°λ³΄κ³ λ©λλ€.
μ¬κΈ°μλ cargo fmt
μλνμ§λ§ Format Document
νλ©΄μ΄ μ€λ₯κ° λ°μν©λλ€.
[Error - 4:45:32 PM] Request textDocument/formatting failed.
Message: Reformat failed to complete successfully
Code: -32603
λλ μ¬μ©νκ³ μλ€
rustc 1.37.0 (eae3437df 2019-08-13)
rustfmt 1.3.0-stable (d3345024 2019-06-09)
cargo 1.37.0 (9edd08916 2019-08-02)
λν vscodeμ μν νμ μ€μμλ RLS [building]
μ€νΌλκ° λ³κ²½λμ§ μμΌλ©° μ μ₯ν λ μμ μ€λ₯λ₯Ό μ μΈνκ³ λ μΆλ ₯μ΄ μμμ μμμ΅λλ€.
μ λλ‘ μλνλ VS Code 1.37μ μ€ννλ μ»΄ν¨ν°μ μλνμ§ μλ 1.38.1μ μ€ννλ λ€λ₯Έ μ»΄ν¨ν°κ° μμΌλ―λ‘ μ΄μ λ¬Έμ μμ νκ· ν κ²μ²λΌ 보μ λλ€.
λμ²λΌ Rustλ₯Ό λ°°μ°κΈ° μμν λλ£ μ΄λ³΄μλ₯Όμν κ°λ¨ν κ²½κ³ μ
λλ€. rls-vscode
μ½λ νμμ μ§μ νλ €λ©΄ νλ‘μ νΈμ Cargo.toml νμΌμ΄ νμν κ² κ°μ΅λλ€.
νλ‘μ νΈμ Cargo.toml νμΌμ΄ νμν κ² κ°μ΅λλ€.
Cargo.toml
νμΌμ μ¬μ©ν΄λ μλνμ§ μμ :( macOS 10.15μμ VS Code 1.40.2λ₯Ό μ¬μ©νκ³ μμ΅λλ€-μ무 μΌλ μΌμ΄λμ§ μμ§λ§ rustfmt
μ¬μ©νμ¬ νμμ μ€νν λ μΆλ ₯μ΄ νμλκ±°λ κΈ°λ‘λμ§ μμ΅λλ€ rustfmt
μ λλ‘ μλν©λλ€.
νΈμ§ : κ²°κ΅ μμ -λ΄ VS μ½λ μ€μ μμ κΈ°λ³Έ ν¬λ§·ν°λ‘ μ€μ λμ΄ Prettierκ° μλͺ» μ¬μ©λμμ΅λλ€.
rustfmtκ° μ€ν¨νλ©΄ κ°μ μ€λ₯κ° λ°μν©λλ€. μ κ²½μ°μλ μ΄κ²μ rustfmt μμ΄ λ¬Έμ μ κ΄λ ¨λ κ² κ°μ΅λλ€. νΉνμ΄ μ½λλ‘ μΈν΄ rustfmtκ° μ€ν¨ν©λλ€.
match var.name{
name if
//BAD COMMENT causes fmt error
name.contains("smth")
// other comment
| name.contains("smth else") => {true}
_ => false,
}
λ°μν rls μ€λ₯λ λ§€μ° μ‘°μ©ν©λλ€. μ²μμλ μ€μ μ νμΈνκ³ rustup (λμμ΄λμ§ μμ)μΌλ‘ rustλ₯Ό μ
λ°μ΄νΈνμ΅λλ€.
rustfmtλ₯Ό μ¬μ©νμ¬ μλμΌλ‘ ν¬λ§·νλ©΄ λ€μ μ€λ₯κ° λ°μν©λλ€ (λ°λΌμ rustfmt λ¬Έμ μ λν λ§ν¬).
rustfmt /path/to/file.rs
error[internal]: left behind trailing whitespace
--> /path/to/file.rs:157:157:19
|
157 | name if
| ^
|
warning: rustfmt has failed to format. See previous 1 errors.
μ΄ μ€λ₯κ° μ¬μ ν μμ λμ§ μμ μ΄μ λ 무μμ λκΉ?
κ°μ₯ μ μ©ν λκΈ
μ΄ λ¬Έμ μ λν μ λ°μ΄νΈκ° μμ΅λκΉ?