about summary refs log tree commit diff
path: root/src/tools/compiletest
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2018-09-12 12:46:48 +0200
committerMichael Woerister <michaelwoerister@posteo>2018-09-12 12:46:48 +0200
commit3beb762dcf2ff721f2c30534ab6ce6b94c3aebaf (patch)
tree77e88e2794da1982b8583bc1c6103eb0d49d9b9e /src/tools/compiletest
parenta2b991b5305b770c7d5288ab3aa231428511c530 (diff)
downloadrust-3beb762dcf2ff721f2c30534ab6ce6b94c3aebaf.tar.gz
rust-3beb762dcf2ff721f2c30534ab6ce6b94c3aebaf.zip
Really make CGU names unique across crates.
Diffstat (limited to 'src/tools/compiletest')
-rw-r--r--src/tools/compiletest/Cargo.toml2
-rw-r--r--src/tools/compiletest/src/main.rs1
-rw-r--r--src/tools/compiletest/src/runtest.rs31
3 files changed, 21 insertions, 13 deletions
diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml
index 7fec2e003a4..0ee31439358 100644
--- a/src/tools/compiletest/Cargo.toml
+++ b/src/tools/compiletest/Cargo.toml
@@ -14,11 +14,11 @@ serde = "1.0"
 serde_json = "1.0"
 serde_derive = "1.0"
 rustfix = "0.4.1"
+lazy_static = "1.0"
 
 [target.'cfg(unix)'.dependencies]
 libc = "0.2"
 
 [target.'cfg(windows)'.dependencies]
-lazy_static = "1.0"
 miow = "0.3"
 winapi = { version = "0.3", features = ["winerror"] }
diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs
index c1d3df79222..a5cf45baa65 100644
--- a/src/tools/compiletest/src/main.rs
+++ b/src/tools/compiletest/src/main.rs
@@ -22,7 +22,6 @@ extern crate libc;
 extern crate log;
 extern crate regex;
 #[macro_use]
-#[cfg(windows)]
 extern crate lazy_static;
 #[macro_use]
 extern crate serde_derive;
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 24b575aae12..2d49c83edb9 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -2355,21 +2355,30 @@ impl<'test> TestCx<'test> {
             string
         }
 
+        // Given a cgu-name-prefix of the form <crate-name>.<crate-disambiguator> or
+        // the form <crate-name1>.<crate-disambiguator1>-in-<crate-name2>.<crate-disambiguator2>,
+        // remove all crate-disambiguators.
         fn remove_crate_disambiguator_from_cgu(cgu: &str) -> String {
-            // The first '.' is the start of the crate disambiguator
-            let disambiguator_start = cgu.find('.')
-                .expect("Could not find start of crate disambiguator in CGU spec");
+            lazy_static! {
+                static ref RE: Regex = Regex::new(
+                    r"^[^\.]+(?P<d1>\.[[:alnum:]]+)(-in-[^\.]+(?P<d2>\.[[:alnum:]]+))?"
+                ).unwrap();
+            }
+
+            let captures = RE.captures(cgu).unwrap_or_else(|| {
+                panic!("invalid cgu name encountered: {}", cgu)
+            });
 
-            // The first non-alphanumeric character is the end of the disambiguator
-            let disambiguator_end = cgu[disambiguator_start + 1 ..]
-                .find(|c| !char::is_alphanumeric(c))
-                .expect("Could not find end of crate disambiguator in CGU spec")
-                + disambiguator_start + 1;
+            let mut new_name = cgu.to_owned();
+
+            if let Some(d2) = captures.name("d2") {
+                new_name.replace_range(d2.start() .. d2.end(), "");
+            }
 
-            let mut result = cgu[0 .. disambiguator_start].to_string();
-            result.push_str(&cgu[disambiguator_end ..]);
+            let d1 = captures.name("d1").unwrap();
+            new_name.replace_range(d1.start() .. d1.end(), "");
 
-            result
+            new_name
         }
     }