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/target/fn.rs | 120 +++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 src/tools/rustfmt/tests/target/fn.rs (limited to 'src/tools/rustfmt/tests/target/fn.rs') diff --git a/src/tools/rustfmt/tests/target/fn.rs b/src/tools/rustfmt/tests/target/fn.rs new file mode 100644 index 000000000..0ad775ee1 --- /dev/null +++ b/src/tools/rustfmt/tests/target/fn.rs @@ -0,0 +1,120 @@ +// Tests different fns + +fn foo(a: AAAA, b: BBB, c: CCC) -> RetType {} + +fn foo(a: AAAA, b: BBB /* some, weird, inline comment */, c: CCC) -> RetType +where + T: Blah, +{ +} + +fn foo(a: AAA /* (comment) */) +where + T: Blah, +{ +} + +fn foo( + a: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, + b: BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB, +) -> RetType +where + T: Blah, +{ +} + +fn foo( + a: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, + b: BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB, +) -> RetType +where + T: Blah, + U: dsfasdfasdfasd, +{ +} + +fn foo B /* paren inside generics */>() {} + +impl Foo { + fn with_no_errors(&mut self, f: F) -> T + where + F: FnOnce(&mut Resolver) -> T, + { + } + + fn foo(mut self, mut bar: u32) {} + + fn bar(self, mut bazz: u32) {} +} + +pub fn render< + 'a, + N: Clone + 'a, + E: Clone + 'a, + G: Labeller<'a, N, E> + GraphWalk<'a, N, E>, + W: Write, +>( + g: &'a G, + w: &mut W, +) -> io::Result<()> { + render_opts(g, w, &[]) +} + +const fn foo() { + x; +} + +pub const fn foo() { + x; +} + +impl Foo { + const fn foo() { + x; + } +} + +fn homura>(_: T) {} + +fn issue377() -> (Box, Box) {} + +fn main() { + let _ = function(move || 5); + let _ = move || 42; + let _ = || unsafe { abort() }; +} + +// With inner attributes. +fn inner() { + #![inline] + x +} + +#[cfg_attr(rustfmt, rustfmt::skip)] +fn foo(a: i32) -> i32 { + // comment + if a > 0 { 1 } else { 2 } +} + +fn ______________________baz( + a: i32, +) -> *mut ::std::option::Option< + extern "C" fn(arg1: i32, _____________________a: i32, arg3: i32) -> (), +> { +} + +pub fn check_path<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + path: &hir::Path, + id: ast::NodeId, + cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option), +) { +} + +pub fn check_path<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + path: &hir::Path, + id: ast::NodeId, + cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option), +) { +} -- cgit v1.2.3