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/impls.rs | 178 ++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 src/tools/rustfmt/tests/source/impls.rs (limited to 'src/tools/rustfmt/tests/source/impls.rs') diff --git a/src/tools/rustfmt/tests/source/impls.rs b/src/tools/rustfmt/tests/source/impls.rs new file mode 100644 index 000000000..dcd1f0cd5 --- /dev/null +++ b/src/tools/rustfmt/tests/source/impls.rs @@ -0,0 +1,178 @@ +// rustfmt-normalize_comments: true +impl Foo for Bar { fn foo() { "hi" } } + +pub impl Foo for Bar { + // Associated Constants + const Baz: i32 = 16; + // Associated Types + type FooBar = usize; + // Comment 1 + fn foo() { "hi" } + // Comment 2 + fn foo() { "hi" } + // Comment 3 +} + +#[inherent] +impl Visible for Bar { + pub const C: i32; + pub type T; + pub fn f(); + pub fn g() {} +} + +pub unsafe impl<'a, 'b, X, Y: Foo> !Foo<'a, X> for Bar<'b, Y> where X: Foo<'a, Z> { + fn foo() { "hi" } +} + +impl<'a, 'b, X, Y: Foo> Foo<'a, X> for Bar<'b, Y> where X: Fooooooooooooooooooooooooooooo<'a, Z> +{ + fn foo() { "hi" } +} + +impl<'a, 'b, X, Y: Foo> Foo<'a, X> for Bar<'b, Y> where X: Foooooooooooooooooooooooooooo<'a, Z> +{ + fn foo() { "hi" } +} + +impl Foo for Bar where T: Baz +{ +} + +impl Foo for Bar where T: Baz { /* Comment */ } + +impl Foo { + fn foo() {} +} + +impl Boo { + + // BOO + fn boo() {} + // FOO + + + +} + +mod a { + impl Foo { + // Hello! + fn foo() {} + } +} + + +mod b { + mod a { + impl Foo { + fn foo() {} + } + } +} + +impl Foo { add_fun!(); } + +impl Blah { + fn boop() {} + add_fun!(); +} + +impl X { fn do_parse( mut self : X ) {} } + +impl Y5000 { + fn bar(self: X< 'a , 'b >, y: Y) {} + + fn bad(&self, ( x, y): CoorT) {} + + fn turbo_bad(self: X< 'a , 'b > , ( x, y): CoorT) { + + } +} + +pub impl Foo for Bar where T: Foo +{ + fn foo() { "hi" } +} + +pub impl Foo for Bar where T: Foo, Z: Baz {} + +mod m { + impl PartialEq for S where T: PartialEq { + fn eq(&self, other: &Self) { + true + } + } + + impl PartialEq for S where T: PartialEq { } + } + +impl Handle, HandleType> { +} + +impl PartialEq for Handle, HandleType> { +} + +mod x { + impl Foo + where A: 'static, + B: 'static, + C: 'static, + D: 'static { } +} + +impl Issue1249 { + // Creates a new flow constructor. + fn foo() {} +} + +// #1600 +impl<#[may_dangle] K, #[may_dangle] V> Drop for RawTable { + fn drop() {} +} + +// #1168 +pub trait Number: Copy + Eq + Not + Shl + + Shr + + BitAnd + BitOr + BitAndAssign + BitOrAssign + + + +{ + // test + fn zero() -> Self; +} + +// #1642 +pub trait SomeTrait : Clone + Eq + PartialEq + Ord + PartialOrd + Default + Hash + Debug + Display + Write + Read + FromStr { + // comment +} + +// #1995 +impl Foo { + fn f( + S { + aaaaaaaaaa: aaaaaaaaaa, + bbbbbbbbbb: bbbbbbbbbb, + cccccccccc: cccccccccc, + }: S + ) -> u32{ + 1 + } +} + +// #2491 +impl<'a, 'b, 'c> SomeThing for (&'a mut SomethingLong, &'b mut SomethingLong, &'c mut SomethingLong) { + fn foo() {} +} + +// #2746 +impl<'seq1, 'seq2, 'body, 'scope, Channel> Adc12< Dual, MasterRunningDma<'seq1, 'body, 'scope, Channel>, SlaveRunningDma<'seq2, 'body, 'scope>, > where Channel: DmaChannel, {} + +// #4084 +impl const std::default::Default for Struct { + #[inline] + fn default() -> Self { + Self { f: 12.5 } + } +} -- cgit v1.2.3