mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Fix and enable disabled codegen-units tests
This commit is contained in:
parent
ca5d25e2c4
commit
03b6c2f2d4
@ -3027,11 +3027,17 @@ impl<'test> TestCx<'test> {
|
|||||||
const PREFIX: &str = "MONO_ITEM ";
|
const PREFIX: &str = "MONO_ITEM ";
|
||||||
const CGU_MARKER: &str = "@@";
|
const CGU_MARKER: &str = "@@";
|
||||||
|
|
||||||
|
// Some MonoItems can contain {closure@/path/to/checkout/tests/codgen-units/test.rs}
|
||||||
|
// To prevent the current dir from leaking, we just replace the entire path to the test
|
||||||
|
// file with TEST_PATH.
|
||||||
let actual: Vec<MonoItem> = proc_res
|
let actual: Vec<MonoItem> = proc_res
|
||||||
.stdout
|
.stdout
|
||||||
.lines()
|
.lines()
|
||||||
.filter(|line| line.starts_with(PREFIX))
|
.filter(|line| line.starts_with(PREFIX))
|
||||||
.map(|line| str_to_mono_item(line, true))
|
.map(|line| {
|
||||||
|
line.replace(&self.testpaths.file.display().to_string(), "TEST_PATH").to_string()
|
||||||
|
})
|
||||||
|
.map(|line| str_to_mono_item(&line, true))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let expected: Vec<MonoItem> = errors::load_errors(&self.testpaths.file, None)
|
let expected: Vec<MonoItem> = errors::load_errors(&self.testpaths.file, None)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//@ compile-flags: -Zinline-mir=no
|
||||||
|
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
// In the current version of the collector that still has to support
|
// We need to disable MIR inlining in both this and its aux-build crate. The MIR inliner
|
||||||
// legacy-codegen, closures do not generate their own MonoItems, so we are
|
// will just inline everything into our start function if we let it. As it should.
|
||||||
// ignoring this test until MIR codegen has taken over completely
|
//@ compile-flags:-Zprint-mono-items=eager -Zinline-mir=no
|
||||||
//@ ignore-test
|
|
||||||
|
|
||||||
//@ compile-flags:-Zprint-mono-items=eager
|
|
||||||
|
|
||||||
#![deny(dead_code)]
|
#![deny(dead_code)]
|
||||||
#![feature(start)]
|
#![feature(start)]
|
||||||
@ -11,15 +8,15 @@
|
|||||||
//@ aux-build:cgu_extern_closures.rs
|
//@ aux-build:cgu_extern_closures.rs
|
||||||
extern crate cgu_extern_closures;
|
extern crate cgu_extern_closures;
|
||||||
|
|
||||||
//~ MONO_ITEM fn cross_crate_closures::start[0]
|
//~ MONO_ITEM fn start @@ cross_crate_closures-cgu.0[Internal]
|
||||||
#[start]
|
#[start]
|
||||||
fn start(_: isize, _: *const *const u8) -> isize {
|
fn start(_: isize, _: *const *const u8) -> isize {
|
||||||
//~ MONO_ITEM fn cgu_extern_closures::inlined_fn[0]
|
//~ MONO_ITEM fn cgu_extern_closures::inlined_fn @@ cross_crate_closures-cgu.0[Internal]
|
||||||
//~ MONO_ITEM fn cgu_extern_closures::inlined_fn[0]::{{closure}}[0]
|
//~ MONO_ITEM fn cgu_extern_closures::inlined_fn::{closure#0} @@ cross_crate_closures-cgu.0[Internal]
|
||||||
let _ = cgu_extern_closures::inlined_fn(1, 2);
|
let _ = cgu_extern_closures::inlined_fn(1, 2);
|
||||||
|
|
||||||
//~ MONO_ITEM fn cgu_extern_closures::inlined_fn_generic[0]<i32>
|
//~ MONO_ITEM fn cgu_extern_closures::inlined_fn_generic::<i32> @@ cross_crate_closures-cgu.0[Internal]
|
||||||
//~ MONO_ITEM fn cgu_extern_closures::inlined_fn_generic[0]::{{closure}}[0]<i32>
|
//~ MONO_ITEM fn cgu_extern_closures::inlined_fn_generic::<i32>::{closure#0} @@ cross_crate_closures-cgu.0[Internal]
|
||||||
let _ = cgu_extern_closures::inlined_fn_generic(3, 4, 5i32);
|
let _ = cgu_extern_closures::inlined_fn_generic(3, 4, 5i32);
|
||||||
|
|
||||||
// Nothing should be generated for this call, we just link to the instance
|
// Nothing should be generated for this call, we just link to the instance
|
||||||
@ -28,5 +25,3 @@ fn start(_: isize, _: *const *const u8) -> isize {
|
|||||||
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM drop-glue i8
|
|
||||||
|
@ -1,49 +1,45 @@
|
|||||||
// In the current version of the collector that still has to support
|
//@ compile-flags:-Zprint-mono-items=eager -Zinline-mir=no
|
||||||
// legacy-codegen, closures do not generate their own MonoItems, so we are
|
|
||||||
// ignoring this test until MIR codegen has taken over completely
|
|
||||||
//@ ignore-test
|
|
||||||
|
|
||||||
//
|
|
||||||
//@ compile-flags:-Zprint-mono-items=eager
|
|
||||||
|
|
||||||
#![deny(dead_code)]
|
#![deny(dead_code)]
|
||||||
#![feature(start)]
|
#![feature(start)]
|
||||||
|
|
||||||
//~ MONO_ITEM fn non_generic_closures::temporary[0]
|
//~ MONO_ITEM fn temporary @@ non_generic_closures-cgu.0[Internal]
|
||||||
fn temporary() {
|
fn temporary() {
|
||||||
//~ MONO_ITEM fn non_generic_closures::temporary[0]::{{closure}}[0]
|
//~ MONO_ITEM fn temporary::{closure#0} @@ non_generic_closures-cgu.0[Internal]
|
||||||
(|a: u32| {
|
(|a: u32| {
|
||||||
let _ = a;
|
let _ = a;
|
||||||
})(4);
|
})(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn non_generic_closures::assigned_to_variable_but_not_executed[0]
|
//~ MONO_ITEM fn assigned_to_variable_but_not_executed @@ non_generic_closures-cgu.0[Internal]
|
||||||
fn assigned_to_variable_but_not_executed() {
|
fn assigned_to_variable_but_not_executed() {
|
||||||
//~ MONO_ITEM fn non_generic_closures::assigned_to_variable_but_not_executed[0]::{{closure}}[0]
|
|
||||||
let _x = |a: i16| {
|
let _x = |a: i16| {
|
||||||
let _ = a + 1;
|
let _ = a + 1;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn non_generic_closures::assigned_to_variable_executed_directly[0]
|
//~ MONO_ITEM fn assigned_to_variable_executed_indirectly @@ non_generic_closures-cgu.0[Internal]
|
||||||
fn assigned_to_variable_executed_indirectly() {
|
fn assigned_to_variable_executed_indirectly() {
|
||||||
//~ MONO_ITEM fn non_generic_closures::assigned_to_variable_executed_directly[0]::{{closure}}[0]
|
//~ MONO_ITEM fn assigned_to_variable_executed_indirectly::{closure#0} @@ non_generic_closures-cgu.0[Internal]
|
||||||
|
//~ MONO_ITEM fn <{closure@TEST_PATH:27:13: 27:21} as std::ops::FnOnce<(i32,)>>::call_once - shim @@ non_generic_closures-cgu.0[Internal]
|
||||||
|
//~ MONO_ITEM fn <{closure@TEST_PATH:27:13: 27:21} as std::ops::FnOnce<(i32,)>>::call_once - shim(vtable) @@ non_generic_closures-cgu.0[Internal]
|
||||||
|
//~ MONO_ITEM fn std::ptr::drop_in_place::<{closure@TEST_PATH:27:13: 27:21}> - shim(None) @@ non_generic_closures-cgu.0[Internal]
|
||||||
let f = |a: i32| {
|
let f = |a: i32| {
|
||||||
let _ = a + 2;
|
let _ = a + 2;
|
||||||
};
|
};
|
||||||
run_closure(&f);
|
run_closure(&f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn non_generic_closures::assigned_to_variable_executed_indirectly[0]
|
//~ MONO_ITEM fn assigned_to_variable_executed_directly @@ non_generic_closures-cgu.0[Internal]
|
||||||
fn assigned_to_variable_executed_directly() {
|
fn assigned_to_variable_executed_directly() {
|
||||||
//~ MONO_ITEM fn non_generic_closures::assigned_to_variable_executed_indirectly[0]::{{closure}}[0]
|
//~ MONO_ITEM fn assigned_to_variable_executed_directly::{closure#0} @@ non_generic_closures-cgu.0[Internal]
|
||||||
let f = |a: i64| {
|
let f = |a: i64| {
|
||||||
let _ = a + 3;
|
let _ = a + 3;
|
||||||
};
|
};
|
||||||
f(4);
|
f(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn non_generic_closures::start[0]
|
//~ MONO_ITEM fn start @@ non_generic_closures-cgu.0[Internal]
|
||||||
#[start]
|
#[start]
|
||||||
fn start(_: isize, _: *const *const u8) -> isize {
|
fn start(_: isize, _: *const *const u8) -> isize {
|
||||||
temporary();
|
temporary();
|
||||||
@ -54,7 +50,7 @@ fn start(_: isize, _: *const *const u8) -> isize {
|
|||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn non_generic_closures::run_closure[0]
|
//~ MONO_ITEM fn run_closure @@ non_generic_closures-cgu.0[Internal]
|
||||||
fn run_closure(f: &Fn(i32)) {
|
fn run_closure(f: &Fn(i32)) {
|
||||||
f(3);
|
f(3);
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,23 @@
|
|||||||
// Currently, all generic functions are instantiated in each codegen unit that
|
|
||||||
// uses them, even those not marked with #[inline], so this test does not make
|
|
||||||
// much sense at the moment.
|
|
||||||
//@ ignore-test
|
|
||||||
|
|
||||||
// We specify incremental here because we want to test the partitioning for incremental compilation
|
// We specify incremental here because we want to test the partitioning for incremental compilation
|
||||||
//@ incremental
|
//@ incremental
|
||||||
//@ compile-flags:-Zprint-mono-items=lazy
|
//@ compile-flags:-Zprint-mono-items=lazy
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![crate_type = "lib"]
|
||||||
#![feature(start)]
|
|
||||||
|
|
||||||
struct SomeType;
|
pub struct SomeType;
|
||||||
|
|
||||||
struct SomeGenericType<T1, T2>(T1, T2);
|
struct SomeGenericType<T1, T2>(T1, T2);
|
||||||
|
|
||||||
mod mod1 {
|
pub mod mod1 {
|
||||||
use super::{SomeGenericType, SomeType};
|
use super::{SomeGenericType, SomeType};
|
||||||
|
|
||||||
// Even though the impl is in `mod1`, the methods should end up in the
|
// Even though the impl is in `mod1`, the methods should end up in the
|
||||||
// parent module, since that is where their self-type is.
|
// parent module, since that is where their self-type is.
|
||||||
impl SomeType {
|
impl SomeType {
|
||||||
//~ MONO_ITEM fn methods_are_with_self_type::mod1[0]::{{impl}}[0]::method[0] @@ methods_are_with_self_type[External]
|
//~ MONO_ITEM fn mod1::<impl SomeType>::method @@ methods_are_with_self_type[External]
|
||||||
fn method(&self) {}
|
pub fn method(&self) {}
|
||||||
|
//~ MONO_ITEM fn mod1::<impl SomeType>::associated_fn @@ methods_are_with_self_type[External]
|
||||||
//~ MONO_ITEM fn methods_are_with_self_type::mod1[0]::{{impl}}[0]::associated_fn[0] @@ methods_are_with_self_type[External]
|
pub fn associated_fn() {}
|
||||||
fn associated_fn() {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T1, T2> SomeGenericType<T1, T2> {
|
impl<T1, T2> SomeGenericType<T1, T2> {
|
||||||
@ -52,25 +45,20 @@ mod type2 {
|
|||||||
pub struct Struct;
|
pub struct Struct;
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn methods_are_with_self_type::start[0]
|
//~ MONO_ITEM fn start @@ methods_are_with_self_type[External]
|
||||||
#[start]
|
pub fn start() {
|
||||||
fn start(_: isize, _: *const *const u8) -> isize {
|
//~ MONO_ITEM fn mod1::<impl SomeGenericType<u32, u64>>::method @@ methods_are_with_self_type.volatile[External]
|
||||||
//~ MONO_ITEM fn methods_are_with_self_type::mod1[0]::{{impl}}[1]::method[0]<u32, u64> @@ methods_are_with_self_type.volatile[WeakODR]
|
|
||||||
SomeGenericType(0u32, 0u64).method();
|
SomeGenericType(0u32, 0u64).method();
|
||||||
//~ MONO_ITEM fn methods_are_with_self_type::mod1[0]::{{impl}}[1]::associated_fn[0]<char, &str> @@ methods_are_with_self_type.volatile[WeakODR]
|
//~ MONO_ITEM fn mod1::<impl SomeGenericType<char, &str>>::associated_fn @@ methods_are_with_self_type.volatile[External]
|
||||||
SomeGenericType::associated_fn('c', "&str");
|
SomeGenericType::associated_fn('c', "&str");
|
||||||
|
|
||||||
//~ MONO_ITEM fn methods_are_with_self_type::{{impl}}[0]::foo[0]<methods_are_with_self_type::type1[0]::Struct[0]> @@ methods_are_with_self_type-type1.volatile[WeakODR]
|
//~ MONO_ITEM fn <type1::Struct as Trait>::foo @@ methods_are_with_self_type-type1.volatile[External]
|
||||||
type1::Struct.foo();
|
type1::Struct.foo();
|
||||||
//~ MONO_ITEM fn methods_are_with_self_type::{{impl}}[0]::foo[0]<methods_are_with_self_type::type2[0]::Struct[0]> @@ methods_are_with_self_type-type2.volatile[WeakODR]
|
//~ MONO_ITEM fn <type2::Struct as Trait>::foo @@ methods_are_with_self_type-type2.volatile[External]
|
||||||
type2::Struct.foo();
|
type2::Struct.foo();
|
||||||
|
|
||||||
//~ MONO_ITEM fn methods_are_with_self_type::Trait[0]::default[0]<methods_are_with_self_type::type1[0]::Struct[0]> @@ methods_are_with_self_type-type1.volatile[WeakODR]
|
//~ MONO_ITEM fn <type1::Struct as Trait>::default @@ methods_are_with_self_type-type1.volatile[External]
|
||||||
type1::Struct.default();
|
type1::Struct.default();
|
||||||
//~ MONO_ITEM fn methods_are_with_self_type::Trait[0]::default[0]<methods_are_with_self_type::type2[0]::Struct[0]> @@ methods_are_with_self_type-type2.volatile[WeakODR]
|
//~ MONO_ITEM fn <type2::Struct as Trait>::default @@ methods_are_with_self_type-type2.volatile[External]
|
||||||
type2::Struct.default();
|
type2::Struct.default();
|
||||||
|
|
||||||
0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM drop-glue i8
|
|
||||||
|
Loading…
Reference in New Issue
Block a user