diff --git a/src/imports.rs b/src/imports.rs index 61a359a498b..69c7b0ac4ff 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -656,9 +656,16 @@ impl Ord for UseSegment { match (self, other) { (&Slf(ref a), &Slf(ref b)) | (&Super(ref a), &Super(ref b)) - | (&Crate(ref a), &Crate(ref b)) => a.cmp(b), + | (&Crate(ref a), &Crate(ref b)) => match (a, b) { + (Some(sa), Some(sb)) => { + sa.trim_start_matches("r#").cmp(sb.trim_start_matches("r#")) + } + (_, _) => a.cmp(b), + }, (&Glob, &Glob) => Ordering::Equal, - (&Ident(ref ia, ref aa), &Ident(ref ib, ref ab)) => { + (&Ident(ref pia, ref aa), &Ident(ref pib, ref ab)) => { + let ia = pia.trim_start_matches("r#"); + let ib = pib.trim_start_matches("r#"); // snake_case < CamelCase < UPPER_SNAKE_CASE if ia.starts_with(char::is_uppercase) && ib.starts_with(char::is_lowercase) { return Ordering::Greater; @@ -676,13 +683,14 @@ impl Ord for UseSegment { if ident_ord != Ordering::Equal { return ident_ord; } - if aa.is_none() && ab.is_some() { - return Ordering::Less; - } - if aa.is_some() && ab.is_none() { - return Ordering::Greater; + match (aa, ab) { + (None, Some(_)) => Ordering::Less, + (Some(_), None) => Ordering::Greater, + (Some(aas), Some(abs)) => aas + .trim_start_matches("r#") + .cmp(abs.trim_start_matches("r#")), + (None, None) => Ordering::Equal, } - aa.cmp(ab) } (&List(ref a), &List(ref b)) => { for (a, b) in a.iter().zip(b.iter()) { diff --git a/tests/source/imports_raw_identifiers.rs b/tests/source/imports_raw_identifiers.rs new file mode 100644 index 00000000000..c7373f927f5 --- /dev/null +++ b/tests/source/imports_raw_identifiers.rs @@ -0,0 +1,7 @@ +use websocket::client::ClientBuilder; +use websocket::r#async::futures::Stream; +use websocket::result::WebSocketError; + +fn main() { + println!("Hello, world!"); +} diff --git a/tests/target/imports_raw_identifiers.rs b/tests/target/imports_raw_identifiers.rs new file mode 100644 index 00000000000..47f3e209991 --- /dev/null +++ b/tests/target/imports_raw_identifiers.rs @@ -0,0 +1,7 @@ +use websocket::r#async::futures::Stream; +use websocket::client::ClientBuilder; +use websocket::result::WebSocketError; + +fn main() { + println!("Hello, world!"); +}