diff --git a/rustfmt.toml b/rustfmt.toml index 24d300e91fa..5f40abcbaa5 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -15,7 +15,6 @@ ignore = [ # - some UI tests are broken by different formatting # - 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-units/", "/tests/coverage/", "/tests/coverage-run-rustdoc/", "/tests/crashes/", diff --git a/tests/codegen-units/item-collection/auxiliary/cgu_export_trait_method.rs b/tests/codegen-units/item-collection/auxiliary/cgu_export_trait_method.rs index 5566bb4e4b2..1992baf8c76 100644 --- a/tests/codegen-units/item-collection/auxiliary/cgu_export_trait_method.rs +++ b/tests/codegen-units/item-collection/auxiliary/cgu_export_trait_method.rs @@ -2,25 +2,43 @@ #![crate_type = "lib"] -pub trait Trait : Sized { +pub trait Trait: Sized { 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_generic(self, x: T) -> (Self, T) { (self, x) } + fn with_default_impl(self) -> Self { + self + } + fn with_default_impl_generic(self, x: T) -> (Self, T) { + (self, x) + } fn without_default_impl(x: u32) -> (Self, u32); fn without_default_impl_generic(x: T) -> (Self, T); } impl Trait for char { - fn without_self() -> u32 { 2 } - fn without_default_impl(x: u32) -> (Self, u32) { ('c', x) } - fn without_default_impl_generic(x: T) -> (Self, T) { ('c', x) } + fn without_self() -> u32 { + 2 + } + fn without_default_impl(x: u32) -> (Self, u32) { + ('c', x) + } + fn without_default_impl_generic(x: T) -> (Self, T) { + ('c', x) + } } impl Trait for u32 { - fn without_self() -> u32 { 1 } - fn without_default_impl(x: u32) -> (Self, u32) { (0, x) } - fn without_default_impl_generic(x: T) -> (Self, T) { (0, x) } + fn without_self() -> u32 { + 1 + } + fn without_default_impl(x: u32) -> (Self, u32) { + (0, x) + } + fn without_default_impl_generic(x: T) -> (Self, T) { + (0, x) + } } diff --git a/tests/codegen-units/item-collection/auxiliary/cgu_extern_closures.rs b/tests/codegen-units/item-collection/auxiliary/cgu_extern_closures.rs index 05ea0a89ff2..0192a3d4188 100644 --- a/tests/codegen-units/item-collection/auxiliary/cgu_extern_closures.rs +++ b/tests/codegen-units/item-collection/auxiliary/cgu_extern_closures.rs @@ -2,22 +2,19 @@ #[inline] pub fn inlined_fn(x: i32, y: i32) -> i32 { - - let closure = |a, b| { a + b }; + let closure = |a, b| a + b; closure(x, y) } pub fn inlined_fn_generic(x: i32, y: i32, z: T) -> (i32, T) { - - let closure = |a, b| { a + b }; + let closure = |a, b| a + b; (closure(x, y), z) } 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) } diff --git a/tests/codegen-units/item-collection/cross-crate-closures.rs b/tests/codegen-units/item-collection/cross-crate-closures.rs index 4ec7f17d584..2dab19401ed 100644 --- a/tests/codegen-units/item-collection/cross-crate-closures.rs +++ b/tests/codegen-units/item-collection/cross-crate-closures.rs @@ -14,7 +14,6 @@ //~ MONO_ITEM fn cross_crate_closures::start[0] #[start] 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]::{{closure}}[0] let _ = cgu_extern_closures::inlined_fn(1, 2); diff --git a/tests/codegen-units/item-collection/cross-crate-trait-method.rs b/tests/codegen-units/item-collection/cross-crate-trait-method.rs index 84977328e49..99777760315 100644 --- a/tests/codegen-units/item-collection/cross-crate-trait-method.rs +++ b/tests/codegen-units/item-collection/cross-crate-trait-method.rs @@ -24,8 +24,6 @@ fn start(_: isize, _: *const *const u8) -> isize { //~ MONO_ITEM fn ::with_default_impl let _ = Trait::with_default_impl('c'); - - //~ MONO_ITEM fn ::with_default_impl_generic::<&str> let _ = Trait::with_default_impl_generic(0u32, "abc"); //~ MONO_ITEM fn ::with_default_impl_generic:: diff --git a/tests/codegen-units/item-collection/drop_in_place_intrinsic.rs b/tests/codegen-units/item-collection/drop_in_place_intrinsic.rs index 66dcda26066..947faa165a9 100644 --- a/tests/codegen-units/item-collection/drop_in_place_intrinsic.rs +++ b/tests/codegen-units/item-collection/drop_in_place_intrinsic.rs @@ -15,7 +15,6 @@ fn drop(&mut self) {} //~ MONO_ITEM fn start #[start] 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] let x = [StructWithDtor(0), StructWithDtor(1)]; diff --git a/tests/codegen-units/item-collection/function-as-argument.rs b/tests/codegen-units/item-collection/function-as-argument.rs index 4e6fd99d29e..4be713dc367 100644 --- a/tests/codegen-units/item-collection/function-as-argument.rs +++ b/tests/codegen-units/item-collection/function-as-argument.rs @@ -16,7 +16,6 @@ fn take_fn_pointer(f: fn(T1, T2), x: T1, y: T2) { //~ MONO_ITEM fn start #[start] fn start(_: isize, _: *const *const u8) -> isize { - //~ MONO_ITEM fn take_fn_once::}> //~ MONO_ITEM fn function:: //~ MONO_ITEM fn } as std::ops::FnOnce<(u32, &str)>>::call_once - shim(fn(u32, &str) {function::}) diff --git a/tests/codegen-units/item-collection/generic-drop-glue.rs b/tests/codegen-units/item-collection/generic-drop-glue.rs index 99250dc7dc6..d861d269fae 100644 --- a/tests/codegen-units/item-collection/generic-drop-glue.rs +++ b/tests/codegen-units/item-collection/generic-drop-glue.rs @@ -21,7 +21,7 @@ struct StructNoDrop { enum EnumWithDrop { A(T1), - B(T2) + B(T2), } impl Drop for EnumWithDrop { @@ -30,10 +30,9 @@ fn drop(&mut self) {} enum EnumNoDrop { A(T1), - B(T2) + B(T2), } - struct NonGenericNoDrop(#[allow(dead_code)] i32); struct NonGenericWithDrop(#[allow(dead_code)] i32); @@ -67,24 +66,24 @@ fn start(_: isize, _: *const *const u8) -> isize { //~ MONO_ITEM fn as std::ops::Drop>::drop let _ = match EnumWithDrop::A::(0) { EnumWithDrop::A(x) => x, - EnumWithDrop::B(x) => x as i32 + EnumWithDrop::B(x) => x as i32, }; //~ MONO_ITEM fn std::ptr::drop_in_place::> - shim(Some(EnumWithDrop)) @@ generic_drop_glue-cgu.0[Internal] //~ MONO_ITEM fn as std::ops::Drop>::drop let _ = match EnumWithDrop::B::(1.0) { EnumWithDrop::A(x) => x, - EnumWithDrop::B(x) => x as f64 + EnumWithDrop::B(x) => x as f64, }; let _ = match EnumNoDrop::A::(0) { EnumNoDrop::A(x) => x, - EnumNoDrop::B(x) => x as i32 + EnumNoDrop::B(x) => x as i32, }; let _ = match EnumNoDrop::B::(1.0) { EnumNoDrop::A(x) => x, - EnumNoDrop::B(x) => x as f64 + EnumNoDrop::B(x) => x as f64, }; 0 diff --git a/tests/codegen-units/item-collection/generic-impl.rs b/tests/codegen-units/item-collection/generic-impl.rs index 6e60907c185..23d09e0d8af 100644 --- a/tests/codegen-units/item-collection/generic-impl.rs +++ b/tests/codegen-units/item-collection/generic-impl.rs @@ -8,15 +8,13 @@ struct Struct { f: fn(x: T) -> T, } -fn id(x: T) -> T { x } +fn id(x: T) -> T { + x +} impl Struct { - fn new(x: T) -> Struct { - Struct { - x: x, - f: id - } + Struct { x: x, f: id } } fn get(self, x: T2) -> (T, T2) { @@ -25,11 +23,10 @@ fn get(self, x: T2) -> (T, T2) { } pub struct LifeTimeOnly<'a> { - _a: &'a u32 + _a: &'a u32, } impl<'a> LifeTimeOnly<'a> { - //~ MONO_ITEM fn LifeTimeOnly::<'_>::foo pub fn foo(&self) {} //~ MONO_ITEM fn LifeTimeOnly::<'_>::bar diff --git a/tests/codegen-units/item-collection/instantiation-through-vtable.rs b/tests/codegen-units/item-collection/instantiation-through-vtable.rs index 08e8c03a732..59dd4311a03 100644 --- a/tests/codegen-units/item-collection/instantiation-through-vtable.rs +++ b/tests/codegen-units/item-collection/instantiation-through-vtable.rs @@ -10,11 +10,13 @@ trait Trait { } struct Struct { - _a: T + _a: T, } impl Trait for Struct { - fn foo(&self) -> u32 { 0 } + fn foo(&self) -> u32 { + 0 + } fn bar(&self) {} } diff --git a/tests/codegen-units/item-collection/non-generic-drop-glue.rs b/tests/codegen-units/item-collection/non-generic-drop-glue.rs index d74b17463bf..f7bb2f3f2f4 100644 --- a/tests/codegen-units/item-collection/non-generic-drop-glue.rs +++ b/tests/codegen-units/item-collection/non-generic-drop-glue.rs @@ -7,7 +7,7 @@ //~ MONO_ITEM fn std::ptr::drop_in_place:: - shim(Some(StructWithDrop)) @@ non_generic_drop_glue-cgu.0[Internal] struct StructWithDrop { - x: i32 + x: i32, } impl Drop for StructWithDrop { @@ -16,12 +16,12 @@ fn drop(&mut self) {} } struct StructNoDrop { - x: i32 + x: i32, } //~ MONO_ITEM fn std::ptr::drop_in_place:: - shim(Some(EnumWithDrop)) @@ non_generic_drop_glue-cgu.0[Internal] enum EnumWithDrop { - A(i32) + A(i32), } impl Drop for EnumWithDrop { @@ -30,7 +30,7 @@ fn drop(&mut self) {} } enum EnumNoDrop { - A(i32) + A(i32), } //~ MONO_ITEM fn start @@ -39,10 +39,10 @@ fn start(_: isize, _: *const *const u8) -> isize { let _ = StructWithDrop { x: 0 }.x; let _ = StructNoDrop { x: 0 }.x; let _ = match EnumWithDrop::A(0) { - EnumWithDrop::A(x) => x + EnumWithDrop::A(x) => x, }; let _ = match EnumNoDrop::A(0) { - EnumNoDrop::A(x) => x + EnumNoDrop::A(x) => x, }; 0 diff --git a/tests/codegen-units/item-collection/non-generic-functions.rs b/tests/codegen-units/item-collection/non-generic-functions.rs index 49a999a0d7c..d4d7d221827 100644 --- a/tests/codegen-units/item-collection/non-generic-functions.rs +++ b/tests/codegen-units/item-collection/non-generic-functions.rs @@ -25,7 +25,9 @@ fn baz() {} baz(); } -struct Struct { _x: i32 } +struct Struct { + _x: i32, +} impl Struct { //~ MONO_ITEM fn Struct::foo diff --git a/tests/codegen-units/item-collection/overloaded-operators.rs b/tests/codegen-units/item-collection/overloaded-operators.rs index 23141c27de6..69b55695d3d 100644 --- a/tests/codegen-units/item-collection/overloaded-operators.rs +++ b/tests/codegen-units/item-collection/overloaded-operators.rs @@ -1,12 +1,12 @@ //@ compile-flags:-Zprint-mono-items=eager #![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 { - data: [u8; 3] + data: [u8; 3], } impl Index for Indexable { @@ -14,32 +14,22 @@ impl Index for Indexable { //~ MONO_ITEM fn >::index fn index(&self, index: usize) -> &Self::Output { - if index >= 3 { - &self.data[0] - } else { - &self.data[index] - } + if index >= 3 { &self.data[0] } else { &self.data[index] } } } impl IndexMut for Indexable { //~ MONO_ITEM fn >::index_mut fn index_mut(&mut self, index: usize) -> &mut Self::Output { - if index >= 3 { - &mut self.data[0] - } else { - &mut self.data[index] - } + if index >= 3 { &mut self.data[0] } else { &mut self.data[index] } } } - //~ MONO_ITEM fn ::eq //~ MONO_ITEM fn ::ne #[derive(PartialEq)] pub struct Equatable(u32); - impl Add for Equatable { type Output = u32; diff --git a/tests/codegen-units/item-collection/static-init.rs b/tests/codegen-units/item-collection/static-init.rs index b357f5cd66b..1406fba2b98 100644 --- a/tests/codegen-units/item-collection/static-init.rs +++ b/tests/codegen-units/item-collection/static-init.rs @@ -2,9 +2,9 @@ #![feature(start)] -pub static FN : fn() = foo::; +pub static FN: fn() = foo::; -pub fn foo() { } +pub fn foo() {} //~ MONO_ITEM fn foo:: //~ MONO_ITEM static FN diff --git a/tests/codegen-units/item-collection/trait-implementations.rs b/tests/codegen-units/item-collection/trait-implementations.rs index b364cc5b333..e4c444499e0 100644 --- a/tests/codegen-units/item-collection/trait-implementations.rs +++ b/tests/codegen-units/item-collection/trait-implementations.rs @@ -9,7 +9,6 @@ pub trait SomeTrait { } impl SomeTrait for i64 { - //~ MONO_ITEM fn ::foo fn foo(&self) {} @@ -17,7 +16,6 @@ fn bar(&self, _: T) {} } impl SomeTrait for i32 { - //~ MONO_ITEM fn ::foo fn foo(&self) {} @@ -31,7 +29,6 @@ pub trait SomeGenericTrait { // Concrete impl of generic trait impl SomeGenericTrait for f64 { - //~ MONO_ITEM fn >::foo fn foo(&self, _: u32) {} @@ -40,7 +37,6 @@ fn bar(&self, _: u32, _: T2) {} // Generic impl of generic trait impl SomeGenericTrait for f32 { - fn foo(&self, _: T) {} fn bar(&self, _: T, _: T2) {} } @@ -48,26 +44,26 @@ fn bar(&self, _: T, _: T2) {} //~ MONO_ITEM fn start #[start] fn start(_: isize, _: *const *const u8) -> isize { - //~ MONO_ITEM fn ::bar:: - 0i32.bar('x'); + //~ MONO_ITEM fn ::bar:: + 0i32.bar('x'); - //~ MONO_ITEM fn >::bar::<&str> - 0f64.bar(0u32, "&str"); + //~ MONO_ITEM fn >::bar::<&str> + 0f64.bar(0u32, "&str"); - //~ MONO_ITEM fn >::bar::<()> - 0f64.bar(0u32, ()); + //~ MONO_ITEM fn >::bar::<()> + 0f64.bar(0u32, ()); - //~ MONO_ITEM fn >::foo - 0f32.foo('x'); + //~ MONO_ITEM fn >::foo + 0f32.foo('x'); - //~ MONO_ITEM fn >::foo - 0f32.foo(-1i64); + //~ MONO_ITEM fn >::foo + 0f32.foo(-1i64); - //~ MONO_ITEM fn >::bar::<()> - 0f32.bar(0u32, ()); + //~ MONO_ITEM fn >::bar::<()> + 0f32.bar(0u32, ()); - //~ MONO_ITEM fn >::bar::<&str> - 0f32.bar("&str", "&str"); + //~ MONO_ITEM fn >::bar::<&str> + 0f32.bar("&str", "&str"); - 0 + 0 } diff --git a/tests/codegen-units/item-collection/trait-method-as-argument.rs b/tests/codegen-units/item-collection/trait-method-as-argument.rs index c25e3ea45ec..10cf2a0e967 100644 --- a/tests/codegen-units/item-collection/trait-method-as-argument.rs +++ b/tests/codegen-units/item-collection/trait-method-as-argument.rs @@ -3,16 +3,19 @@ #![deny(dead_code)] #![feature(start)] -trait Trait : Sized { - fn foo(self) -> Self { self } +trait Trait: Sized { + fn foo(self) -> Self { + self + } } 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: F, arg: T) -> T { (f)(arg) diff --git a/tests/codegen-units/item-collection/trait-method-default-impl.rs b/tests/codegen-units/item-collection/trait-method-default-impl.rs index 89fec350f09..b0a43d28e40 100644 --- a/tests/codegen-units/item-collection/trait-method-default-impl.rs +++ b/tests/codegen-units/item-collection/trait-method-default-impl.rs @@ -4,8 +4,10 @@ #![feature(start)] trait SomeTrait { - fn foo(&self) { } - fn bar(&self, x: T) -> T { x } + fn foo(&self) {} + fn bar(&self, x: T) -> T { + x + } } impl SomeTrait for i8 { @@ -17,7 +19,7 @@ impl SomeTrait for i8 { } trait SomeGenericTrait { - fn foo(&self) { } + fn foo(&self) {} fn bar(&self, x: T1, y: T2) {} } diff --git a/tests/codegen-units/item-collection/unsizing.rs b/tests/codegen-units/item-collection/unsizing.rs index 1e2d7f17484..5ea8b47962a 100644 --- a/tests/codegen-units/item-collection/unsizing.rs +++ b/tests/codegen-units/item-collection/unsizing.rs @@ -27,7 +27,7 @@ fn foo(&self) {} struct Struct { _a: u32, _b: i32, - _c: T + _c: T, } impl Trait for f64 { @@ -60,11 +60,7 @@ fn start(_: isize, _: *const *const u8) -> isize { let _char_unsized = char_sized as &Trait; // struct field - let struct_sized = &Struct { - _a: 1, - _b: 2, - _c: 3.0f64 - }; + let struct_sized = &Struct { _a: 1, _b: 2, _c: 3.0f64 }; //~ MONO_ITEM fn std::ptr::drop_in_place:: - shim(None) @@ unsizing-cgu.0[Internal] //~ MONO_ITEM fn ::foo let _struct_unsized = struct_sized as &Struct; diff --git a/tests/codegen-units/item-collection/unused-traits-and-generics.rs b/tests/codegen-units/item-collection/unused-traits-and-generics.rs index 27cdae2c096..d5088d3f893 100644 --- a/tests/codegen-units/item-collection/unused-traits-and-generics.rs +++ b/tests/codegen-units/item-collection/unused-traits-and-generics.rs @@ -1,6 +1,6 @@ //@ compile-flags:-Zprint-mono-items=eager -#![crate_type="lib"] +#![crate_type = "lib"] #![deny(dead_code)] // This test asserts that no codegen items are generated for generic items that @@ -16,7 +16,7 @@ pub fn foo(x: T) -> (T, T) { } pub struct Struct { - x: T + x: T, } impl Struct { @@ -29,7 +29,7 @@ pub fn bar() {} pub enum Enum { A(T), - B { x: T } + B { x: T }, } impl Enum { @@ -56,7 +56,7 @@ pub fn bar() {} pub type Pair = (T, T); pub struct NonGeneric { - x: i32 + x: i32, } impl NonGeneric { diff --git a/tests/codegen-units/partitioning/auxiliary/shared_generics_aux.rs b/tests/codegen-units/partitioning/auxiliary/shared_generics_aux.rs index 158932d165d..b6c568ed387 100644 --- a/tests/codegen-units/partitioning/auxiliary/shared_generics_aux.rs +++ b/tests/codegen-units/partitioning/auxiliary/shared_generics_aux.rs @@ -3,7 +3,7 @@ //@ compile-flags:-Zshare-generics=yes -Copt-level=0 //@ no-prefer-dynamic -#![crate_type="rlib"] +#![crate_type = "rlib"] pub fn generic_fn(x: T, y: T) -> (T, T) { (x, y) diff --git a/tests/codegen-units/partitioning/extern-generic.rs b/tests/codegen-units/partitioning/extern-generic.rs index 0e4b6a37f71..602a5240283 100644 --- a/tests/codegen-units/partitioning/extern-generic.rs +++ b/tests/codegen-units/partitioning/extern-generic.rs @@ -3,7 +3,7 @@ //@ compile-flags:-Zprint-mono-items=eager -Zshare-generics=y #![allow(dead_code)] -#![crate_type="lib"] +#![crate_type = "lib"] //@ aux-build:cgu_generic_function.rs extern crate cgu_generic_function; diff --git a/tests/codegen-units/partitioning/inlining-from-extern-crate.rs b/tests/codegen-units/partitioning/inlining-from-extern-crate.rs index d021f467f1f..b007ffe1cb5 100644 --- a/tests/codegen-units/partitioning/inlining-from-extern-crate.rs +++ b/tests/codegen-units/partitioning/inlining-from-extern-crate.rs @@ -3,7 +3,7 @@ //@ compile-flags:-Zprint-mono-items=lazy //@ compile-flags:-Zinline-in-all-cgus -#![crate_type="lib"] +#![crate_type = "lib"] //@ aux-build:cgu_explicit_inlining.rs extern crate cgu_explicit_inlining; @@ -15,8 +15,7 @@ //~ 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] -pub fn user() -{ +pub fn user() { cgu_explicit_inlining::inlined(); cgu_explicit_inlining::always_inlined(); @@ -28,8 +27,7 @@ pub mod mod1 { use cgu_explicit_inlining; //~ MONO_ITEM fn mod1::user @@ inlining_from_extern_crate-mod1[External] - pub fn user() - { + pub fn user() { cgu_explicit_inlining::inlined(); // does not generate a monomorphization in this crate @@ -41,8 +39,7 @@ pub mod mod2 { use cgu_explicit_inlining; //~ MONO_ITEM fn mod2::user @@ inlining_from_extern_crate-mod2[External] - pub fn user() - { + pub fn user() { cgu_explicit_inlining::always_inlined(); // does not generate a monomorphization in this crate diff --git a/tests/codegen-units/partitioning/local-generic.rs b/tests/codegen-units/partitioning/local-generic.rs index 06f46b23db6..0cfc572650c 100644 --- a/tests/codegen-units/partitioning/local-generic.rs +++ b/tests/codegen-units/partitioning/local-generic.rs @@ -3,13 +3,15 @@ //@ compile-flags:-Zprint-mono-items=eager #![allow(dead_code)] -#![crate_type="lib"] +#![crate_type = "lib"] //~ MONO_ITEM fn generic:: @@ local_generic.volatile[External] //~ MONO_ITEM fn generic:: @@ local_generic.volatile[External] //~ MONO_ITEM fn generic:: @@ local_generic.volatile[External] //~ MONO_ITEM fn generic::<&str> @@ local_generic.volatile[External] -pub fn generic(x: T) -> T { x } +pub fn generic(x: T) -> T { + x +} //~ MONO_ITEM fn user @@ local_generic[Internal] fn user() { diff --git a/tests/codegen-units/partitioning/local-inlining-but-not-all.rs b/tests/codegen-units/partitioning/local-inlining-but-not-all.rs index 2f9cbe83f1d..454de255254 100644 --- a/tests/codegen-units/partitioning/local-inlining-but-not-all.rs +++ b/tests/codegen-units/partitioning/local-inlining-but-not-all.rs @@ -4,16 +4,13 @@ //@ compile-flags:-Zinline-in-all-cgus=no #![allow(dead_code)] -#![crate_type="lib"] +#![crate_type = "lib"] mod inline { //~ MONO_ITEM fn inline::inlined_function @@ local_inlining_but_not_all-inline[External] #[inline] - pub fn inlined_function() - { - - } + pub fn inlined_function() {} } pub mod user1 { @@ -37,7 +34,5 @@ pub fn bar() { pub mod non_user { //~ MONO_ITEM fn non_user::baz @@ local_inlining_but_not_all-non_user[External] - pub fn baz() { - - } + pub fn baz() {} } diff --git a/tests/codegen-units/partitioning/local-inlining.rs b/tests/codegen-units/partitioning/local-inlining.rs index 2329a876c96..42c68b5c621 100644 --- a/tests/codegen-units/partitioning/local-inlining.rs +++ b/tests/codegen-units/partitioning/local-inlining.rs @@ -4,17 +4,14 @@ //@ compile-flags:-Zinline-in-all-cgus #![allow(dead_code)] -#![crate_type="lib"] +#![crate_type = "lib"] mod inline { // 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] #[inline(always)] - pub fn inlined_function() - { - - } + pub fn inlined_function() {} } pub mod user1 { @@ -38,7 +35,5 @@ pub fn bar() { pub mod non_user { //~ MONO_ITEM fn non_user::baz @@ local_inlining-non_user[External] - pub fn baz() { - - } + pub fn baz() {} } diff --git a/tests/codegen-units/partitioning/local-transitive-inlining.rs b/tests/codegen-units/partitioning/local-transitive-inlining.rs index 4ccc53aea1d..0d279ebe740 100644 --- a/tests/codegen-units/partitioning/local-transitive-inlining.rs +++ b/tests/codegen-units/partitioning/local-transitive-inlining.rs @@ -4,16 +4,13 @@ //@ compile-flags:-Zinline-in-all-cgus #![allow(dead_code)] -#![crate_type="rlib"] +#![crate_type = "rlib"] mod inline { //~ MONO_ITEM fn inline::inlined_function @@ local_transitive_inlining-indirect_user[Internal] #[inline(always)] - pub fn inlined_function() - { - - } + pub fn inlined_function() {} } mod direct_user { @@ -38,7 +35,5 @@ pub fn bar() { pub mod non_user { //~ MONO_ITEM fn non_user::baz @@ local_transitive_inlining-non_user[External] - pub fn baz() { - - } + pub fn baz() {} } diff --git a/tests/codegen-units/partitioning/methods-are-with-self-type.rs b/tests/codegen-units/partitioning/methods-are-with-self-type.rs index 3ba53334cc9..901e7507d73 100644 --- a/tests/codegen-units/partitioning/methods-are-with-self-type.rs +++ b/tests/codegen-units/partitioning/methods-are-with-self-type.rs @@ -15,7 +15,7 @@ struct SomeGenericType(T1, T2); mod mod1 { - use super::{SomeType, SomeGenericType}; + use super::{SomeGenericType, SomeType}; // Even though the impl is in `mod1`, the methods should end up in the // parent module, since that is where their self-type is. @@ -40,8 +40,7 @@ fn default(&self) {} // We provide an implementation of `Trait` for all types. The corresponding // monomorphizations should end up in whichever module the concrete `T` is. -impl Trait for T -{ +impl Trait for T { fn foo(&self) {} } diff --git a/tests/codegen-units/partitioning/regular-modules.rs b/tests/codegen-units/partitioning/regular-modules.rs index 68601975d06..29497146415 100644 --- a/tests/codegen-units/partitioning/regular-modules.rs +++ b/tests/codegen-units/partitioning/regular-modules.rs @@ -3,7 +3,7 @@ //@ compile-flags:-Zprint-mono-items=eager #![allow(dead_code)] -#![crate_type="lib"] +#![crate_type = "lib"] //~ MONO_ITEM fn foo @@ regular_modules[Internal] fn foo() {} diff --git a/tests/codegen-units/partitioning/shared-generics.rs b/tests/codegen-units/partitioning/shared-generics.rs index 5b78794316c..ea312719ac9 100644 --- a/tests/codegen-units/partitioning/shared-generics.rs +++ b/tests/codegen-units/partitioning/shared-generics.rs @@ -4,14 +4,13 @@ //@ incremental //@ compile-flags:-Zprint-mono-items=eager -Zshare-generics=yes -Copt-level=0 -#![crate_type="rlib"] +#![crate_type = "rlib"] //@ aux-build:shared_generics_aux.rs extern crate shared_generics_aux; //~ MONO_ITEM fn foo pub fn foo() { - //~ MONO_ITEM fn shared_generics_aux::generic_fn:: @@ shared_generics_aux-in-shared_generics.volatile[External] let _ = shared_generics_aux::generic_fn(0u16, 1u16); diff --git a/tests/codegen-units/partitioning/statics.rs b/tests/codegen-units/partitioning/statics.rs index c7eef1f3789..00dd6d877e1 100644 --- a/tests/codegen-units/partitioning/statics.rs +++ b/tests/codegen-units/partitioning/statics.rs @@ -2,7 +2,7 @@ //@ incremental //@ compile-flags:-Zprint-mono-items=lazy -#![crate_type="rlib"] +#![crate_type = "rlib"] //~ MONO_ITEM static FOO @@ statics[Internal] static FOO: u32 = 0; diff --git a/tests/codegen-units/partitioning/vtable-through-const.rs b/tests/codegen-units/partitioning/vtable-through-const.rs index f91c0c0bfdb..a9186cea9c8 100644 --- a/tests/codegen-units/partitioning/vtable-through-const.rs +++ b/tests/codegen-units/partitioning/vtable-through-const.rs @@ -28,20 +28,24 @@ pub trait Trait1Gen { } impl Trait1Gen for NeedsDrop { - fn do_something(&self, x: T) -> T { x } - fn do_something_else(&self, x: T) -> T { x } + fn do_something(&self, x: T) -> T { + x + } + fn do_something_else(&self, x: T) -> T { + x + } } //~ MONO_ITEM fn mod1::id:: @@ vtable_through_const-mod1.volatile[Internal] - fn id(x: T) -> T { x } + fn id(x: T) -> T { + x + } // These are referenced, so they produce mono-items (see start()) pub const TRAIT1_REF: &'static Trait1 = &NeedsDrop as &Trait1; pub const TRAIT1_GEN_REF: &'static Trait1Gen = &NeedsDrop as &Trait1Gen; pub const ID_CHAR: fn(char) -> char = id::; - - pub trait Trait2 { fn do_something(&self) {} fn do_something_else(&self) {} @@ -57,8 +61,12 @@ pub trait Trait2Gen { } impl Trait2Gen for NeedsDrop { - fn do_something(&self, x: T) -> T { x } - fn do_something_else(&self, x: T) -> T { x } + fn do_something(&self, x: T) -> T { + x + } + fn do_something_else(&self, x: T) -> T { + x + } } // These are not referenced, so they do not produce mono-items diff --git a/tests/codegen-units/polymorphization/unused_type_parameters.rs b/tests/codegen-units/polymorphization/unused_type_parameters.rs index cf5f7c32098..438305f112f 100644 --- a/tests/codegen-units/polymorphization/unused_type_parameters.rs +++ b/tests/codegen-units/polymorphization/unused_type_parameters.rs @@ -9,54 +9,51 @@ mod functions { // Function doesn't have any type parameters to be unused. pub fn no_parameters() {} -//~ MONO_ITEM fn functions::no_parameters + //~ MONO_ITEM fn functions::no_parameters // Function has an unused type parameter. - pub fn unused() { - } + pub fn unused() {} -//~ MONO_ITEM fn functions::unused:: + //~ MONO_ITEM fn functions::unused:: // Function uses type parameter in value of a binding. pub fn used_binding_value() { let _: T = Default::default(); } -//~ MONO_ITEM fn functions::used_binding_value:: -//~ MONO_ITEM fn functions::used_binding_value:: + //~ MONO_ITEM fn functions::used_binding_value:: + //~ MONO_ITEM fn functions::used_binding_value:: // Function uses type parameter in type of a binding. pub fn used_binding_type() { let _: Option = None; } -//~ MONO_ITEM fn functions::used_binding_type:: -//~ MONO_ITEM fn functions::used_binding_type:: + //~ MONO_ITEM fn functions::used_binding_type:: + //~ MONO_ITEM fn functions::used_binding_type:: // Function uses type parameter in argument. - pub fn used_argument(_: T) { - } + pub fn used_argument(_: T) {} -//~ MONO_ITEM fn functions::used_argument:: -//~ MONO_ITEM fn functions::used_argument:: -// + //~ MONO_ITEM fn functions::used_argument:: + //~ MONO_ITEM fn functions::used_argument:: + // // Function uses type parameter in substitutions to another function. pub fn used_substs() { unused::() } -//~ MONO_ITEM fn functions::used_substs:: -//~ MONO_ITEM fn functions::used_substs:: + //~ MONO_ITEM fn functions::used_substs:: + //~ MONO_ITEM fn functions::used_substs:: } - mod closures { // Function doesn't have any type parameters to be unused. pub fn no_parameters() { let _ = || {}; } -//~ MONO_ITEM fn closures::no_parameters + //~ MONO_ITEM fn closures::no_parameters // Function has an unused type parameter in parent and closure. pub fn unused() -> u32 { @@ -64,8 +61,8 @@ pub fn unused() -> u32 { add_one(3) } -//~ MONO_ITEM fn closures::unused::::{closure#0} -//~ MONO_ITEM fn closures::unused:: + //~ MONO_ITEM fn closures::unused::::{closure#0} + //~ MONO_ITEM fn closures::unused:: // Function has an unused type parameter in closure, but not in parent. pub fn used_parent() -> u32 { @@ -74,9 +71,9 @@ pub fn used_parent() -> u32 { add_one(3) } -//~ MONO_ITEM fn closures::used_parent::::{closure#0} -//~ MONO_ITEM fn closures::used_parent:: -//~ MONO_ITEM fn closures::used_parent:: + //~ MONO_ITEM fn closures::used_parent::::{closure#0} + //~ MONO_ITEM fn closures::used_parent:: + //~ MONO_ITEM fn closures::used_parent:: // Function uses type parameter in value of a binding in closure. pub fn used_binding_value() -> T { @@ -88,10 +85,10 @@ pub fn used_binding_value() -> T { x() } -//~ MONO_ITEM fn closures::used_binding_value::::{closure#0} -//~ MONO_ITEM fn closures::used_binding_value::::{closure#0} -//~ MONO_ITEM fn closures::used_binding_value:: -//~ MONO_ITEM fn closures::used_binding_value:: + //~ MONO_ITEM fn closures::used_binding_value::::{closure#0} + //~ MONO_ITEM fn closures::used_binding_value::::{closure#0} + //~ MONO_ITEM fn closures::used_binding_value:: + //~ MONO_ITEM fn closures::used_binding_value:: // Function uses type parameter in type of a binding in closure. pub fn used_binding_type() -> Option { @@ -103,10 +100,10 @@ pub fn used_binding_type() -> Option { x() } -//~ MONO_ITEM fn closures::used_binding_type::::{closure#0} -//~ MONO_ITEM fn closures::used_binding_type::::{closure#0} -//~ MONO_ITEM fn closures::used_binding_type:: -//~ MONO_ITEM fn closures::used_binding_type:: + //~ MONO_ITEM fn closures::used_binding_type::::{closure#0} + //~ MONO_ITEM fn closures::used_binding_type::::{closure#0} + //~ MONO_ITEM fn closures::used_binding_type:: + //~ MONO_ITEM fn closures::used_binding_type:: // Function and closure uses type parameter in argument. pub fn used_argument(t: T) -> u32 { @@ -114,10 +111,10 @@ pub fn used_argument(t: T) -> u32 { x(t) } -//~ MONO_ITEM fn closures::used_argument::::{closure#0} -//~ MONO_ITEM fn closures::used_argument::::{closure#0} -//~ MONO_ITEM fn closures::used_argument:: -//~ MONO_ITEM fn closures::used_argument:: + //~ MONO_ITEM fn closures::used_argument::::{closure#0} + //~ MONO_ITEM fn closures::used_argument::::{closure#0} + //~ MONO_ITEM fn closures::used_argument:: + //~ MONO_ITEM fn closures::used_argument:: // Closure uses type parameter in argument. pub fn used_argument_closure() -> u32 { @@ -126,10 +123,10 @@ pub fn used_argument_closure() -> u32 { x(t) } -//~ MONO_ITEM fn closures::used_argument_closure::::{closure#0} -//~ MONO_ITEM fn closures::used_argument_closure::::{closure#0} -//~ MONO_ITEM fn closures::used_argument_closure:: -//~ MONO_ITEM fn closures::used_argument_closure:: + //~ MONO_ITEM fn closures::used_argument_closure::::{closure#0} + //~ MONO_ITEM fn closures::used_argument_closure::::{closure#0} + //~ MONO_ITEM fn closures::used_argument_closure:: + //~ MONO_ITEM fn closures::used_argument_closure:: // Closure uses type parameter as upvar. pub fn used_upvar() -> T { @@ -138,10 +135,10 @@ pub fn used_upvar() -> T { y() } -//~ MONO_ITEM fn closures::used_upvar::::{closure#0} -//~ MONO_ITEM fn closures::used_upvar::::{closure#0} -//~ MONO_ITEM fn closures::used_upvar:: -//~ MONO_ITEM fn closures::used_upvar:: + //~ MONO_ITEM fn closures::used_upvar::::{closure#0} + //~ MONO_ITEM fn closures::used_upvar::::{closure#0} + //~ MONO_ITEM fn closures::used_upvar:: + //~ MONO_ITEM fn closures::used_upvar:: // Closure uses type parameter in substitutions to another function. pub fn used_substs() { @@ -149,10 +146,10 @@ pub fn used_substs() { x() } -//~ MONO_ITEM fn closures::used_substs::::{closure#0} -//~ MONO_ITEM fn closures::used_substs::::{closure#0} -//~ MONO_ITEM fn closures::used_substs:: -//~ MONO_ITEM fn closures::used_substs:: + //~ MONO_ITEM fn closures::used_substs::::{closure#0} + //~ MONO_ITEM fn closures::used_substs::::{closure#0} + //~ MONO_ITEM fn closures::used_substs:: + //~ MONO_ITEM fn closures::used_substs:: } mod methods { @@ -160,32 +157,30 @@ mod methods { impl Foo { // Function has an unused type parameter from impl. - pub fn unused_impl() { - } + pub fn unused_impl() {} -//~ MONO_ITEM fn methods::Foo::::unused_impl + //~ MONO_ITEM fn methods::Foo::::unused_impl // Function has an unused type parameter from impl and fn. - pub fn unused_both() { - } + pub fn unused_both() {} -//~ MONO_ITEM fn methods::Foo::::unused_both:: + //~ MONO_ITEM fn methods::Foo::::unused_both:: // Function uses type parameter from impl. pub fn used_impl() { let _: F = Default::default(); } -//~ MONO_ITEM fn methods::Foo::::used_impl -//~ MONO_ITEM fn methods::Foo::::used_impl + //~ MONO_ITEM fn methods::Foo::::used_impl + //~ MONO_ITEM fn methods::Foo::::used_impl // Function uses type parameter from impl. pub fn used_fn() { let _: G = Default::default(); } -//~ MONO_ITEM fn methods::Foo::::used_fn:: -//~ MONO_ITEM fn methods::Foo::::used_fn:: + //~ MONO_ITEM fn methods::Foo::::used_fn:: + //~ MONO_ITEM fn methods::Foo::::used_fn:: // Function uses type parameter from impl. pub fn used_both() { @@ -193,16 +188,16 @@ pub fn used_both() { let _: G = Default::default(); } -//~ MONO_ITEM fn methods::Foo::::used_both:: -//~ MONO_ITEM fn methods::Foo::::used_both:: + //~ MONO_ITEM fn methods::Foo::::used_both:: + //~ MONO_ITEM fn methods::Foo::::used_both:: // Function uses type parameter in substitutions to another function. pub fn used_substs() { super::functions::unused::() } -//~ MONO_ITEM fn methods::Foo::::used_substs -//~ MONO_ITEM fn methods::Foo::::used_substs + //~ MONO_ITEM fn methods::Foo::::used_substs + //~ MONO_ITEM fn methods::Foo::::used_substs // Function has an unused type parameter from impl and fn. pub fn closure_unused_all() -> u32 { @@ -210,8 +205,8 @@ pub fn closure_unused_all() -> u32 { add_one(3) } -//~ MONO_ITEM fn methods::Foo::::closure_unused_all::::{closure#0} -//~ MONO_ITEM fn methods::Foo::::closure_unused_all:: + //~ MONO_ITEM fn methods::Foo::::closure_unused_all::::{closure#0} + //~ MONO_ITEM fn methods::Foo::::closure_unused_all:: // Function uses type parameter from impl and fn in closure. pub fn closure_used_both() -> u32 { @@ -224,10 +219,10 @@ pub fn closure_used_both() -> u32 { add_one(3) } -//~ MONO_ITEM fn methods::Foo::::closure_used_both::::{closure#0} -//~ MONO_ITEM fn methods::Foo::::closure_used_both::::{closure#0} -//~ MONO_ITEM fn methods::Foo::::closure_used_both:: -//~ MONO_ITEM fn methods::Foo::::closure_used_both:: + //~ MONO_ITEM fn methods::Foo::::closure_used_both::::{closure#0} + //~ MONO_ITEM fn methods::Foo::::closure_used_both::::{closure#0} + //~ MONO_ITEM fn methods::Foo::::closure_used_both:: + //~ MONO_ITEM fn methods::Foo::::closure_used_both:: // Function uses type parameter from fn in closure. pub fn closure_used_fn() -> u32 { @@ -239,10 +234,10 @@ pub fn closure_used_fn() -> u32 { add_one(3) } -//~ MONO_ITEM fn methods::Foo::::closure_used_fn::::{closure#0} -//~ MONO_ITEM fn methods::Foo::::closure_used_fn::::{closure#0} -//~ MONO_ITEM fn methods::Foo::::closure_used_fn:: -//~ MONO_ITEM fn methods::Foo::::closure_used_fn:: + //~ MONO_ITEM fn methods::Foo::::closure_used_fn::::{closure#0} + //~ MONO_ITEM fn methods::Foo::::closure_used_fn::::{closure#0} + //~ MONO_ITEM fn methods::Foo::::closure_used_fn:: + //~ MONO_ITEM fn methods::Foo::::closure_used_fn:: // Function uses type parameter from impl in closure. pub fn closure_used_impl() -> u32 { @@ -254,10 +249,10 @@ pub fn closure_used_impl() -> u32 { add_one(3) } -//~ MONO_ITEM fn methods::Foo::::closure_used_impl::::{closure#0} -//~ MONO_ITEM fn methods::Foo::::closure_used_impl::::{closure#0} -//~ MONO_ITEM fn methods::Foo::::closure_used_impl:: -//~ MONO_ITEM fn methods::Foo::::closure_used_impl:: + //~ MONO_ITEM fn methods::Foo::::closure_used_impl::::{closure#0} + //~ MONO_ITEM fn methods::Foo::::closure_used_impl::::{closure#0} + //~ MONO_ITEM fn methods::Foo::::closure_used_impl:: + //~ MONO_ITEM fn methods::Foo::::closure_used_impl:: // Closure uses type parameter in substitutions to another function. pub fn closure_used_substs() { @@ -265,15 +260,13 @@ pub fn closure_used_substs() { x() } -//~ MONO_ITEM fn methods::Foo::::closure_used_substs::{closure#0} -//~ MONO_ITEM fn methods::Foo::::closure_used_substs::{closure#0} -//~ MONO_ITEM fn methods::Foo::::closure_used_substs -//~ MONO_ITEM fn methods::Foo::::closure_used_substs + //~ MONO_ITEM fn methods::Foo::::closure_used_substs::{closure#0} + //~ MONO_ITEM fn methods::Foo::::closure_used_substs::{closure#0} + //~ MONO_ITEM fn methods::Foo::::closure_used_substs + //~ MONO_ITEM fn methods::Foo::::closure_used_substs } } - - fn dispatch() { functions::no_parameters(); functions::unused::();