]> git.lizzy.rs Git - rust.git/commitdiff
Don't misplace the :: on associated items.
authorAaron Gallagher <habnabit@google.com>
Tue, 3 May 2016 00:11:22 +0000 (17:11 -0700)
committerAaron Gallagher <habnabit@google.com>
Tue, 3 May 2016 00:11:22 +0000 (17:11 -0700)
The rewritten location of the :: on global paths for qpaths was wrong.

src/types.rs
tests/target/associated-items.rs [new file with mode: 0644]

index a1d449f32492c5d8c38721eb7e83337eedc3300f..cf65f4426b32b678ff98d14f1920186192a98b1e 100644 (file)
@@ -33,7 +33,7 @@ pub fn rewrite_path(context: &RewriteContext,
                     -> Option<String> {
     let skip_count = qself.map_or(0, |x| x.position);
 
-    let mut result = if path.global {
+    let mut result = if path.global && qself.is_none() {
         "::".to_owned()
     } else {
         String::new()
@@ -48,6 +48,9 @@ pub fn rewrite_path(context: &RewriteContext,
 
         if skip_count > 0 {
             result.push_str(" as ");
+            if path.global {
+                result.push_str("::");
+            }
 
             let extra_offset = extra_offset(&result, offset);
             // 3 = ">::".len()
diff --git a/tests/target/associated-items.rs b/tests/target/associated-items.rs
new file mode 100644 (file)
index 0000000..1b0a828
--- /dev/null
@@ -0,0 +1,3 @@
+fn main() {
+    println!("{}", <bool as ::std::default::Default>::default());
+}