{"action":"opened","issue":{"url":"https://api.github.com/repos/rust-lang-nursery/rls/issues/1110","repository_url":"https://api.github.com/repos/rust-lang-nursery/rls","labels_url":"https://api.github.com/repos/rust-lang-nursery/rls/issues/1110/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang-nursery/rls/issues/1110/comments","events_url":"https://api.github.com/repos/rust-lang-nursery/rls/issues/1110/events","html_url":"https://github.com/rust-lang-nursery/rls/issues/1110","id":376359683,"node_id":"MDU6SXNzdWUzNzYzNTk2ODM=","number":1110,"title":"Respect Cargo `[$target-kind.edition]` when formatting a file","user":{"login":"Xanewok","id":3093213,"node_id":"MDQ6VXNlcjMwOTMyMTM=","avatar_url":"https://avatars2.githubusercontent.com/u/3093213?v=4","gravatar_id":"","url":"https://api.github.com/users/Xanewok","html_url":"https://github.com/Xanewok","followers_url":"https://api.github.com/users/Xanewok/followers","following_url":"https://api.github.com/users/Xanewok/following{/other_user}","gists_url":"https://api.github.com/users/Xanewok/gists{/gist_id}","starred_url":"https://api.github.com/users/Xanewok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Xanewok/subscriptions","organizations_url":"https://api.github.com/users/Xanewok/orgs","repos_url":"https://api.github.com/users/Xanewok/repos","events_url":"https://api.github.com/users/Xanewok/events{/privacy}","received_events_url":"https://api.github.com/users/Xanewok/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-01T11:45:45Z","updated_at":"2018-11-01T11:45:45Z","closed_at":null,"author_association":"COLLABORATOR","body":"At the moment we only respect Rustfmt [file configuration](https://github.com/rust-lang-nursery/rls/blob/8a5f3e315ce5db0fbc3b333e67aa31a8de9920f1/src/actions/requests.rs#L750), however it'd be good to also detect crate kind edition if specified in a Cargo.toml and use that as a default.\r\n\r\nNot sure if I'm overthinking this, but it seems it's possible to have two distinct crate targets (e.g. `[[bin]]`) using a different edition but still including the same file - in this case the edition-specific formatting would be ambiguous. What does `cargo fmt` do in this case? I believe Cargo should try to detect that and possibly emit a warning since this could result in some subtle bugs or unexpected behaviour, while RLS should fail and with a message.\r\n\r\nWhile we have the file -> package mapping thanks to project model, since the edition can be specified per crate target we'd need to resolve that information in a more fine-grained way. One way would be to parse the Cargo-emitted `.d` files for bin and libs or use something like [build plan with computed file inputs](https://github.com/rust-lang/cargo/pull/6213) to create a file -> [crate target] mapping.\r\n\r\ncc @otavio "}}
{"actor":{"display_login":"Xanewok"}}