From b437dca4bd100c0a7a498d5960d566a0ccd92432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Rouill=C3=A9?= Date: Wed, 4 Dec 2019 23:05:01 +0100 Subject: Run rustfmt with respect to Cargo.toml edition --- crates/ra_lsp_server/src/main_loop/handlers.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'crates/ra_lsp_server/src/main_loop/handlers.rs') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index ca47ff5e1..409583634 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -555,12 +555,18 @@ pub fn handle_formatting( let _p = profile("handle_formatting"); let file_id = params.text_document.try_conv_with(&world)?; let file = world.analysis().file_text(file_id)?; + let crate_ids = world.analysis().crate_for(file_id)?; let file_line_index = world.analysis().file_line_index(file_id)?; let end_position = TextUnit::of_str(&file).conv_with(&file_line_index); use std::process; let mut rustfmt = process::Command::new("rustfmt"); + if let Some(&crate_id) = crate_ids.first() { + // Assume all crates are in the same edition + let edition = world.analysis().crate_edition(crate_id)?; + rustfmt.args(&["--edition", &edition.to_string()]); + } rustfmt.stdin(process::Stdio::piped()).stdout(process::Stdio::piped()); if let Ok(path) = params.text_document.uri.to_file_path() { -- cgit v1.2.3