Run rustfmt on tests/codegen-units/.

This commit is contained in:
Nicholas Nethercote 2024-05-29 14:25:55 +10:00
parent 72800d3b89
commit 780a91786e
32 changed files with 208 additions and 229 deletions

View file

@ -15,7 +15,6 @@ ignore = [
# - some UI tests are broken by different formatting # - some UI tests are broken by different formatting
# - some require special comments in a particular position (e.g. `EMIT_MIR` comments) # - some require special comments in a particular position (e.g. `EMIT_MIR` comments)
"/tests/codegen/simd-intrinsic/", # Many types like `u8x64` are better hand-formatted. "/tests/codegen/simd-intrinsic/", # Many types like `u8x64` are better hand-formatted.
"/tests/codegen-units/",
"/tests/coverage/", "/tests/coverage/",
"/tests/coverage-run-rustdoc/", "/tests/coverage-run-rustdoc/",
"/tests/crashes/", "/tests/crashes/",

View file

@ -4,23 +4,41 @@
pub trait Trait: Sized { pub trait Trait: Sized {
fn without_self() -> u32; fn without_self() -> u32;
fn without_self_default() -> u32 { 0 } fn without_self_default() -> u32 {
0
}
fn with_default_impl(self) -> Self { self } fn with_default_impl(self) -> Self {
fn with_default_impl_generic<T>(self, x: T) -> (Self, T) { (self, x) } self
}
fn with_default_impl_generic<T>(self, x: T) -> (Self, T) {
(self, x)
}
fn without_default_impl(x: u32) -> (Self, u32); fn without_default_impl(x: u32) -> (Self, u32);
fn without_default_impl_generic<T>(x: T) -> (Self, T); fn without_default_impl_generic<T>(x: T) -> (Self, T);
} }
impl Trait for char { impl Trait for char {
fn without_self() -> u32 { 2 } fn without_self() -> u32 {
fn without_default_impl(x: u32) -> (Self, u32) { ('c', x) } 2
fn without_default_impl_generic<T>(x: T) -> (Self, T) { ('c', x) } }
fn without_default_impl(x: u32) -> (Self, u32) {
('c', x)
}
fn without_default_impl_generic<T>(x: T) -> (Self, T) {
('c', x)
}
} }
impl Trait for u32 { impl Trait for u32 {
fn without_self() -> u32 { 1 } fn without_self() -> u32 {
fn without_default_impl(x: u32) -> (Self, u32) { (0, x) } 1
fn without_default_impl_generic<T>(x: T) -> (Self, T) { (0, x) } }
fn without_default_impl(x: u32) -> (Self, u32) {
(0, x)
}
fn without_default_impl_generic<T>(x: T) -> (Self, T) {
(0, x)
}
} }

View file

@ -2,22 +2,19 @@
#[inline] #[inline]
pub fn inlined_fn(x: i32, y: i32) -> i32 { pub fn inlined_fn(x: i32, y: i32) -> i32 {
let closure = |a, b| a + b;
let closure = |a, b| { a + b };
closure(x, y) closure(x, y)
} }
pub fn inlined_fn_generic<T>(x: i32, y: i32, z: T) -> (i32, T) { pub fn inlined_fn_generic<T>(x: i32, y: i32, z: T) -> (i32, T) {
let closure = |a, b| a + b;
let closure = |a, b| { a + b };
(closure(x, y), z) (closure(x, y), z)
} }
pub fn non_inlined_fn(x: i32, y: i32) -> i32 { pub fn non_inlined_fn(x: i32, y: i32) -> i32 {
let closure = |a, b| a + b;
let closure = |a, b| { a + b };
closure(x, y) closure(x, y)
} }

View file

@ -14,7 +14,6 @@ extern crate cgu_extern_closures;
//~ MONO_ITEM fn cross_crate_closures::start[0] //~ MONO_ITEM fn cross_crate_closures::start[0]
#[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[0]
//~ MONO_ITEM fn cgu_extern_closures::inlined_fn[0]::{{closure}}[0] //~ MONO_ITEM fn cgu_extern_closures::inlined_fn[0]::{{closure}}[0]
let _ = cgu_extern_closures::inlined_fn(1, 2); let _ = cgu_extern_closures::inlined_fn(1, 2);

View file

@ -24,8 +24,6 @@ fn start(_: isize, _: *const *const u8) -> isize {
//~ MONO_ITEM fn <char as cgu_export_trait_method::Trait>::with_default_impl //~ MONO_ITEM fn <char as cgu_export_trait_method::Trait>::with_default_impl
let _ = Trait::with_default_impl('c'); let _ = Trait::with_default_impl('c');
//~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::with_default_impl_generic::<&str> //~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::with_default_impl_generic::<&str>
let _ = Trait::with_default_impl_generic(0u32, "abc"); let _ = Trait::with_default_impl_generic(0u32, "abc");
//~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::with_default_impl_generic::<bool> //~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::with_default_impl_generic::<bool>

View file

@ -15,7 +15,6 @@ impl Drop for StructWithDtor {
//~ MONO_ITEM fn start //~ MONO_ITEM fn start
#[start] #[start]
fn start(_: isize, _: *const *const u8) -> isize { fn start(_: isize, _: *const *const u8) -> isize {
//~ MONO_ITEM fn std::ptr::drop_in_place::<[StructWithDtor; 2]> - shim(Some([StructWithDtor; 2])) @@ drop_in_place_intrinsic-cgu.0[Internal] //~ MONO_ITEM fn std::ptr::drop_in_place::<[StructWithDtor; 2]> - shim(Some([StructWithDtor; 2])) @@ drop_in_place_intrinsic-cgu.0[Internal]
let x = [StructWithDtor(0), StructWithDtor(1)]; let x = [StructWithDtor(0), StructWithDtor(1)];

View file

@ -16,7 +16,6 @@ fn take_fn_pointer<T1, T2>(f: fn(T1, T2), x: T1, y: T2) {
//~ MONO_ITEM fn start //~ MONO_ITEM fn start
#[start] #[start]
fn start(_: isize, _: *const *const u8) -> isize { fn start(_: isize, _: *const *const u8) -> isize {
//~ MONO_ITEM fn take_fn_once::<u32, &str, fn(u32, &str) {function::<u32, &str>}> //~ MONO_ITEM fn take_fn_once::<u32, &str, fn(u32, &str) {function::<u32, &str>}>
//~ MONO_ITEM fn function::<u32, &str> //~ MONO_ITEM fn function::<u32, &str>
//~ MONO_ITEM fn <fn(u32, &str) {function::<u32, &str>} as std::ops::FnOnce<(u32, &str)>>::call_once - shim(fn(u32, &str) {function::<u32, &str>}) //~ MONO_ITEM fn <fn(u32, &str) {function::<u32, &str>} as std::ops::FnOnce<(u32, &str)>>::call_once - shim(fn(u32, &str) {function::<u32, &str>})

View file

@ -21,7 +21,7 @@ struct StructNoDrop<T1, T2> {
enum EnumWithDrop<T1, T2> { enum EnumWithDrop<T1, T2> {
A(T1), A(T1),
B(T2) B(T2),
} }
impl<T1, T2> Drop for EnumWithDrop<T1, T2> { impl<T1, T2> Drop for EnumWithDrop<T1, T2> {
@ -30,10 +30,9 @@ impl<T1, T2> Drop for EnumWithDrop<T1, T2> {
enum EnumNoDrop<T1, T2> { enum EnumNoDrop<T1, T2> {
A(T1), A(T1),
B(T2) B(T2),
} }
struct NonGenericNoDrop(#[allow(dead_code)] i32); struct NonGenericNoDrop(#[allow(dead_code)] i32);
struct NonGenericWithDrop(#[allow(dead_code)] i32); struct NonGenericWithDrop(#[allow(dead_code)] i32);
@ -67,24 +66,24 @@ fn start(_: isize, _: *const *const u8) -> isize {
//~ MONO_ITEM fn <EnumWithDrop<i32, i64> as std::ops::Drop>::drop //~ MONO_ITEM fn <EnumWithDrop<i32, i64> as std::ops::Drop>::drop
let _ = match EnumWithDrop::A::<i32, i64>(0) { let _ = match EnumWithDrop::A::<i32, i64>(0) {
EnumWithDrop::A(x) => x, EnumWithDrop::A(x) => x,
EnumWithDrop::B(x) => x as i32 EnumWithDrop::B(x) => x as i32,
}; };
//~ MONO_ITEM fn std::ptr::drop_in_place::<EnumWithDrop<f64, f32>> - shim(Some(EnumWithDrop<f64, f32>)) @@ generic_drop_glue-cgu.0[Internal] //~ MONO_ITEM fn std::ptr::drop_in_place::<EnumWithDrop<f64, f32>> - shim(Some(EnumWithDrop<f64, f32>)) @@ generic_drop_glue-cgu.0[Internal]
//~ MONO_ITEM fn <EnumWithDrop<f64, f32> as std::ops::Drop>::drop //~ MONO_ITEM fn <EnumWithDrop<f64, f32> as std::ops::Drop>::drop
let _ = match EnumWithDrop::B::<f64, f32>(1.0) { let _ = match EnumWithDrop::B::<f64, f32>(1.0) {
EnumWithDrop::A(x) => x, EnumWithDrop::A(x) => x,
EnumWithDrop::B(x) => x as f64 EnumWithDrop::B(x) => x as f64,
}; };
let _ = match EnumNoDrop::A::<i32, i64>(0) { let _ = match EnumNoDrop::A::<i32, i64>(0) {
EnumNoDrop::A(x) => x, EnumNoDrop::A(x) => x,
EnumNoDrop::B(x) => x as i32 EnumNoDrop::B(x) => x as i32,
}; };
let _ = match EnumNoDrop::B::<f64, f32>(1.0) { let _ = match EnumNoDrop::B::<f64, f32>(1.0) {
EnumNoDrop::A(x) => x, EnumNoDrop::A(x) => x,
EnumNoDrop::B(x) => x as f64 EnumNoDrop::B(x) => x as f64,
}; };
0 0

View file

@ -8,15 +8,13 @@ struct Struct<T> {
f: fn(x: T) -> T, f: fn(x: T) -> T,
} }
fn id<T>(x: T) -> T { x } fn id<T>(x: T) -> T {
x
}
impl<T> Struct<T> { impl<T> Struct<T> {
fn new(x: T) -> Struct<T> { fn new(x: T) -> Struct<T> {
Struct { Struct { x: x, f: id }
x: x,
f: id
}
} }
fn get<T2>(self, x: T2) -> (T, T2) { fn get<T2>(self, x: T2) -> (T, T2) {
@ -25,11 +23,10 @@ impl<T> Struct<T> {
} }
pub struct LifeTimeOnly<'a> { pub struct LifeTimeOnly<'a> {
_a: &'a u32 _a: &'a u32,
} }
impl<'a> LifeTimeOnly<'a> { impl<'a> LifeTimeOnly<'a> {
//~ MONO_ITEM fn LifeTimeOnly::<'_>::foo //~ MONO_ITEM fn LifeTimeOnly::<'_>::foo
pub fn foo(&self) {} pub fn foo(&self) {}
//~ MONO_ITEM fn LifeTimeOnly::<'_>::bar //~ MONO_ITEM fn LifeTimeOnly::<'_>::bar

View file

@ -10,11 +10,13 @@ trait Trait {
} }
struct Struct<T> { struct Struct<T> {
_a: T _a: T,
} }
impl<T> Trait for Struct<T> { impl<T> Trait for Struct<T> {
fn foo(&self) -> u32 { 0 } fn foo(&self) -> u32 {
0
}
fn bar(&self) {} fn bar(&self) {}
} }

View file

@ -7,7 +7,7 @@
//~ MONO_ITEM fn std::ptr::drop_in_place::<StructWithDrop> - shim(Some(StructWithDrop)) @@ non_generic_drop_glue-cgu.0[Internal] //~ MONO_ITEM fn std::ptr::drop_in_place::<StructWithDrop> - shim(Some(StructWithDrop)) @@ non_generic_drop_glue-cgu.0[Internal]
struct StructWithDrop { struct StructWithDrop {
x: i32 x: i32,
} }
impl Drop for StructWithDrop { impl Drop for StructWithDrop {
@ -16,12 +16,12 @@ impl Drop for StructWithDrop {
} }
struct StructNoDrop { struct StructNoDrop {
x: i32 x: i32,
} }
//~ MONO_ITEM fn std::ptr::drop_in_place::<EnumWithDrop> - shim(Some(EnumWithDrop)) @@ non_generic_drop_glue-cgu.0[Internal] //~ MONO_ITEM fn std::ptr::drop_in_place::<EnumWithDrop> - shim(Some(EnumWithDrop)) @@ non_generic_drop_glue-cgu.0[Internal]
enum EnumWithDrop { enum EnumWithDrop {
A(i32) A(i32),
} }
impl Drop for EnumWithDrop { impl Drop for EnumWithDrop {
@ -30,7 +30,7 @@ impl Drop for EnumWithDrop {
} }
enum EnumNoDrop { enum EnumNoDrop {
A(i32) A(i32),
} }
//~ MONO_ITEM fn start //~ MONO_ITEM fn start
@ -39,10 +39,10 @@ fn start(_: isize, _: *const *const u8) -> isize {
let _ = StructWithDrop { x: 0 }.x; let _ = StructWithDrop { x: 0 }.x;
let _ = StructNoDrop { x: 0 }.x; let _ = StructNoDrop { x: 0 }.x;
let _ = match EnumWithDrop::A(0) { let _ = match EnumWithDrop::A(0) {
EnumWithDrop::A(x) => x EnumWithDrop::A(x) => x,
}; };
let _ = match EnumNoDrop::A(0) { let _ = match EnumNoDrop::A(0) {
EnumNoDrop::A(x) => x EnumNoDrop::A(x) => x,
}; };
0 0

View file

@ -25,7 +25,9 @@ fn bar() {
baz(); baz();
} }
struct Struct { _x: i32 } struct Struct {
_x: i32,
}
impl Struct { impl Struct {
//~ MONO_ITEM fn Struct::foo //~ MONO_ITEM fn Struct::foo

View file

@ -3,10 +3,10 @@
#![deny(dead_code)] #![deny(dead_code)]
#![crate_type = "lib"] #![crate_type = "lib"]
use std::ops::{Index, IndexMut, Add, Deref}; use std::ops::{Add, Deref, Index, IndexMut};
pub struct Indexable { pub struct Indexable {
data: [u8; 3] data: [u8; 3],
} }
impl Index<usize> for Indexable { impl Index<usize> for Indexable {
@ -14,32 +14,22 @@ impl Index<usize> for Indexable {
//~ MONO_ITEM fn <Indexable as std::ops::Index<usize>>::index //~ MONO_ITEM fn <Indexable as std::ops::Index<usize>>::index
fn index(&self, index: usize) -> &Self::Output { fn index(&self, index: usize) -> &Self::Output {
if index >= 3 { if index >= 3 { &self.data[0] } else { &self.data[index] }
&self.data[0]
} else {
&self.data[index]
}
} }
} }
impl IndexMut<usize> for Indexable { impl IndexMut<usize> for Indexable {
//~ MONO_ITEM fn <Indexable as std::ops::IndexMut<usize>>::index_mut //~ MONO_ITEM fn <Indexable as std::ops::IndexMut<usize>>::index_mut
fn index_mut(&mut self, index: usize) -> &mut Self::Output { fn index_mut(&mut self, index: usize) -> &mut Self::Output {
if index >= 3 { if index >= 3 { &mut self.data[0] } else { &mut self.data[index] }
&mut self.data[0]
} else {
&mut self.data[index]
} }
} }
}
//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::eq //~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::eq
//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::ne //~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::ne
#[derive(PartialEq)] #[derive(PartialEq)]
pub struct Equatable(u32); pub struct Equatable(u32);
impl Add<u32> for Equatable { impl Add<u32> for Equatable {
type Output = u32; type Output = u32;

View file

@ -9,7 +9,6 @@ pub trait SomeTrait {
} }
impl SomeTrait for i64 { impl SomeTrait for i64 {
//~ MONO_ITEM fn <i64 as SomeTrait>::foo //~ MONO_ITEM fn <i64 as SomeTrait>::foo
fn foo(&self) {} fn foo(&self) {}
@ -17,7 +16,6 @@ impl SomeTrait for i64 {
} }
impl SomeTrait for i32 { impl SomeTrait for i32 {
//~ MONO_ITEM fn <i32 as SomeTrait>::foo //~ MONO_ITEM fn <i32 as SomeTrait>::foo
fn foo(&self) {} fn foo(&self) {}
@ -31,7 +29,6 @@ pub trait SomeGenericTrait<T> {
// Concrete impl of generic trait // Concrete impl of generic trait
impl SomeGenericTrait<u32> for f64 { impl SomeGenericTrait<u32> for f64 {
//~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::foo //~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::foo
fn foo(&self, _: u32) {} fn foo(&self, _: u32) {}
@ -40,7 +37,6 @@ impl SomeGenericTrait<u32> for f64 {
// Generic impl of generic trait // Generic impl of generic trait
impl<T> SomeGenericTrait<T> for f32 { impl<T> SomeGenericTrait<T> for f32 {
fn foo(&self, _: T) {} fn foo(&self, _: T) {}
fn bar<T2>(&self, _: T, _: T2) {} fn bar<T2>(&self, _: T, _: T2) {}
} }

View file

@ -4,15 +4,18 @@
#![feature(start)] #![feature(start)]
trait Trait: Sized { trait Trait: Sized {
fn foo(self) -> Self { self } fn foo(self) -> Self {
self
}
} }
impl Trait for u32 { impl Trait for u32 {
fn foo(self) -> u32 { self } fn foo(self) -> u32 {
self
}
} }
impl Trait for char { impl Trait for char {}
}
fn take_foo_once<T, F: FnOnce(T) -> T>(f: F, arg: T) -> T { fn take_foo_once<T, F: FnOnce(T) -> T>(f: F, arg: T) -> T {
(f)(arg) (f)(arg)

View file

@ -5,7 +5,9 @@
trait SomeTrait { trait SomeTrait {
fn foo(&self) {} fn foo(&self) {}
fn bar<T>(&self, x: T) -> T { x } fn bar<T>(&self, x: T) -> T {
x
}
} }
impl SomeTrait for i8 { impl SomeTrait for i8 {

View file

@ -27,7 +27,7 @@ impl Trait for char {
struct Struct<T: ?Sized> { struct Struct<T: ?Sized> {
_a: u32, _a: u32,
_b: i32, _b: i32,
_c: T _c: T,
} }
impl Trait for f64 { impl Trait for f64 {
@ -60,11 +60,7 @@ fn start(_: isize, _: *const *const u8) -> isize {
let _char_unsized = char_sized as &Trait; let _char_unsized = char_sized as &Trait;
// struct field // struct field
let struct_sized = &Struct { let struct_sized = &Struct { _a: 1, _b: 2, _c: 3.0f64 };
_a: 1,
_b: 2,
_c: 3.0f64
};
//~ MONO_ITEM fn std::ptr::drop_in_place::<f64> - shim(None) @@ unsizing-cgu.0[Internal] //~ MONO_ITEM fn std::ptr::drop_in_place::<f64> - shim(None) @@ unsizing-cgu.0[Internal]
//~ MONO_ITEM fn <f64 as Trait>::foo //~ MONO_ITEM fn <f64 as Trait>::foo
let _struct_unsized = struct_sized as &Struct<Trait>; let _struct_unsized = struct_sized as &Struct<Trait>;

View file

@ -16,7 +16,7 @@ pub fn foo<T: Copy>(x: T) -> (T, T) {
} }
pub struct Struct<T> { pub struct Struct<T> {
x: T x: T,
} }
impl<T> Struct<T> { impl<T> Struct<T> {
@ -29,7 +29,7 @@ impl<T> Struct<T> {
pub enum Enum<T> { pub enum Enum<T> {
A(T), A(T),
B { x: T } B { x: T },
} }
impl<T> Enum<T> { impl<T> Enum<T> {
@ -56,7 +56,7 @@ impl<T> TupleStruct<T> {
pub type Pair<T> = (T, T); pub type Pair<T> = (T, T);
pub struct NonGeneric { pub struct NonGeneric {
x: i32 x: i32,
} }
impl NonGeneric { impl NonGeneric {

View file

@ -15,8 +15,7 @@ extern crate cgu_explicit_inlining;
//~ MONO_ITEM fn cgu_explicit_inlining::always_inlined @@ inlining_from_extern_crate[Internal] inlining_from_extern_crate-mod2[Internal] //~ MONO_ITEM fn cgu_explicit_inlining::always_inlined @@ inlining_from_extern_crate[Internal] inlining_from_extern_crate-mod2[Internal]
//~ MONO_ITEM fn user @@ inlining_from_extern_crate[External] //~ MONO_ITEM fn user @@ inlining_from_extern_crate[External]
pub fn user() pub fn user() {
{
cgu_explicit_inlining::inlined(); cgu_explicit_inlining::inlined();
cgu_explicit_inlining::always_inlined(); cgu_explicit_inlining::always_inlined();
@ -28,8 +27,7 @@ pub mod mod1 {
use cgu_explicit_inlining; use cgu_explicit_inlining;
//~ MONO_ITEM fn mod1::user @@ inlining_from_extern_crate-mod1[External] //~ MONO_ITEM fn mod1::user @@ inlining_from_extern_crate-mod1[External]
pub fn user() pub fn user() {
{
cgu_explicit_inlining::inlined(); cgu_explicit_inlining::inlined();
// does not generate a monomorphization in this crate // does not generate a monomorphization in this crate
@ -41,8 +39,7 @@ pub mod mod2 {
use cgu_explicit_inlining; use cgu_explicit_inlining;
//~ MONO_ITEM fn mod2::user @@ inlining_from_extern_crate-mod2[External] //~ MONO_ITEM fn mod2::user @@ inlining_from_extern_crate-mod2[External]
pub fn user() pub fn user() {
{
cgu_explicit_inlining::always_inlined(); cgu_explicit_inlining::always_inlined();
// does not generate a monomorphization in this crate // does not generate a monomorphization in this crate

View file

@ -9,7 +9,9 @@
//~ MONO_ITEM fn generic::<u64> @@ local_generic.volatile[External] //~ MONO_ITEM fn generic::<u64> @@ local_generic.volatile[External]
//~ MONO_ITEM fn generic::<char> @@ local_generic.volatile[External] //~ MONO_ITEM fn generic::<char> @@ local_generic.volatile[External]
//~ MONO_ITEM fn generic::<&str> @@ local_generic.volatile[External] //~ MONO_ITEM fn generic::<&str> @@ local_generic.volatile[External]
pub fn generic<T>(x: T) -> T { x } pub fn generic<T>(x: T) -> T {
x
}
//~ MONO_ITEM fn user @@ local_generic[Internal] //~ MONO_ITEM fn user @@ local_generic[Internal]
fn user() { fn user() {

View file

@ -10,10 +10,7 @@ mod inline {
//~ MONO_ITEM fn inline::inlined_function @@ local_inlining_but_not_all-inline[External] //~ MONO_ITEM fn inline::inlined_function @@ local_inlining_but_not_all-inline[External]
#[inline] #[inline]
pub fn inlined_function() pub fn inlined_function() {}
{
}
} }
pub mod user1 { pub mod user1 {
@ -37,7 +34,5 @@ pub mod user2 {
pub mod non_user { pub mod non_user {
//~ MONO_ITEM fn non_user::baz @@ local_inlining_but_not_all-non_user[External] //~ MONO_ITEM fn non_user::baz @@ local_inlining_but_not_all-non_user[External]
pub fn baz() { pub fn baz() {}
}
} }

View file

@ -11,10 +11,7 @@ mod inline {
// Important: This function should show up in all codegen units where it is inlined // Important: This function should show up in all codegen units where it is inlined
//~ MONO_ITEM fn inline::inlined_function @@ local_inlining-user1[Internal] local_inlining-user2[Internal] //~ MONO_ITEM fn inline::inlined_function @@ local_inlining-user1[Internal] local_inlining-user2[Internal]
#[inline(always)] #[inline(always)]
pub fn inlined_function() pub fn inlined_function() {}
{
}
} }
pub mod user1 { pub mod user1 {
@ -38,7 +35,5 @@ pub mod user2 {
pub mod non_user { pub mod non_user {
//~ MONO_ITEM fn non_user::baz @@ local_inlining-non_user[External] //~ MONO_ITEM fn non_user::baz @@ local_inlining-non_user[External]
pub fn baz() { pub fn baz() {}
}
} }

View file

@ -10,10 +10,7 @@ mod inline {
//~ MONO_ITEM fn inline::inlined_function @@ local_transitive_inlining-indirect_user[Internal] //~ MONO_ITEM fn inline::inlined_function @@ local_transitive_inlining-indirect_user[Internal]
#[inline(always)] #[inline(always)]
pub fn inlined_function() pub fn inlined_function() {}
{
}
} }
mod direct_user { mod direct_user {
@ -38,7 +35,5 @@ pub mod indirect_user {
pub mod non_user { pub mod non_user {
//~ MONO_ITEM fn non_user::baz @@ local_transitive_inlining-non_user[External] //~ MONO_ITEM fn non_user::baz @@ local_transitive_inlining-non_user[External]
pub fn baz() { pub fn baz() {}
}
} }

View file

@ -15,7 +15,7 @@ struct SomeType;
struct SomeGenericType<T1, T2>(T1, T2); struct SomeGenericType<T1, T2>(T1, T2);
mod mod1 { mod mod1 {
use super::{SomeType, SomeGenericType}; 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.
@ -40,8 +40,7 @@ trait Trait {
// We provide an implementation of `Trait` for all types. The corresponding // We provide an implementation of `Trait` for all types. The corresponding
// monomorphizations should end up in whichever module the concrete `T` is. // monomorphizations should end up in whichever module the concrete `T` is.
impl<T> Trait for T impl<T> Trait for T {
{
fn foo(&self) {} fn foo(&self) {}
} }

View file

@ -11,7 +11,6 @@ extern crate shared_generics_aux;
//~ MONO_ITEM fn foo //~ MONO_ITEM fn foo
pub fn foo() { pub fn foo() {
//~ MONO_ITEM fn shared_generics_aux::generic_fn::<u16> @@ shared_generics_aux-in-shared_generics.volatile[External] //~ MONO_ITEM fn shared_generics_aux::generic_fn::<u16> @@ shared_generics_aux-in-shared_generics.volatile[External]
let _ = shared_generics_aux::generic_fn(0u16, 1u16); let _ = shared_generics_aux::generic_fn(0u16, 1u16);

View file

@ -28,20 +28,24 @@ mod mod1 {
} }
impl<T> Trait1Gen<T> for NeedsDrop { impl<T> Trait1Gen<T> for NeedsDrop {
fn do_something(&self, x: T) -> T { x } fn do_something(&self, x: T) -> T {
fn do_something_else(&self, x: T) -> T { x } x
}
fn do_something_else(&self, x: T) -> T {
x
}
} }
//~ MONO_ITEM fn mod1::id::<i64> @@ vtable_through_const-mod1.volatile[Internal] //~ MONO_ITEM fn mod1::id::<i64> @@ vtable_through_const-mod1.volatile[Internal]
fn id<T>(x: T) -> T { x } fn id<T>(x: T) -> T {
x
}
// These are referenced, so they produce mono-items (see start()) // These are referenced, so they produce mono-items (see start())
pub const TRAIT1_REF: &'static Trait1 = &NeedsDrop as &Trait1; pub const TRAIT1_REF: &'static Trait1 = &NeedsDrop as &Trait1;
pub const TRAIT1_GEN_REF: &'static Trait1Gen<u8> = &NeedsDrop as &Trait1Gen<u8>; pub const TRAIT1_GEN_REF: &'static Trait1Gen<u8> = &NeedsDrop as &Trait1Gen<u8>;
pub const ID_CHAR: fn(char) -> char = id::<char>; pub const ID_CHAR: fn(char) -> char = id::<char>;
pub trait Trait2 { pub trait Trait2 {
fn do_something(&self) {} fn do_something(&self) {}
fn do_something_else(&self) {} fn do_something_else(&self) {}
@ -57,8 +61,12 @@ mod mod1 {
} }
impl<T> Trait2Gen<T> for NeedsDrop { impl<T> Trait2Gen<T> for NeedsDrop {
fn do_something(&self, x: T) -> T { x } fn do_something(&self, x: T) -> T {
fn do_something_else(&self, x: T) -> T { x } x
}
fn do_something_else(&self, x: T) -> T {
x
}
} }
// These are not referenced, so they do not produce mono-items // These are not referenced, so they do not produce mono-items

View file

@ -12,8 +12,7 @@ mod functions {
//~ MONO_ITEM fn functions::no_parameters //~ MONO_ITEM fn functions::no_parameters
// Function has an unused type parameter. // Function has an unused type parameter.
pub fn unused<T>() { pub fn unused<T>() {}
}
//~ MONO_ITEM fn functions::unused::<T> //~ MONO_ITEM fn functions::unused::<T>
@ -34,8 +33,7 @@ mod functions {
//~ MONO_ITEM fn functions::used_binding_type::<u64> //~ MONO_ITEM fn functions::used_binding_type::<u64>
// Function uses type parameter in argument. // Function uses type parameter in argument.
pub fn used_argument<T>(_: T) { pub fn used_argument<T>(_: T) {}
}
//~ MONO_ITEM fn functions::used_argument::<u32> //~ MONO_ITEM fn functions::used_argument::<u32>
//~ MONO_ITEM fn functions::used_argument::<u64> //~ MONO_ITEM fn functions::used_argument::<u64>
@ -49,7 +47,6 @@ mod functions {
//~ MONO_ITEM fn functions::used_substs::<u64> //~ MONO_ITEM fn functions::used_substs::<u64>
} }
mod closures { mod closures {
// Function doesn't have any type parameters to be unused. // Function doesn't have any type parameters to be unused.
pub fn no_parameters() { pub fn no_parameters() {
@ -160,14 +157,12 @@ mod methods {
impl<F: Default> Foo<F> { impl<F: Default> Foo<F> {
// Function has an unused type parameter from impl. // Function has an unused type parameter from impl.
pub fn unused_impl() { pub fn unused_impl() {}
}
//~ MONO_ITEM fn methods::Foo::<F>::unused_impl //~ MONO_ITEM fn methods::Foo::<F>::unused_impl
// Function has an unused type parameter from impl and fn. // Function has an unused type parameter from impl and fn.
pub fn unused_both<G: Default>() { pub fn unused_both<G: Default>() {}
}
//~ MONO_ITEM fn methods::Foo::<F>::unused_both::<G> //~ MONO_ITEM fn methods::Foo::<F>::unused_both::<G>
@ -272,8 +267,6 @@ mod methods {
} }
} }
fn dispatch<T: Default>() { fn dispatch<T: Default>() {
functions::no_parameters(); functions::no_parameters();
functions::unused::<T>(); functions::unused::<T>();