mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Run rustfmt on tests/codegen-units/
.
This commit is contained in:
parent
72800d3b89
commit
780a91786e
@ -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/",
|
||||||
|
@ -2,25 +2,43 @@
|
|||||||
|
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
@ -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>
|
||||||
|
@ -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)];
|
||||||
|
|
||||||
|
@ -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>})
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
//@ compile-flags:-Zprint-mono-items=eager
|
//@ compile-flags:-Zprint-mono-items=eager
|
||||||
|
|
||||||
#![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;
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
#![feature(start)]
|
#![feature(start)]
|
||||||
|
|
||||||
pub static FN : fn() = foo::<i32>;
|
pub static FN: fn() = foo::<i32>;
|
||||||
|
|
||||||
pub fn foo<T>() { }
|
pub fn foo<T>() {}
|
||||||
|
|
||||||
//~ MONO_ITEM fn foo::<T>
|
//~ MONO_ITEM fn foo::<T>
|
||||||
//~ MONO_ITEM static FN
|
//~ MONO_ITEM static FN
|
||||||
|
@ -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) {}
|
||||||
}
|
}
|
||||||
@ -48,26 +44,26 @@ impl<T> SomeGenericTrait<T> for f32 {
|
|||||||
//~ 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 <i32 as SomeTrait>::bar::<char>
|
//~ MONO_ITEM fn <i32 as SomeTrait>::bar::<char>
|
||||||
0i32.bar('x');
|
0i32.bar('x');
|
||||||
|
|
||||||
//~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::bar::<&str>
|
//~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::bar::<&str>
|
||||||
0f64.bar(0u32, "&str");
|
0f64.bar(0u32, "&str");
|
||||||
|
|
||||||
//~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::bar::<()>
|
//~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::bar::<()>
|
||||||
0f64.bar(0u32, ());
|
0f64.bar(0u32, ());
|
||||||
|
|
||||||
//~ MONO_ITEM fn <f32 as SomeGenericTrait<char>>::foo
|
//~ MONO_ITEM fn <f32 as SomeGenericTrait<char>>::foo
|
||||||
0f32.foo('x');
|
0f32.foo('x');
|
||||||
|
|
||||||
//~ MONO_ITEM fn <f32 as SomeGenericTrait<i64>>::foo
|
//~ MONO_ITEM fn <f32 as SomeGenericTrait<i64>>::foo
|
||||||
0f32.foo(-1i64);
|
0f32.foo(-1i64);
|
||||||
|
|
||||||
//~ MONO_ITEM fn <f32 as SomeGenericTrait<u32>>::bar::<()>
|
//~ MONO_ITEM fn <f32 as SomeGenericTrait<u32>>::bar::<()>
|
||||||
0f32.bar(0u32, ());
|
0f32.bar(0u32, ());
|
||||||
|
|
||||||
//~ MONO_ITEM fn <f32 as SomeGenericTrait<&str>>::bar::<&str>
|
//~ MONO_ITEM fn <f32 as SomeGenericTrait<&str>>::bar::<&str>
|
||||||
0f32.bar("&str", "&str");
|
0f32.bar("&str", "&str");
|
||||||
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,19 @@
|
|||||||
#![deny(dead_code)]
|
#![deny(dead_code)]
|
||||||
#![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)
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
#![feature(start)]
|
#![feature(start)]
|
||||||
|
|
||||||
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 {
|
||||||
@ -17,7 +19,7 @@ impl SomeTrait for i8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
trait SomeGenericTrait<T1> {
|
trait SomeGenericTrait<T1> {
|
||||||
fn foo(&self) { }
|
fn foo(&self) {}
|
||||||
fn bar<T2>(&self, x: T1, y: T2) {}
|
fn bar<T2>(&self, x: T1, y: T2) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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>;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//@ compile-flags:-Zprint-mono-items=eager
|
//@ compile-flags:-Zprint-mono-items=eager
|
||||||
|
|
||||||
#![crate_type="lib"]
|
#![crate_type = "lib"]
|
||||||
#![deny(dead_code)]
|
#![deny(dead_code)]
|
||||||
|
|
||||||
// This test asserts that no codegen items are generated for generic items that
|
// This test asserts that no codegen items are generated for generic items that
|
||||||
@ -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 {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
//@ compile-flags:-Zshare-generics=yes -Copt-level=0
|
//@ compile-flags:-Zshare-generics=yes -Copt-level=0
|
||||||
//@ no-prefer-dynamic
|
//@ no-prefer-dynamic
|
||||||
|
|
||||||
#![crate_type="rlib"]
|
#![crate_type = "rlib"]
|
||||||
|
|
||||||
pub fn generic_fn<T>(x: T, y: T) -> (T, T) {
|
pub fn generic_fn<T>(x: T, y: T) -> (T, T) {
|
||||||
(x, y)
|
(x, y)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
//@ compile-flags:-Zprint-mono-items=eager -Zshare-generics=y
|
//@ compile-flags:-Zprint-mono-items=eager -Zshare-generics=y
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![crate_type="lib"]
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
//@ aux-build:cgu_generic_function.rs
|
//@ aux-build:cgu_generic_function.rs
|
||||||
extern crate cgu_generic_function;
|
extern crate cgu_generic_function;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
//@ compile-flags:-Zprint-mono-items=lazy
|
//@ compile-flags:-Zprint-mono-items=lazy
|
||||||
//@ compile-flags:-Zinline-in-all-cgus
|
//@ compile-flags:-Zinline-in-all-cgus
|
||||||
|
|
||||||
#![crate_type="lib"]
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
//@ aux-build:cgu_explicit_inlining.rs
|
//@ aux-build:cgu_explicit_inlining.rs
|
||||||
extern crate cgu_explicit_inlining;
|
extern crate cgu_explicit_inlining;
|
||||||
@ -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
|
||||||
|
@ -3,13 +3,15 @@
|
|||||||
//@ compile-flags:-Zprint-mono-items=eager
|
//@ compile-flags:-Zprint-mono-items=eager
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![crate_type="lib"]
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
//~ MONO_ITEM fn generic::<u32> @@ local_generic.volatile[External]
|
//~ MONO_ITEM fn generic::<u32> @@ local_generic.volatile[External]
|
||||||
//~ 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() {
|
||||||
|
@ -4,16 +4,13 @@
|
|||||||
//@ compile-flags:-Zinline-in-all-cgus=no
|
//@ compile-flags:-Zinline-in-all-cgus=no
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![crate_type="lib"]
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
mod inline {
|
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() {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,17 +4,14 @@
|
|||||||
//@ compile-flags:-Zinline-in-all-cgus
|
//@ compile-flags:-Zinline-in-all-cgus
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![crate_type="lib"]
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
mod inline {
|
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() {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,13 @@
|
|||||||
//@ compile-flags:-Zinline-in-all-cgus
|
//@ compile-flags:-Zinline-in-all-cgus
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![crate_type="rlib"]
|
#![crate_type = "rlib"]
|
||||||
|
|
||||||
mod inline {
|
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() {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
//@ compile-flags:-Zprint-mono-items=eager
|
//@ compile-flags:-Zprint-mono-items=eager
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![crate_type="lib"]
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
//~ MONO_ITEM fn foo @@ regular_modules[Internal]
|
//~ MONO_ITEM fn foo @@ regular_modules[Internal]
|
||||||
fn foo() {}
|
fn foo() {}
|
||||||
|
@ -4,14 +4,13 @@
|
|||||||
//@ incremental
|
//@ incremental
|
||||||
//@ compile-flags:-Zprint-mono-items=eager -Zshare-generics=yes -Copt-level=0
|
//@ compile-flags:-Zprint-mono-items=eager -Zshare-generics=yes -Copt-level=0
|
||||||
|
|
||||||
#![crate_type="rlib"]
|
#![crate_type = "rlib"]
|
||||||
|
|
||||||
//@ aux-build:shared_generics_aux.rs
|
//@ aux-build:shared_generics_aux.rs
|
||||||
extern crate shared_generics_aux;
|
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);
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//@ incremental
|
//@ incremental
|
||||||
//@ compile-flags:-Zprint-mono-items=lazy
|
//@ compile-flags:-Zprint-mono-items=lazy
|
||||||
|
|
||||||
#![crate_type="rlib"]
|
#![crate_type = "rlib"]
|
||||||
|
|
||||||
//~ MONO_ITEM static FOO @@ statics[Internal]
|
//~ MONO_ITEM static FOO @@ statics[Internal]
|
||||||
static FOO: u32 = 0;
|
static FOO: u32 = 0;
|
||||||
|
@ -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
|
||||||
|
@ -9,54 +9,51 @@ mod functions {
|
|||||||
// 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() {}
|
||||||
|
|
||||||
//~ 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>
|
||||||
|
|
||||||
// Function uses type parameter in value of a binding.
|
// Function uses type parameter in value of a binding.
|
||||||
pub fn used_binding_value<T: Default>() {
|
pub fn used_binding_value<T: Default>() {
|
||||||
let _: T = Default::default();
|
let _: T = Default::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn functions::used_binding_value::<u32>
|
//~ MONO_ITEM fn functions::used_binding_value::<u32>
|
||||||
//~ MONO_ITEM fn functions::used_binding_value::<u64>
|
//~ MONO_ITEM fn functions::used_binding_value::<u64>
|
||||||
|
|
||||||
// Function uses type parameter in type of a binding.
|
// Function uses type parameter in type of a binding.
|
||||||
pub fn used_binding_type<T>() {
|
pub fn used_binding_type<T>() {
|
||||||
let _: Option<T> = None;
|
let _: Option<T> = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn functions::used_binding_type::<u32>
|
//~ MONO_ITEM fn functions::used_binding_type::<u32>
|
||||||
//~ 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>
|
||||||
//
|
//
|
||||||
// Function uses type parameter in substitutions to another function.
|
// Function uses type parameter in substitutions to another function.
|
||||||
pub fn used_substs<T>() {
|
pub fn used_substs<T>() {
|
||||||
unused::<T>()
|
unused::<T>()
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn functions::used_substs::<u32>
|
//~ MONO_ITEM fn functions::used_substs::<u32>
|
||||||
//~ 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() {
|
||||||
let _ = || {};
|
let _ = || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn closures::no_parameters
|
//~ MONO_ITEM fn closures::no_parameters
|
||||||
|
|
||||||
// Function has an unused type parameter in parent and closure.
|
// Function has an unused type parameter in parent and closure.
|
||||||
pub fn unused<T>() -> u32 {
|
pub fn unused<T>() -> u32 {
|
||||||
@ -64,8 +61,8 @@ mod closures {
|
|||||||
add_one(3)
|
add_one(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn closures::unused::<T>::{closure#0}
|
//~ MONO_ITEM fn closures::unused::<T>::{closure#0}
|
||||||
//~ MONO_ITEM fn closures::unused::<T>
|
//~ MONO_ITEM fn closures::unused::<T>
|
||||||
|
|
||||||
// Function has an unused type parameter in closure, but not in parent.
|
// Function has an unused type parameter in closure, but not in parent.
|
||||||
pub fn used_parent<T: Default>() -> u32 {
|
pub fn used_parent<T: Default>() -> u32 {
|
||||||
@ -74,9 +71,9 @@ mod closures {
|
|||||||
add_one(3)
|
add_one(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn closures::used_parent::<T>::{closure#0}
|
//~ MONO_ITEM fn closures::used_parent::<T>::{closure#0}
|
||||||
//~ MONO_ITEM fn closures::used_parent::<u32>
|
//~ MONO_ITEM fn closures::used_parent::<u32>
|
||||||
//~ MONO_ITEM fn closures::used_parent::<u64>
|
//~ MONO_ITEM fn closures::used_parent::<u64>
|
||||||
|
|
||||||
// Function uses type parameter in value of a binding in closure.
|
// Function uses type parameter in value of a binding in closure.
|
||||||
pub fn used_binding_value<T: Default>() -> T {
|
pub fn used_binding_value<T: Default>() -> T {
|
||||||
@ -88,10 +85,10 @@ mod closures {
|
|||||||
x()
|
x()
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn closures::used_binding_value::<u32>::{closure#0}
|
//~ MONO_ITEM fn closures::used_binding_value::<u32>::{closure#0}
|
||||||
//~ MONO_ITEM fn closures::used_binding_value::<u64>::{closure#0}
|
//~ MONO_ITEM fn closures::used_binding_value::<u64>::{closure#0}
|
||||||
//~ MONO_ITEM fn closures::used_binding_value::<u32>
|
//~ MONO_ITEM fn closures::used_binding_value::<u32>
|
||||||
//~ MONO_ITEM fn closures::used_binding_value::<u64>
|
//~ MONO_ITEM fn closures::used_binding_value::<u64>
|
||||||
|
|
||||||
// Function uses type parameter in type of a binding in closure.
|
// Function uses type parameter in type of a binding in closure.
|
||||||
pub fn used_binding_type<T>() -> Option<T> {
|
pub fn used_binding_type<T>() -> Option<T> {
|
||||||
@ -103,10 +100,10 @@ mod closures {
|
|||||||
x()
|
x()
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn closures::used_binding_type::<u32>::{closure#0}
|
//~ MONO_ITEM fn closures::used_binding_type::<u32>::{closure#0}
|
||||||
//~ MONO_ITEM fn closures::used_binding_type::<u64>::{closure#0}
|
//~ MONO_ITEM fn closures::used_binding_type::<u64>::{closure#0}
|
||||||
//~ MONO_ITEM fn closures::used_binding_type::<u32>
|
//~ MONO_ITEM fn closures::used_binding_type::<u32>
|
||||||
//~ MONO_ITEM fn closures::used_binding_type::<u64>
|
//~ MONO_ITEM fn closures::used_binding_type::<u64>
|
||||||
|
|
||||||
// Function and closure uses type parameter in argument.
|
// Function and closure uses type parameter in argument.
|
||||||
pub fn used_argument<T>(t: T) -> u32 {
|
pub fn used_argument<T>(t: T) -> u32 {
|
||||||
@ -114,10 +111,10 @@ mod closures {
|
|||||||
x(t)
|
x(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn closures::used_argument::<u32>::{closure#0}
|
//~ MONO_ITEM fn closures::used_argument::<u32>::{closure#0}
|
||||||
//~ MONO_ITEM fn closures::used_argument::<u64>::{closure#0}
|
//~ MONO_ITEM fn closures::used_argument::<u64>::{closure#0}
|
||||||
//~ MONO_ITEM fn closures::used_argument::<u32>
|
//~ MONO_ITEM fn closures::used_argument::<u32>
|
||||||
//~ MONO_ITEM fn closures::used_argument::<u64>
|
//~ MONO_ITEM fn closures::used_argument::<u64>
|
||||||
|
|
||||||
// Closure uses type parameter in argument.
|
// Closure uses type parameter in argument.
|
||||||
pub fn used_argument_closure<T: Default>() -> u32 {
|
pub fn used_argument_closure<T: Default>() -> u32 {
|
||||||
@ -126,10 +123,10 @@ mod closures {
|
|||||||
x(t)
|
x(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn closures::used_argument_closure::<u32>::{closure#0}
|
//~ MONO_ITEM fn closures::used_argument_closure::<u32>::{closure#0}
|
||||||
//~ MONO_ITEM fn closures::used_argument_closure::<u64>::{closure#0}
|
//~ MONO_ITEM fn closures::used_argument_closure::<u64>::{closure#0}
|
||||||
//~ MONO_ITEM fn closures::used_argument_closure::<u32>
|
//~ MONO_ITEM fn closures::used_argument_closure::<u32>
|
||||||
//~ MONO_ITEM fn closures::used_argument_closure::<u64>
|
//~ MONO_ITEM fn closures::used_argument_closure::<u64>
|
||||||
|
|
||||||
// Closure uses type parameter as upvar.
|
// Closure uses type parameter as upvar.
|
||||||
pub fn used_upvar<T: Default>() -> T {
|
pub fn used_upvar<T: Default>() -> T {
|
||||||
@ -138,10 +135,10 @@ mod closures {
|
|||||||
y()
|
y()
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn closures::used_upvar::<u32>::{closure#0}
|
//~ MONO_ITEM fn closures::used_upvar::<u32>::{closure#0}
|
||||||
//~ MONO_ITEM fn closures::used_upvar::<u64>::{closure#0}
|
//~ MONO_ITEM fn closures::used_upvar::<u64>::{closure#0}
|
||||||
//~ MONO_ITEM fn closures::used_upvar::<u32>
|
//~ MONO_ITEM fn closures::used_upvar::<u32>
|
||||||
//~ MONO_ITEM fn closures::used_upvar::<u64>
|
//~ MONO_ITEM fn closures::used_upvar::<u64>
|
||||||
|
|
||||||
// Closure uses type parameter in substitutions to another function.
|
// Closure uses type parameter in substitutions to another function.
|
||||||
pub fn used_substs<T>() {
|
pub fn used_substs<T>() {
|
||||||
@ -149,10 +146,10 @@ mod closures {
|
|||||||
x()
|
x()
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn closures::used_substs::<u32>::{closure#0}
|
//~ MONO_ITEM fn closures::used_substs::<u32>::{closure#0}
|
||||||
//~ MONO_ITEM fn closures::used_substs::<u64>::{closure#0}
|
//~ MONO_ITEM fn closures::used_substs::<u64>::{closure#0}
|
||||||
//~ MONO_ITEM fn closures::used_substs::<u32>
|
//~ MONO_ITEM fn closures::used_substs::<u32>
|
||||||
//~ MONO_ITEM fn closures::used_substs::<u64>
|
//~ MONO_ITEM fn closures::used_substs::<u64>
|
||||||
}
|
}
|
||||||
|
|
||||||
mod methods {
|
mod methods {
|
||||||
@ -160,32 +157,30 @@ 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>
|
||||||
|
|
||||||
// Function uses type parameter from impl.
|
// Function uses type parameter from impl.
|
||||||
pub fn used_impl() {
|
pub fn used_impl() {
|
||||||
let _: F = Default::default();
|
let _: F = Default::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn methods::Foo::<u32>::used_impl
|
//~ MONO_ITEM fn methods::Foo::<u32>::used_impl
|
||||||
//~ MONO_ITEM fn methods::Foo::<u64>::used_impl
|
//~ MONO_ITEM fn methods::Foo::<u64>::used_impl
|
||||||
|
|
||||||
// Function uses type parameter from impl.
|
// Function uses type parameter from impl.
|
||||||
pub fn used_fn<G: Default>() {
|
pub fn used_fn<G: Default>() {
|
||||||
let _: G = Default::default();
|
let _: G = Default::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn methods::Foo::<F>::used_fn::<u32>
|
//~ MONO_ITEM fn methods::Foo::<F>::used_fn::<u32>
|
||||||
//~ MONO_ITEM fn methods::Foo::<F>::used_fn::<u64>
|
//~ MONO_ITEM fn methods::Foo::<F>::used_fn::<u64>
|
||||||
|
|
||||||
// Function uses type parameter from impl.
|
// Function uses type parameter from impl.
|
||||||
pub fn used_both<G: Default>() {
|
pub fn used_both<G: Default>() {
|
||||||
@ -193,16 +188,16 @@ mod methods {
|
|||||||
let _: G = Default::default();
|
let _: G = Default::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn methods::Foo::<u32>::used_both::<u32>
|
//~ MONO_ITEM fn methods::Foo::<u32>::used_both::<u32>
|
||||||
//~ MONO_ITEM fn methods::Foo::<u64>::used_both::<u64>
|
//~ MONO_ITEM fn methods::Foo::<u64>::used_both::<u64>
|
||||||
|
|
||||||
// Function uses type parameter in substitutions to another function.
|
// Function uses type parameter in substitutions to another function.
|
||||||
pub fn used_substs() {
|
pub fn used_substs() {
|
||||||
super::functions::unused::<F>()
|
super::functions::unused::<F>()
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn methods::Foo::<u32>::used_substs
|
//~ MONO_ITEM fn methods::Foo::<u32>::used_substs
|
||||||
//~ MONO_ITEM fn methods::Foo::<u64>::used_substs
|
//~ MONO_ITEM fn methods::Foo::<u64>::used_substs
|
||||||
|
|
||||||
// Function has an unused type parameter from impl and fn.
|
// Function has an unused type parameter from impl and fn.
|
||||||
pub fn closure_unused_all<G: Default>() -> u32 {
|
pub fn closure_unused_all<G: Default>() -> u32 {
|
||||||
@ -210,8 +205,8 @@ mod methods {
|
|||||||
add_one(3)
|
add_one(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn methods::Foo::<F>::closure_unused_all::<G>::{closure#0}
|
//~ MONO_ITEM fn methods::Foo::<F>::closure_unused_all::<G>::{closure#0}
|
||||||
//~ MONO_ITEM fn methods::Foo::<F>::closure_unused_all::<G>
|
//~ MONO_ITEM fn methods::Foo::<F>::closure_unused_all::<G>
|
||||||
|
|
||||||
// Function uses type parameter from impl and fn in closure.
|
// Function uses type parameter from impl and fn in closure.
|
||||||
pub fn closure_used_both<G: Default>() -> u32 {
|
pub fn closure_used_both<G: Default>() -> u32 {
|
||||||
@ -224,10 +219,10 @@ mod methods {
|
|||||||
add_one(3)
|
add_one(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_both::<u32>::{closure#0}
|
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_both::<u32>::{closure#0}
|
||||||
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_both::<u64>::{closure#0}
|
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_both::<u64>::{closure#0}
|
||||||
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_both::<u32>
|
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_both::<u32>
|
||||||
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_both::<u64>
|
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_both::<u64>
|
||||||
|
|
||||||
// Function uses type parameter from fn in closure.
|
// Function uses type parameter from fn in closure.
|
||||||
pub fn closure_used_fn<G: Default>() -> u32 {
|
pub fn closure_used_fn<G: Default>() -> u32 {
|
||||||
@ -239,10 +234,10 @@ mod methods {
|
|||||||
add_one(3)
|
add_one(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u32>::{closure#0}
|
//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u32>::{closure#0}
|
||||||
//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u64>::{closure#0}
|
//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u64>::{closure#0}
|
||||||
//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u32>
|
//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u32>
|
||||||
//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u64>
|
//~ MONO_ITEM fn methods::Foo::<F>::closure_used_fn::<u64>
|
||||||
|
|
||||||
// Function uses type parameter from impl in closure.
|
// Function uses type parameter from impl in closure.
|
||||||
pub fn closure_used_impl<G: Default>() -> u32 {
|
pub fn closure_used_impl<G: Default>() -> u32 {
|
||||||
@ -254,10 +249,10 @@ mod methods {
|
|||||||
add_one(3)
|
add_one(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_impl::<G>::{closure#0}
|
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_impl::<G>::{closure#0}
|
||||||
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_impl::<G>::{closure#0}
|
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_impl::<G>::{closure#0}
|
||||||
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_impl::<G>
|
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_impl::<G>
|
||||||
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_impl::<G>
|
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_impl::<G>
|
||||||
|
|
||||||
// Closure uses type parameter in substitutions to another function.
|
// Closure uses type parameter in substitutions to another function.
|
||||||
pub fn closure_used_substs() {
|
pub fn closure_used_substs() {
|
||||||
@ -265,15 +260,13 @@ mod methods {
|
|||||||
x()
|
x()
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_substs::{closure#0}
|
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_substs::{closure#0}
|
||||||
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_substs::{closure#0}
|
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_substs::{closure#0}
|
||||||
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_substs
|
//~ MONO_ITEM fn methods::Foo::<u32>::closure_used_substs
|
||||||
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_substs
|
//~ MONO_ITEM fn methods::Foo::<u64>::closure_used_substs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn dispatch<T: Default>() {
|
fn dispatch<T: Default>() {
|
||||||
functions::no_parameters();
|
functions::no_parameters();
|
||||||
functions::unused::<T>();
|
functions::unused::<T>();
|
||||||
|
Loading…
Reference in New Issue
Block a user