Skip to content

Commit

Permalink
Add support for the rename item (#7)
Browse files Browse the repository at this point in the history
This PR adds support for the rename item, which allows use crate as _ (importing the crate without importing its name).
  • Loading branch information
pratapsingh1729 authored Nov 10, 2023
1 parent 223251c commit 73910ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ fn to_doc<'a>(
Rule::module => unsupported(pair),
Rule::item_list => unsupported(pair),
Rule::extern_crate => unsupported(pair),
Rule::rename => unsupported(pair),
Rule::rename => map_to_doc(ctx, arena, pair),
Rule::r#use => map_to_doc(ctx, arena, pair),
Rule::use_tree => map_to_doc(ctx, arena, pair),
Rule::use_tree_list => comma_delimited(ctx, arena, pair).braces().group(),
Expand Down
9 changes: 9 additions & 0 deletions tests/rustfmt-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,12 @@ type NoSpaceTypeA=NoSpaceTypeB;
"#;
compare(file);
}

#[test]
fn rust_rename() {
let file = r#"
use crate::parse_serialize::View as _;
use LongLongLongLongLongLongLongLongLongLongType as LongerLongLongLongLongLongLongLongLongLongLongType;
"#;
compare(file);
}

0 comments on commit 73910ea

Please sign in to comment.