Perf + Test Case RE: ShoyuVanilla

This commit is contained in:
Flora Hill
2026-02-19 23:00:29 +00:00
parent 3a8a3c74f2
commit 102f2ecc91
2 changed files with 15 additions and 5 deletions
@@ -1528,6 +1528,16 @@ fn merge_gated_imports_with_different_values() {
assert_eq!(result, None);
}
#[test]
fn merge_gated_imports_different_order() {
check_merge(
r#"#[cfg(a)] #[cfg(b)] use foo::bar;"#,
r#"#[cfg(b)] #[cfg(a)] use foo::baz;"#,
r#"#[cfg(a)] #[cfg(b)] use foo::{bar, baz};"#,
MergeBehavior::Crate,
);
}
#[test]
fn merge_into_existing_cfg_import() {
check(
@@ -4,7 +4,7 @@
use itertools::{EitherOrBoth, Itertools};
use parser::T;
use syntax::{
Direction, SyntaxElement, algo,
Direction, SyntaxElement, ToSmolStr, algo,
ast::{
self, AstNode, HasAttrs, HasName, HasVisibility, PathSegmentKind, edit_in_place::Removable,
make,
@@ -691,10 +691,10 @@ pub fn eq_attrs(
attrs0: impl Iterator<Item = ast::Attr>,
attrs1: impl Iterator<Item = ast::Attr>,
) -> bool {
let mut attrs0: Vec<_> = attrs0.map(|attr| attr.syntax().text().to_string()).collect();
let mut attrs1: Vec<_> = attrs1.map(|attr| attr.syntax().text().to_string()).collect();
attrs0.sort();
attrs1.sort();
let mut attrs0: Vec<_> = attrs0.map(|attr| attr.syntax().text().to_smolstr()).collect();
let mut attrs1: Vec<_> = attrs1.map(|attr| attr.syntax().text().to_smolstr()).collect();
attrs0.sort_unstable();
attrs1.sort_unstable();
attrs0 == attrs1
}