File tree 1 file changed +6
-5
lines changed
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -1788,14 +1788,15 @@ fn run_rustfmt(
1788
1788
let file_id = from_proto:: file_id ( snap, & text_document. uri ) ?;
1789
1789
let file = snap. analysis . file_text ( file_id) ?;
1790
1790
1791
- // find the edition of the package the file belongs to
1792
- // (if it belongs to multiple we'll just pick the first one and pray)
1793
- let edition = snap
1791
+ // Determine the edition of the crate the file belongs to (if there's multiple, we pick the
1792
+ // highest edition).
1793
+ let editions = snap
1794
1794
. analysis
1795
1795
. relevant_crates_for ( file_id) ?
1796
1796
. into_iter ( )
1797
- . find_map ( |crate_id| snap. cargo_target_for_crate_root ( crate_id) )
1798
- . map ( |( ws, target) | ws[ ws[ target] . package ] . edition ) ;
1797
+ . map ( |crate_id| snap. analysis . crate_edition ( crate_id) )
1798
+ . collect :: < Result < Vec < _ > , _ > > ( ) ?;
1799
+ let edition = editions. iter ( ) . copied ( ) . max ( ) ;
1799
1800
1800
1801
let line_index = snap. file_line_index ( file_id) ?;
1801
1802
You can’t perform that action at this time.
0 commit comments