From 8a3edb1d661ed5ce685bd5dcfa600b6e02897b86 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Tue, 1 Sep 2020 17:12:52 -0400 Subject: Update tests for extern block linting --- src/test/debuginfo/type-names.rs | 58 ++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 26 deletions(-) (limited to 'src/test/debuginfo') diff --git a/src/test/debuginfo/type-names.rs b/src/test/debuginfo/type-names.rs index 1e0e8beb10f..43e68fedbfa 100644 --- a/src/test/debuginfo/type-names.rs +++ b/src/test/debuginfo/type-names.rs @@ -23,7 +23,6 @@ // gdbg-check:type = struct Struct2 // gdbr-check:type = type_names::mod1::Struct2 - // ENUMS // gdb-command:whatis simple_enum_1 // gdbg-check:type = union Enum1 @@ -45,7 +44,6 @@ // gdbg-check:type = union Enum3 // gdbr-check:type = type_names::mod1::mod2::Enum3 - // TUPLES // gdb-command:whatis tuple1 // gdbg-check:type = struct (u32, type_names::Struct1, type_names::mod1::mod2::Enum3) @@ -55,7 +53,6 @@ // gdbg-check:type = struct ((type_names::Struct1, type_names::mod1::mod2::Struct3), type_names::mod1::Enum2, char) // gdbr-check:type = ((type_names::Struct1, type_names::mod1::mod2::Struct3), type_names::mod1::Enum2, char) - // BOX // gdb-command:whatis box1 // gdbg-check:type = struct (alloc::boxed::Box, i32) @@ -65,7 +62,6 @@ // gdbg-check:type = struct (alloc::boxed::Box>, i32) // gdbr-check:type = (alloc::boxed::Box>, i32) - // REFERENCES // gdb-command:whatis ref1 // gdbg-check:type = struct (&type_names::Struct1, i32) @@ -83,7 +79,6 @@ // gdbg-check:type = struct (&mut type_names::GenericStruct, i32) // gdbr-check:type = (&mut type_names::GenericStruct, i32) - // RAW POINTERS // gdb-command:whatis mut_ptr1 // gdbg-check:type = struct (*mut type_names::Struct1, isize) @@ -109,7 +104,6 @@ // gdbg-check:type = struct (*const type_names::mod1::mod2::Enum3, isize) // gdbr-check:type = (*const type_names::mod1::mod2::Enum3, isize) - // VECTORS // gdb-command:whatis fixed_size_vec1 // gdbg-check:type = struct ([type_names::Struct1; 3], i16) @@ -127,7 +121,6 @@ // gdbg-check:type = struct &[type_names::mod1::Enum2] // gdbr-check:type = &[type_names::mod1::Enum2] - // TRAITS // gdb-command:whatis box_trait // gdbg-check:type = struct Box @@ -153,7 +146,6 @@ // gdbg-check:type = struct &mut Trait2> // gdbr-check:type = type_names::&mut Trait2> - // BARE FUNCTIONS // gdb-command:whatis rust_fn // gdbg-check:type = struct (fn(core::option::Option, core::option::Option<&type_names::mod1::Struct2>), usize) @@ -199,7 +191,6 @@ // gdbg-check:type = struct (unsafe extern "C" fn(*const u8, ...) -> isize, usize) // gdbr-check:type = (unsafe extern "C" fn(*const u8, ...) -> isize, usize) - // CLOSURES // gdb-command:whatis closure1 // gdbg-check:type = struct (closure, usize) @@ -219,7 +210,7 @@ use std::marker::PhantomData; use std::ptr; pub struct Struct1; -struct GenericStruct(PhantomData<(T1,T2)>); +struct GenericStruct(PhantomData<(T1, T2)>); enum Enum1 { Variant1, @@ -246,8 +237,12 @@ mod mod1 { } } -trait Trait1 { fn dummy(&self) { } } -trait Trait2 { fn dummy(&self, _: T1, _:T2) { } } +trait Trait1 { + fn dummy(&self) {} +} +trait Trait2 { + fn dummy(&self, _: T1, _: T2) {} +} impl Trait1 for isize {} impl Trait2 for isize {} @@ -257,16 +252,26 @@ extern "C" fn extern_c_fn(_: isize) {} unsafe fn unsafe_fn(_: Result) {} extern "stdcall" fn extern_stdcall_fn() {} -fn rust_fn_with_return_value(_: f64) -> usize { 4 } -extern "C" fn extern_c_fn_with_return_value() -> Struct1 { Struct1 } -unsafe fn unsafe_fn_with_return_value(_: GenericStruct) -> mod1::Struct2 { mod1::Struct2 } -extern "stdcall" fn extern_stdcall_fn_with_return_value(_: Box) -> usize { 0 } +fn rust_fn_with_return_value(_: f64) -> usize { + 4 +} +extern "C" fn extern_c_fn_with_return_value() -> Struct1 { + Struct1 +} +unsafe fn unsafe_fn_with_return_value(_: GenericStruct) -> mod1::Struct2 { + mod1::Struct2 +} +extern "stdcall" fn extern_stdcall_fn_with_return_value(_: Box) -> usize { + 0 +} -fn generic_function(x: T) -> T { x } +fn generic_function(x: T) -> T { + x +} #[allow(improper_ctypes)] -extern { - fn printf(_:*const u8, ...) -> isize; +extern "C" { + fn printf(_: *const u8, ...) -> isize; } // In many of the cases below, the type that is actually under test is wrapped @@ -277,7 +282,6 @@ extern { // printed correctly, so the tests below just construct a tuple type that will // then *contain* the type name that we want to see. fn main() { - // Structs let simple_struct = Struct1; let generic_struct1: GenericStruct = @@ -336,11 +340,11 @@ fn main() { let mut_ref_trait = (&mut mut_int1) as &mut Trait1; let generic_box_trait = (box 0_isize) as Box>; - let generic_ref_trait = (&0_isize) as &Trait2; + let generic_ref_trait = (&0_isize) as &Trait2; let mut generic_mut_ref_trait_impl = 0_isize; - let generic_mut_ref_trait = (&mut generic_mut_ref_trait_impl) as - &mut Trait2>; + let generic_mut_ref_trait = (&mut generic_mut_ref_trait_impl) + as &mut Trait2>; // Bare Functions let rust_fn = (rust_fn, 0_usize); @@ -364,11 +368,13 @@ fn main() { // how that maps to rustc's internal representation of these forms. // Once closures have reached their 1.0 form, the tests below should // probably be expanded. - let closure1 = (|x:isize| {}, 0_usize); - let closure2 = (|x:i8, y: f32| { (x as f32) + y }, 0_usize); + let closure1 = (|x: isize| {}, 0_usize); + let closure2 = (|x: i8, y: f32| (x as f32) + y, 0_usize); zzz(); // #break } #[inline(never)] -fn zzz() { () } +fn zzz() { + () +} -- cgit 1.4.1-3-g733a5