From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/tools/rustfmt/tests/source/type.rs | 168 +++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 src/tools/rustfmt/tests/source/type.rs (limited to 'src/tools/rustfmt/tests/source/type.rs') diff --git a/src/tools/rustfmt/tests/source/type.rs b/src/tools/rustfmt/tests/source/type.rs new file mode 100644 index 000000000..61ef73a3c --- /dev/null +++ b/src/tools/rustfmt/tests/source/type.rs @@ -0,0 +1,168 @@ +// rustfmt-normalize_comments: true +fn types() { + let x: [ Vec < _ > ] = []; + let y: * mut [ SomeType ; konst_funk() ] = expr(); + let z: (/*#digits*/ usize, /*exp*/ i16) = funk(); + let z: ( usize /*#digits*/ , i16 /*exp*/ ) = funk(); +} + +struct F { + f: extern "C" fn(x: u8, ... /* comment */), + g: extern "C" fn(x: u8,/* comment */ ...), + h: extern "C" fn(x: u8, ... ), + i: extern "C" fn(x: u8, /* comment 4*/ y: String, // comment 3 + z: Foo, /* comment */ .../* comment 2*/ ), +} + +fn issue_1006(def_id_to_string: for<'a, 'b> unsafe fn(TyCtxt<'b, 'tcx, 'tcx>, DefId) -> String) {} + +fn impl_trait_fn_1() -> impl Fn(i32) -> Option {} + +fn impl_trait_fn_2() -> impl Future {} + +fn issue_1234() { + do_parse!(name: take_while1!(is_token) >> (Header)) +} + +// #2510 +impl CombineTypes { + pub fn pop_callback( + &self, + query_id: Uuid, + ) -> Option< + ( + ProjectId, + Box () + Sync + Send>, + ), + > { + self.query_callbacks()(&query_id) + } +} + +// #2859 +pub fn do_something<'a, T: Trait1 + Trait2 + 'a>(&fooo: u32) -> impl Future< + Item = ( + impl Future + 'a, + impl Future + 'a, +impl Future + 'a, + ), + Error = SomeError, + > + + + 'a { +} + +pub fn do_something<'a, T: Trait1 + Trait2 + 'a>( &fooo: u32, +) -> impl Future< + Item = ( +impl Future + 'a, + impl Future + 'a, + impl Future + 'a, + ), + Error = SomeError, + > + + Future< + Item = ( + impl Future + 'a, +impl Future + 'a, + impl Future + 'a, + ), + Error = SomeError, + > + + Future< + Item = ( + impl Future + 'a, + impl Future + 'a, + impl Future + 'a, + ), + Error = SomeError, + > + + + 'a + 'b + + 'c { +} + +// #3051 +token![impl]; +token![ impl ]; + +// #3060 +macro_rules! foo { + ($foo_api: ty) => { + type Target = ( $foo_api ) + 'static; + } +} + +type Target = ( FooAPI ) + 'static; + +// #3137 +fn foo(t: T) +where + T: ( FnOnce() -> () ) + Clone, + U: ( FnOnce() -> () ) + 'static, +{ +} + +// #3117 +fn issue3117() { + { + { + { + { + { + { + { + { + let opt: &mut Option = + unsafe { &mut *self.future.get() }; + } + } + } + } + } + } + } + } +} + +// #3139 +fn issue3139() { + assert_eq!( + to_json_value(&None :: ).unwrap(), + json!( { "test": None :: } ) + ); +} + +// #3180 +fn foo(a: SomeLongComplexType, b: SomeOtherLongComplexType) -> Box> { +} + +type MyFn = fn(a: SomeLongComplexType, b: SomeOtherLongComplexType,) -> Box>; + +// Const bound + +trait T: ~ const Super {} + +const fn not_quite_const() -> i32 { ::CONST } + +struct S(std::marker::PhantomData); + +impl ~ const T {} + +fn apit(_: impl ~ const T) {} + +fn rpit() -> impl ~ const T { S } + +pub struct Foo(T); +impl Foo { + fn new(t: T) -> Self { + Self(t) + } +} + +// #4357 +type T = typeof( +1); +impl T for .. { +} -- cgit v1.2.3