about summary refs log tree commit diff
path: root/src/tools/compiletest
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-08-17 21:24:22 +0000
committerbors <bors@rust-lang.org>2018-08-17 21:24:22 +0000
commit1fa944914c092d728c8307e976a4b447df25bf16 (patch)
treeb61dd57fb983082285f9d301c028ae305d391ffe /src/tools/compiletest
parentc8c587fe4ea43afb1c3cf9fe008101f09003ccd1 (diff)
parentd662083a6c78928c70cc74b600205c246dab3bf6 (diff)
downloadrust-1fa944914c092d728c8307e976a4b447df25bf16.tar.gz
rust-1fa944914c092d728c8307e976a4b447df25bf16.zip
Auto merge of #53356 - michaelwoerister:itlto, r=alexcrichton
Preliminary work for incremental ThinLTO (CGU name edition)

Bring back the first half of #52266 but hopefully without the performance regression.
Diffstat (limited to 'src/tools/compiletest')
-rw-r--r--src/tools/compiletest/src/runtest.rs33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 4b246ab6745..b1361730826 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -2209,12 +2209,12 @@ impl<'test> TestCx<'test> {
             .stdout
             .lines()
             .filter(|line| line.starts_with(PREFIX))
-            .map(str_to_mono_item)
+            .map(|line| str_to_mono_item(line, true))
             .collect();
 
         let expected: Vec<MonoItem> = errors::load_errors(&self.testpaths.file, None)
             .iter()
-            .map(|e| str_to_mono_item(&e.msg[..]))
+            .map(|e| str_to_mono_item(&e.msg[..], false))
             .collect();
 
         let mut missing = Vec::new();
@@ -2299,14 +2299,14 @@ impl<'test> TestCx<'test> {
         }
 
         // [MONO_ITEM] name [@@ (cgu)+]
-        fn str_to_mono_item(s: &str) -> MonoItem {
+        fn str_to_mono_item(s: &str, cgu_has_crate_disambiguator: bool) -> MonoItem {
             let s = if s.starts_with(PREFIX) {
                 (&s[PREFIX.len()..]).trim()
             } else {
                 s.trim()
             };
 
-            let full_string = format!("{}{}", PREFIX, s.trim().to_owned());
+            let full_string = format!("{}{}", PREFIX, s);
 
             let parts: Vec<&str> = s
                 .split(CGU_MARKER)
@@ -2323,7 +2323,13 @@ impl<'test> TestCx<'test> {
                     .split(' ')
                     .map(str::trim)
                     .filter(|s| !s.is_empty())
-                    .map(str::to_owned)
+                    .map(|s| {
+                        if cgu_has_crate_disambiguator {
+                            remove_crate_disambiguator_from_cgu(s)
+                        } else {
+                            s.to_string()
+                        }
+                    })
                     .collect()
             } else {
                 HashSet::new()
@@ -2348,6 +2354,23 @@ impl<'test> TestCx<'test> {
 
             string
         }
+
+        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");
+
+            // 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 result = cgu[0 .. disambiguator_start].to_string();
+            result.push_str(&cgu[disambiguator_end ..]);
+
+            result
+        }
     }
 
     fn init_incremental_test(&self) {