Skip to content

Commit c09a8e5

Browse files
Adapt codegen-unit tests to new CGU naming scheme.
1 parent 2d2cd21 commit c09a8e5

File tree

8 files changed

+58
-35
lines changed

8 files changed

+58
-35
lines changed

src/test/codegen-units/item-collection/drop_in_place_intrinsic.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#![feature(start)]
1616

17-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<drop_in_place_intrinsic::StructWithDtor[0]> @@ drop_in_place_intrinsic0[Internal]
17+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<drop_in_place_intrinsic::StructWithDtor[0]> @@ drop_in_place_intrinsic-cgu.0[Internal]
1818
struct StructWithDtor(u32);
1919

2020
impl Drop for StructWithDtor {
@@ -26,7 +26,7 @@ impl Drop for StructWithDtor {
2626
#[start]
2727
fn start(_: isize, _: *const *const u8) -> isize {
2828

29-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<[drop_in_place_intrinsic::StructWithDtor[0]; 2]> @@ drop_in_place_intrinsic0[Internal]
29+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<[drop_in_place_intrinsic::StructWithDtor[0]; 2]> @@ drop_in_place_intrinsic-cgu.0[Internal]
3030
let x = [StructWithDtor(0), StructWithDtor(1)];
3131

3232
drop_slice_in_place(&x);
@@ -40,7 +40,7 @@ fn drop_slice_in_place(x: &[StructWithDtor]) {
4040
// This is the interesting thing in this test case: Normally we would
4141
// not have drop-glue for the unsized [StructWithDtor]. This has to be
4242
// generated though when the drop_in_place() intrinsic is used.
43-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<[drop_in_place_intrinsic::StructWithDtor[0]]> @@ drop_in_place_intrinsic0[Internal]
43+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<[drop_in_place_intrinsic::StructWithDtor[0]]> @@ drop_in_place_intrinsic-cgu.0[Internal]
4444
::std::ptr::drop_in_place(x as *const _ as *mut [StructWithDtor]);
4545
}
4646
}

src/test/codegen-units/item-collection/generic-drop-glue.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ enum EnumNoDrop<T1, T2> {
4747
struct NonGenericNoDrop(i32);
4848

4949
struct NonGenericWithDrop(i32);
50-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::NonGenericWithDrop[0]> @@ generic_drop_glue0[Internal]
50+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::NonGenericWithDrop[0]> @@ generic_drop_glue-cgu.0[Internal]
5151

5252
impl Drop for NonGenericWithDrop {
5353
//~ MONO_ITEM fn generic_drop_glue::{{impl}}[2]::drop[0]
@@ -57,11 +57,11 @@ impl Drop for NonGenericWithDrop {
5757
//~ MONO_ITEM fn generic_drop_glue::start[0]
5858
#[start]
5959
fn start(_: isize, _: *const *const u8) -> isize {
60-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructWithDrop[0]<i8, char>> @@ generic_drop_glue0[Internal]
60+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructWithDrop[0]<i8, char>> @@ generic_drop_glue-cgu.0[Internal]
6161
//~ MONO_ITEM fn generic_drop_glue::{{impl}}[0]::drop[0]<i8, char>
6262
let _ = StructWithDrop { x: 0i8, y: 'a' }.x;
6363

64-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructWithDrop[0]<&str, generic_drop_glue::NonGenericNoDrop[0]>> @@ generic_drop_glue0[Internal]
64+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructWithDrop[0]<&str, generic_drop_glue::NonGenericNoDrop[0]>> @@ generic_drop_glue-cgu.0[Internal]
6565
//~ MONO_ITEM fn generic_drop_glue::{{impl}}[0]::drop[0]<&str, generic_drop_glue::NonGenericNoDrop[0]>
6666
let _ = StructWithDrop { x: "&str", y: NonGenericNoDrop(0) }.y;
6767

@@ -70,17 +70,17 @@ fn start(_: isize, _: *const *const u8) -> isize {
7070

7171
// This is supposed to generate drop-glue because it contains a field that
7272
// needs to be dropped.
73-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructNoDrop[0]<generic_drop_glue::NonGenericWithDrop[0], f64>> @@ generic_drop_glue0[Internal]
73+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructNoDrop[0]<generic_drop_glue::NonGenericWithDrop[0], f64>> @@ generic_drop_glue-cgu.0[Internal]
7474
let _ = StructNoDrop { x: NonGenericWithDrop(0), y: 0f64 }.y;
7575

76-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::EnumWithDrop[0]<i32, i64>> @@ generic_drop_glue0[Internal]
76+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::EnumWithDrop[0]<i32, i64>> @@ generic_drop_glue-cgu.0[Internal]
7777
//~ MONO_ITEM fn generic_drop_glue::{{impl}}[1]::drop[0]<i32, i64>
7878
let _ = match EnumWithDrop::A::<i32, i64>(0) {
7979
EnumWithDrop::A(x) => x,
8080
EnumWithDrop::B(x) => x as i32
8181
};
8282

83-
//~MONO_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::EnumWithDrop[0]<f64, f32>> @@ generic_drop_glue0[Internal]
83+
//~MONO_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::EnumWithDrop[0]<f64, f32>> @@ generic_drop_glue-cgu.0[Internal]
8484
//~ MONO_ITEM fn generic_drop_glue::{{impl}}[1]::drop[0]<f64, f32>
8585
let _ = match EnumWithDrop::B::<f64, f32>(1.0) {
8686
EnumWithDrop::A(x) => x,

src/test/codegen-units/item-collection/instantiation-through-vtable.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ impl<T> Trait for Struct<T> {
3434
fn start(_: isize, _: *const *const u8) -> isize {
3535
let s1 = Struct { _a: 0u32 };
3636

37-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<instantiation_through_vtable::Struct[0]<u32>> @@ instantiation_through_vtable0[Internal]
37+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<instantiation_through_vtable::Struct[0]<u32>> @@ instantiation_through_vtable-cgu.0[Internal]
3838
//~ MONO_ITEM fn instantiation_through_vtable::{{impl}}[0]::foo[0]<u32>
3939
//~ MONO_ITEM fn instantiation_through_vtable::{{impl}}[0]::bar[0]<u32>
4040
let _ = &s1 as &Trait;
4141

4242
let s1 = Struct { _a: 0u64 };
43-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<instantiation_through_vtable::Struct[0]<u64>> @@ instantiation_through_vtable0[Internal]
43+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<instantiation_through_vtable::Struct[0]<u64>> @@ instantiation_through_vtable-cgu.0[Internal]
4444
//~ MONO_ITEM fn instantiation_through_vtable::{{impl}}[0]::foo[0]<u64>
4545
//~ MONO_ITEM fn instantiation_through_vtable::{{impl}}[0]::bar[0]<u64>
4646
let _ = &s1 as &Trait;

src/test/codegen-units/item-collection/non-generic-drop-glue.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#![deny(dead_code)]
1616
#![feature(start)]
1717

18-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<non_generic_drop_glue::StructWithDrop[0]> @@ non_generic_drop_glue0[Internal]
18+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<non_generic_drop_glue::StructWithDrop[0]> @@ non_generic_drop_glue-cgu.0[Internal]
1919
struct StructWithDrop {
2020
x: i32
2121
}
@@ -29,7 +29,7 @@ struct StructNoDrop {
2929
x: i32
3030
}
3131

32-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<non_generic_drop_glue::EnumWithDrop[0]> @@ non_generic_drop_glue0[Internal]
32+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<non_generic_drop_glue::EnumWithDrop[0]> @@ non_generic_drop_glue-cgu.0[Internal]
3333
enum EnumWithDrop {
3434
A(i32)
3535
}

src/test/codegen-units/item-collection/transitive-drop-glue.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
#![deny(dead_code)]
1616
#![feature(start)]
1717

18-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::Root[0]> @@ transitive_drop_glue0[Internal]
18+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::Root[0]> @@ transitive_drop_glue-cgu.0[Internal]
1919
struct Root(Intermediate);
20-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::Intermediate[0]> @@ transitive_drop_glue0[Internal]
20+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::Intermediate[0]> @@ transitive_drop_glue-cgu.0[Internal]
2121
struct Intermediate(Leaf);
22-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::Leaf[0]> @@ transitive_drop_glue0[Internal]
22+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::Leaf[0]> @@ transitive_drop_glue-cgu.0[Internal]
2323
struct Leaf;
2424

2525
impl Drop for Leaf {
@@ -40,15 +40,15 @@ impl<T> Drop for LeafGen<T> {
4040
fn start(_: isize, _: *const *const u8) -> isize {
4141
let _ = Root(Intermediate(Leaf));
4242

43-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::RootGen[0]<u32>> @@ transitive_drop_glue0[Internal]
44-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::IntermediateGen[0]<u32>> @@ transitive_drop_glue0[Internal]
45-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::LeafGen[0]<u32>> @@ transitive_drop_glue0[Internal]
43+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::RootGen[0]<u32>> @@ transitive_drop_glue-cgu.0[Internal]
44+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::IntermediateGen[0]<u32>> @@ transitive_drop_glue-cgu.0[Internal]
45+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::LeafGen[0]<u32>> @@ transitive_drop_glue-cgu.0[Internal]
4646
//~ MONO_ITEM fn transitive_drop_glue::{{impl}}[1]::drop[0]<u32>
4747
let _ = RootGen(IntermediateGen(LeafGen(0u32)));
4848

49-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::RootGen[0]<i16>> @@ transitive_drop_glue0[Internal]
50-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::IntermediateGen[0]<i16>> @@ transitive_drop_glue0[Internal]
51-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::LeafGen[0]<i16>> @@ transitive_drop_glue0[Internal]
49+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::RootGen[0]<i16>> @@ transitive_drop_glue-cgu.0[Internal]
50+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::IntermediateGen[0]<i16>> @@ transitive_drop_glue-cgu.0[Internal]
51+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::LeafGen[0]<i16>> @@ transitive_drop_glue-cgu.0[Internal]
5252
//~ MONO_ITEM fn transitive_drop_glue::{{impl}}[1]::drop[0]<i16>
5353
let _ = RootGen(IntermediateGen(LeafGen(0i16)));
5454

src/test/codegen-units/item-collection/tuple-drop-glue.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#![deny(dead_code)]
1616
#![feature(start)]
1717

18-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<tuple_drop_glue::Dropped[0]> @@ tuple_drop_glue0[Internal]
18+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<tuple_drop_glue::Dropped[0]> @@ tuple_drop_glue-cgu.0[Internal]
1919
struct Dropped;
2020

2121
impl Drop for Dropped {
@@ -26,11 +26,11 @@ impl Drop for Dropped {
2626
//~ MONO_ITEM fn tuple_drop_glue::start[0]
2727
#[start]
2828
fn start(_: isize, _: *const *const u8) -> isize {
29-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<(u32, tuple_drop_glue::Dropped[0])> @@ tuple_drop_glue0[Internal]
29+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<(u32, tuple_drop_glue::Dropped[0])> @@ tuple_drop_glue-cgu.0[Internal]
3030
let x = (0u32, Dropped);
3131

32-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<(i16, (tuple_drop_glue::Dropped[0], bool))> @@ tuple_drop_glue0[Internal]
33-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<(tuple_drop_glue::Dropped[0], bool)> @@ tuple_drop_glue0[Internal]
32+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<(i16, (tuple_drop_glue::Dropped[0], bool))> @@ tuple_drop_glue-cgu.0[Internal]
33+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<(tuple_drop_glue::Dropped[0], bool)> @@ tuple_drop_glue-cgu.0[Internal]
3434
let x = (0i16, (Dropped, true));
3535

3636
0

src/test/codegen-units/item-collection/unsizing.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Wrapper<U>> for Wrapper<T>
5959
fn start(_: isize, _: *const *const u8) -> isize {
6060
// simple case
6161
let bool_sized = &true;
62-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<bool> @@ unsizing0[Internal]
62+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<bool> @@ unsizing-cgu.0[Internal]
6363
//~ MONO_ITEM fn unsizing::{{impl}}[0]::foo[0]
6464
let _bool_unsized = bool_sized as &Trait;
6565

6666
let char_sized = &'a';
6767

68-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<char> @@ unsizing0[Internal]
68+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<char> @@ unsizing-cgu.0[Internal]
6969
//~ MONO_ITEM fn unsizing::{{impl}}[1]::foo[0]
7070
let _char_unsized = char_sized as &Trait;
7171

@@ -75,13 +75,13 @@ fn start(_: isize, _: *const *const u8) -> isize {
7575
_b: 2,
7676
_c: 3.0f64
7777
};
78-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<f64> @@ unsizing0[Internal]
78+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<f64> @@ unsizing-cgu.0[Internal]
7979
//~ MONO_ITEM fn unsizing::{{impl}}[2]::foo[0]
8080
let _struct_unsized = struct_sized as &Struct<Trait>;
8181

8282
// custom coercion
8383
let wrapper_sized = Wrapper(&0u32);
84-
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<u32> @@ unsizing0[Internal]
84+
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<u32> @@ unsizing-cgu.0[Internal]
8585
//~ MONO_ITEM fn unsizing::{{impl}}[3]::foo[0]
8686
let _wrapper_sized = wrapper_sized as Wrapper<Trait>;
8787

src/tools/compiletest/src/runtest.rs

+28-5
Original file line numberDiff line numberDiff line change
@@ -2209,12 +2209,12 @@ impl<'test> TestCx<'test> {
22092209
.stdout
22102210
.lines()
22112211
.filter(|line| line.starts_with(PREFIX))
2212-
.map(str_to_mono_item)
2212+
.map(|line| str_to_mono_item(line, true))
22132213
.collect();
22142214

22152215
let expected: Vec<MonoItem> = errors::load_errors(&self.testpaths.file, None)
22162216
.iter()
2217-
.map(|e| str_to_mono_item(&e.msg[..]))
2217+
.map(|e| str_to_mono_item(&e.msg[..], false))
22182218
.collect();
22192219

22202220
let mut missing = Vec::new();
@@ -2299,14 +2299,14 @@ impl<'test> TestCx<'test> {
22992299
}
23002300

23012301
// [MONO_ITEM] name [@@ (cgu)+]
2302-
fn str_to_mono_item(s: &str) -> MonoItem {
2302+
fn str_to_mono_item(s: &str, cgu_has_crate_disambiguator: bool) -> MonoItem {
23032303
let s = if s.starts_with(PREFIX) {
23042304
(&s[PREFIX.len()..]).trim()
23052305
} else {
23062306
s.trim()
23072307
};
23082308

2309-
let full_string = format!("{}{}", PREFIX, s.trim().to_owned());
2309+
let full_string = format!("{}{}", PREFIX, s);
23102310

23112311
let parts: Vec<&str> = s
23122312
.split(CGU_MARKER)
@@ -2323,7 +2323,13 @@ impl<'test> TestCx<'test> {
23232323
.split(' ')
23242324
.map(str::trim)
23252325
.filter(|s| !s.is_empty())
2326-
.map(str::to_owned)
2326+
.map(|s| {
2327+
if cgu_has_crate_disambiguator {
2328+
remove_crate_disambiguator_from_cgu(s)
2329+
} else {
2330+
s.to_string()
2331+
}
2332+
})
23272333
.collect()
23282334
} else {
23292335
HashSet::new()
@@ -2348,6 +2354,23 @@ impl<'test> TestCx<'test> {
23482354

23492355
string
23502356
}
2357+
2358+
fn remove_crate_disambiguator_from_cgu(cgu: &str) -> String {
2359+
// The first '.' is the start of the crate disambiguator
2360+
let disambiguator_start = cgu.find('.')
2361+
.expect("Could not find start of crate disambiguator in CGU spec");
2362+
2363+
// The first non-alphanumeric character is the end of the disambiguator
2364+
let disambiguator_end = cgu[disambiguator_start + 1 ..]
2365+
.find(|c| !char::is_alphanumeric(c))
2366+
.expect("Could not find end of crate disambiguator in CGU spec")
2367+
+ disambiguator_start + 1;
2368+
2369+
let mut result = cgu[0 .. disambiguator_start].to_string();
2370+
result.push_str(&cgu[disambiguator_end ..]);
2371+
2372+
result
2373+
}
23512374
}
23522375

23532376
fn init_incremental_test(&self) {

0 commit comments

Comments
 (0)